@spectric/ui 0.0.22 → 0.0.23

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.
@@ -2,6 +2,7 @@ import { LitElement, PropertyValues, TemplateResult } from 'lit';
2
2
  import { HTMLElementTagWithEvents, ReactElementWithPropsAndEvents } from '../types';
3
3
  import { PaginationChangeProps, PaginationProps } from '../pagination';
4
4
  import { FilterEvent } from './cell';
5
+ import { ButtonSizesTypes } from '../Button';
5
6
  export declare const TableElementTag = "spectric-table";
6
7
  export type { TableProps, TableEvents };
7
8
  export type DomRenderable = HTMLElement | TemplateResult | string | number | null | undefined;
@@ -21,6 +22,11 @@ export declare enum TableSortDirection {
21
22
  none = "none"
22
23
  }
23
24
  export type TableSortDirectionTypes = `${TableSortDirection}`;
25
+ export type CellAction<T> = {
26
+ tooltip: DomRenderable;
27
+ icon: DomRenderable;
28
+ onClick: (row: T, column: ColumnSettings<T>) => void;
29
+ };
24
30
  export type ColumnSettings<T> = {
25
31
  [TABLE_CREATED_SELECTION_COLUMN]?: boolean;
26
32
  width?: number;
@@ -34,6 +40,7 @@ export type ColumnSettings<T> = {
34
40
  sortDirection?: TableSortDirectionTypes;
35
41
  filterable?: boolean;
36
42
  disableCellOverflowTooltip?: boolean;
43
+ cellActions?: CellAction<T>[];
37
44
  title?: DomRenderable | ((table: SpectricTableElement<T>) => DomRenderable);
38
45
  /**
39
46
  * Key to used for getting data from an object for a cell
@@ -85,6 +92,8 @@ export declare class SpectricTableElement<T = any> extends LitElement implements
85
92
  * Needed for virtualization
86
93
  */
87
94
  fontSize: number;
95
+ protected cellActionButtonSize: ButtonSizesTypes;
96
+ getCellActionButtonSize(): "small" | "large" | "medium" | "xsmall" | "xxsmall" | "tiny";
88
97
  static getDefaultDataSorterAndPaginatior<T>(data: T[]): (props: TableDataOptions<T>) => T[];
89
98
  private _handlePaginationChange;
90
99
  private _handleSortChange;
@@ -2074,7 +2074,7 @@
2074
2074
  },
2075
2075
  {
2076
2076
  "name": "spectric-table",
2077
- "description": "React example\n<iframe width=\"100%\" height=\"400px\" src=\"https://stackblitz.com/edit/react-ts-2ue7azag?ctl=1&embed=1&file=App.tsx&hideExplorer=1&hideNavigation=1\"/>\n\nEvents:\n\n * `paginationChange` {`CustomEvent<PaginationChangeProps>`} - \n\n * `change` {`CustomEvent<TableDataOptions<T>>`} - \n\n * `filter` {`CustomEvent<FilterEvent<T>>`} - \n\n * `sortChange` {`CustomEvent<ColumnSettings<T>>`} - \n\n * `selected` {`CustomEvent<T[]>`} - \n\nAttributes:\n\n * `fontSize` {`number`} - Needed for virtualization\n\n * `select` {`\"none\" | \"multi\" | \"single\"`} - \n\n * `sort` {`\"multi\" | \"single\"`} - \n\n * `rowHeight` {`number`} - Needed for virtualization\n\n * `sortOrder` {`string[]`} - \n\nProperties:\n\n * `fontSize` {`number`} - Needed for virtualization\n\n * `_handlePaginationChange` - \n\n * `_handleSortChange` - \n\n * `_handleColumnResize` - \n\n * `_emitChange` - \n\n * `__DO_NOT_USE_filter` - \n\n * `selected` {`T[]`} - \n\n * `_getRowHeight` - \n\n * `_handleSelectAllChange` - \n\n * `selectColumnConfig` {`ColumnSettings<T>`} - \n\n * `data` {`T[]`} - \n\n * `select` {`\"none\" | \"multi\" | \"single\"`} - \n\n * `sort` {`\"multi\" | \"single\"`} - \n\n * `rowHeight` {`number`} - Needed for virtualization\n\n * `pagination` {`PaginationProps | undefined`} - \n\n * `columns` {`ColumnSettings<T>[]`} - \n\n * `sortOrder` {`string[]`} - ",
2077
+ "description": "React example\n<iframe width=\"100%\" height=\"400px\" src=\"https://stackblitz.com/edit/react-ts-2ue7azag?ctl=1&embed=1&file=App.tsx&hideExplorer=1&hideNavigation=1\"/>\n\nEvents:\n\n * `paginationChange` {`CustomEvent<PaginationChangeProps>`} - \n\n * `change` {`CustomEvent<TableDataOptions<T>>`} - \n\n * `filter` {`CustomEvent<FilterEvent<T>>`} - \n\n * `sortChange` {`CustomEvent<ColumnSettings<T>>`} - \n\n * `selected` {`CustomEvent<T[]>`} - \n\nAttributes:\n\n * `fontSize` {`number`} - Needed for virtualization\n\n * `select` {`\"none\" | \"multi\" | \"single\"`} - \n\n * `sort` {`\"multi\" | \"single\"`} - \n\n * `rowHeight` {`number`} - Needed for virtualization\n\n * `sortOrder` {`string[]`} - \n\nProperties:\n\n * `fontSize` {`number`} - Needed for virtualization\n\n * `cellActionButtonSize` {`\"large\" | \"medium\" | \"small\" | \"xsmall\" | \"xxsmall\" | \"tiny\"`} - \n\n * `_handlePaginationChange` - \n\n * `_handleSortChange` - \n\n * `_handleColumnResize` - \n\n * `_emitChange` - \n\n * `__DO_NOT_USE_filter` - \n\n * `selected` {`T[]`} - \n\n * `_getRowHeight` - \n\n * `_handleSelectAllChange` - \n\n * `selectColumnConfig` {`ColumnSettings<T>`} - \n\n * `data` {`T[]`} - \n\n * `select` {`\"none\" | \"multi\" | \"single\"`} - \n\n * `sort` {`\"multi\" | \"single\"`} - \n\n * `rowHeight` {`number`} - Needed for virtualization\n\n * `pagination` {`PaginationProps | undefined`} - \n\n * `columns` {`ColumnSettings<T>[]`} - \n\n * `sortOrder` {`string[]`} - ",
2078
2078
  "attributes": [
2079
2079
  {
2080
2080
  "name": "fontSize",
@@ -2257,7 +2257,7 @@
2257
2257
  },
2258
2258
  {
2259
2259
  "name": "spectric-storybook-example-content",
2260
- "description": "Attributes:\n\n * `frameWidth` {`number`} - \n\nProperties:\n\n * `frameWidth` {`number`} - \n\n * `query` {`SpectricQuery`} - \n\n * `dataSorter` - \n\n * `dialogOpen` {`boolean`} - \n\n * `tableData` {`TestData[]`} - \n\n * `columns` {`ColumnSettings<TestData>[]`} - \n\n * `pagination` {`PaginationProps`} - \n\n * `_handleFilter` - \n\n * `_handlePaginationChange` - ",
2260
+ "description": "Attributes:\n\n * `frameWidth` {`number`} - \n\nProperties:\n\n * `frameWidth` {`number`} - \n\n * `query` {`SpectricQuery`} - \n\n * `dataSorter` - \n\n * `dialogOpen` {`boolean`} - \n\n * `tableData` {`TestData[]`} - \n\n * `columns` - \n\n * `pagination` {`PaginationProps`} - \n\n * `_handleFilter` - \n\n * `_handlePaginationChange` - ",
2261
2261
  "attributes": [
2262
2262
  {
2263
2263
  "name": "frameWidth",
package/dist/index.es.js CHANGED
@@ -2182,8 +2182,7 @@ let z = class extends B {
2182
2182
  @click=${() => {
2183
2183
  this.checked = !this.checked, this.value = !!this.checked;
2184
2184
  }} icon size=${this.size || "xxsmall"} variant=${this.checked ? "primary" : "secondary"}>${this.checked ? "✓" : " "}</spectric-button>
2185
-
2186
- ${this.label}
2185
+ ${this.label.length ? m`<span>${this.label}</span>` : null}
2187
2186
  </div>
2188
2187
  </label>
2189
2188
  `;
@@ -6213,13 +6212,15 @@ let Te = class extends B {
6213
6212
  return this.column.render ? e = this.column.render(this.row, this.index, this.table) : this.column.key && typeof this.row == "object" ? e = mt(this.row, this.column.key) : e = m`error`, e;
6214
6213
  }
6215
6214
  render() {
6215
+ var a;
6216
6216
  let e = this.getRenderedValue(), t = ["cell-contents"];
6217
- this.column.filterable && t.push("filterable");
6218
- let i = oc(
6219
- this.column.filterable ? m`<div class="table-cell-actions">
6217
+ (this.column.filterable || (a = this.column.cellActions) != null && a.length) && t.push("hasActions");
6218
+ const i = this.table.getCellActionButtonSize();
6219
+ let s = oc(
6220
+ this.column.filterable ? m`
6220
6221
  <spectric-button
6221
6222
  @click=${this._handleFilterOut}
6222
- size="tiny"
6223
+ .size=${i}
6223
6224
  variant="text"
6224
6225
  icon
6225
6226
  tooltip="Filter Out Value"
@@ -6227,14 +6228,21 @@ let Te = class extends B {
6227
6228
  >
6228
6229
  <spectric-button
6229
6230
  @click=${this._handleFilterFor}
6230
- size="tiny"
6231
+ .size=${i}
6231
6232
  variant="text"
6232
6233
  icon
6233
6234
  tooltip="Filter For Value"
6234
6235
  >+</spectric-button
6235
6236
  >
6236
- </div>` : null
6237
- );
6237
+ ` : null
6238
+ ), r = (this.column.cellActions || []).map((n) => m`<spectric-button
6239
+ @click=${() => n.onClick(this.row, this.column)}
6240
+ .size=${i}
6241
+ variant="text"
6242
+ icon
6243
+ .tooltip=${n.tooltip}
6244
+ >${n.icon}</spectric-button
6245
+ >`);
6238
6246
  return this.styleRules = {
6239
6247
  width: this.column.width ? this.column.width + "px" : null,
6240
6248
  whiteSpace: this.column.whiteSpace || null
@@ -6243,7 +6251,9 @@ let Te = class extends B {
6243
6251
  style=${ri(this.styleRules)}
6244
6252
  @mouseenter=${this._displayOverflowTooltip}
6245
6253
  >
6246
- ${i}
6254
+ <div class="table-cell-actions ${i}">
6255
+ ${r} ${s}
6256
+ </div>
6247
6257
  <div class=${t.join(" ")}>
6248
6258
  ${this.overflow ? m`<spectric-tooltip .text=${this.overflow}></spectric-tooltip>` : null}<span>${e}</span>
6249
6259
  </div>
@@ -6500,7 +6510,7 @@ const Bt = 4, Ur = Symbol(
6500
6510
  );
6501
6511
  let ie = class extends B {
6502
6512
  constructor() {
6503
- super(...arguments), this.data = [], this.columns = [], this.select = "none", this.sort = "single", this.sortOrder = [], this.rowHeight = 25, this.fontSize = 16, this._handlePaginationChange = (e) => {
6513
+ super(...arguments), this.data = [], this.columns = [], this.select = "none", this.sort = "single", this.sortOrder = [], this.rowHeight = 25, this.fontSize = 16, this.cellActionButtonSize = "xxsmall", this._handlePaginationChange = (e) => {
6504
6514
  if (this.pagination) {
6505
6515
  let t = { ...this.pagination, ...e.detail }, { totalItems: i, page: s, pageSize: r } = t;
6506
6516
  i && s && r && (s - 1) * r > i && (t.page = 1), this.pagination = t;
@@ -6543,6 +6553,8 @@ let ie = class extends B {
6543
6553
  e.stopPropagation(), e.target.checked ? this.selectAll() : this.deselectAll();
6544
6554
  }, this.selectColumnConfig = {
6545
6555
  [Ur]: !0,
6556
+ allowResize: !1,
6557
+ filterable: !1,
6546
6558
  width: 39,
6547
6559
  title: (e) => e.select === "multi" ? m`<spectric-input
6548
6560
  variant="checkbox"
@@ -6574,6 +6586,9 @@ let ie = class extends B {
6574
6586
  }
6575
6587
  };
6576
6588
  }
6589
+ getCellActionButtonSize() {
6590
+ return this.cellActionButtonSize;
6591
+ }
6577
6592
  static getDefaultDataSorterAndPaginatior(e) {
6578
6593
  return (t) => {
6579
6594
  let i = (t.sortOrder || []).map(