@itfin/components 2.0.95 → 2.0.96

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": "2.0.95",
3
+ "version": "2.0.96",
4
4
  "author": "Vitalii Savchuk <esvit666@gmail.com>",
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -0,0 +1,109 @@
1
+ <template>
2
+
3
+ <div>
4
+ <div v-for="(item, n) in items" :key="n">
5
+ <slot name="item" :item="item" :isChecked="isChecked(item)" :onToggle="(isChecked) => onToggleOption(item, isChecked)" :isDisabled="disabled || isDisabled(item)">
6
+ <itf-checkbox
7
+ :value="isChecked(item)"
8
+ :label="item.name"
9
+ :disabled="disabled || isDisabled(item)"
10
+ @input="onToggleOption(item, $event)"
11
+ >
12
+ {{ item[itemKey] || item }}
13
+ </itf-checkbox>
14
+ </slot>
15
+
16
+ <div v-if="item[childrenKey] && item[childrenKey].length" class="ps-4 mb-2">
17
+ <itf-nested-checkbox-group
18
+ :value="value"
19
+ @input="$emit('input', $event)"
20
+ :items="item[childrenKey]"
21
+ :disabled="disabled || isDisabled(item)"
22
+ :item-key="itemKey"
23
+ :children-key="childrenKey"
24
+ :max="max"
25
+ :disabled-ids="disabledIds"
26
+ >
27
+ <template v-for="(_, name) in $slots" #[name]="slotData">
28
+ <slot :name="name" v-bind="slotData || {}"/>
29
+ </template>
30
+ <template v-for="(_, name) in $scopedSlots" #[name]="slotData">
31
+ <slot :name="name" v-bind="slotData || {}"/>
32
+ </template>
33
+ </itf-nested-checkbox-group>
34
+ </div>
35
+ </div>
36
+
37
+ <slot />
38
+ </div>
39
+
40
+ </template>
41
+ <script>
42
+ import { Vue, Component, Prop, Model } from 'vue-property-decorator';
43
+ import itfCheckbox from './Checkbox';
44
+ import itfTableRows from '@itfin/components/src/components/table/TableRows.vue';
45
+
46
+ export default @Component({
47
+ name: 'itfNestedCheckboxGroup',
48
+ components: {
49
+ itfTableRows,
50
+ itfCheckbox
51
+ },
52
+ })
53
+ class itfNestedCheckboxGroup extends Vue {
54
+ @Model('input', { type: Array, default: () => [] }) value;
55
+
56
+ @Prop(Array) items;
57
+ @Prop(Boolean) disabled;
58
+ @Prop({ type: Array, default: () => [] }) disabledIds;
59
+
60
+ @Prop({ type: String }) itemKey;
61
+ @Prop({ type: String, default: 'children' }) childrenKey;
62
+
63
+ @Prop(Number) max;
64
+
65
+ onToggleOption(value, isChecked) {
66
+ const arr = this.value ? [ ...this.value ] : [];
67
+ if (value[this.childrenKey] && value[this.childrenKey].length) {
68
+ for (const child of value[this.childrenKey]) {
69
+ const index = arr.findIndex(item => this.itemKey ? item[this.itemKey] === child[this.itemKey] : item === child);
70
+ if (index !== -1 && isChecked === false) {
71
+ arr.splice(index, 1);
72
+ } else if (isChecked === true) {
73
+ arr.push(child);
74
+ }
75
+ }
76
+ this.$emit('input', arr);
77
+ return;
78
+ }
79
+ const index = this.getCheckedIndex(value);
80
+ if (index !== -1 && isChecked === false) {
81
+ arr.splice(index, 1);
82
+ } else if (isChecked === true) {
83
+ arr.push(value);
84
+ }
85
+ this.$emit('input', arr);
86
+ }
87
+
88
+ getCheckedIndex(value) {
89
+ if (this.itemKey) {
90
+ return this.value && this.value.findIndex(item => item[this.itemKey] === value[this.itemKey]);
91
+ }
92
+ return this.value.indexOf(value);
93
+ }
94
+
95
+ isChecked(value) {
96
+ if (value[this.childrenKey] && value[this.childrenKey].length) {
97
+ return value[this.childrenKey].every(child => this.isChecked(child)) || this.getCheckedIndex(value) !== -1;
98
+ }
99
+ return this.getCheckedIndex(value) !== -1;
100
+ }
101
+
102
+ isDisabled(value) {
103
+ if (this.disabledIds.includes(value)) {
104
+ return true;
105
+ }
106
+ return this.getCheckedIndex(value) === -1 && (this.max !== 'undefined' && this.value.length >= this.max);
107
+ }
108
+ }
109
+ </script>
@@ -13,7 +13,7 @@
13
13
  </slot>
14
14
  <itf-button icon @click="close" :aria-label="$t('components.close')" class="btn-close"></itf-button>
15
15
  </div>
16
- <div class="modal-body" v-if="value">
16
+ <div class="modal-body" v-if="value" v-loading="loading">
17
17
  <slot></slot>
18
18
  </div>
19
19
  <div class="modal-footer" v-if="$slots.footer">
@@ -28,6 +28,7 @@
28
28
  <script>
29
29
  import { Vue, Component, Prop, Watch, PropSync, Inject } from 'vue-property-decorator';
30
30
  import itfButton from '../button/Button';
31
+ import loading from '../../directives/loading';
31
32
 
32
33
  let globalModalIndex = 0; // base modal z-index
33
34
  let globalZIndexStack = 300; // base modal z-index
@@ -37,6 +38,9 @@ export default @Component({
37
38
  name: 'itfModal',
38
39
  components: {
39
40
  itfButton
41
+ },
42
+ directives: {
43
+ loading
40
44
  }
41
45
  })
42
46
  class itfModal extends Vue {
@@ -47,6 +51,7 @@ class itfModal extends Vue {
47
51
  @Prop({ type: String, default: '', validator: (value) => ['', 'sm', 'lg', 'xl'].includes(value) }) size;
48
52
 
49
53
  @Prop({ type: Number, default: 500 }) animationDuration
54
+ @Prop({ type: Boolean, default: false }) loading;
50
55
  @Prop({ type: Boolean, default: false }) fullscreen;
51
56
  @Prop({ type: Boolean, default: false }) basic;
52
57
  @Prop({ type: Boolean, default: false }) image;