@fluid-topics/ft-filterable-table 0.3.11 → 0.3.13

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.
@@ -0,0 +1,12 @@
1
+ export declare const FtFilterableTableCssVariables: {
2
+ headerBackground: import("@fluid-topics/ft-wc-utils").FtCssVariable;
3
+ oddRowBackground: import("@fluid-topics/ft-wc-utils").FtCssVariable;
4
+ evenRowBackground: import("@fluid-topics/ft-wc-utils").FtCssVariable;
5
+ rowHoverBackground: import("@fluid-topics/ft-wc-utils").FtCssVariable;
6
+ stickyHeaderZIndex: import("@fluid-topics/ft-wc-utils").FtCssVariable;
7
+ colorOnSurfaceHigh: import("@fluid-topics/ft-wc-utils").FtCssVariable;
8
+ titleFont: import("@fluid-topics/ft-wc-utils").FtCssVariable;
9
+ contentFont: import("@fluid-topics/ft-wc-utils").FtCssVariable;
10
+ };
11
+ export declare const styles: import("lit").CSSResult;
12
+ //# sourceMappingURL=ft-filterable-table.css.d.ts.map
@@ -0,0 +1,124 @@
1
+ import { css } from "lit";
2
+ import { designSystemVariables, FtCssVariableFactory, setVariable } from "@fluid-topics/ft-wc-utils";
3
+ import { FtButtonCssVariables } from "@fluid-topics/ft-button/build/ft-button.css";
4
+ export const FtFilterableTableCssVariables = {
5
+ headerBackground: FtCssVariableFactory.create("--ft-filterable-table-header-background", "COLOR", "whitesmoke"),
6
+ oddRowBackground: FtCssVariableFactory.create("--ft-filterable-table-odd-row-background", "COLOR", "#FFFFFF"),
7
+ evenRowBackground: FtCssVariableFactory.create("--ft-filterable-table-even-row-background", "COLOR", "#fdfdfd"),
8
+ rowHoverBackground: FtCssVariableFactory.create("--ft-filterable-table-row-hover-background", "COLOR", "#fafafa"),
9
+ stickyHeaderZIndex: FtCssVariableFactory.create("--ft-filterable-table-sticky-header-zindex", "NUMBER", "100"),
10
+ colorOnSurfaceHigh: FtCssVariableFactory.external(designSystemVariables.colorOnSurfaceHigh, "Design system"),
11
+ titleFont: FtCssVariableFactory.external(designSystemVariables.titleFont, "Design system"),
12
+ contentFont: FtCssVariableFactory.external(designSystemVariables.contentFont, "Design system"),
13
+ };
14
+ //language=css
15
+ export const styles = css `
16
+ :host {
17
+ display: block;
18
+ }
19
+
20
+ .table {
21
+ display: grid;
22
+ }
23
+
24
+ .header, .row {
25
+ display: contents;
26
+ }
27
+
28
+ .header-cell {
29
+ display: flex;
30
+ flex-direction: column;
31
+ background: ${FtFilterableTableCssVariables.headerBackground};
32
+ color: ${FtFilterableTableCssVariables.colorOnSurfaceHigh};
33
+ padding: .5rem 1rem;
34
+ font-family: ${FtFilterableTableCssVariables.titleFont};
35
+ }
36
+
37
+ .header-cell--sticky {
38
+ top: 0;
39
+ z-index: ${FtFilterableTableCssVariables.stickyHeaderZIndex};
40
+ position: sticky;
41
+ }
42
+
43
+ .header-cell:first-of-type {
44
+ border-radius: .5rem 0 0 0;
45
+ }
46
+
47
+ .header-cell:last-of-type {
48
+ border-radius: 0 .5rem 0 0;
49
+ }
50
+
51
+ .column-title-container {
52
+ display: flex;
53
+ align-items: center;
54
+ }
55
+
56
+ .column-title-container ft-button {
57
+ ${setVariable(FtButtonCssVariables.backgroundColor, FtFilterableTableCssVariables.headerBackground)};
58
+ ${setVariable(FtButtonCssVariables.color, FtFilterableTableCssVariables.colorOnSurfaceHigh)};
59
+ }
60
+
61
+ .column-title {
62
+ white-space: nowrap;
63
+ text-transform: uppercase;
64
+ margin-right: .5rem;
65
+ font-weight: normal;
66
+ letter-spacing: 1.5px;
67
+ font-size: 0.8em;
68
+ }
69
+
70
+ .column-filter {
71
+ flex-grow: 1;
72
+ flex-shrink: 0;
73
+ }
74
+
75
+ .column-filter:not(:empty) {
76
+ padding-top: .5rem;
77
+ }
78
+
79
+ .column-filter ft-text-field,
80
+ .column-filter ft-select {
81
+ width: 150px;
82
+ min-width: 100%;
83
+ }
84
+
85
+ .cell {
86
+ padding: 1rem;
87
+ border-left: 1px solid ${FtFilterableTableCssVariables.headerBackground};
88
+ border-bottom: 1px solid ${FtFilterableTableCssVariables.headerBackground};
89
+ overflow-x: auto;
90
+ display: flex;
91
+ align-items: center;
92
+ font-family: ${FtFilterableTableCssVariables.contentFont};
93
+ }
94
+
95
+ /* Even is 2n+1 and odd is 2n because of the header */
96
+ .row:nth-child(2n) > .cell {
97
+ background: ${FtFilterableTableCssVariables.oddRowBackground};
98
+ }
99
+
100
+ .row:nth-child(2n + 1) > .cell {
101
+ background: ${FtFilterableTableCssVariables.evenRowBackground};
102
+ }
103
+
104
+ .row:hover > .cell {
105
+ background: ${FtFilterableTableCssVariables.rowHoverBackground};
106
+ }
107
+
108
+ .cell:last-of-type {
109
+ border-right: 1px solid ${FtFilterableTableCssVariables.headerBackground};
110
+ }
111
+
112
+ .row:last-of-type .cell:first-of-type {
113
+ border-radius: 0 0 0 .5rem;
114
+ }
115
+
116
+ .row:last-of-type .cell:last-of-type {
117
+ border-radius: 0 0 .5rem 0;
118
+ }
119
+
120
+ .hidden {
121
+ visibility: hidden;
122
+ }
123
+ `;
124
+ //# sourceMappingURL=ft-filterable-table.css.js.map
@@ -1,46 +1,9 @@
1
- import { PropertyValues, TemplateResult } from "lit";
1
+ import { PropertyValues } from "lit";
2
2
  import { FtLitElement } from "@fluid-topics/ft-wc-utils";
3
3
  import "@fluid-topics/ft-select";
4
4
  import "@fluid-topics/ft-text-field";
5
5
  import "@fluid-topics/ft-button";
6
- export declare type Getter<T> = (o: T) => any;
7
- export interface ColumnConfiguration<T> {
8
- title: string | TemplateResult;
9
- getter: string | Getter<T>;
10
- render?: (value: any, index: number) => string | TemplateResult;
11
- sortable?: boolean;
12
- comparator?: (a: any, b: any) => number;
13
- filter?: "text" | "select" | "date" | "none";
14
- stringify?: (value: any, index: number) => string;
15
- }
16
- export interface Sort {
17
- column: number;
18
- order: "asc" | "desc";
19
- }
20
- interface Filter {
21
- value?: string;
22
- rangeStart?: Date;
23
- rangeEnd?: Date;
24
- }
25
- export declare class RowClickEvent<T> extends CustomEvent<T> {
26
- constructor(data: T);
27
- }
28
- export interface FtFilterableTableProperties<T extends Record<string, any>> {
29
- data: Array<T>;
30
- columns: Array<ColumnConfiguration<T>>;
31
- sort?: Sort;
32
- stickyHeaders: boolean;
33
- }
34
- export declare const FtFilterableTableCssVariables: {
35
- headerBackground: import("@fluid-topics/ft-wc-utils").FtCssVariable;
36
- oddRowBackground: import("@fluid-topics/ft-wc-utils").FtCssVariable;
37
- evenRowBackground: import("@fluid-topics/ft-wc-utils").FtCssVariable;
38
- rowHoverBackground: import("@fluid-topics/ft-wc-utils").FtCssVariable;
39
- stickyHeaderZIndex: import("@fluid-topics/ft-wc-utils").FtCssVariable;
40
- colorOnSurfaceHigh: import("@fluid-topics/ft-wc-utils").FtCssVariable;
41
- titleFont: import("@fluid-topics/ft-wc-utils").FtCssVariable;
42
- contentFont: import("@fluid-topics/ft-wc-utils").FtCssVariable;
43
- };
6
+ import { ColumnConfiguration, Filter, FtFilterableTableProperties, Sort } from "./ft-filterable-table.properties";
44
7
  export declare class FtFilterableTable<T extends Record<string, any>> extends FtLitElement implements FtFilterableTableProperties<T> {
45
8
  data: Array<T>;
46
9
  columns: Array<ColumnConfiguration<T>>;
@@ -51,7 +14,7 @@ export declare class FtFilterableTable<T extends Record<string, any>> extends Ft
51
14
  selectData: Array<Array<string>>;
52
15
  static styles: import("lit").CSSResult;
53
16
  init(data: Array<T>, columns: Array<ColumnConfiguration<T>>, sort?: Sort): void;
54
- protected render(): TemplateResult<1>;
17
+ protected render(): import("lit-html").TemplateResult<1>;
55
18
  private filterData;
56
19
  private sortData;
57
20
  protected update(props: PropertyValues): void;
@@ -63,5 +26,4 @@ export declare class FtFilterableTable<T extends Record<string, any>> extends Ft
63
26
  private getValue;
64
27
  private getValueAsString;
65
28
  }
66
- export {};
67
29
  //# sourceMappingURL=ft-filterable-table.d.ts.map
@@ -4,31 +4,17 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
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
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- import { css, html } from "lit";
7
+ import { html } from "lit";
8
8
  import { property, state } from "lit/decorators.js";
9
9
  import { repeat } from "lit/directives/repeat.js";
10
10
  import { unsafeHTML } from "lit/directives/unsafe-html.js";
11
- import { designSystemVariables, FtCssVariableFactory, FtLitElement, setVariable } from "@fluid-topics/ft-wc-utils";
11
+ import { FtLitElement } from "@fluid-topics/ft-wc-utils";
12
12
  import "@fluid-topics/ft-select";
13
13
  import "@fluid-topics/ft-text-field";
14
14
  import "@fluid-topics/ft-button";
15
- import { FtButtonCssVariables } from "@fluid-topics/ft-button";
16
15
  import { classMap } from "lit/directives/class-map.js";
17
- export class RowClickEvent extends CustomEvent {
18
- constructor(data) {
19
- super("row-click", { detail: data });
20
- }
21
- }
22
- export const FtFilterableTableCssVariables = {
23
- headerBackground: FtCssVariableFactory.create("--ft-filterable-table-header-background", "COLOR", "whitesmoke"),
24
- oddRowBackground: FtCssVariableFactory.create("--ft-filterable-table-odd-row-background", "COLOR", "#FFFFFF"),
25
- evenRowBackground: FtCssVariableFactory.create("--ft-filterable-table-even-row-background", "COLOR", "#fdfdfd"),
26
- rowHoverBackground: FtCssVariableFactory.create("--ft-filterable-table-row-hover-background", "COLOR", "#fafafa"),
27
- stickyHeaderZIndex: FtCssVariableFactory.create("--ft-filterable-table-sticky-header-zindex", "NUMBER", "100"),
28
- colorOnSurfaceHigh: FtCssVariableFactory.external(designSystemVariables.colorOnSurfaceHigh, "Design system"),
29
- titleFont: FtCssVariableFactory.external(designSystemVariables.titleFont, "Design system"),
30
- contentFont: FtCssVariableFactory.external(designSystemVariables.contentFont, "Design system"),
31
- };
16
+ import { RowClickEvent } from "./ft-filterable-table.properties";
17
+ import { styles } from "./ft-filterable-table.css";
32
18
  const DEFAULT_RENDER = (v) => html `${v}`;
33
19
  const DEFAULT_COMPARATOR = (a, b) => a - b;
34
20
  const DEFAULT_STRINGIFY = (v) => "" + v;
@@ -225,115 +211,7 @@ export class FtFilterableTable extends FtLitElement {
225
211
  }
226
212
  }
227
213
  //language=css
228
- FtFilterableTable.styles = css `
229
- :host {
230
- display: block;
231
- }
232
-
233
- .table {
234
- display: grid;
235
- }
236
-
237
- .header, .row {
238
- display: contents;
239
- }
240
-
241
- .header-cell {
242
- display: flex;
243
- flex-direction: column;
244
- background: ${FtFilterableTableCssVariables.headerBackground};
245
- color: ${FtFilterableTableCssVariables.colorOnSurfaceHigh};
246
- padding: .5rem 1rem;
247
- font-family: ${FtFilterableTableCssVariables.titleFont};
248
- }
249
-
250
- .header-cell--sticky {
251
- top: 0;
252
- z-index: ${FtFilterableTableCssVariables.stickyHeaderZIndex};
253
- position: sticky;
254
- }
255
-
256
- .header-cell:first-of-type {
257
- border-radius: .5rem 0 0 0;
258
- }
259
-
260
- .header-cell:last-of-type {
261
- border-radius: 0 .5rem 0 0;
262
- }
263
-
264
- .column-title-container {
265
- display: flex;
266
- align-items: center;
267
- }
268
-
269
- .column-title-container ft-button {
270
- ${setVariable(FtButtonCssVariables.backgroundColor, FtFilterableTableCssVariables.headerBackground)};
271
- ${setVariable(FtButtonCssVariables.color, FtFilterableTableCssVariables.colorOnSurfaceHigh)};
272
- }
273
-
274
- .column-title {
275
- white-space: nowrap;
276
- text-transform: uppercase;
277
- margin-right: .5rem;
278
- font-weight: normal;
279
- letter-spacing: 1.5px;
280
- font-size: 0.8em;
281
- }
282
-
283
- .column-filter {
284
- flex-grow: 1;
285
- flex-shrink: 0;
286
- }
287
-
288
- .column-filter:not(:empty) {
289
- padding-top: .5rem;
290
- }
291
-
292
- .column-filter ft-text-field,
293
- .column-filter ft-select {
294
- width: 150px;
295
- min-width: 100%;
296
- }
297
-
298
- .cell {
299
- padding: 1rem;
300
- border-left: 1px solid ${FtFilterableTableCssVariables.headerBackground};
301
- border-bottom: 1px solid ${FtFilterableTableCssVariables.headerBackground};
302
- overflow-x: auto;
303
- display: flex;
304
- align-items: center;
305
- font-family: ${FtFilterableTableCssVariables.contentFont};
306
- }
307
-
308
- /* Even is 2n+1 and odd is 2n because of the header */
309
- .row:nth-child(2n) > .cell {
310
- background: ${FtFilterableTableCssVariables.oddRowBackground};
311
- }
312
-
313
- .row:nth-child(2n + 1) > .cell {
314
- background: ${FtFilterableTableCssVariables.evenRowBackground};
315
- }
316
-
317
- .row:hover > .cell {
318
- background: ${FtFilterableTableCssVariables.rowHoverBackground};
319
- }
320
-
321
- .cell:last-of-type {
322
- border-right: 1px solid ${FtFilterableTableCssVariables.headerBackground};
323
- }
324
-
325
- .row:last-of-type .cell:first-of-type {
326
- border-radius: 0 0 0 .5rem;
327
- }
328
-
329
- .row:last-of-type .cell:last-of-type {
330
- border-radius: 0 0 .5rem 0;
331
- }
332
-
333
- .hidden {
334
- visibility: hidden;
335
- }
336
- `;
214
+ FtFilterableTable.styles = styles;
337
215
  __decorate([
338
216
  property({ attribute: false })
339
217
  ], FtFilterableTable.prototype, "data", void 0);