@itfin/components 1.3.59 → 1.3.61

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.59",
3
+ "version": "1.3.61",
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,17 @@ 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),
203
+ icon: this.panels[type].icon ? this.panels[type].icon(this.$t.bind(this), payload) : null,
193
204
  type,
194
205
  payload,
195
206
  isCollapsed: false,
@@ -208,9 +219,13 @@ export default class PanelList extends Vue {
208
219
  this.$nextTick(() => { // щоб панелі змінювались при редагуванні
209
220
  const n = newStack.length;
210
221
  newPanel.emit = (event, ...args) => this.emitEvent(event, ...args);
211
- newPanel.open = (type, visOptions, payload) => this.openPanel(visOptions.title, visOptions.icon, type, payload, n + 1);
222
+ newPanel.open = (type, payload) => this.openPanel(type, payload, n + 1);
212
223
  newPanel.close = () => this.closePanel(newPanel);
213
224
  newPanel.expand = () => this.expandPanel(newPanel);
225
+ newPanel.getTitle = () => newPanel.title;
226
+ newPanel.getIcon = () => newPanel.icon;
227
+ newPanel.setTitle = (title: string) => { newPanel.title = title; };
228
+ newPanel.setIcon = (icon: string) => { newPanel.icon = icon; };
214
229
  newPanel.on = (eventName, func: (event: string, ...args: any[]) => any) => {
215
230
  if (!newPanel.__events[eventName]) {
216
231
  newPanel.__events[eventName] = [];
@@ -234,6 +249,8 @@ export default class PanelList extends Vue {
234
249
  newPanel.getPayload = () => newPanel.payload;
235
250
  newPanel.setPayload = (value: any) => {
236
251
  newPanel.payload = value;
252
+ newPanel.title = this.panels[type].caption(this.$t.bind(this), value);
253
+ newPanel.icon = this.panels[type].icon ? this.panels[type].icon(this.$t.bind(this), payload) : null,
237
254
  this.setPanelHash()
238
255
  }
239
256
  newStack.push(newPanel);
@@ -244,8 +261,8 @@ export default class PanelList extends Vue {
244
261
  });
245
262
  }
246
263
 
247
- async openPanel(title: string, icon: string, type: string, payload: any, openIndex?: number) {
248
- await this.internalOpenPanel(title, icon, type, payload, openIndex);
264
+ async openPanel(type: string, payload: any, openIndex?: number) {
265
+ await this.internalOpenPanel(type, payload, openIndex);
249
266
  this.setPanelHash()
250
267
  }
251
268
 
@@ -299,9 +316,20 @@ export default class PanelList extends Vue {
299
316
  payload: JSON.parse(decodeURIComponent(payload))
300
317
  };
301
318
  });
319
+ const newStack = [];
302
320
  for (const panel of panels) {
303
- await this.internalOpenPanel('', '', panel.type, panel.payload);
321
+ const resPanel = await this.internalOpenPanel(panel.type, panel.payload);
322
+ newStack.push(resPanel);
304
323
  }
324
+ this.panelsStack = newStack;
325
+ }
326
+ }
327
+
328
+ handlePopState() {
329
+ this.parsePanelHash();
330
+ // виправляє проблему відкритої панелі при натисканні кнопки "назад" до першої панелі
331
+ if (this.panelsStack.length === 2) {
332
+ this.panelsStack = this.panelsStack.slice(0, 1);
305
333
  }
306
334
  }
307
335
  }