@itfin/components 1.3.58 → 1.3.60

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itfin/components",
3
- "version": "1.3.58",
3
+ "version": "1.3.60",
4
4
  "author": "Vitalii Savchuk <esvit666@gmail.com>",
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -1,10 +1,10 @@
1
1
  <template>
2
2
  <div tabindex="-1" class="b-panel" :class="{'b-panel__collapsed': collapsed, 'b-panel__active': !collapsed}">
3
- <div v-if="collapsed" class="b-panel__expand">
3
+ <div v-if="collapsed" class="b-panel__expand" @click.stop.prevent="expandPanel">
4
4
  <itf-button v-if="closeable" icon small class="b-panel__expand_button" @click="closePanel">
5
5
  <itf-icon name="cross" />
6
6
  </itf-button>
7
- <a href="" class="b-panel__expand_text_container" @click.stop.prevent="expandPanel">
7
+ <a href="" class="b-panel__expand_text_container">
8
8
  <itf-icon v-if="icon" :name="icon" class="mt-2" />
9
9
 
10
10
  <div class="b-panel__expand_text" v-text="title"></div>
@@ -74,6 +74,7 @@
74
74
  height: 100%;
75
75
  position: relative;
76
76
  padding-top: 2px;
77
+ cursor: pointer;
77
78
  }
78
79
  &__expand_text_container {
79
80
  text-decoration: none;
@@ -19,7 +19,7 @@
19
19
  :panel="panel"
20
20
  :payload="panel.payload"
21
21
  :multiple="isOpenMultiple"
22
- :open="(title, icon, type, payload) => openPanel(title, icon, type, payload, n + 1)"
22
+ :open="(title, icon, type, payload) => openPanel(type, payload, n + 1)"
23
23
  :close="() => closePanel(panel)"
24
24
  :expand="() => expandPanel(panel)"
25
25
  :fullsize="() => fullsizePanel(panel)">
@@ -31,7 +31,7 @@
31
31
  :panel="panel"
32
32
  :payload="panel.payload"
33
33
  :multiple="isOpenMultiple"
34
- :open="(title, icon, type, payload) => openPanel(title, icon, type, payload, n + 1)"
34
+ :open="(title, icon, type, payload) => openPanel(type, payload, n + 1)"
35
35
  :close="() => closePanel(panel)"
36
36
  :expand="() => expandPanel(panel)"
37
37
  :fullsize="() => fullsizePanel(panel)">
@@ -44,7 +44,7 @@
44
44
  :panel="panel"
45
45
  :payload="panel.payload"
46
46
  :multiple="isOpenMultiple"
47
- :open="(title, icon, type, payload) => openPanel(title, icon, type, payload, n + 1)"
47
+ :open="(title, icon, type, payload) => openPanel(type, payload, n + 1)"
48
48
  :close="() => closePanel(panel)"
49
49
  :expand="() => expandPanel(panel)"
50
50
  :fullsize="() => fullsizePanel(panel)">
@@ -57,7 +57,7 @@
57
57
  :panel="panel"
58
58
  :payload="panel.payload"
59
59
  :multiple="isOpenMultiple"
60
- :open="(title, icon, type, payload) => openPanel(title, icon, type, payload, n + 1)"
60
+ :open="(title, icon, type, payload) => openPanel(type, payload, n + 1)"
61
61
  :close="() => closePanel(panel)"
62
62
  :expand="() => expandPanel(panel)"
63
63
  :fullsize="() => fullsizePanel(panel)">
@@ -139,9 +139,14 @@ export default class PanelList extends Vue {
139
139
 
140
140
  created() {
141
141
  if (this.firstPanel) {
142
- this.internalOpenPanel(this.firstPanel.title, this.firstPanel.icon, this.firstPanel.type, this.firstPanel.payload);
142
+ this.internalOpenPanel(this.firstPanel.type, this.firstPanel.payload);
143
143
  }
144
- this.parsePanelHash();
144
+ this.parsePanelHash(); // щоб панелі змінювались при перезавантаженні
145
+ window.addEventListener('popstate', this.handlePopState); // щоб панелі змінювались при навігації
146
+ }
147
+
148
+ beforeDestroy() {
149
+ window.removeEventListener('popstate', this.handlePopState);
145
150
  }
146
151
 
147
152
  get isOpenMultiple() {
@@ -185,11 +190,16 @@ export default class PanelList extends Vue {
185
190
  this.panelsStack = newStack;
186
191
  }
187
192
 
188
- internalOpenPanel(title: string, icon: string, type: string, payload: any, openIndex?: number) {
193
+ internalOpenPanel(type: string, payload: any = {}, openIndex?: number) {
194
+ if (!this.panels[type]) {
195
+ return;
196
+ }
197
+ if (typeof this.panels[type].caption !== 'function') {
198
+ throw new Error('Panel component must have a "caption" function');
199
+ }
189
200
  const newPanel:any = {
190
201
  id: this.nextId++,
191
- title,
192
- icon,
202
+ title: this.panels[type].caption(this.$t.bind(this), payload),
193
203
  type,
194
204
  payload,
195
205
  isCollapsed: false,
@@ -208,9 +218,13 @@ export default class PanelList extends Vue {
208
218
  this.$nextTick(() => { // щоб панелі змінювались при редагуванні
209
219
  const n = newStack.length;
210
220
  newPanel.emit = (event, ...args) => this.emitEvent(event, ...args);
211
- newPanel.open = (type, visOptions, payload) => this.openPanel(visOptions.title, visOptions.icon, type, payload, n + 1);
221
+ newPanel.open = (type, payload) => this.openPanel(type, payload, n + 1);
212
222
  newPanel.close = () => this.closePanel(newPanel);
213
223
  newPanel.expand = () => this.expandPanel(newPanel);
224
+ newPanel.getTitle = () => newPanel.title;
225
+ newPanel.getIcon = () => newPanel.icon;
226
+ newPanel.setTitle = (title: string) => { newPanel.title = title; };
227
+ newPanel.setIcon = (icon: string) => { newPanel.icon = icon; };
214
228
  newPanel.on = (eventName, func: (event: string, ...args: any[]) => any) => {
215
229
  if (!newPanel.__events[eventName]) {
216
230
  newPanel.__events[eventName] = [];
@@ -244,8 +258,8 @@ export default class PanelList extends Vue {
244
258
  });
245
259
  }
246
260
 
247
- async openPanel(title: string, icon: string, type: string, payload: any, openIndex?: number) {
248
- await this.internalOpenPanel(title, icon, type, payload, openIndex);
261
+ async openPanel(type: string, payload: any, openIndex?: number) {
262
+ await this.internalOpenPanel(type, payload, openIndex);
249
263
  this.setPanelHash()
250
264
  }
251
265
 
@@ -299,9 +313,20 @@ export default class PanelList extends Vue {
299
313
  payload: JSON.parse(decodeURIComponent(payload))
300
314
  };
301
315
  });
316
+ const newStack = [];
302
317
  for (const panel of panels) {
303
- await this.internalOpenPanel('', '', panel.type, panel.payload);
318
+ const resPanel = await this.internalOpenPanel(panel.type, panel.payload);
319
+ newStack.push(resPanel);
304
320
  }
321
+ this.panelsStack = newStack;
322
+ }
323
+ }
324
+
325
+ handlePopState() {
326
+ this.parsePanelHash();
327
+ // виправляє проблему відкритої панелі при натисканні кнопки "назад" до першої панелі
328
+ if (this.panelsStack.length === 2) {
329
+ this.panelsStack = this.panelsStack.slice(0, 1);
305
330
  }
306
331
  }
307
332
  }
@@ -34,6 +34,7 @@
34
34
  :striped="striped"
35
35
  :expanded-ids="expandedIds"
36
36
  :css-property="cssProperty"
37
+ :sorting.sync="_sorting"
37
38
  @update:expanded-ids="$emit('update:expanded-ids', $event)"
38
39
  @new="$emit('new', $event)"
39
40
  @add-column="$emit('add-column', $event)"
@@ -85,6 +86,7 @@ class itfTable2 extends Vue {
85
86
  @Prop({ type: String, default: null }) stateName; // save state to storage
86
87
  @Prop({ type: Object, default: () => ({}) }) schema;
87
88
  @ModelSync('value', 'input', { type: Array, default: () => ([]) }) selectedIds;
89
+ @PropSync('sorting', { type: Object, default: () => ({}) }) _sorting;
88
90
  @Prop({ type: Array, default: () => [] }) expandedIds;
89
91
  @Prop() currency;
90
92
  @Prop() currencies;
@@ -44,6 +44,7 @@
44
44
  :no-select-all="noSelectAll"
45
45
  :selected-ids="selectedIds"
46
46
  :indicatorType="indicatorType"
47
+ :sorting.sync="_sorting"
47
48
  @update:selectedIds="$emit('update:selectedIds', $event)"
48
49
  @update:columns="$emit('update:columns', $event)"
49
50
  @add-column="$emit('add-column', $event)"
@@ -347,6 +348,7 @@ class itfTableGroup extends Vue {
347
348
  @Prop(Boolean) striped;
348
349
  @Prop() indicatorWidth;
349
350
  @Prop() cssProperty;
351
+ @PropSync('sorting', { type: Object, default: () => ({}) }) _sorting;
350
352
  @Prop({ type: String, default: null }) indicatorType;
351
353
  @Prop({type: String, default: function() { return this.$t('components.table.new'); } }) newLabel;
352
354
  @Prop({type: Object, default: () => ({})}) schema;
@@ -33,24 +33,24 @@
33
33
  v-draggable="{ handle: true, payload: { index: n, item: column }, mirror: {yAxis:false} }">
34
34
  <itf-dropdown text append-to-body shadow ref="dropdown" class="w-100" :disabled="noColumnMenu">
35
35
  <template #button>
36
- <span class="itf-table2__header-title" :title="column.title[locale] || column.title['en_US']">
36
+ <span class="itf-table2__header-title text-truncate" :title="column.title[locale] || column.title['en_US']" :class="{'ms-auto': column.align === 'end'}">
37
37
  <span v-if="column.icon" :class="column.icon"></span>
38
38
  {{column.title[locale] || column.title['en_US']}}
39
39
  <div v-if="column.prefix" class="itf-table2__subtitle" v-text="column.prefix" />
40
40
  </span>
41
- <!-- <itf-icon name="arrow_up" :size="16" class="ms-1" />-->
41
+ <itf-icon v-if="_sorting[column.property]" :name="_sorting[column.property] === 'asc' ? 'arrow_up' : 'arrow_down'" :size="16" class="ms-1" />
42
42
  </template>
43
43
 
44
44
  <div v-if="column.sortable">
45
- <a class="dropdown-item d-flex align-items-center" href="javascript:;">
45
+ <a class="dropdown-item d-flex align-items-center" href="javascript:;" @click="sortBy(column, 'asc')">
46
46
  <itf-icon name="arrow_up" :size="16" class="me-1" />
47
47
  {{$t('components.table.sortAscending')}}
48
48
  </a>
49
49
  </div>
50
50
  <div v-if="column.sortable">
51
- <a class="dropdown-item d-flex align-items-center" href="javascript:;">
51
+ <a class="dropdown-item d-flex align-items-center" href="javascript:;" @click="sortBy(column, 'desc')">
52
52
  <itf-icon name="arrow_down" :size="16" class="me-1" />
53
- {{$t('components.table.sortAscending')}}
53
+ {{$t('components.table.sortDescending')}}
54
54
  </a>
55
55
  </div>
56
56
  <div v-if="column.groupable">
@@ -159,6 +159,7 @@ class itfTableHeader extends Vue {
159
159
  @Inject() tableEl;
160
160
 
161
161
  @PropSync('columns', { type: Array, default: () => ([]) }) sortedColumns;
162
+ @PropSync('sorting', { type: Object, default: () => ({}) }) _sorting;
162
163
  @Prop({ type: Array, default: () => ([]) }) rows;
163
164
  @Prop({ type: Array, default: () => ([]) }) selectedIds;
164
165
  @Prop({ type: Object, default: () => ({}) }) schema;
@@ -335,5 +336,10 @@ class itfTableHeader extends Vue {
335
336
  onSortColumns(items) {
336
337
  this.$emit('update:columns', items);
337
338
  }
339
+
340
+ sortBy(column, order) {
341
+ console.info({ [column.property]: order });
342
+ this.$emit('update:sorting', { [column.property]: order });
343
+ }
338
344
  }
339
345
  </script>
@@ -51,7 +51,7 @@
51
51
  v-if="column.visible !== false"
52
52
  :data-column="k"
53
53
  :style="`width: ${column.width}px; max-width: ${column.width}px; left: ${column.left}px;`"
54
- :class="{'sticky': column.pinned, 'last-sticky-column': k === lastPinnedIndex, 'flex-grow-1': column.grow, 'px-2': !(column.editable && editable), 'editable': column.editable && editable}"
54
+ :class="{'justify-content-end': column.align === 'end', 'sticky': column.pinned, 'last-sticky-column': k === lastPinnedIndex, 'flex-grow-1': column.grow, 'px-2': !(column.editable && editable), 'editable': column.editable && editable}"
55
55
  class="table-view-item-value d-flex h-100">
56
56
  <slot :name="`column.${column.property}`" :toggle="() => $emit('toggle', item)" :level="level" :editable="column.editable && editable" :item="item" :column="column" :update="(val) => updateValue(item, val, n, column)" :value="getValue(item, column)">
57
57
  <template v-if="column.editable && editable">
@@ -51,7 +51,7 @@ body[data-theme="dark"] {
51
51
  bottom: 0;
52
52
  }
53
53
  &.table-striped {
54
- .table-view-item:nth-child(odd) {
54
+ .table-view-item:nth-child(even) {
55
55
  --itf-table2-row-bg: var(--itf-table-alt-bg);
56
56
  }
57
57
  }