@zywave/zui-table 4.0.2-pre.1 → 4.0.2-pre.2
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/dist/base.d.ts +29 -0
- package/dist/base.js +67 -0
- package/dist/base.js.map +1 -0
- package/dist/css/zui-table.fouc.css +1 -1
- package/dist/custom-elements.json +192 -27
- package/dist/zui-table-cell-css.js +1 -1
- package/dist/zui-table-cell-css.js.map +1 -1
- package/dist/zui-table-cell.d.ts +27 -3
- package/dist/zui-table-cell.js +93 -6
- package/dist/zui-table-cell.js.map +1 -1
- package/dist/zui-table-css.js +1 -1
- package/dist/zui-table-css.js.map +1 -1
- package/dist/zui-table-footer.d.ts +6 -4
- package/dist/zui-table-footer.js +6 -4
- package/dist/zui-table-footer.js.map +1 -1
- package/dist/zui-table-row-css.js +1 -1
- package/dist/zui-table-row-css.js.map +1 -1
- package/dist/zui-table-row.d.ts +7 -4
- package/dist/zui-table-row.js +57 -11
- package/dist/zui-table-row.js.map +1 -1
- package/dist/zui-table-topbar-css.js +1 -1
- package/dist/zui-table-topbar-css.js.map +1 -1
- package/dist/zui-table-topbar.d.ts +12 -3
- package/dist/zui-table-topbar.js +105 -5
- package/dist/zui-table-topbar.js.map +1 -1
- package/dist/zui-table.d.ts +7 -5
- package/dist/zui-table.js +24 -10
- package/dist/zui-table.js.map +1 -1
- package/docs/customelement-manifest-element.html +28 -0
- package/{demo/index.html → docs/demo.html} +236 -42
- package/lab.html +347 -60
- package/package.json +9 -4
- package/src/base.ts +79 -0
- package/src/css/zui-table.fouc.scss +90 -17
- package/src/zui-table-cell-css.js +1 -1
- package/src/zui-table-cell.scss +26 -0
- package/src/zui-table-cell.ts +84 -6
- package/src/zui-table-css.js +1 -1
- package/src/zui-table-footer.ts +6 -4
- package/src/zui-table-row-css.js +1 -1
- package/src/zui-table-row.scss +11 -4
- package/src/zui-table-row.ts +51 -11
- package/src/zui-table-topbar-css.js +1 -1
- package/src/zui-table-topbar.scss +77 -9
- package/src/zui-table-topbar.ts +106 -5
- package/src/zui-table.scss +2 -2
- package/src/zui-table.ts +24 -9
- package/test/zui-table.test.ts +146 -4
package/dist/zui-table-cell.js
CHANGED
|
@@ -4,34 +4,121 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
13
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
14
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
15
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
16
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
17
|
+
};
|
|
18
|
+
var _ZuiTableCellElement_instances, _ZuiTableCellElement_sort, _ZuiTableCellElement_sortable, _ZuiTableCellElement_onSortableClick;
|
|
19
|
+
import { ZuiTableBaseElement } from './base.js';
|
|
20
|
+
import { html, nothing } from 'lit';
|
|
21
|
+
import { property, state } from 'lit/decorators.js';
|
|
22
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
10
23
|
import { style } from './zui-table-cell-css.js';
|
|
11
24
|
/**
|
|
25
|
+
* An individual table cell to be passed into a `<zui-table-row>`.
|
|
26
|
+
*
|
|
12
27
|
* @element zui-table-cell
|
|
13
28
|
*
|
|
14
|
-
* @slot -
|
|
29
|
+
* @slot - Unnamed slot, table cell content goes here
|
|
15
30
|
*
|
|
16
31
|
* @cssprop [--zui-table-cell-padding=13px 20px] - Override cell padding
|
|
32
|
+
* @cssprop [--zui-table-cell-sort-color=var(--zui-gray-300)] - ([sortable]): Default color of chevron when `direction` is `null`
|
|
33
|
+
* @cssprop [--zui-table-cell-sort-active-color=var(--zui-blue)] - Highlight color used to indicate the active sort direction
|
|
34
|
+
*
|
|
35
|
+
* @event sort - Event fires when a `sortable` cell is clicked
|
|
17
36
|
*/
|
|
18
|
-
export class ZuiTableCellElement extends
|
|
37
|
+
export class ZuiTableCellElement extends ZuiTableBaseElement {
|
|
19
38
|
constructor() {
|
|
20
39
|
super(...arguments);
|
|
40
|
+
_ZuiTableCellElement_instances.add(this);
|
|
21
41
|
/**
|
|
22
42
|
* Set to decrease table cell padding to accommodate action button(s)
|
|
23
43
|
*/
|
|
24
44
|
this.action = false;
|
|
45
|
+
/**
|
|
46
|
+
* This private field is needed to persist state between the cell and the header row. DO NOT USE EXTERNALLY
|
|
47
|
+
*/
|
|
48
|
+
this._isAllowedSort = false;
|
|
49
|
+
_ZuiTableCellElement_sort.set(this, null);
|
|
50
|
+
_ZuiTableCellElement_sortable.set(this, false);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Current sort direction of the sortable cell
|
|
54
|
+
* @type {null | "ascending" | "descending"}
|
|
55
|
+
*/
|
|
56
|
+
get sort() {
|
|
57
|
+
return __classPrivateFieldGet(this, _ZuiTableCellElement_sort, "f");
|
|
58
|
+
}
|
|
59
|
+
set sort(val) {
|
|
60
|
+
var _a;
|
|
61
|
+
const acceptableVals = ['ascending', 'descending', null];
|
|
62
|
+
if (acceptableVals.includes(val)) {
|
|
63
|
+
const oldVal = __classPrivateFieldGet(this, _ZuiTableCellElement_sort, "f");
|
|
64
|
+
__classPrivateFieldSet(this, _ZuiTableCellElement_sort, val, "f");
|
|
65
|
+
this.requestUpdate('sort', oldVal);
|
|
66
|
+
(_a = this._state) === null || _a === void 0 ? void 0 : _a.channel.dispatchEvent(new CustomEvent('sort', { detail: { sort: val, cell: this } }));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* (`zui-table-row[header]`): Whether or not cell header is sortable; another requirement is the parent element, `<zui-table-cell header>` must have `header` attribute or property set
|
|
71
|
+
*/
|
|
72
|
+
get sortable() {
|
|
73
|
+
return this._isAllowedSort && __classPrivateFieldGet(this, _ZuiTableCellElement_sortable, "f");
|
|
74
|
+
}
|
|
75
|
+
set sortable(val) {
|
|
76
|
+
const oldVal = __classPrivateFieldGet(this, _ZuiTableCellElement_sortable, "f");
|
|
77
|
+
__classPrivateFieldSet(this, _ZuiTableCellElement_sortable, val, "f");
|
|
78
|
+
this.requestUpdate('sortable', oldVal);
|
|
25
79
|
}
|
|
26
80
|
static get styles() {
|
|
27
81
|
return [super.styles, style];
|
|
28
82
|
}
|
|
29
83
|
render() {
|
|
30
|
-
|
|
84
|
+
const styles = { 'is-selectable': this.sortable };
|
|
85
|
+
return html `<div @click="${__classPrivateFieldGet(this, _ZuiTableCellElement_instances, "m", _ZuiTableCellElement_onSortableClick)}" class="${classMap(styles)}">
|
|
86
|
+
<slot></slot>
|
|
87
|
+
${this.sortable ? html `<zui-icon icon="zui-sort"></zui-icon>` : nothing}
|
|
88
|
+
</div>`;
|
|
89
|
+
}
|
|
90
|
+
click() {
|
|
91
|
+
super.click();
|
|
92
|
+
__classPrivateFieldGet(this, _ZuiTableCellElement_instances, "m", _ZuiTableCellElement_onSortableClick).call(this);
|
|
31
93
|
}
|
|
32
94
|
}
|
|
95
|
+
_ZuiTableCellElement_sort = new WeakMap(), _ZuiTableCellElement_sortable = new WeakMap(), _ZuiTableCellElement_instances = new WeakSet(), _ZuiTableCellElement_onSortableClick = function _ZuiTableCellElement_onSortableClick() {
|
|
96
|
+
if (this.sortable) {
|
|
97
|
+
switch (this.sort) {
|
|
98
|
+
case 'ascending':
|
|
99
|
+
this.sort = 'descending';
|
|
100
|
+
break;
|
|
101
|
+
case 'descending':
|
|
102
|
+
this.sort = null;
|
|
103
|
+
break;
|
|
104
|
+
case null:
|
|
105
|
+
default:
|
|
106
|
+
this.sort = 'ascending';
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
};
|
|
33
111
|
__decorate([
|
|
34
112
|
property({ type: Boolean, reflect: true })
|
|
35
113
|
], ZuiTableCellElement.prototype, "action", void 0);
|
|
114
|
+
__decorate([
|
|
115
|
+
property({ type: String, reflect: true })
|
|
116
|
+
], ZuiTableCellElement.prototype, "sort", null);
|
|
117
|
+
__decorate([
|
|
118
|
+
property({ type: Boolean, reflect: true })
|
|
119
|
+
], ZuiTableCellElement.prototype, "sortable", null);
|
|
120
|
+
__decorate([
|
|
121
|
+
state()
|
|
122
|
+
], ZuiTableCellElement.prototype, "_isAllowedSort", void 0);
|
|
36
123
|
window.customElements.define('zui-table-cell', ZuiTableCellElement);
|
|
37
124
|
//# sourceMappingURL=zui-table-cell.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zui-table-cell.js","sourceRoot":"","sources":["../src/zui-table-cell.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"zui-table-cell.js","sourceRoot":"","sources":["../src/zui-table-cell.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,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 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { style } from './zui-table-cell-css.js';\n\n/**\n * An individual table cell to be passed into a `<zui-table-row>`.\n *\n * @element zui-table-cell\n *\n * @slot - Unnamed slot, table cell content goes here\n *\n * @cssprop [--zui-table-cell-padding=13px 20px] - Override cell padding\n * @cssprop [--zui-table-cell-sort-color=var(--zui-gray-300)] - ([sortable]): Default color of chevron when `direction` is `null`\n * @cssprop [--zui-table-cell-sort-active-color=var(--zui-blue)] - Highlight color used to indicate the active sort direction\n *\n * @event sort - Event fires when a `sortable` cell is clicked\n */\nexport class ZuiTableCellElement extends ZuiTableBaseElement {\n /**\n * Set to decrease table cell padding to accommodate action button(s)\n */\n @property({ type: Boolean, reflect: true })\n action = false;\n\n /**\n * Current sort direction of the sortable cell\n * @type {null | \"ascending\" | \"descending\"}\n */\n @property({ type: String, reflect: true })\n get sort(): ZuiTableSortDirection {\n return this.#sort;\n }\n\n set sort(val: ZuiTableSortDirection) {\n const acceptableVals = ['ascending', 'descending', null];\n if (acceptableVals.includes(val)) {\n const oldVal = this.#sort;\n this.#sort = val;\n this.requestUpdate('sort', oldVal);\n this._state?.channel.dispatchEvent(new CustomEvent('sort', { detail: { sort: val, cell: this } }));\n }\n }\n\n /**\n * (`zui-table-row[header]`): Whether or not cell header is sortable; another requirement is the parent element, `<zui-table-cell header>` must have `header` attribute or property set\n */\n @property({ type: Boolean, reflect: true })\n get sortable() {\n return this._isAllowedSort && this.#sortable;\n }\n\n set sortable(val: boolean) {\n const oldVal = this.#sortable;\n this.#sortable = val;\n this.requestUpdate('sortable', oldVal);\n }\n\n /**\n * This private field is needed to persist state between the cell and the header row. DO NOT USE EXTERNALLY\n */\n @state()\n private _isAllowedSort = false;\n\n #sort: ZuiTableSortDirection = null;\n #sortable = false;\n\n static get styles() {\n return [super.styles, style];\n }\n\n render() {\n const styles = { 'is-selectable': this.sortable };\n return html`<div @click=\"${this.#onSortableClick}\" class=\"${classMap(styles)}\">\n <slot></slot>\n ${this.sortable ? html`<zui-icon icon=\"zui-sort\"></zui-icon>` : nothing}\n </div>`;\n }\n\n click() {\n super.click();\n\n this.#onSortableClick();\n }\n\n #onSortableClick() {\n if (this.sortable) {\n switch (this.sort) {\n case 'ascending':\n this.sort = 'descending';\n break;\n case 'descending':\n this.sort = null;\n break;\n case null:\n default:\n this.sort = 'ascending';\n break;\n }\n }\n }\n}\n\nwindow.customElements.define('zui-table-cell', ZuiTableCellElement);\n\nexport type ZuiTableSortDirection = null | 'ascending' | 'descending';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'zui-table-cell': ZuiTableCellElement;\n }\n}\n"]}
|
package/dist/zui-table-css.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const style = css `:host{contain:none;display:block}:host([banded]) ::slotted(zui-table-row:not([header]):nth-child(even)){background-color:var(--zui-gray-25)}:host([banded]) ::slotted(zui-table-row:not([header])){border:0}:host([no-results]) .no-results{padding:.75rem 1.25rem;background-color:#fff;box-shadow:0 1px 3px rgba(0,0,0,.29)}@media(min-width: 45em){:host([no-results]) .no-results{background-color:transparent;box-shadow:none}}::slotted(zui-table-row:not([header])){border-bottom:
|
|
2
|
+
export const style = css `:host{contain:none;display:block}:host([banded]) ::slotted(zui-table-row:not([header]):nth-child(even)){background-color:var(--zui-gray-25)}:host([banded]) ::slotted(zui-table-row:not([header])){border:0}:host([no-results]) .no-results{padding:.75rem 1.25rem;background-color:#fff;box-shadow:0 1px 3px rgba(0,0,0,.29)}@media(min-width: 45em){:host([no-results]) .no-results{background-color:transparent;box-shadow:none}}::slotted(zui-table-row:not([header])){border-bottom:2px solid var(--zui-gray-100)}@media(min-width: 45em){::slotted(zui-table-row:not([header])){border-bottom-width:1px}}::slotted(zui-table-row:not([header]):last-of-type){border-bottom:0}.table{display:flex;width:100%;flex-direction:column;border-collapse:collapse;border-spacing:0}@media(min-width: 45em){.table{background-color:#fff;box-shadow:0 1px 3px rgba(0,0,0,.29)}}`;
|
|
3
3
|
//# sourceMappingURL=zui-table-css.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zui-table-css.js","sourceRoot":"","sources":["../src/zui-table-css.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,KAAK,GAAG,GAAG,CAAA,+0BAA+0B,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport const style = css`:host{contain:none;display:block}:host([banded]) ::slotted(zui-table-row:not([header]):nth-child(even)){background-color:var(--zui-gray-25)}:host([banded]) ::slotted(zui-table-row:not([header])){border:0}:host([no-results]) .no-results{padding:.75rem 1.25rem;background-color:#fff;box-shadow:0 1px 3px rgba(0,0,0,.29)}@media(min-width: 45em){:host([no-results]) .no-results{background-color:transparent;box-shadow:none}}::slotted(zui-table-row:not([header])){border-bottom:
|
|
1
|
+
{"version":3,"file":"zui-table-css.js","sourceRoot":"","sources":["../src/zui-table-css.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,KAAK,GAAG,GAAG,CAAA,+0BAA+0B,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport const style = css`:host{contain:none;display:block}:host([banded]) ::slotted(zui-table-row:not([header]):nth-child(even)){background-color:var(--zui-gray-25)}:host([banded]) ::slotted(zui-table-row:not([header])){border:0}:host([no-results]) .no-results{padding:.75rem 1.25rem;background-color:#fff;box-shadow:0 1px 3px rgba(0,0,0,.29)}@media(min-width: 45em){:host([no-results]) .no-results{background-color:transparent;box-shadow:none}}::slotted(zui-table-row:not([header])){border-bottom:2px solid var(--zui-gray-100)}@media(min-width: 45em){::slotted(zui-table-row:not([header])){border-bottom-width:1px}}::slotted(zui-table-row:not([header]):last-of-type){border-bottom:0}.table{display:flex;width:100%;flex-direction:column;border-collapse:collapse;border-spacing:0}@media(min-width: 45em){.table{background-color:#fff;box-shadow:0 1px 3px rgba(0,0,0,.29)}}`;\n"]}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ZuiTableBaseElement } from './base.js';
|
|
2
2
|
/**
|
|
3
|
+
* Footer table element, should come as the last item passed into a `<zui-table>`.
|
|
4
|
+
*
|
|
3
5
|
* @element zui-table-footer
|
|
4
6
|
*
|
|
5
|
-
* @slot -
|
|
7
|
+
* @slot - Unnamed slot, table footer content goes here
|
|
6
8
|
*
|
|
7
|
-
* @cssprop [--zui-table-footer-margin=10px] - Override the margin between the table and footer of the table
|
|
9
|
+
* @cssprop [--zui-table-footer-margin=0.625rem (10px)] - Override the margin between the table and footer of the table
|
|
8
10
|
*/
|
|
9
|
-
export declare class ZuiTableFooterElement extends
|
|
11
|
+
export declare class ZuiTableFooterElement extends ZuiTableBaseElement {
|
|
10
12
|
static get styles(): import("lit").CSSResultGroup[];
|
|
11
13
|
render(): import("lit-html").TemplateResult<1>;
|
|
12
14
|
}
|
package/dist/zui-table-footer.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ZuiTableBaseElement } from './base.js';
|
|
2
2
|
import { html } from 'lit';
|
|
3
3
|
import { style } from './zui-table-footer-css.js';
|
|
4
4
|
/**
|
|
5
|
+
* Footer table element, should come as the last item passed into a `<zui-table>`.
|
|
6
|
+
*
|
|
5
7
|
* @element zui-table-footer
|
|
6
8
|
*
|
|
7
|
-
* @slot -
|
|
9
|
+
* @slot - Unnamed slot, table footer content goes here
|
|
8
10
|
*
|
|
9
|
-
* @cssprop [--zui-table-footer-margin=10px] - Override the margin between the table and footer of the table
|
|
11
|
+
* @cssprop [--zui-table-footer-margin=0.625rem (10px)] - Override the margin between the table and footer of the table
|
|
10
12
|
*/
|
|
11
|
-
export class ZuiTableFooterElement extends
|
|
13
|
+
export class ZuiTableFooterElement extends ZuiTableBaseElement {
|
|
12
14
|
static get styles() {
|
|
13
15
|
return [super.styles, style];
|
|
14
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zui-table-footer.js","sourceRoot":"","sources":["../src/zui-table-footer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"zui-table-footer.js","sourceRoot":"","sources":["../src/zui-table-footer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAElD;;;;;;;;GAQG;AACH,MAAM,OAAO,qBAAsB,SAAQ,mBAAmB;IAC5D,MAAM,KAAK,MAAM;QACf,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC/B,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAA;;WAEJ,CAAC;IACV,CAAC;CACF;AAED,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,CAAC","sourcesContent":["import { ZuiTableBaseElement } from './base.js';\nimport { html } from 'lit';\nimport { style } from './zui-table-footer-css.js';\n\n/**\n * Footer table element, should come as the last item passed into a `<zui-table>`.\n *\n * @element zui-table-footer\n *\n * @slot - Unnamed slot, table footer content goes here\n *\n * @cssprop [--zui-table-footer-margin=0.625rem (10px)] - Override the margin between the table and footer of the table\n */\nexport class ZuiTableFooterElement extends ZuiTableBaseElement {\n static get styles() {\n return [super.styles, style];\n }\n\n render() {\n return html`<div class=\"footer\">\n <slot></slot>\n </div>`;\n }\n}\n\nwindow.customElements.define('zui-table-footer', ZuiTableFooterElement);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'zui-table-footer': ZuiTableFooterElement;\n }\n}\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const style = css `:host{contain:none}:host(:last-of-type:not([summary])) div,:host([summary]) div{margin-bottom:0}:host([header]){display:none;background-color:#fff;border-bottom:1px solid var(--zui-gray-200)}:host([header]) ::slotted(zui-table-cell){--zui-table-cell-padding: 0.53125rem 1.25rem;font-weight:600
|
|
2
|
+
export const style = css `:host{contain:none}:host(:last-of-type:not([summary])) div,:host([summary]) div{margin-bottom:0}:host([header]){display:none;background-color:#fff;border-bottom:1px solid var(--zui-gray-200)}@media(min-width: 45em){:host([header]){display:block}}:host([header]) div{box-shadow:none}:host([header]) ::slotted(zui-table-cell){--zui-table-cell-padding: 0.53125rem 1.25rem;font-weight:600;user-select:none}div{display:grid;grid-template-columns:auto;margin-bottom:0;padding:.625rem 0;background-color:#fff;box-shadow:0 1px 3px rgba(0,0,0,.29)}@media(min-width: 45em){div{grid-template-columns:var(--zui-table-columns-template, repeat(auto-fit, minmax(0, 1fr)));padding:0;background-color:transparent;box-shadow:none}}:host([summary]){background-color:var(--zui-table-summary-background-color, var(--zui-gray-600)) !important}:host([summary]) div{margin-bottom:0;background-color:transparent}:host([summary]) ::slotted(zui-table-cell){font-weight:600;color:var(--zui-table-summary-text-color, #fff)}`;
|
|
3
3
|
//# sourceMappingURL=zui-table-row-css.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zui-table-row-css.js","sourceRoot":"","sources":["../src/zui-table-row-css.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,KAAK,GAAG,GAAG,CAAA,
|
|
1
|
+
{"version":3,"file":"zui-table-row-css.js","sourceRoot":"","sources":["../src/zui-table-row-css.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,KAAK,GAAG,GAAG,CAAA,o+BAAo+B,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport const style = css`:host{contain:none}:host(:last-of-type:not([summary])) div,:host([summary]) div{margin-bottom:0}:host([header]){display:none;background-color:#fff;border-bottom:1px solid var(--zui-gray-200)}@media(min-width: 45em){:host([header]){display:block}}:host([header]) div{box-shadow:none}:host([header]) ::slotted(zui-table-cell){--zui-table-cell-padding: 0.53125rem 1.25rem;font-weight:600;user-select:none}div{display:grid;grid-template-columns:auto;margin-bottom:0;padding:.625rem 0;background-color:#fff;box-shadow:0 1px 3px rgba(0,0,0,.29)}@media(min-width: 45em){div{grid-template-columns:var(--zui-table-columns-template, repeat(auto-fit, minmax(0, 1fr)));padding:0;background-color:transparent;box-shadow:none}}:host([summary]){background-color:var(--zui-table-summary-background-color, var(--zui-gray-600)) !important}:host([summary]) div{margin-bottom:0;background-color:transparent}:host([summary]) ::slotted(zui-table-cell){font-weight:600;color:var(--zui-table-summary-text-color, #fff)}`;\n"]}
|
package/dist/zui-table-row.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ZuiTableBaseElement } from './base.js';
|
|
2
2
|
/**
|
|
3
|
+
* Pass into `<zui-table>`, `<zui-table-row>` holds a row of `<zui-table-cell>`'s.
|
|
4
|
+
*
|
|
3
5
|
* @element zui-table-row
|
|
4
6
|
*
|
|
5
|
-
* @slot -
|
|
7
|
+
* @slot - Unnamed slot, `<zui-table-cell>`s are declared here
|
|
6
8
|
*
|
|
7
|
-
* @cssprop [--zui-table-columns-template=repeat(auto-fit, minmax(0, 1fr))] - Override the table columns template. See
|
|
9
|
+
* @cssprop [--zui-table-columns-template=repeat(auto-fit, minmax(0, 1fr))] - Override the table columns template. See https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns for more information on valid values.
|
|
8
10
|
* @cssprop [--zui-table-summary-background-color=var(--zui-gray-600)] - Override the table summary background color
|
|
9
11
|
* @cssprop [--zui-table-summary-text-color=#fff] - Override the table summary text color
|
|
10
12
|
*/
|
|
11
|
-
export declare class ZuiTableRowElement extends
|
|
13
|
+
export declare class ZuiTableRowElement extends ZuiTableBaseElement {
|
|
12
14
|
#private;
|
|
13
15
|
/**
|
|
14
16
|
* Declare a table header; typically the first row in `<zui-table>`
|
|
@@ -22,6 +24,7 @@ export declare class ZuiTableRowElement extends ZuiBaseElement {
|
|
|
22
24
|
static get styles(): import("lit").CSSResultGroup[];
|
|
23
25
|
connectedCallback(): void;
|
|
24
26
|
firstUpdated(): void;
|
|
27
|
+
updated(changedProperties: Map<string | number | symbol, unknown>): void;
|
|
25
28
|
render(): import("lit-html").TemplateResult<1>;
|
|
26
29
|
}
|
|
27
30
|
declare global {
|
package/dist/zui-table-row.js
CHANGED
|
@@ -9,21 +9,29 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var
|
|
13
|
-
|
|
12
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
13
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
14
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
15
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
16
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
17
|
+
};
|
|
18
|
+
var _ZuiTableRowElement_instances, _ZuiTableRowElement_sortLock, _ZuiTableRowElement_onTableSort, _ZuiTableRowElement_ensureCellState;
|
|
19
|
+
import { ZuiTableBaseElement } from './base.js';
|
|
14
20
|
import { html } from 'lit';
|
|
15
21
|
import { property, queryAssignedElements } from 'lit/decorators.js';
|
|
16
22
|
import { style } from './zui-table-row-css.js';
|
|
17
23
|
/**
|
|
24
|
+
* Pass into `<zui-table>`, `<zui-table-row>` holds a row of `<zui-table-cell>`'s.
|
|
25
|
+
*
|
|
18
26
|
* @element zui-table-row
|
|
19
27
|
*
|
|
20
|
-
* @slot -
|
|
28
|
+
* @slot - Unnamed slot, `<zui-table-cell>`s are declared here
|
|
21
29
|
*
|
|
22
|
-
* @cssprop [--zui-table-columns-template=repeat(auto-fit, minmax(0, 1fr))] - Override the table columns template. See
|
|
30
|
+
* @cssprop [--zui-table-columns-template=repeat(auto-fit, minmax(0, 1fr))] - Override the table columns template. See https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns for more information on valid values.
|
|
23
31
|
* @cssprop [--zui-table-summary-background-color=var(--zui-gray-600)] - Override the table summary background color
|
|
24
32
|
* @cssprop [--zui-table-summary-text-color=#fff] - Override the table summary text color
|
|
25
33
|
*/
|
|
26
|
-
export class ZuiTableRowElement extends
|
|
34
|
+
export class ZuiTableRowElement extends ZuiTableBaseElement {
|
|
27
35
|
constructor() {
|
|
28
36
|
super(...arguments);
|
|
29
37
|
_ZuiTableRowElement_instances.add(this);
|
|
@@ -35,6 +43,7 @@ export class ZuiTableRowElement extends ZuiBaseElement {
|
|
|
35
43
|
* Declare a table summary row; typically the last row in `<zui-table>` before `<zui-table-footer>`
|
|
36
44
|
*/
|
|
37
45
|
this.summary = false;
|
|
46
|
+
_ZuiTableRowElement_sortLock.set(this, void 0);
|
|
38
47
|
}
|
|
39
48
|
static get styles() {
|
|
40
49
|
return [super.styles, style];
|
|
@@ -44,25 +53,62 @@ export class ZuiTableRowElement extends ZuiBaseElement {
|
|
|
44
53
|
this.setAttribute('role', 'row');
|
|
45
54
|
}
|
|
46
55
|
firstUpdated() {
|
|
47
|
-
|
|
56
|
+
var _a;
|
|
57
|
+
if (this.header) {
|
|
58
|
+
const firstCellWithDirection = (_a = this._slottedCells) === null || _a === void 0 ? void 0 : _a.find((cell) => cell === null || cell === void 0 ? void 0 : cell.hasAttribute('sort'));
|
|
59
|
+
this._slottedCells.forEach((cell) => {
|
|
60
|
+
if (cell.sort && cell !== firstCellWithDirection) {
|
|
61
|
+
cell.sort = null;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
updated(changedProperties) {
|
|
67
|
+
var _a;
|
|
68
|
+
super.updated(changedProperties);
|
|
69
|
+
if (changedProperties.has('header')) {
|
|
70
|
+
__classPrivateFieldGet(this, _ZuiTableRowElement_instances, "m", _ZuiTableRowElement_ensureCellState).call(this);
|
|
71
|
+
if (this.header) {
|
|
72
|
+
(_a = this._state) === null || _a === void 0 ? void 0 : _a.channel.addEventListener('sort', (e) => __classPrivateFieldGet(this, _ZuiTableRowElement_instances, "m", _ZuiTableRowElement_onTableSort).call(this, e));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
48
75
|
}
|
|
49
76
|
render() {
|
|
50
77
|
return html `<div>
|
|
51
|
-
<slot @slotchange="${__classPrivateFieldGet(this, _ZuiTableRowElement_instances, "m",
|
|
78
|
+
<slot @slotchange="${__classPrivateFieldGet(this, _ZuiTableRowElement_instances, "m", _ZuiTableRowElement_ensureCellState).call(this)}"></slot>
|
|
52
79
|
</div>`;
|
|
53
80
|
}
|
|
54
81
|
}
|
|
55
|
-
_ZuiTableRowElement_instances = new WeakSet(),
|
|
82
|
+
_ZuiTableRowElement_sortLock = new WeakMap(), _ZuiTableRowElement_instances = new WeakSet(), _ZuiTableRowElement_onTableSort = function _ZuiTableRowElement_onTableSort(event) {
|
|
83
|
+
var _a;
|
|
84
|
+
if (__classPrivateFieldGet(this, _ZuiTableRowElement_sortLock, "f")) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
__classPrivateFieldSet(this, _ZuiTableRowElement_sortLock, true, "f");
|
|
88
|
+
(_a = this._slottedCells) === null || _a === void 0 ? void 0 : _a.forEach((cell) => {
|
|
89
|
+
if (cell !== event.detail.cell) {
|
|
90
|
+
cell.sort = null;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
setTimeout(() => {
|
|
94
|
+
__classPrivateFieldSet(this, _ZuiTableRowElement_sortLock, false, "f");
|
|
95
|
+
}, 0);
|
|
96
|
+
}, _ZuiTableRowElement_ensureCellState = function _ZuiTableRowElement_ensureCellState() {
|
|
56
97
|
if (!this._slottedCells) {
|
|
57
98
|
return;
|
|
58
99
|
}
|
|
59
100
|
if (this.header) {
|
|
60
|
-
this._slottedCells.
|
|
101
|
+
this._slottedCells.forEach((cell) => {
|
|
102
|
+
cell.setAttribute('role', 'columnheader');
|
|
103
|
+
cell._isAllowedSort = true;
|
|
104
|
+
});
|
|
61
105
|
}
|
|
62
106
|
else {
|
|
63
|
-
this._slottedCells.
|
|
107
|
+
this._slottedCells.forEach((cell) => {
|
|
108
|
+
cell.setAttribute('role', 'cell');
|
|
109
|
+
cell._isAllowedSort = false;
|
|
110
|
+
});
|
|
64
111
|
}
|
|
65
|
-
this.requestUpdate();
|
|
66
112
|
};
|
|
67
113
|
__decorate([
|
|
68
114
|
property({ type: Boolean, reflect: true })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zui-table-row.js","sourceRoot":"","sources":["../src/zui-table-row.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"zui-table-row.js","sourceRoot":"","sources":["../src/zui-table-row.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAG/C;;;;;;;;;;GAUG;AACH,MAAM,OAAO,kBAAmB,SAAQ,mBAAmB;IAA3D;;;QACE;;WAEG;QAEH,WAAM,GAAG,KAAK,CAAC;QAEf;;WAEG;QAEH,YAAO,GAAG,KAAK,CAAC;QAKhB,+CAAoB;IAsEtB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AAkB,CAAC,CAAC","sourcesContent":["import { ZuiTableBaseElement } from './base.js';\nimport { html } from 'lit';\nimport { property, queryAssignedElements } from 'lit/decorators.js';\nimport { style } from './zui-table-row-css.js';\nimport type { ZuiTableCellElement } from './zui-table-cell.js';\n\n/**\n * Pass into `<zui-table>`, `<zui-table-row>` holds a row of `<zui-table-cell>`'s.\n *\n * @element zui-table-row\n *\n * @slot - Unnamed slot, `<zui-table-cell>`s are declared here\n *\n * @cssprop [--zui-table-columns-template=repeat(auto-fit, minmax(0, 1fr))] - Override the table columns template. See https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns for more information on valid values.\n * @cssprop [--zui-table-summary-background-color=var(--zui-gray-600)] - Override the table summary background color\n * @cssprop [--zui-table-summary-text-color=#fff] - Override the table summary text color\n */\nexport class ZuiTableRowElement extends ZuiTableBaseElement {\n /**\n * Declare a table header; typically the first row in `<zui-table>`\n */\n @property({ type: Boolean, reflect: true })\n header = false;\n\n /**\n * Declare a table summary row; typically the last row in `<zui-table>` before `<zui-table-footer>`\n */\n @property({ type: Boolean, reflect: true })\n summary = false;\n\n @queryAssignedElements({ selector: 'zui-table-cell' })\n private _slottedCells: Array<ZuiTableCellElement>;\n\n #sortLock?: boolean;\n\n static get styles() {\n return [super.styles, style];\n }\n\n connectedCallback() {\n super.connectedCallback();\n this.setAttribute('role', 'row');\n }\n\n firstUpdated() {\n if (this.header) {\n const firstCellWithDirection = this._slottedCells?.find((cell) => cell?.hasAttribute('sort'));\n this._slottedCells.forEach((cell) => {\n if (cell.sort && cell !== firstCellWithDirection) {\n cell.sort = null;\n }\n });\n }\n }\n\n updated(changedProperties: Map<string | number | symbol, unknown>) {\n super.updated(changedProperties);\n if (changedProperties.has('header')) {\n this.#ensureCellState();\n if (this.header) {\n this._state?.channel.addEventListener('sort', (e: CustomEvent<{ cell: HTMLElement }>) => this.#onTableSort(e));\n }\n }\n }\n\n render() {\n return html`<div>\n <slot @slotchange=\"${this.#ensureCellState()}\"></slot>\n </div>`;\n }\n\n #onTableSort(event: CustomEvent<{ cell: HTMLElement }>) {\n if (this.#sortLock) {\n return;\n }\n this.#sortLock = true;\n this._slottedCells?.forEach((cell) => {\n if (cell !== event.detail.cell) {\n cell.sort = null;\n }\n });\n setTimeout(() => {\n this.#sortLock = false;\n }, 0);\n }\n\n #ensureCellState() {\n if (!this._slottedCells) {\n return;\n }\n\n if (this.header) {\n this._slottedCells.forEach((cell) => {\n cell.setAttribute('role', 'columnheader');\n (cell as any)._isAllowedSort = true;\n });\n } else {\n this._slottedCells.forEach((cell) => {\n cell.setAttribute('role', 'cell');\n (cell as any)._isAllowedSort = false;\n });\n }\n }\n}\n\nwindow.customElements.define('zui-table-row', ZuiTableRowElement);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'zui-table-row': ZuiTableRowElement;\n }\n}\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const style = css `:host{contain:none}.topbar{display:flex;width:100%;min-height:3.75rem;align-items:center;padding:.625rem 1.25rem;background-color:var(--zui-gray-25);box-shadow:
|
|
2
|
+
export const style = css `:host{contain:none}.topbar{display:flex;width:100%;min-height:3.75rem;flex-wrap:wrap;justify-content:space-between;align-items:center}@media(min-width: 45em){.topbar{flex-wrap:nowrap;padding:.625rem 1.25rem;background-color:var(--zui-gray-25);box-shadow:none}}.content{display:flex;flex:1;align-items:center;order:1;margin-bottom:1.25rem}@media(min-width: 30em){.content{flex:auto;order:0}}@media(min-width: 45em){.content{margin-bottom:0}}.content ::slotted(zui-search){--zui-search-border-color: var(--zui-gray-50);width:100%}@media(min-width: 45em){.content ::slotted(zui-search){width:auto}}.counter{display:flex;width:100%;flex-shrink:0;justify-content:flex-end;order:2;margin-bottom:.625rem;margin-left:auto;padding-left:.625rem;font-size:.75rem;color:var(--zui-gray-400)}@media(min-width: 45em){.counter{width:auto;margin-bottom:0}}.action{display:flex;width:100%;justify-content:flex-end;margin-bottom:1.25rem}@media(min-width: 30em){.action{width:auto}}@media(min-width: 45em){.action{margin-bottom:0}}.action slot[name=action]{display:flex;width:100%;flex-direction:column}@media(min-width: 30em){.action slot[name=action]{flex-direction:row}}.action ::slotted(zui-button){width:100%}@media(min-width: 30em){.action ::slotted(zui-button){width:auto}}@media(min-width: 30em){.action ::slotted(zui-button:first-of-type){margin-left:1.25rem}}@media(min-width: 45em){.action ::slotted(zui-button:first-of-type){margin-left:.625rem}}.action ::slotted(zui-button:not(:first-of-type)){margin-top:.625rem}@media(min-width: 30em){.action ::slotted(zui-button:not(:first-of-type)){margin-top:0;margin-left:.625rem}}`;
|
|
3
3
|
//# sourceMappingURL=zui-table-topbar-css.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zui-table-topbar-css.js","sourceRoot":"","sources":["../src/zui-table-topbar-css.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,KAAK,GAAG,GAAG,CAAA,
|
|
1
|
+
{"version":3,"file":"zui-table-topbar-css.js","sourceRoot":"","sources":["../src/zui-table-topbar-css.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,KAAK,GAAG,GAAG,CAAA,ilDAAilD,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport const style = css`:host{contain:none}.topbar{display:flex;width:100%;min-height:3.75rem;flex-wrap:wrap;justify-content:space-between;align-items:center}@media(min-width: 45em){.topbar{flex-wrap:nowrap;padding:.625rem 1.25rem;background-color:var(--zui-gray-25);box-shadow:none}}.content{display:flex;flex:1;align-items:center;order:1;margin-bottom:1.25rem}@media(min-width: 30em){.content{flex:auto;order:0}}@media(min-width: 45em){.content{margin-bottom:0}}.content ::slotted(zui-search){--zui-search-border-color: var(--zui-gray-50);width:100%}@media(min-width: 45em){.content ::slotted(zui-search){width:auto}}.counter{display:flex;width:100%;flex-shrink:0;justify-content:flex-end;order:2;margin-bottom:.625rem;margin-left:auto;padding-left:.625rem;font-size:.75rem;color:var(--zui-gray-400)}@media(min-width: 45em){.counter{width:auto;margin-bottom:0}}.action{display:flex;width:100%;justify-content:flex-end;margin-bottom:1.25rem}@media(min-width: 30em){.action{width:auto}}@media(min-width: 45em){.action{margin-bottom:0}}.action slot[name=action]{display:flex;width:100%;flex-direction:column}@media(min-width: 30em){.action slot[name=action]{flex-direction:row}}.action ::slotted(zui-button){width:100%}@media(min-width: 30em){.action ::slotted(zui-button){width:auto}}@media(min-width: 30em){.action ::slotted(zui-button:first-of-type){margin-left:1.25rem}}@media(min-width: 45em){.action ::slotted(zui-button:first-of-type){margin-left:.625rem}}.action ::slotted(zui-button:not(:first-of-type)){margin-top:.625rem}@media(min-width: 30em){.action ::slotted(zui-button:not(:first-of-type)){margin-top:0;margin-left:.625rem}}`;\n"]}
|
|
@@ -1,13 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ZuiTableBaseElement } from './base.js';
|
|
2
2
|
/**
|
|
3
|
+
* Used to house table related pieces such as a search input or `zui-search`, and other up front information.
|
|
4
|
+
*
|
|
3
5
|
* @element zui-table-topbar
|
|
4
6
|
*
|
|
5
|
-
* @slot -
|
|
7
|
+
* @slot - Unnamed slot, table cell content goes here
|
|
6
8
|
* @slot counter - Total number of results from table goes here
|
|
7
9
|
* @slot action - Action(s) that affect the whole table goes here
|
|
8
10
|
*/
|
|
9
|
-
export declare class ZuiTableTopbarElement extends
|
|
11
|
+
export declare class ZuiTableTopbarElement extends ZuiTableBaseElement {
|
|
12
|
+
#private;
|
|
13
|
+
private _actionSlottedElements;
|
|
14
|
+
private _counterSlottedNodes;
|
|
15
|
+
private _actionButtons;
|
|
10
16
|
static get styles(): import("lit").CSSResultGroup[];
|
|
17
|
+
connectedCallback(): void;
|
|
18
|
+
disconnectedCallback(): void;
|
|
19
|
+
firstUpdated(): void;
|
|
11
20
|
render(): import("lit-html").TemplateResult<1>;
|
|
12
21
|
}
|
|
13
22
|
declare global {
|
package/dist/zui-table-topbar.js
CHANGED
|
@@ -1,24 +1,124 @@
|
|
|
1
|
-
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _ZuiTableTopbarElement_instances, _ZuiTableTopbarElement_mobileBreakpoint, _ZuiTableTopbarElement_mobileTopbarActionButtonsEvent, _ZuiTableTopbarElement_addBlockStylingToButtons, _ZuiTableTopbarElement_removeBlockStylingFromButtons, _ZuiTableTopbarElement_toggleCounterDivDisplay, _ZuiTableTopbarElement_toggleActionDivDisplay;
|
|
13
|
+
import { ZuiTableBaseElement } from './base.js';
|
|
2
14
|
import { html } from 'lit';
|
|
15
|
+
import { queryAssignedElements, queryAssignedNodes } from 'lit/decorators.js';
|
|
3
16
|
import { style } from './zui-table-topbar-css.js';
|
|
17
|
+
import { screenBreakpoints } from '@zywave/zui-base/dist/utils/breakpoints';
|
|
4
18
|
/**
|
|
19
|
+
* Used to house table related pieces such as a search input or `zui-search`, and other up front information.
|
|
20
|
+
*
|
|
5
21
|
* @element zui-table-topbar
|
|
6
22
|
*
|
|
7
|
-
* @slot -
|
|
23
|
+
* @slot - Unnamed slot, table cell content goes here
|
|
8
24
|
* @slot counter - Total number of results from table goes here
|
|
9
25
|
* @slot action - Action(s) that affect the whole table goes here
|
|
10
26
|
*/
|
|
11
|
-
export class ZuiTableTopbarElement extends
|
|
27
|
+
export class ZuiTableTopbarElement extends ZuiTableBaseElement {
|
|
28
|
+
constructor() {
|
|
29
|
+
super(...arguments);
|
|
30
|
+
_ZuiTableTopbarElement_instances.add(this);
|
|
31
|
+
_ZuiTableTopbarElement_mobileBreakpoint.set(this, window.matchMedia(`only screen and (max-width: ${screenBreakpoints.xsmall})`));
|
|
32
|
+
_ZuiTableTopbarElement_mobileTopbarActionButtonsEvent.set(this, (b) => {
|
|
33
|
+
b.matches ? __classPrivateFieldGet(this, _ZuiTableTopbarElement_instances, "m", _ZuiTableTopbarElement_addBlockStylingToButtons).call(this) : __classPrivateFieldGet(this, _ZuiTableTopbarElement_instances, "m", _ZuiTableTopbarElement_removeBlockStylingFromButtons).call(this);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
12
36
|
static get styles() {
|
|
13
37
|
return [super.styles, style];
|
|
14
38
|
}
|
|
39
|
+
connectedCallback() {
|
|
40
|
+
super.connectedCallback();
|
|
41
|
+
if (__classPrivateFieldGet(this, _ZuiTableTopbarElement_mobileBreakpoint, "f").addEventListener) {
|
|
42
|
+
__classPrivateFieldGet(this, _ZuiTableTopbarElement_mobileBreakpoint, "f").addEventListener('change', __classPrivateFieldGet(this, _ZuiTableTopbarElement_mobileTopbarActionButtonsEvent, "f"));
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
__classPrivateFieldGet(this, _ZuiTableTopbarElement_mobileBreakpoint, "f").addListener(__classPrivateFieldGet(this, _ZuiTableTopbarElement_mobileTopbarActionButtonsEvent, "f"));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
disconnectedCallback() {
|
|
49
|
+
super.disconnectedCallback();
|
|
50
|
+
if (__classPrivateFieldGet(this, _ZuiTableTopbarElement_mobileBreakpoint, "f").addEventListener) {
|
|
51
|
+
__classPrivateFieldGet(this, _ZuiTableTopbarElement_mobileBreakpoint, "f").removeEventListener('change', __classPrivateFieldGet(this, _ZuiTableTopbarElement_mobileTopbarActionButtonsEvent, "f"));
|
|
52
|
+
}
|
|
53
|
+
else if (__classPrivateFieldGet(this, _ZuiTableTopbarElement_mobileBreakpoint, "f").addListener) {
|
|
54
|
+
__classPrivateFieldGet(this, _ZuiTableTopbarElement_mobileBreakpoint, "f").removeListener(__classPrivateFieldGet(this, _ZuiTableTopbarElement_mobileTopbarActionButtonsEvent, "f"));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
firstUpdated() {
|
|
58
|
+
__classPrivateFieldGet(this, _ZuiTableTopbarElement_mobileBreakpoint, "f").matches ? __classPrivateFieldGet(this, _ZuiTableTopbarElement_instances, "m", _ZuiTableTopbarElement_addBlockStylingToButtons).call(this) : __classPrivateFieldGet(this, _ZuiTableTopbarElement_instances, "m", _ZuiTableTopbarElement_removeBlockStylingFromButtons).call(this);
|
|
59
|
+
__classPrivateFieldGet(this, _ZuiTableTopbarElement_instances, "m", _ZuiTableTopbarElement_toggleActionDivDisplay).call(this);
|
|
60
|
+
__classPrivateFieldGet(this, _ZuiTableTopbarElement_instances, "m", _ZuiTableTopbarElement_toggleCounterDivDisplay).call(this);
|
|
61
|
+
}
|
|
15
62
|
render() {
|
|
16
63
|
return html `<div class="topbar">
|
|
17
64
|
<div class="content"><slot></slot></div>
|
|
18
|
-
<div class="counter"><slot name="counter"></slot></div>
|
|
19
|
-
<div class="action"
|
|
65
|
+
<div class="counter"><slot name="counter" @slotchange="${__classPrivateFieldGet(this, _ZuiTableTopbarElement_instances, "m", _ZuiTableTopbarElement_toggleCounterDivDisplay)}"></slot></div>
|
|
66
|
+
<div class="action"
|
|
67
|
+
><slot
|
|
68
|
+
name="action"
|
|
69
|
+
@slotchange="${__classPrivateFieldGet(this, _ZuiTableTopbarElement_instances, "m", _ZuiTableTopbarElement_toggleActionDivDisplay)} ${__classPrivateFieldGet(this, _ZuiTableTopbarElement_mobileBreakpoint, "f").matches
|
|
70
|
+
? __classPrivateFieldGet(this, _ZuiTableTopbarElement_instances, "m", _ZuiTableTopbarElement_addBlockStylingToButtons)
|
|
71
|
+
: __classPrivateFieldGet(this, _ZuiTableTopbarElement_instances, "m", _ZuiTableTopbarElement_removeBlockStylingFromButtons)}"
|
|
72
|
+
></slot
|
|
73
|
+
></div>
|
|
20
74
|
</div>`;
|
|
21
75
|
}
|
|
22
76
|
}
|
|
77
|
+
_ZuiTableTopbarElement_mobileBreakpoint = new WeakMap(), _ZuiTableTopbarElement_mobileTopbarActionButtonsEvent = new WeakMap(), _ZuiTableTopbarElement_instances = new WeakSet(), _ZuiTableTopbarElement_addBlockStylingToButtons = function _ZuiTableTopbarElement_addBlockStylingToButtons() {
|
|
78
|
+
if (this._actionButtons.length > 0) {
|
|
79
|
+
for (const button of this._actionButtons) {
|
|
80
|
+
if (!button.hasAttribute('block')) {
|
|
81
|
+
button.setAttribute('block', '');
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
this.requestUpdate();
|
|
86
|
+
}, _ZuiTableTopbarElement_removeBlockStylingFromButtons = function _ZuiTableTopbarElement_removeBlockStylingFromButtons() {
|
|
87
|
+
if (this._actionButtons.length > 0) {
|
|
88
|
+
for (const button of this._actionButtons) {
|
|
89
|
+
if (button.hasAttribute('block')) {
|
|
90
|
+
button.removeAttribute('block');
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
this.requestUpdate();
|
|
95
|
+
}, _ZuiTableTopbarElement_toggleCounterDivDisplay = function _ZuiTableTopbarElement_toggleCounterDivDisplay() {
|
|
96
|
+
const counter = this.shadowRoot.querySelector('.counter');
|
|
97
|
+
if (this._counterSlottedNodes.length === 0) {
|
|
98
|
+
counter.style.display = 'none';
|
|
99
|
+
}
|
|
100
|
+
else if (this._counterSlottedNodes.length > 0 && counter.style.display === 'none') {
|
|
101
|
+
counter.style.removeProperty('display');
|
|
102
|
+
}
|
|
103
|
+
this.requestUpdate();
|
|
104
|
+
}, _ZuiTableTopbarElement_toggleActionDivDisplay = function _ZuiTableTopbarElement_toggleActionDivDisplay() {
|
|
105
|
+
const action = this.shadowRoot.querySelector('.action');
|
|
106
|
+
if (this._actionSlottedElements.length === 0) {
|
|
107
|
+
action.style.display = 'none';
|
|
108
|
+
}
|
|
109
|
+
else if (this._actionSlottedElements.length > 0 && action.style.display === 'none') {
|
|
110
|
+
action.style.removeProperty('display');
|
|
111
|
+
}
|
|
112
|
+
this.requestUpdate();
|
|
113
|
+
};
|
|
114
|
+
__decorate([
|
|
115
|
+
queryAssignedElements({ slot: 'action' })
|
|
116
|
+
], ZuiTableTopbarElement.prototype, "_actionSlottedElements", void 0);
|
|
117
|
+
__decorate([
|
|
118
|
+
queryAssignedNodes({ slot: 'counter' })
|
|
119
|
+
], ZuiTableTopbarElement.prototype, "_counterSlottedNodes", void 0);
|
|
120
|
+
__decorate([
|
|
121
|
+
queryAssignedElements({ selector: 'zui-button', slot: 'action' })
|
|
122
|
+
], ZuiTableTopbarElement.prototype, "_actionButtons", void 0);
|
|
23
123
|
window.customElements.define('zui-table-topbar', ZuiTableTopbarElement);
|
|
24
124
|
//# sourceMappingURL=zui-table-topbar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zui-table-topbar.js","sourceRoot":"","sources":["../src/zui-table-topbar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"zui-table-topbar.js","sourceRoot":"","sources":["../src/zui-table-topbar.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAA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queryAssignedElements, queryAssignedNodes } from 'lit/decorators.js';\nimport { style } from './zui-table-topbar-css.js';\nimport { screenBreakpoints } from '@zywave/zui-base/dist/utils/breakpoints';\nimport type { ZuiButton } from '@zywave/zui-button/dist/zui-button.js';\n\n/**\n * Used to house table related pieces such as a search input or `zui-search`, and other up front information.\n *\n * @element zui-table-topbar\n *\n * @slot - Unnamed slot, table cell content goes here\n * @slot counter - Total number of results from table goes here\n * @slot action - Action(s) that affect the whole table goes here\n */\nexport class ZuiTableTopbarElement extends ZuiTableBaseElement {\n @queryAssignedElements({ slot: 'action' })\n private _actionSlottedElements: Array<HTMLCollection>;\n\n @queryAssignedNodes({ slot: 'counter' })\n private _counterSlottedNodes: Array<HTMLCollection>;\n\n @queryAssignedElements({ selector: 'zui-button', slot: 'action' })\n private _actionButtons: Array<ZuiButton>;\n\n #mobileBreakpoint: MediaQueryList = window.matchMedia(`only screen and (max-width: ${screenBreakpoints.xsmall})`);\n\n #mobileTopbarActionButtonsEvent = (b: MediaQueryListEvent) => {\n b.matches ? this.#addBlockStylingToButtons() : this.#removeBlockStylingFromButtons();\n };\n\n static get styles() {\n return [super.styles, style];\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n if (this.#mobileBreakpoint.addEventListener) {\n this.#mobileBreakpoint.addEventListener('change', this.#mobileTopbarActionButtonsEvent);\n } else {\n this.#mobileBreakpoint.addListener(this.#mobileTopbarActionButtonsEvent);\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n\n if (this.#mobileBreakpoint.addEventListener) {\n this.#mobileBreakpoint.removeEventListener('change', this.#mobileTopbarActionButtonsEvent);\n } else if (this.#mobileBreakpoint.addListener) {\n this.#mobileBreakpoint.removeListener(this.#mobileTopbarActionButtonsEvent);\n }\n }\n\n firstUpdated() {\n this.#mobileBreakpoint.matches ? this.#addBlockStylingToButtons() : this.#removeBlockStylingFromButtons();\n this.#toggleActionDivDisplay();\n this.#toggleCounterDivDisplay();\n }\n\n render() {\n return html`<div class=\"topbar\">\n <div class=\"content\"><slot></slot></div>\n <div class=\"counter\"><slot name=\"counter\" @slotchange=\"${this.#toggleCounterDivDisplay}\"></slot></div>\n <div class=\"action\"\n ><slot\n name=\"action\"\n @slotchange=\"${this.#toggleActionDivDisplay} ${this.#mobileBreakpoint.matches\n ? this.#addBlockStylingToButtons\n : this.#removeBlockStylingFromButtons}\"\n ></slot\n ></div>\n </div>`;\n }\n\n #addBlockStylingToButtons() {\n if (this._actionButtons.length > 0) {\n for (const button of this._actionButtons) {\n if (!button.hasAttribute('block')) {\n button.setAttribute('block', '');\n }\n }\n }\n\n this.requestUpdate();\n }\n\n #removeBlockStylingFromButtons() {\n if (this._actionButtons.length > 0) {\n for (const button of this._actionButtons) {\n if (button.hasAttribute('block')) {\n button.removeAttribute('block');\n }\n }\n }\n\n this.requestUpdate();\n }\n\n #toggleCounterDivDisplay() {\n const counter: HTMLElement = this.shadowRoot.querySelector('.counter');\n\n if (this._counterSlottedNodes.length === 0) {\n counter.style.display = 'none';\n } else if (this._counterSlottedNodes.length > 0 && counter.style.display === 'none') {\n counter.style.removeProperty('display');\n }\n\n this.requestUpdate();\n }\n\n #toggleActionDivDisplay() {\n const action: HTMLElement = this.shadowRoot.querySelector('.action');\n\n if (this._actionSlottedElements.length === 0) {\n action.style.display = 'none';\n } else if (this._actionSlottedElements.length > 0 && action.style.display === 'none') {\n action.style.removeProperty('display');\n }\n\n this.requestUpdate();\n }\n}\n\nwindow.customElements.define('zui-table-topbar', ZuiTableTopbarElement);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'zui-table-topbar': ZuiTableTopbarElement;\n }\n}\n"]}
|