chuijs 3.6.2 → 3.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +1203 -162
- package/framework/appLayout/default/chui_app_layout.js +747 -747
- package/framework/appLayout/default/global_style.css +592 -568
- package/framework/appLayout/default/main_theme_style.css +118 -101
- package/framework/components/chui_accordion/accordion.js +63 -63
- package/framework/components/chui_accordion/styles.css +79 -75
- package/framework/components/chui_badge/badge.js +55 -55
- package/framework/components/chui_badge/styles.css +29 -29
- package/framework/components/chui_button/button.js +48 -48
- package/framework/components/chui_button/styles.css +75 -70
- package/framework/components/chui_calendar/calendar.js +97 -97
- package/framework/components/chui_card/card.js +87 -0
- package/framework/components/chui_card/styles.css +72 -0
- package/framework/components/chui_code/code.js +18 -18
- package/framework/components/chui_code/styles.css +9 -9
- package/framework/components/chui_console/console.js +27 -27
- package/framework/components/chui_console/styles.css +31 -31
- package/framework/components/chui_content_block/content_block.js +51 -51
- package/framework/components/chui_content_block/styles.css +2 -2
- package/framework/components/chui_context_menu/context_menu.js +230 -0
- package/framework/components/chui_context_menu/styles.css +136 -0
- package/framework/components/chui_custom_element/custom_element.js +24 -24
- package/framework/components/chui_details/details.js +85 -85
- package/framework/components/chui_details/styles.css +70 -66
- package/framework/components/chui_fieldset/fieldset.js +40 -40
- package/framework/components/chui_fieldset/styles.css +24 -24
- package/framework/components/chui_form/form.js +40 -40
- package/framework/components/chui_form/styles.css +21 -21
- package/framework/components/chui_graphs/graphs.js +234 -190
- package/framework/components/chui_graphs/styles.css +37 -32
- package/framework/components/chui_hero/hero.js +98 -0
- package/framework/components/chui_hero/styles.css +91 -0
- package/framework/components/chui_html_block/html_block.js +16 -16
- package/framework/components/chui_html_block/styles.css +5 -5
- package/framework/components/chui_hx/hx.js +15 -15
- package/framework/components/chui_hx/styles.css +38 -38
- package/framework/components/chui_icons/icons.js +2144 -2144
- package/framework/components/chui_icons/styles.css +13 -13
- package/framework/components/chui_inputs/chui_check_box/check_box.js +32 -32
- package/framework/components/chui_inputs/chui_check_box/styles.css +91 -86
- package/framework/components/chui_inputs/chui_combo_box/combo_box.js +166 -150
- package/framework/components/chui_inputs/chui_combo_box/styles.css +113 -107
- package/framework/components/chui_inputs/chui_date/date.js +177 -174
- package/framework/components/chui_inputs/chui_date/styles.css +163 -128
- package/framework/components/chui_inputs/chui_email/email.js +61 -61
- package/framework/components/chui_inputs/chui_email/styles.css +69 -71
- package/framework/components/chui_inputs/chui_file/file.js +76 -76
- package/framework/components/chui_inputs/chui_file/styles.css +99 -99
- package/framework/components/chui_inputs/chui_multi_combo_box/multi_combo_box.js +295 -295
- package/framework/components/chui_inputs/chui_multi_combo_box/styles.css +212 -235
- package/framework/components/chui_inputs/chui_number/number.js +108 -108
- package/framework/components/chui_inputs/chui_number/styles.css +84 -84
- package/framework/components/chui_inputs/chui_password/password.js +99 -99
- package/framework/components/chui_inputs/chui_password/styles.css +97 -97
- package/framework/components/chui_inputs/chui_radio_button/radio_button.js +45 -45
- package/framework/components/chui_inputs/chui_radio_button/styles.css +76 -73
- package/framework/components/chui_inputs/chui_select_box/select_box.js +187 -170
- package/framework/components/chui_inputs/chui_select_box/styles.css +123 -117
- package/framework/components/chui_inputs/chui_text/styles.css +83 -84
- package/framework/components/chui_inputs/chui_text/text.js +91 -91
- package/framework/components/chui_inputs/chui_text_area/styles.css +57 -57
- package/framework/components/chui_inputs/chui_text_area/text_area.js +61 -61
- package/framework/components/chui_inputs/chui_toggle/styles.css +66 -61
- package/framework/components/chui_inputs/chui_toggle/toggle.js +36 -36
- package/framework/components/chui_label/label.js +54 -54
- package/framework/components/chui_label/styles.css +11 -11
- package/framework/components/chui_media/audio.js +908 -908
- package/framework/components/chui_media/audio_styles.css +458 -458
- package/framework/components/chui_media/image.js +105 -105
- package/framework/components/chui_media/image_styles.css +61 -61
- package/framework/components/chui_media/video.js +248 -248
- package/framework/components/chui_media/video_styles.css +160 -160
- package/framework/components/chui_menu_bar/menu_bar.js +66 -74
- package/framework/components/chui_menu_bar/styles.css +114 -76
- package/framework/components/chui_modal/modal.js +142 -135
- package/framework/components/chui_modal/styles.css +36 -36
- package/framework/components/chui_notification/notification.js +72 -72
- package/framework/components/chui_notification/notification_download.js +78 -78
- package/framework/components/chui_notification/notification_download_progress.css +119 -123
- package/framework/components/chui_notification/notification_download_progress.js +105 -105
- package/framework/components/chui_notification/notification_update.js +54 -54
- package/framework/components/chui_notification/styles.css +91 -91
- package/framework/components/chui_notification/styles_download.css +85 -85
- package/framework/components/chui_notification/styles_update.css +73 -73
- package/framework/components/chui_paragraph/paragraph.js +14 -14
- package/framework/components/chui_paragraph/styles.css +6 -6
- package/framework/components/chui_popups/popups.js +250 -250
- package/framework/components/chui_popups/styles.css +129 -115
- package/framework/components/chui_progress_bar/progress_bar.js +28 -28
- package/framework/components/chui_progress_bar/styles.css +28 -28
- package/framework/components/chui_radio_group/radio_group.js +57 -57
- package/framework/components/chui_radio_group/styles.css +3 -3
- package/framework/components/chui_slideshow/slideshow.js +75 -75
- package/framework/components/chui_slideshow/styles.css +94 -85
- package/framework/components/chui_spinner/spinner.js +45 -45
- package/framework/components/chui_spinner/styles.css +23 -23
- package/framework/components/chui_table/styles.css +42 -42
- package/framework/components/chui_table/table.js +234 -234
- package/framework/components/chui_tabs/chui_tabs.js +77 -77
- package/framework/components/chui_tabs/styles.css +54 -48
- package/framework/components/chui_text_editor/styles.css +217 -217
- package/framework/components/chui_text_editor/text_editor.js +144 -144
- package/framework/components/chui_text_editor/text_editor_panel.js +568 -568
- package/framework/components/chui_tree_view/styles.css +81 -75
- package/framework/components/chui_tree_view/tree_view.js +90 -90
- package/framework/components/chui_webview/styles.css +27 -27
- package/framework/components/chui_webview/webview.js +103 -103
- package/framework/components/telegram_bot/chui_telegram_bot.js +183 -183
- package/framework/modules/chui_animations/animations.js +121 -121
- package/framework/modules/chui_animations/styles.css +79 -79
- package/framework/modules/chui_fonts.js +7129 -6974
- package/framework/modules/chui_functions.js +106 -78
- package/framework/modules/chui_logger/chui_logger.js +53 -53
- package/framework/modules/chui_page/page.js +86 -86
- package/framework/modules/chui_page/styles.css +9 -9
- package/framework/tray_bar/chui_menu_items.js +48 -48
- package/index.js +570 -555
- package/package.json +51 -46
|
@@ -1,235 +1,235 @@
|
|
|
1
|
-
const {Icon, Icons} = require("../chui_icons/icons");
|
|
2
|
-
|
|
3
|
-
class Table {
|
|
4
|
-
#filtered_data = [];
|
|
5
|
-
#sorted_data = [];
|
|
6
|
-
#table = document.createElement('table');
|
|
7
|
-
//#caption = this.#table.createCaption();
|
|
8
|
-
#tHead = this.#table.createTHead();
|
|
9
|
-
#tBody = this.#table.createTBody();
|
|
10
|
-
//#tFoot = this.#table.createTFoot();
|
|
11
|
-
#columns = [];
|
|
12
|
-
#data = [];
|
|
13
|
-
#customNames = [];
|
|
14
|
-
#userSelect = Boolean();
|
|
15
|
-
#columnsWidth = undefined;
|
|
16
|
-
#sorted = undefined;
|
|
17
|
-
constructor(options = {
|
|
18
|
-
data: undefined,
|
|
19
|
-
customName: undefined,
|
|
20
|
-
userSelect: Boolean(),
|
|
21
|
-
sorted: Boolean(),
|
|
22
|
-
columnsWidth: undefined,
|
|
23
|
-
}) {
|
|
24
|
-
this.#sorted = options.sorted;
|
|
25
|
-
this.#columnsWidth = options.columnsWidth;
|
|
26
|
-
this.#data = options.data;
|
|
27
|
-
this.#customNames = options.customName;
|
|
28
|
-
this.#userSelect = options.userSelect;
|
|
29
|
-
require('../../modules/chui_functions').setStyles(__dirname + "/styles.css", 'chUiJS_Table');
|
|
30
|
-
//======================
|
|
31
|
-
//Установка заголовков
|
|
32
|
-
this.#columns = Object.getOwnPropertyNames(this.#data[0]);
|
|
33
|
-
this.#setHeaders();
|
|
34
|
-
//Заполнение таобицы
|
|
35
|
-
this.#setTable(this.#data);
|
|
36
|
-
}
|
|
37
|
-
setContextMenu(ctx = new HTMLElement()) { globalThis.ctxs.push({ elem: this.#table, ctx: ctx }) }
|
|
38
|
-
getColumn(col = Number()) {
|
|
39
|
-
let column = [];
|
|
40
|
-
Array.from(this.#table.rows).forEach(row => {
|
|
41
|
-
Array.from(row.cells).forEach(cell => {
|
|
42
|
-
if (cell.cellIndex === col) {
|
|
43
|
-
column.push(cell)
|
|
44
|
-
}
|
|
45
|
-
})
|
|
46
|
-
})
|
|
47
|
-
return column;
|
|
48
|
-
}
|
|
49
|
-
setData(data = []) { this.#data = data; }
|
|
50
|
-
getData() { return this.#data; }
|
|
51
|
-
refresh(data = []) { this.#setTable(data); }
|
|
52
|
-
set() { return this.#table; }
|
|
53
|
-
//Функции фильтров
|
|
54
|
-
setFilterByProperty(type = String(), property = String(), filterValue = String()) {
|
|
55
|
-
this.#filtered_data = [];
|
|
56
|
-
if (type.includes(Table.FILTER_TYPE.CLEAR_MATCH)) {
|
|
57
|
-
if (this.#filtered_data.length !== 0) {
|
|
58
|
-
this.#filtered_data = this.#filtered_data.filter(data_1 => String(data_1[property]).toLowerCase() === String(filterValue).toLowerCase())
|
|
59
|
-
} else {
|
|
60
|
-
this.#filtered_data = this.#data.filter(data_1 => String(data_1[property]).toLowerCase() === String(filterValue).toLowerCase())
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
if (type.includes(Table.FILTER_TYPE.PARTIAL_MATCH)) {
|
|
64
|
-
if (this.#filtered_data.length !== 0) {
|
|
65
|
-
this.#filtered_data = this.#filtered_data.filter(data_1 => String(data_1[property]).toLowerCase().includes(String(filterValue).toLowerCase()))
|
|
66
|
-
} else {
|
|
67
|
-
this.#filtered_data = this.#data.filter(data_1 => String(data_1[property]).toLowerCase().includes(String(filterValue).toLowerCase()))
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
this.#setTable(this.#filtered_data)
|
|
71
|
-
if (this.#userSelect !== undefined) this.#setUserSelect();
|
|
72
|
-
}
|
|
73
|
-
setFilterByMultiProperty(type = String(), properties = [], filterValue = String()) {
|
|
74
|
-
this.#filtered_data = [];
|
|
75
|
-
if (type.includes(Table.FILTER_TYPE.CLEAR_MATCH)) {
|
|
76
|
-
let dump = []
|
|
77
|
-
for (let property of properties) {
|
|
78
|
-
dump = this.#data.filter(data_1 => String(data_1[property]).toLowerCase() === String(filterValue).toLowerCase())
|
|
79
|
-
dump.forEach(dump => this.#filtered_data.push(dump))
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
if (type.includes(Table.FILTER_TYPE.PARTIAL_MATCH)) {
|
|
83
|
-
let dump = []
|
|
84
|
-
for (let property of properties) {
|
|
85
|
-
dump = this.#data.filter(data_1 => String(data_1[property]).toLowerCase().includes(String(filterValue).toLowerCase()))
|
|
86
|
-
dump.forEach(dump => this.#filtered_data.push(dump))
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
if (filterValue.length > 0) {
|
|
90
|
-
this.#setTable(this.#filtered_data)
|
|
91
|
-
} else if (filterValue.length === 0) {
|
|
92
|
-
this.#setTable(this.#data)
|
|
93
|
-
}
|
|
94
|
-
if (this.#userSelect !== undefined) this.#setUserSelect();
|
|
95
|
-
}
|
|
96
|
-
removeFilterByProperty(property= String(), filterValue = String()) {
|
|
97
|
-
this.#data.filter(data_1 => String(data_1[property]).toLowerCase() === String(filterValue).toLowerCase()).forEach(data_2 => {
|
|
98
|
-
this.#filtered_data.splice(this.#filtered_data.indexOf(data_2), 1)
|
|
99
|
-
})
|
|
100
|
-
if (this.#filtered_data.length !== 0) {
|
|
101
|
-
this.#setTable(this.#filtered_data)
|
|
102
|
-
} else {
|
|
103
|
-
this.#setTable(this.#data)
|
|
104
|
-
}
|
|
105
|
-
if (this.#userSelect !== undefined) this.#setUserSelect()
|
|
106
|
-
}
|
|
107
|
-
//Функции отрисовки таблицы
|
|
108
|
-
#setWidthColumns(row) {
|
|
109
|
-
if (this.#columnsWidth === undefined) {
|
|
110
|
-
let arr = [];
|
|
111
|
-
for (let test of this.#columns) arr.push(`calc(100% / ${this.#columns.length})`);
|
|
112
|
-
row.style.gridTemplateColumns = arr.join(" ");
|
|
113
|
-
} else {
|
|
114
|
-
row.style.gridTemplateColumns = this.#columnsWidth.join(" ");
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
#setHeaders() {
|
|
118
|
-
let cols = this.#columns;
|
|
119
|
-
if (this.#customNames !== undefined) { cols = this.#customNames }
|
|
120
|
-
const row = this.#tHead.insertRow();
|
|
121
|
-
this.#setWidthColumns(row);
|
|
122
|
-
row.style.borderBottom = '1px solid var(--element_background)'
|
|
123
|
-
for (let head of cols) {
|
|
124
|
-
const cell = row.insertCell()
|
|
125
|
-
if (cell.cellIndex !== 0) cell.style.borderLeft = '1px solid var(--element_background)'
|
|
126
|
-
let cell_title = document.createElement("cell_title")
|
|
127
|
-
cell_title.innerText = head;
|
|
128
|
-
cell.appendChild(cell_title)
|
|
129
|
-
if (this.#sorted) {
|
|
130
|
-
let flag = 1;
|
|
131
|
-
let sort_button = document.createElement("sort_button");
|
|
132
|
-
sort_button.style.marginLeft = "10px";
|
|
133
|
-
sort_button.innerText = '';
|
|
134
|
-
cell.appendChild(sort_button)
|
|
135
|
-
cell.addEventListener("click", () => {
|
|
136
|
-
if (flag === 1) {
|
|
137
|
-
sort_button.innerHTML = new Icon(Icons.NAVIGATION.EXPAND_MORE, "20px", "var(--button_text_color)").getHTML();
|
|
138
|
-
this.#sortTable(Table.#SORT_METHOD.ASC, cell.cellIndex)
|
|
139
|
-
flag = 2;
|
|
140
|
-
} else if (flag === 2) {
|
|
141
|
-
sort_button.innerHTML = new Icon(Icons.NAVIGATION.EXPAND_LESS, "20px", "var(--button_text_color)").getHTML();
|
|
142
|
-
this.#sortTable(Table.#SORT_METHOD.DESC, cell.cellIndex)
|
|
143
|
-
flag = 3;
|
|
144
|
-
} else if (flag === 3) {
|
|
145
|
-
sort_button.innerText = "";
|
|
146
|
-
if (this.#filtered_data.length !== 0) {
|
|
147
|
-
this.#setTable(this.#filtered_data);
|
|
148
|
-
} else {
|
|
149
|
-
this.#setTable(this.#data);
|
|
150
|
-
}
|
|
151
|
-
flag = 1;
|
|
152
|
-
}
|
|
153
|
-
})
|
|
154
|
-
}
|
|
155
|
-
cell.style.color = 'var(--button_text_color)';
|
|
156
|
-
cell.style.display = "flex";
|
|
157
|
-
cell.style.flexDirection = "row";
|
|
158
|
-
cell.style.justifyContent = "space-between";
|
|
159
|
-
cell.style.alignItems = "center";
|
|
160
|
-
if (cell.cellIndex !== 0) cell.style.borderLeft = '1px solid transparent';
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
#setTable(data = []) {
|
|
164
|
-
this.#tBody.innerHTML = '';
|
|
165
|
-
for (let dat of data) {
|
|
166
|
-
let row = this.#tBody.insertRow()
|
|
167
|
-
this.#setWidthColumns(row);
|
|
168
|
-
if (data.indexOf(dat) !== data.length - 1) row.style.borderBottom = '1px solid var(--element_background)'
|
|
169
|
-
for (let col of this.#columns) {
|
|
170
|
-
let cell = row.insertCell();
|
|
171
|
-
if (cell.cellIndex !== 0) {
|
|
172
|
-
cell.style.borderLeft = '1px solid var(--element_background)'
|
|
173
|
-
}
|
|
174
|
-
cell.innerHTML = dat[col];
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
if (this.#userSelect !== undefined) this.#setUserSelect();
|
|
178
|
-
}
|
|
179
|
-
#setUserSelect() {
|
|
180
|
-
for (let row of this.#tBody.rows) {
|
|
181
|
-
for (let cell of row.cells) {
|
|
182
|
-
cell.style.userSelect = 'text'
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
#sortTable(sortMethod = String(), col = Number()) {
|
|
187
|
-
if (this.#filtered_data.length !== 0) {
|
|
188
|
-
this.#sorted_data = this.#filtered_data;
|
|
189
|
-
this.#sort(col, sortMethod);
|
|
190
|
-
} else {
|
|
191
|
-
this.#sorted_data = this.#data;
|
|
192
|
-
this.#sort(col, sortMethod);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
#sort(colIndex = Number(), sortMethod = String()) {
|
|
196
|
-
let cols = Object.getOwnPropertyNames(this.#sorted_data[0]);
|
|
197
|
-
let arr = [];
|
|
198
|
-
for (let data of this.#sorted_data) {
|
|
199
|
-
let sub_arr = [];
|
|
200
|
-
for (let i = 0; i < cols.length; i++) sub_arr.push(data[cols[i]]);
|
|
201
|
-
arr.push(sub_arr)
|
|
202
|
-
}
|
|
203
|
-
let sort_data = [];
|
|
204
|
-
//
|
|
205
|
-
function asc(a, b) {
|
|
206
|
-
if (typeof a[colIndex] === "number") {
|
|
207
|
-
if (a[colIndex] === b[colIndex]) { return 0; } else { return (a[colIndex] < b[colIndex]) ? -1 : 1; }
|
|
208
|
-
} else {
|
|
209
|
-
return a[colIndex].toString().localeCompare(b[colIndex].toString());
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
function desc(a, b) {
|
|
213
|
-
if (typeof a[colIndex] === "number") {
|
|
214
|
-
if (b[colIndex] === a[colIndex]) { return 0; } else { return (b[colIndex] < a[colIndex]) ? -1 : 1; }
|
|
215
|
-
} else {
|
|
216
|
-
return b[colIndex].toString().localeCompare(a[colIndex].toString());
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
//
|
|
220
|
-
if (sortMethod.includes(Table.#SORT_METHOD.ASC)) {
|
|
221
|
-
arr.sort(asc).forEach(data => {
|
|
222
|
-
sort_data.push(new this.#data[0].__proto__.constructor(...data))
|
|
223
|
-
})
|
|
224
|
-
} else if (sortMethod.includes(Table.#SORT_METHOD.DESC)) {
|
|
225
|
-
arr.sort(desc).forEach(data => {
|
|
226
|
-
sort_data.push(new this.#data[0].__proto__.constructor(...data))
|
|
227
|
-
})
|
|
228
|
-
}
|
|
229
|
-
this.#setTable(sort_data)
|
|
230
|
-
}
|
|
231
|
-
static #SORT_METHOD = { ASC: "ASC", DESC: "DESC" }
|
|
232
|
-
static FILTER_TYPE = { CLEAR_MATCH: "CLEAR_MATCH", PARTIAL_MATCH: "PARTIAL_MATCH" }
|
|
233
|
-
}
|
|
234
|
-
|
|
1
|
+
const {Icon, Icons} = require("../chui_icons/icons");
|
|
2
|
+
|
|
3
|
+
class Table {
|
|
4
|
+
#filtered_data = [];
|
|
5
|
+
#sorted_data = [];
|
|
6
|
+
#table = document.createElement('table');
|
|
7
|
+
//#caption = this.#table.createCaption();
|
|
8
|
+
#tHead = this.#table.createTHead();
|
|
9
|
+
#tBody = this.#table.createTBody();
|
|
10
|
+
//#tFoot = this.#table.createTFoot();
|
|
11
|
+
#columns = [];
|
|
12
|
+
#data = [];
|
|
13
|
+
#customNames = [];
|
|
14
|
+
#userSelect = Boolean();
|
|
15
|
+
#columnsWidth = undefined;
|
|
16
|
+
#sorted = undefined;
|
|
17
|
+
constructor(options = {
|
|
18
|
+
data: undefined,
|
|
19
|
+
customName: undefined,
|
|
20
|
+
userSelect: Boolean(),
|
|
21
|
+
sorted: Boolean(),
|
|
22
|
+
columnsWidth: undefined,
|
|
23
|
+
}) {
|
|
24
|
+
this.#sorted = options.sorted;
|
|
25
|
+
this.#columnsWidth = options.columnsWidth;
|
|
26
|
+
this.#data = options.data;
|
|
27
|
+
this.#customNames = options.customName;
|
|
28
|
+
this.#userSelect = options.userSelect;
|
|
29
|
+
require('../../modules/chui_functions').setStyles(__dirname + "/styles.css", 'chUiJS_Table');
|
|
30
|
+
//======================
|
|
31
|
+
//Установка заголовков
|
|
32
|
+
this.#columns = Object.getOwnPropertyNames(this.#data[0]);
|
|
33
|
+
this.#setHeaders();
|
|
34
|
+
//Заполнение таобицы
|
|
35
|
+
this.#setTable(this.#data);
|
|
36
|
+
}
|
|
37
|
+
setContextMenu(ctx = new HTMLElement()) { globalThis.ctxs.push({ elem: this.#table, ctx: ctx }) }
|
|
38
|
+
getColumn(col = Number()) {
|
|
39
|
+
let column = [];
|
|
40
|
+
Array.from(this.#table.rows).forEach(row => {
|
|
41
|
+
Array.from(row.cells).forEach(cell => {
|
|
42
|
+
if (cell.cellIndex === col) {
|
|
43
|
+
column.push(cell)
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
})
|
|
47
|
+
return column;
|
|
48
|
+
}
|
|
49
|
+
setData(data = []) { this.#data = data; }
|
|
50
|
+
getData() { return this.#data; }
|
|
51
|
+
refresh(data = []) { this.#setTable(data); }
|
|
52
|
+
set() { return this.#table; }
|
|
53
|
+
//Функции фильтров
|
|
54
|
+
setFilterByProperty(type = String(), property = String(), filterValue = String()) {
|
|
55
|
+
this.#filtered_data = [];
|
|
56
|
+
if (type.includes(Table.FILTER_TYPE.CLEAR_MATCH)) {
|
|
57
|
+
if (this.#filtered_data.length !== 0) {
|
|
58
|
+
this.#filtered_data = this.#filtered_data.filter(data_1 => String(data_1[property]).toLowerCase() === String(filterValue).toLowerCase())
|
|
59
|
+
} else {
|
|
60
|
+
this.#filtered_data = this.#data.filter(data_1 => String(data_1[property]).toLowerCase() === String(filterValue).toLowerCase())
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (type.includes(Table.FILTER_TYPE.PARTIAL_MATCH)) {
|
|
64
|
+
if (this.#filtered_data.length !== 0) {
|
|
65
|
+
this.#filtered_data = this.#filtered_data.filter(data_1 => String(data_1[property]).toLowerCase().includes(String(filterValue).toLowerCase()))
|
|
66
|
+
} else {
|
|
67
|
+
this.#filtered_data = this.#data.filter(data_1 => String(data_1[property]).toLowerCase().includes(String(filterValue).toLowerCase()))
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
this.#setTable(this.#filtered_data)
|
|
71
|
+
if (this.#userSelect !== undefined) this.#setUserSelect();
|
|
72
|
+
}
|
|
73
|
+
setFilterByMultiProperty(type = String(), properties = [], filterValue = String()) {
|
|
74
|
+
this.#filtered_data = [];
|
|
75
|
+
if (type.includes(Table.FILTER_TYPE.CLEAR_MATCH)) {
|
|
76
|
+
let dump = []
|
|
77
|
+
for (let property of properties) {
|
|
78
|
+
dump = this.#data.filter(data_1 => String(data_1[property]).toLowerCase() === String(filterValue).toLowerCase())
|
|
79
|
+
dump.forEach(dump => this.#filtered_data.push(dump))
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (type.includes(Table.FILTER_TYPE.PARTIAL_MATCH)) {
|
|
83
|
+
let dump = []
|
|
84
|
+
for (let property of properties) {
|
|
85
|
+
dump = this.#data.filter(data_1 => String(data_1[property]).toLowerCase().includes(String(filterValue).toLowerCase()))
|
|
86
|
+
dump.forEach(dump => this.#filtered_data.push(dump))
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (filterValue.length > 0) {
|
|
90
|
+
this.#setTable(this.#filtered_data)
|
|
91
|
+
} else if (filterValue.length === 0) {
|
|
92
|
+
this.#setTable(this.#data)
|
|
93
|
+
}
|
|
94
|
+
if (this.#userSelect !== undefined) this.#setUserSelect();
|
|
95
|
+
}
|
|
96
|
+
removeFilterByProperty(property= String(), filterValue = String()) {
|
|
97
|
+
this.#data.filter(data_1 => String(data_1[property]).toLowerCase() === String(filterValue).toLowerCase()).forEach(data_2 => {
|
|
98
|
+
this.#filtered_data.splice(this.#filtered_data.indexOf(data_2), 1)
|
|
99
|
+
})
|
|
100
|
+
if (this.#filtered_data.length !== 0) {
|
|
101
|
+
this.#setTable(this.#filtered_data)
|
|
102
|
+
} else {
|
|
103
|
+
this.#setTable(this.#data)
|
|
104
|
+
}
|
|
105
|
+
if (this.#userSelect !== undefined) this.#setUserSelect()
|
|
106
|
+
}
|
|
107
|
+
//Функции отрисовки таблицы
|
|
108
|
+
#setWidthColumns(row) {
|
|
109
|
+
if (this.#columnsWidth === undefined) {
|
|
110
|
+
let arr = [];
|
|
111
|
+
for (let test of this.#columns) arr.push(`calc(100% / ${this.#columns.length})`);
|
|
112
|
+
row.style.gridTemplateColumns = arr.join(" ");
|
|
113
|
+
} else {
|
|
114
|
+
row.style.gridTemplateColumns = this.#columnsWidth.join(" ");
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
#setHeaders() {
|
|
118
|
+
let cols = this.#columns;
|
|
119
|
+
if (this.#customNames !== undefined) { cols = this.#customNames }
|
|
120
|
+
const row = this.#tHead.insertRow();
|
|
121
|
+
this.#setWidthColumns(row);
|
|
122
|
+
row.style.borderBottom = '1px solid var(--element_background)'
|
|
123
|
+
for (let head of cols) {
|
|
124
|
+
const cell = row.insertCell()
|
|
125
|
+
if (cell.cellIndex !== 0) cell.style.borderLeft = '1px solid var(--element_background)'
|
|
126
|
+
let cell_title = document.createElement("cell_title")
|
|
127
|
+
cell_title.innerText = head;
|
|
128
|
+
cell.appendChild(cell_title)
|
|
129
|
+
if (this.#sorted) {
|
|
130
|
+
let flag = 1;
|
|
131
|
+
let sort_button = document.createElement("sort_button");
|
|
132
|
+
sort_button.style.marginLeft = "10px";
|
|
133
|
+
sort_button.innerText = '';
|
|
134
|
+
cell.appendChild(sort_button)
|
|
135
|
+
cell.addEventListener("click", () => {
|
|
136
|
+
if (flag === 1) {
|
|
137
|
+
sort_button.innerHTML = new Icon(Icons.NAVIGATION.EXPAND_MORE, "20px", "var(--button_text_color)").getHTML();
|
|
138
|
+
this.#sortTable(Table.#SORT_METHOD.ASC, cell.cellIndex)
|
|
139
|
+
flag = 2;
|
|
140
|
+
} else if (flag === 2) {
|
|
141
|
+
sort_button.innerHTML = new Icon(Icons.NAVIGATION.EXPAND_LESS, "20px", "var(--button_text_color)").getHTML();
|
|
142
|
+
this.#sortTable(Table.#SORT_METHOD.DESC, cell.cellIndex)
|
|
143
|
+
flag = 3;
|
|
144
|
+
} else if (flag === 3) {
|
|
145
|
+
sort_button.innerText = "";
|
|
146
|
+
if (this.#filtered_data.length !== 0) {
|
|
147
|
+
this.#setTable(this.#filtered_data);
|
|
148
|
+
} else {
|
|
149
|
+
this.#setTable(this.#data);
|
|
150
|
+
}
|
|
151
|
+
flag = 1;
|
|
152
|
+
}
|
|
153
|
+
})
|
|
154
|
+
}
|
|
155
|
+
cell.style.color = 'var(--button_text_color)';
|
|
156
|
+
cell.style.display = "flex";
|
|
157
|
+
cell.style.flexDirection = "row";
|
|
158
|
+
cell.style.justifyContent = "space-between";
|
|
159
|
+
cell.style.alignItems = "center";
|
|
160
|
+
if (cell.cellIndex !== 0) cell.style.borderLeft = '1px solid transparent';
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
#setTable(data = []) {
|
|
164
|
+
this.#tBody.innerHTML = '';
|
|
165
|
+
for (let dat of data) {
|
|
166
|
+
let row = this.#tBody.insertRow()
|
|
167
|
+
this.#setWidthColumns(row);
|
|
168
|
+
if (data.indexOf(dat) !== data.length - 1) row.style.borderBottom = '1px solid var(--element_background)'
|
|
169
|
+
for (let col of this.#columns) {
|
|
170
|
+
let cell = row.insertCell();
|
|
171
|
+
if (cell.cellIndex !== 0) {
|
|
172
|
+
cell.style.borderLeft = '1px solid var(--element_background)'
|
|
173
|
+
}
|
|
174
|
+
cell.innerHTML = dat[col];
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if (this.#userSelect !== undefined) this.#setUserSelect();
|
|
178
|
+
}
|
|
179
|
+
#setUserSelect() {
|
|
180
|
+
for (let row of this.#tBody.rows) {
|
|
181
|
+
for (let cell of row.cells) {
|
|
182
|
+
cell.style.userSelect = 'text'
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
#sortTable(sortMethod = String(), col = Number()) {
|
|
187
|
+
if (this.#filtered_data.length !== 0) {
|
|
188
|
+
this.#sorted_data = this.#filtered_data;
|
|
189
|
+
this.#sort(col, sortMethod);
|
|
190
|
+
} else {
|
|
191
|
+
this.#sorted_data = this.#data;
|
|
192
|
+
this.#sort(col, sortMethod);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
#sort(colIndex = Number(), sortMethod = String()) {
|
|
196
|
+
let cols = Object.getOwnPropertyNames(this.#sorted_data[0]);
|
|
197
|
+
let arr = [];
|
|
198
|
+
for (let data of this.#sorted_data) {
|
|
199
|
+
let sub_arr = [];
|
|
200
|
+
for (let i = 0; i < cols.length; i++) sub_arr.push(data[cols[i]]);
|
|
201
|
+
arr.push(sub_arr)
|
|
202
|
+
}
|
|
203
|
+
let sort_data = [];
|
|
204
|
+
//
|
|
205
|
+
function asc(a, b) {
|
|
206
|
+
if (typeof a[colIndex] === "number") {
|
|
207
|
+
if (a[colIndex] === b[colIndex]) { return 0; } else { return (a[colIndex] < b[colIndex]) ? -1 : 1; }
|
|
208
|
+
} else {
|
|
209
|
+
return a[colIndex].toString().localeCompare(b[colIndex].toString());
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
function desc(a, b) {
|
|
213
|
+
if (typeof a[colIndex] === "number") {
|
|
214
|
+
if (b[colIndex] === a[colIndex]) { return 0; } else { return (b[colIndex] < a[colIndex]) ? -1 : 1; }
|
|
215
|
+
} else {
|
|
216
|
+
return b[colIndex].toString().localeCompare(a[colIndex].toString());
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
//
|
|
220
|
+
if (sortMethod.includes(Table.#SORT_METHOD.ASC)) {
|
|
221
|
+
arr.sort(asc).forEach(data => {
|
|
222
|
+
sort_data.push(new this.#data[0].__proto__.constructor(...data))
|
|
223
|
+
})
|
|
224
|
+
} else if (sortMethod.includes(Table.#SORT_METHOD.DESC)) {
|
|
225
|
+
arr.sort(desc).forEach(data => {
|
|
226
|
+
sort_data.push(new this.#data[0].__proto__.constructor(...data))
|
|
227
|
+
})
|
|
228
|
+
}
|
|
229
|
+
this.#setTable(sort_data)
|
|
230
|
+
}
|
|
231
|
+
static #SORT_METHOD = { ASC: "ASC", DESC: "DESC" }
|
|
232
|
+
static FILTER_TYPE = { CLEAR_MATCH: "CLEAR_MATCH", PARTIAL_MATCH: "PARTIAL_MATCH" }
|
|
233
|
+
}
|
|
234
|
+
|
|
235
235
|
exports.Table = Table
|
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
let {Animation} = require('../../modules/chui_animations/animations');
|
|
2
|
-
|
|
3
|
-
class Tab {
|
|
4
|
-
#tab = document.createElement('tab');
|
|
5
|
-
#tab_content = [];
|
|
6
|
-
constructor(title) {
|
|
7
|
-
this.#tab.innerText = title;
|
|
8
|
-
}
|
|
9
|
-
addContent(...contents) {
|
|
10
|
-
for (let content of contents) this.#tab_content.push(content);
|
|
11
|
-
}
|
|
12
|
-
getTab() {
|
|
13
|
-
return this.#tab;
|
|
14
|
-
}
|
|
15
|
-
getContent() {
|
|
16
|
-
return this.#tab_content;
|
|
17
|
-
}
|
|
18
|
-
set() {
|
|
19
|
-
return this.#tab;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
class Tabs {
|
|
24
|
-
#tabzz = undefined;
|
|
25
|
-
#id_contents = require("randomstring").generate();
|
|
26
|
-
#tabs = document.createElement('tabs');
|
|
27
|
-
#id_list = require("randomstring").generate();
|
|
28
|
-
#list = document.createElement('list');
|
|
29
|
-
#content = document.createElement('content');
|
|
30
|
-
constructor(options = { width: String(), default: Number(), tabs: [] }) {
|
|
31
|
-
require('../../modules/chui_functions').setStyles(__dirname + "/styles.css", 'chUiJS_Tabs');
|
|
32
|
-
this.#tabzz = options.tabs;
|
|
33
|
-
this.#list.id = this.#id_list;
|
|
34
|
-
this.#content.id = this.#id_contents;
|
|
35
|
-
for (let item of options.tabs) {
|
|
36
|
-
item.getTab().addEventListener('click', (event) => {
|
|
37
|
-
if (event.target.getAttribute("active") === null) {
|
|
38
|
-
document.getElementById(this.#id_list).childNodes.forEach(child => {
|
|
39
|
-
child.removeAttribute("active");
|
|
40
|
-
child.classList.remove("tab_active")
|
|
41
|
-
})
|
|
42
|
-
event.target.setAttribute("active", true);
|
|
43
|
-
event.target.classList.add("tab_active")
|
|
44
|
-
let contentz = document.getElementById(this.#id_contents);
|
|
45
|
-
contentz.innerHTML = '';
|
|
46
|
-
for (let con of item.getContent()) this.#content.appendChild(con.set());
|
|
47
|
-
new Animation(this.#content).fadeIn();
|
|
48
|
-
this.#content.addEventListener('animationend', () => this.#content.removeAttribute('style'));
|
|
49
|
-
}
|
|
50
|
-
})
|
|
51
|
-
this.#list.appendChild(item.set());
|
|
52
|
-
}
|
|
53
|
-
this.#tabs.appendChild(this.#list);
|
|
54
|
-
this.#tabs.appendChild(this.#content);
|
|
55
|
-
if (options.default !== undefined) {
|
|
56
|
-
this.#setDefault(options.default)
|
|
57
|
-
} else {
|
|
58
|
-
this.#setDefault(0)
|
|
59
|
-
}
|
|
60
|
-
if (options.width !== undefined) this.#tabs.style.width = options.width;
|
|
61
|
-
}
|
|
62
|
-
#setDefault(num) {
|
|
63
|
-
for (let con of this.#tabzz[num].getContent()) {
|
|
64
|
-
this.#content.appendChild(con.set())
|
|
65
|
-
new Animation(this.#content).fadeIn();
|
|
66
|
-
this.#content.addEventListener('animationend', () => this.#content.removeAttribute('style'));
|
|
67
|
-
}
|
|
68
|
-
this.#tabzz[num].getTab().setAttribute("active", true);
|
|
69
|
-
this.#tabzz[num].getTab().classList.add("tab_active")
|
|
70
|
-
}
|
|
71
|
-
set() {
|
|
72
|
-
return this.#tabs;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
exports.Tab = Tab
|
|
77
|
-
exports.Tabs = Tabs
|
|
1
|
+
let {Animation} = require('../../modules/chui_animations/animations');
|
|
2
|
+
|
|
3
|
+
class Tab {
|
|
4
|
+
#tab = document.createElement('tab');
|
|
5
|
+
#tab_content = [];
|
|
6
|
+
constructor(title) {
|
|
7
|
+
this.#tab.innerText = title;
|
|
8
|
+
}
|
|
9
|
+
addContent(...contents) {
|
|
10
|
+
for (let content of contents) this.#tab_content.push(content);
|
|
11
|
+
}
|
|
12
|
+
getTab() {
|
|
13
|
+
return this.#tab;
|
|
14
|
+
}
|
|
15
|
+
getContent() {
|
|
16
|
+
return this.#tab_content;
|
|
17
|
+
}
|
|
18
|
+
set() {
|
|
19
|
+
return this.#tab;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
class Tabs {
|
|
24
|
+
#tabzz = undefined;
|
|
25
|
+
#id_contents = require("randomstring").generate();
|
|
26
|
+
#tabs = document.createElement('tabs');
|
|
27
|
+
#id_list = require("randomstring").generate();
|
|
28
|
+
#list = document.createElement('list');
|
|
29
|
+
#content = document.createElement('content');
|
|
30
|
+
constructor(options = { width: String(), default: Number(), tabs: [] }) {
|
|
31
|
+
require('../../modules/chui_functions').setStyles(__dirname + "/styles.css", 'chUiJS_Tabs');
|
|
32
|
+
this.#tabzz = options.tabs;
|
|
33
|
+
this.#list.id = this.#id_list;
|
|
34
|
+
this.#content.id = this.#id_contents;
|
|
35
|
+
for (let item of options.tabs) {
|
|
36
|
+
item.getTab().addEventListener('click', (event) => {
|
|
37
|
+
if (event.target.getAttribute("active") === null) {
|
|
38
|
+
document.getElementById(this.#id_list).childNodes.forEach(child => {
|
|
39
|
+
child.removeAttribute("active");
|
|
40
|
+
child.classList.remove("tab_active")
|
|
41
|
+
})
|
|
42
|
+
event.target.setAttribute("active", true);
|
|
43
|
+
event.target.classList.add("tab_active")
|
|
44
|
+
let contentz = document.getElementById(this.#id_contents);
|
|
45
|
+
contentz.innerHTML = '';
|
|
46
|
+
for (let con of item.getContent()) this.#content.appendChild(con.set());
|
|
47
|
+
new Animation(this.#content).fadeIn();
|
|
48
|
+
this.#content.addEventListener('animationend', () => this.#content.removeAttribute('style'));
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
this.#list.appendChild(item.set());
|
|
52
|
+
}
|
|
53
|
+
this.#tabs.appendChild(this.#list);
|
|
54
|
+
this.#tabs.appendChild(this.#content);
|
|
55
|
+
if (options.default !== undefined) {
|
|
56
|
+
this.#setDefault(options.default)
|
|
57
|
+
} else {
|
|
58
|
+
this.#setDefault(0)
|
|
59
|
+
}
|
|
60
|
+
if (options.width !== undefined) this.#tabs.style.width = options.width;
|
|
61
|
+
}
|
|
62
|
+
#setDefault(num) {
|
|
63
|
+
for (let con of this.#tabzz[num].getContent()) {
|
|
64
|
+
this.#content.appendChild(con.set())
|
|
65
|
+
new Animation(this.#content).fadeIn();
|
|
66
|
+
this.#content.addEventListener('animationend', () => this.#content.removeAttribute('style'));
|
|
67
|
+
}
|
|
68
|
+
this.#tabzz[num].getTab().setAttribute("active", true);
|
|
69
|
+
this.#tabzz[num].getTab().classList.add("tab_active")
|
|
70
|
+
}
|
|
71
|
+
set() {
|
|
72
|
+
return this.#tabs;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
exports.Tab = Tab
|
|
77
|
+
exports.Tabs = Tabs
|