@3t-transform/threeteeui 0.0.16 → 0.0.18

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.
Files changed (125) hide show
  1. package/dist/cjs/{index-864b7110.js → index-bf777121.js} +3 -0
  2. package/dist/cjs/loader.cjs.js +2 -2
  3. package/dist/cjs/tttx-button.cjs.entry.js +25 -19
  4. package/dist/cjs/tttx-checkbox.cjs.entry.js +18 -18
  5. package/dist/cjs/tttx-form.cjs.entry.js +365 -365
  6. package/dist/cjs/tttx-icon.cjs.entry.js +14 -1856
  7. package/dist/cjs/tttx-input-calendar.cjs.entry.js +125 -0
  8. package/dist/cjs/tttx-keyvalue-block.cjs.entry.js +33 -0
  9. package/dist/cjs/tttx-list.cjs.entry.js +188 -188
  10. package/dist/cjs/tttx-loading-spinner.cjs.entry.js +16 -16
  11. package/dist/cjs/tttx-popover-content.cjs.entry.js +13 -13
  12. package/dist/cjs/tttx-standalone-input.cjs.entry.js +127 -127
  13. package/dist/cjs/tttx-table.cjs.entry.js +50 -50
  14. package/dist/cjs/tttx.cjs.js +2 -2
  15. package/dist/collection/collection-manifest.json +2 -0
  16. package/dist/collection/components/atoms/tttx-button/tttx-button.css +94 -18
  17. package/dist/collection/components/atoms/tttx-button/tttx-button.js +110 -93
  18. package/dist/collection/components/atoms/tttx-button/tttx-button.stories.js +74 -27
  19. package/dist/collection/components/atoms/tttx-icon/tttx-icon.css +8 -5
  20. package/dist/collection/components/atoms/tttx-icon/tttx-icon.js +62 -116
  21. package/dist/collection/components/atoms/tttx-icon/tttx-icon.stories.js +22 -47
  22. package/dist/collection/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.css +26 -0
  23. package/dist/collection/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.js +56 -0
  24. package/dist/collection/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.stories.js +12 -0
  25. package/dist/collection/components/atoms/tttx-loading-spinner/tttx-loading-spinner.js +67 -66
  26. package/dist/collection/components/atoms/tttx-loading-spinner/tttx-loading-spinner.stories.js +17 -17
  27. package/dist/collection/components/atoms/tttx-popover-content/tttx-popover-content.js +97 -96
  28. package/dist/collection/components/atoms/tttx-popover-content/tttx-popover-content.stories.js +23 -23
  29. package/dist/collection/components/atoms/ttx-checkbox/tttx-checkbox.js +102 -101
  30. package/dist/collection/components/atoms/ttx-checkbox/tttx-checkbox.stories.js +9 -9
  31. package/dist/collection/components/molecules/tttx-form/tttx-form.css +95 -11
  32. package/dist/collection/components/molecules/tttx-form/tttx-form.js +452 -451
  33. package/dist/collection/components/molecules/tttx-form/tttx-form.stories.js +109 -109
  34. package/dist/collection/components/molecules/tttx-input-calendar/tttx-input-calendar.css +93 -0
  35. package/dist/collection/components/molecules/tttx-input-calendar/tttx-input-calendar.js +174 -0
  36. package/dist/collection/components/molecules/tttx-input-calendar/tttx-input-calendar.stories.js +27 -0
  37. package/dist/collection/components/molecules/tttx-list/tttx-list.js +312 -311
  38. package/dist/collection/components/molecules/tttx-list/tttx-list.stories.js +14 -14
  39. package/dist/collection/components/molecules/tttx-standalone-input/tttx-standalone-input.js +570 -569
  40. package/dist/collection/components/molecules/tttx-standalone-input/tttx-standalone-input.stories.js +134 -134
  41. package/dist/collection/components/molecules/tttx-table/tttx-table.js +174 -177
  42. package/dist/collection/components/molecules/tttx-table/tttx-table.stories.js +65 -65
  43. package/dist/collection/components/palette.stories.js +7 -7
  44. package/dist/collection/docs/gettingstarted-developer.stories.js +5 -5
  45. package/dist/collection/icons.js +2838 -2838
  46. package/dist/collection/index.js +1 -1
  47. package/dist/components/index.d.ts +2 -0
  48. package/dist/components/index.js +2 -0
  49. package/dist/components/tttx-button.js +1 -40
  50. package/dist/components/tttx-button2.js +56 -0
  51. package/dist/components/tttx-checkbox.js +36 -36
  52. package/dist/components/tttx-form.js +382 -382
  53. package/dist/components/tttx-icon2.js +32 -1874
  54. package/dist/components/tttx-input-calendar.d.ts +11 -0
  55. package/dist/components/tttx-input-calendar.js +157 -0
  56. package/dist/components/tttx-keyvalue-block.d.ts +11 -0
  57. package/dist/components/tttx-keyvalue-block.js +49 -0
  58. package/dist/components/tttx-list.js +214 -214
  59. package/dist/components/tttx-loading-spinner2.js +33 -33
  60. package/dist/components/tttx-popover-content2.js +32 -32
  61. package/dist/components/tttx-standalone-input.js +168 -169
  62. package/dist/components/tttx-table.js +79 -79
  63. package/dist/esm/{index-232e347b.js → index-a05bd606.js} +3 -0
  64. package/dist/esm/loader.js +3 -3
  65. package/dist/esm/polyfills/core-js.js +0 -0
  66. package/dist/esm/polyfills/dom.js +0 -0
  67. package/dist/esm/polyfills/es5-html-element.js +0 -0
  68. package/dist/esm/polyfills/index.js +0 -0
  69. package/dist/esm/polyfills/system.js +0 -0
  70. package/dist/esm/tttx-button.entry.js +25 -19
  71. package/dist/esm/tttx-checkbox.entry.js +18 -18
  72. package/dist/esm/tttx-form.entry.js +365 -365
  73. package/dist/esm/tttx-icon.entry.js +14 -1856
  74. package/dist/esm/tttx-input-calendar.entry.js +121 -0
  75. package/dist/esm/tttx-keyvalue-block.entry.js +29 -0
  76. package/dist/esm/tttx-list.entry.js +188 -188
  77. package/dist/esm/tttx-loading-spinner.entry.js +16 -16
  78. package/dist/esm/tttx-popover-content.entry.js +13 -13
  79. package/dist/esm/tttx-standalone-input.entry.js +127 -127
  80. package/dist/esm/tttx-table.entry.js +50 -50
  81. package/dist/esm/tttx.js +3 -3
  82. package/dist/tttx/{p-3973b7dd.entry.js → p-037d286f.entry.js} +1 -1
  83. package/dist/tttx/{p-184c4fae.js → p-07b134af.js} +1 -1
  84. package/dist/tttx/{p-125f06b3.entry.js → p-1b63f16a.entry.js} +1 -1
  85. package/dist/tttx/p-45afb84c.entry.js +1 -0
  86. package/dist/tttx/p-68ff0f39.entry.js +1 -0
  87. package/dist/tttx/{p-6828fe6f.entry.js → p-93763d3c.entry.js} +1 -1
  88. package/dist/tttx/p-a5808741.entry.js +1 -0
  89. package/dist/tttx/{p-fe4c70b2.entry.js → p-a92ca87e.entry.js} +1 -1
  90. package/dist/tttx/{p-5ce1ba22.entry.js → p-a96ca037.entry.js} +1 -1
  91. package/dist/tttx/p-dc087fd8.entry.js +1 -0
  92. package/dist/tttx/p-e3cc75bb.entry.js +1 -0
  93. package/dist/tttx/{p-01e1894e.entry.js → p-f579ed1e.entry.js} +1 -1
  94. package/dist/tttx/tttx.esm.js +1 -1
  95. package/dist/types/components/atoms/tttx-button/tttx-button.d.ts +10 -9
  96. package/dist/types/components/atoms/tttx-button/tttx-button.stories.d.ts +10 -20
  97. package/dist/types/components/atoms/tttx-icon/tttx-icon.d.ts +5 -14
  98. package/dist/types/components/atoms/tttx-icon/tttx-icon.stories.d.ts +20 -21
  99. package/dist/types/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.d.ts +4 -0
  100. package/dist/types/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.stories.d.ts +6 -0
  101. package/dist/types/components/atoms/tttx-loading-spinner/tttx-loading-spinner.d.ts +6 -6
  102. package/dist/types/components/atoms/tttx-loading-spinner/tttx-loading-spinner.stories.d.ts +17 -17
  103. package/dist/types/components/atoms/tttx-popover-content/tttx-popover-content.d.ts +7 -7
  104. package/dist/types/components/atoms/tttx-popover-content/tttx-popover-content.stories.d.ts +18 -18
  105. package/dist/types/components/atoms/ttx-checkbox/tttx-checkbox.d.ts +9 -9
  106. package/dist/types/components/atoms/ttx-checkbox/tttx-checkbox.stories.d.ts +6 -6
  107. package/dist/types/components/molecules/tttx-form/tttx-form.d.ts +134 -134
  108. package/dist/types/components/molecules/tttx-form/tttx-form.stories.d.ts +12 -12
  109. package/dist/types/components/molecules/tttx-input-calendar/tttx-input-calendar.d.ts +19 -0
  110. package/dist/types/components/molecules/tttx-input-calendar/tttx-input-calendar.stories.d.ts +26 -0
  111. package/dist/types/components/molecules/tttx-list/tttx-list.d.ts +51 -51
  112. package/dist/types/components/molecules/tttx-list/tttx-list.stories.d.ts +13 -13
  113. package/dist/types/components/molecules/tttx-standalone-input/tttx-standalone-input.d.ts +38 -38
  114. package/dist/types/components/molecules/tttx-standalone-input/tttx-standalone-input.stories.d.ts +106 -106
  115. package/dist/types/components/molecules/tttx-table/tttx-table.d.ts +15 -15
  116. package/dist/types/components/molecules/tttx-table/tttx-table.stories.d.ts +21 -21
  117. package/dist/types/components/palette.stories.d.ts +6 -6
  118. package/dist/types/components.d.ts +46 -15
  119. package/dist/types/docs/gettingstarted-developer.stories.d.ts +5 -5
  120. package/dist/types/icons.d.ts +2 -2
  121. package/dist/types/index.d.ts +1 -1
  122. package/package.json +4 -4
  123. package/dist/tttx/p-10316ff1.entry.js +0 -1
  124. package/dist/tttx/p-b1c22f5f.entry.js +0 -1
  125. package/dist/tttx/p-c7f9be65.entry.js +0 -1
@@ -1,311 +1,312 @@
1
- import { h, Host } from "@stencil/core";
2
- export class TttxList {
3
- constructor() {
4
- this.rowCount = 0;
5
- this.name = undefined;
6
- this.selectable = undefined;
7
- this.items = [];
8
- this.selectedIds = [];
9
- this.loading = true;
10
- this.lastPage = false;
11
- }
12
- listLoadHandler(event) {
13
- if (event.detail.name !== this.name)
14
- return;
15
- this.items = [...this.items, ...event.detail.items];
16
- this.loading = false;
17
- this.lastPage = event.detail.lastPage;
18
- this.renderRows(event.detail.items);
19
- if (this.scrollableParent.clientHeight === this.scrollableParent.scrollHeight)
20
- this.listPaginateHandler();
21
- }
22
- listPaginateHandler() {
23
- // We don't want to emit an event to load the next page if this is the last page, or if we're already loading
24
- if (this.lastPage || this.loading)
25
- return;
26
- this.loading = true;
27
- this.listPaginate.emit({ name: this.name });
28
- }
29
- listClearDataCacheHandler(event) {
30
- if (event.detail.name !== this.name)
31
- return;
32
- this.items = [];
33
- this.selectedIds = [];
34
- this.listItemContainer()
35
- .querySelectorAll(".tttx-list__row")
36
- .forEach((node) => {
37
- node.remove();
38
- });
39
- this.rowCount = 0;
40
- this.lastPage = false;
41
- this.loading = false;
42
- }
43
- listActionSelectedEventHandler(event) {
44
- if (event.detail.name !== this.name || !this.selectable || this.selectedIds.length === 0)
45
- return;
46
- const selectedRows = this.selectedIds.map(id => {
47
- return this.items[id];
48
- });
49
- if (event.detail.removeRows)
50
- this.removeSelectedRows();
51
- this.listSelectedEvent.emit({
52
- name: this.name,
53
- eventName: event.detail.eventName,
54
- selectedRows,
55
- });
56
- }
57
- removeSelectedRows() {
58
- const orderedSelectedIds = [...this.selectedIds].sort((a, b) => {
59
- return b - a;
60
- });
61
- orderedSelectedIds.forEach(itemIndex => {
62
- this.items.splice(itemIndex, 1);
63
- this.listItemContainer().removeChild(this.listItemContainer().querySelector(`[data-row-id="${itemIndex}"]`));
64
- // If this removes the scrollbar and we're not on the last page, load in a new page
65
- if (this.scrollableParent.clientHeight === this.scrollableParent.scrollHeight)
66
- this.listPaginateHandler();
67
- });
68
- // Empty selected ids with mutation rather than assignment to avoid unecessary component rerender
69
- this.selectedIds.splice(0, this.selectedIds.length);
70
- }
71
- listItemClickHandler(itemData) {
72
- if (this.selectedIds.length !== 0)
73
- return;
74
- this.listItemClick.emit({ itemData, name: this.name });
75
- }
76
- componentWillLoad() {
77
- this.template = this.host.querySelector("template");
78
- this.scrollableParent = this.getScrollableParent(this.host);
79
- const scrollableContext = this.scrollableParent === document.scrollingElement ? document : this.scrollableParent;
80
- scrollableContext.addEventListener("scroll", this.scrollHandler.bind(this));
81
- window.addEventListener("resize", this.scrollHandler.bind(this));
82
- }
83
- componentDidLoad() {
84
- // Emit event to load first page
85
- this.listPaginate.emit({ name: this.name });
86
- }
87
- listItemContainer() {
88
- return this.host.shadowRoot.querySelector(".list-item-container");
89
- }
90
- async scrollHandler() {
91
- const { clientHeight, scrollTop, scrollHeight } = this.scrollableParent;
92
- if (Math.abs(scrollHeight - clientHeight - scrollTop) < 26)
93
- this.listPaginateHandler();
94
- }
95
- isScrollable(node) {
96
- const hasScrollbar = ["scroll", "auto"].includes(node.style.overflowY);
97
- return hasScrollbar;
98
- }
99
- getScrollableParent(node) {
100
- if (!node || node === document.body) {
101
- return document.scrollingElement;
102
- }
103
- else {
104
- return this.isScrollable(node) ? node : this.getScrollableParent(node.parentElement);
105
- }
106
- }
107
- appendRowCheckbox(rowContainer) {
108
- if (!this.selectable)
109
- return;
110
- const rowId = this.rowCount;
111
- const checkbox = document.createElement("input");
112
- checkbox.setAttribute("type", "checkbox");
113
- checkbox.addEventListener("click", e => {
114
- e.stopPropagation();
115
- if (e.target.checked) {
116
- this.selectedIds = [...this.selectedIds, rowId];
117
- rowContainer.classList.add("selected");
118
- }
119
- else {
120
- this.selectedIds = this.selectedIds.filter(id => {
121
- return id !== rowId;
122
- });
123
- rowContainer.classList.remove("selected");
124
- }
125
- });
126
- rowContainer.setAttribute("data-row-id", `${rowId}`);
127
- this.rowCount++;
128
- rowContainer.appendChild(checkbox);
129
- }
130
- appendSeededTemplate(rowData, rowContainer) {
131
- this.template.childNodes.forEach(child => {
132
- const clone = child.cloneNode(false);
133
- if (clone.getAttribute("data-fields")) {
134
- const fields = clone.getAttribute("data-fields").replace(/\s/g, "").split(",");
135
- const filteredRowData = Object.fromEntries(fields.map((field) => {
136
- return [field, rowData[field]];
137
- }));
138
- clone.setAttribute("row-data", JSON.stringify(filteredRowData));
139
- }
140
- else {
141
- clone.setAttribute("row-data", JSON.stringify(rowData));
142
- }
143
- rowContainer.appendChild(clone);
144
- });
145
- }
146
- appendGenericTemplate(rowData, rowContainer) {
147
- const row = document.createElement("div");
148
- row.classList.add("generic-template__content");
149
- row.textContent = rowData.text;
150
- rowContainer.appendChild(row);
151
- if (!rowData.icon)
152
- return;
153
- const icon = document.createElement("span");
154
- icon.classList.add("material-symbols-rounded");
155
- icon.textContent = rowData.icon;
156
- if (rowData.iconColor)
157
- icon.style["color"] = rowData.iconColor;
158
- row.prepend(icon);
159
- }
160
- row(rowData) {
161
- const rowContainer = document.createElement("div");
162
- rowContainer.classList.add("tttx-list__row");
163
- rowContainer.addEventListener("click", () => {
164
- this.listItemClickHandler(rowData);
165
- });
166
- this.appendRowCheckbox(rowContainer);
167
- this.template ? this.appendSeededTemplate(rowData, rowContainer) : this.appendGenericTemplate(rowData, rowContainer);
168
- return rowContainer;
169
- }
170
- renderRows(batchData) {
171
- batchData.forEach(rowData => {
172
- this.listItemContainer().appendChild(this.row(rowData));
173
- });
174
- }
175
- loadIndicator() {
176
- if (!this.loading)
177
- return;
178
- return h("div", { class: "load-indicator" }, h("tttx-loading-spinner", { size: 'large' }));
179
- }
180
- render() {
181
- return (h(Host, null, h("div", { class: "list-item-container", tabindex: "0" }, !this.loading && this.items.length === 0 ? "No data to display" : undefined), this.loadIndicator()));
182
- }
183
- static get is() { return "tttx-list"; }
184
- static get encapsulation() { return "shadow"; }
185
- static get originalStyleUrls() {
186
- return {
187
- "$": ["tttx-list.scss"]
188
- };
189
- }
190
- static get styleUrls() {
191
- return {
192
- "$": ["tttx-list.css"]
193
- };
194
- }
195
- static get properties() {
196
- return {
197
- "name": {
198
- "type": "string",
199
- "mutable": false,
200
- "complexType": {
201
- "original": "string",
202
- "resolved": "string",
203
- "references": {}
204
- },
205
- "required": false,
206
- "optional": false,
207
- "docs": {
208
- "tags": [],
209
- "text": ""
210
- },
211
- "attribute": "name",
212
- "reflect": false
213
- },
214
- "selectable": {
215
- "type": "boolean",
216
- "mutable": false,
217
- "complexType": {
218
- "original": "boolean",
219
- "resolved": "boolean",
220
- "references": {}
221
- },
222
- "required": false,
223
- "optional": false,
224
- "docs": {
225
- "tags": [],
226
- "text": ""
227
- },
228
- "attribute": "selectable",
229
- "reflect": false
230
- }
231
- };
232
- }
233
- static get states() {
234
- return {
235
- "items": {},
236
- "selectedIds": {},
237
- "loading": {},
238
- "lastPage": {}
239
- };
240
- }
241
- static get events() {
242
- return [{
243
- "method": "listPaginate",
244
- "name": "listPaginate",
245
- "bubbles": true,
246
- "cancelable": true,
247
- "composed": true,
248
- "docs": {
249
- "tags": [],
250
- "text": ""
251
- },
252
- "complexType": {
253
- "original": "any",
254
- "resolved": "any",
255
- "references": {}
256
- }
257
- }, {
258
- "method": "listSelectedEvent",
259
- "name": "listSelectedEvent",
260
- "bubbles": true,
261
- "cancelable": true,
262
- "composed": true,
263
- "docs": {
264
- "tags": [],
265
- "text": ""
266
- },
267
- "complexType": {
268
- "original": "any",
269
- "resolved": "any",
270
- "references": {}
271
- }
272
- }, {
273
- "method": "listItemClick",
274
- "name": "listItemClick",
275
- "bubbles": true,
276
- "cancelable": true,
277
- "composed": true,
278
- "docs": {
279
- "tags": [],
280
- "text": ""
281
- },
282
- "complexType": {
283
- "original": "any",
284
- "resolved": "any",
285
- "references": {}
286
- }
287
- }];
288
- }
289
- static get elementRef() { return "host"; }
290
- static get listeners() {
291
- return [{
292
- "name": "listPageLoad",
293
- "method": "listLoadHandler",
294
- "target": "document",
295
- "capture": false,
296
- "passive": false
297
- }, {
298
- "name": "listClearDataCache",
299
- "method": "listClearDataCacheHandler",
300
- "target": "document",
301
- "capture": false,
302
- "passive": false
303
- }, {
304
- "name": "listActionSelectedEvent",
305
- "method": "listActionSelectedEventHandler",
306
- "target": "document",
307
- "capture": false,
308
- "passive": false
309
- }];
310
- }
311
- }
1
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2
+ import { h, Host } from '@stencil/core';
3
+ export class TttxList {
4
+ constructor() {
5
+ this.rowCount = 0;
6
+ this.name = undefined;
7
+ this.selectable = undefined;
8
+ this.items = [];
9
+ this.selectedIds = [];
10
+ this.loading = true;
11
+ this.lastPage = false;
12
+ }
13
+ listLoadHandler(event) {
14
+ if (event.detail.name !== this.name)
15
+ return;
16
+ this.items = [...this.items, ...event.detail.items];
17
+ this.loading = false;
18
+ this.lastPage = event.detail.lastPage;
19
+ this.renderRows(event.detail.items);
20
+ if (this.scrollableParent.clientHeight === this.scrollableParent.scrollHeight)
21
+ this.listPaginateHandler();
22
+ }
23
+ listPaginateHandler() {
24
+ // We don't want to emit an event to load the next page if this is the last page, or if we're already loading
25
+ if (this.lastPage || this.loading)
26
+ return;
27
+ this.loading = true;
28
+ this.listPaginate.emit({ name: this.name });
29
+ }
30
+ listClearDataCacheHandler(event) {
31
+ if (event.detail.name !== this.name)
32
+ return;
33
+ this.items = [];
34
+ this.selectedIds = [];
35
+ this.listItemContainer()
36
+ .querySelectorAll('.tttx-list__row')
37
+ .forEach((node) => {
38
+ node.remove();
39
+ });
40
+ this.rowCount = 0;
41
+ this.lastPage = false;
42
+ this.loading = false;
43
+ }
44
+ listActionSelectedEventHandler(event) {
45
+ if (event.detail.name !== this.name || !this.selectable || this.selectedIds.length === 0)
46
+ return;
47
+ const selectedRows = this.selectedIds.map(id => {
48
+ return this.items[id];
49
+ });
50
+ if (event.detail.removeRows)
51
+ this.removeSelectedRows();
52
+ this.listSelectedEvent.emit({
53
+ name: this.name,
54
+ eventName: event.detail.eventName,
55
+ selectedRows,
56
+ });
57
+ }
58
+ removeSelectedRows() {
59
+ const orderedSelectedIds = [...this.selectedIds].sort((a, b) => {
60
+ return b - a;
61
+ });
62
+ orderedSelectedIds.forEach(itemIndex => {
63
+ this.items.splice(itemIndex, 1);
64
+ this.listItemContainer().removeChild(this.listItemContainer().querySelector(`[data-row-id="${itemIndex}"]`));
65
+ // If this removes the scrollbar and we're not on the last page, load in a new page
66
+ if (this.scrollableParent.clientHeight === this.scrollableParent.scrollHeight)
67
+ this.listPaginateHandler();
68
+ });
69
+ // Empty selected ids with mutation rather than assignment to avoid unecessary component rerender
70
+ this.selectedIds.splice(0, this.selectedIds.length);
71
+ }
72
+ listItemClickHandler(itemData) {
73
+ if (this.selectedIds.length !== 0)
74
+ return;
75
+ this.listItemClick.emit({ itemData, name: this.name });
76
+ }
77
+ componentWillLoad() {
78
+ this.template = this.host.querySelector('template');
79
+ this.scrollableParent = this.getScrollableParent(this.host);
80
+ const scrollableContext = this.scrollableParent === document.scrollingElement ? document : this.scrollableParent;
81
+ scrollableContext.addEventListener('scroll', this.scrollHandler.bind(this));
82
+ window.addEventListener('resize', this.scrollHandler.bind(this));
83
+ }
84
+ componentDidLoad() {
85
+ // Emit event to load first page
86
+ this.listPaginate.emit({ name: this.name });
87
+ }
88
+ listItemContainer() {
89
+ return this.host.shadowRoot.querySelector('.list-item-container');
90
+ }
91
+ async scrollHandler() {
92
+ const { clientHeight, scrollTop, scrollHeight } = this.scrollableParent;
93
+ if (Math.abs(scrollHeight - clientHeight - scrollTop) < 26)
94
+ this.listPaginateHandler();
95
+ }
96
+ isScrollable(node) {
97
+ const hasScrollbar = ['scroll', 'auto'].includes(node.style.overflowY);
98
+ return hasScrollbar;
99
+ }
100
+ getScrollableParent(node) {
101
+ if (!node || node === document.body) {
102
+ return document.scrollingElement;
103
+ }
104
+ else {
105
+ return this.isScrollable(node) ? node : this.getScrollableParent(node.parentElement);
106
+ }
107
+ }
108
+ appendRowCheckbox(rowContainer) {
109
+ if (!this.selectable)
110
+ return;
111
+ const rowId = this.rowCount;
112
+ const checkbox = document.createElement('input');
113
+ checkbox.setAttribute('type', 'checkbox');
114
+ checkbox.addEventListener('click', e => {
115
+ e.stopPropagation();
116
+ if (e.target.checked) {
117
+ this.selectedIds = [...this.selectedIds, rowId];
118
+ rowContainer.classList.add('selected');
119
+ }
120
+ else {
121
+ this.selectedIds = this.selectedIds.filter(id => {
122
+ return id !== rowId;
123
+ });
124
+ rowContainer.classList.remove('selected');
125
+ }
126
+ });
127
+ rowContainer.setAttribute('data-row-id', `${rowId}`);
128
+ this.rowCount++;
129
+ rowContainer.appendChild(checkbox);
130
+ }
131
+ appendSeededTemplate(rowData, rowContainer) {
132
+ this.template.childNodes.forEach(child => {
133
+ const clone = child.cloneNode(false);
134
+ if (clone.getAttribute('data-fields')) {
135
+ const fields = clone.getAttribute('data-fields').replace(/\s/g, '').split(',');
136
+ const filteredRowData = Object.fromEntries(fields.map((field) => {
137
+ return [field, rowData[field]];
138
+ }));
139
+ clone.setAttribute('row-data', JSON.stringify(filteredRowData));
140
+ }
141
+ else {
142
+ clone.setAttribute('row-data', JSON.stringify(rowData));
143
+ }
144
+ rowContainer.appendChild(clone);
145
+ });
146
+ }
147
+ appendGenericTemplate(rowData, rowContainer) {
148
+ const row = document.createElement('div');
149
+ row.classList.add('generic-template__content');
150
+ row.textContent = rowData.text;
151
+ rowContainer.appendChild(row);
152
+ if (!rowData.icon)
153
+ return;
154
+ const icon = document.createElement('span');
155
+ icon.classList.add('material-symbols-rounded');
156
+ icon.textContent = rowData.icon;
157
+ if (rowData.iconColor)
158
+ icon.style['color'] = rowData.iconColor;
159
+ row.prepend(icon);
160
+ }
161
+ row(rowData) {
162
+ const rowContainer = document.createElement('div');
163
+ rowContainer.classList.add('tttx-list__row');
164
+ rowContainer.addEventListener('click', () => {
165
+ this.listItemClickHandler(rowData);
166
+ });
167
+ this.appendRowCheckbox(rowContainer);
168
+ this.template ? this.appendSeededTemplate(rowData, rowContainer) : this.appendGenericTemplate(rowData, rowContainer);
169
+ return rowContainer;
170
+ }
171
+ renderRows(batchData) {
172
+ batchData.forEach(rowData => {
173
+ this.listItemContainer().appendChild(this.row(rowData));
174
+ });
175
+ }
176
+ loadIndicator() {
177
+ if (!this.loading)
178
+ return;
179
+ return h("div", { class: "load-indicator" }, h("tttx-loading-spinner", { size: 'large' }));
180
+ }
181
+ render() {
182
+ return (h(Host, null, h("div", { class: "list-item-container", tabindex: "0" }, !this.loading && this.items.length === 0 ? 'No data to display' : undefined), this.loadIndicator()));
183
+ }
184
+ static get is() { return "tttx-list"; }
185
+ static get encapsulation() { return "shadow"; }
186
+ static get originalStyleUrls() {
187
+ return {
188
+ "$": ["tttx-list.scss"]
189
+ };
190
+ }
191
+ static get styleUrls() {
192
+ return {
193
+ "$": ["tttx-list.css"]
194
+ };
195
+ }
196
+ static get properties() {
197
+ return {
198
+ "name": {
199
+ "type": "string",
200
+ "mutable": false,
201
+ "complexType": {
202
+ "original": "string",
203
+ "resolved": "string",
204
+ "references": {}
205
+ },
206
+ "required": false,
207
+ "optional": false,
208
+ "docs": {
209
+ "tags": [],
210
+ "text": ""
211
+ },
212
+ "attribute": "name",
213
+ "reflect": false
214
+ },
215
+ "selectable": {
216
+ "type": "boolean",
217
+ "mutable": false,
218
+ "complexType": {
219
+ "original": "boolean",
220
+ "resolved": "boolean",
221
+ "references": {}
222
+ },
223
+ "required": false,
224
+ "optional": false,
225
+ "docs": {
226
+ "tags": [],
227
+ "text": ""
228
+ },
229
+ "attribute": "selectable",
230
+ "reflect": false
231
+ }
232
+ };
233
+ }
234
+ static get states() {
235
+ return {
236
+ "items": {},
237
+ "selectedIds": {},
238
+ "loading": {},
239
+ "lastPage": {}
240
+ };
241
+ }
242
+ static get events() {
243
+ return [{
244
+ "method": "listPaginate",
245
+ "name": "listPaginate",
246
+ "bubbles": true,
247
+ "cancelable": true,
248
+ "composed": true,
249
+ "docs": {
250
+ "tags": [],
251
+ "text": ""
252
+ },
253
+ "complexType": {
254
+ "original": "any",
255
+ "resolved": "any",
256
+ "references": {}
257
+ }
258
+ }, {
259
+ "method": "listSelectedEvent",
260
+ "name": "listSelectedEvent",
261
+ "bubbles": true,
262
+ "cancelable": true,
263
+ "composed": true,
264
+ "docs": {
265
+ "tags": [],
266
+ "text": ""
267
+ },
268
+ "complexType": {
269
+ "original": "any",
270
+ "resolved": "any",
271
+ "references": {}
272
+ }
273
+ }, {
274
+ "method": "listItemClick",
275
+ "name": "listItemClick",
276
+ "bubbles": true,
277
+ "cancelable": true,
278
+ "composed": true,
279
+ "docs": {
280
+ "tags": [],
281
+ "text": ""
282
+ },
283
+ "complexType": {
284
+ "original": "any",
285
+ "resolved": "any",
286
+ "references": {}
287
+ }
288
+ }];
289
+ }
290
+ static get elementRef() { return "host"; }
291
+ static get listeners() {
292
+ return [{
293
+ "name": "listPageLoad",
294
+ "method": "listLoadHandler",
295
+ "target": "document",
296
+ "capture": false,
297
+ "passive": false
298
+ }, {
299
+ "name": "listClearDataCache",
300
+ "method": "listClearDataCacheHandler",
301
+ "target": "document",
302
+ "capture": false,
303
+ "passive": false
304
+ }, {
305
+ "name": "listActionSelectedEvent",
306
+ "method": "listActionSelectedEventHandler",
307
+ "target": "document",
308
+ "capture": false,
309
+ "passive": false
310
+ }];
311
+ }
312
+ }