@aquera/nile-elements 0.1.68 → 0.1.69
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/README.md +3 -0
- package/dist/index.js +3 -3
- package/dist/internal/resizable-table-helper.cjs.js +1 -1
- package/dist/internal/resizable-table-helper.cjs.js.map +1 -1
- package/dist/internal/resizable-table-helper.esm.js +1 -1
- package/dist/nile-table-cell-item/nile-table-cell-item.cjs.js +1 -1
- package/dist/nile-table-cell-item/nile-table-cell-item.cjs.js.map +1 -1
- package/dist/nile-table-cell-item/nile-table-cell-item.esm.js +1 -1
- package/dist/nile-table-header-item/nile-table-header-item.cjs.js +1 -1
- package/dist/nile-table-header-item/nile-table-header-item.cjs.js.map +1 -1
- package/dist/nile-table-header-item/nile-table-header-item.esm.js +2 -2
- package/dist/src/internal/resizable-table-helper.d.ts +5 -0
- package/dist/src/internal/resizable-table-helper.js +27 -4
- package/dist/src/internal/resizable-table-helper.js.map +1 -1
- package/dist/src/nile-table-cell-item/nile-table-cell-item.d.ts +2 -1
- package/dist/src/nile-table-cell-item/nile-table-cell-item.js +12 -1
- package/dist/src/nile-table-cell-item/nile-table-cell-item.js.map +1 -1
- package/dist/src/nile-table-header-item/nile-table-header-item.d.ts +2 -1
- package/dist/src/nile-table-header-item/nile-table-header-item.js +12 -1
- package/dist/src/nile-table-header-item/nile-table-header-item.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/internal/resizable-table-helper.ts +31 -8
- package/src/nile-table-cell-item/nile-table-cell-item.ts +15 -1
- package/src/nile-table-header-item/nile-table-header-item.ts +15 -1
package/package.json
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
"description": "Webcomponent nile-elements following open-wc recommendations",
|
4
4
|
"license": "MIT",
|
5
5
|
"author": "nile-elements",
|
6
|
-
"version": "0.1.
|
6
|
+
"version": "0.1.69",
|
7
7
|
"main": "dist/src/index.js",
|
8
8
|
"type": "module",
|
9
9
|
"module": "dist/src/index.js",
|
@@ -192,4 +192,4 @@
|
|
192
192
|
"prettier --write"
|
193
193
|
]
|
194
194
|
}
|
195
|
-
}
|
195
|
+
}
|
@@ -103,6 +103,23 @@ export function synchronizeColumnWidth(sourceElement: HTMLElement, newWidth: num
|
|
103
103
|
});
|
104
104
|
}
|
105
105
|
|
106
|
+
/**
|
107
|
+
* Resets all column widths in a table to their default values
|
108
|
+
* @param tableBody The table body element to reset
|
109
|
+
*/
|
110
|
+
export function resetAllColumnWidths(tableBody: HTMLElement): void {
|
111
|
+
const headerItems = tableBody.querySelectorAll('nile-table-header-item');
|
112
|
+
const cellItems = tableBody.querySelectorAll('nile-table-cell-item');
|
113
|
+
|
114
|
+
headerItems.forEach(header => {
|
115
|
+
header.style.removeProperty('width');
|
116
|
+
});
|
117
|
+
|
118
|
+
cellItems.forEach(cell => {
|
119
|
+
cell.style.removeProperty('width');
|
120
|
+
});
|
121
|
+
}
|
122
|
+
|
106
123
|
/**
|
107
124
|
* Checks if an element has the resizable attribute
|
108
125
|
* @param element The element to check
|
@@ -137,15 +154,21 @@ export function createResizeHandler(element: HTMLElement, minWidth: number = 50)
|
|
137
154
|
* @returns True if any columns have resizable attribute
|
138
155
|
*/
|
139
156
|
export function hasResizableColumns(tableBody: HTMLElement): boolean {
|
140
|
-
const
|
141
|
-
|
157
|
+
const directChildren = Array.from(tableBody.children);
|
158
|
+
|
159
|
+
const hasResizableHeaders = directChildren.some(child => {
|
160
|
+
if (child.tagName.toLowerCase() === 'nile-table-header-item') {
|
161
|
+
return child.hasAttribute('resizable');
|
162
|
+
}
|
163
|
+
return false;
|
164
|
+
});
|
142
165
|
|
143
|
-
const
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
);
|
166
|
+
const hasResizableCells = directChildren.some(child => {
|
167
|
+
if (child.tagName.toLowerCase() === 'nile-table-cell-item') {
|
168
|
+
return child.hasAttribute('resizable');
|
169
|
+
}
|
170
|
+
return false;
|
171
|
+
});
|
149
172
|
|
150
173
|
return hasResizableHeaders || hasResizableCells;
|
151
174
|
}
|
@@ -10,12 +10,13 @@ import {
|
|
10
10
|
html,
|
11
11
|
CSSResultArray,
|
12
12
|
TemplateResult,
|
13
|
+
PropertyValues,
|
13
14
|
} from 'lit';
|
14
15
|
import { customElement, property } from 'lit/decorators.js';
|
15
16
|
import { styles } from './nile-table-cell-item.css';
|
16
17
|
import NileElement from '../internal/nile-element';
|
17
18
|
import { HasSlotController } from '../internal/slot';
|
18
|
-
import { createResizeHandler } from '../internal/resizable-table-helper';
|
19
|
+
import { createResizeHandler, resetAllColumnWidths } from '../internal/resizable-table-helper';
|
19
20
|
|
20
21
|
/**
|
21
22
|
* Nile table Cell Item component.
|
@@ -43,6 +44,19 @@ export class NileTableCellItem extends NileElement {
|
|
43
44
|
|
44
45
|
private handleResizeStart = createResizeHandler(this, 50);
|
45
46
|
|
47
|
+
protected updated(changedProperties: PropertyValues) {
|
48
|
+
super.updated(changedProperties);
|
49
|
+
|
50
|
+
if (changedProperties.has('resizable')) {
|
51
|
+
if (!this.resizable) {
|
52
|
+
const tableBody = this.closest('nile-table-body');
|
53
|
+
if (tableBody) {
|
54
|
+
resetAllColumnWidths(tableBody);
|
55
|
+
}
|
56
|
+
}
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
46
60
|
/**
|
47
61
|
* Render method
|
48
62
|
* @slot This is a slot test
|
@@ -10,12 +10,13 @@ import {
|
|
10
10
|
html,
|
11
11
|
CSSResultArray,
|
12
12
|
TemplateResult,
|
13
|
+
PropertyValues,
|
13
14
|
} from 'lit';
|
14
15
|
import { customElement, state, property } from 'lit/decorators.js';
|
15
16
|
import { styles } from './nile-table-header-item.css';
|
16
17
|
import NileElement from '../internal/nile-element';
|
17
18
|
import { HasSlotController } from '../internal/slot';
|
18
|
-
import { createResizeHandler } from '../internal/resizable-table-helper';
|
19
|
+
import { createResizeHandler, resetAllColumnWidths } from '../internal/resizable-table-helper';
|
19
20
|
|
20
21
|
/**
|
21
22
|
* Nile icon component.
|
@@ -53,6 +54,19 @@ export class NileTableHeaderItem extends NileElement {
|
|
53
54
|
|
54
55
|
/* #region Methods */
|
55
56
|
|
57
|
+
protected updated(changedProperties: PropertyValues) {
|
58
|
+
super.updated(changedProperties);
|
59
|
+
|
60
|
+
if (changedProperties.has('resizable')) {
|
61
|
+
if (!this.resizable) {
|
62
|
+
const tableBody = this.closest('nile-table-body');
|
63
|
+
if (tableBody) {
|
64
|
+
resetAllColumnWidths(tableBody);
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}
|
68
|
+
}
|
69
|
+
|
56
70
|
/**
|
57
71
|
* Render method
|
58
72
|
* @slot This is a slot test
|