@itfin/components 1.0.99 → 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.99",
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,38 +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
- {{toLink}}
33
- </nuxt-link>
34
-
35
- </template>
36
1
  <style lang="scss">
37
2
  @import '../../assets/scss/main';
38
3
  //@import '~bootstrap/scss/buttons';
@@ -142,10 +107,41 @@
142
107
  }
143
108
  }
144
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-->
145
140
  <script>
146
141
  import { Vue, Component, Prop } from 'vue-property-decorator';
147
142
 
148
143
  export default @Component({
144
+ functional: true,
149
145
  name: 'itfButton',
150
146
  components: {
151
147
  }
@@ -166,17 +162,61 @@ class itfButton extends Vue {
166
162
  @Prop(String) href;
167
163
  @Prop(String) target;
168
164
 
169
- get toLink() {
170
- if (this.to) {
171
- return this.to || {};
172
- } else if (this.href) {
173
- 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';
174
199
  }
175
- return {};
176
- }
177
-
178
- get isLink() {
179
- 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
+ )
180
220
  }
181
221
  }
182
222
  </script>
@@ -111,16 +111,16 @@ class itfDropdown extends Vue {
111
111
  // }
112
112
  // }
113
113
  //
114
- // show() {
115
- // if (this.modalEl) {
116
- // this.modalEl.show();
117
- // }
118
- // }
119
- //
120
- // hide() {
121
- // if (this.modalEl) {
122
- // this.modalEl.hide();
123
- // }
124
- // }
114
+ show() {
115
+ if (this.modalEl) {
116
+ this.modalEl.show();
117
+ }
118
+ }
119
+
120
+ hide() {
121
+ if (this.modalEl) {
122
+ this.modalEl.hide();
123
+ }
124
+ }
125
125
  }
126
126
  </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