@vue-interface/btn-activity 2.0.0-beta.2 → 2.0.0-beta.3

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.
@@ -178,7 +178,10 @@ const W = /* @__PURE__ */ N(k, [["render", H]]), D = function(t) {
178
178
  return s || 0;
179
179
  }, h = function(t, e) {
180
180
  const i = (t.ownerDocument || document).defaultView;
181
- setTimeout(e, D(i == null ? void 0 : i.getComputedStyle(t).animationDuration));
181
+ setTimeout(
182
+ e,
183
+ D(i == null ? void 0 : i.getComputedStyle(t).animationDuration)
184
+ );
182
185
  }, L = {
183
186
  name: "BtnActivity",
184
187
  components: {
@@ -221,15 +224,21 @@ const W = /* @__PURE__ */ N(k, [["render", H]]), D = function(t) {
221
224
  active: this.active,
222
225
  "btn-activity": this.activity,
223
226
  [`btn-activity-${this.orientation.replace("btn-activity-", "")}`]: !!this.orientation,
224
- [`'btn-activity-indicator-${this.indicatorProps.type.replace("btn-activity-indicator-", "")}`]: !!this.indicatorProps.type
227
+ [`'btn-activity-indicator-${this.indicatorProps.type.replace(
228
+ "btn-activity-indicator-",
229
+ ""
230
+ )}`]: !!this.indicatorProps.type
225
231
  };
226
232
  },
227
233
  indicatorProps() {
228
- return Object.assign({
229
- type: "spinner"
230
- }, (typeof this.indicator == "string" ? {
231
- type: this.indicator
232
- } : this.indicator) || {});
234
+ return Object.assign(
235
+ {
236
+ type: "spinner"
237
+ },
238
+ (typeof this.indicator == "string" ? {
239
+ type: this.indicator
240
+ } : this.indicator) || {}
241
+ );
233
242
  }
234
243
  },
235
244
  watch: {
@@ -43,11 +43,7 @@ declare const _sfc_main: {
43
43
  minWidth: string | undefined;
44
44
  height: string | undefined;
45
45
  maxHeight: string | undefined;
46
- minHeight: string | undefined; /**
47
- * Disable the button.
48
- *
49
- * @property {Boolean}
50
- */
46
+ minHeight: string | undefined;
51
47
  };
52
48
  };
53
49
  mounted(): Promise<void>;
@@ -81,15 +77,15 @@ declare const _sfc_main: {
81
77
  };
82
78
  })[];
83
79
  props: {
84
- active: BooleanConstructor;
80
+ active: BooleanConstructor; /**
81
+ * Make the button appear with the active state.
82
+ *
83
+ * @property {Boolean}
84
+ */
85
85
  block: BooleanConstructor;
86
86
  componentPrefix: {
87
87
  type: StringConstructor;
88
- default: string; /**
89
- * Display the button as block width.
90
- *
91
- * @property {Boolean}
92
- */
88
+ default: string;
93
89
  };
94
90
  disabled: BooleanConstructor;
95
91
  label: StringConstructor;
@@ -194,7 +190,7 @@ declare const _sfc_main: {
194
190
  [x: string]: any;
195
191
  disabled: any;
196
192
  active: any;
197
- 'btn-activity': any;
193
+ "btn-activity": any;
198
194
  };
199
195
  indicatorProps(): any;
200
196
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue-interface/btn-activity",
3
- "version": "2.0.0-beta.2",
3
+ "version": "2.0.0-beta.3",
4
4
  "description": "A Vue activity button component.",
5
5
  "files": [
6
6
  "index.js",
@@ -1,266 +1,271 @@
1
1
  <script lang="ts">
2
- import { ActivityIndicator } from '@vue-interface/activity-indicator';
3
- import { Btn } from '@vue-interface/btn';
2
+ import { ActivityIndicator } from "@vue-interface/activity-indicator";
3
+ import { Btn } from "@vue-interface/btn";
4
4
 
5
- const convertAnimationDelayToInt = function(delay: any) {
6
- const num = parseFloat(delay || 0);
7
- const matches = delay && delay.match(/m?s/);
8
- const unit = matches ? matches[0] : false;
5
+ const convertAnimationDelayToInt = function (delay: any) {
6
+ const num = parseFloat(delay || 0);
7
+ const matches = delay && delay.match(/m?s/);
8
+ const unit = matches ? matches[0] : false;
9
9
 
10
- let milliseconds;
10
+ let milliseconds;
11
11
 
12
- switch (unit) {
13
- case 's': // seconds
14
- milliseconds = num * 1000;
15
- break;
16
- case 'ms':
12
+ switch (unit) {
13
+ case "s": // seconds
14
+ milliseconds = num * 1000;
15
+ break;
16
+ case "ms":
17
17
  default:
18
- milliseconds = num;
19
- break;
20
- }
18
+ milliseconds = num;
19
+ break;
20
+ }
21
21
 
22
- return milliseconds || 0;
22
+ return milliseconds || 0;
23
23
  };
24
24
 
25
- const animated = function(el: HTMLElement, callback: Function) {
26
- const defaultView = (el.ownerDocument || document).defaultView;
25
+ const animated = function (el: HTMLElement, callback: Function) {
26
+ const defaultView = (el.ownerDocument || document).defaultView;
27
27
 
28
- setTimeout(callback, convertAnimationDelayToInt(defaultView?.getComputedStyle(el).animationDuration));
28
+ setTimeout(
29
+ callback,
30
+ convertAnimationDelayToInt(defaultView?.getComputedStyle(el).animationDuration)
31
+ );
29
32
  };
30
33
 
31
34
  export default {
32
-
33
- name: 'BtnActivity',
34
-
35
- components: {
36
- ActivityIndicator,
37
- Btn
35
+ name: "BtnActivity",
36
+
37
+ components: {
38
+ ActivityIndicator,
39
+ Btn,
40
+ },
41
+
42
+ props: {
43
+ /**
44
+ * Make the button appear with the active state.
45
+ *
46
+ * @property {Boolean}
47
+ */
48
+ active: Boolean,
49
+
50
+ /**
51
+ * Show the activity indicator inside the button.
52
+ *
53
+ * @property {Boolean}
54
+ */
55
+ activity: Boolean,
56
+
57
+ /**
58
+ * Display the button as block width.
59
+ *
60
+ * @property {Boolean}
61
+ */
62
+ block: Boolean,
63
+
64
+ /**
65
+ * Disable the button.
66
+ *
67
+ * @property {Boolean}
68
+ */
69
+ disabled: Boolean,
70
+
71
+ /**
72
+ * The type of activity indicator inside the button.
73
+ *
74
+ * @property {String}
75
+ */
76
+ indicator: {
77
+ type: [Object, String],
78
+ default: "spinner",
38
79
  },
39
80
 
40
- props: {
41
-
42
- /**
43
- * Make the button appear with the active state.
44
- *
45
- * @property {Boolean}
46
- */
47
- active: Boolean,
48
-
49
- /**
50
- * Show the activity indicator inside the button.
51
- *
52
- * @property {Boolean}
53
- */
54
- activity: Boolean,
55
-
56
- /**
57
- * Display the button as block width.
58
- *
59
- * @property {Boolean}
60
- */
61
- block: Boolean,
62
-
63
- /**
64
- * Disable the button.
65
- *
66
- * @property {Boolean}
67
- */
68
- disabled: Boolean,
69
-
70
- /**
71
- * The type of activity indicator inside the button.
72
- *
73
- * @property {String}
74
- */
75
- indicator: {
76
- type: [Object, String],
77
- default: 'spinner'
78
- },
79
-
80
- /**
81
- * The button label.
82
- *
83
- * @property {String}
84
- */
85
- label: String,
86
-
87
- /**
88
- * The orientation of the activity button inside the button.
89
- *
90
- * @property {String}
91
- */
92
- orientation: {
93
- type: String,
94
- default: 'right'
95
- },
81
+ /**
82
+ * The button label.
83
+ *
84
+ * @property {String}
85
+ */
86
+ label: String,
87
+
88
+ /**
89
+ * The orientation of the activity button inside the button.
90
+ *
91
+ * @property {String}
92
+ */
93
+ orientation: {
94
+ type: String,
95
+ default: "right",
96
+ },
96
97
 
97
- /**
98
- * The size of the button.
99
- *
100
- * @property {String}
101
- */
102
- size: {
103
- type: String,
104
- default: 'md'
105
- },
98
+ /**
99
+ * The size of the button.
100
+ *
101
+ * @property {String}
102
+ */
103
+ size: {
104
+ type: String,
105
+ default: "md",
106
+ },
106
107
 
107
- /**
108
- * The HTML tag.
109
- *
110
- * @property {String}
111
- */
112
- tag: String,
113
-
114
- /**
115
- * The variant of the button.
116
- *
117
- * @property {String}
118
- */
119
- variant: {
120
- type: String,
121
- default: 'primary'
122
- }
108
+ /**
109
+ * The HTML tag.
110
+ *
111
+ * @property {String}
112
+ */
113
+ tag: String,
114
+
115
+ /**
116
+ * The variant of the button.
117
+ *
118
+ * @property {String}
119
+ */
120
+ variant: {
121
+ type: String,
122
+ default: "primary",
123
123
  },
124
-
125
- data() {
126
- return {
127
- currentActivity: this.activity
128
- };
124
+ },
125
+
126
+ data() {
127
+ return {
128
+ currentActivity: this.activity,
129
+ };
130
+ },
131
+
132
+ computed: {
133
+ /**
134
+ * An object of classes to append to the button.
135
+ *
136
+ * @return void
137
+ */
138
+ classes() {
139
+ return {
140
+ disabled: this.disabled,
141
+ active: this.active,
142
+ "btn-activity": this.activity,
143
+ [`btn-activity-${this.orientation.replace("btn-activity-", "")}`]: !!this
144
+ .orientation,
145
+ [`'btn-activity-indicator-${this.indicatorProps.type.replace(
146
+ "btn-activity-indicator-",
147
+ ""
148
+ )}`]: !!this.indicatorProps.type,
149
+ };
129
150
  },
130
151
 
131
- computed: {
132
-
133
- /**
134
- * An object of classes to append to the button.
135
- *
136
- * @return void
137
- */
138
- classes() {
139
- return {
140
- 'disabled': this.disabled,
141
- 'active': this.active,
142
- 'btn-activity': this.activity,
143
- [`btn-activity-${this.orientation.replace('btn-activity-', '')}`]: !!this.orientation,
144
- [`'btn-activity-indicator-${this.indicatorProps.type.replace('btn-activity-indicator-', '')}`]: !!this.indicatorProps.type,
145
- };
152
+ indicatorProps() {
153
+ return Object.assign(
154
+ {
155
+ type: "spinner",
146
156
  },
147
-
148
- indicatorProps() {
149
- return Object.assign({
150
- type: 'spinner'
151
- }, (typeof this.indicator === 'string' ? {
152
- type: this.indicator
153
- } : this.indicator) || {});
154
- }
155
-
156
- },
157
-
158
- watch: {
159
-
160
- activity(value: boolean) {
161
- if(value) {
162
- this.showActivity();
157
+ (typeof this.indicator === "string"
158
+ ? {
159
+ type: this.indicator,
163
160
  }
164
- else {
165
- this.hideActivity();
166
- }
167
- }
168
-
161
+ : this.indicator) || {}
162
+ );
169
163
  },
170
-
171
- mounted() {
172
- if(this.activity) {
173
- this.showActivity();
174
- }
164
+ },
165
+
166
+ watch: {
167
+ activity(value: boolean) {
168
+ if (value) {
169
+ this.showActivity();
170
+ } else {
171
+ this.hideActivity();
172
+ }
175
173
  },
174
+ },
176
175
 
177
- methods: {
178
-
179
- /**
180
- * Disable the button.
181
- *
182
- * @return void
183
- */
184
- disable() {
185
- this.$el.disabled = true;
186
- this.$el.classList.add('disabled');
187
- },
188
-
189
- /**
190
- * Enable the button.
191
- *
192
- * @return void
193
- */
194
- enable() {
195
- this.$el.disabled = false;
196
- this.$el.classList.remove('disabled');
197
- },
198
-
199
- /**
200
- * Hide the activity indicator inside the button.
201
- *
202
- * @return void
203
- */
204
- hideActivity() {
205
- this.$el.classList.add('btn-hide-activity');
206
-
207
- animated(this.$el, () => {
208
- this.enable();
209
- this.currentActivity = false;
210
- this.$el.classList.remove('btn-activity', 'btn-hide-activity');
211
- this.$emit('hide-activity');
212
- });
213
- },
176
+ mounted() {
177
+ if (this.activity) {
178
+ this.showActivity();
179
+ }
180
+ },
181
+
182
+ methods: {
183
+ /**
184
+ * Disable the button.
185
+ *
186
+ * @return void
187
+ */
188
+ disable() {
189
+ this.$el.disabled = true;
190
+ this.$el.classList.add("disabled");
191
+ },
214
192
 
215
- /**
216
- * Show the activity indicator inside the button.
217
- *
218
- * @return void
219
- */
220
- showActivity() {
221
- this.currentActivity = true;
222
- this.disable();
223
-
224
- animated(this.$el, () => {
225
- this.$el.classList.add('btn-activity');
226
- this.$emit('show-activity');
227
- });
228
- },
193
+ /**
194
+ * Enable the button.
195
+ *
196
+ * @return void
197
+ */
198
+ enable() {
199
+ this.$el.disabled = false;
200
+ this.$el.classList.remove("disabled");
201
+ },
229
202
 
230
- /**
231
- * Show the activity indicator inside the button.
232
- *
233
- * @return void
234
- */
235
- toggle() {
236
- if(!this.currentActivity) {
237
- this.showActivity();
238
- }
239
- else {
240
- this.hideActivity();
241
- }
242
- }
203
+ /**
204
+ * Hide the activity indicator inside the button.
205
+ *
206
+ * @return void
207
+ */
208
+ hideActivity() {
209
+ this.$el.classList.add("btn-hide-activity");
210
+
211
+ animated(this.$el, () => {
212
+ this.enable();
213
+ this.currentActivity = false;
214
+ this.$el.classList.remove("btn-activity", "btn-hide-activity");
215
+ this.$emit("hide-activity");
216
+ });
217
+ },
243
218
 
244
- }
219
+ /**
220
+ * Show the activity indicator inside the button.
221
+ *
222
+ * @return void
223
+ */
224
+ showActivity() {
225
+ this.currentActivity = true;
226
+ this.disable();
227
+
228
+ animated(this.$el, () => {
229
+ this.$el.classList.add("btn-activity");
230
+ this.$emit("show-activity");
231
+ });
232
+ },
245
233
 
234
+ /**
235
+ * Show the activity indicator inside the button.
236
+ *
237
+ * @return void
238
+ */
239
+ toggle() {
240
+ if (!this.currentActivity) {
241
+ this.showActivity();
242
+ } else {
243
+ this.hideActivity();
244
+ }
245
+ },
246
+ },
246
247
  };
247
248
  </script>
248
249
 
249
250
  <style>
250
251
  @keyframes btn-activity-in {
251
- 0%, 100% {
252
- transform: scale(1);
253
- } 30% {
254
- transform: scale(.98);
255
- }
252
+ 0%,
253
+ 100% {
254
+ transform: scale(1);
255
+ }
256
+ 30% {
257
+ transform: scale(0.98);
258
+ }
256
259
  }
257
260
 
258
261
  @keyframes btn-activity-out {
259
- 0%, 100% {
260
- transform: scale(1);
261
- } 70% {
262
- transform: scale(.98);
263
- }
262
+ 0%,
263
+ 100% {
264
+ transform: scale(1);
265
+ }
266
+ 70% {
267
+ transform: scale(0.98);
268
+ }
264
269
  }
265
270
 
266
271
  .btn-activity-top,
@@ -271,79 +276,79 @@ export default {
271
276
  .btn.btn-activity-left,
272
277
  .btn-activity-right,
273
278
  .btn.btn-activity-right {
274
- display: inline-flex;
275
- position: relative;
276
- transition: all calc(333ms / 2) ease-in;
279
+ display: inline-flex;
280
+ position: relative;
281
+ transition: all calc(333ms / 2) ease-in;
277
282
  }
278
283
 
279
284
  .btn-activity-top .activity-indicator,
280
285
  .btn-activity-bottom .activity-indicator,
281
286
  .btn-activity-left .activity-indicator,
282
287
  .btn-activity-right .activity-indicator {
283
- opacity: 0;
284
- position: absolute;
285
- visibility: hidden;
286
- transition: opacity 333ms ease-in;
288
+ opacity: 0;
289
+ position: absolute;
290
+ visibility: hidden;
291
+ transition: opacity 333ms ease-in;
287
292
  }
288
293
 
289
294
  .btn-activity-top,
290
295
  .btn-activity-bottom {
291
- flex-direction: column;
292
- align-items: center;
296
+ flex-direction: column;
297
+ align-items: center;
293
298
  }
294
299
 
295
300
  .btn-activity-top .activity-indicator,
296
301
  .btn-activity-bottom .activity-indicator {
297
- margin-left: auto;
298
- margin-right: auto;
302
+ margin-left: auto;
303
+ margin-right: auto;
299
304
  }
300
305
 
301
306
  .btn-activity-top {
302
- flex-direction: column-reverse;
307
+ flex-direction: column-reverse;
303
308
  }
304
309
 
305
310
  .btn-activity-top .activity-indicator {
306
- padding-bottom: 1em;
311
+ padding-bottom: 1em;
307
312
  }
308
313
 
309
314
  .btn-activity-bottom .activity-indicator {
310
- padding-top: 1em;
315
+ padding-top: 1em;
311
316
  }
312
317
 
313
318
  .btn-activity-left,
314
319
  .btn-activity-right {
315
- align-items: center;
316
- justify-content: center;
320
+ align-items: center;
321
+ justify-content: center;
317
322
  }
318
323
 
319
324
  .btn-activity-left {
320
- flex-direction: row-reverse;
325
+ flex-direction: row-reverse;
321
326
  }
322
327
 
323
328
  .btn-activity-left .activity-indicator {
324
- padding-right: 1em;
329
+ padding-right: 1em;
325
330
  }
326
331
 
327
332
  .btn-activity-right .activity-indicator {
328
- padding-left: 1em;
333
+ padding-left: 1em;
329
334
  }
330
335
 
331
336
  .btn-activity:not(.btn-link) {
332
- animation: btn-activity-in 333ms;
337
+ animation: btn-activity-in 333ms;
333
338
  }
334
339
 
335
340
  .btn-hide-activity:not(.btn-link) {
336
- animation: btn-activity-out 333ms;
341
+ animation: btn-activity-out 333ms;
337
342
  }
338
343
 
339
344
  .btn-activity.btn-hide-activity .activity-indicator {
340
- opacity: 0;
345
+ opacity: 0;
341
346
  }
342
347
 
343
348
  .btn-activity .activity-indicator {
344
- opacity: 1;
345
- visibility: visible;
346
- position: relative;
347
- font-size: .55em;
349
+ opacity: 1;
350
+ visibility: visible;
351
+ position: relative;
352
+ font-size: 0.55em;
348
353
  }
349
354
  </style>