@itfin/components 1.0.100 → 1.0.103

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.100",
3
+ "version": "1.0.103",
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
  }
@@ -165,18 +161,73 @@ class itfButton extends Vue {
165
161
  @Prop({ type: [String, Object] }) to;
166
162
  @Prop(String) href;
167
163
  @Prop(String) target;
164
+ @Prop() class;
168
165
 
169
- get toLink() {
170
- if (this.to) {
171
- return this.to || {};
172
- } else if (this.href) {
173
- 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
+ }
174
207
  }
175
- return {};
176
- }
177
-
178
- get isLink() {
179
- 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
+ )
180
231
  }
181
232
  }
182
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