@ncino/web-components 2.2.0-preview.4 → 2.2.0-preview.6

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.
@@ -1,23 +1,33 @@
1
- import{a as s,x as a}from"../../../assets/index-chunk2.js";import{t as b}from"../../../assets/index-chunk3.js";import{N as p}from"../table.js";import"../../../assets/index-chunk.js";const c=":host{--ngc-table-header-background-color: #ececec;--ngc-table-header-border-bottom-color: #ececec}",g=":host{display:block;overflow:auto}table{border-spacing:0;width:100%}thead>tr{height:56px}tbody>tr,tfoot>tr{height:48px}th{top:0;position:sticky;z-index:100;min-height:56px;background:var(--ngc-table-header-background-color, #ececec);text-align:left}[dir=rtl] th.mat-header-cell{text-align:right}td{padding:0;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:var(--ngc-table-header-border-bottom-color, #ececec)}th:first-of-type,td:first-of-type{padding-left:24px}[dir=rtl] th:first-of-type,[dir=rtl] td:first-of-type{padding-left:0;padding-right:24px}th:last-of-type,td:last-of-type{padding-right:24px}[dir=rtl] th:last-of-type,[dir=rtl] td:last-of-type{padding-right:0;padding-left:24px}";var h=Object.defineProperty,f=Object.getOwnPropertyDescriptor,u=(t,e,o,r)=>{for(var l=r>1?void 0:r?f(e,o):e,d=t.length-1,i;d>=0;d--)(i=t[d])&&(l=(r?i(e,o,l):i(l))||l);return r&&l&&h(e,o,l),l};let n=class extends p{renderWrapper(t,e){return a`
2
- <table role="grid" aria-labelledby="${this.tableAriaLabelledBy}">
3
- ${t} ${e}
1
+ import{a,x as l}from"../../../assets/index-chunk2.js";import{t as p}from"../../../assets/index-chunk3.js";import{p as h}from"../../../assets/index-chunk5.js";import{s as n}from"../../../assets/index-chunk6.js";import{N as b}from"../table.js";import"../../checkbox/checkbox.gator.js";import"../../../assets/index-chunk.js";import"../../../utils/components/testable-lit-element/testable-lit-element.js";import"../../../utils/string-utils.js";import"../../../utils/lightdom-utils.js";import"../../icon/gator/icon.gator.js";import"../../icon/gator/templates/arrow-left.js";import"../../icon/icon-registry.js";import"../../icon/gator/templates/arrow-right.js";import"../../icon/gator/templates/calendar.js";import"../../icon/gator/templates/check-circle.js";import"../../icon/gator/templates/check.js";import"../../icon/gator/templates/checkbox.js";import"../../icon/gator/templates/checkbox-selected.js";import"../../icon/gator/templates/chevron-down.js";import"../../icon/gator/templates/chevron-left.js";import"../../icon/gator/templates/chevron-right.js";import"../../icon/gator/templates/chevron-up.js";import"../../icon/gator/templates/dashboard.js";import"../../icon/gator/templates/exit.js";import"../../icon/gator/templates/exit-circle.js";import"../../icon/gator/templates/eye-crossed.js";import"../../icon/gator/templates/info.js";import"../../icon/gator/templates/link.js";import"../../icon/gator/templates/overflow-menu.js";import"../../icon/gator/templates/percent.js";import"../../icon/gator/templates/picture.js";import"../../icon/gator/templates/shield-lock.js";import"../../icon/gator/templates/radio.js";import"../../icon/gator/templates/radio-selected.js";import"../../icon/gator/templates/restricted.js";import"../../icon/gator/templates/settings.js";import"../../icon/gator/templates/warning.js";const g=":host{--ngc-table-header-background-color: #ececec;--ngc-table-header-border-bottom-color: #ececec}",m=":host{display:block;overflow:auto}.gator-table{font-family:var(--ngc-font-family-body),sans-serif;border-spacing:0;width:100%}.gator-table thead>tr{height:56px}.gator-table tbody>tr,.gator-table tfoot>tr{height:48px}.gator-table th{top:0;position:sticky;z-index:100;min-height:56px;background:var(--ngc-table-header-background-color, #ececec);text-align:left}.gator-table [dir=rtl] th.mat-header-cell{text-align:right}.gator-table td{padding:0;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:var(--ngc-table-header-border-bottom-color, #ececec)}.gator-table th:first-of-type,.gator-table td:first-of-type{padding-left:24px}.gator-table [dir=rtl] th:first-of-type,.gator-table [dir=rtl] td:first-of-type{padding-left:0;padding-right:24px}.gator-table th:last-of-type,.gator-table td:last-of-type{padding-right:24px}.gator-table [dir=rtl] th:last-of-type,.gator-table [dir=rtl] td:last-of-type{padding-right:0;padding-left:24px}";var f=Object.defineProperty,u=Object.getOwnPropertyDescriptor,y=(e,t,r,o)=>{for(var i=o>1?void 0:o?u(t,r):t,s=e.length-1,d;s>=0;s--)(d=e[s])&&(i=(o?d(t,r,i):d(i))||i);return o&&i&&f(t,r,i),i};let c=class extends b{constructor(){super(...arguments),this.selectedRows=[]}renderWrapper(e,t){return l`
2
+ <table class="gator-table" role="grid" aria-labelledby="${this.tableAriaLabelledBy}">
3
+ ${e} ${t}
4
4
  </table>
5
- `}getTableHeader(t){const e=t.map(this.getTableHeaderColumn);return a`
5
+ `}getTableHeader(e){const t=e.map(this.getTableHeaderColumn);return this.selectable&&t.unshift(l`<th role="gridcell">
6
+ <ngc-checkbox
7
+ ?selected="${this.selectedRows.length===this.data.length}"
8
+ @change="${r=>this.handleSelectAll(r)}"
9
+ ></ngc-checkbox>
10
+ </th>`),l`
6
11
  <thead role="rowgroup">
7
12
  <tr role="row">
8
- ${e}
13
+ ${t}
9
14
  </tr>
10
15
  </thead>
11
- `}getTableHeaderColumn(t){return a`<th>${t.name}</th>`}getTableBody(t,e){const o=e.map(r=>this.getTableBodyRow(r,t));return a`
16
+ `}handleSelectAll(e){e.detail.selected?(this.selectedRows=[...this.data],this.data.forEach(t=>{t.selected=e.detail.selected})):(this.selectedRows=[],this.data.forEach(t=>{t.selected=!1})),this.dispatchEvent(new CustomEvent("selectall",{bubbles:!0,detail:{selectedRows:this.selectedRows}})),this.requestUpdate()}getTableHeaderColumn(e){return l`<th>${e.name}</th>`}getTableBody(e,t){const r=t.map(o=>this.getTableBodyRow(o,e));return l`
12
17
  <tbody role="rowgroup">
13
- ${o}
18
+ ${r}
14
19
  </tbody>
15
- `}getTableBodyRow(t,e){const o=e.map(r=>this.getTableBodyCell(t,r));return a`
20
+ `}getTableBodyRow(e,t){const r=t.map(o=>this.getTableBodyCell(e,o));return this.selectable&&r.unshift(l`<td role="gridcell">
21
+ <ngc-checkbox
22
+ ?selected="${e.selected}"
23
+ @change="${o=>this.handleTableBodyRowSelected(o,e)}"
24
+ ></ngc-checkbox>
25
+ </td>`),l`
16
26
  <tr role="row">
17
- ${o}
27
+ ${r}
18
28
  </tr>
19
- `}getTableBodyCell(t,e){return a`
29
+ `}handleTableBodyRowSelected(e,t){e.detail.selected?this.selectedRows.push(t):this.selectedRows=this.selectedRows.filter(r=>r!==t),this.dispatchEvent(new CustomEvent("rowselected",{bubbles:!0,detail:{data:t,selectedRows:this.selectedRows}}))}getTableBodyCell(e,t){return l`
20
30
  <td role="gridcell">
21
- ${this.getValueForCell(t,e)}
31
+ ${this.getValueForCell(e,t)}
22
32
  </td>
23
- `}getValueForCell(t,e){return typeof e.valueGetter=="function"?a`${e.valueGetter(t)}`:t[e.field]}render(){return this.columnDefinitions?this.renderWrapper(this.getTableHeader(this.columnDefinitions),this.getTableBody(this.columnDefinitions,this.data)):null}};n.styles=[s(c),s(g)];n=u([b("ngc-table")],n);
33
+ `}getValueForCell(e,t){return typeof t.valueGetter=="function"?l`${t.valueGetter(e)}`:e[t.field]}render(){return this.columnDefinitions?this.renderWrapper(this.getTableHeader(this.columnDefinitions),this.getTableBody(this.columnDefinitions,this.data)):null}};c.styles=[a(n),a(h),a(g),a(m)];c=y([p("ngc-table")],c);
@@ -1 +1 @@
1
- import"./gator/table.gator.js";import"../../assets/index-chunk2.js";import"../../assets/index-chunk3.js";import"./table.js";import"../../assets/index-chunk.js";
1
+ import"./gator/table.gator.js";import"../../assets/index-chunk2.js";import"../../assets/index-chunk3.js";import"../../assets/index-chunk5.js";import"../../assets/index-chunk6.js";import"./table.js";import"../../assets/index-chunk.js";import"../../utils/components/testable-lit-element/testable-lit-element.js";import"../checkbox/checkbox.gator.js";import"../../utils/string-utils.js";import"../../utils/lightdom-utils.js";import"../icon/gator/icon.gator.js";import"../icon/gator/templates/arrow-left.js";import"../icon/icon-registry.js";import"../icon/gator/templates/arrow-right.js";import"../icon/gator/templates/calendar.js";import"../icon/gator/templates/check-circle.js";import"../icon/gator/templates/check.js";import"../icon/gator/templates/checkbox.js";import"../icon/gator/templates/checkbox-selected.js";import"../icon/gator/templates/chevron-down.js";import"../icon/gator/templates/chevron-left.js";import"../icon/gator/templates/chevron-right.js";import"../icon/gator/templates/chevron-up.js";import"../icon/gator/templates/dashboard.js";import"../icon/gator/templates/exit.js";import"../icon/gator/templates/exit-circle.js";import"../icon/gator/templates/eye-crossed.js";import"../icon/gator/templates/info.js";import"../icon/gator/templates/link.js";import"../icon/gator/templates/overflow-menu.js";import"../icon/gator/templates/percent.js";import"../icon/gator/templates/picture.js";import"../icon/gator/templates/shield-lock.js";import"../icon/gator/templates/radio.js";import"../icon/gator/templates/radio-selected.js";import"../icon/gator/templates/restricted.js";import"../icon/gator/templates/settings.js";import"../icon/gator/templates/warning.js";
@@ -1 +1 @@
1
- import{r as s}from"../../assets/index-chunk2.js";import{n as a}from"../../assets/index-chunk.js";var b=Object.defineProperty,i=(e,l,o,u)=>{for(var t=void 0,r=e.length-1,p;r>=0;r--)(p=e[r])&&(t=p(l,o,t)||t);return t&&b(l,o,t),t};class n extends s{constructor(){super(...arguments),this.columnDefinitions=[],this.data=[],this.tableAriaLabelledBy=null}}i([a({type:Object,attribute:"column-definitions"})],n.prototype,"columnDefinitions");i([a({type:Object})],n.prototype,"data");i([a({type:String,attribute:"table-aria-labelledby"})],n.prototype,"tableAriaLabelledBy");export{n as N};
1
+ import{n as t}from"../../assets/index-chunk.js";import{T as p}from"../../utils/components/testable-lit-element/testable-lit-element.js";import"../../assets/index-chunk2.js";var b=Object.defineProperty,a=(r,o,n,f)=>{for(var e=void 0,i=r.length-1,s;i>=0;i--)(s=r[i])&&(e=s(o,n,e)||e);return e&&b(o,n,e),e};class l extends p{constructor(){super(...arguments),this.columnDefinitions=[],this.data=[],this.tableAriaLabelledBy=null,this.selectable=!1}}a([t({type:Object,attribute:"column-definitions"})],l.prototype,"columnDefinitions");a([t({type:Object})],l.prototype,"data");a([t({type:String,attribute:"table-aria-labelledby"})],l.prototype,"tableAriaLabelledBy");a([t({type:Boolean})],l.prototype,"selectable");export{l as N};
@@ -1,11 +1,14 @@
1
- import { NjcTable } from '../table.ts';
1
+ import { NjcTable, RowData } from '../table.ts';
2
2
  export declare class NgcTable extends NjcTable {
3
3
  static styles: import('lit').CSSResult[];
4
+ selectedRows: RowData[];
4
5
  renderWrapper(header: unknown, body: unknown): import('lit').TemplateResult<1>;
5
6
  private getTableHeader;
7
+ handleSelectAll(event: CustomEvent): void;
6
8
  private getTableHeaderColumn;
7
9
  private getTableBody;
8
10
  private getTableBodyRow;
11
+ handleTableBodyRowSelected(event: CustomEvent, rowData: RowData): void;
9
12
  private getTableBodyCell;
10
13
  private getValueForCell;
11
14
  render(): import('lit').TemplateResult<1> | null;
@@ -1,4 +1,4 @@
1
- import { LitElement } from 'lit';
1
+ import { TestableLitElement } from '../../utils/components/testable-lit-element/testable-lit-element.ts';
2
2
  export interface ColumnDefinition {
3
3
  id?: string;
4
4
  field: string;
@@ -8,8 +8,9 @@ export interface ColumnDefinition {
8
8
  export interface RowData {
9
9
  [key: string]: any;
10
10
  }
11
- export declare class NjcTable extends LitElement {
11
+ export declare class NjcTable extends TestableLitElement {
12
12
  columnDefinitions: ColumnDefinition[];
13
13
  data: RowData[];
14
14
  tableAriaLabelledBy: string | null;
15
+ selectable: boolean;
15
16
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ncino/web-components",
3
3
  "author": "nCino",
4
- "version": "2.2.0-preview.4",
4
+ "version": "2.2.0-preview.6",
5
5
  "license": "(c) Copyright 2023 nCino, Inc., all rights reserved",
6
6
  "publishConfig": {
7
7
  "registry": "https://registry.npmjs.org/"
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json",
3
3
  "name": "@ncino/web-components",
4
- "version": "2.2.0-preview.3",
4
+ "version": "2.2.0-preview.5",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
@@ -3657,7 +3657,7 @@
3657
3657
  },
3658
3658
  {
3659
3659
  "name": "ngc-table",
3660
- "description": "\n---\n",
3660
+ "description": "\n---\n\n\n### **Events:**\n - **selectall**\n- **rowselected**",
3661
3661
  "doc-url": "",
3662
3662
  "attributes": [
3663
3663
  {
@@ -3671,16 +3671,36 @@
3671
3671
  {
3672
3672
  "name": "table-aria-labelledby",
3673
3673
  "value": { "type": "string | null", "default": "null" }
3674
+ },
3675
+ {
3676
+ "name": "selectable",
3677
+ "value": { "type": "boolean", "default": "false" }
3678
+ },
3679
+ {
3680
+ "name": "data-testid",
3681
+ "value": { "type": "string | undefined", "default": "undefined" }
3674
3682
  }
3675
3683
  ],
3676
- "events": [],
3684
+ "events": [
3685
+ { "name": "selectall", "type": "CustomEvent" },
3686
+ { "name": "rowselected", "type": "CustomEvent" }
3687
+ ],
3677
3688
  "js": {
3678
3689
  "properties": [
3690
+ { "name": "selectedRows", "type": "RowData[]" },
3679
3691
  { "name": "columnDefinitions", "type": "ColumnDefinition[]" },
3680
3692
  { "name": "data", "type": "RowData[]" },
3681
- { "name": "tableAriaLabelledBy", "type": "string | null" }
3693
+ { "name": "tableAriaLabelledBy", "type": "string | null" },
3694
+ { "name": "selectable", "type": "boolean" },
3695
+ { "name": "dataTestid", "type": "string | undefined" },
3696
+ { "name": "labelDataTestid" },
3697
+ { "name": "helpTextDataTestid" },
3698
+ { "name": "errorMessageDataTestid" }
3682
3699
  ],
3683
- "events": []
3700
+ "events": [
3701
+ { "name": "selectall", "type": "CustomEvent" },
3702
+ { "name": "rowselected", "type": "CustomEvent" }
3703
+ ]
3684
3704
  }
3685
3705
  },
3686
3706
  {