@kubex/zinc 1.0.12 → 1.0.13

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.
Files changed (44) hide show
  1. package/dist/custom-elements.json +2493 -2156
  2. package/dist/vscode.html-custom-data.json +185 -155
  3. package/dist/web-types.json +420 -334
  4. package/dist/zn.d.ts +125 -15
  5. package/dist/zn.min.css +1 -1
  6. package/dist/zn.min.js +541 -518
  7. package/docs/pages/components/data-select.md +1 -1
  8. package/docs/pages/components/filter-container.md +72 -0
  9. package/docs/pages/components/filter-wrapper.md +2 -2
  10. package/docs/pages/components/hover-container.md +20 -0
  11. package/docs/pages/components/reveal.md +24 -0
  12. package/docs/pages/components/select.md +39 -1
  13. package/docs/pages/components/toggle.md +6 -3
  14. package/package.json +1 -1
  15. package/scss/_root.scss +4 -4
  16. package/src/components/button/button.component.ts +11 -5
  17. package/src/components/data-select/data-select.component.ts +5 -2
  18. package/src/components/dropdown/dropdown.component.ts +3 -0
  19. package/src/components/filter-container/filter-container.component.ts +112 -0
  20. package/src/components/filter-container/filter-container.scss +5 -0
  21. package/src/components/filter-container/filter-container.test.ts +10 -0
  22. package/src/components/filter-container/index.ts +12 -0
  23. package/src/components/form-group/form-group.component.ts +26 -25
  24. package/src/components/form-group/form-group.scss +1 -0
  25. package/src/components/header/header.scss +7 -0
  26. package/src/components/navbar/navbar.scss +4 -0
  27. package/src/components/note/note.component.ts +1 -0
  28. package/src/components/option/option.component.ts +3 -3
  29. package/src/components/option/option.scss +5 -9
  30. package/src/components/progress-bar/progress-bar.component.ts +1 -1
  31. package/src/components/progress-tile/progress-tile.component.ts +2 -2
  32. package/src/components/reveal/index.ts +12 -0
  33. package/src/components/reveal/reveal.component.ts +92 -0
  34. package/src/components/reveal/reveal.scss +18 -0
  35. package/src/components/reveal/reveal.test.ts +10 -0
  36. package/src/components/select/select.component.ts +63 -7
  37. package/src/components/sp/sp.component.ts +2 -0
  38. package/src/components/split-pane/split-pane.component.ts +2 -1
  39. package/src/components/toggle/toggle.component.ts +33 -23
  40. package/src/components/tooltip/tooltip.component.ts +10 -5
  41. package/src/internal/form.ts +5 -0
  42. package/src/utilities/top-layer-manager.ts +32 -0
  43. package/src/wc.scss +9 -5
  44. package/src/zinc.ts +2 -0
@@ -1,9 +1,9 @@
1
- import {property} from 'lit/decorators.js';
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,12 @@
1
+ import ZnReveal from './reveal.component';
2
+
3
+ export * from './reveal.component';
4
+ export default ZnReveal;
5
+
6
+ ZnReveal.define('zn-reveal');
7
+
8
+ declare global {
9
+ interface HTMLElementTagNameMap {
10
+ 'zn-reveal': ZnReveal;
11
+ }
12
+ }
@@ -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,18 @@
1
+ @use "../../wc";
2
+
3
+ :host {
4
+ display: inline-block;
5
+ cursor: pointer;
6
+ }
7
+
8
+
9
+ .reveal {
10
+ }
11
+
12
+ .reveal--revealed{
13
+ // reveal is showing
14
+ }
15
+
16
+ .reveal--toggled {
17
+ // reveal has been toggled
18
+ }
@@ -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
+ });
@@ -1,6 +1,6 @@
1
1
  import {animateTo, stopAnimations} from '../../internal/animate.js';
2
2
  import {classMap} from "lit/directives/class-map.js";
3
- import {type CSSResultGroup, html, nothing, type TemplateResult, unsafeCSS} from 'lit';
3
+ import {type CSSResultGroup, html, nothing, type TemplateResult, unsafeCSS, PropertyValues} from 'lit';
4
4
  import {FormControlController} from "../../internal/form";
5
5
  import {getAnimation, setDefaultAnimation} from "../../utilities/animation-registry";
6
6
  import {HasSlotController} from "../../internal/slot";
@@ -10,11 +10,11 @@ import {scrollIntoView} from "../../internal/scroll";
10
10
  import {unsafeHTML} from "lit/directives/unsafe-html.js";
11
11
  import {waitForEvent} from "../../internal/event";
12
12
  import {watch} from '../../internal/watch';
13
+ import type {ZincFormControl} from '../../internal/zinc-element';
13
14
  import ZincElement from '../../internal/zinc-element';
14
15
  import ZnChip from "../chip";
15
16
  import ZnIcon from "../icon";
16
17
  import ZnPopup from "../popup";
17
- import type {ZincFormControl} from '../../internal/zinc-element';
18
18
  import type {ZnRemoveEvent} from "../../events/zn-remove";
19
19
  import type ZnOption from "../option";
20
20
 
@@ -224,14 +224,21 @@ export default class ZnSelect extends ZincElement implements ZincFormControl {
224
224
  remove-button:tag__remove-button,
225
225
  remove-button__base:tag__remove-button__base"
226
226
  ?pill=${this.pill}
227
- size=${this.size}
227
+ size="x-small"
228
+ type="primary"
228
229
  removable
229
230
  @zn-remove=${(event: ZnRemoveEvent) => this.handleTagRemove(event, option)}>
230
231
  ${option.getTextLabel()}
232
+ <zn-icon slot="action" src="close" size="16"
233
+ @click=${(e: any) => this.handleTagRemove(e as ZnRemoveEvent, option)}></zn-icon>
231
234
  </zn-chip>
232
235
  `;
233
236
  };
234
237
 
238
+ @property() distinct = "";
239
+
240
+ @property() conditional = "";
241
+
235
242
  /** Gets the validity state object */
236
243
  get validity() {
237
244
  return this.valueInput?.validity;
@@ -307,10 +314,13 @@ export default class ZnSelect extends ZincElement implements ZincFormControl {
307
314
  private handleDocumentKeyDown = (event: KeyboardEvent) => {
308
315
  const target = event.target as HTMLElement;
309
316
  const isClearButton = target.closest('.select__clear') !== null;
310
- const isIconButton = target.closest('zn-icon-button') !== null;
317
+ const isIconButton = target.closest('zn-icon') !== null;
318
+
319
+ // and isn't keyboard_arrow_down icon
320
+ const isExpandIcon = target.closest('.select__expand-icon') !== null;
311
321
 
312
322
  // Ignore presses when the target is an icon button (e.g. the remove button in <zn-tag>)
313
- if (isClearButton || isIconButton) {
323
+ if ((isClearButton || isIconButton) && !isExpandIcon) {
314
324
  return;
315
325
  }
316
326
 
@@ -448,10 +458,12 @@ export default class ZnSelect extends ZincElement implements ZincFormControl {
448
458
 
449
459
  private handleComboboxMouseDown(event: MouseEvent) {
450
460
  const path = event.composedPath();
451
- const isIconButton = path.some(el => el instanceof Element && el.tagName.toLowerCase() === 'zn-icon-button');
461
+ const isIcon = path.some(el => el instanceof Element && el.tagName.toLowerCase() === 'zn-icon');
452
462
 
463
+ // not the keyboard_arrow_down icon
464
+ const isExpandIcon = path.some(el => el instanceof Element && el.classList.contains('select__expand-icon'));
453
465
  // Ignore disabled controls and clicks on tags (remove buttons)
454
- if (this.disabled || isIconButton) {
466
+ if ((this.disabled || isIcon) && !isExpandIcon) {
455
467
  return;
456
468
  }
457
469
 
@@ -550,6 +562,7 @@ export default class ZnSelect extends ZincElement implements ZincFormControl {
550
562
 
551
563
  private handleTagRemove(event: ZnRemoveEvent, option: ZnOption) {
552
564
  event.stopPropagation();
565
+ event.stopImmediatePropagation();
553
566
 
554
567
  if (!this.disabled) {
555
568
  this.toggleOptionSelection(option, false);
@@ -679,6 +692,49 @@ export default class ZnSelect extends ZincElement implements ZincFormControl {
679
692
  this.formControlController.emitInvalidEvent(event);
680
693
  }
681
694
 
695
+ protected firstUpdated(_changedProperties: PropertyValues) {
696
+ super.firstUpdated(_changedProperties);
697
+
698
+ if (this.distinct !== "") {
699
+ // if we are linked to another zn-data-select remove the selected values from that select from this select
700
+ const linkedSelect = document.querySelector(`zn-select[id="${this.distinct}"]`) as ZnSelect;
701
+ if (linkedSelect) {
702
+ linkedSelect.addEventListener('zn-change', () => {
703
+ const linkedValues = Array.isArray(linkedSelect.value) ? linkedSelect.value : [linkedSelect.value];
704
+ const options = this.getAllOptions().map(option => option as HTMLElement);
705
+ options.forEach(option => {
706
+ if (linkedValues.includes((option as ZnOption).value)) {
707
+ option.style.display = 'none';
708
+ } else {
709
+ option.style.display = '';
710
+ }
711
+ });
712
+ });
713
+
714
+ // trigger the event once to initialize
715
+ linkedSelect.dispatchEvent(new Event('zn-input'));
716
+ }
717
+
718
+ }
719
+
720
+ if (this.conditional !== "") {
721
+ const conditionalSelect = document.querySelector(`zn-select[id="${this.conditional}"]`) as ZnSelect;
722
+ console.log('conditionalSelect', conditionalSelect);
723
+ if (conditionalSelect) {
724
+ // disable if the other has any options selected
725
+ conditionalSelect.addEventListener('zn-change', () => {
726
+ let linkedValues = Array.isArray(conditionalSelect.value) ? conditionalSelect.value : [conditionalSelect.value];
727
+ linkedValues = linkedValues.filter(v => v !== '');
728
+ console.log('linkedValues', linkedValues);
729
+ this.disabled = linkedValues.length > 0;
730
+ });
731
+
732
+ // trigger the event once to initialize
733
+ conditionalSelect.dispatchEvent(new Event('zn-input'));
734
+ }
735
+ }
736
+ }
737
+
682
738
  @watch('disabled', {waitUntilFirstUpdate: true})
683
739
  handleDisabledChange() {
684
740
  // Close the listbox when the control is disabled
@@ -52,6 +52,7 @@ export default class ZnSp extends ZincElement {
52
52
  @property({attribute: 'flush-r', type: Boolean, reflect: true}) flushR: boolean = false;
53
53
  @property({attribute: 'width-container', type: Boolean, reflect: true}) widthContainer: boolean = false;
54
54
  @property({attribute: 'form-container', type: Boolean, reflect: true}) formContainer: boolean = false;
55
+ @property({attribute: 'wide-form-container', type: Boolean, reflect: true}) wideFormContainer: boolean = false;
55
56
 
56
57
  connectedCallback() {
57
58
  if (this.gap) {
@@ -81,6 +82,7 @@ export default class ZnSp extends ZincElement {
81
82
  'sp--flush-r': this.flushR,
82
83
  'width-container': this.widthContainer,
83
84
  'form-container': this.formContainer,
85
+ 'wide-form-container': this.wideFormContainer,
84
86
  })}">
85
87
  <slot></slot>
86
88
  </div>`;
@@ -106,7 +106,8 @@ export default class ZnSplitPane extends ZincElement {
106
106
 
107
107
  this.mouseMoveHandler = function (e: any) {
108
108
  let offset = (this.vertical ? e.y : e.x);
109
- if (e instanceof TouchEvent) {
109
+ //'touches' in e fixes Safari
110
+ if ('touches' in e && e instanceof TouchEvent) {
110
111
  offset = (this.vertical ? e.touches[0].clientY : e.touches[0].clientX);
111
112
  }
112
113
  this.setSize(offset - pageOffset);
@@ -163,6 +163,34 @@ export default class ZnToggle extends ZincElement implements ZincFormControl {
163
163
  />`;
164
164
  }
165
165
 
166
+ const tooltipContent = this.checked ? this.onText : this.offText;
167
+ const showTooltip = !!tooltipContent;
168
+
169
+ const toggle = html`
170
+ <div class="switch__input-wrapper" part="base">
171
+ ${fallback}
172
+ <input
173
+ class="switch__input"
174
+ type="checkbox"
175
+ title=${this.title}
176
+ name=${this.name}
177
+ value=${ifDefined(this.value)}
178
+ .checked=${live(this.checked)}
179
+ .disabled=${this.disabled}
180
+ .required=${this.required}
181
+ role="switch"
182
+ aria-checked=${this.checked ? 'true' : 'false'}
183
+ aria-describedby="help-text"
184
+ @click=${this.handleClick}
185
+ @input=${this.handleInput}
186
+ @invalid=${this.handleInvalid}
187
+ @blur=${this.handleBlur}
188
+ @focus=${this.handleFocus}
189
+ @keydown=${this.handleKeyDown}
190
+ />
191
+ <span part="control" class="switch__control"></span>
192
+ </div>`;
193
+
166
194
  return html`
167
195
  <div class="${classMap({
168
196
  'switch__wrapper': true,
@@ -174,29 +202,11 @@ export default class ZnToggle extends ZincElement implements ZincFormControl {
174
202
  })}">
175
203
  <label>
176
204
  ${this.label ? html`<p class="switch-label">${this.label}</p>` : ''}
177
- <div class="switch__input-wrapper" part="base">
178
- ${fallback}
179
- <input
180
- class="switch__input"
181
- type="checkbox"
182
- title=${this.title}
183
- name=${this.name}
184
- value=${ifDefined(this.value)}
185
- .checked=${live(this.checked)}
186
- .disabled=${this.disabled}
187
- .required=${this.required}
188
- role="switch"
189
- aria-checked=${this.checked ? 'true' : 'false'}
190
- aria-describedby="help-text"
191
- @click=${this.handleClick}
192
- @input=${this.handleInput}
193
- @invalid=${this.handleInvalid}
194
- @blur=${this.handleBlur}
195
- @focus=${this.handleFocus}
196
- @keydown=${this.handleKeyDown}
197
- />
198
- <span part="control" class="switch__control"></span>
199
- </div>
205
+ ${!showTooltip ? html`
206
+ ${toggle}` : html`
207
+ <zn-tooltip content="${tooltipContent}">
208
+ ${toggle}
209
+ </zn-tooltip>`}
200
210
  </label>
201
211
  </div>`;
202
212
  }
@@ -3,6 +3,7 @@ import {type CSSResultGroup, html, type PropertyValues, unsafeCSS} from 'lit';
3
3
  import {property, query} from 'lit/decorators.js';
4
4
  import {waitForEvent} from "../../internal/event";
5
5
  import {watch} from '../../internal/watch';
6
+ import topLayerManager from '../../utilities/top-layer-manager';
6
7
  import ZincElement from '../../internal/zinc-element';
7
8
  import type Popup from "../popup";
8
9
 
@@ -82,13 +83,13 @@ export default class ZnTooltip extends ZincElement {
82
83
  }
83
84
 
84
85
  private handleBlur = () => {
85
- if (this.hasTrigger('focus')) {
86
+ if (this.hasTrigger('focus') && !topLayerManager.isDropdownOpen()) {
86
87
  this.hide();
87
88
  }
88
89
  };
89
90
 
90
91
  private handleClick = () => {
91
- if (this.hasTrigger('click')) {
92
+ if (this.hasTrigger('click') && !topLayerManager.isDropdownOpen()) {
92
93
  if (this.open) {
93
94
  this.hide()
94
95
  }
@@ -97,7 +98,7 @@ export default class ZnTooltip extends ZincElement {
97
98
  };
98
99
 
99
100
  private handleFocus = () => {
100
- if (this.hasTrigger('focus')) {
101
+ if (this.hasTrigger('focus') && !topLayerManager.isDropdownOpen()) {
101
102
  this.show();
102
103
  }
103
104
  };
@@ -110,14 +111,14 @@ export default class ZnTooltip extends ZincElement {
110
111
  };
111
112
 
112
113
  private handleMouseOver() {
113
- if (this.hasTrigger('hover')) {
114
+ if (this.hasTrigger('hover') && !topLayerManager.isDropdownOpen()) {
114
115
  clearTimeout(this.hoverTimeout);
115
116
  this.hoverTimeout = window.setTimeout(() => this.show(), 0);
116
117
  }
117
118
  }
118
119
 
119
120
  private handleMouseOut() {
120
- if (this.hasTrigger('hover')) {
121
+ if (this.hasTrigger('hover') && !topLayerManager.isDropdownOpen()) {
121
122
  clearTimeout(this.hoverTimeout);
122
123
  this.hoverTimeout = window.setTimeout(() => this.hide(), 0);
123
124
  }
@@ -126,6 +127,8 @@ export default class ZnTooltip extends ZincElement {
126
127
  @watch('open', {waitUntilFirstUpdate: true})
127
128
  handleOpenChange() {
128
129
  if (this.open) {
130
+ topLayerManager.registerTooltip(this);
131
+
129
132
  if (this.disabled) {
130
133
  return;
131
134
  }
@@ -145,6 +148,8 @@ export default class ZnTooltip extends ZincElement {
145
148
  this.popup.reposition();
146
149
  this.emit('zn-after-show');
147
150
  } else {
151
+ topLayerManager.unregisterTooltip(this);
152
+
148
153
  this.emit('zn-hide');
149
154
  this.popup.active = false;
150
155
  this.body.hidden = true;
@@ -309,6 +309,11 @@ export class FormControlController implements ReactiveController {
309
309
  ? this.form?.getAttribute('data-loading-text') || 'Processing...'
310
310
  : content;
311
311
  }, 20);
312
+
313
+ setTimeout(() => {
314
+ submitButton.disabled = false;
315
+ submitButton.innerHTML = content;
316
+ }, 15000);
312
317
  }
313
318
 
314
319
  if (this.form && !this.form.noValidate && !disabled && !reportValidity(this.host)) {
@@ -0,0 +1,32 @@
1
+ class TopLayerManager {
2
+ private openDropdowns: Set<HTMLElement> = new Set();
3
+ private openTooltips: Set<HTMLElement> = new Set();
4
+
5
+ registerDropdown(el: HTMLElement) {
6
+ this.openDropdowns.add(el);
7
+ }
8
+
9
+ unregisterDropdown(el: HTMLElement) {
10
+ this.openDropdowns.delete(el);
11
+ }
12
+
13
+ isDropdownOpen() {
14
+ return this.openDropdowns.size > 0;
15
+ }
16
+
17
+ registerTooltip(el: HTMLElement) {
18
+ this.openTooltips.add(el);
19
+ }
20
+
21
+ unregisterTooltip(el: HTMLElement) {
22
+ this.openTooltips.delete(el);
23
+ }
24
+
25
+ isTooltipOpen() {
26
+ return this.openTooltips.size > 0;
27
+ }
28
+ }
29
+
30
+ const topLayerManager = new TopLayerManager();
31
+
32
+ export default topLayerManager;
package/src/wc.scss CHANGED
@@ -25,16 +25,20 @@
25
25
  display: none !important;
26
26
  }
27
27
 
28
- .width-container {
28
+ .width-container, .form-container, .wide-form-container {
29
29
  height: 100%;
30
30
  width: 100%;
31
- max-width: var(--zn-container);
32
31
  margin: 0 auto;
33
32
  }
34
33
 
34
+ .width-container {
35
+ max-width: var(--zn-container);
36
+ }
37
+
35
38
  .form-container {
36
- height: 100%;
37
- width: 100%;
38
39
  max-width: var(--zn-container-ph);
39
- margin: 0 auto;
40
+ }
41
+
42
+ .wide-form-container {
43
+ max-width: var(--zn-container-lg);
40
44
  }
package/src/zinc.ts CHANGED
@@ -80,6 +80,8 @@ export {default as Style} from './components/style';
80
80
  export {default as ContentBlock} from './components/content-block';
81
81
  export {default as FilterWrapper} from './components/filter-wrapper';
82
82
  export {default as SettingsContainer} from './components/settings-container';
83
+ export { default as FilterContainer } from './components/filter-container';
84
+ export { default as Reveal } from './components/reveal';
83
85
  /* plop:component */
84
86
 
85
87
  // Base Component