@spectric/ui 0.0.12 → 0.0.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.
package/README.MD CHANGED
@@ -1,6 +1,6 @@
1
1
  # Component Examples and playground
2
2
 
3
- https://pages.spectric.com/web/spectric-ui/?path=/docs/spectric-ui-components-ui-page--docs
3
+ https://pages.spectric.com/web/spectric-ui/
4
4
 
5
5
  # Developing
6
6
 
@@ -26,6 +26,7 @@ export declare class TableCellElement<T> extends LitElement implements CellProps
26
26
  constructor();
27
27
  protected updated(_changedProperties: PropertyValues): void;
28
28
  protected createRenderRoot(): HTMLElement | DocumentFragment;
29
+ _emitFilter(filter: FilterEvent<T>): void;
29
30
  _handleFilterOut: () => void;
30
31
  _handleFilterFor: () => void;
31
32
  protected render(): unknown;
@@ -1,6 +1,6 @@
1
1
  import { LitElement, PropertyValues, TemplateResult } from 'lit';
2
2
  import { HTMLElementTagWithEvents, ReactElementWithPropsAndEvents } from '../types';
3
- import { PaginationProps } from '../pagination';
3
+ import { PaginationChangeProps, PaginationProps } from '../pagination';
4
4
  import { FilterEvent } from './cell';
5
5
  export declare const TableElementTag = "spectric-table";
6
6
  export type { TableProps, TableEvents };
@@ -17,7 +17,7 @@ export declare enum TableSortOption {
17
17
  export type TableSortOptionTypes = `${TableSortOption}`;
18
18
  export declare enum TableSortDirection {
19
19
  ascending = "ascending",
20
- decending = "decending",
20
+ descending = "descending",
21
21
  none = "none"
22
22
  }
23
23
  export type TableSortDirectionTypes = `${TableSortDirection}`;
@@ -78,13 +78,17 @@ export declare class TableElement<T> extends LitElement implements TableProps<T>
78
78
  private __DO_NOT_USE_filter;
79
79
  private selected;
80
80
  protected createRenderRoot(): HTMLElement | DocumentFragment;
81
+ deselectAll(): void;
82
+ selectAll(): void;
81
83
  _handleSelectAllChange: (e: DomEvent<HTMLInputElement>) => void;
82
84
  protected update(changedProperties: PropertyValues): void;
83
85
  protected render(): unknown;
84
86
  }
85
87
  interface TableEvents {
86
88
  'change': (event: CustomEvent<TableDataOptions<any>>) => void;
89
+ 'paginationChange': (event: CustomEvent<PaginationChangeProps>) => void;
87
90
  'filter': (event: CustomEvent<FilterEvent<any>>) => void;
91
+ 'sortChange': (event: CustomEvent<ColumnSettings<any>>) => void;
88
92
  }
89
93
  declare global {
90
94
  interface HTMLElementTagNameMap {
@@ -2025,7 +2025,7 @@
2025
2025
  },
2026
2026
  {
2027
2027
  "name": "spectric-table",
2028
- "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 * `change` {`CustomEvent<TableDataOptions<T>>`} - \n\n * `filter` {`CustomEvent<FilterEvent<T>>`} - \n\n * `selected` {`CustomEvent<T[]>`} - \n\nAttributes:\n\n * `select` {`\"none\" | \"multi\" | \"single\"`} - \n\n * `sort` {`\"multi\" | \"single\"`} - \n\n * `rowHeight` {`number`} - Needed for virtualization\n\nProperties:\n\n * `_handlePaginationChange` - \n\n * `_handleSortChange` - \n\n * `_emitChange` - \n\n * `__DO_NOT_USE_filter` - \n\n * `selected` {`T[]`} - \n\n * `_handleSelectAllChange` - \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>[]`} - ",
2028
+ "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 * `select` {`\"none\" | \"multi\" | \"single\"`} - \n\n * `sort` {`\"multi\" | \"single\"`} - \n\n * `rowHeight` {`number`} - Needed for virtualization\n\nProperties:\n\n * `_handlePaginationChange` - \n\n * `_handleSortChange` - \n\n * `_emitChange` - \n\n * `__DO_NOT_USE_filter` - \n\n * `selected` {`T[]`} - \n\n * `_handleSelectAllChange` - \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>[]`} - ",
2029
2029
  "attributes": [
2030
2030
  {
2031
2031
  "name": "select",
@@ -2058,6 +2058,10 @@
2058
2058
  "name": "rowHeight",
2059
2059
  "description": "`rowHeight` {`number`} - Needed for virtualization\n\nProperty: rowHeight\n\nDefault: 25"
2060
2060
  },
2061
+ {
2062
+ "name": "onpaginationChange",
2063
+ "description": "`paginationChange` {`CustomEvent<PaginationChangeProps>`} - "
2064
+ },
2061
2065
  {
2062
2066
  "name": "onchange",
2063
2067
  "description": "`change` {`CustomEvent<TableDataOptions<T>>`} - "
@@ -2066,6 +2070,10 @@
2066
2070
  "name": "onfilter",
2067
2071
  "description": "`filter` {`CustomEvent<FilterEvent<T>>`} - "
2068
2072
  },
2073
+ {
2074
+ "name": "onsortChange",
2075
+ "description": "`sortChange` {`CustomEvent<ColumnSettings<T>>`} - "
2076
+ },
2069
2077
  {
2070
2078
  "name": "onselected",
2071
2079
  "description": "`selected` {`CustomEvent<T[]>`} - "
package/dist/index.es.js CHANGED
@@ -4340,7 +4340,11 @@ const Nc = "spectric-table-header";
4340
4340
  let br = class extends T {
4341
4341
  constructor() {
4342
4342
  super(...arguments), this.columns = [], this._handleSortChange = (i) => {
4343
- i = JSON.parse(JSON.stringify(i)), i.sortable && (i.sortDirection === F.none || i.sortDirection === void 0 ? i.sortDirection = F.ascending : i.sortDirection === F.ascending ? i.sortDirection = F.decending : i.sortDirection === F.decending && (i.sortDirection = F.none), this.dispatchEvent(new CustomEvent("sortChange", { detail: i })));
4343
+ i = JSON.parse(JSON.stringify(i)), i.sortable && (i.sortDirection === F.none || i.sortDirection === void 0 ? i.sortDirection = F.ascending : i.sortDirection === F.ascending ? i.sortDirection = F.descending : i.sortDirection === F.descending && (i.sortDirection = F.none), this.dispatchEvent(new CustomEvent("sortChange", {
4344
+ composed: !0,
4345
+ bubbles: !0,
4346
+ detail: i
4347
+ })));
4344
4348
  };
4345
4349
  }
4346
4350
  createRenderRoot() {
@@ -4352,7 +4356,7 @@ let br = class extends T {
4352
4356
  ${this.columns.map((i) => {
4353
4357
  let r = ["header-contents"];
4354
4358
  i.filterable, i.sortable && r.push("sortable");
4355
- let o = i.width ? `width:${i.width}px;` : "", s = i.sortDirection === F.ascending ? "🠉" : i.sortDirection == F.decending ? "🠋" : "", n = i.sortDirection || F.none;
4359
+ let o = i.width ? `width:${i.width}px;` : "", s = i.sortDirection === F.ascending ? "🠉" : i.sortDirection == F.descending ? "🠋" : "", n = i.sortDirection || F.none;
4356
4360
  return x`
4357
4361
  <td @click=${() => this._handleSortChange(i)} style="${o}">
4358
4362
  <div class=${r.join(" ")} >${i.title || i.key}
@@ -4380,28 +4384,20 @@ let Me = class extends T {
4380
4384
  constructor() {
4381
4385
  super(), this._handleFilterOut = () => {
4382
4386
  let i;
4383
- this.column.key && typeof this.row == "object" && (i = ze(this.row, this.column.key)), this.dispatchEvent(new CustomEvent("filter", {
4384
- composed: !0,
4385
- bubbles: !0,
4386
- detail: {
4387
- include: !1,
4388
- row: this.row,
4389
- value: i,
4390
- column: this.column
4391
- }
4392
- }));
4387
+ this.column.key && typeof this.row == "object" && (i = ze(this.row, this.column.key)), this._emitFilter({
4388
+ include: !1,
4389
+ row: this.row,
4390
+ value: i,
4391
+ column: this.column
4392
+ });
4393
4393
  }, this._handleFilterFor = () => {
4394
4394
  let i;
4395
- this.column.key && typeof this.row == "object" && (i = ze(this.row, this.column.key)), this.dispatchEvent(new CustomEvent("filter", {
4396
- composed: !0,
4397
- bubbles: !0,
4398
- detail: {
4399
- include: !0,
4400
- row: this.row,
4401
- value: i,
4402
- column: this.column
4403
- }
4404
- }));
4395
+ this.column.key && typeof this.row == "object" && (i = ze(this.row, this.column.key)), this._emitFilter({
4396
+ include: !0,
4397
+ row: this.row,
4398
+ value: i,
4399
+ column: this.column
4400
+ });
4405
4401
  }, this.styleRules = document.createElement("span").style;
4406
4402
  }
4407
4403
  updated(i) {
@@ -4410,6 +4406,13 @@ let Me = class extends T {
4410
4406
  createRenderRoot() {
4411
4407
  return this;
4412
4408
  }
4409
+ _emitFilter(i) {
4410
+ this.dispatchEvent(new CustomEvent("filter", {
4411
+ composed: !0,
4412
+ bubbles: !0,
4413
+ detail: i
4414
+ }));
4415
+ }
4413
4416
  render() {
4414
4417
  let i;
4415
4418
  this.column.render ? i = this.column.render(this.row, this.index, this.table) : this.column.key && typeof this.row == "object" ? i = ze(this.row, this.column.key) : i = x`error`;
@@ -4616,9 +4619,9 @@ const Qc = (i) => i.map(({ key: r, sortDirection: o, compareFn: s }) => (n, e) =
4616
4619
  return s(n, e);
4617
4620
  if (typeof p == "number" || typeof p == "bigint" || typeof p == "boolean") {
4618
4621
  let g = p - h;
4619
- return o === F.decending && (g = g * -1), g;
4622
+ return o === F.descending && (g = g * -1), g;
4620
4623
  } else if (typeof p == "string")
4621
- return p.localeCompare(h) * (o === F.decending ? -1 : 1);
4624
+ return p.localeCompare(h) * (o === F.descending ? -1 : 1);
4622
4625
  });
4623
4626
  var qc = Object.defineProperty, Wc = Object.getOwnPropertyDescriptor, ge = (i, r, o, s) => {
4624
4627
  for (var n = s > 1 ? void 0 : s ? Wc(r, o) : r, e = i.length - 1, p; e >= 0; e--)
@@ -4626,7 +4629,7 @@ var qc = Object.defineProperty, Wc = Object.getOwnPropertyDescriptor, ge = (i, r
4626
4629
  return s && n && qc(r, o, n), n;
4627
4630
  };
4628
4631
  const Yc = "spectric-table";
4629
- var Kc = /* @__PURE__ */ ((i) => (i.multi = "multi", i.single = "single", i.none = "none", i))(Kc || {}), Zc = /* @__PURE__ */ ((i) => (i.multi = "multi", i.single = "single", i))(Zc || {}), F = /* @__PURE__ */ ((i) => (i.ascending = "ascending", i.decending = "decending", i.none = "none", i))(F || {});
4632
+ var Kc = /* @__PURE__ */ ((i) => (i.multi = "multi", i.single = "single", i.none = "none", i))(Kc || {}), Zc = /* @__PURE__ */ ((i) => (i.multi = "multi", i.single = "single", i))(Zc || {}), F = /* @__PURE__ */ ((i) => (i.ascending = "ascending", i.descending = "descending", i.none = "none", i))(F || {});
4630
4633
  let ae = class extends T {
4631
4634
  constructor() {
4632
4635
  super(...arguments), this.data = [], this.columns = [], this.select = "none", this.sort = "single", this.rowHeight = 25, this._handlePaginationChange = (i) => {
@@ -4634,7 +4637,7 @@ let ae = class extends T {
4634
4637
  let r = { ...this.pagination, ...i.detail }, { totalItems: o, page: s, pageSize: n } = r;
4635
4638
  o && s && n && (s - 1) * n > o && (r.page = 1), this.pagination = r;
4636
4639
  }
4637
- this._emitChange();
4640
+ this.dispatchEvent(new CustomEvent("paginationChange", { detail: i.detail })), this._emitChange();
4638
4641
  }, this._handleSortChange = (i) => {
4639
4642
  let r = i.detail, o = this.columns.find((s) => s.key == r.key);
4640
4643
  if (!o) {
@@ -4648,9 +4651,9 @@ let ae = class extends T {
4648
4651
  let { pagination: i, columns: r } = this;
4649
4652
  this.dispatchEvent(new CustomEvent("change", { detail: { pagination: i, columns: r } }));
4650
4653
  }, this.__DO_NOT_USE_filter = () => {
4651
- this.dispatchEvent(new CustomEvent("filter"));
4654
+ this.dispatchEvent(new CustomEvent("filter")), this.dispatchEvent(new CustomEvent("sortChange"));
4652
4655
  }, this.selected = [], this._handleSelectAllChange = (i) => {
4653
- i.stopPropagation(), i.target.checked ? this.selected = [...this.data] : this.selected = [], this.dispatchEvent(new CustomEvent("selected", { detail: this.selected }));
4656
+ i.stopPropagation(), i.target.checked ? this.selectAll() : this.deselectAll();
4654
4657
  };
4655
4658
  }
4656
4659
  static getDefaultDataSorterAndPaginatior(i) {
@@ -4679,6 +4682,12 @@ let ae = class extends T {
4679
4682
  createRenderRoot() {
4680
4683
  return this;
4681
4684
  }
4685
+ deselectAll() {
4686
+ this.selected = [], this.dispatchEvent(new CustomEvent("selected", { detail: this.selected }));
4687
+ }
4688
+ selectAll() {
4689
+ this.selected = [...this.data], this.dispatchEvent(new CustomEvent("selected", { detail: this.selected }));
4690
+ }
4682
4691
  update(i) {
4683
4692
  i.has("select") && this.select === "single" && this.selected.length > 1 && (this.selected = [this.selected[0]], this.dispatchEvent(new CustomEvent("selected", { detail: [...this.selected] }))), super.update(i);
4684
4693
  }