@eturnity/eturnity_reusable_components 1.2.22 → 1.2.23-3d-master.0

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.
@@ -1,5 +1,10 @@
1
1
  <template>
2
- <container>
2
+ <container :inputWidth="inputWidth" :alignItems="alignItems">
3
+ <label-slot-wrapper v-if="hasLabelSlot" :isInteractive="isInteractive" @mousedown="initInteraction">
4
+
5
+ <slot name="label"></slot>
6
+ </label-slot-wrapper>
7
+
3
8
  <label-wrapper v-if="labelText">
4
9
  <label-text>
5
10
  {{ labelText }}
@@ -8,35 +13,51 @@
8
13
  v-if="labelInfoText"
9
14
  :text="labelInfoText"
10
15
  borderColor="#ccc"
11
- size="13"
16
+ size="14px"
12
17
  :alignText="labelInfoAlign"
13
18
  />
14
19
  </label-wrapper>
15
20
  <input-wrapper>
16
21
  <input-container
22
+ v-bind="$attrs"
17
23
  ref="inputField1"
18
24
  :hasUnit="unitName && !!unitName.length"
19
- :placeholder="placeholder"
25
+ :placeholder="displayedPlaceholder"
20
26
  :isError="isError"
21
27
  :inputWidth="inputWidth"
28
+ :inputHeight="inputHeight"
22
29
  :minWidth="minWidth"
23
30
  :value="formatWithCurrency(value)"
24
31
  @blur="onInputBlur($event)"
25
32
  @focus="focusInput()"
26
33
  @keyup.enter="$emit('on-enter-click')"
34
+ @input="onInput($event)"
27
35
  :disabled="disabled"
28
36
  :isDisabled="disabled"
29
37
  :noBorder="noBorder"
30
38
  :textAlign="textAlign"
31
39
  :fontSize="fontSize"
32
40
  :fontColor="fontColor"
41
+ :backgroundColor="backgroundColor"
42
+ v-on="$listeners"
43
+ :hasSlot="hasSlot"
44
+ :slotSize="slotSize"
33
45
  />
46
+ <slot-container v-if="hasSlot" :slotSize="slotSize" :isError="isError">
47
+ <slot></slot>
48
+ </slot-container>
49
+
34
50
  <unit-container
35
- v-if="unitName && showLinearUnitName"
51
+ v-if="unitName && showLinearUnitName && !hasSlot"
36
52
  :hasLength="!!textInput.length"
37
53
  :isError="isError"
38
54
  >{{ unitName }}</unit-container
39
55
  >
56
+ <icon
57
+ v-if="(isError || inputIcon) && !showLinearUnitName"
58
+ :class="inputIconImageClass"
59
+ :src="isError ? warningIcon : inputIconImage"
60
+ />
40
61
  </input-wrapper>
41
62
  <error-message v-if="isError">{{ errorMessage }}</error-message>
42
63
  </container>
@@ -74,11 +95,8 @@ import {
74
95
  numberToString
75
96
  } from '../../../helpers/numberConverter'
76
97
  import InfoText from '../../infoText'
77
-
78
- const Container = styled.div`
79
- width: 100%;
80
- position: relative;
81
- `
98
+ import ErrorMessage from '../../errorMessage'
99
+ import warningIcon from '../../../assets/icons/error_icon.png'
82
100
 
83
101
  const inputProps = {
84
102
  isError: Boolean,
@@ -89,8 +107,23 @@ const inputProps = {
89
107
  noBorder: Boolean,
90
108
  textAlign: String,
91
109
  fontSize: String,
92
- fontColor: String
110
+ fontColor: String,
111
+ backgroundColor:String,
112
+ hasSlot: Boolean,
113
+ slotSize: String,
114
+ inputHeight:String,
115
+ isInteractive:Boolean,
116
+ alignItems:String
93
117
  }
118
+
119
+ const Container = styled('div', inputProps)`
120
+ width: ${(props) => (props.inputWidth ? props.inputWidth : '100%')};
121
+ position: relative;
122
+ display:grid;
123
+ grid-template-columns: ${(props) =>
124
+ props.alignItems === "vertical" ? "1fr" : "auto 1fr"};
125
+ `
126
+
94
127
  const InputContainer = styled('input', inputProps)`
95
128
  border: ${(props) =>
96
129
  props.isError
@@ -98,8 +131,13 @@ const InputContainer = styled('input', inputProps)`
98
131
  : props.noBorder
99
132
  ? 'none'
100
133
  : '1px solid ' + props.theme.colors.mediumGray};
101
- padding: ${(props) =>
102
- props.hasUnit ? '11px 40px 11px 10px' : '11px 5px 11px 10px'};
134
+ padding-top: 11px;
135
+ padding-bottom: 11px;
136
+ padding-left: 10px;
137
+ padding-right: ${(props) =>
138
+ props.slotSize
139
+ ? 'calc(' + props.slotSize + ' + 10px)'
140
+ : '5px'};
103
141
  border-radius: 4px;
104
142
  text-align: ${(props) => props.textAlign};
105
143
  cursor: ${(props) => (props.isDisabled ? 'not-allowed' : 'auto')};
@@ -110,12 +148,15 @@ const InputContainer = styled('input', inputProps)`
110
148
  : props.fontColor
111
149
  ? props.fontColor + ' !important'
112
150
  : props.theme.colors.black};
151
+ background-color:${(props) => props.backgroundColor
152
+ ? props.backgroundColor+' !important'
153
+ : props.theme.colors.white};
113
154
  width: ${(props) => (props.inputWidth ? props.inputWidth : '100%')};
114
155
  min-width: ${(props) => (props.minWidth ? props.minWidth : 'unset')};
115
156
  background-color: ${(props) =>
116
157
  props.isDisabled ? props.theme.colors.grey5 : '#fff'};
117
158
  box-sizing: border-box;
118
-
159
+ max-height: ${(props) => (props.inputHeight)};
119
160
  &::placeholder {
120
161
  color: ${(props) =>
121
162
  props.isError ? props.theme.colors.red : props.theme.colors.darkGray};
@@ -125,6 +166,15 @@ const InputContainer = styled('input', inputProps)`
125
166
  outline: none;
126
167
  }
127
168
  `
169
+ const IconProps = {
170
+ inputIconHeight: String
171
+ }
172
+
173
+ const Icon = styled('img', IconProps)`
174
+ position: absolute;
175
+ right: 10px;
176
+ top: 2px;
177
+ `
128
178
 
129
179
  const InputWrapper = styled.span`
130
180
  position: relative;
@@ -142,6 +192,7 @@ const UnitContainer = styled('span', inputProps)`
142
192
  right: 10px;
143
193
  top: 0;
144
194
  padding-left: 10px;
195
+ text-align: right;
145
196
  color: ${(props) =>
146
197
  props.isError
147
198
  ? props.theme.colors.red
@@ -150,17 +201,40 @@ const UnitContainer = styled('span', inputProps)`
150
201
  : props.theme.colors.mediumGray};
151
202
  `
152
203
 
153
- const ErrorMessage = styled.div`
154
- font-size: 14px;
155
- color: ${(props) => props.theme.colors.red};
204
+ const SlotContainer = styled('span', inputProps)`
205
+ text-align: right;
206
+ border-left: 1px solid
207
+ ${(props) =>
208
+ props.isError
209
+ ? props.theme.colors.red
210
+ : props.hasLength
211
+ ? props.theme.colors.black
212
+ : props.theme.colors.mediumGray};
156
213
  position: absolute;
157
- top: calc(100% + 1px);
214
+ width: ${(props) =>
215
+ props.slotSize ? 'calc(' + props.slotSize + ' - 10px)' : 'fit-content'};
216
+ right: 10px;
217
+ top: 0;
218
+ padding-left: 10px;
219
+ color: ${(props) =>
220
+ props.isError
221
+ ? props.theme.colors.red
222
+ : props.hasLength
223
+ ? props.theme.colors.black
224
+ : props.theme.colors.mediumGray};
158
225
  `
159
226
 
160
- const LabelWrapper = styled.div`
227
+ const LabelWrapper = styled('div',inputProps)`
161
228
  display: flex;
162
229
  gap: 10px;
163
230
  margin-bottom: 8px;
231
+ cursor: ${(props) => (props.isInteractive?'ew-resize':'auto')};
232
+ `
233
+ const LabelSlotWrapper = styled('div',inputProps)`
234
+ display: flex;
235
+ gap: 10px;
236
+ align-items:center;
237
+ cursor: ${(props) => (props.isInteractive?'ew-resize':'auto')};
164
238
  `
165
239
 
166
240
  const LabelText = styled.div`
@@ -177,13 +251,18 @@ export default {
177
251
  UnitContainer,
178
252
  ErrorMessage,
179
253
  LabelWrapper,
254
+ LabelSlotWrapper,
180
255
  LabelText,
181
- InfoText
256
+ InfoText,
257
+ Icon,
258
+ SlotContainer,
182
259
  },
260
+ inheritAttrs: false,
183
261
  data() {
184
262
  return {
185
263
  textInput: '',
186
- isFocused: false
264
+ isFocused: false,
265
+ warningIcon: warningIcon,
187
266
  }
188
267
  },
189
268
  props: {
@@ -203,6 +282,10 @@ export default {
203
282
  required: false,
204
283
  default: null
205
284
  },
285
+ inputHeight:{
286
+ required:false,
287
+ default:null
288
+ },
206
289
  value: {
207
290
  required: true,
208
291
  default: null
@@ -211,6 +294,10 @@ export default {
211
294
  required: false,
212
295
  default: false
213
296
  },
297
+ alignItems: {
298
+ required: false,
299
+ default: "vertical",
300
+ },
214
301
  errorMessage: {
215
302
  required: false,
216
303
  default: 'Please insert a correct number'
@@ -243,6 +330,14 @@ export default {
243
330
  required: false,
244
331
  default: '13px'
245
332
  },
333
+ isInteractive: {
334
+ required: false,
335
+ default: false
336
+ },
337
+ interactionStep:{
338
+ required:false,
339
+ default:1
340
+ },
246
341
  labelText: {
247
342
  required: false,
248
343
  default: null
@@ -253,7 +348,7 @@ export default {
253
348
  },
254
349
  labelInfoAlign: {
255
350
  required: false,
256
- default: 'right'
351
+ default: 'left'
257
352
  },
258
353
  minNumber: {
259
354
  required: false,
@@ -263,14 +358,51 @@ export default {
263
358
  required: false,
264
359
  default: null
265
360
  },
361
+ backgroundColor: {
362
+ required: false,
363
+ default: null
364
+ },
266
365
  numberToStringEnabled: {
267
366
  required: false,
268
367
  default: true
368
+ },
369
+ inputIcon: {
370
+ require: false,
371
+ type: Boolean,
372
+ default: false
373
+ },
374
+ inputIconImage: {
375
+ require: false,
376
+ type: String,
377
+ default: ''
378
+ },
379
+ inputIconImageClass: {
380
+ require: false,
381
+ type: Array,
382
+ default: () => []
383
+ },
384
+ slotSize: {
385
+ required: false
386
+ }
387
+ },
388
+ computed: {
389
+ displayedPlaceholder() {
390
+ if (this.placeholder) return this.placeholder
391
+ return `${this.minNumber || 0} ${this.unitName ? this.unitName : ''}`
392
+ },
393
+ hasSlot() {
394
+ return !!this.$slots.default
395
+ },
396
+ hasLabelSlot(){
397
+ return !!this.$slots.label
398
+ },
399
+ computedSlotSize() {
400
+ return this.slotSize || this.$slots['default'][0].elm.clientWidth
269
401
  }
270
402
  },
271
403
  methods: {
272
404
  onChangeHandler(event) {
273
- if (isNaN(event)) {
405
+ if (isNaN(event) || event=="") {
274
406
  event = this.minNumber || this.minNumber === 0 ? this.minNumber : event
275
407
  }
276
408
  this.$emit('input-change', event)
@@ -305,9 +437,15 @@ export default {
305
437
  value: evaluated,
306
438
  numberPrecision: this.numberPrecision
307
439
  })
440
+ }else if(typeof evaluated === 'number'){
441
+ evaluated=evaluated.toFixed(this.numberPrecision)
308
442
  }
309
443
  return evaluated
310
444
  },
445
+ onInput(value){
446
+ let evaluatedInput = this.onEvaluateCode(value)
447
+ this.$emit('on-input',evaluatedInput)
448
+ },
311
449
  onInputBlur(e) {
312
450
  this.isFocused = false
313
451
  let value = e.target.value
@@ -321,11 +459,11 @@ export default {
321
459
  })
322
460
  }
323
461
  let adjustedMinValue =
324
- value && value.length
325
- ? value
462
+ evaluatedInput && evaluatedInput.length
463
+ ? evaluatedInput
326
464
  : this.minNumber || this.minNumber === 0
327
465
  ? this.minNumber
328
- : ''
466
+ : ''
329
467
  this.$emit('input-blur', adjustedMinValue)
330
468
  },
331
469
  focusInput() {
@@ -336,6 +474,7 @@ export default {
336
474
  this.$nextTick(() => {
337
475
  this.$refs.inputField1.$el.select()
338
476
  })
477
+ this.$emit('input-focus')
339
478
  },
340
479
  formatWithCurrency(value) {
341
480
  let adjustedMinValue =
@@ -352,6 +491,7 @@ export default {
352
491
  })
353
492
  : adjustedMinValue
354
493
  let unit = this.showLinearUnitName ? '' : this.unitName
494
+ //return input + ' ' + unit
355
495
  return input + ' ' + unit
356
496
  } else if (!adjustedMinValue && adjustedMinValue !== 0) {
357
497
  return ''
@@ -363,7 +503,34 @@ export default {
363
503
  })
364
504
  : adjustedMinValue
365
505
  }
366
- }
506
+ },
507
+ initInteraction(e) {
508
+ console.log('InitInteract')
509
+ window.addEventListener('mousemove', this.interact, false);
510
+ window.addEventListener('mouseup', this.stopInteract, false);
511
+ e.preventDefault()
512
+ },
513
+ interact(e) {
514
+ e.preventDefault()
515
+
516
+ let value=parseInt(this.value)
517
+
518
+ value+=this.interactionStep*e.movementX
519
+ this.$emit('on-input',value)
520
+
521
+ console.log('interact',this.value,value)
522
+ this.textInput=numberToString({
523
+ value:
524
+ value && value.length ? value : this.minNumber,
525
+ numberPrecision: this.numberPrecision
526
+ })
527
+ //this.value=value
528
+ },
529
+ stopInteract(e) {
530
+ e.preventDefault()
531
+ window.removeEventListener('mousemove', this.interact, false);
532
+ window.removeEventListener('mouseup', this.stopInteract, false);
533
+ },
367
534
  },
368
535
  created() {
369
536
  if (this.value) {
@@ -387,4 +554,4 @@ export default {
387
554
  }
388
555
  }
389
556
  }
390
- </script>
557
+ </script>
@@ -10,10 +10,11 @@
10
10
  v-if="infoTextMessage"
11
11
  :text="infoTextMessage"
12
12
  borderColor="#ccc"
13
- :size="fontSize ? fontSize : '16'"
13
+ :size="fontSize ? fontSize : '16px'"
14
14
  :alignText="infoTextAlign"
15
15
  />
16
16
  </label-wrapper>
17
+ <input-error-wrapper>
17
18
  <input-container
18
19
  :placeholder="placeholder"
19
20
  :isError="isError"
@@ -25,37 +26,32 @@
25
26
  :disabled="disabled"
26
27
  :isDisabled="disabled"
27
28
  :fontSize="fontSize"
28
- :inputType="inputType"
29
- :type="inputTypeData"
30
29
  />
31
- <icon-wrapper
32
- v-if="inputType === 'password' && !isError"
33
- @click="toggleShowPassword()"
34
- >
35
- <icon name="current_variant" size="20px" />
36
- </icon-wrapper>
37
- <icon-wrapper v-if="isError">
38
- <icon name="warning" size="16px" />
39
- </icon-wrapper>
30
+ <error-message v-if="isError">{{ errorMessage }}</error-message>
31
+ </input-error-wrapper>
40
32
  </input-wrapper>
41
- <error-message v-if="isError">{{ errorMessage }}</error-message>
42
33
  </container>
43
34
  </template>
44
35
 
45
36
  <script>
46
- import styled from 'vue-styled-components'
47
- import InfoText from '../../infoText'
48
- import Icon from '../../icon'
37
+ import styled from "vue-styled-components"
38
+ import InfoText from "../../infoText"
39
+ import ErrorMessage from '../../errorMessage'
49
40
 
50
41
  const Container = styled.div`
51
42
  width: 100%;
52
43
  position: relative;
53
44
  `
54
-
45
+ const InputErrorWrapper = styled.div`
46
+ display: inline-grid;
47
+ grid-template-row: auto auto;
48
+ grid-gap: 0px;
49
+ align-items: center;
50
+ `
55
51
  const labelAttrs = { fontSize: String }
56
- const InputLabel = styled('div', labelAttrs)`
52
+ const InputLabel = styled("div", labelAttrs)`
57
53
  font-weight: bold;
58
- font-size: ${(props) => (props.fontSize ? props.fontSize : '13px')};
54
+ font-size: ${(props) => (props.fontSize ? props.fontSize : "13px")};
59
55
  `
60
56
 
61
57
  const LabelWrapper = styled.div`
@@ -72,34 +68,29 @@ const inputProps = {
72
68
  noBorder: Boolean,
73
69
  isDisabled: Boolean,
74
70
  fontSize: String,
75
- inputType: String
76
71
  }
77
- const InputContainer = styled('input', inputProps)`
72
+ const InputContainer = styled("input", inputProps)`
78
73
  border: ${(props) =>
79
74
  props.isError
80
- ? '1px solid ' + props.theme.colors.red
75
+ ? "1px solid " + props.theme.colors.red
81
76
  : props.noBorder
82
- ? 'none'
77
+ ? "none"
83
78
  : props.hasLength
84
- ? '1px solid ' + props.theme.colors.black
85
- : '1px solid ' + props.theme.colors.mediumGray};
79
+ ? "1px solid " + props.theme.colors.black
80
+ : "1px solid " + props.theme.colors.mediumGray};
86
81
  padding: ${(props) =>
87
- props.isError
88
- ? '11px 25px 11px 10px'
89
- : props.inputType === 'password'
90
- ? '11px 25px 11px 10px'
91
- : '11px 5px 11px 10px'};
82
+ props.hasUnit ? "11px 40px 11px 10px" : "11px 5px 11px 10px"};
92
83
  border-radius: 4px;
93
- font-size: ${(props) => (props.fontSize ? props.fontSize : '16px')};
84
+ font-size: ${(props) => (props.fontSize ? props.fontSize : "16px")};
94
85
  color: ${(props) =>
95
86
  props.isError ? props.theme.colors.red : props.theme.colors.black};
96
- width: ${(props) => (props.inputWidth ? props.inputWidth : '100%')};
97
- min-width: ${(props) => (props.minWidth ? props.minWidth : 'unset')};
87
+ width: ${(props) => (props.inputWidth ? props.inputWidth : "100%")};
88
+ min-width: ${(props) => (props.minWidth ? props.minWidth : "unset")};
98
89
  box-sizing: border-box; // to allow width of 100% with padding
99
90
  font-weight: 500;
100
- cursor: ${(props) => (props.isDisabled ? 'not-allowed' : 'auto')};
91
+ cursor: ${(props) => (props.isDisabled ? "not-allowed" : "auto")};
101
92
  background-color: ${(props) =>
102
- props.isDisabled ? props.theme.colors.grey5 : '#fff'};
93
+ props.isDisabled ? props.theme.colors.grey5 : "#fff"};
103
94
 
104
95
  &::placeholder {
105
96
  color: ${(props) =>
@@ -112,26 +103,13 @@ const InputContainer = styled('input', inputProps)`
112
103
  `
113
104
 
114
105
  const inputAttrs = { alignItems: String, hasLabel: Boolean }
115
- const InputWrapper = styled('div', inputAttrs)`
106
+ const InputWrapper = styled("div", inputAttrs)`
116
107
  position: relative;
117
108
  display: grid;
118
109
  align-items: center;
119
110
  gap: 8px;
120
111
  grid-template-columns: ${(props) =>
121
- props.alignItems === 'vertical' || !props.hasLabel ? '1fr' : 'auto 1fr'};
122
- `
123
-
124
- const ErrorMessage = styled.div`
125
- font-size: 14px;
126
- color: ${(props) => props.theme.colors.red};
127
- position: absolute;
128
- top: calc(100% + 1px);
129
- `
130
-
131
- const IconWrapper = styled.div`
132
- position: absolute;
133
- top: 55%;
134
- right: 5px;
112
+ props.alignItems === "vertical" || !props.hasLabel ? "1fr" : "auto 1fr"};
135
113
  `
136
114
 
137
115
  export default {
@@ -151,7 +129,7 @@ export default {
151
129
  // minWidth="100px"
152
130
  // fontSize="13px"
153
131
  // />
154
- name: 'input-text',
132
+ name: "input-text",
155
133
  components: {
156
134
  Container,
157
135
  InputContainer,
@@ -159,81 +137,64 @@ export default {
159
137
  ErrorMessage,
160
138
  InfoText,
161
139
  InputLabel,
140
+ InputErrorWrapper,
162
141
  LabelWrapper,
163
- Icon,
164
- IconWrapper
165
- },
166
- data() {
167
- return {
168
- inputTypeData: 'text'
169
- }
170
142
  },
171
143
  props: {
172
144
  placeholder: {
173
145
  required: false,
174
- default: ''
146
+ default: "",
175
147
  },
176
148
  alignItems: {
177
149
  required: false,
178
- default: 'horizontal'
150
+ default: "horizontal",
179
151
  },
180
152
  isError: {
181
153
  required: false,
182
- default: false
154
+ default: false,
183
155
  },
184
156
  inputWidth: {
185
157
  required: false,
186
- default: null
158
+ default: null,
187
159
  },
188
160
  minWidth: {
189
161
  required: false,
190
- default: null
162
+ default: null,
191
163
  },
192
164
  value: {
193
165
  required: true,
194
- default: null
166
+ default: null,
195
167
  },
196
168
  errorMessage: {
197
169
  required: false,
198
- default: ''
170
+ default: "",
199
171
  },
200
172
  infoTextMessage: {
201
- required: false
173
+ required: false,
202
174
  },
203
175
  infoTextAlign: {
204
- required: false
176
+ required: false,
205
177
  },
206
178
  label: {
207
- required: false
179
+ required: false,
208
180
  },
209
181
  noBorder: {
210
182
  required: false,
211
- default: false
183
+ default: false,
212
184
  },
213
185
  disabled: {
214
186
  required: false,
215
- default: false
187
+ default: false,
216
188
  },
217
189
  fontSize: {
218
190
  required: false,
219
- default: null
191
+ default: null,
220
192
  },
221
- inputType: {
222
- required: false,
223
- default: 'text'
224
- }
225
193
  },
226
194
  methods: {
227
195
  onChangeHandler($event) {
228
- this.$emit('input-change', $event)
196
+ this.$emit("input-change", $event)
229
197
  },
230
- toggleShowPassword() {
231
- this.inputTypeData =
232
- this.inputTypeData === 'password' ? 'text' : 'password'
233
- }
234
198
  },
235
- created() {
236
- this.inputTypeData = this.inputType
237
- }
238
199
  }
239
200
  </script>
@@ -12,7 +12,7 @@
12
12
  />
13
13
  <span class="checkmark"></span>
14
14
  <label-text :isDisabled="item.disabled">{{ item.label }}</label-text>
15
- <info-text v-if="item.infoText" :text="item.infoText" size="16" />
15
+ <info-text v-if="item.infoText" :text="item.infoText" size="16px" />
16
16
  </label-container>
17
17
  <image-container v-if="item.img">
18
18
  <radio-image :src="item.img" />
@@ -10,7 +10,7 @@
10
10
  v-if="infoTextMessage"
11
11
  :text="infoTextMessage"
12
12
  borderColor="#ccc"
13
- size="16"
13
+ size="16px"
14
14
  :alignText="infoTextAlign"
15
15
  />
16
16
  </label-wrapper>
@@ -23,6 +23,7 @@
23
23
  :disabled="isDisabled"
24
24
  :fontSize="fontSize"
25
25
  @input="onChangeHandler"
26
+ :resize="resize"
26
27
  />
27
28
  </input-wrapper>
28
29
  <error-message v-if="isError && errorText">{{ errorText }}</error-message>
@@ -174,7 +175,11 @@ export default {
174
175
  },
175
176
  inputWidth: {
176
177
  required: false,
177
- default: null
178
+ default: null,
179
+ },
180
+ resize:{
181
+ required:false,
182
+ default: "none"
178
183
  }
179
184
  },
180
185
  methods: {