UNPKG

2.05 kBJavaScriptView Raw
1(function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3 typeof define === 'function' && define.amd ? define(factory) :
4 (global.StepIndicator = factory());
5}(this, (function () { 'use strict';
6
7 /*!
8 * nano-assign v1.0.0
9 * (c) 2017-present egoist <0x142857@gmail.com>
10 * Released under the MIT License.
11 */
12
13 var index = function(obj) {
14 var arguments$1 = arguments;
15
16 for (var i = 1; i < arguments.length; i++) {
17 // eslint-disable-next-line guard-for-in, prefer-rest-params
18 for (var p in arguments[i]) { obj[p] = arguments$1[i][p]; }
19 }
20 return obj
21 };
22
23 var nanoAssign_common = index;
24
25 var index$1 = {
26 name: 'StepIndicator',
27 functional: true,
28 props: {
29 total: {
30 type: Number,
31 required: true
32 },
33 current: {
34 type: Number,
35 required: true
36 },
37 currentColor: {
38 type: String,
39 default: 'rgb(68, 0, 204)'
40 },
41 defaultColor: {
42 type: String,
43 default: 'rgb(130, 140, 153)'
44 },
45 handleClick: {
46 type: Function
47 }
48 },
49 render: function render(h, _ref) {
50 var props = _ref.props,
51 data = _ref.data;
52 var steps = [];
53
54 var _loop = function _loop(i) {
55 var color = i === props.current ? props.currentColor : props.defaultColor;
56 steps.push(h('div', {
57 class: 'step-indicator',
58 style: {
59 color: color,
60 borderColor: color
61 },
62 on: {
63 click: function click() {
64 return props.handleClick && props.handleClick(i);
65 }
66 }
67 }, [i + 1]));
68 };
69
70 for (var i = 0; i < props.total; i++) {
71 _loop(i);
72 }
73
74 var attrs = nanoAssign_common({}, data, {
75 class: ['step-indicators', data.class]
76 });
77 return h('div', attrs, [h('span', {
78 class: 'step-indicators-line'
79 })].concat(steps));
80 }
81 };
82
83 return index$1;
84
85})));