@kubex/zinc 1.0.5 → 1.0.6

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.
@@ -19,7 +19,7 @@ import ZnHoverContainer from "../hover-container";
19
19
  import ZnMenu from "../menu";
20
20
  import ZnMenuItem from "../menu-item";
21
21
  import ZnSkeleton from "../skeleton";
22
-
22
+ import ZnStyle from "../style";
23
23
  import type ZnDataSelect from "../data-select";
24
24
  import type ZnInput from "../input";
25
25
  import type ZnQueryBuilder from "../query-builder";
@@ -148,6 +148,7 @@ export default class ZnDataTable extends ZincElement {
148
148
  'zn-button-group': ZnButtonGroup,
149
149
  'zn-confirm': ZnConfirm,
150
150
  'zn-skeleton': ZnSkeleton,
151
+ 'zn-style': ZnStyle,
151
152
  };
152
153
 
153
154
  @property({attribute: 'data-uri'}) dataUri: string;
@@ -330,12 +331,15 @@ export default class ZnDataTable extends ZincElement {
330
331
  || this.hasSlotController.test(ActionSlots.create.valueOf())
331
332
  || this.hasSlotController.test(ActionSlots.sort.valueOf())
332
333
  || this.hasSlotController.test(ActionSlots.filter.valueOf())
333
- || this.hasSlotController.test(ActionSlots.filter_top.valueOf())
334
- || this.hasSlotController.test(ActionSlots.inputs.valueOf());
334
+ || this.hasSlotController.test(ActionSlots.filter_top.valueOf());
335
+
336
+ const hasInputs = this.hasSlotController.test(ActionSlots.inputs.valueOf());
335
337
 
336
338
  // Headers do not need to be re-rendered with new data
337
339
  return html`
338
340
  <div class="table-container" ${ref((el) => (this.tableContainer = el))}>
341
+ ${hasInputs ? html`
342
+ <slot name="${ActionSlots.inputs.valueOf()}" style="display: none"></slot>` : null}
339
343
  ${hasActions ? this.getTableHeader() : html``}
340
344
  ${tableBody}
341
345
  </div>
@@ -420,7 +424,7 @@ export default class ZnDataTable extends ZincElement {
420
424
  'table': true,
421
425
  'table--standalone': this.standalone,
422
426
  'with-hover': !this.unsortable,
423
- 'table-with--checkboxes': !this.hideCheckboxes,
427
+ 'table--with-checkboxes': !this.hideCheckboxes,
424
428
  })}">
425
429
  <thead>
426
430
  <tr>
@@ -454,7 +458,6 @@ export default class ZnDataTable extends ZincElement {
454
458
  getTableHeader() {
455
459
  return html`
456
460
  <slot name="${ActionSlots.filter_top.valueOf()}"></slot>
457
- <slot name="${ActionSlots.inputs.valueOf()}" style="display: none"></slot>
458
461
  <div class="table__header">
459
462
  <div class="table__header__actions">
460
463
  ${this.getActions()}
@@ -631,29 +634,33 @@ export default class ZnDataTable extends ZincElement {
631
634
  this.requestUpdate();
632
635
  }
633
636
 
634
- selectRow(e: PointerEvent) {
637
+ selectRow(e: Event) {
635
638
  if (!(e.target && (e.target instanceof Element))) {
636
639
  return;
637
640
  }
638
641
 
639
- let target: HTMLElement = e.target as HTMLElement;
642
+ const target: Element | null = e.target;
640
643
  // if is a button or a link continue
641
- if (target.tagName === 'ZN-BUTTON' || target.tagName === 'A' || target.tagName === 'BUTTON') {
642
- return
644
+ if (target?.tagName === 'ZN-BUTTON' || target?.tagName === 'A' || target?.tagName === 'BUTTON') {
645
+ return;
643
646
  }
644
647
 
645
- // traverse parent until we reach a tr
646
- while (target && target.tagName !== 'TR') {
647
- target = target.parentElement as HTMLElement;
648
+ // Find the parent row
649
+ let parent: Element | null = target.closest ? target.closest('tr') : target.parentElement;
650
+ while (parent && parent.tagName !== 'TR') {
651
+ parent = parent.parentElement;
648
652
  }
649
653
 
650
- if (target === null) {
654
+ if (parent === null) {
651
655
  return;
652
656
  }
653
657
 
654
- const checkbox = target.querySelector('input[type="checkbox"]') as HTMLInputElement;
658
+ const checkbox: HTMLInputElement | null = parent.querySelector('input[type="checkbox"]');
655
659
  if (checkbox) {
656
- checkbox.checked = !checkbox.checked;
660
+ const isCheckboxTarget = target instanceof HTMLInputElement && target.type === 'checkbox';
661
+ if (!isCheckboxTarget) {
662
+ checkbox.checked = !checkbox.checked;
663
+ }
657
664
  }
658
665
 
659
666
  this.selectedRows = this._rows.filter((_, index) => {
@@ -690,12 +697,30 @@ export default class ZnDataTable extends ZincElement {
690
697
 
691
698
  renderCell(data: Cell) {
692
699
  if (data && typeof data === 'object') {
693
- let content: TemplateResult = html`${data.text}`;
700
+ let content: TemplateResult | ZincElement = html`${data.text}`;
694
701
 
695
702
  if (data.style || data.color) {
703
+ const styleStr = typeof data.style === 'string' ? data.style : '';
704
+ const tokens = new Set(styleStr.split(',').filter(Boolean));
705
+
706
+ const isMono = tokens.has('mono') || tokens.has('code');
707
+ const isBorder = tokens.has('border');
708
+ const isCenter = tokens.has('center');
709
+
710
+ if (tokens.has('bold') || tokens.has('strong')) {
711
+ content = html`<strong>${content}</strong>`;
712
+ }
713
+
714
+ if (tokens.has('italic')) {
715
+ content = html`<em>${content}</em>`;
716
+ }
717
+
696
718
  content = html`
697
- <zn-style ${ifDefined(data.style || nothing)}
698
- color="${ifDefined(data.color || nothing)}">${content}
719
+ <zn-style
720
+ font="${isMono ? 'mono' : nothing}"
721
+ border="${isBorder || nothing}"
722
+ center="${isCenter || nothing}"
723
+ color="${ifDefined(data.color)}">${content}
699
724
  </zn-style>`;
700
725
  }
701
726
 
@@ -105,6 +105,8 @@ export default class ZnInlineEdit extends ZincElement implements ZincFormControl
105
105
  document.addEventListener('keydown', this.escKeyHandler);
106
106
  document.addEventListener('keydown', this.submitKeyHandler);
107
107
  document.addEventListener('click', this.mouseEventHandler);
108
+ this.addEventListener('mousedown', this.captureMouseDown, {capture: true});
109
+ this.addEventListener('keydown', this.captureKeyDown, {capture: true});
108
110
  }
109
111
 
110
112
  disconnectedCallback() {
@@ -112,6 +114,8 @@ export default class ZnInlineEdit extends ZincElement implements ZincFormControl
112
114
  document.removeEventListener('keydown', this.escKeyHandler);
113
115
  document.removeEventListener('keydown', this.submitKeyHandler);
114
116
  document.removeEventListener('click', this.mouseEventHandler);
117
+ this.removeEventListener('mousedown', this.captureMouseDown, true);
118
+ this.removeEventListener('keydown', this.captureKeyDown, true);
115
119
  }
116
120
 
117
121
  async firstUpdated() {
@@ -157,6 +161,19 @@ export default class ZnInlineEdit extends ZincElement implements ZincFormControl
157
161
  }
158
162
  }
159
163
 
164
+ captureMouseDown = (e: MouseEvent) => {
165
+ if (this.disabled && !this.isEditing) {
166
+ e.stopPropagation();
167
+ }
168
+ }
169
+
170
+ captureKeyDown = (e: KeyboardEvent) => {
171
+ if (this.disabled && !this.isEditing) {
172
+ e.stopPropagation();
173
+ e.preventDefault();
174
+ }
175
+ }
176
+
160
177
  handleEditClick = (e: MouseEvent) => {
161
178
  e.preventDefault();
162
179
  e.stopPropagation();
@@ -183,6 +200,9 @@ export default class ZnInlineEdit extends ZincElement implements ZincFormControl
183
200
  };
184
201
 
185
202
  handleInput = (e: Event) => {
203
+ if (this.disabled || !this.isEditing) {
204
+ return;
205
+ }
186
206
  this.value = (e.target as (HTMLInputElement | HTMLSelectElement)).value;
187
207
  };
188
208
 
@@ -224,7 +244,7 @@ export default class ZnInlineEdit extends ZincElement implements ZincFormControl
224
244
  'ai--padded': this.padded,
225
245
  })}">
226
246
 
227
- <div class="ai__left" @click="${this.handleEditClick}">
247
+ <div class="ai__left" @click="${this.disabled ? undefined : this.handleEditClick}">
228
248
  ${input}
229
249
  </div>
230
250
 
@@ -232,10 +252,11 @@ export default class ZnInlineEdit extends ZincElement implements ZincFormControl
232
252
  ${!this.isEditing ?
233
253
  html`
234
254
  ${hasEditText ? html`
235
- <zn-button @click="${this.handleEditClick}" size="x-small" color="secondary">
255
+ <zn-button @click="${this.disabled ? undefined : this.handleEditClick}" size="x-small"
256
+ color="secondary">
236
257
  ${this.editText}
237
258
  </zn-button>` : html`
238
- <zn-button @click="${this.handleEditClick}"
259
+ <zn-button @click="${this.disabled ? undefined : this.handleEditClick}"
239
260
  class="button--edit"
240
261
  icon="edit"
241
262
  size="x-small"
@@ -133,7 +133,17 @@
133
133
  }
134
134
  }
135
135
 
136
- &--disabled {
136
+ &--disabled:not(.ai--editing) {
137
+ .ai__input::part(input), .ai__input::part(combobox) {
138
+ text-decoration: none;
139
+ caret-color: transparent;
140
+ border-radius: 0;
141
+ }
142
+
143
+ .ai__input::part(display-input) {
144
+ cursor: text;
145
+ }
146
+
137
147
  .ai__right {
138
148
  display: none !important;
139
149
  }
@@ -4,7 +4,7 @@
4
4
  display: block;
5
5
  container-type: inline-size;
6
6
 
7
- --zn-item-label-max-width: 300px;
7
+ --zn-item-label-max-width: 450px;
8
8
  }
9
9
 
10
10
  .item {
@@ -29,7 +29,7 @@
29
29
  &--has-icon {
30
30
  .item__icon {
31
31
  position: relative;
32
- line-height: 33px;
32
+ line-height: var(--zn-line-height-loose);
33
33
  display: flex;
34
34
  justify-content: center;
35
35
  margin-right: var(--zn-spacing-small);
@@ -44,8 +44,6 @@
44
44
  &__header {
45
45
  display: flex;
46
46
  align-items: center;
47
- max-width: var(--zn-item-label-max-width);
48
- width: 100%;
49
47
 
50
48
  .item__caption {
51
49
  width: unset;
@@ -56,8 +54,11 @@
56
54
  &__headings {
57
55
  display: flex;
58
56
  flex-direction: column;
59
- max-width: var(--zn-item-label-max-width);
60
- width: 100%;
57
+ max-width: 40%;
58
+ @include wc.container-query(null, sm) {
59
+ max-width: unset;
60
+ }
61
+ width: var(--zn-item-label-max-width);
61
62
  flex-shrink: 0;
62
63
  }
63
64
 
@@ -65,7 +66,7 @@
65
66
  width: 100%;
66
67
  display: flex;
67
68
  justify-content: space-between;
68
- line-height: 33px;
69
+ line-height: var(--zn-line-height-loose);
69
70
  }
70
71
 
71
72
  &__content-inner {
@@ -84,14 +85,9 @@
84
85
  &__caption {
85
86
  font-weight: 500;
86
87
  color: rgb(var(--zn-text-heading));
87
- line-height: var(--zn-line-height-normal);
88
- max-width: var(--zn-item-label-max-width);
88
+ line-height: var(--zn-line-height-loose);
89
89
  width: 100%;
90
90
  flex-shrink: 0;
91
-
92
- @include wc.container-query(null, sm) {
93
- line-height: var(--zn-line-height-normal);
94
- }
95
91
  }
96
92
 
97
93
  &__description {
@@ -100,9 +96,6 @@
100
96
  margin: var(--zn-spacing-2x-small) 0 0;
101
97
  font-size: var(--zn-font-size-small);
102
98
  color: rgb(var(--zn-text-color));
103
- overflow: hidden;
104
- white-space: nowrap;
105
- text-overflow: ellipsis;
106
99
  }
107
100
 
108
101
  &__action-wrapper {
@@ -159,7 +152,6 @@
159
152
  }
160
153
 
161
154
  &--inline {
162
-
163
155
  gap: var(--zn-spacing-small);
164
156
 
165
157
  .item__header {
@@ -5,6 +5,7 @@
5
5
  }
6
6
 
7
7
  .container {
8
+ padding-bottom: 30px;
8
9
  }
9
10
 
10
11
  .container--scroll {
@@ -19,7 +20,6 @@
19
20
  width: 100%;
20
21
  overflow: auto;
21
22
  box-sizing: border-box;
22
- padding-bottom: 60px;
23
23
  }
24
24
 
25
25
  .setting-container__dropdown {
@@ -32,6 +32,9 @@
32
32
  background: rgba(var(--zn-panel, 0.8));
33
33
  box-shadow: var(--zn-shadow-small);
34
34
  transition: bottom 0.2s ease;
35
+ opacity: 0.7;
36
+ transition-duration: 0.3s;
37
+ transition-property: opacity;
35
38
 
36
39
  &:hover {
37
40
  background: rgba(var(--zn-panel, 1));
@@ -63,13 +66,17 @@
63
66
  }
64
67
  }
65
68
 
69
+ .setting-container__dropdown[open], .setting-container__dropdown:hover {
70
+ opacity: 1;
71
+ }
72
+
66
73
  .setting-container__dropdown[open] .setting-container__toggle-button::part(icon), .setting-container__toggle-button:hover::part(icon) {
67
74
  color: rgb(var(--zn-primary));
68
75
  cursor: pointer;
69
- transition-duration: 0.8s;
76
+ transition-duration: 0.9s;
70
77
  transition-property: rotate, color;
71
- rotate: 480deg;
72
- transition-timing-function: ease-out;
78
+ rotate: 380deg;
79
+ transition-timing-function: ease-in-out;
73
80
  }
74
81
 
75
82
  zn-button {
@@ -20,6 +20,7 @@ export default class ZnStyle extends ZincElement {
20
20
  @property({type: Boolean}) primary = false;
21
21
  @property({type: Boolean}) accent = false;
22
22
  @property({type: Boolean}) center = false;
23
+ @property() font = '';
23
24
  @property() width = '';
24
25
  @property() height = '';
25
26
  @property() pad = '';
@@ -57,6 +58,12 @@ export default class ZnStyle extends ZincElement {
57
58
  this.classList.toggle('flex-jc', true);
58
59
  }
59
60
 
61
+ if (this.font) {
62
+ if (this.font === 'mono') {
63
+ this.classList.toggle('zn-mono', true);
64
+ }
65
+ }
66
+
60
67
  if (this.width === "f") {
61
68
  this.classList.toggle('w-full', true);
62
69
  }
@@ -158,7 +165,6 @@ export default class ZnStyle extends ZincElement {
158
165
  }
159
166
  }
160
167
 
161
-
162
168
  this.style.display = display;
163
169
  }
164
170