@eturnity/eturnity_reusable_components 1.2.54 → 1.2.56

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": "@eturnity/eturnity_reusable_components",
3
- "version": "1.2.54",
3
+ "version": "1.2.56",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "vue-cli-service serve",
@@ -46,6 +46,7 @@
46
46
  :hasSlot="hasSlot"
47
47
  :hasLabelSlot="hasLabelSlot"
48
48
  :slotSize="slotSize"
49
+ :showLinearUnitName="showLinearUnitName"
49
50
  />
50
51
  <slot-container v-if="hasSlot" :slotSize="slotSize" :isError="isError">
51
52
  <slot></slot>
@@ -119,7 +120,8 @@ const inputProps = {
119
120
  isInteractive: Boolean,
120
121
  alignItems: String,
121
122
  labelFontColor: String,
122
- borderColor: String
123
+ borderColor: String,
124
+ showLinearUnitName: Boolean
123
125
  }
124
126
 
125
127
  const Container = styled('div', inputProps)`
@@ -144,8 +146,14 @@ const InputContainer = styled('input', inputProps)`
144
146
  padding-top: 11px;
145
147
  padding-bottom: 11px;
146
148
  padding-left: 10px;
147
- padding-right: ${(props) =>
148
- props.slotSize ? 'calc(' + props.slotSize + ' + 10px)' : '5px'};
149
+ padding-right: ${({ slotSize, isError, showLinearUnitName }) =>
150
+ slotSize
151
+ ? isError && !showLinearUnitName
152
+ ? 'calc(' + slotSize + ' + 24px)'
153
+ : 'calc(' + slotSize + ' + 10px)'
154
+ : isError && !showLinearUnitName
155
+ ? '24px'
156
+ : '5px'};
149
157
  border-radius: 4px;
150
158
  text-align: ${(props) => props.textAlign};
151
159
  cursor: ${(props) => (props.isDisabled ? 'not-allowed' : 'auto')};
@@ -371,9 +379,9 @@ export default {
371
379
  required: false,
372
380
  default: 'left'
373
381
  },
374
- defaultNumber:{
375
- required:false,
376
- default:null
382
+ defaultNumber: {
383
+ required: false,
384
+ default: null
377
385
  },
378
386
  minNumber: {
379
387
  required: false,
@@ -406,7 +414,8 @@ export default {
406
414
  computed: {
407
415
  displayedPlaceholder() {
408
416
  if (this.placeholder) return this.placeholder
409
- if (this.defaultNumber) return `${this.defaultNumber} ${this.unitName ? this.unitName : ''}`
417
+ if (this.defaultNumber)
418
+ return `${this.defaultNumber} ${this.unitName ? this.unitName : ''}`
410
419
  return `${this.minNumber || 0} ${this.unitName ? this.unitName : ''}`
411
420
  },
412
421
  hasSlot() {
@@ -419,12 +428,11 @@ export default {
419
428
  methods: {
420
429
  onChangeHandler(event) {
421
430
  if (isNaN(event) || event === '') {
422
-
423
431
  event = this.defaultNumber
424
- ?this.defaultNumber
425
- :this.minNumber || this.minNumber === 0
426
- ? this.minNumber
427
- : event
432
+ ? this.defaultNumber
433
+ : this.minNumber || this.minNumber === 0
434
+ ? this.minNumber
435
+ : event
428
436
  }
429
437
  if (!this.allowNegative) {
430
438
  event = Math.abs(event)
@@ -436,7 +444,7 @@ export default {
436
444
  onEvaluateCode(val) {
437
445
  // function to perform math on the code
438
446
  // filter the string in case of any malicious content
439
- let filtered = val.replace(/[^-()\d/*+.,]/g, '')
447
+ let filtered = val.replace('(auto)', '').replace(/[^-()\d/*+.,]/g, '')
440
448
  filtered = filtered.split(/([-+*/()])/)
441
449
  let formatted = filtered.map((item) => {
442
450
  if (
@@ -469,8 +477,8 @@ export default {
469
477
  return evaluated
470
478
  },
471
479
  onInput(value) {
472
- if(value===""){
473
- this.$emit('on-input','')
480
+ if (value === '') {
481
+ this.$emit('on-input', '')
474
482
  }
475
483
  let evaluatedVal
476
484
  try {
@@ -489,14 +497,17 @@ export default {
489
497
  if ((evaluatedInput && value.length) || this.minNumber !== null) {
490
498
  this.textInput = numberToString({
491
499
  value:
492
- evaluatedInput && value.length ? evaluatedInput :
493
- this.defaultNumber?this.defaultNumber:this.minNumber,
500
+ evaluatedInput && value.length
501
+ ? evaluatedInput
502
+ : this.defaultNumber
503
+ ? this.defaultNumber
504
+ : this.minNumber,
494
505
  numberPrecision: this.numberPrecision
495
506
  })
496
507
  }
497
508
  let adjustedMinValue =
498
509
  evaluatedInput && evaluatedInput.length
499
- ? evaluatedInput
510
+ ? evaluatedInput
500
511
  : this.defaultNumber
501
512
  ? this.defaultNumber
502
513
  : this.minNumber || this.minNumber === 0
@@ -15,16 +15,20 @@
15
15
  />
16
16
  </label-wrapper>
17
17
  <input-container
18
- :placeholder="placeholder"
19
- :isError="isError"
20
- :rows="rowHeight"
21
- :value="value"
22
18
  :inputWidth="inputWidth"
23
- :disabled="isDisabled"
19
+ :isError="isError"
24
20
  :fontSize="fontSize"
25
- @input="onChangeHandler"
26
- :resize="resize"
27
- />
21
+ :disabled="isDisabled"
22
+ >
23
+ <textarea
24
+ :placeholder="placeholder"
25
+ :rows="rowHeight"
26
+ :value="value"
27
+ :disabled="isDisabled"
28
+ @input="onChangeHandler"
29
+ :resize="resize"
30
+ />
31
+ </input-container>
28
32
  </input-wrapper>
29
33
  <error-message v-if="isError && errorText">{{ errorText }}</error-message>
30
34
  </container>
@@ -71,27 +75,30 @@ const inputProps = {
71
75
  fontSize: String,
72
76
  inputWidth: String
73
77
  }
74
- const InputContainer = styled('textarea', inputProps)`
75
- border: ${(props) =>
76
- props.isError
77
- ? '1px solid ' + props.theme.colors.red
78
- : '1px solid ' + props.theme.colors.grey4};
79
- padding: ${(props) =>
80
- props.hasUnit ? '11px 40px 11px 10px' : '11px 5px 11px 10px'};
81
- border-radius: 4px;
82
- font-size: ${(props) => (props.fontSize ? props.fontSize : '16px')};
83
- color: ${(props) => props.theme.colors.black};
84
- width: ${(props) => (props.inputWidth ? props.inputWidth : '100%')};
85
- max-width: 100%;
86
- box-sizing: border-box; // to allow width of 100% with padding
87
- cursor: ${(props) => (props.disabled ? 'not-allowed' : 'inherit')};
88
78
 
89
- &::placeholder {
90
- color: ${(props) => props.theme.colors.grey2};
91
- }
79
+ const InputContainer = styled('div', inputProps)`
80
+ textarea {
81
+ border: ${(props) =>
82
+ props.isError
83
+ ? '1px solid ' + props.theme.colors.red
84
+ : '1px solid ' + props.theme.colors.grey4};
85
+ padding: ${(props) =>
86
+ props.hasUnit ? '11px 40px 11px 10px' : '11px 5px 11px 10px'};
87
+ border-radius: 4px;
88
+ font-size: ${(props) => (props.fontSize ? props.fontSize : '16px')};
89
+ color: ${(props) => props.theme.colors.black};
90
+ width: ${(props) => (props.inputWidth ? props.inputWidth : '100%')};
91
+ max-width: 100%;
92
+ box-sizing: border-box; // to allow width of 100% with padding
93
+ cursor: ${(props) => (props.disabled ? 'not-allowed' : 'inherit')};
92
94
 
93
- &:focus {
94
- outline: none;
95
+ &::placeholder {
96
+ color: ${(props) => props.theme.colors.grey2};
97
+ }
98
+
99
+ &:focus {
100
+ outline: none;
101
+ }
95
102
  }
96
103
  `
97
104
 
@@ -181,7 +188,7 @@ export default {
181
188
  if (this.isDisabled) {
182
189
  return
183
190
  }
184
- this.$emit('input-change', $event)
191
+ this.$emit('input-change', $event.target.value)
185
192
  }
186
193
  }
187
194
  }