@itfin/components 1.3.54 → 1.3.56

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.54",
3
+ "version": "1.3.56",
4
4
  "author": "Vitalii Savchuk <esvit666@gmail.com>",
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -929,7 +929,7 @@ $rangeThumbSize: 12px;
929
929
  }
930
930
  }
931
931
 
932
- .itf-datepicker {
932
+ .itf-datepicker, .itf-monthpicker {
933
933
  &.with-addon .addon-end {
934
934
  pointer-events: all;
935
935
  padding-right: 0.25rem;
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div class="itf-monthpicker" :class="{'with-addon addon-start': prependIcon}">
2
+ <div class="itf-monthpicker input-group" :class="{'with-addon addon-start': prependIcon, 'with-addon addon-end': clearable}">
3
3
  <div class="addon" v-if="prependIcon">
4
4
  <slot name="addon">
5
5
  <itf-icon :name="prependIcon" />
@@ -16,6 +16,17 @@
16
16
  :value="displayValue"
17
17
  :placeholder="placeholder"
18
18
  />
19
+ <div class="addon-end" v-if="clearable && value">
20
+ <slot name="clear">
21
+ <itf-button
22
+ icon
23
+ small
24
+ @click="$emit('input', '')"
25
+ >
26
+ <itf-icon name="close" />
27
+ </itf-button>
28
+ </slot>
29
+ </div>
19
30
  <div style="display: none">
20
31
  <div ref="dropdown" class="itf-monthpicker__dropdown border rounded">
21
32
  <div>
@@ -42,10 +53,12 @@ import { DateTime } from 'luxon';
42
53
  import tippy from 'tippy.js';
43
54
  import itfIcon from '../icon/Icon';
44
55
  import itfDatePickerInline from './DatePickerInline.vue';
56
+ import itfButton from "@/components/button/Button.vue";
45
57
 
46
58
  export default @Component({
47
59
  name: 'itfMonthPicker',
48
60
  components: {
61
+ itfButton,
49
62
  itfIcon,
50
63
  itfDatePickerInline
51
64
  },
@@ -64,6 +77,8 @@ class itfMonthPicker extends Vue {
64
77
  @Prop({ type: String, default: '' }) prependIcon;
65
78
  @Prop({ type: String, default: 'bottom-start' }) placement;
66
79
 
80
+ @Prop(Boolean) clearable;
81
+
67
82
  focused = false;
68
83
 
69
84
  tooltip = null;
@@ -77,6 +77,8 @@ storiesOf('Common', module)
77
77
  <h2>Month</h2>
78
78
 
79
79
  <itf-month-picker :value="month" v-model.lazy="month"></itf-month-picker>
80
+ <br />
81
+ <itf-month-picker clearable :value="month" v-model.lazy="month"></itf-month-picker>
80
82
 
81
83
  <h2>Period</h2>
82
84
 
@@ -73,7 +73,7 @@ class itfModal extends Vue {
73
73
 
74
74
  @Watch('value')
75
75
  onVisibleChanged(newValue, oldValue) {
76
- if (!this.modalEl || this.preventEvents || (typeof oldValue === 'undefined' && !newValue)) {
76
+ if (!this.modalEl || (this.preventEvents && oldValue !== true) || (typeof oldValue === 'undefined' && !newValue)) {
77
77
  return;
78
78
  }
79
79
  if (newValue) {
@@ -139,8 +139,9 @@ export default class PanelList extends Vue {
139
139
 
140
140
  created() {
141
141
  if (this.firstPanel) {
142
- this.openPanel(this.firstPanel.title, this.firstPanel.icon, this.firstPanel.type, this.firstPanel.payload);
142
+ this.internalOpenPanel(this.firstPanel.title, this.firstPanel.icon, this.firstPanel.type, this.firstPanel.payload);
143
143
  }
144
+ this.parsePanelHash();
144
145
  }
145
146
 
146
147
  get isOpenMultiple() {
@@ -184,7 +185,7 @@ export default class PanelList extends Vue {
184
185
  this.panelsStack = newStack;
185
186
  }
186
187
 
187
- openPanel(title: string, icon: string, type: string, payload: any, openIndex?: number) {
188
+ internalOpenPanel(title: string, icon: string, type: string, payload: any, openIndex?: number) {
188
189
  const newPanel:any = {
189
190
  id: this.nextId++,
190
191
  title,
@@ -203,42 +204,51 @@ export default class PanelList extends Vue {
203
204
  newStack = newStack.slice(0, openIndex);
204
205
  }
205
206
  this.panelsStack = newStack;
206
- this.$nextTick(() => { // щоб панелі змінювались при редагуванні
207
- const n = newStack.length;
208
- newPanel.emit = (event, ...args) => this.emitEvent(event, ...args);
209
- newPanel.open = (type, visOptions, payload) => this.openPanel(visOptions.title, visOptions.icon, type, payload, n + 1);
210
- newPanel.close = () => this.closePanel(newPanel);
211
- newPanel.expand = () => this.expandPanel(newPanel);
212
- newPanel.on = (eventName, func: (event: string, ...args: any[]) => any) => {
213
- if (!newPanel.__events[eventName]) {
214
- newPanel.__events[eventName] = [];
215
- }
216
- newPanel.__events[eventName].push(func);
217
- };
218
- newPanel.off = (eventName, func: (event: string, ...args: any[]) => any) => {
219
- if (newPanel.__events[eventName]) {
220
- newPanel.__events[eventName] = newPanel.__events[eventName].filter(f => f !== func);
221
- }
222
- };
223
- newPanel.once = (eventName, func: (event: string, ...args: any[]) => any) => {
224
- const wrapper = (...args: any[]) => {
225
- func(eventName, ...args);
226
- newPanel.off(eventName, wrapper);
207
+ return new Promise(res => {
208
+ this.$nextTick(() => { // щоб панелі змінювались при редагуванні
209
+ const n = newStack.length;
210
+ newPanel.emit = (event, ...args) => this.emitEvent(event, ...args);
211
+ newPanel.open = (type, visOptions, payload) => this.openPanel(visOptions.title, visOptions.icon, type, payload, n + 1);
212
+ newPanel.close = () => this.closePanel(newPanel);
213
+ newPanel.expand = () => this.expandPanel(newPanel);
214
+ newPanel.on = (eventName, func: (event: string, ...args: any[]) => any) => {
215
+ if (!newPanel.__events[eventName]) {
216
+ newPanel.__events[eventName] = [];
217
+ }
218
+ newPanel.__events[eventName].push(func);
227
219
  };
228
- newPanel.on(eventName, wrapper);
229
- };
230
- newPanel.isMultiple = () => this.isOpenMultiple;
231
- newPanel.fullsize = () => this.fullsizePanel(newPanel);
232
- newPanel.getPayload = () => newPanel.payload;
233
- newPanel.setPayload = (value: any) => {
234
- newPanel.payload = value;
235
- }
236
- newStack.push(newPanel);
237
- this.panelsStack = newStack;
238
- this.ensureOnlyTwoOpenPanels(newPanel.id);
220
+ newPanel.off = (eventName, func: (event: string, ...args: any[]) => any) => {
221
+ if (newPanel.__events[eventName]) {
222
+ newPanel.__events[eventName] = newPanel.__events[eventName].filter(f => f !== func);
223
+ }
224
+ };
225
+ newPanel.once = (eventName, func: (event: string, ...args: any[]) => any) => {
226
+ const wrapper = (...args) => {
227
+ func(eventName, ...args);
228
+ newPanel.off(eventName, wrapper);
229
+ };
230
+ newPanel.on(eventName, wrapper);
231
+ };
232
+ newPanel.isMultiple = () => this.isOpenMultiple;
233
+ newPanel.fullsize = () => this.fullsizePanel(newPanel);
234
+ newPanel.getPayload = () => newPanel.payload;
235
+ newPanel.setPayload = (value: any) => {
236
+ newPanel.payload = value;
237
+ this.setPanelHash()
238
+ }
239
+ newStack.push(newPanel);
240
+ this.panelsStack = newStack;
241
+ this.ensureOnlyTwoOpenPanels(newPanel.id);
242
+ return res(newPanel);
243
+ })
239
244
  });
240
245
  }
241
246
 
247
+ async openPanel(title: string, icon: string, type: string, payload: any, openIndex?: number) {
248
+ await this.internalOpenPanel(title, icon, type, payload, openIndex);
249
+ this.setPanelHash()
250
+ }
251
+
242
252
  emitEvent(event: string, ...args: any[]) {
243
253
  for (const panel of this.panelsStack) {
244
254
  if (panel.__events[event]) {
@@ -261,6 +271,7 @@ export default class PanelList extends Vue {
261
271
  this.panelsStack[openPanelIndex - 1].isCollapsed = false;
262
272
  }
263
273
  this.ensureOnlyTwoOpenPanels(openPanel.id);
274
+ this.setPanelHash()
264
275
  }
265
276
 
266
277
  fullsizePanel(panel: IPanel) {
@@ -270,5 +281,28 @@ export default class PanelList extends Vue {
270
281
  }
271
282
  this.panelsStack = newStack;
272
283
  }
284
+
285
+ setPanelHash() {
286
+ const hash = this.panelsStack.map(panel => {
287
+ return `${panel.type}=${JSON.stringify(panel.payload || {})}`;
288
+ }).join('&');
289
+ this.$router.push({ hash });
290
+ }
291
+
292
+ async parsePanelHash() {
293
+ const hash = this.$route.hash;
294
+ if (hash) {
295
+ const panels = hash.slice(1).split('&').map(item => {
296
+ const [type, payload] = item.split('=');
297
+ return {
298
+ type,
299
+ payload: JSON.parse(decodeURIComponent(payload))
300
+ };
301
+ });
302
+ for (const panel of panels) {
303
+ await this.internalOpenPanel('', '', panel.type, panel.payload);
304
+ }
305
+ }
306
+ }
273
307
  }
274
308
  </script>
@@ -26,16 +26,18 @@
26
26
  <slot :name="name" v-bind="slotData || {}"/>
27
27
  </template>
28
28
  </itf-table-rows>
29
- <div v-if="!rows.length" data-test="table-no-results" class="table-view-item">
30
- <div class="table-row-template">
31
- <div accept-group="items" class="table-view-body-space"></div>
32
- <div class="shadow-area"></div>
33
- <div class="indicator sticky"></div>
34
- <div class="table-item-inner">
35
- <div class="table-view-item-value w-100 align-items-center p-3 no-results">
36
- {{$t('components.table.noResults')}}
29
+ <div v-if="!rows.length" data-test="table-no-results" class="scroller">
30
+ <div class="table-view-item">
31
+ <div class="table-row-template">
32
+ <div accept-group="items" class="table-view-body-space"></div>
33
+ <div class="shadow-area"></div>
34
+ <div class="indicator sticky"></div>
35
+ <div class="table-item-inner">
36
+ <div class="table-view-item-value w-100 align-items-center p-3 no-results">
37
+ {{$t('components.table.noResults')}}
38
+ </div>
39
+ <div class="boundary right"></div>
37
40
  </div>
38
- <div class="boundary right"></div>
39
41
  </div>
40
42
  </div>
41
43
  </div>
@@ -22,7 +22,7 @@
22
22
  </span>
23
23
  <span class="d-flex align-items-center line-overflow group-header-value"
24
24
  data-test="group-value-group-label-value">
25
- <slot name="group-title" :rows="rows" :title="rows">{{ title }}</slot>
25
+ <slot name="group-title" :rows="rows" :title="title">{{ title }}</slot>
26
26
  </span>
27
27
  </a>
28
28
  </div>