@itfin/components 1.3.51 → 1.3.53

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.51",
3
+ "version": "1.3.53",
4
4
  "author": "Vitalii Savchuk <esvit666@gmail.com>",
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -11,20 +11,22 @@
11
11
  </a>
12
12
  </div>
13
13
  <div v-show="!collapsed" class="b-panel-header">
14
- <div>
15
- <slot name="title">
16
- <div class="b-panel__title" v-text="title"></div>
17
- </slot>
18
- </div>
19
- <div>
20
- <slot name="buttons"></slot>
21
- <itf-button v-if="expandable" icon small class="b-panel__expand_button" @click="fullsizePanel">
22
- <itf-icon name="expand" />
23
- </itf-button>
24
- <itf-button v-if="closeable" icon small class="b-panel__expand_button" @click="closePanel">
25
- <itf-icon name="cross" />
26
- </itf-button>
27
- </div>
14
+ <slot name="header">
15
+ <div>
16
+ <slot name="title">
17
+ <div class="b-panel__title" v-text="title"></div>
18
+ </slot>
19
+ </div>
20
+ <div class="d-flex gap-1">
21
+ <slot name="buttons"></slot>
22
+ <itf-button v-if="expandable" icon small class="b-panel__expand_button" @click="fullsizePanel">
23
+ <itf-icon name="expand" />
24
+ </itf-button>
25
+ <itf-button v-if="closeable" icon small class="b-panel__expand_button" @click="closePanel">
26
+ <itf-icon name="cross" />
27
+ </itf-button>
28
+ </div>
29
+ </slot>
28
30
  </div>
29
31
  <div v-show="!collapsed" class="b-panel-body">
30
32
  <slot></slot>
@@ -23,9 +23,9 @@
23
23
  :close="() => closePanel(panel)"
24
24
  :expand="() => expandPanel(panel)"
25
25
  :fullsize="() => fullsizePanel(panel)">
26
- <component :is="panels[panel.type]" :panel="panel" :payload="panel.payload" />
26
+ <component :is="panels[panel.type].default || panels[panel.type]" :panel="panel" :payload="panel.payload" />
27
27
  </slot>
28
- <template v-if="$scopedSlots[`${panel.type}.title`]" #title>
28
+ <template v-if="$scopedSlots[`${panel.type}.title`] || panels[panel.type].title" #title>
29
29
  <slot
30
30
  :name="`${panel.type}.title`"
31
31
  :panel="panel"
@@ -35,9 +35,10 @@
35
35
  :close="() => closePanel(panel)"
36
36
  :expand="() => expandPanel(panel)"
37
37
  :fullsize="() => fullsizePanel(panel)">
38
+ <component v-if="panels[panel.type].title" :is="panels[panel.type].title" :panel="panel" :payload="panel.payload" />
38
39
  </slot>
39
40
  </template>
40
- <template v-if="$scopedSlots[`${panel.type}.buttons`]" #buttons>
41
+ <template v-if="$scopedSlots[`${panel.type}.buttons`] || panels[panel.type].buttons" #buttons>
41
42
  <slot
42
43
  :name="`${panel.type}.buttons`"
43
44
  :panel="panel"
@@ -47,6 +48,20 @@
47
48
  :close="() => closePanel(panel)"
48
49
  :expand="() => expandPanel(panel)"
49
50
  :fullsize="() => fullsizePanel(panel)">
51
+ <component v-if="panels[panel.type].buttons" :is="panels[panel.type].buttons" :panel="panel" :payload="panel.payload" />
52
+ </slot>
53
+ </template>
54
+ <template v-if="$scopedSlots[`${panel.type}.header`] || panels[panel.type].header" #header>
55
+ <slot
56
+ :name="`${panel.type}.header`"
57
+ :panel="panel"
58
+ :payload="panel.payload"
59
+ :multiple="isOpenMultiple"
60
+ :open="(title, icon, type, payload) => openPanel(title, icon, type, payload, n + 1)"
61
+ :close="() => closePanel(panel)"
62
+ :expand="() => expandPanel(panel)"
63
+ :fullsize="() => fullsizePanel(panel)">
64
+ <component v-if="panels[panel.type].header" :is="panels[panel.type].header" :panel="panel" :payload="panel.payload" />
50
65
  </slot>
51
66
  </template>
52
67
  </panel>
@@ -78,6 +93,11 @@
78
93
  import { Vue, Component, Prop } from 'vue-property-decorator';
79
94
  import Panel from './Panel.vue';
80
95
 
96
+ interface VisualOptions {
97
+ title: string;
98
+ icon?: string;
99
+ }
100
+
81
101
  interface IPanel {
82
102
  id: number;
83
103
  title: string;
@@ -86,6 +106,15 @@ interface IPanel {
86
106
  payload: any;
87
107
  isCollapsed: boolean;
88
108
  isCloseable: boolean;
109
+ open: (type: string, visOptions: VisualOptions, payload: any) => void;
110
+ close: () => void;
111
+ expand: () => void;
112
+ on: (eventName: string, func: (event: string, ...args: any[]) => any) => void;
113
+ off: (eventName: string, func: (event: string, ...args: any[]) => any) => void;
114
+ once: (eventName: string, func: (event: string, ...args: any[]) => any) => void;
115
+ emit: (event: string, ...args: any[]) => void;
116
+ isMultiple: () => boolean;
117
+ __events: Record<string, ((event: string, ...args: any[]) => any)[]>;
89
118
  }
90
119
 
91
120
  @Component({
@@ -95,9 +124,6 @@ interface IPanel {
95
124
  directives: {
96
125
  },
97
126
  filters: {
98
- },
99
- provide() {
100
- return { panelList: this }; // do not use Provide from vue-property-decorator
101
127
  }
102
128
  })
103
129
  export default class PanelList extends Vue {
@@ -163,7 +189,8 @@ export default class PanelList extends Vue {
163
189
  type,
164
190
  payload,
165
191
  isCollapsed: false,
166
- isCloseable: true
192
+ isCloseable: true,
193
+ __events: {}
167
194
  };
168
195
  if (!this.panelsStack.length) {
169
196
  newPanel.isCloseable = false;
@@ -172,9 +199,51 @@ export default class PanelList extends Vue {
172
199
  if (openIndex) {
173
200
  newStack = newStack.slice(0, openIndex);
174
201
  }
175
- newStack.push(newPanel);
176
202
  this.panelsStack = newStack;
177
- this.ensureOnlyTwoOpenPanels(newPanel.id);
203
+ this.$nextTick(() => { // щоб панелі змінювались при редагуванні
204
+ const n = newStack.length;
205
+ newPanel.emit = (event, ...args) => this.emitEvent(event, ...args);
206
+ newPanel.open = (type, visOptions, payload) => this.openPanel(visOptions.title, visOptions.icon, type, payload, n + 1);
207
+ newPanel.close = () => this.closePanel(newPanel);
208
+ newPanel.expand = () => this.expandPanel(newPanel);
209
+ newPanel.on = (eventName, func: (event: string, ...args: any[]) => any) => {
210
+ if (!newPanel.__events[eventName]) {
211
+ newPanel.__events[eventName] = [];
212
+ }
213
+ newPanel.__events[eventName].push(func);
214
+ };
215
+ newPanel.off = (eventName, func: (event: string, ...args: any[]) => any) => {
216
+ if (newPanel.__events[eventName]) {
217
+ newPanel.__events[eventName] = newPanel.__events[eventName].filter(f => f !== func);
218
+ }
219
+ };
220
+ newPanel.once = (eventName, func: (event: string, ...args: any[]) => any) => {
221
+ const wrapper = (...args) => {
222
+ func(...args);
223
+ newPanel.off(eventName, wrapper);
224
+ };
225
+ newPanel.on(eventName, wrapper);
226
+ };
227
+ newPanel.isMultiple = () => this.isOpenMultiple;
228
+ newPanel.getPayload = () => newPanel.payload;
229
+ newPanel.setPayload = (value: any) => {
230
+ console.info(value);
231
+ newPanel.payload = value;
232
+ }
233
+ newStack.push(newPanel);
234
+ this.panelsStack = newStack;
235
+ this.ensureOnlyTwoOpenPanels(newPanel.id);
236
+ });
237
+ }
238
+
239
+ emitEvent(event: string, ...args: any[]) {
240
+ for (const panel of this.panelsStack) {
241
+ if (panel.__events[event]) {
242
+ for (const func of panel.__events[event]) {
243
+ func(event, ...args);
244
+ }
245
+ }
246
+ }
178
247
  }
179
248
 
180
249
  closePanel(panel: IPanel) {
@@ -47,7 +47,7 @@
47
47
 
48
48
  </template>
49
49
  <script>
50
- import { Vue, Component, Prop, Watch } from 'vue-property-decorator';
50
+ import { Vue, Component, Prop, Watch, ModelSync } from 'vue-property-decorator';
51
51
  import itfCheckboxGroup from '../checkbox/CheckboxGroup.vue';
52
52
  import itfButton from '../button/Button.vue';
53
53
  import itfIcon from '../icon/Icon.vue';
@@ -77,6 +77,7 @@ class itfTable2 extends Vue {
77
77
  @Prop({ type: String, default: null, validator: (val) => ['order', 'checkbox', 'toggle', 'property'].includes(val) }) indicatorType;
78
78
  @Prop({ type: String, default: null }) stateName; // save state to storage
79
79
  @Prop({ type: Object, default: () => ({}) }) schema;
80
+ @ModelSync('value', 'input', { type: Array, default: () => ([]) }) selectedIds;
80
81
  @Prop() currency;
81
82
  @Prop() currencies;
82
83
  @Prop(Boolean) addNewRows;
@@ -95,7 +96,6 @@ class itfTable2 extends Vue {
95
96
  selectedIds: [],
96
97
  columns: []
97
98
  };
98
- selectedIds = [];
99
99
 
100
100
  getTableState() {
101
101
  const list = this.schema?.properties || [];
@@ -27,14 +27,13 @@
27
27
  <a href="" @click.prevent.stop="$emit('toggle', item)" v-else-if="indicatorType === 'toggle'">
28
28
  <template v-if="subrowsProperty && item[subrowsProperty] && item[subrowsProperty].length">
29
29
  <template v-if="item[subrowsProperty] && item[subrowsProperty].length && !isExpanded(item)">
30
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-plus-square" viewBox="0 0 16 16">
31
- <path d="M14 1a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1zM2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2z"/>
32
- <path d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4"/>
30
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-caret-right-fill" viewBox="0 0 16 16">
31
+ <path d="m12.14 8.753-5.482 4.796c-.646.566-1.658.106-1.658-.753V3.204a1 1 0 0 1 1.659-.753l5.48 4.796a1 1 0 0 1 0 1.506z"/>
33
32
  </svg>
34
33
  </template>
35
34
  <template v-else>
36
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-square" viewBox="0 0 16 16">
37
- <path d="M14 1a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1zM2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2z"/>
35
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-caret-down-fill" viewBox="0 0 16 16">
36
+ <path d="M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z"/>
38
37
  </svg>
39
38
  </template>
40
39
  </template>
@@ -52,9 +51,9 @@
52
51
  :style="`width: ${column.width}px; max-width: ${column.width}px; left: ${column.left}px;`"
53
52
  :class="{'sticky': column.pinned, 'last-sticky-column': k === lastPinnedIndex, 'flex-grow-1': column.grow, 'px-2': !(column.editable && editable), 'editable': column.editable && editable}"
54
53
  class="table-view-item-value d-flex h-100">
55
- <slot :name="`column.${column.property}`" :level="level" :editable="column.editable && editable" :item="item" :column="column" :update="(val) => updateValue(item, val, n, column)" :value="getValue(item, column)">
54
+ <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)">
56
55
  <template v-if="column.editable && editable">
57
- <slot :name="`edit.${column.type}`" :level="level" :update="(val) => updateValue(item, val, n, column)" :value="getValue(item, column)" :item="item" :column="column">
56
+ <slot :name="`edit.${column.type}`" :level="level" :toggle="() => $emit('toggle', item)" :update="(val) => updateValue(item, val, n, column)" :value="getValue(item, column)" :item="item" :column="column">
58
57
  <itf-text-field class="w-100" v-if="column.type === 'text'" :value="getValue(item, column)" @input="updateValue(item, $event, n, column)" />
59
58
  <itf-hours-field
60
59
  class="w-100"
@@ -69,7 +68,7 @@
69
68
  </slot>
70
69
  </template>
71
70
  <div v-else class="h-100 align-items-center d-flex w-100">
72
- <slot :name="`format.${column.type}`" :level="level" :value="getValue(item, column)" :update="(value) => updateValue(item, value, n, column)" :item="item" :column="column">
71
+ <slot :name="`format.${column.type}`" :toggle="() => $emit('toggle', item)" :level="level" :value="getValue(item, column)" :update="(value) => updateValue(item, value, n, column)" :item="item" :column="column">
73
72
  {{getValue(item, column)}}
74
73
  </slot>
75
74
  </div>