@kubex/zinc 1.1.97 → 1.1.99

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 (85) hide show
  1. package/AGENTS.md +5 -0
  2. package/CLAUDE.md +5 -0
  3. package/dist/chunks/zn.R2EAU6OS.js +1 -0
  4. package/dist/custom-elements.json +14747 -12528
  5. package/dist/vscode.html-custom-data.json +386 -61
  6. package/dist/web-types.json +1232 -481
  7. package/dist/zn.d.ts +529 -11
  8. package/dist/zn.min.js +649 -478
  9. package/docs/pages/components/background.md +143 -0
  10. package/docs/pages/components/button.md +11 -1
  11. package/docs/pages/components/chart.md +165 -3
  12. package/docs/pages/components/checkbox-group.md +13 -1
  13. package/docs/pages/components/checkbox.md +59 -1
  14. package/docs/pages/components/icon-picker.md +8 -0
  15. package/docs/pages/components/radio-group.md +12 -0
  16. package/docs/pages/components/radio.md +188 -0
  17. package/docs/pages/components/remarkd-editor.md +22 -0
  18. package/docs/pages/components/scroll-container.md +14 -15
  19. package/docs/pages/components/thumbnail-group.md +216 -0
  20. package/docs/pages/components/thumbnail.md +349 -0
  21. package/docs/pages/components/well.md +34 -0
  22. package/package.json +1 -1
  23. package/src/components/background/background.component.ts +111 -0
  24. package/src/components/background/background.scss +236 -0
  25. package/src/components/background/background.test.ts +120 -0
  26. package/src/components/background/index.ts +12 -0
  27. package/src/components/button/button.component.ts +8 -0
  28. package/src/components/chart/builders.test.ts +190 -1
  29. package/src/components/chart/builders.ts +246 -4
  30. package/src/components/chart/chart.component.ts +33 -1
  31. package/src/components/chart/chart.test.ts +66 -1
  32. package/src/components/chart/echarts-loader.ts +10 -0
  33. package/src/components/checkbox/checkbox.component.ts +62 -6
  34. package/src/components/checkbox/checkbox.scss +1 -0
  35. package/src/components/checkbox/checkbox.test.ts +56 -0
  36. package/src/components/checkbox-group/checkbox-group.component.ts +15 -0
  37. package/src/components/checkbox-group/checkbox-group.scss +23 -5
  38. package/src/components/checkbox-group/checkbox-group.test.ts +15 -0
  39. package/src/components/collapsible/collapsible.component.ts +49 -4
  40. package/src/components/collapsible/collapsible.scss +33 -14
  41. package/src/components/confirm/confirm.component.ts +3 -3
  42. package/src/components/confirm/confirm.test.ts +15 -0
  43. package/src/components/dialog/dialog.component.ts +3 -2
  44. package/src/components/editor/editor.component.ts +7 -6
  45. package/src/components/header/header.scss +2 -2
  46. package/src/components/icon-picker/icon-picker.component.ts +3 -0
  47. package/src/components/icon-picker/lucide-icons.ts +1756 -0
  48. package/src/components/navbar/navbar.scss +11 -0
  49. package/src/components/page/page.scss +1 -1
  50. package/src/components/radio/radio.component.ts +63 -7
  51. package/src/components/radio/radio.scss +1 -0
  52. package/src/components/radio/radio.test.ts +56 -0
  53. package/src/components/radio-group/radio-group.component.ts +16 -3
  54. package/src/components/radio-group/radio-group.scss +23 -4
  55. package/src/components/radio-group/radio-group.test.ts +15 -0
  56. package/src/components/remarkd-editor/remarkd-editor.component.ts +118 -5
  57. package/src/components/remarkd-editor/remarkd-editor.scss +8 -1
  58. package/src/components/remarkd-editor/remarkd-editor.test.ts +135 -0
  59. package/src/components/scroll-container/scroll-container.component.ts +15 -1
  60. package/src/components/scroll-container/scroll-container.scss +4 -2
  61. package/src/components/scroll-container/scroll-container.test.ts +13 -0
  62. package/src/components/slideout/slideout.component.ts +3 -2
  63. package/src/components/split-pane/split-pane.scss +21 -15
  64. package/src/components/thumbnail/index.ts +12 -0
  65. package/src/components/thumbnail/thumbnail.component.ts +460 -0
  66. package/src/components/thumbnail/thumbnail.scss +360 -0
  67. package/src/components/thumbnail/thumbnail.test.ts +379 -0
  68. package/src/components/thumbnail-group/index.ts +12 -0
  69. package/src/components/thumbnail-group/thumbnail-group.component.ts +268 -0
  70. package/src/components/thumbnail-group/thumbnail-group.scss +86 -0
  71. package/src/components/thumbnail-group/thumbnail-group.test.ts +151 -0
  72. package/src/components/tile/tile.scss +4 -2
  73. package/src/components/translation-group/translation-group.test.ts +22 -0
  74. package/src/components/translations/translations.component.ts +18 -3
  75. package/src/components/well/well.component.ts +22 -4
  76. package/src/components/well/well.scss +24 -0
  77. package/src/components/well/well.test.ts +43 -0
  78. package/src/form-control.scss +3 -1
  79. package/src/internal/conditional.ts +2 -2
  80. package/src/internal/form.ts +2 -1
  81. package/src/internal/selection-card.ts +19 -0
  82. package/src/selection-card.scss +187 -0
  83. package/src/utilities/query.test.ts +18 -1
  84. package/src/utilities/query.ts +8 -0
  85. package/src/zinc.ts +3 -0
@@ -34,6 +34,8 @@ import styles from './checkbox-group.scss';
34
34
  * @csspart form-control-label - The label's wrapper.
35
35
  * @csspart form-control-input - The input's wrapper.
36
36
  * @csspart form-control-help-text - The help text's wrapper.
37
+ *
38
+ * @cssproperty --zn-checkbox-group-column-width - Minimum column width used by the horizontal contained grid, or the card basis when `wrap` is set.
37
39
  */
38
40
  export default class ZnCheckboxGroup extends ZincElement implements ZincFormControl {
39
41
  static styles: CSSResultGroup = unsafeCSS(styles);
@@ -75,6 +77,15 @@ export default class ZnCheckboxGroup extends ZincElement implements ZincFormCont
75
77
  /** The checkbox group's style. Changes the group's style from the default (plain) style to the 'contained' style. This style will be applied to all child checkboxes. */
76
78
  @property({type: Boolean, reflect: true}) contained = false;
77
79
 
80
+ /** Squares off the corners of every contained checkbox in the group, which are rounded by default. */
81
+ @property({type: Boolean, reflect: true}) square = false;
82
+
83
+ /**
84
+ * Lays horizontal contained checkboxes out as a wrapping row instead of an equal-width grid, so each one sizes from
85
+ * `--zn-checkbox-group-column-width` (set it to `auto` to size from content) and wraps onto a new line when needed.
86
+ */
87
+ @property({type: Boolean, reflect: true}) wrap = false;
88
+
78
89
  /**
79
90
  * By default, form controls are associated with the nearest containing `<form>` element. This attribute allows you
80
91
  * to place the form control outside of a form and associate it with the form that has this `id`. The form must be in
@@ -158,6 +169,10 @@ export default class ZnCheckboxGroup extends ZincElement implements ZincFormCont
158
169
  checkbox.size = this.size;
159
170
  checkbox.horizontal = this.horizontal;
160
171
 
172
+ if (this.square) {
173
+ checkbox.square = true;
174
+ }
175
+
161
176
  // Add class to checkboxes in a Checkbox Group so that we can style them without using :slotted
162
177
  checkbox.classList.add('groupedCheckbox');
163
178
 
@@ -8,8 +8,9 @@
8
8
 
9
9
  :host([horizontal]) .form-control-input {
10
10
  display: flex;
11
- column-gap: var(--zn-spacing-2x-large);
12
11
  flex-wrap: wrap;
12
+ column-gap: var(--zn-spacing-2x-large);
13
+ row-gap: var(--zn-spacing-small);
13
14
  }
14
15
 
15
16
  ::slotted(zn-checkbox[horizontal]) {
@@ -17,15 +18,16 @@
17
18
  min-width: 100px;
18
19
  }
19
20
 
20
- :host([contained]) .form-control-input {
21
+ /* The label supplies the gap above the options, so a group without one starts flush. */
22
+ :host([contained]) .form-control--has-label .form-control-input {
21
23
  margin-top: var(--zn-spacing-medium);
22
24
  }
23
25
 
24
26
  :host([horizontal][contained]) .form-control-input {
25
- margin-top: var(--zn-spacing-medium);
26
27
  display: grid;
27
- grid-template-columns: repeat(auto-fit, minmax(152px, 1fr));
28
- gap: var(--zn-spacing-x-small);
28
+ grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--zn-checkbox-group-column-width, 152px)), 1fr));
29
+ align-items: stretch;
30
+ gap: var(--zn-spacing-small);
29
31
  }
30
32
 
31
33
  ::slotted(zn-checkbox) {
@@ -42,6 +44,22 @@
42
44
  height: 100%;
43
45
  }
44
46
 
47
+ /* `wrap` swaps the equal-width grid for a flex row: cards start from their basis and wrap onto new lines. */
48
+ :host([horizontal][contained][wrap]) .form-control-input {
49
+ display: flex;
50
+ flex-wrap: wrap;
51
+ align-items: stretch;
52
+ gap: var(--zn-spacing-x-small);
53
+ }
54
+
55
+ :host([wrap]) ::slotted(zn-checkbox[horizontal][contained]) {
56
+ flex: 1 1 var(--zn-checkbox-group-column-width, 152px);
57
+ min-width: 0;
58
+
59
+ /* A percentage height would resolve against every line, not the card's own. */
60
+ height: auto;
61
+ }
62
+
45
63
 
46
64
  .form-control {
47
65
  position: relative;
@@ -7,4 +7,19 @@ describe('<zn-checkbox-group>', () => {
7
7
 
8
8
  expect(el).to.exist;
9
9
  });
10
+
11
+ it('propagates contained and square to its checkboxs', async () => {
12
+ const el = await fixture<HTMLElement>(html`
13
+ <zn-checkbox-group contained square>
14
+ <zn-checkbox value="one">One</zn-checkbox>
15
+ <zn-checkbox value="two">Two</zn-checkbox>
16
+ </zn-checkbox-group>
17
+ `);
18
+ await new Promise(resolve => requestAnimationFrame(resolve));
19
+
20
+ el.querySelectorAll('zn-checkbox').forEach(child => {
21
+ expect(child).to.have.attribute('contained');
22
+ expect(child).to.have.attribute('square');
23
+ });
24
+ });
10
25
  });
@@ -52,6 +52,10 @@ export default class ZnCollapsible extends ZincElement {
52
52
 
53
53
  @state() numberOfItems: number = 0;
54
54
 
55
+ @state() private animating: boolean = false;
56
+
57
+ private animatingTimer?: ReturnType<typeof setTimeout>;
58
+
55
59
  protected _store: Store;
56
60
 
57
61
  private readonly hasSlotController = new HasSlotController(this, '[default]', 'header', 'caption', 'label', 'description');
@@ -94,6 +98,11 @@ export default class ZnCollapsible extends ZincElement {
94
98
  }
95
99
  }
96
100
 
101
+ disconnectedCallback() {
102
+ super.disconnectedCallback();
103
+ clearTimeout(this.animatingTimer);
104
+ }
105
+
97
106
  // this is for handling global toggles
98
107
  public handleCaptionToggle = (e: ZnInputEvent) => {
99
108
  const toggle = e.target as ZnToggle;
@@ -104,8 +113,38 @@ export default class ZnCollapsible extends ZincElement {
104
113
 
105
114
  protected updated(changedProperties: PropertyValues) {
106
115
  super.updated(changedProperties);
107
- if (changedProperties.has('expanded') && this.storeKey) {
108
- this._store.set(this.storeKey, this.expanded.toString());
116
+ if (changedProperties.has('expanded')) {
117
+ if (changedProperties.get('expanded') !== undefined) {
118
+ this.startAnimating();
119
+ }
120
+
121
+ if (this.storeKey) {
122
+ this._store.set(this.storeKey, this.expanded.toString());
123
+ }
124
+ }
125
+ }
126
+
127
+ // Content is only clipped while the height transition runs, so expanded
128
+ // content can overflow the host. The timer covers a transitionend that never
129
+ // arrives (reduced motion, hidden host).
130
+ private startAnimating() {
131
+ if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
132
+ return;
133
+ }
134
+
135
+ this.animating = true;
136
+ clearTimeout(this.animatingTimer);
137
+ this.animatingTimer = setTimeout(() => (this.animating = false), 600);
138
+ }
139
+
140
+ private stopAnimating() {
141
+ clearTimeout(this.animatingTimer);
142
+ this.animating = false;
143
+ }
144
+
145
+ private handleTransitionEnd = (e: TransitionEvent) => {
146
+ if (e.target === e.currentTarget && e.propertyName === 'grid-template-rows') {
147
+ this.stopAnimating();
109
148
  }
110
149
  }
111
150
 
@@ -160,8 +199,14 @@ export default class ZnCollapsible extends ZincElement {
160
199
  <zn-icon library="material-outlined" src="expand_more" class="expand"></zn-icon>` : ''}
161
200
  </div>
162
201
  </slot>
163
- <div class=${classMap({ 'content': true, 'content--flush': this.flush, })} part="content">
164
- <slot @slotchange="${this.requestUpdate}"></slot>
202
+ <div class=${classMap({
203
+ 'content': true,
204
+ 'content--flush': this.flush,
205
+ 'content--animating': this.animating,
206
+ })} part="content" @transitionend="${this.handleTransitionEnd}">
207
+ <div class="content__inner">
208
+ <slot @slotchange="${this.requestUpdate}"></slot>
209
+ </div>
165
210
  </div>
166
211
  </div>`;
167
212
  }
@@ -76,29 +76,48 @@
76
76
  }
77
77
  }
78
78
 
79
- :host(:not([flush])).content {
80
- @include wc.padding();
79
+ // Height animates via grid-template-rows 0fr -> 1fr; the inline padding is
80
+ // constant so the content never reflows (and re-wraps) mid-transition.
81
+ .content {
82
+ display: grid;
83
+ grid-template-rows: 0fr;
84
+ opacity: 0;
85
+ transition: grid-template-rows var(--zn-transition-medium) cubic-bezier(0.32, 0.72, 0, 1),
86
+ opacity var(--zn-transition-fast) ease-out;
87
+
88
+ &__inner {
89
+ min-height: 0;
90
+ padding: 0 var(--zn-spacing-medium) var(--zn-spacing-medium);
91
+ transform: translateY(-4px);
92
+ transition: transform var(--zn-transition-medium) cubic-bezier(0.32, 0.72, 0, 1);
93
+ }
94
+
95
+ &--flush &__inner {
96
+ padding: 0;
97
+ }
81
98
  }
82
99
 
83
- .content {
84
- transition: .1s all ease-out;
100
+ // Clipped while collapsed or mid-transition only, so expanded content can still
101
+ // overflow the host (dropdowns, tooltips).
102
+ :host(:not([expanded])) .content,
103
+ .content--animating {
104
+ overflow: hidden;
85
105
  }
86
106
 
87
107
  :host([expanded]) .content {
88
- margin: 0 var(--zn-spacing-medium);
89
- padding-bottom: var(--zn-spacing-medium);
108
+ grid-template-rows: 1fr;
109
+ opacity: 1;
90
110
 
91
- &--flush {
92
- margin: 0;
93
- padding: 0;
111
+ .content__inner {
112
+ transform: none;
94
113
  }
95
114
  }
96
115
 
97
- :host(:not([expanded])) .content {
98
- max-height: 0;
99
- opacity: 0;
100
- overflow: hidden;
101
- padding: 0;
116
+ @media (prefers-reduced-motion: reduce) {
117
+ .content,
118
+ .content__inner {
119
+ transition-duration: 0s;
120
+ }
102
121
  }
103
122
 
104
123
  .expand {
@@ -1,6 +1,6 @@
1
1
  import {classMap} from "lit/directives/class-map.js";
2
2
  import {type CSSResultGroup, html, nothing, type PropertyValues, unsafeCSS} from 'lit';
3
- import {deepQuerySelectorAll} from "../../utilities/query";
3
+ import {deepQuerySelectorAll, idSelector} from "../../utilities/query";
4
4
  import {HasSlotController} from "../../internal/slot";
5
5
  import {ifDefined} from "lit/directives/if-defined.js";
6
6
  import {property, query, state} from 'lit/decorators.js';
@@ -97,7 +97,7 @@ export default class ZnConfirm extends ZincElement {
97
97
  const trigger = this.hasSlotController.getSlot('trigger');
98
98
  trigger?.addEventListener('click', this.show);
99
99
  } else if (this.trigger) {
100
- const triggers = deepQuerySelectorAll('#' + this.trigger, this.parentElement as Element, '');
100
+ const triggers = deepQuerySelectorAll(idSelector(this.trigger), this.parentElement as Element, '');
101
101
  triggers.forEach((el: HTMLButtonElement) => {
102
102
  el.addEventListener('click', this.show);
103
103
  });
@@ -105,7 +105,7 @@ export default class ZnConfirm extends ZincElement {
105
105
  }
106
106
 
107
107
  updateTriggers() {
108
- const triggers = deepQuerySelectorAll('#' + this.trigger, this.parentElement as Element, '');
108
+ const triggers = deepQuerySelectorAll(idSelector(this.trigger), this.parentElement as Element, '');
109
109
  triggers.forEach((el: HTMLButtonElement) => {
110
110
  // if already has a click listener, remove it
111
111
  el.removeEventListener('click', this.show);
@@ -7,4 +7,19 @@ describe('<zn-confirm-modal>', () => {
7
7
 
8
8
  expect(el).to.exist;
9
9
  });
10
+
11
+ it('connects a trigger whose id contains CSS syntax characters', async () => {
12
+ const id = 'delete-enum-cloud_hosting_&_infrastructure';
13
+ const el = await fixture<HTMLElement>(html`
14
+ <div>
15
+ <button id="${id}">Delete</button>
16
+ <zn-confirm trigger="${id}" caption="Delete"></zn-confirm>
17
+ </div>
18
+ `);
19
+ const confirm = el.querySelector<HTMLElement & {updateComplete: Promise<void>}>('zn-confirm')!;
20
+ await confirm.updateComplete;
21
+
22
+ // An unescaped `#id` selector throws a SyntaxError here, leaving the component unrendered.
23
+ expect(confirm.shadowRoot!.querySelector('zn-dialog')).to.exist;
24
+ });
10
25
  });
@@ -1,6 +1,7 @@
1
1
  import {classMap} from "lit/directives/class-map.js";
2
2
  import {type CSSResultGroup, html, type PropertyValues, unsafeCSS} from 'lit';
3
3
  import {HasSlotController} from "../../internal/slot";
4
+ import {idSelector} from "../../utilities/query";
4
5
  import {ifDefined} from "lit/directives/if-defined.js";
5
6
  import {property, query} from 'lit/decorators.js';
6
7
  import {unlockBodyScrolling} from "../../internal/scroll";
@@ -105,7 +106,7 @@ export default class ZnDialog extends ZincElement {
105
106
  this.shadowRoot?.addEventListener('click', this.closeClickHandler);
106
107
 
107
108
  if (this.trigger) {
108
- const trigger = this.parentNode?.querySelector('#' + this.trigger);
109
+ const trigger = this.parentNode?.querySelector(idSelector(this.trigger));
109
110
  if (trigger) {
110
111
  trigger.addEventListener('click', () => this.show());
111
112
  }
@@ -132,7 +133,7 @@ export default class ZnDialog extends ZincElement {
132
133
  this.removeEventListener('click', this.closeClickHandler);
133
134
 
134
135
  if (this.trigger) {
135
- const trigger = this.parentElement?.querySelector('#' + this.trigger);
136
+ const trigger = this.parentElement?.querySelector(idSelector(this.trigger));
136
137
  if (trigger) {
137
138
  trigger.removeEventListener('click', () => this.show());
138
139
  }
@@ -1,5 +1,5 @@
1
1
  import {type CSSResultGroup, html, type PropertyValues, unsafeCSS} from 'lit';
2
- import {deepQuerySelectorAll} from "../../utilities/query";
2
+ import {deepQuerySelectorAll, idSelector} from "../../utilities/query";
3
3
  import {FormControlController} from '../../internal/form';
4
4
  import {on} from "../../utilities/on";
5
5
  import {property, query} from 'lit/decorators.js';
@@ -489,12 +489,13 @@ export default class ZnEditor extends ZincElement implements ZincFormControl {
489
489
 
490
490
  // Find which element contains the content to insert
491
491
  // Priority: currentTarget > selectedTarget > target > composedPath > querySelector
492
+ const contentSelector = idSelector(contentContainer);
492
493
  const contentElement: Element | null =
493
- (e.currentTarget instanceof Element && e.currentTarget.closest('#' + contentContainer)) ||
494
- (e.selectedTarget instanceof Element && e.selectedTarget.closest('#' + contentContainer)) ||
495
- (e.target instanceof Element && e.target.closest('#' + contentContainer)) ||
496
- ((e.composedPath()[0] as Element)?.closest('#' + contentContainer)) ||
497
- deepQuerySelectorAll(`#${contentContainer}`, document.documentElement, '')[0];
494
+ (e.currentTarget instanceof Element && e.currentTarget.closest(contentSelector)) ||
495
+ (e.selectedTarget instanceof Element && e.selectedTarget.closest(contentSelector)) ||
496
+ (e.target instanceof Element && e.target.closest(contentSelector)) ||
497
+ ((e.composedPath()[0] as Element)?.closest(contentSelector)) ||
498
+ deepQuerySelectorAll(contentSelector, document.documentElement, '')[0];
498
499
  if (!contentElement) return;
499
500
 
500
501
  let content = contentElement.textContent;
@@ -24,7 +24,7 @@
24
24
  white-space: nowrap;
25
25
  text-overflow: ellipsis;
26
26
  display: flex;
27
- gap: var(--zn-spacing-x-small);
27
+ gap: var(--zn-spacing-2x-small);
28
28
  align-items: center;
29
29
  text-wrap: auto;
30
30
  }
@@ -110,6 +110,7 @@
110
110
  width: 100%;
111
111
  max-width: 100%;
112
112
  height: fit-content;
113
+ min-height: var(--zn-input-height-medium, 36px);
113
114
  gap: 10px;
114
115
  margin: 0 auto;
115
116
  padding: var(--zn-base-gap);
@@ -226,7 +227,6 @@
226
227
  slot[name="actions"] {
227
228
  justify-content: end;
228
229
  flex-wrap: nowrap;
229
- height: var(--zn-icon-size, 20px);
230
230
  }
231
231
 
232
232
  slot[name="actions"]::slotted(zn-button-menu) {
@@ -131,6 +131,8 @@ export default class ZnIconPicker extends ZincElement implements ZincFormControl
131
131
  return (await import('./brand-icons')).brandIcons;
132
132
  case 'line':
133
133
  return (await import('./line-icons')).lineIcons;
134
+ case 'lucide':
135
+ return (await import('./lucide-icons')).lucideIcons;
134
136
  default: {
135
137
  const lists = await import('./material-icons');
136
138
  switch (library) {
@@ -438,6 +440,7 @@ export default class ZnIconPicker extends ZincElement implements ZincFormControl
438
440
  <zn-option value="material-symbols-outlined">Material Symbols Outlined</zn-option>
439
441
  <zn-option value="brands">Brands</zn-option>
440
442
  <zn-option value="line">Line</zn-option>
443
+ <zn-option value="lucide">Lucide</zn-option>
441
444
  <zn-option value="gravatar">Gravatar</zn-option>
442
445
  <zn-option value="libravatar">Libravatar</zn-option>
443
446
  <zn-option value="avatar">Avatar</zn-option>