quasar-ui-sellmate-ui-kit 3.9.5 → 3.9.7

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.
@@ -0,0 +1,96 @@
1
+ function createDiv(val) {
2
+ const div = document.createElement('div');
3
+ div.classList.add(`resizable-${val}`);
4
+ div.style.top = '10px';
5
+ if (val === 'right') div.style.right = 0;
6
+ if (val === 'left') div.style.left = 0;
7
+ div.style.width = '4px';
8
+ div.style.position = 'absolute';
9
+ div.style.cursor = 'col-resize';
10
+ div.style.backgroundColor = 'none';
11
+ div.style.border = '1px solid #CCCCCC';
12
+ div.style.borderTop = 'none';
13
+ div.style.borderBottom = 'none';
14
+ div.style.zIndex = 2;
15
+ div.style.userSelect = 'none';
16
+ div.style.height = '16px';
17
+ return div;
18
+ }
19
+
20
+ function setTableTreeNode(tableEl, colIndex, newWidth, columns, resizedWidths) {
21
+ const allTables = tableEl.querySelectorAll('table');
22
+
23
+ allTables.forEach(table => {
24
+ const rows = table.querySelectorAll('tr');
25
+ rows.forEach(row => {
26
+ const cols = row.children;
27
+ if (cols[colIndex]) {
28
+
29
+ const minWidth = colIndex === 0 ? columns[colIndex].width : 0;
30
+ const resultWidth = Math.max(newWidth, minWidth);
31
+ cols[colIndex].style.minWidth = `${resultWidth}px`;
32
+ cols[colIndex].style.width = `${resultWidth}px`;
33
+
34
+ resizedWidths[colIndex] = resultWidth;
35
+ }
36
+ });
37
+ });
38
+ }
39
+
40
+ function setListeners(div, position, colIndex, tableEl, resizedWidths, columns) {
41
+ let curCol;
42
+ let pageX;
43
+ let curColWidth;
44
+
45
+ div.addEventListener('mousedown', (e) => {
46
+ curCol = e.target.parentElement;
47
+ pageX = e.pageX;
48
+ curColWidth = curCol.offsetWidth;
49
+ }, { passive: true });
50
+
51
+ document.addEventListener('mousemove', (e) => {
52
+ if (curCol) {
53
+ const diffX = e.pageX - pageX;
54
+ let newWidth = position === 'right' ? curColWidth + diffX : curColWidth - diffX;
55
+
56
+ const minWidth = colIndex === 0 ? columns[colIndex].width : 0;
57
+
58
+ newWidth = Math.max(newWidth, minWidth);
59
+ curCol.style.minWidth = `${newWidth}px`;
60
+ curCol.style.width = `${newWidth}px`;
61
+
62
+ resizedWidths[colIndex] = newWidth;
63
+ setTableTreeNode(tableEl, colIndex, newWidth, columns, resizedWidths);
64
+ }
65
+ }, { passive: true });
66
+
67
+ document.addEventListener('mouseup', () => {
68
+ curCol = null;
69
+ pageX = null;
70
+ curColWidth = null;
71
+ }, { passive: true });
72
+ }
73
+
74
+ function addResizable(tableEl, columns) {
75
+ const tableElement = tableEl.getElementsByTagName('table')[0];
76
+ const firstRow = tableElement.getElementsByTagName('tr')[0];
77
+ const cols = firstRow ? firstRow.children : [];
78
+ const resizedWidths = {};
79
+
80
+ for (let i = 0; i < cols.length - 1; i += 1) {
81
+ const div = createDiv('right');
82
+ cols[i].appendChild(div);
83
+ cols[i].style.position = 'sticky';
84
+ setListeners(div, 'right', i, tableEl, resizedWidths, columns);
85
+ }
86
+
87
+ return resizedWidths;
88
+ }
89
+
90
+ export function useResizableTree() {
91
+ return {
92
+ addResizable
93
+ };
94
+ }
95
+
96
+
package/src/vue-plugin.js CHANGED
@@ -41,6 +41,7 @@ import SYearMonthPicker from './components/SYearMonthPicker.vue';
41
41
  import Directive from './directives/Directive';
42
42
  import SBadge from './components/SBadge.vue';
43
43
  import STag from './components/STag.vue';
44
+ import STableTree from './components/STableTree.vue'
44
45
 
45
46
  const version = __UI_VERSION__;
46
47
 
@@ -75,6 +76,7 @@ function install(app) {
75
76
  app.component('s-route-tab', SRouteTab);
76
77
  app.component('s-tabs', STabs);
77
78
  app.component('s-table', STable);
79
+ app.component('s-table-tree', STableTree)
78
80
  app.component('s-time-picker', STimePicker);
79
81
  app.component('s-tag', STag);
80
82
  app.component('s-date-time-picker', SDateTimePicker);
Binary file