scb-wc-test 0.1.177 → 0.1.178

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,11 +1,36 @@
1
- import{a as l,n as o,i as _,x as u,t as f}from"../../vendor/vendor.js";(function(){try{var d=typeof globalThis<"u"?globalThis:window;if(!d.__scb_ce_guard_installed__){d.__scb_ce_guard_installed__=!0;var r=customElements.define.bind(customElements);customElements.define=function(t,n,e){try{customElements.get(t)||r(t,n,e)}catch(a){var s=String(a||"");if(s.indexOf("already been used")===-1&&s.indexOf("NotSupportedError")===-1)throw a}}}}catch{}})();var b=Object.defineProperty,p=Object.getOwnPropertyDescriptor,i=(d,r,t,n)=>{for(var e=n>1?void 0:n?p(r,t):r,s=d.length-1,a;s>=0;s--)(a=d[s])&&(e=(n?a(r,t,e):a(e))||e);return n&&e&&b(r,t,e),e};let c=class extends _{constructor(){super(...arguments),this.data=[]}render(){return u`
2
- <div>
3
- <h3>SCB Table Advanced</h3>
4
- <!-- Table rendering logic here -->
5
- </div>
6
- `}};c.styles=l`
7
- :host {
8
- display: block;
9
- /* Add component styles here */
10
- }
11
- `;i([o({type:Array})],c.prototype,"data",2);c=i([f("scb-table-advanced")],c);
1
+ import{a as E,n as u,i as v,x as _,t as N}from"../../vendor/vendor.js";import"../scb-pagination/scb-pagination.js";import"../scb-icon-button/scb-icon-button.js";import"../scb-link/scb-link.js";import"../../vendor/vendor-material.js";import"../scb-button/scb-button.js";import"../../vendor/preload-helper.js";import"../scb-tooltip/scb-tooltip.js";(function(){try{var e=typeof globalThis<"u"?globalThis:window;if(!e.__scb_ce_guard_installed__){e.__scb_ce_guard_installed__=!0;var a=customElements.define.bind(customElements);customElements.define=function(r,l,s){try{customElements.get(r)||a(r,l,s)}catch(i){var t=String(i||"");if(t.indexOf("already been used")===-1&&t.indexOf("NotSupportedError")===-1)throw i}}}}catch{}})();var T=Object.defineProperty,w=Object.getOwnPropertyDescriptor,y=(e,a,r,l)=>{for(var s=l>1?void 0:l?w(a,r):a,t=e.length-1,i;t>=0;t--)(i=e[t])&&(s=(l?i(a,r,s):i(s))||s);return l&&s&&T(a,r,s),s};let d=class extends v{constructor(){super(...arguments),this.pagination=!1,this.pageSize=10,this.currentPage=1,this.totalRows=0,this._sortedColumn=null,this._sortDirection="asc",this._onSlotChange=()=>{this.pagination&&(this._updateTotalRows(),this._paginateTable())},this._onPaginationChange=e=>{const a=e.detail;a&&typeof a.page=="number"&&this._changePage(a.page)}}render(){const e=Math.ceil(this.totalRows/this.pageSize);return _`
2
+ <slot @slotchange=${this._onSlotChange}></slot>
3
+ <div class="pagination">
4
+ ${this.pagination&&e>1?_`
5
+ <scb-pagination
6
+ .page=${this.currentPage}
7
+ .totalPages=${e}
8
+ @page-change=${this._onPaginationChange}
9
+ variant="icon"
10
+ ></scb-pagination>
11
+ `:""}
12
+ </div>
13
+ `}firstUpdated(){const e=this.shadowRoot.querySelector("slot");e&&(e.addEventListener("slotchange",()=>this._attachThListeners()),this._attachThListeners())}_attachThListeners(){const e=this.shadowRoot.querySelector("slot");if(!e)return;const a=e.assignedNodes({flatten:!0}),r=[],l=[],s=[];a.forEach(t=>{t.nodeType===Node.ELEMENT_NODE&&(r.push(...t.querySelectorAll("th")),l.push(...t.querySelectorAll("td")),s.push(...t.querySelectorAll("tr")))}),r.forEach((t,i)=>{t.style.textAlign="left",t.style.padding="16px 0px 16px 32px",t.style.position="relative",t.style.backgroundColor="var(--md-sys-color-surface)",t.style.fontFamily="var(--md-sys-typescale-label-medium-font)",t.style.fontSize="var(--md-sys-typescale-label-medium-size)",t.style.lineHeight="var(--md-sys-typescale-label-medium-line-height)",t.style.fontWeight="var(--md-sys-typescale-label-medium-weight)",t.style.letterSpacing="var(--md-sys-typescale-label-medium-tracking)";const o=t.firstChild;if(o&&o.nodeType===Node.TEXT_NODE&&o.textContent?.trim()||o&&o.nodeType===Node.ELEMENT_NODE&&o.tagName.toLowerCase()!=="p"){const c=document.createElement("p");c.textContent=o.textContent?o.textContent.trim():"",c.style.margin="0",t.replaceChild(c,o),t.querySelectorAll("scb-icon-button.scb-sort-icon").forEach(h=>h.remove());const p=document.createElement("scb-icon-button");p.className="scb-sort-icon",p.onclick=()=>this._onThClick(i),p.setAttribute("variant","standard"),this._sortedColumn===i?(p.setAttribute("variant","filled-tonal"),p.setAttribute("icon",this._sortDirection==="asc"?"arrow_downward":"arrow_upward")):(p.setAttribute("icon","swap_horiz"),p.style.transform+=" rotate(90deg)");var n=document.createElement("div");n.style.display="flex",n.style.gap="12px",n.style.flexWrap="nowrap",n.style.alignItems="center",n.appendChild(c),n.appendChild(p),t.appendChild(n)}}),l.forEach(t=>{t.style.padding="16px 0px 16px 32px",t.style.textAlign="left",t.style.borderTop="1px solid var(--md-sys-color-outline-variant)",t.style.verticalAlign="text-top",t.style.backgroundColor="var(--md-sys-color-surface)",t.style.fontFamily="var(--md-sys-typescale-body-medium-font)",t.style.fontSize="var(--md-sys-typescale-body-medium-size)",t.style.lineHeight="var(--md-sys-typescale-body-medium-line-height)",t.style.fontWeight="var(--md-sys-typescale-body-medium-weight)",t.style.letterSpacing="var(--md-sys-typescale-body-medium-tracking)"}),s.forEach(t=>{const i=t.querySelectorAll("th");i.length>0&&i.forEach((n,c)=>{c===0&&(n.style.paddingLeft="24px"),c===i.length-1?n.style.paddingRight="24px":n.style.paddingRight=""});const o=t.querySelectorAll("td");o.length>0&&o.forEach((n,c)=>{c===0&&(n.style.paddingLeft="24px"),c===o.length-1?n.style.paddingRight="24px":n.style.paddingRight=""})}),this.pagination&&this._paginateTable()}_onThClick(e){this._sortedColumn===e?this._sortDirection=this._sortDirection==="asc"?"desc":"asc":(this._sortedColumn=e,this._sortDirection="asc"),this._sortTable(e,this._sortDirection),this._attachThListeners()}_sortTable(e,a){const r=this.shadowRoot.querySelector("slot");if(!r)return;const l=r.assignedNodes({flatten:!0});let s=null;if(l.forEach(o=>{if(o.nodeType===Node.ELEMENT_NODE){const n=o.querySelector("tbody");n&&(s=n)}}),!s)return;Array.from(s.querySelectorAll("tr")).sort((o,n)=>{const c=o.children[e]?.textContent?.trim()??"",p=n.children[e]?.textContent?.trim()??"",h=Date.parse(c.replace(/\s+/g," ")),f=Date.parse(p.replace(/\s+/g," "));if(!isNaN(h)&&!isNaN(f))return a==="asc"?h-f:f-h;const g=parseFloat(c.replace(",",".")),m=parseFloat(p.replace(",","."));if(!isNaN(g)&&!isNaN(m))return a==="asc"?g-m:m-g;const b=c.localeCompare(p,"sv");return a==="asc"?b:-b}).forEach(o=>s.appendChild(o)),this.pagination&&this._paginateTable()}_updateTotalRows(){const e=this.shadowRoot.querySelector("slot");if(!e)return;const a=e.assignedNodes({flatten:!0});let r=null;a.forEach(l=>{if(l.nodeType===Node.ELEMENT_NODE){const s=l.querySelector("tbody");s&&(r=s)}}),r&&(this.totalRows=r.querySelectorAll("tr").length)}_paginateTable(){const e=this.shadowRoot.querySelector("slot");if(!e)return;const a=e.assignedNodes({flatten:!0});let r=null;if(a.forEach(i=>{if(i.nodeType===Node.ELEMENT_NODE){const o=i.querySelector("tbody");o&&(r=o)}}),!r)return;const l=Array.from(r.querySelectorAll("tr"));l.forEach(i=>i.style.display="none");const s=(this.currentPage-1)*this.pageSize,t=s+this.pageSize;l.slice(s,t).forEach(i=>i.style.display="")}_changePage(e){const a=Math.ceil(this.totalRows/this.pageSize);e<1||e>a||(this.currentPage=e,this._paginateTable(),this.requestUpdate())}};d.styles=E`
14
+ :host {
15
+ display: block;
16
+ color: var(--md-sys-color-on-surface);
17
+ font-family: var(--brand, Inter);
18
+ }
19
+ ::slotted(table) {
20
+ border-collapse: collapse;
21
+ border-spacing: 0;
22
+ border-radius: 24px;
23
+ overflow: hidden;
24
+ }
25
+ .pagination {
26
+ margin-top: 16px;
27
+ display: flex;
28
+ justify-self: center;
29
+ }
30
+ ::slotted(th) .scb-sort-icon {
31
+ pointer-events: none;
32
+ }
33
+ ::slotted(th:hover) .scb-sort-icon {
34
+ pointer-events: auto;
35
+ }
36
+ `;y([u({type:Boolean,attribute:"with-pagination"})],d.prototype,"pagination",2);y([u({type:Number})],d.prototype,"pageSize",2);y([u({type:Number})],d.prototype,"currentPage",2);y([u({type:Number})],d.prototype,"totalRows",2);d=y([N("scb-table-advanced")],d);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scb-wc-test",
3
- "version": "0.1.177",
3
+ "version": "0.1.178",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
@@ -373,5 +373,5 @@
373
373
  },
374
374
  "./mvc/*": "./mvc/*"
375
375
  },
376
- "buildHash": "6F06332E7EDB55D186CB4ACF5B863ACC41DBF661A0B2C01D663DAB8F32924D30"
376
+ "buildHash": "F6A0BCA80C6A176CF415B8273DF3B4155F1A137E644B825050F83C180134685E"
377
377
  }
@@ -1,6 +1,20 @@
1
1
  import { LitElement } from 'lit';
2
2
  export declare class ScbTableAdvanced extends LitElement {
3
+ pagination: boolean;
4
+ pageSize: number;
5
+ currentPage: number;
6
+ totalRows: number;
7
+ private _sortedColumn;
8
+ private _sortDirection;
3
9
  static styles: import('lit').CSSResult;
4
- data: Array<any>;
5
10
  render(): import('lit-html').TemplateResult<1>;
11
+ firstUpdated(): void;
12
+ private _attachThListeners;
13
+ private _onThClick;
14
+ private _sortTable;
15
+ private _onSlotChange;
16
+ private _updateTotalRows;
17
+ private _paginateTable;
18
+ private _changePage;
19
+ private _onPaginationChange;
6
20
  }
@@ -1,35 +1,170 @@
1
- import { css as c, LitElement as d, html as v } from "lit";
2
- import { property as m, customElement as b } from "lit/decorators.js";
3
- var i = Object.defineProperty, h = Object.getOwnPropertyDescriptor, p = (n, r, o, t) => {
4
- for (var e = t > 1 ? void 0 : t ? h(r, o) : r, a = n.length - 1, l; a >= 0; a--)
5
- (l = n[a]) && (e = (t ? l(r, o, e) : l(e)) || e);
6
- return t && e && i(r, o, e), e;
1
+ import { css as w, LitElement as S, html as T } from "lit";
2
+ import { property as g, customElement as x } from "lit/decorators.js";
3
+ import "../scb-pagination/scb-pagination.js";
4
+ import "../scb-icon-button/scb-icon-button.js";
5
+ var C = Object.defineProperty, A = Object.getOwnPropertyDescriptor, u = (e, a, n, l) => {
6
+ for (var o = l > 1 ? void 0 : l ? A(a, n) : a, t = e.length - 1, i; t >= 0; t--)
7
+ (i = e[t]) && (o = (l ? i(a, n, o) : i(o)) || o);
8
+ return l && o && C(a, n, o), o;
7
9
  };
8
- let s = class extends d {
10
+ let h = class extends S {
9
11
  constructor() {
10
- super(...arguments), this.data = [];
12
+ super(...arguments), this.pagination = !1, this.pageSize = 10, this.currentPage = 1, this.totalRows = 0, this._sortedColumn = null, this._sortDirection = "asc", this._onSlotChange = () => {
13
+ this.pagination && (this._updateTotalRows(), this._paginateTable());
14
+ }, this._onPaginationChange = (e) => {
15
+ const a = e.detail;
16
+ a && typeof a.page == "number" && this._changePage(a.page);
17
+ };
11
18
  }
12
19
  render() {
13
- return v`
14
- <div>
15
- <h3>SCB Table Advanced</h3>
16
- <!-- Table rendering logic here -->
17
- </div>
18
- `;
20
+ const e = Math.ceil(this.totalRows / this.pageSize);
21
+ return T`
22
+ <slot @slotchange=${this._onSlotChange}></slot>
23
+ <div class="pagination">
24
+ ${this.pagination && e > 1 ? T`
25
+ <scb-pagination
26
+ .page=${this.currentPage}
27
+ .totalPages=${e}
28
+ @page-change=${this._onPaginationChange}
29
+ variant="icon"
30
+ ></scb-pagination>
31
+ ` : ""}
32
+ </div>
33
+ `;
34
+ }
35
+ firstUpdated() {
36
+ const e = this.shadowRoot.querySelector("slot");
37
+ e && (e.addEventListener("slotchange", () => this._attachThListeners()), this._attachThListeners());
38
+ }
39
+ _attachThListeners() {
40
+ const e = this.shadowRoot.querySelector("slot");
41
+ if (!e) return;
42
+ const a = e.assignedNodes({ flatten: !0 }), n = [], l = [], o = [];
43
+ a.forEach((t) => {
44
+ t.nodeType === Node.ELEMENT_NODE && (n.push(...t.querySelectorAll("th")), l.push(...t.querySelectorAll("td")), o.push(...t.querySelectorAll("tr")));
45
+ }), n.forEach((t, i) => {
46
+ var c;
47
+ t.style.textAlign = "left", t.style.padding = "16px 0px 16px 32px", t.style.position = "relative", t.style.backgroundColor = "var(--md-sys-color-surface)", t.style.fontFamily = "var(--md-sys-typescale-label-medium-font)", t.style.fontSize = "var(--md-sys-typescale-label-medium-size)", t.style.lineHeight = "var(--md-sys-typescale-label-medium-line-height)", t.style.fontWeight = "var(--md-sys-typescale-label-medium-weight)", t.style.letterSpacing = "var(--md-sys-typescale-label-medium-tracking)";
48
+ const s = t.firstChild;
49
+ if (s && s.nodeType === Node.TEXT_NODE && ((c = s.textContent) != null && c.trim()) || s && s.nodeType === Node.ELEMENT_NODE && s.tagName.toLowerCase() !== "p") {
50
+ const d = document.createElement("p");
51
+ d.textContent = s.textContent ? s.textContent.trim() : "", d.style.margin = "0", t.replaceChild(d, s), t.querySelectorAll("scb-icon-button.scb-sort-icon").forEach((y) => y.remove());
52
+ const p = document.createElement("scb-icon-button");
53
+ p.className = "scb-sort-icon", p.onclick = () => this._onThClick(i), p.setAttribute("variant", "standard"), this._sortedColumn === i ? (p.setAttribute("variant", "filled-tonal"), p.setAttribute("icon", this._sortDirection === "asc" ? "arrow_downward" : "arrow_upward")) : (p.setAttribute("icon", "swap_horiz"), p.style.transform += " rotate(90deg)");
54
+ var r = document.createElement("div");
55
+ r.style.display = "flex", r.style.gap = "12px", r.style.flexWrap = "nowrap", r.style.alignItems = "center", r.appendChild(d), r.appendChild(p), t.appendChild(r);
56
+ }
57
+ }), l.forEach((t) => {
58
+ t.style.padding = "16px 0px 16px 32px", t.style.textAlign = "left", t.style.borderTop = "1px solid var(--md-sys-color-outline-variant)", t.style.verticalAlign = "text-top", t.style.backgroundColor = "var(--md-sys-color-surface)", t.style.fontFamily = "var(--md-sys-typescale-body-medium-font)", t.style.fontSize = "var(--md-sys-typescale-body-medium-size)", t.style.lineHeight = "var(--md-sys-typescale-body-medium-line-height)", t.style.fontWeight = "var(--md-sys-typescale-body-medium-weight)", t.style.letterSpacing = "var(--md-sys-typescale-body-medium-tracking)";
59
+ }), o.forEach((t) => {
60
+ const i = t.querySelectorAll("th");
61
+ i.length > 0 && i.forEach((r, c) => {
62
+ c === 0 && (r.style.paddingLeft = "24px"), c === i.length - 1 ? r.style.paddingRight = "24px" : r.style.paddingRight = "";
63
+ });
64
+ const s = t.querySelectorAll("td");
65
+ s.length > 0 && s.forEach((r, c) => {
66
+ c === 0 && (r.style.paddingLeft = "24px"), c === s.length - 1 ? r.style.paddingRight = "24px" : r.style.paddingRight = "";
67
+ });
68
+ }), this.pagination && this._paginateTable();
69
+ }
70
+ _onThClick(e) {
71
+ this._sortedColumn === e ? this._sortDirection = this._sortDirection === "asc" ? "desc" : "asc" : (this._sortedColumn = e, this._sortDirection = "asc"), this._sortTable(e, this._sortDirection), this._attachThListeners();
72
+ }
73
+ _sortTable(e, a) {
74
+ const n = this.shadowRoot.querySelector("slot");
75
+ if (!n) return;
76
+ const l = n.assignedNodes({ flatten: !0 });
77
+ let o = null;
78
+ if (l.forEach((s) => {
79
+ if (s.nodeType === Node.ELEMENT_NODE) {
80
+ const r = s.querySelector("tbody");
81
+ r && (o = r);
82
+ }
83
+ }), !o) return;
84
+ Array.from(o.querySelectorAll("tr")).sort((s, r) => {
85
+ var _, E, N, v;
86
+ const c = ((E = (_ = s.children[e]) == null ? void 0 : _.textContent) == null ? void 0 : E.trim()) ?? "", d = ((v = (N = r.children[e]) == null ? void 0 : N.textContent) == null ? void 0 : v.trim()) ?? "", p = Date.parse(c.replace(/\s+/g, " ")), y = Date.parse(d.replace(/\s+/g, " "));
87
+ if (!isNaN(p) && !isNaN(y))
88
+ return a === "asc" ? p - y : y - p;
89
+ const f = parseFloat(c.replace(",", ".")), m = parseFloat(d.replace(",", "."));
90
+ if (!isNaN(f) && !isNaN(m))
91
+ return a === "asc" ? f - m : m - f;
92
+ const b = c.localeCompare(d, "sv");
93
+ return a === "asc" ? b : -b;
94
+ }).forEach((s) => o.appendChild(s)), this.pagination && this._paginateTable();
95
+ }
96
+ _updateTotalRows() {
97
+ const e = this.shadowRoot.querySelector("slot");
98
+ if (!e) return;
99
+ const a = e.assignedNodes({ flatten: !0 });
100
+ let n = null;
101
+ a.forEach((l) => {
102
+ if (l.nodeType === Node.ELEMENT_NODE) {
103
+ const o = l.querySelector("tbody");
104
+ o && (n = o);
105
+ }
106
+ }), n && (this.totalRows = n.querySelectorAll("tr").length);
107
+ }
108
+ _paginateTable() {
109
+ const e = this.shadowRoot.querySelector("slot");
110
+ if (!e) return;
111
+ const a = e.assignedNodes({ flatten: !0 });
112
+ let n = null;
113
+ if (a.forEach((i) => {
114
+ if (i.nodeType === Node.ELEMENT_NODE) {
115
+ const s = i.querySelector("tbody");
116
+ s && (n = s);
117
+ }
118
+ }), !n) return;
119
+ const l = Array.from(n.querySelectorAll("tr"));
120
+ l.forEach((i) => i.style.display = "none");
121
+ const o = (this.currentPage - 1) * this.pageSize, t = o + this.pageSize;
122
+ l.slice(o, t).forEach((i) => i.style.display = "");
123
+ }
124
+ _changePage(e) {
125
+ const a = Math.ceil(this.totalRows / this.pageSize);
126
+ e < 1 || e > a || (this.currentPage = e, this._paginateTable(), this.requestUpdate());
19
127
  }
20
128
  };
21
- s.styles = c`
22
- :host {
23
- display: block;
24
- /* Add component styles here */
25
- }
26
- `;
27
- p([
28
- m({ type: Array })
29
- ], s.prototype, "data", 2);
30
- s = p([
31
- b("scb-table-advanced")
32
- ], s);
129
+ h.styles = w`
130
+ :host {
131
+ display: block;
132
+ color: var(--md-sys-color-on-surface);
133
+ font-family: var(--brand, Inter);
134
+ }
135
+ ::slotted(table) {
136
+ border-collapse: collapse;
137
+ border-spacing: 0;
138
+ border-radius: 24px;
139
+ overflow: hidden;
140
+ }
141
+ .pagination {
142
+ margin-top: 16px;
143
+ display: flex;
144
+ justify-self: center;
145
+ }
146
+ ::slotted(th) .scb-sort-icon {
147
+ pointer-events: none;
148
+ }
149
+ ::slotted(th:hover) .scb-sort-icon {
150
+ pointer-events: auto;
151
+ }
152
+ `;
153
+ u([
154
+ g({ type: Boolean, attribute: "with-pagination" })
155
+ ], h.prototype, "pagination", 2);
156
+ u([
157
+ g({ type: Number })
158
+ ], h.prototype, "pageSize", 2);
159
+ u([
160
+ g({ type: Number })
161
+ ], h.prototype, "currentPage", 2);
162
+ u([
163
+ g({ type: Number })
164
+ ], h.prototype, "totalRows", 2);
165
+ h = u([
166
+ x("scb-table-advanced")
167
+ ], h);
33
168
  export {
34
- s as ScbTableAdvanced
169
+ h as ScbTableAdvanced
35
170
  };