@getflip/swirl-components 0.43.2 → 0.44.1
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/components.json +36 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/swirl-components.cjs.js +1 -1
- package/dist/cjs/swirl-modal.cjs.entry.js +7 -3
- package/dist/cjs/swirl-table-column.cjs.entry.js +5 -0
- package/dist/cjs/swirl-table-row.cjs.entry.js +6 -0
- package/dist/cjs/swirl-table.cjs.entry.js +66 -139
- package/dist/collection/assets/pdfjs/pdf.worker.min.js +22 -0
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/swirl-modal/swirl-modal.css +132 -23
- package/dist/collection/components/swirl-modal/swirl-modal.js +29 -2
- package/dist/collection/components/swirl-table/swirl-table.js +87 -140
- package/dist/collection/components/swirl-table-column/swirl-table-column.js +5 -0
- package/dist/collection/components/swirl-table-row/swirl-table-row.js +6 -0
- package/dist/components/assets/pdfjs/pdf.worker.min.js +22 -0
- package/dist/components/swirl-modal.js +8 -3
- package/dist/components/swirl-table-column.js +5 -0
- package/dist/components/swirl-table-row.js +6 -0
- package/dist/components/swirl-table.js +68 -140
- package/dist/esm/loader.js +1 -1
- package/dist/esm/swirl-components.js +1 -1
- package/dist/esm/swirl-modal.entry.js +7 -3
- package/dist/esm/swirl-table-column.entry.js +5 -0
- package/dist/esm/swirl-table-row.entry.js +7 -1
- package/dist/esm/swirl-table.entry.js +66 -139
- package/dist/swirl-components/p-11977640.entry.js +10 -0
- package/dist/swirl-components/p-7412f5ee.entry.js +1 -0
- package/dist/swirl-components/p-e72b46cf.entry.js +1 -0
- package/dist/swirl-components/p-fd2f8580.entry.js +1 -0
- package/dist/swirl-components/swirl-components.esm.js +1 -1
- package/dist/types/components/swirl-modal/swirl-modal.d.ts +2 -0
- package/dist/types/components/swirl-table/swirl-table.d.ts +8 -8
- package/dist/types/components/swirl-table-column/swirl-table-column.d.ts +1 -0
- package/dist/types/components/swirl-table-row/swirl-table-row.d.ts +2 -0
- package/dist/types/components.d.ts +8 -0
- package/package.json +1 -1
- package/vscode-data.json +12 -0
- package/dist/swirl-components/p-40b1fc51.entry.js +0 -1
- package/dist/swirl-components/p-6e409546.entry.js +0 -10
- package/dist/swirl-components/p-7d7f11e8.entry.js +0 -1
- package/dist/swirl-components/p-98844f25.entry.js +0 -1
|
@@ -82,18 +82,22 @@ const SwirlTable = class {
|
|
|
82
82
|
constructor(hostRef) {
|
|
83
83
|
index.registerInstance(this, hostRef);
|
|
84
84
|
this.updateLayout = dist(async () => {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
await this.layOutColumns();
|
|
85
|
+
this.resetCellStyles();
|
|
86
|
+
this.resetColumnStyles();
|
|
87
|
+
this.resetEmptyRowStyles();
|
|
88
|
+
this.resetRowGroupStyles();
|
|
89
|
+
this.layoutEmptyRow();
|
|
90
|
+
this.layoutRowGroups();
|
|
92
91
|
this.layOutCells();
|
|
93
|
-
},
|
|
92
|
+
}, 16, { leading: true });
|
|
94
93
|
this.onScroll = () => {
|
|
95
94
|
this.updateScrolledState();
|
|
96
95
|
};
|
|
96
|
+
this.onSlotChange = async () => {
|
|
97
|
+
await this.updateLayout();
|
|
98
|
+
this.updateScrolledState();
|
|
99
|
+
this.updateEmptyState();
|
|
100
|
+
};
|
|
97
101
|
this.caption = undefined;
|
|
98
102
|
this.emptyStateLabel = "No results found.";
|
|
99
103
|
this.label = undefined;
|
|
@@ -102,22 +106,6 @@ const SwirlTable = class {
|
|
|
102
106
|
this.scrolled = undefined;
|
|
103
107
|
this.scrolledToEnd = undefined;
|
|
104
108
|
}
|
|
105
|
-
componentDidLoad() {
|
|
106
|
-
this.observer = new MutationObserver(async () => {
|
|
107
|
-
await this.updateLayout();
|
|
108
|
-
this.updateScrolledState();
|
|
109
|
-
this.updateEmptyState();
|
|
110
|
-
});
|
|
111
|
-
this.observer.observe(this.el, {
|
|
112
|
-
childList: true,
|
|
113
|
-
subtree: true,
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
disconnectedCallback() {
|
|
117
|
-
var _a, _b;
|
|
118
|
-
(_a = this.columnObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
119
|
-
(_b = this.observer) === null || _b === void 0 ? void 0 : _b.disconnect();
|
|
120
|
-
}
|
|
121
109
|
async componentDidRender() {
|
|
122
110
|
await this.updateLayout();
|
|
123
111
|
this.updateScrolledState();
|
|
@@ -127,6 +115,52 @@ const SwirlTable = class {
|
|
|
127
115
|
await this.updateLayout();
|
|
128
116
|
this.updateScrolledState();
|
|
129
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* Force a re-render of the table
|
|
120
|
+
*/
|
|
121
|
+
async rerender() {
|
|
122
|
+
await this.updateLayout();
|
|
123
|
+
this.updateScrolledState();
|
|
124
|
+
this.updateEmptyState();
|
|
125
|
+
}
|
|
126
|
+
resetEmptyRowStyles() {
|
|
127
|
+
const emptyRow = this.el.shadowRoot.querySelector(".table__empty-row");
|
|
128
|
+
if (!Boolean(emptyRow)) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
emptyRow.style.width = "";
|
|
132
|
+
}
|
|
133
|
+
resetRowGroupStyles() {
|
|
134
|
+
const tableRowGroups = Array.from(this.el.querySelectorAll("swirl-table-row-group"));
|
|
135
|
+
tableRowGroups.forEach((tableRowGroup) => {
|
|
136
|
+
const headerRow = tableRowGroup.shadowRoot.querySelector(".table-row-group__header-row");
|
|
137
|
+
if (!Boolean(headerRow)) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
tableRowGroup.shadowRoot.querySelector(".table-row-group__header-row").style.width = "";
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
resetColumnStyles() {
|
|
144
|
+
const columns = this.getColumns();
|
|
145
|
+
columns.forEach((column) => {
|
|
146
|
+
column.classList.remove("table-column--has-shadow");
|
|
147
|
+
column.style.right = "";
|
|
148
|
+
column.style.left = "";
|
|
149
|
+
column.style.position = "";
|
|
150
|
+
column.style.zIndex = "";
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
resetCellStyles() {
|
|
154
|
+
const cells = this.getCells();
|
|
155
|
+
cells.forEach((cell) => {
|
|
156
|
+
cell.classList.remove("table-cell--has-shadow");
|
|
157
|
+
cell.style.flex = "";
|
|
158
|
+
cell.style.left = "";
|
|
159
|
+
cell.style.right = "";
|
|
160
|
+
cell.style.position = "";
|
|
161
|
+
cell.style.zIndex = "";
|
|
162
|
+
});
|
|
163
|
+
}
|
|
130
164
|
updateScrolledState() {
|
|
131
165
|
const isMobile = utils.isMobileViewport();
|
|
132
166
|
const scrollable = this.container.scrollWidth > this.container.clientWidth;
|
|
@@ -164,45 +198,7 @@ const SwirlTable = class {
|
|
|
164
198
|
getCells() {
|
|
165
199
|
return Array.from(this.el.querySelectorAll("swirl-table-cell"));
|
|
166
200
|
}
|
|
167
|
-
|
|
168
|
-
const emptyRow = this.el.shadowRoot.querySelector(".table__empty-row");
|
|
169
|
-
if (!Boolean(emptyRow)) {
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
emptyRow.style.width = "";
|
|
173
|
-
await new Promise((resolve) => setTimeout(resolve));
|
|
174
|
-
}
|
|
175
|
-
async resetRowGroupStyles() {
|
|
176
|
-
const tableRowGroups = Array.from(this.el.querySelectorAll("swirl-table-row-group"));
|
|
177
|
-
tableRowGroups.forEach((tableRowGroup) => {
|
|
178
|
-
tableRowGroup.shadowRoot.querySelector(".table-row-group__header-row").style.width = "";
|
|
179
|
-
});
|
|
180
|
-
await new Promise((resolve) => setTimeout(resolve));
|
|
181
|
-
}
|
|
182
|
-
async resetColumnStyles() {
|
|
183
|
-
const columns = this.getColumns();
|
|
184
|
-
columns.forEach((column) => {
|
|
185
|
-
column.classList.remove("table-column--has-shadow");
|
|
186
|
-
column.style.right = "";
|
|
187
|
-
column.style.left = "";
|
|
188
|
-
column.style.position = "";
|
|
189
|
-
column.style.zIndex = "";
|
|
190
|
-
});
|
|
191
|
-
await new Promise((resolve) => setTimeout(resolve));
|
|
192
|
-
}
|
|
193
|
-
async resetCellStyles() {
|
|
194
|
-
const cells = this.getCells();
|
|
195
|
-
cells.forEach((cell) => {
|
|
196
|
-
cell.classList.remove("table-cell--has-shadow");
|
|
197
|
-
cell.style.flex = "";
|
|
198
|
-
cell.style.left = "";
|
|
199
|
-
cell.style.right = "";
|
|
200
|
-
cell.style.position = "";
|
|
201
|
-
cell.style.zIndex = "";
|
|
202
|
-
});
|
|
203
|
-
await new Promise((resolve) => setTimeout(resolve));
|
|
204
|
-
}
|
|
205
|
-
async layoutEmptyRow() {
|
|
201
|
+
layoutEmptyRow() {
|
|
206
202
|
const emptyRow = this.el.shadowRoot.querySelector(".table__empty-row");
|
|
207
203
|
if (!Boolean(emptyRow)) {
|
|
208
204
|
return;
|
|
@@ -210,97 +206,28 @@ const SwirlTable = class {
|
|
|
210
206
|
const scrollWidth = `${this.el.shadowRoot.querySelector(".table__container").scrollWidth}px`;
|
|
211
207
|
emptyRow.style.width = scrollWidth;
|
|
212
208
|
}
|
|
213
|
-
|
|
209
|
+
layoutRowGroups() {
|
|
210
|
+
var _a;
|
|
214
211
|
const tableRowGroups = Array.from(this.el.querySelectorAll("swirl-table-row-group"));
|
|
215
|
-
const scrollWidth = `${this.el.shadowRoot.querySelector(".table__container").scrollWidth}px`;
|
|
212
|
+
const scrollWidth = `${(_a = this.el.shadowRoot.querySelector(".table__container")) === null || _a === void 0 ? void 0 : _a.scrollWidth}px`;
|
|
216
213
|
tableRowGroups.forEach((tableRowGroup) => {
|
|
217
|
-
tableRowGroup.shadowRoot.querySelector(".table-row-group__header-row")
|
|
218
|
-
|
|
219
|
-
}
|
|
220
|
-
async layOutColumns() {
|
|
221
|
-
const columns = this.getColumns();
|
|
222
|
-
const tableContainer = this.container;
|
|
223
|
-
const tableContainerWidth = tableContainer.clientWidth;
|
|
224
|
-
columns.forEach((column, index) => {
|
|
225
|
-
var _a, _b;
|
|
226
|
-
if (!column.sticky || utils.isMobileViewport()) {
|
|
214
|
+
const headerRow = tableRowGroup.shadowRoot.querySelector(".table-row-group__header-row");
|
|
215
|
+
if (!Boolean(headerRow)) {
|
|
227
216
|
return;
|
|
228
217
|
}
|
|
229
|
-
|
|
230
|
-
const nextColumnIsSticky = (_a = columns[index + 1]) === null || _a === void 0 ? void 0 : _a.sticky;
|
|
231
|
-
const prevColumnIsSticky = (_b = columns[index - 1]) === null || _b === void 0 ? void 0 : _b.sticky;
|
|
232
|
-
const columnIsOnTopOfShadow = isInFirstHalfOfTable && nextColumnIsSticky;
|
|
233
|
-
column.style.zIndex = columnIsOnTopOfShadow ? "1" : "";
|
|
234
|
-
const columnHasShadow = (isInFirstHalfOfTable && !nextColumnIsSticky) ||
|
|
235
|
-
(!isInFirstHalfOfTable && !prevColumnIsSticky);
|
|
236
|
-
if (columnHasShadow) {
|
|
237
|
-
column.classList.add(isInFirstHalfOfTable
|
|
238
|
-
? "table-column--has-shadow-right"
|
|
239
|
-
: "table-column--has-shadow-left");
|
|
240
|
-
}
|
|
241
|
-
else {
|
|
242
|
-
column.classList.remove("table-column--has-shadow-right");
|
|
243
|
-
column.classList.remove("table-column--has-shadow-left");
|
|
244
|
-
}
|
|
245
|
-
const offset = isInFirstHalfOfTable
|
|
246
|
-
? column.offsetLeft
|
|
247
|
-
: Math.max(0, tableContainerWidth -
|
|
248
|
-
(column.offsetLeft + column.getBoundingClientRect().width));
|
|
249
|
-
column.style.position = "sticky";
|
|
250
|
-
if (isInFirstHalfOfTable) {
|
|
251
|
-
column.style.left = `${offset}px`;
|
|
252
|
-
}
|
|
253
|
-
else {
|
|
254
|
-
column.style.right = `${offset}px`;
|
|
255
|
-
}
|
|
218
|
+
tableRowGroup.shadowRoot.querySelector(".table-row-group__header-row").style.width = scrollWidth;
|
|
256
219
|
});
|
|
257
|
-
await new Promise((resolve) => setTimeout(resolve));
|
|
258
220
|
}
|
|
259
221
|
layOutCells() {
|
|
260
222
|
const columns = this.getColumns();
|
|
261
223
|
const cells = this.getCells();
|
|
262
224
|
columns.forEach((column, colIndex) => {
|
|
263
|
-
var _a, _b;
|
|
264
225
|
const cellsOfColumn = cells.filter((_, cellIndex) => {
|
|
265
226
|
return (colIndex - cellIndex) % columns.length === 0;
|
|
266
227
|
});
|
|
267
|
-
const isInFirstHalfOfTable = colIndex <= Math.floor(columns.length / 2);
|
|
268
|
-
const offset = isInFirstHalfOfTable
|
|
269
|
-
? window.getComputedStyle(column).left
|
|
270
|
-
: window.getComputedStyle(column).right;
|
|
271
|
-
const nextColumnIsSticky = (_a = columns[colIndex + 1]) === null || _a === void 0 ? void 0 : _a.sticky;
|
|
272
|
-
const prevColumnIsSticky = (_b = columns[colIndex - 1]) === null || _b === void 0 ? void 0 : _b.sticky;
|
|
273
|
-
const columnIsSticky = column.sticky;
|
|
274
228
|
const columnWidth = column.width || `${column.getBoundingClientRect().width}px`;
|
|
275
229
|
cellsOfColumn.forEach((cell) => {
|
|
276
|
-
const cellSticksToLeft = columnIsSticky && isInFirstHalfOfTable;
|
|
277
|
-
const cellSticksToRight = columnIsSticky && !isInFirstHalfOfTable;
|
|
278
|
-
const cellIsOnTopOfShadow = isInFirstHalfOfTable && nextColumnIsSticky;
|
|
279
230
|
cell.style.flex = Boolean(columnWidth) ? `0 0 ${columnWidth}` : "";
|
|
280
|
-
if (utils.isMobileViewport()) {
|
|
281
|
-
cell.classList.remove("table-cell--has-shadow");
|
|
282
|
-
cell.style.left = "";
|
|
283
|
-
cell.style.right = "";
|
|
284
|
-
cell.style.position = "";
|
|
285
|
-
cell.style.zIndex = "";
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
cell.style.left = cellSticksToLeft ? offset : "";
|
|
289
|
-
cell.style.right = cellSticksToRight ? offset : "";
|
|
290
|
-
cell.style.position = columnIsSticky ? "sticky" : "";
|
|
291
|
-
cell.style.zIndex = cellIsOnTopOfShadow ? "1" : "";
|
|
292
|
-
const cellHasShadow = columnIsSticky &&
|
|
293
|
-
((isInFirstHalfOfTable && !nextColumnIsSticky) ||
|
|
294
|
-
(!isInFirstHalfOfTable && !prevColumnIsSticky));
|
|
295
|
-
if (cellHasShadow) {
|
|
296
|
-
cell.classList.add(isInFirstHalfOfTable
|
|
297
|
-
? "table-cell--has-shadow-right"
|
|
298
|
-
: "table-cell--has-shadow-left");
|
|
299
|
-
}
|
|
300
|
-
else {
|
|
301
|
-
cell.classList.remove("table-cell--has-shadow-right");
|
|
302
|
-
cell.classList.remove("table-cell--has-shadow-left");
|
|
303
|
-
}
|
|
304
231
|
});
|
|
305
232
|
});
|
|
306
233
|
}
|
|
@@ -309,7 +236,7 @@ const SwirlTable = class {
|
|
|
309
236
|
this.empty = !Boolean(rowsContainer) || rowsContainer.children.length === 0;
|
|
310
237
|
}
|
|
311
238
|
render() {
|
|
312
|
-
return (index.h(index.Host, null, index.h("div", { class: "table" }, index.h("div", { class: "table__container", onScroll: this.onScroll, ref: (el) => (this.container = el) }, index.h("div", { "aria-describedby": Boolean(this.caption) ? "caption" : undefined, "aria-label": this.label, role: "table", class: "table__table" }, this.caption && (index.h("swirl-visually-hidden", null, index.h("div", { id: "caption" }, this.caption))), index.h("div", { role: "rowgroup" }, index.h("div", { class: "table__header", role: "row" }, index.h("slot", { name: "columns" }))), index.h("div", { class: "table__body" }, index.h("slot", { name: "rows" }), this.empty && (index.h("div", { class: "table__empty-row", role: "row" }, index.h("div", { "aria-colspan": this.getColumns().length, class: "table__empty-row-cell", role: "cell" }, index.h("swirl-text", { align: "center", size: "sm" }, this.emptyStateLabel))))))))));
|
|
239
|
+
return (index.h(index.Host, null, index.h("div", { class: "table" }, index.h("div", { class: "table__container", onScroll: this.onScroll, ref: (el) => (this.container = el) }, index.h("div", { "aria-describedby": Boolean(this.caption) ? "caption" : undefined, "aria-label": this.label, role: "table", class: "table__table" }, this.caption && (index.h("swirl-visually-hidden", null, index.h("div", { id: "caption" }, this.caption))), index.h("div", { role: "rowgroup" }, index.h("div", { class: "table__header", role: "row" }, index.h("slot", { name: "columns", onSlotchange: this.onSlotChange }))), index.h("div", { class: "table__body" }, index.h("slot", { name: "rows", onSlotchange: this.onSlotChange }), this.empty && (index.h("div", { class: "table__empty-row", role: "row" }, index.h("div", { "aria-colspan": this.getColumns().length, class: "table__empty-row-cell", role: "cell" }, index.h("swirl-text", { align: "center", size: "sm" }, this.emptyStateLabel))))))))));
|
|
313
240
|
}
|
|
314
241
|
get el() { return index.getElement(this); }
|
|
315
242
|
};
|