@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
@@ -0,0 +1,125 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-bf777121.js');
6
+
7
+ const tttxInputCalendarCss = ".material-symbols-rounded{font-variation-settings:\"FILL\" 1, \"wght\" 400, \"GRAD\" 0, \"opsz\" 24}:host{display:block;--border-radius:4px;position:relative}.calcontainer{-webkit-perspective:500px;perspective:500px}.lefty{float:left}.righty{float:right}.calendar{display:none;position:absolute;box-sizing:border-box;width:312px;height:332px;background-color:white;padding:16px;box-shadow:0px 1px 5px rgba(17, 17, 17, 0.3);border-radius:var(--border-radius)}.calendar-header{display:flex;justify-content:space-between;margin-bottom:8px}.date-display{margin-top:8px}.calendar-header select{border:none;padding:5px}.calendar-table{width:100%;border-collapse:collapse}.calendar-table th{text-align:center;padding:4px;text-transform:uppercase;font-size:14px;color:#757575;border-bottom:1px solid #d5d5d5;margin-bottom:8px}.calendar .calendar-table td{padding:0;margin:0;width:14.2%;text-align:center;height:36px;line-height:36px}.calendar .calendar-table td span:hover{background-color:#f0f0f0}.calendar .calendar-table td span{display:block;text-align:center;padding:4px;cursor:pointer;border-radius:var(--border-radius)}.calendar-visible{display:block}.calendar-table thead tr{border-bottom:1px solid #d5d5d5}";
8
+
9
+ const TttxInputCalendar = class {
10
+ constructor(hostRef) {
11
+ index.registerInstance(this, hostRef);
12
+ // an array of month numbers mapped to their names
13
+ this.monthNames = Array.from({ length: 12 }, (_, i) => i + 1).map((month) => {
14
+ const date = new Date(0);
15
+ date.setUTCMonth(month - 1);
16
+ return date.toLocaleString('default', { month: 'long' });
17
+ });
18
+ this.onClickOutside = (event) => {
19
+ if (!this.el.contains(event.target) && this.showCalendar) {
20
+ this.showCalendar = false;
21
+ }
22
+ };
23
+ this.onFocusIn = (event) => {
24
+ if (!this.el.contains(event.target) && this.showCalendar) {
25
+ this.showCalendar = false;
26
+ }
27
+ };
28
+ this.previousHandler = () => {
29
+ if (this.selectedMonth === 1) {
30
+ this.selectedMonth = 12;
31
+ this.selectedYear--;
32
+ }
33
+ else {
34
+ this.selectedMonth--;
35
+ }
36
+ };
37
+ this.nextHandler = () => {
38
+ if (this.selectedMonth === 12) {
39
+ this.selectedMonth = 1;
40
+ this.selectedYear++;
41
+ }
42
+ else {
43
+ this.selectedMonth++;
44
+ }
45
+ };
46
+ this.months = false;
47
+ this.years = false;
48
+ this.showCalendar = false;
49
+ this.selectedYear = new Date().getFullYear();
50
+ this.selectedMonth = new Date().getMonth() + 1;
51
+ }
52
+ componentDidLoad() {
53
+ const slot = this.el.shadowRoot.querySelector('slot');
54
+ if (slot) {
55
+ const assignedElements = slot.assignedElements();
56
+ if (assignedElements[0]) {
57
+ assignedElements[0].addEventListener('click', (event) => {
58
+ event.preventDefault();
59
+ this.showCalendar = !this.showCalendar;
60
+ });
61
+ }
62
+ }
63
+ document.addEventListener('click', this.onClickOutside);
64
+ }
65
+ disconnectedCallback() {
66
+ document.removeEventListener('click', this.onClickOutside);
67
+ }
68
+ getDaysAndDates(year, month) {
69
+ const firstDayOfMonth = new Date(year, month - 1, 1);
70
+ const lastDayOfMonth = new Date(year, month, 0);
71
+ const daysAndDates = [];
72
+ for (let day = firstDayOfMonth; day <= lastDayOfMonth; day.setDate(day.getDate() + 1)) {
73
+ const weekDay = day.getDay();
74
+ const date = day.getDate();
75
+ const dayAndDate = {
76
+ day: weekDay,
77
+ date: date
78
+ };
79
+ daysAndDates.push(dayAndDate);
80
+ }
81
+ return daysAndDates;
82
+ }
83
+ clickDateHandler(event) {
84
+ const { year, month, day } = event;
85
+ const selectedDate = new Date(year, month - 1, day + 1);
86
+ this.inputElement.valueAsDate = selectedDate;
87
+ this.showCalendar = false;
88
+ }
89
+ render() {
90
+ const daysOfWeek = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
91
+ const daysAndDates = this.getDaysAndDates(this.selectedYear, this.selectedMonth);
92
+ const currentYear = new Date().getFullYear();
93
+ const years = Array.from({ length: 11 }, (_, i) => currentYear - 5 + i);
94
+ const calendarGrid = [];
95
+ let currentWeek = [];
96
+ // Fill empty days before the first day of the month
97
+ for (let i = 0; i < daysAndDates[0].day; i++) {
98
+ currentWeek.push(index.h("td", null));
99
+ }
100
+ // Fill the calendar with days and dates
101
+ daysAndDates.forEach(({ day, date }) => {
102
+ currentWeek.push(index.h("td", null, index.h("span", { onClick: () => this.clickDateHandler({ year: this.selectedYear, month: this.selectedMonth, day: date }) }, date)));
103
+ if (day === 6) {
104
+ calendarGrid.push(index.h("tr", null, currentWeek));
105
+ currentWeek = [];
106
+ }
107
+ });
108
+ // Fill the remaining empty days in the last week
109
+ if (currentWeek.length > 0) {
110
+ while (currentWeek.length < 7) {
111
+ currentWeek.push(index.h("td", null));
112
+ }
113
+ calendarGrid.push(index.h("tr", null, currentWeek));
114
+ }
115
+ return (index.h(index.Host, null, index.h("div", { class: "calcontainer" }, index.h("slot", null), index.h("div", { class: `calendar ${this.showCalendar ? 'calendar-visible' : ''}` }, index.h("div", { class: "calendar-header" }, index.h("tttx-button", { onClick: this.previousHandler, design: "borderless", icon: "chevron_left", notext: true }), this.months && index.h("select", { id: "month-select", onInput: (event) => {
116
+ this.selectedMonth = parseInt(event.target.value);
117
+ } }, Array.from({ length: 12 }, (_, i) => i + 1).map((month) => (index.h("option", { value: month, selected: month === this.selectedMonth }, this.monthNames[month - 1])))), this.years && index.h("select", { id: "year-select", onInput: (event) => {
118
+ this.selectedYear = parseInt(event.target.value);
119
+ } }, years.map((year) => (index.h("option", { value: year, selected: year === this.selectedYear }, year)))), index.h("div", { class: "date-display" }, this.monthNames[this.selectedMonth - 1], " ", this.selectedYear), index.h("tttx-button", { onClick: this.nextHandler, design: "borderless", icon: "chevron_right", notext: true })), index.h("table", { class: "calendar-table" }, index.h("thead", null, index.h("tr", null, daysOfWeek.map((day) => (index.h("th", null, day))))), index.h("tbody", null, calendarGrid))))));
120
+ }
121
+ get el() { return index.getElement(this); }
122
+ };
123
+ TttxInputCalendar.style = tttxInputCalendarCss;
124
+
125
+ exports.tttx_input_calendar = TttxInputCalendar;
@@ -0,0 +1,33 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-bf777121.js');
6
+
7
+ const tttxKeyvalueBlockCss = ":host{display:block}dl{margin:0;padding:0;font-family:\"Roboto\", sans-serif;cursor:default}dt{font-weight:400;line-height:21px;font-size:16px;color:#757575}dd{margin:0;font-weight:400;font-size:16px;color:#212121;line-height:21px;margin-bottom:18px}";
8
+
9
+ const TttxKeyvalueBlock = class {
10
+ constructor(hostRef) {
11
+ index.registerInstance(this, hostRef);
12
+ this.keyvalues = undefined;
13
+ }
14
+ render() {
15
+ let values;
16
+ if (typeof this.keyvalues === 'string') {
17
+ values = JSON.parse(this.keyvalues);
18
+ }
19
+ else {
20
+ values = this.keyvalues;
21
+ }
22
+ const keys = Object.keys(values);
23
+ const elements = [];
24
+ for (let i = 0; i < keys.length; i++) {
25
+ elements.push(index.h("dt", null, keys[i]));
26
+ elements.push(index.h("dd", null, values[keys[i]]));
27
+ }
28
+ return (index.h(index.Host, null, index.h("dl", null, elements)));
29
+ }
30
+ };
31
+ TttxKeyvalueBlock.style = tttxKeyvalueBlockCss;
32
+
33
+ exports.tttx_keyvalue_block = TttxKeyvalueBlock;
@@ -2,197 +2,197 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-864b7110.js');
5
+ const index = require('./index-bf777121.js');
6
6
 
7
7
  const tttxListCss = ".material-symbols-rounded{font-variation-settings:\"FILL\" 1, \"wght\" 400, \"GRAD\" 0, \"opsz\" 24}.material-symbols-rounded{font-family:\"Material Symbols Rounded\", sans-serif;font-weight:400;font-style:normal;font-size:24px;line-height:1;letter-spacing:normal;text-transform:none;display:inline-block;white-space:nowrap;word-wrap:normal;direction:ltr;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;color:#9e9e9e}:host{display:flex;flex-direction:column}.tttx-list__row{min-height:52px;line-height:36px;padding:8px;display:flex;flex-direction:row;align-items:center;cursor:pointer;border-bottom:1px solid #d5d5d5}.tttx-list__row .generic-template__content{width:100%;display:flex;align-items:center;gap:8px}.tttx-list__row:first-of-type{border-top:1px solid #d5d5d5}.tttx-list__row:focus,.tttx-list__row:active{background-color:#e6e6e6}.tttx-list__row.selected{background-color:#e7f1f9}.load-indicator{display:flex;justify-content:center}";
8
8
 
9
- const TttxList = class {
10
- constructor(hostRef) {
11
- index.registerInstance(this, hostRef);
12
- this.listPaginate = index.createEvent(this, "listPaginate", 7);
13
- this.listSelectedEvent = index.createEvent(this, "listSelectedEvent", 7);
14
- this.listItemClick = index.createEvent(this, "listItemClick", 7);
15
- this.rowCount = 0;
16
- this.name = undefined;
17
- this.selectable = undefined;
18
- this.items = [];
19
- this.selectedIds = [];
20
- this.loading = true;
21
- this.lastPage = false;
22
- }
23
- listLoadHandler(event) {
24
- if (event.detail.name !== this.name)
25
- return;
26
- this.items = [...this.items, ...event.detail.items];
27
- this.loading = false;
28
- this.lastPage = event.detail.lastPage;
29
- this.renderRows(event.detail.items);
30
- if (this.scrollableParent.clientHeight === this.scrollableParent.scrollHeight)
31
- this.listPaginateHandler();
32
- }
33
- listPaginateHandler() {
34
- // 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
35
- if (this.lastPage || this.loading)
36
- return;
37
- this.loading = true;
38
- this.listPaginate.emit({ name: this.name });
39
- }
40
- listClearDataCacheHandler(event) {
41
- if (event.detail.name !== this.name)
42
- return;
43
- this.items = [];
44
- this.selectedIds = [];
45
- this.listItemContainer()
46
- .querySelectorAll(".tttx-list__row")
47
- .forEach((node) => {
48
- node.remove();
49
- });
50
- this.rowCount = 0;
51
- this.lastPage = false;
52
- this.loading = false;
53
- }
54
- listActionSelectedEventHandler(event) {
55
- if (event.detail.name !== this.name || !this.selectable || this.selectedIds.length === 0)
56
- return;
57
- const selectedRows = this.selectedIds.map(id => {
58
- return this.items[id];
59
- });
60
- if (event.detail.removeRows)
61
- this.removeSelectedRows();
62
- this.listSelectedEvent.emit({
63
- name: this.name,
64
- eventName: event.detail.eventName,
65
- selectedRows,
66
- });
67
- }
68
- removeSelectedRows() {
69
- const orderedSelectedIds = [...this.selectedIds].sort((a, b) => {
70
- return b - a;
71
- });
72
- orderedSelectedIds.forEach(itemIndex => {
73
- this.items.splice(itemIndex, 1);
74
- this.listItemContainer().removeChild(this.listItemContainer().querySelector(`[data-row-id="${itemIndex}"]`));
75
- // If this removes the scrollbar and we're not on the last page, load in a new page
76
- if (this.scrollableParent.clientHeight === this.scrollableParent.scrollHeight)
77
- this.listPaginateHandler();
78
- });
79
- // Empty selected ids with mutation rather than assignment to avoid unecessary component rerender
80
- this.selectedIds.splice(0, this.selectedIds.length);
81
- }
82
- listItemClickHandler(itemData) {
83
- if (this.selectedIds.length !== 0)
84
- return;
85
- this.listItemClick.emit({ itemData, name: this.name });
86
- }
87
- componentWillLoad() {
88
- this.template = this.host.querySelector("template");
89
- this.scrollableParent = this.getScrollableParent(this.host);
90
- const scrollableContext = this.scrollableParent === document.scrollingElement ? document : this.scrollableParent;
91
- scrollableContext.addEventListener("scroll", this.scrollHandler.bind(this));
92
- window.addEventListener("resize", this.scrollHandler.bind(this));
93
- }
94
- componentDidLoad() {
95
- // Emit event to load first page
96
- this.listPaginate.emit({ name: this.name });
97
- }
98
- listItemContainer() {
99
- return this.host.shadowRoot.querySelector(".list-item-container");
100
- }
101
- async scrollHandler() {
102
- const { clientHeight, scrollTop, scrollHeight } = this.scrollableParent;
103
- if (Math.abs(scrollHeight - clientHeight - scrollTop) < 26)
104
- this.listPaginateHandler();
105
- }
106
- isScrollable(node) {
107
- const hasScrollbar = ["scroll", "auto"].includes(node.style.overflowY);
108
- return hasScrollbar;
109
- }
110
- getScrollableParent(node) {
111
- if (!node || node === document.body) {
112
- return document.scrollingElement;
113
- }
114
- else {
115
- return this.isScrollable(node) ? node : this.getScrollableParent(node.parentElement);
116
- }
117
- }
118
- appendRowCheckbox(rowContainer) {
119
- if (!this.selectable)
120
- return;
121
- const rowId = this.rowCount;
122
- const checkbox = document.createElement("input");
123
- checkbox.setAttribute("type", "checkbox");
124
- checkbox.addEventListener("click", e => {
125
- e.stopPropagation();
126
- if (e.target.checked) {
127
- this.selectedIds = [...this.selectedIds, rowId];
128
- rowContainer.classList.add("selected");
129
- }
130
- else {
131
- this.selectedIds = this.selectedIds.filter(id => {
132
- return id !== rowId;
133
- });
134
- rowContainer.classList.remove("selected");
135
- }
136
- });
137
- rowContainer.setAttribute("data-row-id", `${rowId}`);
138
- this.rowCount++;
139
- rowContainer.appendChild(checkbox);
140
- }
141
- appendSeededTemplate(rowData, rowContainer) {
142
- this.template.childNodes.forEach(child => {
143
- const clone = child.cloneNode(false);
144
- if (clone.getAttribute("data-fields")) {
145
- const fields = clone.getAttribute("data-fields").replace(/\s/g, "").split(",");
146
- const filteredRowData = Object.fromEntries(fields.map((field) => {
147
- return [field, rowData[field]];
148
- }));
149
- clone.setAttribute("row-data", JSON.stringify(filteredRowData));
150
- }
151
- else {
152
- clone.setAttribute("row-data", JSON.stringify(rowData));
153
- }
154
- rowContainer.appendChild(clone);
155
- });
156
- }
157
- appendGenericTemplate(rowData, rowContainer) {
158
- const row = document.createElement("div");
159
- row.classList.add("generic-template__content");
160
- row.textContent = rowData.text;
161
- rowContainer.appendChild(row);
162
- if (!rowData.icon)
163
- return;
164
- const icon = document.createElement("span");
165
- icon.classList.add("material-symbols-rounded");
166
- icon.textContent = rowData.icon;
167
- if (rowData.iconColor)
168
- icon.style["color"] = rowData.iconColor;
169
- row.prepend(icon);
170
- }
171
- row(rowData) {
172
- const rowContainer = document.createElement("div");
173
- rowContainer.classList.add("tttx-list__row");
174
- rowContainer.addEventListener("click", () => {
175
- this.listItemClickHandler(rowData);
176
- });
177
- this.appendRowCheckbox(rowContainer);
178
- this.template ? this.appendSeededTemplate(rowData, rowContainer) : this.appendGenericTemplate(rowData, rowContainer);
179
- return rowContainer;
180
- }
181
- renderRows(batchData) {
182
- batchData.forEach(rowData => {
183
- this.listItemContainer().appendChild(this.row(rowData));
184
- });
185
- }
186
- loadIndicator() {
187
- if (!this.loading)
188
- return;
189
- return index.h("div", { class: "load-indicator" }, index.h("tttx-loading-spinner", { size: 'large' }));
190
- }
191
- render() {
192
- return (index.h(index.Host, null, index.h("div", { class: "list-item-container", tabindex: "0" }, !this.loading && this.items.length === 0 ? "No data to display" : undefined), this.loadIndicator()));
193
- }
194
- get host() { return index.getElement(this); }
195
- };
9
+ const TttxList = class {
10
+ constructor(hostRef) {
11
+ index.registerInstance(this, hostRef);
12
+ this.listPaginate = index.createEvent(this, "listPaginate", 7);
13
+ this.listSelectedEvent = index.createEvent(this, "listSelectedEvent", 7);
14
+ this.listItemClick = index.createEvent(this, "listItemClick", 7);
15
+ this.rowCount = 0;
16
+ this.name = undefined;
17
+ this.selectable = undefined;
18
+ this.items = [];
19
+ this.selectedIds = [];
20
+ this.loading = true;
21
+ this.lastPage = false;
22
+ }
23
+ listLoadHandler(event) {
24
+ if (event.detail.name !== this.name)
25
+ return;
26
+ this.items = [...this.items, ...event.detail.items];
27
+ this.loading = false;
28
+ this.lastPage = event.detail.lastPage;
29
+ this.renderRows(event.detail.items);
30
+ if (this.scrollableParent.clientHeight === this.scrollableParent.scrollHeight)
31
+ this.listPaginateHandler();
32
+ }
33
+ listPaginateHandler() {
34
+ // 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
35
+ if (this.lastPage || this.loading)
36
+ return;
37
+ this.loading = true;
38
+ this.listPaginate.emit({ name: this.name });
39
+ }
40
+ listClearDataCacheHandler(event) {
41
+ if (event.detail.name !== this.name)
42
+ return;
43
+ this.items = [];
44
+ this.selectedIds = [];
45
+ this.listItemContainer()
46
+ .querySelectorAll('.tttx-list__row')
47
+ .forEach((node) => {
48
+ node.remove();
49
+ });
50
+ this.rowCount = 0;
51
+ this.lastPage = false;
52
+ this.loading = false;
53
+ }
54
+ listActionSelectedEventHandler(event) {
55
+ if (event.detail.name !== this.name || !this.selectable || this.selectedIds.length === 0)
56
+ return;
57
+ const selectedRows = this.selectedIds.map(id => {
58
+ return this.items[id];
59
+ });
60
+ if (event.detail.removeRows)
61
+ this.removeSelectedRows();
62
+ this.listSelectedEvent.emit({
63
+ name: this.name,
64
+ eventName: event.detail.eventName,
65
+ selectedRows,
66
+ });
67
+ }
68
+ removeSelectedRows() {
69
+ const orderedSelectedIds = [...this.selectedIds].sort((a, b) => {
70
+ return b - a;
71
+ });
72
+ orderedSelectedIds.forEach(itemIndex => {
73
+ this.items.splice(itemIndex, 1);
74
+ this.listItemContainer().removeChild(this.listItemContainer().querySelector(`[data-row-id="${itemIndex}"]`));
75
+ // If this removes the scrollbar and we're not on the last page, load in a new page
76
+ if (this.scrollableParent.clientHeight === this.scrollableParent.scrollHeight)
77
+ this.listPaginateHandler();
78
+ });
79
+ // Empty selected ids with mutation rather than assignment to avoid unecessary component rerender
80
+ this.selectedIds.splice(0, this.selectedIds.length);
81
+ }
82
+ listItemClickHandler(itemData) {
83
+ if (this.selectedIds.length !== 0)
84
+ return;
85
+ this.listItemClick.emit({ itemData, name: this.name });
86
+ }
87
+ componentWillLoad() {
88
+ this.template = this.host.querySelector('template');
89
+ this.scrollableParent = this.getScrollableParent(this.host);
90
+ const scrollableContext = this.scrollableParent === document.scrollingElement ? document : this.scrollableParent;
91
+ scrollableContext.addEventListener('scroll', this.scrollHandler.bind(this));
92
+ window.addEventListener('resize', this.scrollHandler.bind(this));
93
+ }
94
+ componentDidLoad() {
95
+ // Emit event to load first page
96
+ this.listPaginate.emit({ name: this.name });
97
+ }
98
+ listItemContainer() {
99
+ return this.host.shadowRoot.querySelector('.list-item-container');
100
+ }
101
+ async scrollHandler() {
102
+ const { clientHeight, scrollTop, scrollHeight } = this.scrollableParent;
103
+ if (Math.abs(scrollHeight - clientHeight - scrollTop) < 26)
104
+ this.listPaginateHandler();
105
+ }
106
+ isScrollable(node) {
107
+ const hasScrollbar = ['scroll', 'auto'].includes(node.style.overflowY);
108
+ return hasScrollbar;
109
+ }
110
+ getScrollableParent(node) {
111
+ if (!node || node === document.body) {
112
+ return document.scrollingElement;
113
+ }
114
+ else {
115
+ return this.isScrollable(node) ? node : this.getScrollableParent(node.parentElement);
116
+ }
117
+ }
118
+ appendRowCheckbox(rowContainer) {
119
+ if (!this.selectable)
120
+ return;
121
+ const rowId = this.rowCount;
122
+ const checkbox = document.createElement('input');
123
+ checkbox.setAttribute('type', 'checkbox');
124
+ checkbox.addEventListener('click', e => {
125
+ e.stopPropagation();
126
+ if (e.target.checked) {
127
+ this.selectedIds = [...this.selectedIds, rowId];
128
+ rowContainer.classList.add('selected');
129
+ }
130
+ else {
131
+ this.selectedIds = this.selectedIds.filter(id => {
132
+ return id !== rowId;
133
+ });
134
+ rowContainer.classList.remove('selected');
135
+ }
136
+ });
137
+ rowContainer.setAttribute('data-row-id', `${rowId}`);
138
+ this.rowCount++;
139
+ rowContainer.appendChild(checkbox);
140
+ }
141
+ appendSeededTemplate(rowData, rowContainer) {
142
+ this.template.childNodes.forEach(child => {
143
+ const clone = child.cloneNode(false);
144
+ if (clone.getAttribute('data-fields')) {
145
+ const fields = clone.getAttribute('data-fields').replace(/\s/g, '').split(',');
146
+ const filteredRowData = Object.fromEntries(fields.map((field) => {
147
+ return [field, rowData[field]];
148
+ }));
149
+ clone.setAttribute('row-data', JSON.stringify(filteredRowData));
150
+ }
151
+ else {
152
+ clone.setAttribute('row-data', JSON.stringify(rowData));
153
+ }
154
+ rowContainer.appendChild(clone);
155
+ });
156
+ }
157
+ appendGenericTemplate(rowData, rowContainer) {
158
+ const row = document.createElement('div');
159
+ row.classList.add('generic-template__content');
160
+ row.textContent = rowData.text;
161
+ rowContainer.appendChild(row);
162
+ if (!rowData.icon)
163
+ return;
164
+ const icon = document.createElement('span');
165
+ icon.classList.add('material-symbols-rounded');
166
+ icon.textContent = rowData.icon;
167
+ if (rowData.iconColor)
168
+ icon.style['color'] = rowData.iconColor;
169
+ row.prepend(icon);
170
+ }
171
+ row(rowData) {
172
+ const rowContainer = document.createElement('div');
173
+ rowContainer.classList.add('tttx-list__row');
174
+ rowContainer.addEventListener('click', () => {
175
+ this.listItemClickHandler(rowData);
176
+ });
177
+ this.appendRowCheckbox(rowContainer);
178
+ this.template ? this.appendSeededTemplate(rowData, rowContainer) : this.appendGenericTemplate(rowData, rowContainer);
179
+ return rowContainer;
180
+ }
181
+ renderRows(batchData) {
182
+ batchData.forEach(rowData => {
183
+ this.listItemContainer().appendChild(this.row(rowData));
184
+ });
185
+ }
186
+ loadIndicator() {
187
+ if (!this.loading)
188
+ return;
189
+ return index.h("div", { class: "load-indicator" }, index.h("tttx-loading-spinner", { size: 'large' }));
190
+ }
191
+ render() {
192
+ return (index.h(index.Host, null, index.h("div", { class: "list-item-container", tabindex: "0" }, !this.loading && this.items.length === 0 ? 'No data to display' : undefined), this.loadIndicator()));
193
+ }
194
+ get host() { return index.getElement(this); }
195
+ };
196
196
  TttxList.style = tttxListCss;
197
197
 
198
198
  exports.tttx_list = TttxList;
@@ -2,25 +2,25 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-864b7110.js');
5
+ const index = require('./index-bf777121.js');
6
6
 
7
7
  const tttxLoadingSpinnerCss = ".material-symbols-rounded{font-variation-settings:\"FILL\" 1, \"wght\" 400, \"GRAD\" 0, \"opsz\" 24}.spinner-container{position:absolute}.loading-box{display:flex;align-items:center;justify-content:center}.loading-text{font-size:16px;font-weight:400;padding-top:10px;text-align:center}.spinner{border:solid #1479c6;border-bottom-color:#d5d5d5;border-radius:50%;position:relative;box-sizing:border-box;animation:rotation 1s linear infinite}.spinner.small{height:20px;width:20px;border-width:4px}.spinner.large{height:60px;width:60px;border-width:8px}@keyframes rotation{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}";
8
8
 
9
- const TttxLoadingSpinner = class {
10
- constructor(hostRef) {
11
- index.registerInstance(this, hostRef);
12
- this.loadingMessage = undefined;
13
- this.size = 'large';
14
- }
15
- renderLoadingMessage() {
16
- if (!this.loadingMessage)
17
- return '';
18
- return index.h("div", { class: "loading-text" }, "Loading, please wait...");
19
- }
20
- render() {
21
- return (index.h("div", { class: "spinner-container" }, index.h("div", { class: "loading-box" }, index.h("span", { class: `spinner ${this.size}` })), this.renderLoadingMessage()));
22
- }
23
- };
9
+ const TttxLoadingSpinner = class {
10
+ constructor(hostRef) {
11
+ index.registerInstance(this, hostRef);
12
+ this.loadingMessage = undefined;
13
+ this.size = 'large';
14
+ }
15
+ renderLoadingMessage() {
16
+ if (!this.loadingMessage)
17
+ return '';
18
+ return index.h("div", { class: "loading-text" }, "Loading, please wait...");
19
+ }
20
+ render() {
21
+ return (index.h("div", { class: "spinner-container" }, index.h("div", { class: "loading-box" }, index.h("span", { class: `spinner ${this.size}` })), this.renderLoadingMessage()));
22
+ }
23
+ };
24
24
  TttxLoadingSpinner.style = tttxLoadingSpinnerCss;
25
25
 
26
26
  exports.tttx_loading_spinner = TttxLoadingSpinner;
@@ -2,22 +2,22 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-864b7110.js');
5
+ const index = require('./index-bf777121.js');
6
6
 
7
7
  const tttxPopoverContentCss = ".material-symbols-rounded{font-variation-settings:\"FILL\" 1, \"wght\" 400, \"GRAD\" 0, \"opsz\" 24}:host{display:block;max-width:400px}h4{margin:0;font-size:15px;font-weight:700;color:black;margin-bottom:4px}p{margin:0;font-size:14px;font-weight:normal;color:black;margin-bottom:4px}.linky{color:#1479c6;text-decoration:none;cursor:pointer}";
8
8
 
9
- const TttxPopoverContent = class {
10
- constructor(hostRef) {
11
- index.registerInstance(this, hostRef);
12
- this.header = undefined;
13
- this.body = undefined;
14
- this.linkcontext = undefined;
15
- this.linktext = undefined;
16
- }
17
- render() {
18
- return (index.h(index.Host, null, this.header && index.h("h4", null, this.header), this.body && index.h("p", null, this.body), this.linkcontext && (index.h("span", { class: "linky", onClick: evt => console.log(this.linkcontext, evt) }, this.linktext || 'More Information'))));
19
- }
20
- };
9
+ const TttxPopoverContent = class {
10
+ constructor(hostRef) {
11
+ index.registerInstance(this, hostRef);
12
+ this.header = undefined;
13
+ this.body = undefined;
14
+ this.linkcontext = undefined;
15
+ this.linktext = undefined;
16
+ }
17
+ render() {
18
+ return (index.h(index.Host, null, this.header && index.h("h4", null, this.header), this.body && index.h("p", null, this.body), this.linkcontext && (index.h("span", { class: "linky", onClick: evt => console.log(this.linkcontext, evt) }, this.linktext || 'More Information'))));
19
+ }
20
+ };
21
21
  TttxPopoverContent.style = tttxPopoverContentCss;
22
22
 
23
23
  exports.tttx_popover_content = TttxPopoverContent;