apex-grid 1.0.0-rc.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 (211) hide show
  1. package/LICENSE +0 -0
  2. package/README.md +16 -0
  3. package/dist/bundle.js +2069 -0
  4. package/dist/docs/.nojekyll +1 -0
  5. package/dist/docs/assets/highlight.css +22 -0
  6. package/dist/docs/assets/main.js +54 -0
  7. package/dist/docs/assets/search.js +1 -0
  8. package/dist/docs/assets/style.css +1257 -0
  9. package/dist/docs/classes/ApexGrid.html +240 -0
  10. package/dist/docs/index.html +79 -0
  11. package/dist/docs/interfaces/ApexCellContext.html +92 -0
  12. package/dist/docs/interfaces/ApexFilteringEvent.html +78 -0
  13. package/dist/docs/interfaces/ApexGridEventMap.html +101 -0
  14. package/dist/docs/interfaces/ApexHeaderContext.html +78 -0
  15. package/dist/docs/interfaces/ColumnConfiguration.html +168 -0
  16. package/dist/docs/interfaces/ColumnFilterConfiguration.html +76 -0
  17. package/dist/docs/interfaces/ColumnSortConfiguration.html +93 -0
  18. package/dist/docs/interfaces/FilterExpression.html +97 -0
  19. package/dist/docs/interfaces/GridRemoteConfig.html +78 -0
  20. package/dist/docs/interfaces/GridSortConfiguration.html +73 -0
  21. package/dist/docs/interfaces/SortExpression.html +111 -0
  22. package/dist/docs/modules.html +89 -0
  23. package/dist/docs/types/DataType.html +63 -0
  24. package/dist/docs/types/FilterCriteria.html +63 -0
  25. package/dist/docs/types/Keys.html +68 -0
  26. package/dist/docs/types/RemoteFilterHook.html +84 -0
  27. package/dist/docs/types/RemoteSortHook.html +84 -0
  28. package/dist/docs/types/SortState.html +68 -0
  29. package/dist/docs/types/SortingDirection.html +65 -0
  30. package/dist/docs/types/Values.html +68 -0
  31. package/dist/src/components/cell.d.ts +19 -0
  32. package/dist/src/components/cell.d.ts.map +1 -0
  33. package/dist/src/components/cell.js +45 -0
  34. package/dist/src/components/cell.js.map +1 -0
  35. package/dist/src/components/filter-row.d.ts +47 -0
  36. package/dist/src/components/filter-row.d.ts.map +1 -0
  37. package/dist/src/components/filter-row.js +307 -0
  38. package/dist/src/components/filter-row.js.map +1 -0
  39. package/dist/src/components/grid-body.d.ts +12 -0
  40. package/dist/src/components/grid-body.d.ts.map +1 -0
  41. package/dist/src/components/grid-body.js +27 -0
  42. package/dist/src/components/grid-body.js.map +1 -0
  43. package/dist/src/components/grid.d.ts +183 -0
  44. package/dist/src/components/grid.d.ts.map +1 -0
  45. package/dist/src/components/grid.js +303 -0
  46. package/dist/src/components/grid.js.map +1 -0
  47. package/dist/src/components/header-row.d.ts +23 -0
  48. package/dist/src/components/header-row.d.ts.map +1 -0
  49. package/dist/src/components/header-row.js +77 -0
  50. package/dist/src/components/header-row.js.map +1 -0
  51. package/dist/src/components/header.d.ts +23 -0
  52. package/dist/src/components/header.d.ts.map +1 -0
  53. package/dist/src/components/header.js +143 -0
  54. package/dist/src/components/header.js.map +1 -0
  55. package/dist/src/components/row.d.ts +21 -0
  56. package/dist/src/components/row.d.ts.map +1 -0
  57. package/dist/src/components/row.js +64 -0
  58. package/dist/src/components/row.js.map +1 -0
  59. package/dist/src/controllers/data-operation.d.ts +18 -0
  60. package/dist/src/controllers/data-operation.d.ts.map +1 -0
  61. package/dist/src/controllers/data-operation.js +37 -0
  62. package/dist/src/controllers/data-operation.js.map +1 -0
  63. package/dist/src/controllers/dom.d.ts +17 -0
  64. package/dist/src/controllers/dom.d.ts.map +1 -0
  65. package/dist/src/controllers/dom.js +31 -0
  66. package/dist/src/controllers/dom.js.map +1 -0
  67. package/dist/src/controllers/filter.d.ts +22 -0
  68. package/dist/src/controllers/filter.d.ts.map +1 -0
  69. package/dist/src/controllers/filter.js +79 -0
  70. package/dist/src/controllers/filter.js.map +1 -0
  71. package/dist/src/controllers/navigation.d.ts +31 -0
  72. package/dist/src/controllers/navigation.d.ts.map +1 -0
  73. package/dist/src/controllers/navigation.js +88 -0
  74. package/dist/src/controllers/navigation.js.map +1 -0
  75. package/dist/src/controllers/resize.d.ts +28 -0
  76. package/dist/src/controllers/resize.d.ts.map +1 -0
  77. package/dist/src/controllers/resize.js +70 -0
  78. package/dist/src/controllers/resize.js.map +1 -0
  79. package/dist/src/controllers/sort.d.ts +16 -0
  80. package/dist/src/controllers/sort.d.ts.map +1 -0
  81. package/dist/src/controllers/sort.js +90 -0
  82. package/dist/src/controllers/sort.js.map +1 -0
  83. package/dist/src/controllers/state.d.ts +22 -0
  84. package/dist/src/controllers/state.d.ts.map +1 -0
  85. package/dist/src/controllers/state.js +27 -0
  86. package/dist/src/controllers/state.js.map +1 -0
  87. package/dist/src/index.d.ts +12 -0
  88. package/dist/src/index.d.ts.map +1 -0
  89. package/dist/src/index.js +8 -0
  90. package/dist/src/index.js.map +1 -0
  91. package/dist/src/internal/constants.d.ts +9 -0
  92. package/dist/src/internal/constants.d.ts.map +1 -0
  93. package/dist/src/internal/constants.js +19 -0
  94. package/dist/src/internal/constants.js.map +1 -0
  95. package/dist/src/internal/icon-registry.d.ts +2 -0
  96. package/dist/src/internal/icon-registry.d.ts.map +1 -0
  97. package/dist/src/internal/icon-registry.js +29 -0
  98. package/dist/src/internal/icon-registry.js.map +1 -0
  99. package/dist/src/internal/is-defined.d.ts +2 -0
  100. package/dist/src/internal/is-defined.d.ts.map +1 -0
  101. package/dist/src/internal/is-defined.js +4 -0
  102. package/dist/src/internal/is-defined.js.map +1 -0
  103. package/dist/src/internal/mixins/event-emitter.d.ts +8 -0
  104. package/dist/src/internal/mixins/event-emitter.d.ts.map +1 -0
  105. package/dist/src/internal/mixins/event-emitter.js +18 -0
  106. package/dist/src/internal/mixins/event-emitter.js.map +1 -0
  107. package/dist/src/internal/normalize-case.d.ts +2 -0
  108. package/dist/src/internal/normalize-case.d.ts.map +1 -0
  109. package/dist/src/internal/normalize-case.js +4 -0
  110. package/dist/src/internal/normalize-case.js.map +1 -0
  111. package/dist/src/internal/part-map.d.ts +5 -0
  112. package/dist/src/internal/part-map.d.ts.map +1 -0
  113. package/dist/src/internal/part-map.js +6 -0
  114. package/dist/src/internal/part-map.js.map +1 -0
  115. package/dist/src/internal/tags.d.ts +8 -0
  116. package/dist/src/internal/tags.d.ts.map +1 -0
  117. package/dist/src/internal/tags.js +8 -0
  118. package/dist/src/internal/tags.js.map +1 -0
  119. package/dist/src/internal/types.d.ts +181 -0
  120. package/dist/src/internal/types.d.ts.map +1 -0
  121. package/dist/src/internal/types.js +2 -0
  122. package/dist/src/internal/types.js.map +1 -0
  123. package/dist/src/internal/utils.d.ts +10 -0
  124. package/dist/src/internal/utils.d.ts.map +1 -0
  125. package/dist/src/internal/utils.js +37 -0
  126. package/dist/src/internal/utils.js.map +1 -0
  127. package/dist/src/internal/watch.d.ts +6 -0
  128. package/dist/src/internal/watch.d.ts.map +1 -0
  129. package/dist/src/internal/watch.js +19 -0
  130. package/dist/src/internal/watch.js.map +1 -0
  131. package/dist/src/operations/base.d.ts +7 -0
  132. package/dist/src/operations/base.d.ts.map +1 -0
  133. package/dist/src/operations/base.js +11 -0
  134. package/dist/src/operations/base.js.map +1 -0
  135. package/dist/src/operations/filter/operands/base.d.ts +8 -0
  136. package/dist/src/operations/filter/operands/base.d.ts.map +1 -0
  137. package/dist/src/operations/filter/operands/base.js +15 -0
  138. package/dist/src/operations/filter/operands/base.js.map +1 -0
  139. package/dist/src/operations/filter/operands/boolean.d.ts +11 -0
  140. package/dist/src/operations/filter/operands/boolean.d.ts.map +1 -0
  141. package/dist/src/operations/filter/operands/boolean.js +36 -0
  142. package/dist/src/operations/filter/operands/boolean.js.map +1 -0
  143. package/dist/src/operations/filter/operands/number.d.ts +14 -0
  144. package/dist/src/operations/filter/operands/number.d.ts.map +1 -0
  145. package/dist/src/operations/filter/operands/number.js +51 -0
  146. package/dist/src/operations/filter/operands/number.js.map +1 -0
  147. package/dist/src/operations/filter/operands/string.d.ts +14 -0
  148. package/dist/src/operations/filter/operands/string.d.ts.map +1 -0
  149. package/dist/src/operations/filter/operands/string.js +52 -0
  150. package/dist/src/operations/filter/operands/string.js.map +1 -0
  151. package/dist/src/operations/filter/state.d.ts +17 -0
  152. package/dist/src/operations/filter/state.d.ts.map +1 -0
  153. package/dist/src/operations/filter/state.js +42 -0
  154. package/dist/src/operations/filter/state.js.map +1 -0
  155. package/dist/src/operations/filter/tree.d.ts +17 -0
  156. package/dist/src/operations/filter/tree.d.ts.map +1 -0
  157. package/dist/src/operations/filter/tree.js +44 -0
  158. package/dist/src/operations/filter/tree.js.map +1 -0
  159. package/dist/src/operations/filter/types.d.ts +44 -0
  160. package/dist/src/operations/filter/types.d.ts.map +1 -0
  161. package/dist/src/operations/filter/types.js +2 -0
  162. package/dist/src/operations/filter/types.js.map +1 -0
  163. package/dist/src/operations/filter.d.ts +9 -0
  164. package/dist/src/operations/filter.d.ts.map +1 -0
  165. package/dist/src/operations/filter.js +22 -0
  166. package/dist/src/operations/filter.js.map +1 -0
  167. package/dist/src/operations/sort/types.d.ts +38 -0
  168. package/dist/src/operations/sort/types.d.ts.map +1 -0
  169. package/dist/src/operations/sort/types.js +2 -0
  170. package/dist/src/operations/sort/types.js.map +1 -0
  171. package/dist/src/operations/sort.d.ts +10 -0
  172. package/dist/src/operations/sort.d.ts.map +1 -0
  173. package/dist/src/operations/sort.js +37 -0
  174. package/dist/src/operations/sort.js.map +1 -0
  175. package/dist/src/styles/body-cell/body-cell-styles.d.ts +3 -0
  176. package/dist/src/styles/body-cell/body-cell-styles.d.ts.map +1 -0
  177. package/dist/src/styles/body-cell/body-cell-styles.js +70 -0
  178. package/dist/src/styles/body-cell/body-cell-styles.js.map +1 -0
  179. package/dist/src/styles/body-row/body-row-styles.d.ts +3 -0
  180. package/dist/src/styles/body-row/body-row-styles.d.ts.map +1 -0
  181. package/dist/src/styles/body-row/body-row-styles.js +38 -0
  182. package/dist/src/styles/body-row/body-row-styles.js.map +1 -0
  183. package/dist/src/styles/filter-row/filter-row-styles.d.ts +3 -0
  184. package/dist/src/styles/filter-row/filter-row-styles.d.ts.map +1 -0
  185. package/dist/src/styles/filter-row/filter-row-styles.js +96 -0
  186. package/dist/src/styles/filter-row/filter-row-styles.js.map +1 -0
  187. package/dist/src/styles/grid/themes/light/grid.bootstrap-styles.d.ts +3 -0
  188. package/dist/src/styles/grid/themes/light/grid.bootstrap-styles.d.ts.map +1 -0
  189. package/dist/src/styles/grid/themes/light/grid.bootstrap-styles.js +82 -0
  190. package/dist/src/styles/grid/themes/light/grid.bootstrap-styles.js.map +1 -0
  191. package/dist/src/styles/grid/themes/light/grid.fluent-styles.d.ts +3 -0
  192. package/dist/src/styles/grid/themes/light/grid.fluent-styles.d.ts.map +1 -0
  193. package/dist/src/styles/grid/themes/light/grid.fluent-styles.js +82 -0
  194. package/dist/src/styles/grid/themes/light/grid.fluent-styles.js.map +1 -0
  195. package/dist/src/styles/grid/themes/light/grid.indigo-styles.d.ts +3 -0
  196. package/dist/src/styles/grid/themes/light/grid.indigo-styles.d.ts.map +1 -0
  197. package/dist/src/styles/grid/themes/light/grid.indigo-styles.js +82 -0
  198. package/dist/src/styles/grid/themes/light/grid.indigo-styles.js.map +1 -0
  199. package/dist/src/styles/grid/themes/light/grid.material-styles.d.ts +3 -0
  200. package/dist/src/styles/grid/themes/light/grid.material-styles.d.ts.map +1 -0
  201. package/dist/src/styles/grid/themes/light/grid.material-styles.js +82 -0
  202. package/dist/src/styles/grid/themes/light/grid.material-styles.js.map +1 -0
  203. package/dist/src/styles/header-cell/header-cell-styles.d.ts +3 -0
  204. package/dist/src/styles/header-cell/header-cell-styles.d.ts.map +1 -0
  205. package/dist/src/styles/header-cell/header-cell-styles.js +141 -0
  206. package/dist/src/styles/header-cell/header-cell-styles.js.map +1 -0
  207. package/dist/src/styles/header-row/header-row.base-styles.d.ts +3 -0
  208. package/dist/src/styles/header-row/header-row.base-styles.d.ts.map +1 -0
  209. package/dist/src/styles/header-row/header-row.base-styles.js +35 -0
  210. package/dist/src/styles/header-row/header-row.base-styles.js.map +1 -0
  211. package/package.json +93 -0
@@ -0,0 +1,183 @@
1
+ import { nothing, PropertyDeclaration, TemplateResult } from 'lit';
2
+ import { ContextProvider } from '@lit-labs/context';
3
+ import { StateController } from '../controllers/state.js';
4
+ import { DataOperationsController } from '../controllers/data-operation.js';
5
+ import { GridDOMController } from '../controllers/dom.js';
6
+ import { EventEmitterBase } from '../internal/mixins/event-emitter.js';
7
+ import type { ColumnConfiguration, GridRemoteConfig, GridSortConfiguration, Keys } from '../internal/types.js';
8
+ import type { FilterExpressionTree } from '../operations/filter/tree.js';
9
+ import type { FilterExpression } from '../operations/filter/types.js';
10
+ import type { SortExpression } from '../operations/sort/types.js';
11
+ import ApexGridBody from './grid-body.js';
12
+ import ApexGridHeaderRow from './header-row.js';
13
+ import ApexGridRow from './row.js';
14
+ import ApexFilterRow from './filter-row.js';
15
+ /**
16
+ * Event object for the filtering event of the grid.
17
+ */
18
+ export interface ApexFilteringEvent<T extends object> {
19
+ /**
20
+ * The filter expression to apply.
21
+ */
22
+ expression: FilterExpression<T>;
23
+ /**
24
+ * The filter state of the column.
25
+ */
26
+ state: FilterExpressionTree<T>;
27
+ }
28
+ /**
29
+ * Events for the apex-grid.
30
+ */
31
+ export interface ApexGridEventMap<T extends object> {
32
+ /**
33
+ * Emitted when sorting is initiated through the UI.
34
+ * Returns the sort expression which will be used for the operation.
35
+ *
36
+ * @remarks
37
+ * The event is cancellable which prevents the operation from being applied.
38
+ * The expression can be modified prior to the operation running.
39
+ *
40
+ * @event
41
+ */
42
+ sorting: CustomEvent<SortExpression<T>>;
43
+ /**
44
+ * Emitted when a sort operation initiated through the UI has completed.
45
+ * Returns the sort expression used for the operation.
46
+ *
47
+ * @event
48
+ */
49
+ sorted: CustomEvent<SortExpression<T>>;
50
+ /**
51
+ * Emitted when filtering is initiated through the UI.
52
+ *
53
+ * @remarks
54
+ * The event is cancellable which prevents the operation from being applied.
55
+ * The expression can be modified prior to the operation running.
56
+ *
57
+ * @event
58
+ */
59
+ filtering: CustomEvent<ApexFilteringEvent<T>>;
60
+ /**
61
+ * Emitted when a filter operation initiated through the UI has completed.
62
+ * Returns the filter state for the affected column.
63
+ *
64
+ * @event
65
+ */
66
+ filtered: CustomEvent<FilterExpressionTree<T>>;
67
+ }
68
+ /**
69
+ * Apex grid is a web component for displaying data in a tabular format quick and easy.
70
+ *
71
+ * Out of the box it provides row virtualization, sort and filter operations (client and server side),
72
+ * the ability to template cells and headers and column hiding.
73
+ *
74
+ * @element apex-grid
75
+ *
76
+ * @fires sorting - Emitted when sorting is initiated through the UI.
77
+ * @fires sorted - Emitted when a sort operation initiated through the UI has completed.
78
+ * @fires filtering - Emitted when filtering is initiated through the UI.
79
+ * @fires filtered - Emitted when a filter operation initiated through the UI has completed.
80
+ *
81
+ */
82
+ export default class ApexGrid<T extends object> extends EventEmitterBase<ApexGridEventMap<T>> {
83
+ static get is(): "apex-grid";
84
+ static styles: import("lit").CSSResult;
85
+ protected stateController: StateController<T>;
86
+ protected DOM: GridDOMController<T>;
87
+ protected dataController: DataOperationsController<T>;
88
+ protected rowRenderer: <T_1>(data: T_1, index: number) => TemplateResult;
89
+ protected stateProvider: ContextProvider<{
90
+ __context__: StateController<any>;
91
+ }>;
92
+ protected bodyElement: ApexGridBody;
93
+ protected headerRow: ApexGridHeaderRow<T>;
94
+ protected filterRow: ApexFilterRow<T>;
95
+ protected dataState: Array<T>;
96
+ protected _rows: NodeListOf<ApexGridRow<T>>;
97
+ /** Column configuration for the grid. */
98
+ columns: Array<ColumnConfiguration<T>>;
99
+ /** The data source for the grid. */
100
+ data: Array<T>;
101
+ /**
102
+ * Whether the grid will try to "resolve" its column configuration based on the passed
103
+ * data source.
104
+ *
105
+ * @remarks
106
+ * This is a one-time operation which is executed when the grid is initially added to the DOM.
107
+ * Passing an empty data source or having a late bound data source (such as a HTTP request) will usually
108
+ * result in empty column configuration for the grid.
109
+ *
110
+ * This property is ignored if any existing column configuration already exists in the grid.
111
+ */
112
+ autoGenerate: boolean;
113
+ /** Sort configuration property for the grid. */
114
+ sortConfiguration: GridSortConfiguration;
115
+ /**
116
+ * Configuration object which controls remote data operations for the grid.
117
+ */
118
+ remoteConfiguration?: GridRemoteConfig<T>;
119
+ /**
120
+ * Set sort state for the apex grid.
121
+ *
122
+ * @remarks
123
+ *
124
+ */
125
+ sortExpressions: SortExpression<T>[];
126
+ /**
127
+ * Set filter state for the apex grid.
128
+ */
129
+ filterExpressions: FilterExpression<T>[];
130
+ /**
131
+ * Returns the collection of rendered row elements in the grid.
132
+ *
133
+ * @remarks
134
+ * Since the grid has virtualization, this property returns only the currently rendered
135
+ * chunk of elements in the DOM.
136
+ */
137
+ get rows(): ApexGridRow<T>[];
138
+ /**
139
+ * Returns the state of the data source after sort/filter operations
140
+ * have been applied.
141
+ */
142
+ get dataView(): ReadonlyArray<T>;
143
+ /**
144
+ * The total number of items in the {@link ApexGrid.dataView} collection.
145
+ */
146
+ get totalItems(): number;
147
+ constructor();
148
+ connectedCallback(): void;
149
+ requestUpdate(name?: PropertyKey, oldValue?: unknown, options?: PropertyDeclaration<this, unknown>): void;
150
+ protected watchSortExpressions(): void;
151
+ protected watchFilterExpressions(): void;
152
+ protected watchColumns(_: ColumnConfiguration<T>[], newConfig?: ColumnConfiguration<T>[]): void;
153
+ protected dataChanged(): void;
154
+ protected pipeline(): Promise<void>;
155
+ /**
156
+ * Performs a filter operation in the grid based on the passed expression(s).
157
+ */
158
+ filter(config: FilterExpression<T> | FilterExpression<T>[]): void;
159
+ /**
160
+ * Performs a sort operation in the grid based on the passed expression(s).
161
+ */
162
+ sort(expressions: SortExpression<T> | SortExpression<T>[]): void;
163
+ /**
164
+ * Returns a {@link ColumnConfiguration} for a given column.
165
+ */
166
+ getColumn(id: Keys<T> | number): ColumnConfiguration<T> | undefined;
167
+ /**
168
+ * Updates the column configuration of the grid.
169
+ */
170
+ updateColumn(key: Keys<T>, config: Partial<ColumnConfiguration<T>>): void;
171
+ protected bodyClickHandler(event: MouseEvent): void;
172
+ protected bodyKeydownHandler(event: KeyboardEvent): void;
173
+ protected renderHeaderRow(): TemplateResult<1>;
174
+ protected renderBody(): TemplateResult<1>;
175
+ protected renderFilterRow(): typeof nothing | TemplateResult<1>;
176
+ protected render(): TemplateResult<1>;
177
+ }
178
+ declare global {
179
+ interface HTMLElementTagNameMap {
180
+ [ApexGrid.is]: ApexGrid<object>;
181
+ }
182
+ }
183
+ //# sourceMappingURL=grid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../../src/components/grid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAKpD,OAAO,EAAE,eAAe,EAAoB,MAAM,yBAAyB,CAAC;AAC5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AAMvE,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,IAAI,EACL,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAOlE,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,iBAAiB,MAAM,iBAAiB,CAAC;AAChD,OAAO,WAAW,MAAM,UAAU,CAAC;AAEnC,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAsB5C;;GAEG;AACH,MAAM,WAAW,kBAAkB,CAAC,CAAC,SAAS,MAAM;IAClD;;OAEG;IACH,UAAU,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAChC;;OAEG;IACH,KAAK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Y,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC;IAsBzE,SAAS,CAAC,gBAAgB,CAAC,KAAK,EAAE,UAAU;IAU5C,SAAS,CAAC,kBAAkB,CAAC,KAAK,EAAE,aAAa;IAOjD,SAAS,CAAC,eAAe;IAOzB,SAAS,CAAC,UAAU;IASpB,SAAS,CAAC,eAAe;cAMN,MAAM;CAG1B;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;KACjC;CACF"}
@@ -0,0 +1,303 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { html, nothing } from 'lit';
8
+ import { ContextProvider } from '@lit-labs/context';
9
+ import { customElement, eventOptions, property, query, queryAll, state } from 'lit/decorators.js';
10
+ import { styleMap } from 'lit/directives/style-map.js';
11
+ import { GRID_TAG } from '../internal/tags.js';
12
+ import { StateController, gridStateContext } from '../controllers/state.js';
13
+ import { DataOperationsController } from '../controllers/data-operation.js';
14
+ import { GridDOMController } from '../controllers/dom.js';
15
+ import { EventEmitterBase } from '../internal/mixins/event-emitter.js';
16
+ import { watch } from '../internal/watch.js';
17
+ import { DEFAULT_COLUMN_CONFIG, PIPELINE } from '../internal/constants.js';
18
+ import { registerGridIcons } from '../internal/icon-registry.js';
19
+ import { asArray, autoGenerateColumns, getFilterOperandsFor } from '../internal/utils.js';
20
+ import { default as bootstrap } from '../styles/grid/themes/light/grid.bootstrap-styles.js';
21
+ import { default as fluent } from '../styles/grid/themes/light/grid.fluent-styles.js';
22
+ import { default as indigo } from '../styles/grid/themes/light/grid.indigo-styles.js';
23
+ import { default as material } from '../styles/grid/themes/light/grid.material-styles.js';
24
+ import ApexGridBody from './grid-body.js';
25
+ import ApexGridHeaderRow from './header-row.js';
26
+ import ApexGridRow from './row.js';
27
+ import ApexGridCell from './cell.js';
28
+ import ApexFilterRow from './filter-row.js';
29
+ import { themes } from 'igniteui-webcomponents/theming/theming-decorator.js';
30
+ import { defineComponents, IgcButtonComponent, IgcChipComponent, IgcDropdownComponent, IgcInputComponent, IgcIconComponent, IgcDropdownItemComponent, } from 'igniteui-webcomponents';
31
+ defineComponents(IgcButtonComponent, IgcChipComponent, IgcInputComponent, IgcDropdownComponent, IgcIconComponent, IgcDropdownItemComponent);
32
+ /**
33
+ * Apex grid is a web component for displaying data in a tabular format quick and easy.
34
+ *
35
+ * Out of the box it provides row virtualization, sort and filter operations (client and server side),
36
+ * the ability to template cells and headers and column hiding.
37
+ *
38
+ * @element apex-grid
39
+ *
40
+ * @fires sorting - Emitted when sorting is initiated through the UI.
41
+ * @fires sorted - Emitted when a sort operation initiated through the UI has completed.
42
+ * @fires filtering - Emitted when filtering is initiated through the UI.
43
+ * @fires filtered - Emitted when a filter operation initiated through the UI has completed.
44
+ *
45
+ */
46
+ let ApexGrid = class ApexGrid extends EventEmitterBase {
47
+ static get is() {
48
+ return GRID_TAG;
49
+ }
50
+ /**
51
+ * Returns the collection of rendered row elements in the grid.
52
+ *
53
+ * @remarks
54
+ * Since the grid has virtualization, this property returns only the currently rendered
55
+ * chunk of elements in the DOM.
56
+ */
57
+ get rows() {
58
+ return Array.from(this._rows);
59
+ }
60
+ /**
61
+ * Returns the state of the data source after sort/filter operations
62
+ * have been applied.
63
+ */
64
+ get dataView() {
65
+ return this.dataState;
66
+ }
67
+ /**
68
+ * The total number of items in the {@link ApexGrid.dataView} collection.
69
+ */
70
+ get totalItems() {
71
+ return this.dataState.length;
72
+ }
73
+ constructor() {
74
+ super();
75
+ this.stateController = new StateController(this);
76
+ this.DOM = new GridDOMController(this, this.stateController);
77
+ this.dataController = new DataOperationsController(this);
78
+ this.rowRenderer = (data, index) => {
79
+ return html `<apex-grid-row
80
+ part="row"
81
+ style=${styleMap({ ...this.DOM.columnSizes, ...this.DOM.getActiveRowStyles(index) })}
82
+ .index=${index}
83
+ .activeNode=${this.stateController.active}
84
+ .data=${data}
85
+ .columns=${this.columns}
86
+ ></apex-grid-row>`;
87
+ };
88
+ this.stateProvider = new ContextProvider(this, gridStateContext, this.stateController);
89
+ this.dataState = [];
90
+ /** Column configuration for the grid. */
91
+ this.columns = [];
92
+ /** The data source for the grid. */
93
+ this.data = [];
94
+ /**
95
+ * Whether the grid will try to "resolve" its column configuration based on the passed
96
+ * data source.
97
+ *
98
+ * @remarks
99
+ * This is a one-time operation which is executed when the grid is initially added to the DOM.
100
+ * Passing an empty data source or having a late bound data source (such as a HTTP request) will usually
101
+ * result in empty column configuration for the grid.
102
+ *
103
+ * This property is ignored if any existing column configuration already exists in the grid.
104
+ */
105
+ this.autoGenerate = false;
106
+ /** Sort configuration property for the grid. */
107
+ this.sortConfiguration = {
108
+ multiple: true,
109
+ triState: true,
110
+ };
111
+ /**
112
+ * Set sort state for the apex grid.
113
+ *
114
+ * @remarks
115
+ *
116
+ */
117
+ this.sortExpressions = [];
118
+ /**
119
+ * Set filter state for the apex grid.
120
+ */
121
+ this.filterExpressions = [];
122
+ registerGridIcons();
123
+ }
124
+ connectedCallback() {
125
+ super.connectedCallback();
126
+ autoGenerateColumns(this);
127
+ }
128
+ requestUpdate(name, oldValue, options) {
129
+ var _a, _b;
130
+ (_a = this.headerRow) === null || _a === void 0 ? void 0 : _a.requestUpdate();
131
+ (_b = this.filterRow) === null || _b === void 0 ? void 0 : _b.requestUpdate();
132
+ super.requestUpdate(name, oldValue, options);
133
+ }
134
+ watchSortExpressions() {
135
+ if (this.sortExpressions.length) {
136
+ this.sort(this.sortExpressions);
137
+ }
138
+ }
139
+ watchFilterExpressions() {
140
+ if (this.filterExpressions.length) {
141
+ this.filter(this.filterExpressions);
142
+ }
143
+ }
144
+ watchColumns(_, newConfig = []) {
145
+ this.columns = newConfig.map(config => ({ ...DEFAULT_COLUMN_CONFIG, ...config }));
146
+ }
147
+ dataChanged() {
148
+ this.dataState = structuredClone(this.data);
149
+ if (this.hasUpdated) {
150
+ this.pipeline();
151
+ }
152
+ }
153
+ async pipeline() {
154
+ this.dataState = await this.dataController.apply(structuredClone(this.data), this.stateController);
155
+ }
156
+ /**
157
+ * Performs a filter operation in the grid based on the passed expression(s).
158
+ */
159
+ filter(config) {
160
+ this.stateController.filtering.filter(asArray(config).map(each => typeof each.condition === 'string'
161
+ ? Object.assign(each, {
162
+ condition: getFilterOperandsFor(this.getColumn(each.key)).get(each.condition),
163
+ })
164
+ : each));
165
+ }
166
+ /**
167
+ * Performs a sort operation in the grid based on the passed expression(s).
168
+ */
169
+ sort(expressions) {
170
+ this.stateController.sorting.sort(expressions);
171
+ }
172
+ /**
173
+ * Returns a {@link ColumnConfiguration} for a given column.
174
+ */
175
+ getColumn(id) {
176
+ return typeof id === 'number'
177
+ ? this.columns.at(id)
178
+ : this.columns.find(({ key }) => key === id);
179
+ }
180
+ /**
181
+ * Updates the column configuration of the grid.
182
+ */
183
+ updateColumn(key, config) {
184
+ // Check and reset data operation states
185
+ // TODO: Run `pipeline` updates ?
186
+ if (!config.sort) {
187
+ this.stateController.sorting.reset(key);
188
+ }
189
+ if (!config.filter) {
190
+ this.stateController.filtering.reset(key);
191
+ }
192
+ this.columns = this.columns.map(each => {
193
+ if (key === each.key) {
194
+ each = { ...each, ...config };
195
+ }
196
+ return each;
197
+ });
198
+ this.requestUpdate();
199
+ }
200
+ bodyClickHandler(event) {
201
+ const target = event.composedPath().find(el => el instanceof ApexGridCell);
202
+ if (target) {
203
+ this.stateController.active = {
204
+ column: target.column.key,
205
+ row: target.row.index,
206
+ };
207
+ }
208
+ }
209
+ bodyKeydownHandler(event) {
210
+ const target = event.target;
211
+ if (this.bodyElement.isSameNode(target)) {
212
+ this.stateController.navigation.navigate(event, this.bodyElement);
213
+ }
214
+ }
215
+ renderHeaderRow() {
216
+ return html `<apex-grid-header-row
217
+ style=${styleMap(this.DOM.columnSizes)}
218
+ .columns=${this.columns}
219
+ ></apex-grid-header-row>`;
220
+ }
221
+ renderBody() {
222
+ return html `<apex-grid-body
223
+ @keydown=${this.bodyKeydownHandler}
224
+ @click=${this.bodyClickHandler}
225
+ .items=${this.dataState}
226
+ .renderItem=${this.rowRenderer}
227
+ ></apex-grid-body>`;
228
+ }
229
+ renderFilterRow() {
230
+ return this.columns.some(column => column.filter)
231
+ ? html `<apex-filter-row style=${styleMap(this.DOM.columnSizes)}></apex-filter-row>`
232
+ : nothing;
233
+ }
234
+ render() {
235
+ return html `${this.stateController.resizing.renderIndicator()}${this.renderHeaderRow()}${this.renderFilterRow()}${this.renderBody()}`;
236
+ }
237
+ };
238
+ ApexGrid.styles = bootstrap;
239
+ __decorate([
240
+ query(ApexGridBody.is)
241
+ ], ApexGrid.prototype, "bodyElement", void 0);
242
+ __decorate([
243
+ query(ApexGridHeaderRow.is)
244
+ ], ApexGrid.prototype, "headerRow", void 0);
245
+ __decorate([
246
+ query(ApexFilterRow.is)
247
+ ], ApexGrid.prototype, "filterRow", void 0);
248
+ __decorate([
249
+ state()
250
+ ], ApexGrid.prototype, "dataState", void 0);
251
+ __decorate([
252
+ queryAll(ApexGridRow.is)
253
+ ], ApexGrid.prototype, "_rows", void 0);
254
+ __decorate([
255
+ property({ attribute: false })
256
+ ], ApexGrid.prototype, "columns", void 0);
257
+ __decorate([
258
+ property({ attribute: false })
259
+ ], ApexGrid.prototype, "data", void 0);
260
+ __decorate([
261
+ property({ type: Boolean, attribute: 'auto-generate' })
262
+ ], ApexGrid.prototype, "autoGenerate", void 0);
263
+ __decorate([
264
+ property({ attribute: false })
265
+ ], ApexGrid.prototype, "sortConfiguration", void 0);
266
+ __decorate([
267
+ property({ attribute: false })
268
+ ], ApexGrid.prototype, "remoteConfiguration", void 0);
269
+ __decorate([
270
+ property({ attribute: false })
271
+ ], ApexGrid.prototype, "sortExpressions", void 0);
272
+ __decorate([
273
+ property({ attribute: false })
274
+ ], ApexGrid.prototype, "filterExpressions", void 0);
275
+ __decorate([
276
+ watch('sortExpressions')
277
+ ], ApexGrid.prototype, "watchSortExpressions", null);
278
+ __decorate([
279
+ watch('filterExpressions')
280
+ ], ApexGrid.prototype, "watchFilterExpressions", null);
281
+ __decorate([
282
+ watch('columns')
283
+ ], ApexGrid.prototype, "watchColumns", null);
284
+ __decorate([
285
+ watch('data')
286
+ ], ApexGrid.prototype, "dataChanged", null);
287
+ __decorate([
288
+ watch(PIPELINE)
289
+ ], ApexGrid.prototype, "pipeline", null);
290
+ __decorate([
291
+ eventOptions({ capture: true })
292
+ ], ApexGrid.prototype, "bodyClickHandler", null);
293
+ ApexGrid = __decorate([
294
+ themes({
295
+ bootstrap,
296
+ fluent,
297
+ indigo,
298
+ material,
299
+ }),
300
+ customElement(GRID_TAG)
301
+ ], ApexGrid);
302
+ export default ApexGrid;
303
+ //# sourceMappingURL=grid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grid.js","sourceRoot":"","sources":["../../../src/components/grid.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAuC,MAAM,KAAK,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAClG,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,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EAAE,CAAC;qDACkB;AASjD;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;iDACkB;AAMjD;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;mDACsB;AAiDrD;IADC,KAAK,CAAC,iBAAiB,CAAC;oDAKxB;AAGD;IADC,KAAK,CAAC,mBAAmB,CAAC;sDAK1B;AAGD;IADC,KAAK,CAAC,SAAS,CAAC;4CAGhB;AAGD;IADC,KAAK,CAAC,MAAM,CAAC;2CAMb;AAGe;IADf,KAAK,CAAC,QAAQ,CAAC;wCAMf;AA0DD;IADC,YAAY,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gDAS/B;AA1OkB,QAAQ;IAP5B,MAAM,CAAC;QACN,SAAS;QACT,MAAM;QACN,MAAM;QACN,QAAQ;KACT,CAAC;IACD,aAAa,CAAC,QAAQ,CAAC;GACH,QAAQ,CA4Q5B;eA5QoB,QAAQ","sourcesContent":["import { html, nothing, PropertyDeclaration, TemplateResult } from 'lit';\nimport { ContextProvider } from '@lit-labs/context';\nimport { customElement, eventOptions, property, query, queryAll, state } from 'lit/decorators.js';\nimport { styleMap } from 'lit/directives/style-map.js';\n\nimport { GRID_TAG } from '../internal/tags.js';\nimport { StateController, gridStateContext } from '../controllers/state.js';\nimport { DataOperationsController } from '../controllers/data-operation.js';\nimport { GridDOMController } from '../controllers/dom.js';\nimport { EventEmitterBase } from '../internal/mixins/event-emitter.js';\nimport { watch } from '../internal/watch.js';\nimport { DEFAULT_COLUMN_CONFIG, PIPELINE } from '../internal/constants.js';\nimport { registerGridIcons } from '../internal/icon-registry.js';\nimport { asArray, autoGenerateColumns, getFilterOperandsFor } from '../internal/utils.js';\n\nimport type {\n ColumnConfiguration,\n GridRemoteConfig,\n GridSortConfiguration,\n Keys,\n} from '../internal/types.js';\nimport type { FilterExpressionTree } from '../operations/filter/tree.js';\nimport type { FilterExpression } from '../operations/filter/types.js';\nimport type { SortExpression } from '../operations/sort/types.js';\n\nimport { default as bootstrap } from '../styles/grid/themes/light/grid.bootstrap-styles.js';\nimport { default as fluent } from '../styles/grid/themes/light/grid.fluent-styles.js';\nimport { default as indigo } from '../styles/grid/themes/light/grid.indigo-styles.js';\nimport { default as material } from '../styles/grid/themes/light/grid.material-styles.js';\n\nimport ApexGridBody from './grid-body.js';\nimport ApexGridHeaderRow from './header-row.js';\nimport ApexGridRow from './row.js';\nimport ApexGridCell from './cell.js';\nimport ApexFilterRow from './filter-row.js';\n\nimport { themes } from 'igniteui-webcomponents/theming/theming-decorator.js';\nimport {\n defineComponents,\n IgcButtonComponent,\n IgcChipComponent,\n IgcDropdownComponent,\n IgcInputComponent,\n IgcIconComponent,\n IgcDropdownItemComponent,\n} from 'igniteui-webcomponents';\n\ndefineComponents(\n IgcButtonComponent,\n IgcChipComponent,\n IgcInputComponent,\n IgcDropdownComponent,\n IgcIconComponent,\n IgcDropdownItemComponent,\n);\n\n/**\n * Event object for the filtering event of the grid.\n */\nexport interface ApexFilteringEvent<T extends object> {\n /**\n * The filter expression to apply.\n */\n expression: FilterExpression<T>;\n /**\n * The filter state of the column.\n */\n state: FilterExpressionTree<T>;\n}\n\n// TODO: Subject to change as these are way too generic names\n/**\n * Events for the apex-grid.\n */\nexport interface ApexGridEventMap<T extends object> {\n /**\n * Emitted when sorting is initiated through the UI.\n * Returns the sort expression which will be used for the operation.\n *\n * @remarks\n * The event is cancellable which prevents the operation from being applied.\n * The expression can be modified prior to the operation running.\n *\n * @event\n */\n sorting: CustomEvent<SortExpression<T>>;\n /**\n * Emitted when a sort operation initiated through the UI has completed.\n * Returns the sort expression used for the operation.\n *\n * @event\n */\n sorted: CustomEvent<SortExpression<T>>;\n /**\n * Emitted when filtering is initiated through the UI.\n *\n * @remarks\n * The event is cancellable which prevents the operation from being applied.\n * The expression can be modified prior to the operation running.\n *\n * @event\n */\n filtering: CustomEvent<ApexFilteringEvent<T>>;\n /**\n * Emitted when a filter operation initiated through the UI has completed.\n * Returns the filter state for the affected column.\n *\n * @event\n */\n filtered: CustomEvent<FilterExpressionTree<T>>;\n}\n\n/**\n * Apex grid is a web component for displaying data in a tabular format quick and easy.\n *\n * Out of the box it provides row virtualization, sort and filter operations (client and server side),\n * the ability to template cells and headers and column hiding.\n *\n * @element apex-grid\n *\n * @fires sorting - Emitted when sorting is initiated through the UI.\n * @fires sorted - Emitted when a sort operation initiated through the UI has completed.\n * @fires filtering - Emitted when filtering is initiated through the UI.\n * @fires filtered - Emitted when a filter operation initiated through the UI has completed.\n *\n */\n@themes({\n bootstrap,\n fluent,\n indigo,\n material,\n})\n@customElement(GRID_TAG)\nexport default class ApexGrid<T extends object> extends EventEmitterBase<ApexGridEventMap<T>> {\n public static get is() {\n return GRID_TAG;\n }\n\n public static override styles = bootstrap;\n\n protected stateController = new StateController<T>(this);\n protected DOM = new GridDOMController<T>(this, this.stateController);\n protected dataController = new DataOperationsController<T>(this);\n\n protected rowRenderer = <T>(data: T, index: number): TemplateResult => {\n return html`<apex-grid-row\n part=\"row\"\n style=${styleMap({ ...this.DOM.columnSizes, ...this.DOM.getActiveRowStyles(index) })}\n .index=${index}\n .activeNode=${this.stateController.active}\n .data=${data}\n .columns=${this.columns}\n ></apex-grid-row>`;\n };\n\n protected stateProvider = new ContextProvider(this, gridStateContext, this.stateController);\n\n @query(ApexGridBody.is)\n protected bodyElement!: ApexGridBody;\n\n @query(ApexGridHeaderRow.is)\n protected headerRow!: ApexGridHeaderRow<T>;\n\n @query(ApexFilterRow.is)\n protected filterRow!: ApexFilterRow<T>;\n\n @state()\n protected dataState: Array<T> = [];\n\n @queryAll(ApexGridRow.is)\n protected _rows!: NodeListOf<ApexGridRow<T>>;\n\n /** Column configuration for the grid. */\n @property({ attribute: false })\n public columns: Array<ColumnConfiguration<T>> = [];\n\n /** The data source for the grid. */\n @property({ attribute: false })\n public data: Array<T> = [];\n\n /**\n * Whether the grid will try to \"resolve\" its column configuration based on the passed\n * data source.\n *\n * @remarks\n * This is a one-time operation which is executed when the grid is initially added to the DOM.\n * Passing an empty data source or having a late bound data source (such as a HTTP request) will usually\n * result in empty column configuration for the grid.\n *\n * This property is ignored if any existing column configuration already exists in the grid.\n */\n @property({ type: Boolean, attribute: 'auto-generate' })\n public autoGenerate = false;\n\n /** Sort configuration property for the grid. */\n @property({ attribute: false })\n public sortConfiguration: GridSortConfiguration = {\n multiple: true,\n triState: true,\n };\n\n /**\n * Configuration object which controls remote data operations for the grid.\n */\n @property({ attribute: false })\n public remoteConfiguration?: GridRemoteConfig<T>;\n\n /**\n * Set sort state for the apex grid.\n *\n * @remarks\n *\n */\n @property({ attribute: false })\n public sortExpressions: SortExpression<T>[] = [];\n\n /**\n * Set filter state for the apex grid.\n */\n @property({ attribute: false })\n public filterExpressions: FilterExpression<T>[] = [];\n\n /**\n * Returns the collection of rendered row elements in the grid.\n *\n * @remarks\n * Since the grid has virtualization, this property returns only the currently rendered\n * chunk of elements in the DOM.\n */\n public get rows() {\n return Array.from(this._rows);\n }\n\n /**\n * Returns the state of the data source after sort/filter operations\n * have been applied.\n */\n public get dataView(): ReadonlyArray<T> {\n return this.dataState;\n }\n\n /**\n * The total number of items in the {@link ApexGrid.dataView} collection.\n */\n public get totalItems() {\n return this.dataState.length;\n }\n\n constructor() {\n super();\n registerGridIcons();\n }\n\n public override connectedCallback() {\n super.connectedCallback();\n autoGenerateColumns(this);\n }\n\n public override requestUpdate(\n name?: PropertyKey,\n oldValue?: unknown,\n options?: PropertyDeclaration<this, unknown>,\n ): void {\n this.headerRow?.requestUpdate();\n this.filterRow?.requestUpdate();\n super.requestUpdate(name, oldValue, options);\n }\n\n @watch('sortExpressions')\n protected watchSortExpressions() {\n if (this.sortExpressions.length) {\n this.sort(this.sortExpressions);\n }\n }\n\n @watch('filterExpressions')\n protected watchFilterExpressions() {\n if (this.filterExpressions.length) {\n this.filter(this.filterExpressions);\n }\n }\n\n @watch('columns')\n protected watchColumns(_: ColumnConfiguration<T>[], newConfig: ColumnConfiguration<T>[] = []) {\n this.columns = newConfig.map(config => ({ ...DEFAULT_COLUMN_CONFIG, ...config }));\n }\n\n @watch('data')\n protected dataChanged() {\n this.dataState = structuredClone(this.data);\n if (this.hasUpdated) {\n this.pipeline();\n }\n }\n\n @watch(PIPELINE)\n protected async pipeline() {\n this.dataState = await this.dataController.apply(\n structuredClone(this.data),\n this.stateController,\n );\n }\n\n /**\n * Performs a filter operation in the grid based on the passed expression(s).\n */\n public filter(config: FilterExpression<T> | FilterExpression<T>[]) {\n this.stateController.filtering.filter(\n asArray(config).map(each =>\n typeof each.condition === 'string'\n ? Object.assign(each, {\n condition: getFilterOperandsFor(this.getColumn(each.key)!).get(each.condition as any),\n })\n : each,\n ),\n );\n }\n\n /**\n * Performs a sort operation in the grid based on the passed expression(s).\n */\n public sort(expressions: SortExpression<T> | SortExpression<T>[]) {\n this.stateController.sorting.sort(expressions);\n }\n\n /**\n * Returns a {@link ColumnConfiguration} for a given column.\n */\n public getColumn(id: Keys<T> | number) {\n return typeof id === 'number'\n ? this.columns.at(id)\n : this.columns.find(({ key }) => key === id);\n }\n\n /**\n * Updates the column configuration of the grid.\n */\n public updateColumn(key: Keys<T>, config: Partial<ColumnConfiguration<T>>) {\n // Check and reset data operation states\n // TODO: Run `pipeline` updates ?\n if (!config.sort) {\n this.stateController.sorting.reset(key);\n }\n\n if (!config.filter) {\n this.stateController.filtering.reset(key);\n }\n\n this.columns = this.columns.map(each => {\n if (key === each.key) {\n each = { ...each, ...config };\n }\n return each;\n });\n\n this.requestUpdate();\n }\n\n @eventOptions({ capture: true })\n protected bodyClickHandler(event: MouseEvent) {\n const target = event.composedPath().find(el => el instanceof ApexGridCell) as ApexGridCell<T>;\n if (target) {\n this.stateController.active = {\n column: target.column.key,\n row: target.row.index,\n };\n }\n }\n\n protected bodyKeydownHandler(event: KeyboardEvent) {\n const target = event.target as HTMLElement & ApexGridBody;\n if (this.bodyElement.isSameNode(target)) {\n this.stateController.navigation.navigate(event, this.bodyElement);\n }\n }\n\n protected renderHeaderRow() {\n return html`<apex-grid-header-row\n style=${styleMap(this.DOM.columnSizes)}\n .columns=${this.columns}\n ></apex-grid-header-row>`;\n }\n\n protected renderBody() {\n return html`<apex-grid-body\n @keydown=${this.bodyKeydownHandler}\n @click=${this.bodyClickHandler}\n .items=${this.dataState}\n .renderItem=${this.rowRenderer}\n ></apex-grid-body>`;\n }\n\n protected renderFilterRow() {\n return this.columns.some(column => column.filter)\n ? html`<apex-filter-row style=${styleMap(this.DOM.columnSizes)}></apex-filter-row>`\n : nothing;\n }\n\n protected override render() {\n return html`${this.stateController.resizing.renderIndicator()}${this.renderHeaderRow()}${this.renderFilterRow()}${this.renderBody()}`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n [ApexGrid.is]: ApexGrid<object>;\n }\n}\n"]}
@@ -0,0 +1,23 @@
1
+ import { LitElement, PropertyValueMap } from 'lit';
2
+ import { StateController } from '../controllers/state.js';
3
+ import ApexGridHeader from './header.js';
4
+ import type { ColumnConfiguration } from '../internal/types.js';
5
+ export default class ApexGridHeaderRow<T extends object> extends LitElement {
6
+ #private;
7
+ static get is(): "apex-grid-header-row";
8
+ static styles: import("lit").CSSResult;
9
+ protected _headers: NodeListOf<ApexGridHeader<T>>;
10
+ state: StateController<T>;
11
+ columns: Array<ColumnConfiguration<T>>;
12
+ get headers(): ApexGridHeader<T>[];
13
+ constructor();
14
+ connectedCallback(): void;
15
+ protected shouldUpdate(props: PropertyValueMap<this> | Map<PropertyKey, this>): boolean;
16
+ protected render(): import("lit-html").TemplateResult<1>;
17
+ }
18
+ declare global {
19
+ interface HTMLElementTagNameMap {
20
+ [ApexGridHeaderRow.is]: ApexGridHeaderRow<object>;
21
+ }
22
+ }
23
+ //# sourceMappingURL=header-row.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"header-row.d.ts","sourceRoot":"","sources":["../../../src/components/header-row.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,UAAU,EAAW,gBAAgB,EAAE,MAAM,KAAK,CAAC;AAIlE,OAAO,EAAoB,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAI5E,OAAO,cAAc,MAAM,aAAa,CAAC;AAGzC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAGhE,MAAM,CAAC,OAAO,OAAO,iBAAiB,CAAC,CAAC,SAAS,MAAM,CAAE,SAAQ,UAAU;;IACzE,WAAkB,EAAE,2BAEnB;IACD,OAAuB,MAAM,0BAAU;IAGvC,SAAS,CAAC,QAAQ,EAAG,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;IAI5C,KAAK,EAAG,eAAe,CAAC,CAAC,CAAC,CAAC;IAG3B,OAAO,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAM;IAEnD,IAAW,OAAO,wBAEjB;;IAOe,iBAAiB;cAcd,YAAY,CAAC,KAAK,EAAE,gBAAgB,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,GAAG,OAAO;cAK7E,MAAM;CAc1B;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,CAAC,iBAAiB,CAAC,EAAE,CAAC,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;KACnD;CACF"}
@@ -0,0 +1,77 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _ApexGridHeaderRow_instances, _ApexGridHeaderRow_activeFilterColumn;
13
+ import { html, LitElement, nothing } from 'lit';
14
+ import { contextProvided } from '@lit-labs/context';
15
+ import { customElement, property, queryAll } from 'lit/decorators.js';
16
+ import { map } from 'lit/directives/map.js';
17
+ import { gridStateContext } from '../controllers/state.js';
18
+ import { partNameMap } from '../internal/part-map.js';
19
+ import { GRID_HEADER_ROW_TAG } from '../internal/tags.js';
20
+ import ApexGridHeader from './header.js';
21
+ import styles from '../styles/header-row/header-row.base-styles.js';
22
+ let ApexGridHeaderRow = class ApexGridHeaderRow extends LitElement {
23
+ static get is() {
24
+ return GRID_HEADER_ROW_TAG;
25
+ }
26
+ get headers() {
27
+ return Array.from(this._headers);
28
+ }
29
+ constructor() {
30
+ super();
31
+ _ApexGridHeaderRow_instances.add(this);
32
+ this.columns = [];
33
+ this.addEventListener('click', __classPrivateFieldGet(this, _ApexGridHeaderRow_instances, "m", _ApexGridHeaderRow_activeFilterColumn));
34
+ }
35
+ connectedCallback() {
36
+ super.connectedCallback();
37
+ this.setAttribute('tabindex', '0');
38
+ }
39
+ shouldUpdate(props) {
40
+ this.headers.forEach(header => header.requestUpdate());
41
+ return super.shouldUpdate(props);
42
+ }
43
+ render() {
44
+ const filterRow = this.state.filtering.filterRow;
45
+ return html `${map(this.columns, column => column.hidden
46
+ ? nothing
47
+ : html `<apex-grid-header
48
+ part=${partNameMap({
49
+ filtered: column === (filterRow === null || filterRow === void 0 ? void 0 : filterRow.column),
50
+ })}
51
+ .column=${column}
52
+ ></apex-grid-header>`)}`;
53
+ }
54
+ };
55
+ _ApexGridHeaderRow_instances = new WeakSet(), _ApexGridHeaderRow_activeFilterColumn = function _ApexGridHeaderRow_activeFilterColumn(event) {
56
+ const header = event
57
+ .composedPath()
58
+ .filter(target => target instanceof ApexGridHeader)
59
+ .at(0);
60
+ this.state.filtering.setActiveColumn(header === null || header === void 0 ? void 0 : header.column);
61
+ };
62
+ ApexGridHeaderRow.styles = styles;
63
+ __decorate([
64
+ queryAll(ApexGridHeader.is)
65
+ ], ApexGridHeaderRow.prototype, "_headers", void 0);
66
+ __decorate([
67
+ contextProvided({ context: gridStateContext, subscribe: true }),
68
+ property({ attribute: false })
69
+ ], ApexGridHeaderRow.prototype, "state", void 0);
70
+ __decorate([
71
+ property({ attribute: false })
72
+ ], ApexGridHeaderRow.prototype, "columns", void 0);
73
+ ApexGridHeaderRow = __decorate([
74
+ customElement(GRID_HEADER_ROW_TAG)
75
+ ], ApexGridHeaderRow);
76
+ export default ApexGridHeaderRow;
77
+ //# sourceMappingURL=header-row.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"header-row.js","sourceRoot":"","sources":["../../../src/components/header-row.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAoB,MAAM,KAAK,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAmB,MAAM,yBAAyB,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,cAAc,MAAM,aAAa,CAAC;AACzC,OAAO,MAAM,MAAM,gDAAgD,CAAC;AAKrD,IAAM,iBAAiB,GAAvB,MAAM,iBAAoC,SAAQ,UAAU;IAClE,MAAM,KAAK,EAAE;QAClB,OAAO,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MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,CAAC,CAAC;AACvD,CAAC;AAjCsB,wBAAM,GAAG,MAAM,CAAC;AAGvC;IADC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;mDACuB;AAInD;IAFC,eAAe,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IAC/D,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;gDACG;AAGlC;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;kDACoB;AAdhC,iBAAiB;IADrC,aAAa,CAAC,mBAAmB,CAAC;GACd,iBAAiB,CA0DrC;eA1DoB,iBAAiB","sourcesContent":["import { html, LitElement, nothing, PropertyValueMap } from 'lit';\nimport { contextProvided } from '@lit-labs/context';\nimport { customElement, property, queryAll } from 'lit/decorators.js';\nimport { map } from 'lit/directives/map.js';\nimport { gridStateContext, StateController } from '../controllers/state.js';\nimport { partNameMap } from '../internal/part-map.js';\nimport { GRID_HEADER_ROW_TAG } from '../internal/tags.js';\n\nimport ApexGridHeader from './header.js';\nimport styles from '../styles/header-row/header-row.base-styles.js';\n\nimport type { ColumnConfiguration } from '../internal/types.js';\n\n@customElement(GRID_HEADER_ROW_TAG)\nexport default class ApexGridHeaderRow<T extends object> extends LitElement {\n public static get is() {\n return GRID_HEADER_ROW_TAG;\n }\n public static override styles = styles;\n\n @queryAll(ApexGridHeader.is)\n protected _headers!: NodeListOf<ApexGridHeader<T>>;\n\n @contextProvided({ context: gridStateContext, subscribe: true })\n @property({ attribute: false })\n public state!: StateController<T>;\n\n @property({ attribute: false })\n public columns: Array<ColumnConfiguration<T>> = [];\n\n public get headers() {\n return Array.from(this._headers);\n }\n\n constructor() {\n super();\n this.addEventListener('click', this.#activeFilterColumn);\n }\n\n public override connectedCallback() {\n super.connectedCallback();\n this.setAttribute('tabindex', '0');\n }\n\n #activeFilterColumn(event: MouseEvent) {\n const header = event\n .composedPath()\n .filter(target => target instanceof ApexGridHeader)\n .at(0) as ApexGridHeader<T>;\n\n this.state.filtering.setActiveColumn(header?.column);\n }\n\n protected override shouldUpdate(props: PropertyValueMap<this> | Map<PropertyKey, this>): boolean {\n this.headers.forEach(header => header.requestUpdate());\n return super.shouldUpdate(props);\n }\n\n protected override render() {\n const filterRow = this.state.filtering.filterRow;\n\n return html`${map(this.columns, column =>\n column.hidden\n ? nothing\n : html`<apex-grid-header\n part=${partNameMap({\n filtered: column === filterRow?.column,\n })}\n .column=${column}\n ></apex-grid-header>`,\n )}`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n [ApexGridHeaderRow.is]: ApexGridHeaderRow<object>;\n }\n}\n"]}