@kubex/zinc 1.0.14 → 1.0.16
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/custom-elements.json +156 -43
- package/dist/vscode.html-custom-data.json +11 -3
- package/dist/web-types.json +37 -16
- package/dist/zn.d.ts +102 -91
- package/dist/zn.min.css +1 -1
- package/dist/zn.min.js +206 -191
- package/docs/pages/components/collapsible.md +41 -1
- package/docs/pages/components/note.md +11 -1
- package/docs/pages/components/select.md +2 -2
- package/package.json +1 -1
- package/scss/shared/_button.scss +1 -1
- package/src/components/button/button.component.ts +2 -2
- package/src/components/button/button.scss +12 -13
- package/src/components/collapsible/collapsible.component.ts +53 -20
- package/src/components/collapsible/collapsible.scss +2 -0
- package/src/components/confirm/confirm.component.ts +28 -7
- package/src/components/data-table/data-table.component.ts +35 -20
- package/src/components/data-table/data-table.scss +1 -1
- package/src/components/dialog/dialog.component.ts +1 -3
- package/src/components/filter-container/filter-container.component.ts +1 -1
- package/src/components/input/input.component.ts +1 -1
- package/src/components/note/note.component.ts +20 -34
- package/src/components/note/note.scss +8 -0
- package/src/components/option/option.component.ts +11 -10
- package/src/components/order-table/order-table.scss +4 -1
- package/src/components/select/select.component.ts +64 -52
- package/src/components/style/style.component.ts +7 -1
- package/src/components/textarea/textarea.component.ts +36 -1
- package/src/components/textarea/textarea.scss +2 -2
|
@@ -31,10 +31,50 @@ Used instead of directly setting the `expanded` attribute on the element.
|
|
|
31
31
|
</zn-collapsible>
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
+
### Checkbox stuff
|
|
35
|
+
|
|
36
|
+
```html:preview
|
|
37
|
+
|
|
38
|
+
<zn-collapsible caption="Collapsible with Checkbox">
|
|
39
|
+
<div class="flex-mid" slot="caption">
|
|
40
|
+
<div class="grow zn-pr">Billing</div>
|
|
41
|
+
<zn-toggle name="enabled"></zn-toggle>
|
|
42
|
+
</div>
|
|
43
|
+
<div class="permission" data-filter="Example Permission">
|
|
44
|
+
<div class="flex-row zn-pad">
|
|
45
|
+
<div class="flex-mid">
|
|
46
|
+
<div class="grow flex-col flex-jc">
|
|
47
|
+
<strong>Example Permission</strong>
|
|
48
|
+
<span>Example Permission Description</span>
|
|
49
|
+
</div>
|
|
50
|
+
<div class="flex-mid">
|
|
51
|
+
<zn-toggle class="permission-toggle" name="enabled" value="1" fallback="0" size="medium">
|
|
52
|
+
</zn-toggle>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
</div>
|
|
57
|
+
<div class="permission" data-filter="Example Permission">
|
|
58
|
+
<div class="flex-row zn-pad">
|
|
59
|
+
<div class="flex-mid">
|
|
60
|
+
<div class="grow flex-col flex-jc">
|
|
61
|
+
<strong>Example Permission 2</strong>
|
|
62
|
+
<span>Example Permission 2 Description</span>
|
|
63
|
+
</div>
|
|
64
|
+
<div class="flex-mid">
|
|
65
|
+
<zn-toggle name="enabled" size="medium"></zn-toggle>
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
</zn-collapsible>
|
|
71
|
+
```
|
|
72
|
+
|
|
34
73
|
### Expanded Attribute
|
|
35
74
|
|
|
36
75
|
```html:preview
|
|
37
|
-
|
|
76
|
+
|
|
77
|
+
<zn-collapsible caption="Expanded Attribute"
|
|
38
78
|
description="Adding the expanded attribute will open the collapsible"
|
|
39
79
|
expanded>
|
|
40
80
|
<zn-button>Button</zn-button>
|
|
@@ -9,7 +9,17 @@ layout: component
|
|
|
9
9
|
|
|
10
10
|
<zn-note color="gray">
|
|
11
11
|
<span slot="caption">The caption</span>
|
|
12
|
-
<
|
|
12
|
+
<div slot="snippet">This is a short version of the below.</div>
|
|
13
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam, autem deleniti, dolore dolores ea enim fugit
|
|
14
|
+
harum incidunt minima numquam possimus praesentium quaerat quasi sequi sunt temporibus ut velit, veniam. Aut dolor
|
|
15
|
+
eius quae. Consequatur deleniti ipsum itaque pariatur ullam velit! Alias aut delectus dolores esse fuga iure laborum
|
|
16
|
+
magnam maiores minima, minus, natus placeat provident quasi ratione ullam ut? Fugit nisi placeat quidem suscipit
|
|
17
|
+
voluptatum? Adipisci aspernatur assumenda consequatur dolore ea esse exercitationem ipsum maiores minima neque saepe,
|
|
18
|
+
voluptates voluptatibus! A ab adipisci consequatur, esse eveniet itaque sed soluta! Aliquid animi blanditiis dolores
|
|
19
|
+
dolorum eum facere fugit harum id illo, laboriosam laborum libero magni minus natus nihil perspiciatis porro quae
|
|
20
|
+
quisquam, ratione rem repellat sequi sit suscipit voluptas voluptatum. Atque delectus eos fugit illo sit soluta
|
|
21
|
+
suscipit vero? At consectetur culpa dolor, dolores ea earum enim error et expedita iste laudantium nam necessitatibus
|
|
22
|
+
quaerat, quis sed tempora vel voluptatum?
|
|
13
23
|
<span slot="date">
|
|
14
24
|
<small>11/10/24</small>
|
|
15
25
|
</span>
|
|
@@ -18,10 +18,10 @@ instead.
|
|
|
18
18
|
```html:preview
|
|
19
19
|
|
|
20
20
|
<form method="get" action="#">
|
|
21
|
-
<zn-select name="something" label="Select one option"
|
|
21
|
+
<zn-select name="something" label="Select one option">
|
|
22
22
|
<zn-option value="0">Option 0</zn-option>
|
|
23
23
|
<zn-option value="1">Option 1</zn-option>
|
|
24
|
-
<zn-option value="2">Option 2</zn-option>
|
|
24
|
+
<zn-option value="2" selected>Option 2</zn-option>
|
|
25
25
|
<zn-option value="3">Option 3</zn-option>
|
|
26
26
|
<zn-option value="4">Option 4</zn-option>
|
|
27
27
|
<zn-option value="5">Option 5</zn-option>
|
package/package.json
CHANGED
package/scss/shared/_button.scss
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {classMap} from 'lit/directives/class-map.js';
|
|
2
|
-
import {type CSSResultGroup, unsafeCSS} from 'lit';
|
|
2
|
+
import {type CSSResultGroup, nothing, unsafeCSS} from 'lit';
|
|
3
3
|
import {FormControlController, validValidityState} from "../../internal/form";
|
|
4
4
|
import {HasSlotController} from '../../internal/slot';
|
|
5
5
|
import {html, literal} from 'lit/static-html.js';
|
|
@@ -339,7 +339,6 @@ export default class ZnButton extends ZincElement implements ZincFormControl {
|
|
|
339
339
|
'button--text': (this.text && !this.outline),
|
|
340
340
|
'button--grow': this.grow,
|
|
341
341
|
'button--standard': !this.outline && !this.text,
|
|
342
|
-
'button--disabled': this.disabled,
|
|
343
342
|
'button--with-icon': this.icon,
|
|
344
343
|
'button--icon-left': this.iconPosition === 'left',
|
|
345
344
|
'button--icon-right': this.iconPosition === 'right',
|
|
@@ -356,6 +355,7 @@ export default class ZnButton extends ZincElement implements ZincFormControl {
|
|
|
356
355
|
rel="${ifDefined(isLink ? this.rel : undefined)}"
|
|
357
356
|
gaid="${ifDefined(this.gaid)}"
|
|
358
357
|
data-notification="${ifDefined(this.notification)}"
|
|
358
|
+
disabled=${this.disabled || nothing}
|
|
359
359
|
@click="${this.handleClick}">
|
|
360
360
|
${this.iconPosition === 'left' ? icon : ''}
|
|
361
361
|
<slot part="label"
|
|
@@ -21,7 +21,6 @@
|
|
|
21
21
|
|
|
22
22
|
border-width: 1px;
|
|
23
23
|
border-color: transparent;
|
|
24
|
-
height: 100%;
|
|
25
24
|
display: inline-flex;
|
|
26
25
|
position: relative;
|
|
27
26
|
|
|
@@ -93,7 +92,7 @@
|
|
|
93
92
|
outline-offset: 2px;
|
|
94
93
|
}
|
|
95
94
|
|
|
96
|
-
|
|
95
|
+
[disabled] {
|
|
97
96
|
cursor: not-allowed;
|
|
98
97
|
opacity: 0.5;
|
|
99
98
|
|
|
@@ -108,11 +107,11 @@
|
|
|
108
107
|
border-color: var(--zn-color-neutral-50);
|
|
109
108
|
color: rgb(var(--zn-primary));
|
|
110
109
|
|
|
111
|
-
&:hover:not(
|
|
110
|
+
&:hover:not([disabled]) {
|
|
112
111
|
background-color: var(--zn-color-neutral-100)
|
|
113
112
|
}
|
|
114
113
|
|
|
115
|
-
&:active:not(
|
|
114
|
+
&:active:not([disabled]) {
|
|
116
115
|
background-color: var(--zn-color-neutral-100)
|
|
117
116
|
}
|
|
118
117
|
}
|
|
@@ -122,11 +121,11 @@
|
|
|
122
121
|
border-color: rgb(var(--btn-color));
|
|
123
122
|
color: rgba(255, 255, 255, 0.9);
|
|
124
123
|
|
|
125
|
-
&:hover:not(
|
|
124
|
+
&:hover:not([disabled]) {
|
|
126
125
|
background-color: rgba(var(--btn-color), 0.8);
|
|
127
126
|
}
|
|
128
127
|
|
|
129
|
-
&:active:not(
|
|
128
|
+
&:active:not([disabled]) {
|
|
130
129
|
background-color: rgba(var(--btn-color));
|
|
131
130
|
}
|
|
132
131
|
}
|
|
@@ -137,7 +136,7 @@
|
|
|
137
136
|
border-color: rgb(var(--btn-color));
|
|
138
137
|
color: rgb(var(--btn-color));
|
|
139
138
|
|
|
140
|
-
&:hover:not(
|
|
139
|
+
&:hover:not([disabled]), &:active:not([disabled]) {
|
|
141
140
|
background-color: rgb(var(--btn-color));
|
|
142
141
|
color: white;
|
|
143
142
|
}
|
|
@@ -145,7 +144,7 @@
|
|
|
145
144
|
&.button--secondary {
|
|
146
145
|
border-color: #F3EFFF;
|
|
147
146
|
|
|
148
|
-
&:hover:not(
|
|
147
|
+
&:hover:not([disabled]), &:active:not([disabled]) {
|
|
149
148
|
background-color: rgb(221, 218, 236);
|
|
150
149
|
}
|
|
151
150
|
}
|
|
@@ -156,7 +155,7 @@
|
|
|
156
155
|
background: none;
|
|
157
156
|
color: rgb(var(--btn-color));
|
|
158
157
|
|
|
159
|
-
&:hover:not(
|
|
158
|
+
&:hover:not([disabled]), &:active:not([disabled]) {
|
|
160
159
|
background-color: rgba(var(--btn-color), 0.1);
|
|
161
160
|
}
|
|
162
161
|
|
|
@@ -275,11 +274,11 @@
|
|
|
275
274
|
border-color: transparent !important;
|
|
276
275
|
color: inherit;
|
|
277
276
|
|
|
278
|
-
&:hover:not(
|
|
277
|
+
&:hover:not([disabled]) {
|
|
279
278
|
background-color: rgba(var(--zn-primary), 0.1);
|
|
280
279
|
}
|
|
281
280
|
|
|
282
|
-
&:active:not(
|
|
281
|
+
&:active:not([disabled]) {
|
|
283
282
|
background-color: rgba(var(--zn-primary), 0.2);
|
|
284
283
|
}
|
|
285
284
|
}
|
|
@@ -291,7 +290,7 @@
|
|
|
291
290
|
color: white;
|
|
292
291
|
opacity: 1 !important;
|
|
293
292
|
|
|
294
|
-
&:hover {
|
|
293
|
+
&:hover:not([disabled]) {
|
|
295
294
|
background-color: rgb(var(--btn-color));
|
|
296
295
|
}
|
|
297
296
|
|
|
@@ -304,7 +303,7 @@
|
|
|
304
303
|
border-color: rgb(var(--btn-color));
|
|
305
304
|
color: rgb(var(--btn-color));
|
|
306
305
|
|
|
307
|
-
&:hover, &:active {
|
|
306
|
+
&:hover:not([disabled]), &:active:not([disabled]) {
|
|
308
307
|
background-color: rgba(var(--btn-color));
|
|
309
308
|
color: white;
|
|
310
309
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import {classMap} from "lit/directives/class-map.js";
|
|
2
|
-
import {type CSSResultGroup, html, unsafeCSS} from 'lit';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { classMap } from "lit/directives/class-map.js";
|
|
2
|
+
import { type CSSResultGroup, html, unsafeCSS } from 'lit';
|
|
3
|
+
import { HasSlotController } from "../../internal/slot";
|
|
4
|
+
import { property, state } from 'lit/decorators.js';
|
|
5
|
+
import { Store } from "../../internal/storage";
|
|
5
6
|
import ZincElement from '../../internal/zinc-element';
|
|
6
7
|
|
|
7
8
|
import styles from './collapsible.scss';
|
|
8
|
-
import {
|
|
9
|
+
import { ZnInputEvent } from "../../events/zn-input";
|
|
10
|
+
import ZnToggle from "../toggle";
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
13
|
* @summary Toggles between showing and hiding content when clicked
|
|
@@ -21,28 +23,28 @@ import {HasSlotController} from "../../internal/slot";
|
|
|
21
23
|
export default class ZnCollapsible extends ZincElement {
|
|
22
24
|
static styles: CSSResultGroup = unsafeCSS(styles);
|
|
23
25
|
|
|
24
|
-
@property({reflect: true}) caption = '';
|
|
26
|
+
@property({ reflect: true }) caption = '';
|
|
25
27
|
|
|
26
|
-
@property({reflect: true}) description
|
|
28
|
+
@property({ reflect: true }) description: string;
|
|
27
29
|
|
|
28
|
-
@property({reflect: true}) label = '';
|
|
30
|
+
@property({ reflect: true }) label = '';
|
|
29
31
|
|
|
30
|
-
@property({type: Boolean, attribute: 'show-number', reflect: true}) showNumber: boolean = false;
|
|
32
|
+
@property({ type: Boolean, attribute: 'show-number', reflect: true }) showNumber: boolean = false;
|
|
31
33
|
|
|
32
34
|
// what element name to count
|
|
33
|
-
@property({type: String, attribute: 'count-element'}) countElement: string = '*';
|
|
35
|
+
@property({ type: String, attribute: 'count-element' }) countElement: string = '*';
|
|
34
36
|
|
|
35
|
-
@property({type: Boolean, reflect: true}) expanded: boolean = false;
|
|
37
|
+
@property({ type: Boolean, reflect: true }) expanded: boolean = false;
|
|
36
38
|
|
|
37
|
-
@property({attribute: 'default'}) defaultState: 'open' | 'closed';
|
|
39
|
+
@property({ attribute: 'default' }) defaultState: 'open' | 'closed';
|
|
38
40
|
|
|
39
|
-
@property({attribute: 'local-storage', type: Boolean, reflect: true}) localStorage: boolean;
|
|
41
|
+
@property({ attribute: 'local-storage', type: Boolean, reflect: true }) localStorage: boolean;
|
|
40
42
|
|
|
41
|
-
@property({attribute: 'store-key', reflect: true}) storeKey: string = "";
|
|
43
|
+
@property({ attribute: 'store-key', reflect: true }) storeKey: string = "";
|
|
42
44
|
|
|
43
|
-
@property({attribute: 'store-ttl', type: Number, reflect: true}) storeTtl = 0;
|
|
45
|
+
@property({ attribute: 'store-ttl', type: Number, reflect: true }) storeTtl = 0;
|
|
44
46
|
|
|
45
|
-
@property({attribute: 'flush', type: Boolean, reflect: true}) flush: boolean = false;
|
|
47
|
+
@property({ attribute: 'flush', type: Boolean, reflect: true }) flush: boolean = false;
|
|
46
48
|
|
|
47
49
|
@state() numberOfItems: number = 0;
|
|
48
50
|
|
|
@@ -52,7 +54,9 @@ export default class ZnCollapsible extends ZincElement {
|
|
|
52
54
|
|
|
53
55
|
private observer: MutationObserver;
|
|
54
56
|
|
|
55
|
-
|
|
57
|
+
private showArrow: boolean = true;
|
|
58
|
+
|
|
59
|
+
async connectedCallback() {
|
|
56
60
|
super.connectedCallback();
|
|
57
61
|
this._store = new Store(this.localStorage ? window.localStorage : window.sessionStorage, "zncla:", this.storeTtl);
|
|
58
62
|
this.expanded = this.defaultState === 'open';
|
|
@@ -70,7 +74,28 @@ export default class ZnCollapsible extends ZincElement {
|
|
|
70
74
|
this.observer = new MutationObserver(() => {
|
|
71
75
|
this.recalculateNumberOfItems();
|
|
72
76
|
});
|
|
73
|
-
this.observer.observe(slot, {childList: true, subtree: true});
|
|
77
|
+
this.observer.observe(slot, { childList: true, subtree: true });
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
await this.updateComplete;
|
|
81
|
+
|
|
82
|
+
const captionSlot = this.hasSlotController.getSlot('caption') as HTMLDivElement;
|
|
83
|
+
if (captionSlot) {
|
|
84
|
+
const toggles = captionSlot.querySelectorAll('zn-toggle');
|
|
85
|
+
// remove the drop arrow
|
|
86
|
+
this.showArrow = false;
|
|
87
|
+
toggles.forEach(toggle => {
|
|
88
|
+
toggle.removeEventListener('zn-input', this.handleCaptionToggle);
|
|
89
|
+
toggle.addEventListener('zn-input', this.handleCaptionToggle);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// this is for handling global toggles
|
|
95
|
+
public handleCaptionToggle = (e: ZnInputEvent) => {
|
|
96
|
+
const toggle = e.target as ZnToggle;
|
|
97
|
+
if (toggle) {
|
|
98
|
+
this.expanded = toggle.checked;
|
|
74
99
|
}
|
|
75
100
|
}
|
|
76
101
|
|
|
@@ -82,6 +107,11 @@ export default class ZnCollapsible extends ZincElement {
|
|
|
82
107
|
}
|
|
83
108
|
|
|
84
109
|
handleCollapse = (e: MouseEvent) => {
|
|
110
|
+
const target = e.target as HTMLElement;
|
|
111
|
+
if (target.tagName.toLowerCase() === 'input' && (target as HTMLInputElement).type === 'checkbox') {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
|
|
85
115
|
if (this.expanded) {
|
|
86
116
|
this.expanded = false;
|
|
87
117
|
e.stopPropagation();
|
|
@@ -112,13 +142,16 @@ export default class ZnCollapsible extends ZincElement {
|
|
|
112
142
|
<p class="caption">
|
|
113
143
|
<slot name="caption">${this.caption}</slot>
|
|
114
144
|
</p>
|
|
115
|
-
<p class="description"
|
|
145
|
+
<p class="description">
|
|
146
|
+
<slot name="description">${this.description}</slot>
|
|
147
|
+
</p>
|
|
116
148
|
</div>
|
|
117
149
|
<div class="header__right">
|
|
118
150
|
<slot name="label"><p class="label">${this.label}</p></slot>
|
|
119
151
|
${this.showNumber && !this.expanded ? html`
|
|
120
152
|
<zn-chip size="small" type="primary">${this.numberOfItems}</zn-chip>` : ''}
|
|
121
|
-
|
|
153
|
+
${this.showArrow ? html`
|
|
154
|
+
<zn-icon library="material-outlined" src="expand_more" class="expand"></zn-icon>` : ''}
|
|
122
155
|
</div>
|
|
123
156
|
</slot>
|
|
124
157
|
<div class="${classMap({
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {classMap} from "lit/directives/class-map.js";
|
|
2
|
-
import {type CSSResultGroup, html, type PropertyValues, unsafeCSS} from 'lit';
|
|
2
|
+
import {type CSSResultGroup, html, nothing, type PropertyValues, unsafeCSS} from 'lit';
|
|
3
3
|
import {deepQuerySelectorAll} from "../../utilities/query";
|
|
4
4
|
import {HasSlotController} from "../../internal/slot";
|
|
5
5
|
import {ifDefined} from "lit/directives/if-defined.js";
|
|
6
|
-
import {property, query} from 'lit/decorators.js';
|
|
6
|
+
import {property, query, state} from 'lit/decorators.js';
|
|
7
7
|
import ZincElement from "../../internal/zinc-element";
|
|
8
8
|
import ZnDialog from "../dialog";
|
|
9
9
|
|
|
@@ -61,6 +61,11 @@ export default class ZnConfirm extends ZincElement {
|
|
|
61
61
|
|
|
62
62
|
@property({type: Boolean, attribute: 'hide-icon'}) hideIcon: boolean = false;
|
|
63
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Show a loading state when the dialog is submitted.
|
|
66
|
+
*/
|
|
67
|
+
@property({type: Boolean, attribute: 'show-loading'}) showLoading: boolean = false;
|
|
68
|
+
|
|
64
69
|
/**
|
|
65
70
|
* The dialog's trigger element. This is used to open the dialog when clicked. If you do not provide a trigger, you
|
|
66
71
|
* will need to manually open the dialog using the `show()` method.
|
|
@@ -75,6 +80,9 @@ export default class ZnConfirm extends ZincElement {
|
|
|
75
80
|
|
|
76
81
|
@query('zn-dialog') dialog: ZnDialog;
|
|
77
82
|
|
|
83
|
+
/** Internal loading state used when showLoading is enabled */
|
|
84
|
+
@state() private loading: boolean = false;
|
|
85
|
+
|
|
78
86
|
protected firstUpdated(_changedProperties: PropertyValues) {
|
|
79
87
|
super.firstUpdated(_changedProperties);
|
|
80
88
|
if (this.open) {
|
|
@@ -108,10 +116,12 @@ export default class ZnConfirm extends ZincElement {
|
|
|
108
116
|
show = (event: Event | undefined = undefined) => {
|
|
109
117
|
const trigger = event?.target as HTMLButtonElement
|
|
110
118
|
if (trigger?.disabled) return;
|
|
119
|
+
this.loading = false;
|
|
111
120
|
this.dialog.show();
|
|
112
121
|
}
|
|
113
122
|
|
|
114
123
|
hide() {
|
|
124
|
+
this.loading = false;
|
|
115
125
|
this.dialog.hide();
|
|
116
126
|
}
|
|
117
127
|
|
|
@@ -143,12 +153,18 @@ export default class ZnConfirm extends ZincElement {
|
|
|
143
153
|
: ''}
|
|
144
154
|
|
|
145
155
|
<div class="confirm-dialog__content">
|
|
146
|
-
${this.
|
|
147
|
-
|
|
156
|
+
${!this.loading ? html`
|
|
157
|
+
${this.content ? html`${this.content}` : ''}
|
|
158
|
+
<slot></slot>` : html`
|
|
159
|
+
Loading...`}
|
|
148
160
|
</div>
|
|
149
161
|
|
|
150
|
-
<zn-button outline color="${this.type}" slot="footer" dialog-closer
|
|
151
|
-
|
|
162
|
+
<zn-button outline color="${this.type}" slot="footer" dialog-closer disabled=${this.loading || nothing}>
|
|
163
|
+
${this.cancelText}
|
|
164
|
+
</zn-button>
|
|
165
|
+
<zn-button color="${this.type}" slot="footer" @click="${this.submitDialog}" disabled=${this.loading || nothing}>
|
|
166
|
+
${this.confirmText}
|
|
167
|
+
</zn-button>
|
|
152
168
|
|
|
153
169
|
<slot name="footer-text" slot="footer-text">${this.footerText}</slot>
|
|
154
170
|
</zn-dialog>`;
|
|
@@ -174,7 +190,12 @@ export default class ZnConfirm extends ZincElement {
|
|
|
174
190
|
detail: {element: form}
|
|
175
191
|
}))
|
|
176
192
|
form.requestSubmit();
|
|
177
|
-
this.
|
|
193
|
+
if (!this.showLoading) {
|
|
194
|
+
this.hide();
|
|
195
|
+
} else {
|
|
196
|
+
this.loading = true;
|
|
197
|
+
this.dialog.closer.disabled = true;
|
|
198
|
+
}
|
|
178
199
|
}
|
|
179
200
|
}
|
|
180
201
|
}
|
|
@@ -158,6 +158,7 @@ export default class ZnDataTable extends ZincElement {
|
|
|
158
158
|
@property({attribute: 'data', type: Object, reflect: true}) data: any;
|
|
159
159
|
@property({attribute: 'sort-column'}) sortColumn: string;
|
|
160
160
|
@property({attribute: 'sort-direction'}) sortDirection: string = "asc";
|
|
161
|
+
@property({attribute: 'local-sort', type: Boolean}) localSort: boolean = false;
|
|
161
162
|
@property({attribute: 'filter'}) filter: string = '';
|
|
162
163
|
@property({attribute: 'wide-column'}) wideColumn: string;
|
|
163
164
|
@property({attribute: 'key'}) key: string = 'id';
|
|
@@ -813,7 +814,13 @@ export default class ZnDataTable extends ZincElement {
|
|
|
813
814
|
return () => {
|
|
814
815
|
this.sortColumn = key;
|
|
815
816
|
this.sortDirection = this.sortDirection === 'asc' ? 'desc' : 'asc';
|
|
816
|
-
|
|
817
|
+
|
|
818
|
+
if (this.localSort) {
|
|
819
|
+
this._rows = this.sortLocalData(this._rows as Row[]);
|
|
820
|
+
this.requestUpdate();
|
|
821
|
+
} else {
|
|
822
|
+
this._dataTask.run().then(r => r);
|
|
823
|
+
}
|
|
817
824
|
};
|
|
818
825
|
}
|
|
819
826
|
|
|
@@ -1051,23 +1058,11 @@ export default class ZnDataTable extends ZincElement {
|
|
|
1051
1058
|
}
|
|
1052
1059
|
|
|
1053
1060
|
private getRows(data: Response): Row[] {
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
sourceRows.sort((rowA: Row, rowB: Row) => {
|
|
1061
|
-
const getCellForSort = (row: Row): Cell => {
|
|
1062
|
-
const byHeading = row.cells.find((cell: Cell) => cell.column === this.sortColumn);
|
|
1063
|
-
if (byHeading !== undefined) return byHeading as unknown as Cell;
|
|
1064
|
-
return row.cells[sortIndex];
|
|
1065
|
-
};
|
|
1066
|
-
|
|
1067
|
-
const aVal = getCellForSort(rowA);
|
|
1068
|
-
const bVal = getCellForSort(rowB);
|
|
1069
|
-
return this.sortData(aVal, bVal);
|
|
1070
|
-
});
|
|
1061
|
+
// Copy rows to avoid mutating original data
|
|
1062
|
+
const sourceRows = Array.isArray(data.rows) ? data.rows.slice() : [];
|
|
1063
|
+
|
|
1064
|
+
if (this.localSort && this.sortColumn) {
|
|
1065
|
+
return this.sortLocalData(sourceRows);
|
|
1071
1066
|
}
|
|
1072
1067
|
|
|
1073
1068
|
return sourceRows;
|
|
@@ -1136,6 +1131,25 @@ export default class ZnDataTable extends ZincElement {
|
|
|
1136
1131
|
return aNormal < bNormal ? 1 : aNormal > bNormal ? -1 : 0;
|
|
1137
1132
|
}
|
|
1138
1133
|
|
|
1134
|
+
private sortLocalData(rows: Row[]): Row[] {
|
|
1135
|
+
if (!this.sortColumn) return rows;
|
|
1136
|
+
|
|
1137
|
+
const headerKeys = Object.keys(this.headers);
|
|
1138
|
+
const sortIndex = headerKeys.indexOf(this.sortColumn);
|
|
1139
|
+
|
|
1140
|
+
const getCellForSort = (row: Row): Cell => {
|
|
1141
|
+
const byHeading = row.cells.find((cell: Cell) => cell.column === this.sortColumn);
|
|
1142
|
+
if (byHeading !== undefined) return byHeading as unknown as Cell;
|
|
1143
|
+
return row.cells[sortIndex];
|
|
1144
|
+
};
|
|
1145
|
+
|
|
1146
|
+
return rows.slice().sort((rowA: Row, rowB: Row) => {
|
|
1147
|
+
const aVal = getCellForSort(rowA);
|
|
1148
|
+
const bVal = getCellForSort(rowB);
|
|
1149
|
+
return this.sortData(aVal, bVal);
|
|
1150
|
+
});
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1139
1153
|
private loadingTable() {
|
|
1140
1154
|
return html`
|
|
1141
1155
|
<div class="table-container">
|
|
@@ -1239,8 +1253,9 @@ export default class ZnDataTable extends ZincElement {
|
|
|
1239
1253
|
type="${ifDefined(action.confirmType)}"
|
|
1240
1254
|
caption="${action.confirmTitle}"
|
|
1241
1255
|
content="${action.confirmContent}"
|
|
1242
|
-
action="${action.uri}"
|
|
1243
|
-
|
|
1256
|
+
action="${action.uri}"
|
|
1257
|
+
show-loading></zn-confirm>
|
|
1258
|
+
<zn-menu-item id="${triggerId}" confirm>
|
|
1244
1259
|
${(action.icon) ? html`
|
|
1245
1260
|
<zn-icon src="${action.icon}" size="20" slot="prefix"></zn-icon>` : html``}
|
|
1246
1261
|
${action.text}
|
|
@@ -57,9 +57,7 @@ export default class ZnDialog extends ZincElement {
|
|
|
57
57
|
private closeWatcher: CloseWatcher | null;
|
|
58
58
|
|
|
59
59
|
@query('.dialog') dialog: HTMLDialogElement;
|
|
60
|
-
@query('.
|
|
61
|
-
@query('.dialog__overlay') overlay: HTMLElement;
|
|
62
|
-
|
|
60
|
+
@query('.dialog__close') closer: HTMLButtonElement;
|
|
63
61
|
|
|
64
62
|
/** The dialog's theme variant. */
|
|
65
63
|
@property({reflect: true}) variant: 'default' | 'warning' | 'announcement' = 'default';
|
|
@@ -268,7 +268,7 @@ export default class ZnInput extends ZincElement implements ZincFormControl {
|
|
|
268
268
|
}
|
|
269
269
|
|
|
270
270
|
private handleChange() {
|
|
271
|
-
if (this.type === 'currency') {
|
|
271
|
+
if (this.type === 'currency' && this.input.value) {
|
|
272
272
|
this.value = parseFloat(this.input.value as string).toFixed(2)
|
|
273
273
|
} else {
|
|
274
274
|
this.value = this.input.value;
|