@itfin/components 1.0.101 → 1.0.102

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.102",
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
  }
@@ -165,17 +162,61 @@ class itfButton extends Vue {
165
162
  @Prop(String) href;
166
163
  @Prop(String) target;
167
164
 
168
- get toLink() {
169
- if (this.to) {
170
- return this.to || {};
171
- } else if (this.href) {
172
- return { path: this.href };
165
+ render (createElement, { data, slots, children, props }) {
166
+ const {
167
+ to, href, target, disabled, color, block, loading, labeled, secondary, primary, small, large, icon, loadingText
168
+ } = props;
169
+ const component = to ? 'nuxt-link' : (props.href ? 'a' : 'button');
170
+ const staticClass = (data.staticClass || '') + ' itf-button btn';
171
+ const comProps = {
172
+ ...data,
173
+ attrs: {
174
+ ...data.attrs,
175
+ tabindex: 0
176
+ },
177
+ class: {
178
+ ...(data.class || {}),
179
+ [`btn-${color}`]: color,
180
+ 'itf-button__block': block,
181
+ 'labeled': labeled,
182
+ 'disabled': disabled || loading,
183
+ 'btn-primary': primary,
184
+ 'btn-basic': !primary && !secondary && !color,
185
+ 'btn-secondary': secondary,
186
+ 'btn-sm': small,
187
+ 'btn-lg': large,
188
+ // 'px-3': small && !icon,
189
+ // 'px-5': large && !icon,
190
+ // 'px-4': !icon && !large && !small,
191
+ 'btn-icon': icon,
192
+ 'loading': loading
193
+ },
194
+ props,
195
+ staticClass
196
+ };
197
+ if (component === 'button') {
198
+ comProps.attrs.type = 'button';
173
199
  }
174
- return {};
175
- }
176
-
177
- get isLink() {
178
- return this.href || this.to;
200
+ if (href) {
201
+ comProps.attrs.href = href;
202
+ }
203
+ if (target) {
204
+ comProps.attrs.target = target;
205
+ }
206
+ let childs = [];
207
+ if (loading) {
208
+ childs.push([createElement('div', { staticClass: 'itf-spinner', class: { 'itf-spinner__white': primary } })]);
209
+ }
210
+ if (loading && loadingText) {
211
+ childs.push([createElement('div', loadingText)]);
212
+ } else if (children && children.length) {
213
+ childs.push(...children);
214
+ }
215
+ return createElement(
216
+ component,
217
+ comProps,
218
+ childs
219
+ )
179
220
  }
180
221
  }
181
222
  </script>
@@ -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