@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
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"./components/swirl-inline-error/swirl-inline-error.js",
|
|
25
25
|
"./components/swirl-inline-notification/swirl-inline-notification.js",
|
|
26
26
|
"./components/swirl-link/swirl-link.js",
|
|
27
|
+
"./components/swirl-modal/swirl-modal.js",
|
|
27
28
|
"./components/swirl-option-list-item/swirl-option-list-item.js",
|
|
28
29
|
"./components/swirl-pagination/swirl-pagination.js",
|
|
29
30
|
"./components/swirl-popover/swirl-popover.js",
|
|
@@ -166,7 +167,6 @@
|
|
|
166
167
|
"./components/swirl-icon/icons/swirl-icon-warning.js",
|
|
167
168
|
"./components/swirl-lightbox/swirl-lightbox.js",
|
|
168
169
|
"./components/swirl-list/swirl-list.js",
|
|
169
|
-
"./components/swirl-modal/swirl-modal.js",
|
|
170
170
|
"./components/swirl-option-list/swirl-option-list.js",
|
|
171
171
|
"./components/swirl-option-list-section/swirl-option-list-section.js",
|
|
172
172
|
"./components/swirl-pdf-reader/swirl-pdf-reader.js",
|
|
@@ -23,32 +23,120 @@
|
|
|
23
23
|
display: none;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
.modal
|
|
27
|
-
-webkit-animation: 0.15s modal-
|
|
28
|
-
animation: 0.15s modal-
|
|
26
|
+
.modal--variant-default.modal--closing {
|
|
27
|
+
-webkit-animation: 0.15s modal-fade-out;
|
|
28
|
+
animation: 0.15s modal-fade-out;
|
|
29
|
+
-webkit-animation-fill-mode: forwards;
|
|
30
|
+
animation-fill-mode: forwards;
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
@media (prefers-reduced-motion) {
|
|
32
34
|
|
|
33
|
-
.modal
|
|
35
|
+
.modal--variant-default.modal--closing {
|
|
34
36
|
-webkit-animation: none;
|
|
35
37
|
animation: none
|
|
36
38
|
}
|
|
37
39
|
}
|
|
38
40
|
|
|
39
|
-
.modal:not(.modal--closing) .
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
.modal--variant-default:not(.modal--closing) .modal__backdrop {
|
|
42
|
+
-webkit-animation: 0.15s modal-backdrop-fade-in;
|
|
43
|
+
animation: 0.15s modal-backdrop-fade-in;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@media (prefers-reduced-motion) {
|
|
47
|
+
|
|
48
|
+
.modal--variant-default:not(.modal--closing) .modal__backdrop {
|
|
49
|
+
-webkit-animation: none;
|
|
50
|
+
animation: none
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.modal--variant-default:not(.modal--closing) .modal__body {
|
|
55
|
+
-webkit-animation: 0.15s modal-scale-in;
|
|
56
|
+
animation: 0.15s modal-scale-in;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@media (prefers-reduced-motion) {
|
|
60
|
+
|
|
61
|
+
.modal--variant-default:not(.modal--closing) .modal__body {
|
|
62
|
+
-webkit-animation: none;
|
|
63
|
+
animation: none
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.modal--variant-drawer {
|
|
68
|
+
justify-content: end;
|
|
69
|
+
align-items: stretch;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.modal--variant-drawer.modal--closing {
|
|
73
|
+
-webkit-animation: 0.15s modal-drawer-slide-out;
|
|
74
|
+
animation: 0.15s modal-drawer-slide-out;
|
|
75
|
+
-webkit-animation-fill-mode: forwards;
|
|
76
|
+
animation-fill-mode: forwards;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@media (prefers-reduced-motion) {
|
|
80
|
+
|
|
81
|
+
.modal--variant-drawer.modal--closing {
|
|
82
|
+
-webkit-animation: none;
|
|
83
|
+
animation: none
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.modal--variant-drawer.modal--hide-label .modal__content {
|
|
88
|
+
padding-top: calc(3.5rem + var(--s-space-8));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.modal--variant-drawer .modal__backdrop {
|
|
92
|
+
background-color: transparent;
|
|
93
|
+
-webkit-animation: none;
|
|
94
|
+
animation: none;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.modal--variant-drawer .modal__body {
|
|
98
|
+
height: 100%;
|
|
99
|
+
max-height: none;
|
|
100
|
+
border-radius: 0;
|
|
101
|
+
-webkit-animation: 0.15s modal-drawer-slide-in;
|
|
102
|
+
animation: 0.15s modal-drawer-slide-in;
|
|
103
|
+
box-shadow: var(--s-shadow-level-3);
|
|
42
104
|
}
|
|
43
105
|
|
|
44
106
|
@media (prefers-reduced-motion) {
|
|
45
107
|
|
|
46
|
-
.modal
|
|
108
|
+
.modal--variant-drawer .modal__body {
|
|
47
109
|
-webkit-animation: none;
|
|
48
110
|
animation: none
|
|
49
111
|
}
|
|
50
112
|
}
|
|
51
113
|
|
|
114
|
+
.modal--variant-drawer .modal__close-button {
|
|
115
|
+
right: auto;
|
|
116
|
+
left: var(--s-space-8);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
@media (min-width: 768px) {
|
|
120
|
+
|
|
121
|
+
.modal--variant-drawer .modal__close-button {
|
|
122
|
+
left: var(--s-space-16)
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.modal--variant-drawer .modal__header {
|
|
127
|
+
padding-left: calc(var(--s-space-8) + 2.5rem + var(--s-space-8));
|
|
128
|
+
padding-right: var(--s-space-16);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
@media (min-width: 768px) {
|
|
132
|
+
|
|
133
|
+
.modal--variant-drawer .modal__header {
|
|
134
|
+
padding-top: var(--s-space-16);
|
|
135
|
+
padding-right: var(--s-space-24);
|
|
136
|
+
padding-left: calc(var(--s-space-16) + 2.5rem + var(--s-space-8))
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
52
140
|
.modal--padded .modal__content {
|
|
53
141
|
padding-top: var(--s-space-24);
|
|
54
142
|
padding-right: var(--s-space-16);
|
|
@@ -70,21 +158,6 @@
|
|
|
70
158
|
padding-top: var(--s-space-16);
|
|
71
159
|
}
|
|
72
160
|
|
|
73
|
-
.modal--closing {
|
|
74
|
-
-webkit-animation: 0.15s modal-fade-out;
|
|
75
|
-
animation: 0.15s modal-fade-out;
|
|
76
|
-
-webkit-animation-fill-mode: forwards;
|
|
77
|
-
animation-fill-mode: forwards;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
@media (prefers-reduced-motion) {
|
|
81
|
-
|
|
82
|
-
.modal--closing {
|
|
83
|
-
-webkit-animation: none;
|
|
84
|
-
animation: none
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
161
|
@media (min-width: 768px) {
|
|
89
162
|
|
|
90
163
|
.modal--scrollable .modal__content {
|
|
@@ -260,3 +333,39 @@
|
|
|
260
333
|
opacity: 0;
|
|
261
334
|
}
|
|
262
335
|
}
|
|
336
|
+
|
|
337
|
+
@-webkit-keyframes modal-drawer-slide-in {
|
|
338
|
+
from {
|
|
339
|
+
transform: translate3d(100%, 0, 0);
|
|
340
|
+
}
|
|
341
|
+
to {
|
|
342
|
+
transform: translate3d(0, 0, 0);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
@keyframes modal-drawer-slide-in {
|
|
347
|
+
from {
|
|
348
|
+
transform: translate3d(100%, 0, 0);
|
|
349
|
+
}
|
|
350
|
+
to {
|
|
351
|
+
transform: translate3d(0, 0, 0);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
@-webkit-keyframes modal-drawer-slide-out {
|
|
356
|
+
from {
|
|
357
|
+
transform: translate3d(0, 0, 0);
|
|
358
|
+
}
|
|
359
|
+
to {
|
|
360
|
+
transform: translate3d(100%, 0, 0);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
@keyframes modal-drawer-slide-out {
|
|
365
|
+
from {
|
|
366
|
+
transform: translate3d(0, 0, 0);
|
|
367
|
+
}
|
|
368
|
+
to {
|
|
369
|
+
transform: translate3d(100%, 0, 0);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
@@ -51,6 +51,7 @@ export class SwirlModal {
|
|
|
51
51
|
this.padded = true;
|
|
52
52
|
this.primaryActionLabel = undefined;
|
|
53
53
|
this.secondaryActionLabel = undefined;
|
|
54
|
+
this.variant = "default";
|
|
54
55
|
this.isOpen = false;
|
|
55
56
|
this.closing = false;
|
|
56
57
|
this.hasCustomHeader = undefined;
|
|
@@ -119,15 +120,18 @@ export class SwirlModal {
|
|
|
119
120
|
}
|
|
120
121
|
render() {
|
|
121
122
|
const showControls = Boolean(this.primaryActionLabel) || Boolean(this.secondaryActionLabel);
|
|
122
|
-
const className = classnames("modal", {
|
|
123
|
+
const className = classnames("modal", `modal--variant-${this.variant}`, {
|
|
123
124
|
"modal--closing": this.closing,
|
|
124
125
|
"modal--has-custom-header": this.hasCustomHeader,
|
|
126
|
+
"modal--hide-label": this.hideLabel,
|
|
125
127
|
"modal--padded": this.padded,
|
|
126
128
|
"modal--scrollable": this.scrollable,
|
|
127
129
|
"modal--scrolled": this.scrolled,
|
|
128
130
|
"modal--scrolled-down": this.scrolledDown,
|
|
129
131
|
});
|
|
130
|
-
return (h(Host, null, h("section", { "aria-hidden": String(!this.isOpen), "aria-label": this.label, "aria-modal": "true", class: className, onKeyDown: this.onKeyDown, role: "dialog", ref: (el) => (this.modalEl = el) }, h("div", { class: "modal__backdrop", onClick: this.onBackdropClick }), h("div", { class: "modal__body", style: { maxWidth: this.maxWidth } }, !this.hideCloseButton && (h("swirl-button", { class: "modal__close-button", hideLabel: true, icon:
|
|
132
|
+
return (h(Host, null, h("section", { "aria-hidden": String(!this.isOpen), "aria-label": this.label, "aria-modal": "true", class: className, onKeyDown: this.onKeyDown, role: "dialog", ref: (el) => (this.modalEl = el) }, h("div", { class: "modal__backdrop", onClick: this.onBackdropClick }), h("div", { class: "modal__body", style: { maxWidth: this.maxWidth } }, !this.hideCloseButton && (h("swirl-button", { class: "modal__close-button", hideLabel: true, icon: this.variant === "default"
|
|
133
|
+
? "<swirl-icon-close></swirl-icon-close>"
|
|
134
|
+
: "<swirl-icon-double-arrow-right></swirl-icon-double-arrow-right>", label: this.closeButtonLabel, onClick: this.onCloseButtonClick })), h("header", { class: "modal__custom-header" }, h("slot", { name: "custom-header", onSlotchange: this.onCustomHeaderSlotChange, ref: (el) => (this.customHeaderSlot = el) })), !this.hideLabel && (h("header", { class: "modal__header" }, h("swirl-heading", { as: "h2", class: "modal__heading", level: 3, text: this.label }))), h("div", { class: "modal__content", onScroll: this.determineScrollStatus, ref: (el) => (this.scrollContainer = el) }, h("slot", null)), showControls && (h("footer", { class: "modal__controls" }, h("swirl-button-group", { wrap: true }, this.secondaryActionLabel && (h("swirl-button", { label: this.secondaryActionLabel, onClick: this.onSecondaryAction })), this.primaryActionLabel && (h("swirl-button", { intent: "primary", label: this.primaryActionLabel, onClick: this.onPrimaryAction, variant: "flat" })))))))));
|
|
131
135
|
}
|
|
132
136
|
static get is() { return "swirl-modal"; }
|
|
133
137
|
static get originalStyleUrls() {
|
|
@@ -279,6 +283,29 @@ export class SwirlModal {
|
|
|
279
283
|
},
|
|
280
284
|
"attribute": "secondary-action-label",
|
|
281
285
|
"reflect": false
|
|
286
|
+
},
|
|
287
|
+
"variant": {
|
|
288
|
+
"type": "string",
|
|
289
|
+
"mutable": false,
|
|
290
|
+
"complexType": {
|
|
291
|
+
"original": "SwirlModalVariant",
|
|
292
|
+
"resolved": "\"default\" | \"drawer\"",
|
|
293
|
+
"references": {
|
|
294
|
+
"SwirlModalVariant": {
|
|
295
|
+
"location": "local",
|
|
296
|
+
"path": "/home/runner/work/swirl/swirl/packages/swirl-components/src/components/swirl-modal/swirl-modal.tsx"
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
},
|
|
300
|
+
"required": false,
|
|
301
|
+
"optional": true,
|
|
302
|
+
"docs": {
|
|
303
|
+
"tags": [],
|
|
304
|
+
"text": ""
|
|
305
|
+
},
|
|
306
|
+
"attribute": "variant",
|
|
307
|
+
"reflect": false,
|
|
308
|
+
"defaultValue": "\"default\""
|
|
282
309
|
}
|
|
283
310
|
};
|
|
284
311
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { h, Host, } from "@stencil/core";
|
|
2
|
-
import debouncePromise from "debounce-promise";
|
|
3
2
|
import { isMobileViewport } from "../../utils";
|
|
3
|
+
import debouncePromise from "debounce-promise";
|
|
4
4
|
/**
|
|
5
5
|
* @slot columns - Column container, should contain SwirlTableColumns.
|
|
6
6
|
* @slot rows - Row container, should contain SwirlTableRows.
|
|
@@ -8,18 +8,22 @@ import { isMobileViewport } from "../../utils";
|
|
|
8
8
|
export class SwirlTable {
|
|
9
9
|
constructor() {
|
|
10
10
|
this.updateLayout = debouncePromise(async () => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
await this.layOutColumns();
|
|
11
|
+
this.resetCellStyles();
|
|
12
|
+
this.resetColumnStyles();
|
|
13
|
+
this.resetEmptyRowStyles();
|
|
14
|
+
this.resetRowGroupStyles();
|
|
15
|
+
this.layoutEmptyRow();
|
|
16
|
+
this.layoutRowGroups();
|
|
18
17
|
this.layOutCells();
|
|
19
|
-
},
|
|
18
|
+
}, 16, { leading: true });
|
|
20
19
|
this.onScroll = () => {
|
|
21
20
|
this.updateScrolledState();
|
|
22
21
|
};
|
|
22
|
+
this.onSlotChange = async () => {
|
|
23
|
+
await this.updateLayout();
|
|
24
|
+
this.updateScrolledState();
|
|
25
|
+
this.updateEmptyState();
|
|
26
|
+
};
|
|
23
27
|
this.caption = undefined;
|
|
24
28
|
this.emptyStateLabel = "No results found.";
|
|
25
29
|
this.label = undefined;
|
|
@@ -28,22 +32,6 @@ export class SwirlTable {
|
|
|
28
32
|
this.scrolled = undefined;
|
|
29
33
|
this.scrolledToEnd = undefined;
|
|
30
34
|
}
|
|
31
|
-
componentDidLoad() {
|
|
32
|
-
this.observer = new MutationObserver(async () => {
|
|
33
|
-
await this.updateLayout();
|
|
34
|
-
this.updateScrolledState();
|
|
35
|
-
this.updateEmptyState();
|
|
36
|
-
});
|
|
37
|
-
this.observer.observe(this.el, {
|
|
38
|
-
childList: true,
|
|
39
|
-
subtree: true,
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
disconnectedCallback() {
|
|
43
|
-
var _a, _b;
|
|
44
|
-
(_a = this.columnObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
45
|
-
(_b = this.observer) === null || _b === void 0 ? void 0 : _b.disconnect();
|
|
46
|
-
}
|
|
47
35
|
async componentDidRender() {
|
|
48
36
|
await this.updateLayout();
|
|
49
37
|
this.updateScrolledState();
|
|
@@ -53,6 +41,52 @@ export class SwirlTable {
|
|
|
53
41
|
await this.updateLayout();
|
|
54
42
|
this.updateScrolledState();
|
|
55
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Force a re-render of the table
|
|
46
|
+
*/
|
|
47
|
+
async rerender() {
|
|
48
|
+
await this.updateLayout();
|
|
49
|
+
this.updateScrolledState();
|
|
50
|
+
this.updateEmptyState();
|
|
51
|
+
}
|
|
52
|
+
resetEmptyRowStyles() {
|
|
53
|
+
const emptyRow = this.el.shadowRoot.querySelector(".table__empty-row");
|
|
54
|
+
if (!Boolean(emptyRow)) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
emptyRow.style.width = "";
|
|
58
|
+
}
|
|
59
|
+
resetRowGroupStyles() {
|
|
60
|
+
const tableRowGroups = Array.from(this.el.querySelectorAll("swirl-table-row-group"));
|
|
61
|
+
tableRowGroups.forEach((tableRowGroup) => {
|
|
62
|
+
const headerRow = tableRowGroup.shadowRoot.querySelector(".table-row-group__header-row");
|
|
63
|
+
if (!Boolean(headerRow)) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
tableRowGroup.shadowRoot.querySelector(".table-row-group__header-row").style.width = "";
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
resetColumnStyles() {
|
|
70
|
+
const columns = this.getColumns();
|
|
71
|
+
columns.forEach((column) => {
|
|
72
|
+
column.classList.remove("table-column--has-shadow");
|
|
73
|
+
column.style.right = "";
|
|
74
|
+
column.style.left = "";
|
|
75
|
+
column.style.position = "";
|
|
76
|
+
column.style.zIndex = "";
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
resetCellStyles() {
|
|
80
|
+
const cells = this.getCells();
|
|
81
|
+
cells.forEach((cell) => {
|
|
82
|
+
cell.classList.remove("table-cell--has-shadow");
|
|
83
|
+
cell.style.flex = "";
|
|
84
|
+
cell.style.left = "";
|
|
85
|
+
cell.style.right = "";
|
|
86
|
+
cell.style.position = "";
|
|
87
|
+
cell.style.zIndex = "";
|
|
88
|
+
});
|
|
89
|
+
}
|
|
56
90
|
updateScrolledState() {
|
|
57
91
|
const isMobile = isMobileViewport();
|
|
58
92
|
const scrollable = this.container.scrollWidth > this.container.clientWidth;
|
|
@@ -90,45 +124,7 @@ export class SwirlTable {
|
|
|
90
124
|
getCells() {
|
|
91
125
|
return Array.from(this.el.querySelectorAll("swirl-table-cell"));
|
|
92
126
|
}
|
|
93
|
-
|
|
94
|
-
const emptyRow = this.el.shadowRoot.querySelector(".table__empty-row");
|
|
95
|
-
if (!Boolean(emptyRow)) {
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
emptyRow.style.width = "";
|
|
99
|
-
await new Promise((resolve) => setTimeout(resolve));
|
|
100
|
-
}
|
|
101
|
-
async resetRowGroupStyles() {
|
|
102
|
-
const tableRowGroups = Array.from(this.el.querySelectorAll("swirl-table-row-group"));
|
|
103
|
-
tableRowGroups.forEach((tableRowGroup) => {
|
|
104
|
-
tableRowGroup.shadowRoot.querySelector(".table-row-group__header-row").style.width = "";
|
|
105
|
-
});
|
|
106
|
-
await new Promise((resolve) => setTimeout(resolve));
|
|
107
|
-
}
|
|
108
|
-
async resetColumnStyles() {
|
|
109
|
-
const columns = this.getColumns();
|
|
110
|
-
columns.forEach((column) => {
|
|
111
|
-
column.classList.remove("table-column--has-shadow");
|
|
112
|
-
column.style.right = "";
|
|
113
|
-
column.style.left = "";
|
|
114
|
-
column.style.position = "";
|
|
115
|
-
column.style.zIndex = "";
|
|
116
|
-
});
|
|
117
|
-
await new Promise((resolve) => setTimeout(resolve));
|
|
118
|
-
}
|
|
119
|
-
async resetCellStyles() {
|
|
120
|
-
const cells = this.getCells();
|
|
121
|
-
cells.forEach((cell) => {
|
|
122
|
-
cell.classList.remove("table-cell--has-shadow");
|
|
123
|
-
cell.style.flex = "";
|
|
124
|
-
cell.style.left = "";
|
|
125
|
-
cell.style.right = "";
|
|
126
|
-
cell.style.position = "";
|
|
127
|
-
cell.style.zIndex = "";
|
|
128
|
-
});
|
|
129
|
-
await new Promise((resolve) => setTimeout(resolve));
|
|
130
|
-
}
|
|
131
|
-
async layoutEmptyRow() {
|
|
127
|
+
layoutEmptyRow() {
|
|
132
128
|
const emptyRow = this.el.shadowRoot.querySelector(".table__empty-row");
|
|
133
129
|
if (!Boolean(emptyRow)) {
|
|
134
130
|
return;
|
|
@@ -136,97 +132,28 @@ export class SwirlTable {
|
|
|
136
132
|
const scrollWidth = `${this.el.shadowRoot.querySelector(".table__container").scrollWidth}px`;
|
|
137
133
|
emptyRow.style.width = scrollWidth;
|
|
138
134
|
}
|
|
139
|
-
|
|
135
|
+
layoutRowGroups() {
|
|
136
|
+
var _a;
|
|
140
137
|
const tableRowGroups = Array.from(this.el.querySelectorAll("swirl-table-row-group"));
|
|
141
|
-
const scrollWidth = `${this.el.shadowRoot.querySelector(".table__container").scrollWidth}px`;
|
|
138
|
+
const scrollWidth = `${(_a = this.el.shadowRoot.querySelector(".table__container")) === null || _a === void 0 ? void 0 : _a.scrollWidth}px`;
|
|
142
139
|
tableRowGroups.forEach((tableRowGroup) => {
|
|
143
|
-
tableRowGroup.shadowRoot.querySelector(".table-row-group__header-row")
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
async layOutColumns() {
|
|
147
|
-
const columns = this.getColumns();
|
|
148
|
-
const tableContainer = this.container;
|
|
149
|
-
const tableContainerWidth = tableContainer.clientWidth;
|
|
150
|
-
columns.forEach((column, index) => {
|
|
151
|
-
var _a, _b;
|
|
152
|
-
if (!column.sticky || isMobileViewport()) {
|
|
140
|
+
const headerRow = tableRowGroup.shadowRoot.querySelector(".table-row-group__header-row");
|
|
141
|
+
if (!Boolean(headerRow)) {
|
|
153
142
|
return;
|
|
154
143
|
}
|
|
155
|
-
|
|
156
|
-
const nextColumnIsSticky = (_a = columns[index + 1]) === null || _a === void 0 ? void 0 : _a.sticky;
|
|
157
|
-
const prevColumnIsSticky = (_b = columns[index - 1]) === null || _b === void 0 ? void 0 : _b.sticky;
|
|
158
|
-
const columnIsOnTopOfShadow = isInFirstHalfOfTable && nextColumnIsSticky;
|
|
159
|
-
column.style.zIndex = columnIsOnTopOfShadow ? "1" : "";
|
|
160
|
-
const columnHasShadow = (isInFirstHalfOfTable && !nextColumnIsSticky) ||
|
|
161
|
-
(!isInFirstHalfOfTable && !prevColumnIsSticky);
|
|
162
|
-
if (columnHasShadow) {
|
|
163
|
-
column.classList.add(isInFirstHalfOfTable
|
|
164
|
-
? "table-column--has-shadow-right"
|
|
165
|
-
: "table-column--has-shadow-left");
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
column.classList.remove("table-column--has-shadow-right");
|
|
169
|
-
column.classList.remove("table-column--has-shadow-left");
|
|
170
|
-
}
|
|
171
|
-
const offset = isInFirstHalfOfTable
|
|
172
|
-
? column.offsetLeft
|
|
173
|
-
: Math.max(0, tableContainerWidth -
|
|
174
|
-
(column.offsetLeft + column.getBoundingClientRect().width));
|
|
175
|
-
column.style.position = "sticky";
|
|
176
|
-
if (isInFirstHalfOfTable) {
|
|
177
|
-
column.style.left = `${offset}px`;
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
column.style.right = `${offset}px`;
|
|
181
|
-
}
|
|
144
|
+
tableRowGroup.shadowRoot.querySelector(".table-row-group__header-row").style.width = scrollWidth;
|
|
182
145
|
});
|
|
183
|
-
await new Promise((resolve) => setTimeout(resolve));
|
|
184
146
|
}
|
|
185
147
|
layOutCells() {
|
|
186
148
|
const columns = this.getColumns();
|
|
187
149
|
const cells = this.getCells();
|
|
188
150
|
columns.forEach((column, colIndex) => {
|
|
189
|
-
var _a, _b;
|
|
190
151
|
const cellsOfColumn = cells.filter((_, cellIndex) => {
|
|
191
152
|
return (colIndex - cellIndex) % columns.length === 0;
|
|
192
153
|
});
|
|
193
|
-
const isInFirstHalfOfTable = colIndex <= Math.floor(columns.length / 2);
|
|
194
|
-
const offset = isInFirstHalfOfTable
|
|
195
|
-
? window.getComputedStyle(column).left
|
|
196
|
-
: window.getComputedStyle(column).right;
|
|
197
|
-
const nextColumnIsSticky = (_a = columns[colIndex + 1]) === null || _a === void 0 ? void 0 : _a.sticky;
|
|
198
|
-
const prevColumnIsSticky = (_b = columns[colIndex - 1]) === null || _b === void 0 ? void 0 : _b.sticky;
|
|
199
|
-
const columnIsSticky = column.sticky;
|
|
200
154
|
const columnWidth = column.width || `${column.getBoundingClientRect().width}px`;
|
|
201
155
|
cellsOfColumn.forEach((cell) => {
|
|
202
|
-
const cellSticksToLeft = columnIsSticky && isInFirstHalfOfTable;
|
|
203
|
-
const cellSticksToRight = columnIsSticky && !isInFirstHalfOfTable;
|
|
204
|
-
const cellIsOnTopOfShadow = isInFirstHalfOfTable && nextColumnIsSticky;
|
|
205
156
|
cell.style.flex = Boolean(columnWidth) ? `0 0 ${columnWidth}` : "";
|
|
206
|
-
if (isMobileViewport()) {
|
|
207
|
-
cell.classList.remove("table-cell--has-shadow");
|
|
208
|
-
cell.style.left = "";
|
|
209
|
-
cell.style.right = "";
|
|
210
|
-
cell.style.position = "";
|
|
211
|
-
cell.style.zIndex = "";
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
cell.style.left = cellSticksToLeft ? offset : "";
|
|
215
|
-
cell.style.right = cellSticksToRight ? offset : "";
|
|
216
|
-
cell.style.position = columnIsSticky ? "sticky" : "";
|
|
217
|
-
cell.style.zIndex = cellIsOnTopOfShadow ? "1" : "";
|
|
218
|
-
const cellHasShadow = columnIsSticky &&
|
|
219
|
-
((isInFirstHalfOfTable && !nextColumnIsSticky) ||
|
|
220
|
-
(!isInFirstHalfOfTable && !prevColumnIsSticky));
|
|
221
|
-
if (cellHasShadow) {
|
|
222
|
-
cell.classList.add(isInFirstHalfOfTable
|
|
223
|
-
? "table-cell--has-shadow-right"
|
|
224
|
-
: "table-cell--has-shadow-left");
|
|
225
|
-
}
|
|
226
|
-
else {
|
|
227
|
-
cell.classList.remove("table-cell--has-shadow-right");
|
|
228
|
-
cell.classList.remove("table-cell--has-shadow-left");
|
|
229
|
-
}
|
|
230
157
|
});
|
|
231
158
|
});
|
|
232
159
|
}
|
|
@@ -235,7 +162,7 @@ export class SwirlTable {
|
|
|
235
162
|
this.empty = !Boolean(rowsContainer) || rowsContainer.children.length === 0;
|
|
236
163
|
}
|
|
237
164
|
render() {
|
|
238
|
-
return (h(Host, null, h("div", { class: "table" }, h("div", { class: "table__container", onScroll: this.onScroll, ref: (el) => (this.container = el) }, h("div", { "aria-describedby": Boolean(this.caption) ? "caption" : undefined, "aria-label": this.label, role: "table", class: "table__table" }, this.caption && (h("swirl-visually-hidden", null, h("div", { id: "caption" }, this.caption))), h("div", { role: "rowgroup" }, h("div", { class: "table__header", role: "row" }, h("slot", { name: "columns" }))), h("div", { class: "table__body" }, h("slot", { name: "rows" }), this.empty && (h("div", { class: "table__empty-row", role: "row" }, h("div", { "aria-colspan": this.getColumns().length, class: "table__empty-row-cell", role: "cell" }, h("swirl-text", { align: "center", size: "sm" }, this.emptyStateLabel))))))))));
|
|
165
|
+
return (h(Host, null, h("div", { class: "table" }, h("div", { class: "table__container", onScroll: this.onScroll, ref: (el) => (this.container = el) }, h("div", { "aria-describedby": Boolean(this.caption) ? "caption" : undefined, "aria-label": this.label, role: "table", class: "table__table" }, this.caption && (h("swirl-visually-hidden", null, h("div", { id: "caption" }, this.caption))), h("div", { role: "rowgroup" }, h("div", { class: "table__header", role: "row" }, h("slot", { name: "columns", onSlotchange: this.onSlotChange }))), h("div", { class: "table__body" }, h("slot", { name: "rows", onSlotchange: this.onSlotChange }), this.empty && (h("div", { class: "table__empty-row", role: "row" }, h("div", { "aria-colspan": this.getColumns().length, class: "table__empty-row-cell", role: "cell" }, h("swirl-text", { align: "center", size: "sm" }, this.emptyStateLabel))))))))));
|
|
239
166
|
}
|
|
240
167
|
static get is() { return "swirl-table"; }
|
|
241
168
|
static get encapsulation() { return "shadow"; }
|
|
@@ -313,6 +240,26 @@ export class SwirlTable {
|
|
|
313
240
|
"scrolledToEnd": {}
|
|
314
241
|
};
|
|
315
242
|
}
|
|
243
|
+
static get methods() {
|
|
244
|
+
return {
|
|
245
|
+
"rerender": {
|
|
246
|
+
"complexType": {
|
|
247
|
+
"signature": "() => Promise<void>",
|
|
248
|
+
"parameters": [],
|
|
249
|
+
"references": {
|
|
250
|
+
"Promise": {
|
|
251
|
+
"location": "global"
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
"return": "Promise<void>"
|
|
255
|
+
},
|
|
256
|
+
"docs": {
|
|
257
|
+
"text": "Force a re-render of the table",
|
|
258
|
+
"tags": []
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
}
|
|
316
263
|
static get elementRef() { return "el"; }
|
|
317
264
|
static get listeners() {
|
|
318
265
|
return [{
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { h, Host } from "@stencil/core";
|
|
2
|
+
import { closestPassShadow } from "../../utils";
|
|
2
3
|
/**
|
|
3
4
|
* @slot slot - The column label.
|
|
4
5
|
*/
|
|
@@ -11,6 +12,10 @@ export class SwirlTableColumn {
|
|
|
11
12
|
this.sticky = undefined;
|
|
12
13
|
this.width = undefined;
|
|
13
14
|
}
|
|
15
|
+
componentDidRender() {
|
|
16
|
+
const table = closestPassShadow(this.el, "swirl-table");
|
|
17
|
+
table === null || table === void 0 ? void 0 : table.rerender();
|
|
18
|
+
}
|
|
14
19
|
render() {
|
|
15
20
|
const styles = {
|
|
16
21
|
flex: Boolean(this.width) ? `0 0 ${this.width}` : "",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { h, Host } from "@stencil/core";
|
|
2
2
|
import classnames from "classnames";
|
|
3
|
+
import { closestPassShadow } from "../../utils";
|
|
3
4
|
/**
|
|
4
5
|
* @slot slot - The cells of this row.
|
|
5
6
|
*/
|
|
@@ -8,6 +9,10 @@ export class SwirlTableRow {
|
|
|
8
9
|
this.highlighted = undefined;
|
|
9
10
|
this.index = undefined;
|
|
10
11
|
}
|
|
12
|
+
componentDidLoad() {
|
|
13
|
+
const table = closestPassShadow(this.el, "swirl-table");
|
|
14
|
+
table === null || table === void 0 ? void 0 : table.rerender();
|
|
15
|
+
}
|
|
11
16
|
render() {
|
|
12
17
|
const className = classnames("table-row", {
|
|
13
18
|
"table-row--highlighted": this.highlighted,
|
|
@@ -64,4 +69,5 @@ export class SwirlTableRow {
|
|
|
64
69
|
}
|
|
65
70
|
};
|
|
66
71
|
}
|
|
72
|
+
static get elementRef() { return "el"; }
|
|
67
73
|
}
|