@eturnity/eturnity_reusable_components 1.1.99 → 1.2.0-beta.2
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
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
// <close-button
|
|
14
14
|
// color="#fff"
|
|
15
15
|
// />
|
|
16
|
-
import styled from
|
|
16
|
+
import styled from 'vue-styled-components'
|
|
17
17
|
|
|
18
18
|
const Container = styled.div`
|
|
19
19
|
position: relative;
|
|
@@ -27,8 +27,8 @@ const Wrapper = styled.div`
|
|
|
27
27
|
`
|
|
28
28
|
|
|
29
29
|
const lineAttrs = { color: String }
|
|
30
|
-
const Line = styled(
|
|
31
|
-
width:
|
|
30
|
+
const Line = styled('div', lineAttrs)`
|
|
31
|
+
width: 20px;
|
|
32
32
|
height: 2px;
|
|
33
33
|
background-color: ${(props) =>
|
|
34
34
|
props.color ? props.color : props.theme.colors.red};
|
|
@@ -45,17 +45,17 @@ const RightLine = styled(Line)`
|
|
|
45
45
|
`
|
|
46
46
|
|
|
47
47
|
export default {
|
|
48
|
-
name:
|
|
48
|
+
name: 'close-button',
|
|
49
49
|
components: {
|
|
50
50
|
Container,
|
|
51
51
|
Wrapper,
|
|
52
52
|
LeftLine,
|
|
53
|
-
RightLine
|
|
53
|
+
RightLine
|
|
54
54
|
},
|
|
55
55
|
props: {
|
|
56
56
|
color: {
|
|
57
|
-
required: false
|
|
58
|
-
}
|
|
59
|
-
}
|
|
57
|
+
required: false
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
60
|
}
|
|
61
61
|
</script>
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
<input-container
|
|
17
17
|
ref="inputField1"
|
|
18
18
|
:hasUnit="unitName && !!unitName.length"
|
|
19
|
-
:placeholder="
|
|
19
|
+
:placeholder="displayedPlaceholder"
|
|
20
20
|
:isError="isError"
|
|
21
21
|
:inputWidth="inputWidth"
|
|
22
22
|
:minWidth="minWidth"
|
|
@@ -68,12 +68,12 @@
|
|
|
68
68
|
// :minNumber="0"
|
|
69
69
|
// fontColor="blue"
|
|
70
70
|
// />
|
|
71
|
-
import styled from
|
|
71
|
+
import styled from 'vue-styled-components'
|
|
72
72
|
import {
|
|
73
73
|
stringToNumber,
|
|
74
74
|
numberToString,
|
|
75
|
-
} from
|
|
76
|
-
import InfoText from
|
|
75
|
+
} from '../../../helpers/numberConverter'
|
|
76
|
+
import InfoText from '../../infoText'
|
|
77
77
|
|
|
78
78
|
const Container = styled.div`
|
|
79
79
|
width: 100%;
|
|
@@ -91,29 +91,36 @@ const inputProps = {
|
|
|
91
91
|
fontSize: String,
|
|
92
92
|
fontColor: String,
|
|
93
93
|
}
|
|
94
|
-
const InputContainer = styled(
|
|
94
|
+
const InputContainer = styled('input', inputProps)`
|
|
95
95
|
border: ${(props) =>
|
|
96
96
|
props.isError
|
|
97
|
-
?
|
|
97
|
+
? '1px solid ' + props.theme.colors.red
|
|
98
98
|
: props.noBorder
|
|
99
|
+
<<<<<<< HEAD
|
|
100
|
+
? 'none'
|
|
101
|
+
: props.hasLength
|
|
102
|
+
? '1px solid ' + props.theme.colors.black
|
|
103
|
+
: '1px solid ' + props.theme.colors.mediumGray};
|
|
104
|
+
=======
|
|
99
105
|
? "none"
|
|
100
106
|
: "1px solid " + props.theme.colors.mediumGray};
|
|
107
|
+
>>>>>>> master
|
|
101
108
|
padding: ${(props) =>
|
|
102
|
-
props.hasUnit ?
|
|
109
|
+
props.hasUnit ? '11px 40px 11px 10px' : '11px 5px 11px 10px'};
|
|
103
110
|
border-radius: 4px;
|
|
104
111
|
text-align: ${(props) => props.textAlign};
|
|
105
|
-
cursor: ${(props) => (props.isDisabled ?
|
|
106
|
-
font-size: ${(props) => (props.fontSize ? props.fontSize :
|
|
112
|
+
cursor: ${(props) => (props.isDisabled ? 'not-allowed' : 'auto')};
|
|
113
|
+
font-size: ${(props) => (props.fontSize ? props.fontSize : '13px')};
|
|
107
114
|
color: ${(props) =>
|
|
108
115
|
props.isError
|
|
109
116
|
? props.theme.colors.red
|
|
110
117
|
: props.fontColor
|
|
111
|
-
? props.fontColor +
|
|
118
|
+
? props.fontColor + ' !important'
|
|
112
119
|
: props.theme.colors.black};
|
|
113
|
-
width: ${(props) => (props.inputWidth ? props.inputWidth :
|
|
114
|
-
min-width: ${(props) => (props.minWidth ? props.minWidth :
|
|
120
|
+
width: ${(props) => (props.inputWidth ? props.inputWidth : '100%')};
|
|
121
|
+
min-width: ${(props) => (props.minWidth ? props.minWidth : 'unset')};
|
|
115
122
|
background-color: ${(props) =>
|
|
116
|
-
props.isDisabled ? props.theme.colors.grey5 :
|
|
123
|
+
props.isDisabled ? props.theme.colors.grey5 : '#fff'};
|
|
117
124
|
box-sizing: border-box;
|
|
118
125
|
|
|
119
126
|
&::placeholder {
|
|
@@ -130,7 +137,7 @@ const InputWrapper = styled.span`
|
|
|
130
137
|
position: relative;
|
|
131
138
|
`
|
|
132
139
|
|
|
133
|
-
const UnitContainer = styled(
|
|
140
|
+
const UnitContainer = styled('span', inputProps)`
|
|
134
141
|
border-left: 1px solid
|
|
135
142
|
${(props) =>
|
|
136
143
|
props.isError
|
|
@@ -169,7 +176,7 @@ const LabelText = styled.div`
|
|
|
169
176
|
`
|
|
170
177
|
|
|
171
178
|
export default {
|
|
172
|
-
name:
|
|
179
|
+
name: 'input-number',
|
|
173
180
|
components: {
|
|
174
181
|
Container,
|
|
175
182
|
InputContainer,
|
|
@@ -182,14 +189,20 @@ export default {
|
|
|
182
189
|
},
|
|
183
190
|
data() {
|
|
184
191
|
return {
|
|
185
|
-
textInput:
|
|
192
|
+
textInput: '',
|
|
186
193
|
isFocused: false,
|
|
187
194
|
}
|
|
188
195
|
},
|
|
196
|
+
computed: {
|
|
197
|
+
displayedPlaceholder() {
|
|
198
|
+
if (this.placeholder) return this.placeholder
|
|
199
|
+
return `${this.minNumber || 0} ${this.unitName ? this.unitName : ''}`
|
|
200
|
+
},
|
|
201
|
+
},
|
|
189
202
|
props: {
|
|
190
203
|
placeholder: {
|
|
191
204
|
required: false,
|
|
192
|
-
default:
|
|
205
|
+
default: '',
|
|
193
206
|
},
|
|
194
207
|
isError: {
|
|
195
208
|
required: false,
|
|
@@ -213,7 +226,7 @@ export default {
|
|
|
213
226
|
},
|
|
214
227
|
errorMessage: {
|
|
215
228
|
required: false,
|
|
216
|
-
default:
|
|
229
|
+
default: 'Please insert a correct number',
|
|
217
230
|
},
|
|
218
231
|
numberPrecision: {
|
|
219
232
|
required: false,
|
|
@@ -221,7 +234,7 @@ export default {
|
|
|
221
234
|
},
|
|
222
235
|
unitName: {
|
|
223
236
|
required: false,
|
|
224
|
-
default:
|
|
237
|
+
default: '',
|
|
225
238
|
},
|
|
226
239
|
showLinearUnitName: {
|
|
227
240
|
required: false,
|
|
@@ -237,11 +250,11 @@ export default {
|
|
|
237
250
|
},
|
|
238
251
|
textAlign: {
|
|
239
252
|
required: false,
|
|
240
|
-
default:
|
|
253
|
+
default: 'left',
|
|
241
254
|
},
|
|
242
255
|
fontSize: {
|
|
243
256
|
required: false,
|
|
244
|
-
default:
|
|
257
|
+
default: '13px',
|
|
245
258
|
},
|
|
246
259
|
labelText: {
|
|
247
260
|
required: false,
|
|
@@ -253,7 +266,7 @@ export default {
|
|
|
253
266
|
},
|
|
254
267
|
labelInfoAlign: {
|
|
255
268
|
required: false,
|
|
256
|
-
default:
|
|
269
|
+
default: 'right',
|
|
257
270
|
},
|
|
258
271
|
minNumber: {
|
|
259
272
|
required: false,
|
|
@@ -271,24 +284,28 @@ export default {
|
|
|
271
284
|
methods: {
|
|
272
285
|
onChangeHandler(event) {
|
|
273
286
|
if (isNaN(event)) {
|
|
287
|
+
<<<<<<< HEAD
|
|
288
|
+
event = ''
|
|
289
|
+
=======
|
|
274
290
|
event = this.minNumber || this.minNumber === 0 ? this.minNumber : event
|
|
291
|
+
>>>>>>> master
|
|
275
292
|
}
|
|
276
|
-
this.$emit(
|
|
293
|
+
this.$emit('input-change', event)
|
|
277
294
|
},
|
|
278
295
|
onEvaluateCode(val) {
|
|
279
296
|
// function to perform math on the code
|
|
280
297
|
// filter the string in case of any malicious content
|
|
281
|
-
let filtered = val.replace(/[^-()\d/*+.,]/g,
|
|
298
|
+
let filtered = val.replace(/[^-()\d/*+.,]/g, '')
|
|
282
299
|
filtered = filtered.split(/([-+*/()])/)
|
|
283
300
|
let formatted = filtered.map((item) => {
|
|
284
301
|
if (
|
|
285
|
-
item ===
|
|
286
|
-
item ===
|
|
287
|
-
item ===
|
|
288
|
-
item ===
|
|
289
|
-
item ===
|
|
290
|
-
item ===
|
|
291
|
-
item ===
|
|
302
|
+
item === '+' ||
|
|
303
|
+
item === '-' ||
|
|
304
|
+
item === '*' ||
|
|
305
|
+
item === '/' ||
|
|
306
|
+
item === '(' ||
|
|
307
|
+
item === ')' ||
|
|
308
|
+
item === ''
|
|
292
309
|
) {
|
|
293
310
|
return item
|
|
294
311
|
} else {
|
|
@@ -299,11 +316,15 @@ export default {
|
|
|
299
316
|
return num
|
|
300
317
|
}
|
|
301
318
|
})
|
|
319
|
+
<<<<<<< HEAD
|
|
320
|
+
let evaluated = eval(formatted.join(''))
|
|
321
|
+
=======
|
|
302
322
|
let evaluated = eval(formatted.join(""))
|
|
303
323
|
evaluated = stringToNumber({
|
|
304
324
|
value: evaluated,
|
|
305
325
|
numberPrecision: this.numberPrecision,
|
|
306
326
|
})
|
|
327
|
+
>>>>>>> master
|
|
307
328
|
return evaluated
|
|
308
329
|
},
|
|
309
330
|
onInputBlur(e) {
|
|
@@ -323,8 +344,8 @@ export default {
|
|
|
323
344
|
? value
|
|
324
345
|
: this.minNumber || this.minNumber === 0
|
|
325
346
|
? this.minNumber
|
|
326
|
-
:
|
|
327
|
-
this.$emit(
|
|
347
|
+
: ''
|
|
348
|
+
this.$emit('input-blur', adjustedMinValue)
|
|
328
349
|
},
|
|
329
350
|
focusInput() {
|
|
330
351
|
if (this.disabled) {
|
|
@@ -341,8 +362,16 @@ export default {
|
|
|
341
362
|
? value
|
|
342
363
|
: this.minNumber || this.minNumber === 0
|
|
343
364
|
? this.minNumber
|
|
344
|
-
:
|
|
365
|
+
: ''
|
|
345
366
|
if ((adjustedMinValue || adjustedMinValue === 0) && !this.isFocused) {
|
|
367
|
+
<<<<<<< HEAD
|
|
368
|
+
let input = numberToString({
|
|
369
|
+
value: adjustedMinValue,
|
|
370
|
+
numberPrecision: this.numberPrecision,
|
|
371
|
+
})
|
|
372
|
+
let unit = this.showLinearUnitName ? '' : this.unitName
|
|
373
|
+
return input + ' ' + unit
|
|
374
|
+
=======
|
|
346
375
|
let input = this.numberToStringEnabled
|
|
347
376
|
? numberToString({
|
|
348
377
|
value: adjustedMinValue,
|
|
@@ -351,8 +380,9 @@ export default {
|
|
|
351
380
|
: adjustedMinValue
|
|
352
381
|
let unit = this.showLinearUnitName ? "" : this.unitName
|
|
353
382
|
return input + " " + unit
|
|
383
|
+
>>>>>>> master
|
|
354
384
|
} else if (!adjustedMinValue && adjustedMinValue !== 0) {
|
|
355
|
-
return
|
|
385
|
+
return ''
|
|
356
386
|
} else {
|
|
357
387
|
return this.numberToStringEnabled
|
|
358
388
|
? numberToString({
|
|
@@ -380,9 +410,9 @@ export default {
|
|
|
380
410
|
clearInput: function (value) {
|
|
381
411
|
if (value) {
|
|
382
412
|
// If the value is typed, then we should clear the textInput on Continue
|
|
383
|
-
this.textInput =
|
|
413
|
+
this.textInput = ''
|
|
384
414
|
}
|
|
385
415
|
},
|
|
386
416
|
},
|
|
387
417
|
}
|
|
388
|
-
</script>
|
|
418
|
+
</script>
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
// <div>Data....</div>
|
|
25
25
|
// </modal>
|
|
26
26
|
|
|
27
|
-
import styled from
|
|
28
|
-
import CloseButton from
|
|
29
|
-
import Spinner from
|
|
27
|
+
import styled from 'vue-styled-components'
|
|
28
|
+
import CloseButton from '../../buttons/closeButton'
|
|
29
|
+
import Spinner from '../../spinner'
|
|
30
30
|
|
|
31
31
|
const pageAttrs = { isOpen: Boolean }
|
|
32
|
-
const PageWrapper = styled(
|
|
32
|
+
const PageWrapper = styled('div', pageAttrs)`
|
|
33
33
|
position: fixed;
|
|
34
34
|
display: grid;
|
|
35
35
|
top: 0;
|
|
@@ -73,8 +73,8 @@ const ModalContainer = styled.div`
|
|
|
73
73
|
|
|
74
74
|
.close {
|
|
75
75
|
position: absolute;
|
|
76
|
-
right:
|
|
77
|
-
top:
|
|
76
|
+
right: 20px;
|
|
77
|
+
top: 20px;
|
|
78
78
|
|
|
79
79
|
@media (max-width: 425px) {
|
|
80
80
|
right: 14px;
|
|
@@ -93,46 +93,46 @@ const ModalContainer = styled.div`
|
|
|
93
93
|
`
|
|
94
94
|
|
|
95
95
|
export default {
|
|
96
|
-
name:
|
|
96
|
+
name: 'modal',
|
|
97
97
|
components: {
|
|
98
98
|
PageWrapper,
|
|
99
99
|
ModalContainer,
|
|
100
100
|
CloseButton,
|
|
101
|
-
Spinner
|
|
101
|
+
Spinner
|
|
102
102
|
},
|
|
103
103
|
props: {
|
|
104
104
|
isOpen: {
|
|
105
105
|
required: true,
|
|
106
|
-
default: false
|
|
106
|
+
default: false
|
|
107
107
|
},
|
|
108
108
|
preventOutsideClose: {
|
|
109
109
|
required: false,
|
|
110
|
-
default: false
|
|
110
|
+
default: false
|
|
111
111
|
},
|
|
112
112
|
isLoading: {
|
|
113
113
|
required: false,
|
|
114
|
-
default: false
|
|
114
|
+
default: false
|
|
115
115
|
},
|
|
116
116
|
hideClose: {
|
|
117
117
|
required: false,
|
|
118
|
-
default: false
|
|
119
|
-
}
|
|
118
|
+
default: false
|
|
119
|
+
}
|
|
120
120
|
},
|
|
121
121
|
methods: {
|
|
122
122
|
onCloseModal() {
|
|
123
|
-
this.$emit(
|
|
123
|
+
this.$emit('on-close')
|
|
124
124
|
},
|
|
125
125
|
onOutsideClose() {
|
|
126
126
|
// If true, then only allow closing to come from clicking the X or wherever the onCloseModal is called
|
|
127
127
|
if (!this.preventOutsideClose) {
|
|
128
|
-
this.$emit(
|
|
128
|
+
this.$emit('on-close')
|
|
129
129
|
}
|
|
130
|
-
}
|
|
130
|
+
}
|
|
131
131
|
},
|
|
132
132
|
watch: {
|
|
133
133
|
isOpen: function (newVal) {
|
|
134
|
-
document.body.style.overflow = newVal ?
|
|
135
|
-
}
|
|
136
|
-
}
|
|
134
|
+
document.body.style.overflow = newVal ? 'hidden' : ''
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
137
|
}
|
|
138
138
|
</script>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import Modal from "./index.vue";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
title: "Modal",
|
|
5
|
+
component: Modal,
|
|
6
|
+
// argTypes: {},
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const Template = (args, { argTypes }) => ({
|
|
10
|
+
// Components used in your story `template` are defined in the `components` object
|
|
11
|
+
components: { Modal },
|
|
12
|
+
// The story's `args` need to be mapped into the template through the `setup()` method
|
|
13
|
+
props: Object.keys(argTypes),
|
|
14
|
+
template: '<modal v-bind="$props" />',
|
|
15
|
+
|
|
16
|
+
// import Modal from "@eturnity/eturnity_reusable_components/src/components/modals/modal"
|
|
17
|
+
// This is a more flexible modal box, where the parent can decide how the body of the modal looks
|
|
18
|
+
// To use:
|
|
19
|
+
// <modal :isOpen="isOpen" @on-close="$emit('on-close-summary')" :preventOutsideClose="true" :isLoading="true" :hideClose="true">
|
|
20
|
+
// <div>Data....</div>
|
|
21
|
+
// </modal>
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export const Default = Template.bind({
|
|
25
|
+
isOpen: true,
|
|
26
|
+
preventOutsideClose: true,
|
|
27
|
+
isLoading: false,
|
|
28
|
+
hideClose: false,
|
|
29
|
+
});
|
|
30
|
+
Default.args = {};
|