@itfin/components 1.0.37 → 1.0.41

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.0.37",
3
+ "version": "1.0.41",
4
4
 
5
5
  "main": "dist/itfin-components.umd.js",
6
6
  "unpkg": "dist/itfin-components.common.js",
@@ -42,7 +42,7 @@ $input-focus-border: rgb(11 49 79 / 25%);
42
42
  $form-check-input-border: 1px solid rgba(#000, .08);
43
43
  $form-switch-focus-color: tint-color($primary, 50%);
44
44
 
45
- $modal-backdrop-bg: #fff;
45
+ $modal-backdrop-bg: #999;
46
46
  $modal-backdrop-opacity: .25;
47
47
  $modal-content-border-radius: 0;
48
48
 
@@ -73,6 +73,8 @@
73
73
  import { Vue, Component, Provide } from 'vue-property-decorator';
74
74
  import Message from './message';
75
75
 
76
+ let globalApp = null;
77
+
76
78
  export default @Component({
77
79
  name: 'itfApp',
78
80
  components: {}
@@ -80,10 +82,12 @@ export default @Component({
80
82
  class itfApp extends Vue {
81
83
  @Provide() globalApp = this;
82
84
  @Provide() appendContext = function appendContext() {
83
- return this.$el;
85
+ return globalApp.$el;
84
86
  };
85
87
 
86
88
  created() {
89
+ globalApp = this;
90
+ Vue.prototype.$globalApp = this;
87
91
  Vue.prototype.$showSuccess = this.showSuccess.bind(this);
88
92
  Vue.prototype.$showError = this.showError.bind(this);
89
93
  Vue.prototype.$showMessage = this.showMessage.bind(this);
@@ -1,11 +1,15 @@
1
1
  <template>
2
2
 
3
- <button
4
- @click="$emit('click', $event)"
3
+ <nuxt-link
4
+ @click.native="$emit('click', $event)"
5
5
  :disabled="disabled"
6
6
  class="itf-button btn"
7
7
  tabindex="0"
8
8
  type="button"
9
+ :tag="isLink ? 'a' : 'button'"
10
+ :href="href"
11
+ :to="to || {}"
12
+ :target="target"
9
13
  :class="{
10
14
  [`btn-${color}`]: color,
11
15
  'itf-button__block': block,
@@ -25,7 +29,7 @@
25
29
  <div class="itf-spinner" :class="{'itf-spinner__white': primary}" v-if="loading"></div>
26
30
  <div v-if="loading && loadingText">{{loadingText}}</div>
27
31
  <slot v-else></slot>
28
- </button>
32
+ </nuxt-link>
29
33
 
30
34
  </template>
31
35
  <style lang="scss">
@@ -36,6 +40,9 @@
36
40
  display: inline-flex;
37
41
  align-items: center;
38
42
 
43
+ &.btn-primary {
44
+ color: #fff; // @todo remove when remove vuetify
45
+ }
39
46
  &.itf-button__block {
40
47
  display: block;
41
48
  width: 100%;
@@ -150,5 +157,12 @@ class itfButton extends Vue {
150
157
  @Prop(String) loadingText;
151
158
  @Prop(String) color;
152
159
  @Prop(Boolean) disabled;
160
+ @Prop({ type: [String, Object] }) to;
161
+ @Prop(String) href;
162
+ @Prop(String) target;
163
+
164
+ get isLink() {
165
+ return this.to || this.href;
166
+ }
153
167
  }
154
168
  </script>
@@ -1,9 +1,10 @@
1
1
  <template>
2
2
 
3
3
  <div class="itf-checkbox form-check" :class="{ 'form-switch': this.switch, 'itf-checkbox__large': large, 'itf-checkbox__medium': medium }">
4
- <input class="form-check-input" :id="id" slot="input" type="checkbox" name="checkbox" v-model="isChecked" :disabled="isDisabled" />
4
+ <input class="form-check-input" :id="id" type="checkbox" name="checkbox" v-model="isChecked" :disabled="isDisabled" />
5
5
  <label :for="id" slot="label" class="form-check-label">
6
6
  {{label}}
7
+ <slot name="icon"></slot>
7
8
  </label>
8
9
  </div>
9
10
 
@@ -15,7 +16,7 @@
15
16
  .form-check-input, .form-check-label {
16
17
  cursor: pointer;
17
18
  }
18
- &__large {
19
+ &__large.form-check {
19
20
  padding-left: $form-check-padding-start * 2;
20
21
  min-height: 2.5rem;
21
22
 
@@ -39,7 +40,7 @@
39
40
  }
40
41
  }
41
42
  }
42
- &__medium {
43
+ &__medium.form-check {
43
44
  padding-left: $form-check-padding-start * 1.5;
44
45
  min-height: 2rem;
45
46
 
@@ -0,0 +1,89 @@
1
+ <template>
2
+
3
+ <div class="itf-radio form-check" :class="{ 'itf-radio__large': large, 'itf-radio__medium': medium }">
4
+ <input class="form-check-input" :id="id" type="radio" :name="name" v-model="isChecked" :disabled="disabled" />
5
+ <label :for="id" slot="label" class="form-check-label">
6
+ {{label}}
7
+ <slot name="icon"></slot>
8
+ </label>
9
+ </div>
10
+
11
+ </template>
12
+ <style lang="scss">
13
+ @import '../../assets/scss/variables';
14
+
15
+ .itf-radio {
16
+ .form-check-input, .form-check-label {
17
+ cursor: pointer;
18
+ }
19
+ &__large.form-check {
20
+ padding-left: $form-check-padding-start * 2;
21
+ min-height: 2.5rem;
22
+
23
+ .form-check-label {
24
+ padding-top: 0.25rem;
25
+ }
26
+ .form-check-input {
27
+ margin-top: 0;
28
+ width: $form-check-input-width * 2;
29
+ height: $form-check-input-width * 2;
30
+ margin-left: -$form-check-padding-start * 2;
31
+ }
32
+ }
33
+ &__medium.form-check {
34
+ padding-left: $form-check-padding-start * 1.5;
35
+ min-height: 2rem;
36
+
37
+ .form-check-input {
38
+ margin-top: 0;
39
+ width: $form-check-input-width * 1.5;
40
+ height: $form-check-input-width * 1.5;
41
+ margin-left: -$form-check-padding-start * 1.5;
42
+ }
43
+ }
44
+ }
45
+ </style>
46
+ <script>
47
+ import { Vue, Component, Prop, Model, Inject } from 'vue-property-decorator';
48
+
49
+ let globalRadioId = 0;
50
+
51
+ export default @Component({
52
+ name: 'itfCheckbox',
53
+ components: {
54
+ }
55
+ })
56
+ class itfCheckbox extends Vue {
57
+ @Inject({ default: null }) checkboxGroup;
58
+
59
+ @Model('input') checked;
60
+ @Prop(String) label;
61
+ @Prop() value;
62
+ @Prop({ type: String, required: true }) name;
63
+
64
+ @Prop(Boolean) disabled;
65
+ @Prop(Boolean) medium;
66
+ @Prop(Boolean) large;
67
+
68
+ id = '';
69
+
70
+ created() {
71
+ globalRadioId += 1;
72
+ this.id = `radio${globalRadioId}`;
73
+ }
74
+
75
+ set isChecked(val) {
76
+ this.$emit('input', this.value);
77
+ }
78
+
79
+ get isChecked() {
80
+ if (this.itemKey) {
81
+ if (!this.checked || !this.value) {
82
+ return false;
83
+ }
84
+ return this.checked[this.itemKey] === this.value[this.itemKey];
85
+ }
86
+ return this.checked === this.value;
87
+ }
88
+ }
89
+ </script>
@@ -90,7 +90,8 @@ class itfForm extends Vue {
90
90
  }
91
91
 
92
92
  doValidation(showError = true) {
93
- const isValid = !this.components.filter(component => component.doValidation && !component.doValidation(true)).length;
93
+ // @todo remove validate when migrate from vuetify
94
+ const isValid = !this.components.filter(component => (component.doValidation && !component.doValidation(true)) || (component.validate && !component.validate(true))).length;
94
95
  if (showError && !isValid && this.$showError) {
95
96
  this.$showError('Please fix the errors below to proceed.', { duration: 3000 });
96
97
  }
@@ -13,10 +13,8 @@
13
13
  <div class="modal-body">
14
14
  <slot></slot>
15
15
  </div>
16
- <div class="modal-footer">
17
- <slot name="footer">
18
- <itf-button primary data-bs-dismiss="modal">Close</itf-button>
19
- </slot>
16
+ <div class="modal-footer" v-if="$slots.footer">
17
+ <slot name="footer"></slot>
20
18
  </div>
21
19
  </div>
22
20
  </div>
@@ -36,9 +34,9 @@
36
34
  }
37
35
  }
38
36
  .modal-open .itf-app {
39
- -webkit-filter: blur(5px);
40
- -moz-filter: blur(5px);
41
- filter: blur(5px);
37
+ -webkit-filter: blur(5px) grayscale(1);
38
+ -moz-filter: blur(5px) grayscale(1);
39
+ filter: blur(5px) grayscale(1);
42
40
  }
43
41
  </style>
44
42
  <script>
@@ -162,5 +160,12 @@ class itfModal extends Vue {
162
160
  this.value = false;
163
161
  }
164
162
  }
163
+
164
+ scrollModalTop() {
165
+ const scrollEl = this.$el.closest('.itf-modal');
166
+ if (scrollEl) {
167
+ scrollEl.scrollTop = 0;
168
+ }
169
+ }
165
170
  }
166
171
  </script>
@@ -132,7 +132,8 @@ class itfPopover extends Vue {
132
132
 
133
133
  hide() {
134
134
  if (this.modalEl) {
135
- this.modalEl.hide();
135
+ // треба затримка щоб попав не показався знову через отримання фокусу
136
+ setTimeout(() => this.modalEl.hide(), 10);
136
137
  }
137
138
  }
138
139
  }
@@ -8,12 +8,15 @@
8
8
  </div>
9
9
 
10
10
  <input
11
+ ref="input"
11
12
  autocomplete="off"
12
13
  :placeholder="placeholder"
13
14
  :class="{ 'is-invalid': isInvalid(), 'is-valid': isSuccess() }"
14
15
  class="itf-text-field__input form-control"
15
16
  type="text"
16
17
  :value="value"
18
+ :disabled="disabled"
19
+ :readonly="readonly"
17
20
  @input="onInput($event.target.value)"
18
21
  />
19
22
 
@@ -65,6 +68,8 @@ class itfTextField extends Vue {
65
68
  @Prop(String) prependIcon;
66
69
  @Prop(String) placeholder;
67
70
  @Prop(Boolean) clearable;
71
+ @Prop(Boolean) disabled;
72
+ @Prop(Boolean) readonly;
68
73
  @Prop({ type: [Number, String], default: 0 }) delayInput;
69
74
 
70
75
  onInput = null;
@@ -80,5 +85,13 @@ class itfTextField extends Vue {
80
85
  isSuccess() {
81
86
  return this.itemLabel && this.itemLabel.isHasSuccess();
82
87
  }
88
+
89
+ insertTextToCurrentPosition(text) {
90
+ const position = this.$refs.input.selectionStart;
91
+ const value = this.value || '';
92
+ const startText = value.slice(0, position);
93
+ const endText = value.slice(position);
94
+ this.$emit('input', `${startText}${text}${endText}`);
95
+ }
83
96
  }
84
97
  </script>
@@ -8,7 +8,10 @@
8
8
  </div>
9
9
  <div v-if="autogrow" class="itf-textarea__autogrow-text form-control">{{value}}&nbsp;</div>
10
10
  <textarea
11
+ ref="input"
11
12
  :rows="rows"
13
+ :readonly="readonly"
14
+ :disabled="disabled"
12
15
  :placeholder="placeholder"
13
16
  :class="{ 'is-invalid': isInvalid(), 'is-valid': isSuccess() }"
14
17
  class="itf-textarea__input form-control"
@@ -65,6 +68,8 @@ class itfTextarea extends Vue {
65
68
  @Prop(String) prependIcon;
66
69
  @Prop(String) placeholder;
67
70
  @Prop(Boolean) autogrow;
71
+ @Prop(Boolean) disabled;
72
+ @Prop(Boolean) readonly;
68
73
  @Prop({ type: [Number, String], default: 0 }) delayInput;
69
74
  @Prop({ type: [Number, String] }) rows;
70
75
 
@@ -81,5 +86,13 @@ class itfTextarea extends Vue {
81
86
  isSuccess() {
82
87
  return this.itemLabel && this.itemLabel.isHasSuccess();
83
88
  }
89
+
90
+ insertTextToCurrentPosition(text) {
91
+ const position = this.$refs.input.selectionStart;
92
+ const value = this.value || '';
93
+ const startText = value.slice(0, position);
94
+ const endText = value.slice(position);
95
+ this.$emit('input', `${startText}${text}${endText}`);
96
+ }
84
97
  }
85
98
  </script>