@itfin/components 1.0.101 → 1.0.104

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.101",
3
+ "version": "1.0.104",
4
4
  "main": "dist/itfin-components.umd.js",
5
5
  "unpkg": "dist/itfin-components.common.js",
6
6
  "author": "Vitalii Savchuk <esvit666@gmail.com>",
@@ -1,37 +1,3 @@
1
- <template>
2
-
3
- <nuxt-link
4
- @click.native="$emit('click', $event)"
5
- class="itf-button btn"
6
- tabindex="0"
7
- type="button"
8
- :to="toLink || {}"
9
- :disabled="disabled"
10
- :target="target"
11
- :tag="isLink ? 'a' : 'button'"
12
- :event="isLink ? 'click' : []"
13
- :class="{
14
- [`btn-${color}`]: color,
15
- 'itf-button__block': block,
16
- 'labeled': labeled,
17
- 'disabled': disabled || loading,
18
- 'btn-primary': primary,
19
- 'btn-basic': !primary && !secondary && !color,
20
- 'btn-secondary': secondary,
21
- 'btn-sm': small,
22
- 'btn-lg': large,
23
- // 'px-3': small && !icon,
24
- // 'px-5': large && !icon,
25
- // 'px-4': !icon && !large && !small,
26
- 'btn-icon': icon,
27
- 'loading': loading
28
- }">
29
- <div class="itf-spinner" :class="{'itf-spinner__white': primary}" v-if="loading"></div>
30
- <div v-if="loading && loadingText">{{loadingText}}</div>
31
- <slot v-else></slot>
32
- </nuxt-link>
33
-
34
- </template>
35
1
  <style lang="scss">
36
2
  @import '../../assets/scss/main';
37
3
  //@import '~bootstrap/scss/buttons';
@@ -141,10 +107,41 @@
141
107
  }
142
108
  }
143
109
  </style>
110
+ <!---template>
111
+
112
+ <nuxt-link
113
+ @click.native="$emit('click', $event)"
114
+ :disabled="disabled"
115
+ :target="target"
116
+ :tag="isLink ? 'a' : 'button'"
117
+ :event="isLink ? 'click' : []"
118
+ :class="{
119
+ [`btn-${color}`]: color,
120
+ 'itf-button__block': block,
121
+ 'labeled': labeled,
122
+ 'disabled': disabled || loading,
123
+ 'btn-primary': primary,
124
+ 'btn-basic': !primary && !secondary && !color,
125
+ 'btn-secondary': secondary,
126
+ 'btn-sm': small,
127
+ 'btn-lg': large,
128
+ // 'px-3': small && !icon,
129
+ // 'px-5': large && !icon,
130
+ // 'px-4': !icon && !large && !small,
131
+ 'btn-icon': icon,
132
+ 'loading': loading
133
+ }">
134
+ <div class="itf-spinner" :class="{'itf-spinner__white': primary}" v-if="loading"></div>
135
+ <div v-if="loading && loadingText">{{loadingText}}</div>
136
+ <slot v-else></slot>
137
+ </nuxt-link>
138
+
139
+ </template-->
144
140
  <script>
145
141
  import { Vue, Component, Prop } from 'vue-property-decorator';
146
142
 
147
143
  export default @Component({
144
+ functional: true,
148
145
  name: 'itfButton',
149
146
  components: {
150
147
  }
@@ -164,18 +161,73 @@ class itfButton extends Vue {
164
161
  @Prop({ type: [String, Object] }) to;
165
162
  @Prop(String) href;
166
163
  @Prop(String) target;
164
+ @Prop() class;
167
165
 
168
- get toLink() {
169
- if (this.to) {
170
- return this.to || {};
171
- } else if (this.href) {
172
- return { path: this.href };
166
+ render (createElement, { data, slots, children, props }) {
167
+ const {
168
+ to, href, target, disabled, color, block, loading, labeled, secondary, primary, small, large, icon, loadingText,
169
+ class: classNames
170
+ } = props;
171
+ const component = to ? 'nuxt-link' : (props.href ? 'a' : 'button');
172
+ const staticClass = (data.staticClass || '') + ' itf-button btn';
173
+ const comProps = {
174
+ ...data,
175
+ attrs: {
176
+ ...data.attrs,
177
+ tabindex: 0
178
+ },
179
+ class: {
180
+ [`btn-${color}`]: color,
181
+ 'itf-button__block': block,
182
+ 'labeled': labeled,
183
+ 'disabled': disabled || loading,
184
+ 'btn-primary': primary,
185
+ 'btn-basic': !primary && !secondary && !color,
186
+ 'btn-secondary': secondary,
187
+ 'btn-sm': small,
188
+ 'btn-lg': large,
189
+ // 'px-3': small && !icon,
190
+ // 'px-5': large && !icon,
191
+ // 'px-4': !icon && !large && !small,
192
+ 'btn-icon': icon,
193
+ 'loading': loading
194
+ },
195
+ props,
196
+ staticClass
197
+ };
198
+ if (data.class) {
199
+ if (typeof data.class === 'string') {
200
+ comProps.class[data.class] = true;
201
+ } else {
202
+ comProps.class = {
203
+ ...data.class,
204
+ ...comProps.class
205
+ };
206
+ }
173
207
  }
174
- return {};
175
- }
176
-
177
- get isLink() {
178
- return this.href || this.to;
208
+ if (component === 'button') {
209
+ comProps.attrs.type = 'button';
210
+ }
211
+ if (href) {
212
+ comProps.attrs.href = href;
213
+ }
214
+ if (target) {
215
+ comProps.attrs.target = target;
216
+ }
217
+ let childs = [];
218
+ if (loading) {
219
+ childs.push([createElement('div', { staticClass: 'itf-spinner', class: { 'itf-spinner__white': primary } })]);
220
+ }
221
+ if (loading && loadingText) {
222
+ childs.push([createElement('div', loadingText)]);
223
+ } else if (children && children.length) {
224
+ childs.push(...children);
225
+ }
226
+ return createElement(
227
+ component,
228
+ comProps,
229
+ childs
230
+ )
179
231
  }
180
232
  }
181
233
  </script>
@@ -86,7 +86,7 @@ class itfDropdown extends Vue {
86
86
  return;
87
87
  }
88
88
  const { default: Dropdown } = await import('bootstrap/js/src/dropdown.js');
89
- this.modalEl = new Dropdown(this.$refs.toggle.$el, {
89
+ this.modalEl = new Dropdown(this.$refs.toggle, {
90
90
  reference: 'toggle',
91
91
  autoClose: this.autoclose
92
92
  });
@@ -1103,7 +1103,7 @@ export default {
1103
1103
  this.searchEl === undefined ||
1104
1104
  ignoredButtons
1105
1105
  .filter(Boolean)
1106
- .some((ref) => ref.$el.contains(event.target) || ref === event.target)
1106
+ .some((ref) => ref === event.target || (ref.$el || ref).contains(event.target))
1107
1107
  ) {
1108
1108
  event.preventDefault()
1109
1109
  return
@@ -32,7 +32,7 @@ class itfTab extends Vue {
32
32
  get active() {
33
33
  if (this.to) {
34
34
  const route = this.$router.resolve(this.to);
35
- return this.$route.path === (route && route.href);
35
+ return this.$route.fullPath === (route && route.href);
36
36
  }
37
37
  return this.tabsManager && this.tabsManager.getValue() === this.id;
38
38
  }