@kubex/zinc 1.0.12 → 1.0.14
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 +2611 -2187
- package/dist/vscode.html-custom-data.json +185 -155
- package/dist/web-types.json +420 -334
- package/dist/zn.d.ts +133 -15
- package/dist/zn.min.css +1 -1
- package/dist/zn.min.js +603 -551
- package/docs/pages/components/data-select.md +1 -1
- package/docs/pages/components/filter-container.md +72 -0
- package/docs/pages/components/filter-wrapper.md +2 -2
- package/docs/pages/components/hover-container.md +20 -0
- package/docs/pages/components/reveal.md +24 -0
- package/docs/pages/components/select.md +39 -1
- package/docs/pages/components/toggle.md +6 -3
- package/package.json +1 -1
- package/scss/_root.scss +4 -4
- package/src/components/button/button.component.ts +11 -5
- package/src/components/content-block/content-block.scss +35 -23
- package/src/components/data-select/data-select.component.ts +5 -2
- package/src/components/data-table/data-table.component.ts +128 -27
- package/src/components/data-table/data-table.scss +56 -10
- package/src/components/dropdown/dropdown.component.ts +3 -0
- package/src/components/editor/editor.component.ts +1 -1
- package/src/components/filter-container/filter-container.component.ts +112 -0
- package/src/components/filter-container/filter-container.scss +5 -0
- package/src/components/filter-container/filter-container.test.ts +10 -0
- package/src/components/filter-container/index.ts +12 -0
- package/src/components/filter-wrapper/filter-wrapper.component.ts +1 -1
- package/src/components/form-group/form-group.component.ts +26 -26
- package/src/components/header/header.scss +7 -0
- package/src/components/navbar/navbar.scss +4 -0
- package/src/components/note/note.component.ts +1 -0
- package/src/components/option/option.component.ts +3 -3
- package/src/components/option/option.scss +5 -9
- package/src/components/progress-bar/progress-bar.component.ts +1 -1
- package/src/components/progress-tile/progress-tile.component.ts +2 -2
- package/src/components/reveal/index.ts +12 -0
- package/src/components/reveal/reveal.component.ts +92 -0
- package/src/components/reveal/reveal.scss +18 -0
- package/src/components/reveal/reveal.test.ts +10 -0
- package/src/components/select/select.component.ts +63 -7
- package/src/components/sp/sp.component.ts +2 -0
- package/src/components/split-pane/split-pane.component.ts +2 -1
- package/src/components/tile/tile.component.ts +3 -1
- package/src/components/toggle/toggle.component.ts +33 -23
- package/src/components/tooltip/tooltip.component.ts +10 -5
- package/src/internal/form.ts +5 -0
- package/src/utilities/top-layer-manager.ts +32 -0
- package/src/wc.scss +9 -5
- package/src/zinc.ts +2 -0
|
@@ -18,6 +18,18 @@ table {
|
|
|
18
18
|
table-layout: auto;
|
|
19
19
|
text-align: left;
|
|
20
20
|
|
|
21
|
+
tbody tr:nth-of-type(even) {
|
|
22
|
+
background-color: unset !important;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
tbody tr.table__row--data.table__row--odd:not(.table__row--selected) td {
|
|
26
|
+
background-color: rgba(var(--zn-body));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
tbody tr.table__row--details td {
|
|
30
|
+
background-color: rgb(var(--zn-shadow));
|
|
31
|
+
}
|
|
32
|
+
|
|
21
33
|
&.table--standalone {
|
|
22
34
|
background-color: rgb(var(--zn-panel));
|
|
23
35
|
border-radius: var(--zn-border-radius-large);
|
|
@@ -34,11 +46,16 @@ table {
|
|
|
34
46
|
border-bottom: 1px solid rgb(var(--zn-border-color)) !important;
|
|
35
47
|
}
|
|
36
48
|
|
|
37
|
-
&.with-hover tbody tr:hover {
|
|
49
|
+
&.with-hover tbody tr.table__row--data:not(.table__row--selected):hover td {
|
|
38
50
|
background-color: rgba(var(--zn-primary), 0.05) !important;
|
|
39
51
|
cursor: pointer;
|
|
40
52
|
}
|
|
41
53
|
|
|
54
|
+
&.with-hover tbody tr.table__row--details:hover {
|
|
55
|
+
background-color: inherit;
|
|
56
|
+
cursor: default;
|
|
57
|
+
}
|
|
58
|
+
|
|
42
59
|
tbody tr td {
|
|
43
60
|
border-top: 1px solid rgb(var(--zn-border-color)) !important;
|
|
44
61
|
}
|
|
@@ -47,10 +64,6 @@ table {
|
|
|
47
64
|
border-top: 0 !important;
|
|
48
65
|
}
|
|
49
66
|
|
|
50
|
-
tbody tr:nth-of-type(even) {
|
|
51
|
-
background-color: rgba(var(--zn-body));
|
|
52
|
-
}
|
|
53
|
-
|
|
54
67
|
thead tr th:first-of-type,
|
|
55
68
|
tbody tr td:first-of-type {
|
|
56
69
|
padding-left: 14px;
|
|
@@ -169,6 +182,12 @@ table {
|
|
|
169
182
|
visibility: hidden;
|
|
170
183
|
}
|
|
171
184
|
}
|
|
185
|
+
|
|
186
|
+
&--expander {
|
|
187
|
+
width: 28px;
|
|
188
|
+
min-width: 28px;
|
|
189
|
+
padding-right: 0;
|
|
190
|
+
}
|
|
172
191
|
}
|
|
173
192
|
|
|
174
193
|
&__cell {
|
|
@@ -232,6 +251,11 @@ table {
|
|
|
232
251
|
gap: var(--zn-spacing-small);
|
|
233
252
|
}
|
|
234
253
|
}
|
|
254
|
+
|
|
255
|
+
&--expander {
|
|
256
|
+
width: 28px;
|
|
257
|
+
min-width: 28px;
|
|
258
|
+
}
|
|
235
259
|
}
|
|
236
260
|
|
|
237
261
|
&__header {
|
|
@@ -306,6 +330,28 @@ table {
|
|
|
306
330
|
}
|
|
307
331
|
}
|
|
308
332
|
}
|
|
333
|
+
|
|
334
|
+
&__details {
|
|
335
|
+
display: grid;
|
|
336
|
+
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
|
|
337
|
+
gap: var(--zn-spacing-x-large) !important;
|
|
338
|
+
|
|
339
|
+
&__item {
|
|
340
|
+
display: flex;
|
|
341
|
+
flex-direction: column;
|
|
342
|
+
gap: var(--zn-spacing-2x-small, 4px);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
&__label {
|
|
346
|
+
font-size: 12px;
|
|
347
|
+
color: rgb(var(--zn-text-subtle, var(--zn-text)));
|
|
348
|
+
opacity: 0.8;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
&__value {
|
|
352
|
+
font-size: 14px;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
309
355
|
}
|
|
310
356
|
|
|
311
357
|
.reduced-opacity .table tbody {
|
|
@@ -335,10 +381,6 @@ table {
|
|
|
335
381
|
table tbody tr.table__row--selected {
|
|
336
382
|
background-color: var(--zn-color-purple-100);
|
|
337
383
|
|
|
338
|
-
&:nth-of-type(even) {
|
|
339
|
-
background-color: hsla(from var(--zn-color-purple-200) h s l / 0.8);
|
|
340
|
-
}
|
|
341
|
-
|
|
342
384
|
&:hover {
|
|
343
385
|
background-color: var(--zn-color-purple-200) !important;
|
|
344
386
|
}
|
|
@@ -393,13 +435,16 @@ table tbody tr.table__row--selected {
|
|
|
393
435
|
border-bottom-right-radius: 0;
|
|
394
436
|
}
|
|
395
437
|
}
|
|
438
|
+
|
|
439
|
+
&.table__row--odd {
|
|
440
|
+
background-color: hsla(from var(--zn-color-purple-200) h s l / 0.8);
|
|
441
|
+
}
|
|
396
442
|
}
|
|
397
443
|
|
|
398
444
|
table:has(tbody tr:first-of-type.table__row--selected) thead tr th {
|
|
399
445
|
border-bottom-color: var(--zn-color-purple-600) !important;
|
|
400
446
|
}
|
|
401
447
|
|
|
402
|
-
|
|
403
448
|
.table-group__title {
|
|
404
449
|
font-weight: var(--zn-font-weight-semibold);
|
|
405
450
|
font-size: var(--zn-font-size-large);
|
|
@@ -411,3 +456,4 @@ table:has(tbody tr:first-of-type.table__row--selected) thead tr th {
|
|
|
411
456
|
white-space: nowrap;
|
|
412
457
|
text-overflow: ellipsis;
|
|
413
458
|
}
|
|
459
|
+
|
|
@@ -6,6 +6,7 @@ import {property, query} from 'lit/decorators.js';
|
|
|
6
6
|
import {unsafeHTML} from 'lit/directives/unsafe-html.js';
|
|
7
7
|
import {waitForEvent} from "../../internal/event";
|
|
8
8
|
import {watch} from '../../internal/watch';
|
|
9
|
+
import topLayerManager from '../../utilities/top-layer-manager';
|
|
9
10
|
import ZincElement from '../../internal/zinc-element';
|
|
10
11
|
import type {ZnSelectEvent} from "../../events/zn-select";
|
|
11
12
|
import type ZnButton from "../button";
|
|
@@ -324,6 +325,7 @@ export default class ZnDropdown extends ZincElement {
|
|
|
324
325
|
|
|
325
326
|
if (this.open) {
|
|
326
327
|
this.emit('zn-show');
|
|
328
|
+
topLayerManager.registerDropdown(this);
|
|
327
329
|
this.addOpenListeners();
|
|
328
330
|
this.panel.hidden = false;
|
|
329
331
|
this.popup.active = true;
|
|
@@ -331,6 +333,7 @@ export default class ZnDropdown extends ZincElement {
|
|
|
331
333
|
this.emit('zn-after-show');
|
|
332
334
|
} else {
|
|
333
335
|
this.emit('zn-hide');
|
|
336
|
+
topLayerManager.unregisterDropdown(this);
|
|
334
337
|
this.removeOpenListeners();
|
|
335
338
|
this.panel.blur();
|
|
336
339
|
this.panel.hidden = true;
|
|
@@ -374,7 +374,7 @@ export default class ZnEditor extends ZincElement implements ZincFormControl {
|
|
|
374
374
|
}
|
|
375
375
|
|
|
376
376
|
private _handleTextChange() {
|
|
377
|
-
this.value = this.quillElement.
|
|
377
|
+
this.value = this.quillElement.getSemanticHTML();
|
|
378
378
|
this.editorHtml.value = this.value;
|
|
379
379
|
this.emit('zn-change');
|
|
380
380
|
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import {property} from 'lit/decorators.js';
|
|
2
|
+
import {type CSSResultGroup, html, unsafeCSS} from 'lit';
|
|
3
|
+
import ZincElement from '../../internal/zinc-element';
|
|
4
|
+
|
|
5
|
+
import styles from './filter-container.scss';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @summary Short summary of the component's intended use.
|
|
9
|
+
* @documentation https://zinc.style/components/filter-container
|
|
10
|
+
* @status experimental
|
|
11
|
+
* @since 1.0
|
|
12
|
+
*
|
|
13
|
+
* @dependency zn-example
|
|
14
|
+
*
|
|
15
|
+
* @event zn-event-name - Emitted as an example.
|
|
16
|
+
*
|
|
17
|
+
* @slot - The default slot.
|
|
18
|
+
* @slot example - An example slot.
|
|
19
|
+
*
|
|
20
|
+
* @csspart base - The component's base wrapper.
|
|
21
|
+
*
|
|
22
|
+
* @cssproperty --example - An example CSS custom property.
|
|
23
|
+
*/
|
|
24
|
+
export default class ZnFilterContainer extends ZincElement {
|
|
25
|
+
static styles: CSSResultGroup = unsafeCSS(styles);
|
|
26
|
+
|
|
27
|
+
@property() attr = 'filter';
|
|
28
|
+
|
|
29
|
+
public handleSearchChange(event: Event) {
|
|
30
|
+
// get all element that have data-'this.attr' attribute
|
|
31
|
+
const filterableElements = this.querySelectorAll(`[data-${this.attr}]`);
|
|
32
|
+
const input = event.target as HTMLInputElement;
|
|
33
|
+
const searchTerm = input.value.toLowerCase();
|
|
34
|
+
|
|
35
|
+
filterableElements.forEach((el) => {
|
|
36
|
+
const filterValue = el.getAttribute(`data-${this.attr}`)?.toLowerCase() || '';
|
|
37
|
+
if (filterValue.includes(searchTerm)) {
|
|
38
|
+
(el as HTMLElement).style.display = '';
|
|
39
|
+
} else {
|
|
40
|
+
(el as HTMLElement).style.display = 'none';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const panel = el.closest('zn-panel');
|
|
44
|
+
if (panel) {
|
|
45
|
+
const panelItems = panel.querySelectorAll(`[data-${this.attr}]`);
|
|
46
|
+
let anyVisible = false;
|
|
47
|
+
panelItems.forEach((item) => {
|
|
48
|
+
if ((item as HTMLElement).style.display !== 'none') {
|
|
49
|
+
anyVisible = true;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
});
|
|
53
|
+
if (anyVisible) {
|
|
54
|
+
(panel as HTMLElement).style.display = '';
|
|
55
|
+
} else {
|
|
56
|
+
(panel as HTMLElement).style.display = 'none';
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const accordionItem = el.closest('zn-accordion');
|
|
61
|
+
if (accordionItem) {
|
|
62
|
+
const itemElements = accordionItem.querySelectorAll(`[data-${this.attr}]`);
|
|
63
|
+
let anyVisible = false;
|
|
64
|
+
itemElements.forEach((item) => {
|
|
65
|
+
if ((item as HTMLElement).style.display !== 'none') {
|
|
66
|
+
anyVisible = true;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
if (anyVisible) {
|
|
71
|
+
(accordionItem as HTMLElement).style.display = '';
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
if (searchTerm === '') {
|
|
77
|
+
filterableElements.forEach((el) => {
|
|
78
|
+
(el as HTMLElement).style.display = '';
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// if nothing is visible, show a "no results found" message
|
|
83
|
+
const anyVisibleElements = Array.from(filterableElements).some((el) => {
|
|
84
|
+
return (el as HTMLElement).style.display !== 'none';
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
let noResultsMessage = this.querySelector('.no-results-message') as HTMLElement;
|
|
88
|
+
if (!anyVisibleElements) {
|
|
89
|
+
if (!noResultsMessage) {
|
|
90
|
+
noResultsMessage = document.createElement('div');
|
|
91
|
+
noResultsMessage.className = 'no-results-message';
|
|
92
|
+
noResultsMessage.textContent = 'No results found';
|
|
93
|
+
this.appendChild(noResultsMessage);
|
|
94
|
+
}
|
|
95
|
+
noResultsMessage.style.display = '';
|
|
96
|
+
} else {
|
|
97
|
+
if (noResultsMessage) {
|
|
98
|
+
noResultsMessage.style.display = 'none';
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
render() {
|
|
105
|
+
return html`
|
|
106
|
+
<zn-input placeholder="Filter" clearable type="search" @zn-input=${this.handleSearchChange}
|
|
107
|
+
style="margin-bottom: var(--zn-spacing-small)">
|
|
108
|
+
<zn-icon src="search" slot="prefix"></zn-icon>
|
|
109
|
+
</zn-input>
|
|
110
|
+
<slot></slot> `;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import '../../../dist/zn.min.js';
|
|
2
|
+
import { expect, fixture, html } from '@open-wc/testing';
|
|
3
|
+
|
|
4
|
+
describe('<zn-filter-container>', () => {
|
|
5
|
+
it('should render a component', async () => {
|
|
6
|
+
const el = await fixture(html` <zn-filter-container></zn-filter-container> `);
|
|
7
|
+
|
|
8
|
+
expect(el).to.exist;
|
|
9
|
+
});
|
|
10
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import ZnFilterContainer from './filter-container.component';
|
|
2
|
+
|
|
3
|
+
export * from './filter-container.component';
|
|
4
|
+
export default ZnFilterContainer;
|
|
5
|
+
|
|
6
|
+
ZnFilterContainer.define('zn-filter-container');
|
|
7
|
+
|
|
8
|
+
declare global {
|
|
9
|
+
interface HTMLElementTagNameMap {
|
|
10
|
+
'zn-filter-container': ZnFilterContainer;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -47,7 +47,7 @@ export default class ZnFilterWrapper extends ZincElement {
|
|
|
47
47
|
event.preventDefault();
|
|
48
48
|
const dataTable: ZnDataTable | null = this.closest('zn-data-table');
|
|
49
49
|
if (dataTable) {
|
|
50
|
-
const allowedInputs = ['zn-input', 'zn-select', 'zn-query-builder', 'zn-data-select', 'input', 'select', 'textarea'];
|
|
50
|
+
const allowedInputs = ['zn-input', 'zn-select', 'zn-query-builder', 'zn-data-select', 'zn-datepicker', 'input', 'select', 'textarea'];
|
|
51
51
|
const inputs = Array.from(this.querySelectorAll(allowedInputs.join(','))) as AllowedInputElement[];
|
|
52
52
|
const params: Record<string, any> = {};
|
|
53
53
|
inputs.forEach(input => {
|
|
@@ -35,7 +35,6 @@ export default class ZnFormGroup extends ZincElement {
|
|
|
35
35
|
/** The form groups help text. If you need to display HTML, use the `help-text` slot instead. */
|
|
36
36
|
@property({attribute: 'help-text'}) helpText = '';
|
|
37
37
|
|
|
38
|
-
|
|
39
38
|
render() {
|
|
40
39
|
const hasLabelSlot = this.hasSlotController.test('label');
|
|
41
40
|
const hasLabelTooltipSlot = this.hasSlotController.test('label-tooltip');
|
|
@@ -57,32 +56,33 @@ export default class ZnFormGroup extends ZincElement {
|
|
|
57
56
|
aria-describedby="help-text">
|
|
58
57
|
|
|
59
58
|
<zn-cols layout="1,2" mc="2" part="form-control-container" class="form-control__container">
|
|
60
|
-
|
|
61
|
-
<
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
<
|
|
71
|
-
<slot
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
59
|
+
${hasLabel ? html`
|
|
60
|
+
<div>
|
|
61
|
+
<label
|
|
62
|
+
part="form-control-label"
|
|
63
|
+
id="label"
|
|
64
|
+
class="form-control__label"
|
|
65
|
+
aria-hidden=${hasLabel ? 'false' : 'true'}>
|
|
66
|
+
<slot name="label">${this.label}</slot>
|
|
67
|
+
${hasLabelTooltip
|
|
68
|
+
? html`
|
|
69
|
+
<zn-tooltip class="form-control--label-tooltip">
|
|
70
|
+
<div slot="content">
|
|
71
|
+
<slot name="label-tooltip">${this.labelTooltip}</slot>
|
|
72
|
+
</div>
|
|
73
|
+
<zn-icon src="info"></zn-icon>
|
|
74
|
+
</zn-tooltip>`
|
|
75
|
+
: ''}
|
|
76
|
+
</label>
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
78
|
+
${hasHelpText ? html`
|
|
79
|
+
<div
|
|
80
|
+
part="form-control-help-text"
|
|
81
|
+
id="help-text"
|
|
82
|
+
class="form-control__help-text">
|
|
83
|
+
<slot name="help-text">${this.helpText}</slot>
|
|
84
|
+
</div>` : html``}
|
|
85
|
+
</div>` : html``}
|
|
86
86
|
|
|
87
87
|
<div part="form-control-input" class="form-control-input">
|
|
88
88
|
<slot></slot>
|
|
@@ -140,15 +140,15 @@ export default class ZnOption extends ZincElement {
|
|
|
140
140
|
})}
|
|
141
141
|
@mouseenter=${this.handleMouseEnter}
|
|
142
142
|
@mouseleave=${this.handleMouseLeave}>
|
|
143
|
+
<slot part="prefix" name="prefix" class="option__prefix"></slot>
|
|
144
|
+
<slot part="label" class="option__label" @slotchange=${this.handleDefaultSlotChange}></slot>
|
|
145
|
+
<slot part="suffix" name="suffix" class="option__suffix"></slot>
|
|
143
146
|
<zn-icon
|
|
144
147
|
part="checked-option-icon"
|
|
145
148
|
class="option__check"
|
|
146
149
|
src="check_small"
|
|
147
150
|
aria-hidden="true"
|
|
148
151
|
></zn-icon>
|
|
149
|
-
<slot part="prefix" name="prefix" class="option__prefix"></slot>
|
|
150
|
-
<slot part="label" class="option__label" @slotchange=${this.handleDefaultSlotChange}></slot>
|
|
151
|
-
<slot part="suffix" name="suffix" class="option__suffix"></slot>
|
|
152
152
|
</div>
|
|
153
153
|
`;
|
|
154
154
|
}
|
|
@@ -20,19 +20,11 @@
|
|
|
20
20
|
line-height: var(--zn-line-height-normal);
|
|
21
21
|
letter-spacing: var(--zn-letter-spacing-normal);
|
|
22
22
|
color: var(--zn-input-color);
|
|
23
|
-
padding: var(--zn-spacing-x-small) var(--zn-spacing-
|
|
23
|
+
padding: var(--zn-spacing-x-small) var(--zn-spacing-small);
|
|
24
24
|
transition: var(--zn-transition-fast) fill;
|
|
25
25
|
cursor: pointer;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
.option--singular:not(.option--selected) {
|
|
29
|
-
padding: var(--zn-spacing-x-small) var(--zn-spacing-2x-large) var(--zn-spacing-x-small) var(--zn-spacing-large);
|
|
30
|
-
|
|
31
|
-
zn-icon {
|
|
32
|
-
display: none;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
28
|
|
|
37
29
|
.option--hover:not(.option--current):not(.option--disabled) {
|
|
38
30
|
background-color: var(--zn-color-primary-100);
|
|
@@ -73,6 +65,10 @@
|
|
|
73
65
|
visibility: visible;
|
|
74
66
|
}
|
|
75
67
|
|
|
68
|
+
.option--selected {
|
|
69
|
+
background-color: var(--zn-color-primary-200);
|
|
70
|
+
}
|
|
71
|
+
|
|
76
72
|
.option__prefix,
|
|
77
73
|
.option__suffix {
|
|
78
74
|
flex: 0 0 auto;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {classMap} from "lit/directives/class-map.js";
|
|
2
2
|
import {type CSSResultGroup, html, unsafeCSS} from 'lit';
|
|
3
|
+
import {property} from 'lit/decorators.js';
|
|
3
4
|
import ZincElement from '../../internal/zinc-element';
|
|
4
5
|
|
|
5
6
|
import styles from './progress-tile.scss';
|
|
6
|
-
import {classMap} from "lit/directives/class-map.js";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @summary Short summary of the component's intended use.
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import {property} from 'lit/decorators.js';
|
|
2
|
+
import {type CSSResultGroup, html, unsafeCSS} from 'lit';
|
|
3
|
+
import ZincElement from '../../internal/zinc-element';
|
|
4
|
+
|
|
5
|
+
import styles from './reveal.scss';
|
|
6
|
+
import {classMap} from "lit/directives/class-map.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @summary Short summary of the component's intended use.
|
|
10
|
+
* @documentation https://zinc.style/components/reveal
|
|
11
|
+
* @status experimental
|
|
12
|
+
* @since 1.0
|
|
13
|
+
*
|
|
14
|
+
* @dependency zn-example
|
|
15
|
+
*
|
|
16
|
+
* @event zn-event-name - Emitted as an example.
|
|
17
|
+
*
|
|
18
|
+
* @slot - The default slot.
|
|
19
|
+
* @slot example - An example slot.
|
|
20
|
+
*
|
|
21
|
+
* @csspart base - The component's base wrapper.
|
|
22
|
+
*
|
|
23
|
+
* @usage
|
|
24
|
+
* ```html
|
|
25
|
+
* <zn-reveal duration="3000"
|
|
26
|
+
* initial="******@hotmail.com"
|
|
27
|
+
* revealed="john.doe@hotmail.com" toggle>
|
|
28
|
+
* </zn-reveal>
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @cssproperty --example - An example CSS custom property.
|
|
32
|
+
*/
|
|
33
|
+
export default class ZnReveal extends ZincElement {
|
|
34
|
+
static styles: CSSResultGroup = unsafeCSS(styles);
|
|
35
|
+
|
|
36
|
+
@property({type: Number}) duration: number = 2000;
|
|
37
|
+
|
|
38
|
+
@property() initial: string = '';
|
|
39
|
+
|
|
40
|
+
@property() revealed: string = '';
|
|
41
|
+
|
|
42
|
+
private _isRevealed: boolean = false;
|
|
43
|
+
private _isToggled: boolean = false;
|
|
44
|
+
|
|
45
|
+
protected handleToggleReveal() {
|
|
46
|
+
if (this.duration) {
|
|
47
|
+
this._isRevealed = true;
|
|
48
|
+
this._isToggled = true;
|
|
49
|
+
|
|
50
|
+
this.requestUpdate();
|
|
51
|
+
|
|
52
|
+
setTimeout(() => {
|
|
53
|
+
this._isRevealed = false;
|
|
54
|
+
this._isToggled = false;
|
|
55
|
+
this.requestUpdate();
|
|
56
|
+
}, this.duration);
|
|
57
|
+
} else {
|
|
58
|
+
this._isRevealed = !this._isRevealed;
|
|
59
|
+
this._isToggled = !this._isToggled;
|
|
60
|
+
this.requestUpdate();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
protected handleMouseEnter() {
|
|
65
|
+
// handle hover only while hovered
|
|
66
|
+
this._isRevealed = true;
|
|
67
|
+
this.requestUpdate();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
protected handleMouseLeave() {
|
|
71
|
+
if (this._isToggled) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
this._isRevealed = false;
|
|
75
|
+
this.requestUpdate();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
render() {
|
|
79
|
+
return html`
|
|
80
|
+
<div class=${classMap({
|
|
81
|
+
'reveal': true,
|
|
82
|
+
'reveal--revealed': this._isRevealed,
|
|
83
|
+
'reveal--toggled': this._isToggled,
|
|
84
|
+
})}
|
|
85
|
+
@click="${this.handleToggleReveal}"
|
|
86
|
+
@mouseenter="${this.handleMouseEnter}"
|
|
87
|
+
@mouseleave="${this.handleMouseLeave}">
|
|
88
|
+
${this._isRevealed ? this.revealed : this.initial}
|
|
89
|
+
</div>
|
|
90
|
+
`;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import '../../../dist/zn.min.js';
|
|
2
|
+
import { expect, fixture, html } from '@open-wc/testing';
|
|
3
|
+
|
|
4
|
+
describe('<zn-reveal>', () => {
|
|
5
|
+
it('should render a component', async () => {
|
|
6
|
+
const el = await fixture(html` <zn-reveal></zn-reveal> `);
|
|
7
|
+
|
|
8
|
+
expect(el).to.exist;
|
|
9
|
+
});
|
|
10
|
+
});
|