@eturnity/eturnity_reusable_components 1.2.2-EPDM-5243.6 → 1.2.2-QA03-19-9-2022.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eturnity/eturnity_reusable_components",
3
- "version": "1.2.2-EPDM-5243.6",
3
+ "version": "1.2.2-QA03-19-9-2022.2",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "vue-cli-service serve",
package/src/App.vue CHANGED
@@ -1,50 +1,13 @@
1
1
  <template>
2
2
  <ThemeProvider :theme="getTheme()" :style="{ height: '100%' }">
3
3
  <page-container>
4
- <main-table titleText="My Table">
5
- <thead>
6
- <tr>
7
- <th>Column 1</th>
8
- <th>Column 2</th>
9
- <th>Column 3</th>
10
- <div />
11
- </tr>
12
- </thead>
13
- <tbody>
14
- <tr>
15
- <!-- <table-dropdown
16
- :colSpan="3"
17
- :tableItems="getDropdownValues()"
18
- @toggle-dropdown-open="toggleDropdownOpen()"
19
- @item-selected="onItemSelected({ item: $event, index })"
20
- :isOpen="isDropdownOpen()"
21
- :optionItems="itemOptions"
22
- :optionsDisplay="['display_name', 'company_item_number', 'model']"
23
- /> -->
24
- <td>Test</td>
25
- <div class="icons-container">
26
- <three-dots :options="listOptions" :isLoading="false" />
27
- </div>
28
- </tr>
29
- </tbody>
30
- </main-table>
31
- <br />
32
- <br />
33
- <toggle
34
- @on-toggle-change="onInputChange($event)"
35
- :isChecked="inputValue"
36
- label="My Label Text"
37
- infoTextMessage="This is my test message"
38
- infoTextAlign="right"
39
- labelAlign="right"
40
- :disabled="false"
41
- />
42
- <br />
43
4
  <input-number
44
- placeholder="Enter distance"
45
- :numberPrecision="2"
46
- :value="inputValue"
47
- @input-change="onInputChange($event)"
5
+ :value="num"
6
+ @input-change="num = $event"
7
+ unitName="t"
8
+ id="biebie"
9
+ test="koko"
10
+ @keydown="keydownHandler"
48
11
  />
49
12
  <br />
50
13
  <page-subtitle text="My Subtitle" infoText="My info Text" />
@@ -112,6 +75,7 @@ export default {
112
75
  },
113
76
  data() {
114
77
  return {
78
+ num: 42,
115
79
  inputValue: null,
116
80
  checkedOption: 'button_1',
117
81
  question: {
@@ -170,6 +134,9 @@ export default {
170
134
  }
171
135
  },
172
136
  methods: {
137
+ keydownHandler(e) {
138
+ console.log('test', e)
139
+ },
173
140
  getTheme() {
174
141
  return theme
175
142
  },
@@ -0,0 +1,62 @@
1
+ <template>
2
+ <component-wrapper>
3
+ <text-overlay>
4
+ <slot></slot>
5
+ </text-overlay>
6
+ </component-wrapper>
7
+ </template>
8
+
9
+ <script>
10
+ // import InfoText from "@eturnity/eturnity_reusable_components/src/components/infoText"
11
+ //To use:
12
+ // <error-message
13
+ // alignText="right" // default is left
14
+ // />
15
+
16
+ import styled from 'vue-styled-components'
17
+
18
+ const TextOverlay = styled.div`
19
+ position: absolute;
20
+ top: calc(100% + 13px);
21
+ background: ${(props) => props.theme.colors.red};
22
+ padding: 10px;
23
+ width: max-content;
24
+ max-width: 100%;
25
+ min-width: 200px;
26
+ font-size: 11px;
27
+ font-weight: 400;
28
+ border-radius: 4px;
29
+ font-family: 'Lato-Bold', Arial;
30
+ z-index: 99;
31
+ color: ${(props) => props.theme.colors.white};
32
+
33
+ :before {
34
+ content: '';
35
+ background-color: ${(props) => props.theme.colors.red};
36
+ position: absolute;
37
+ top: 2px;
38
+ left: 40px;
39
+ height: 11px;
40
+ width: 11px;
41
+ transform-origin: center center;
42
+ transform: translate(-2em, -0.5em) rotate(45deg);
43
+ }
44
+ `
45
+
46
+ const ComponentWrapper = styled.div`
47
+ display: block;
48
+ `
49
+
50
+ export default {
51
+ name: 'info-text',
52
+ components: {
53
+ TextOverlay,
54
+ ComponentWrapper
55
+ },
56
+ props: {},
57
+ methods: {},
58
+ data() {
59
+ return {}
60
+ }
61
+ }
62
+ </script>
@@ -14,9 +14,10 @@
14
14
  </label-wrapper>
15
15
  <input-wrapper>
16
16
  <input-container
17
+ v-bind="$attrs"
17
18
  ref="inputField1"
18
19
  :hasUnit="unitName && !!unitName.length"
19
- :placeholder="placeholder"
20
+ :placeholder="displayedPlaceholder"
20
21
  :isError="isError"
21
22
  :inputWidth="inputWidth"
22
23
  :minWidth="minWidth"
@@ -30,6 +31,7 @@
30
31
  :textAlign="textAlign"
31
32
  :fontSize="fontSize"
32
33
  :fontColor="fontColor"
34
+ v-on="$listeners"
33
35
  />
34
36
  <unit-container
35
37
  v-if="unitName && showLinearUnitName"
@@ -37,6 +39,11 @@
37
39
  :isError="isError"
38
40
  >{{ unitName }}</unit-container
39
41
  >
42
+ <icon
43
+ v-if="(isError || inputIcon) && !showLinearUnitName"
44
+ :class="inputIconImageClass"
45
+ :src="isError ? warningIcon : inputIconImage"
46
+ />
40
47
  </input-wrapper>
41
48
  <error-message v-if="isError">{{ errorMessage }}</error-message>
42
49
  </container>
@@ -68,13 +75,14 @@
68
75
  // :minNumber="0"
69
76
  // fontColor="blue"
70
77
  // />
71
- import styled from "vue-styled-components"
78
+ import styled from 'vue-styled-components'
72
79
  import {
73
80
  stringToNumber,
74
- numberToString,
75
- } from "../../../helpers/numberConverter"
76
- import InfoText from "../../infoText"
77
-
81
+ numberToString
82
+ } from '../../../helpers/numberConverter'
83
+ import InfoText from '../../infoText'
84
+ import ErrorMessage from '../../errorMessage'
85
+ import warningIcon from '../../../assets/icons/error_icon.png'
78
86
  const Container = styled.div`
79
87
  width: 100%;
80
88
  position: relative;
@@ -89,31 +97,31 @@ const inputProps = {
89
97
  noBorder: Boolean,
90
98
  textAlign: String,
91
99
  fontSize: String,
92
- fontColor: String,
100
+ fontColor: String
93
101
  }
94
- const InputContainer = styled("input", inputProps)`
102
+ const InputContainer = styled('input', inputProps)`
95
103
  border: ${(props) =>
96
104
  props.isError
97
- ? "1px solid " + props.theme.colors.red
105
+ ? '1px solid ' + props.theme.colors.red
98
106
  : props.noBorder
99
- ? "none"
100
- : "1px solid " + props.theme.colors.mediumGray};
107
+ ? 'none'
108
+ : '1px solid ' + props.theme.colors.mediumGray};
101
109
  padding: ${(props) =>
102
- props.hasUnit ? "11px 40px 11px 10px" : "11px 5px 11px 10px"};
110
+ props.hasUnit ? '11px 40px 11px 10px' : '11px 5px 11px 10px'};
103
111
  border-radius: 4px;
104
112
  text-align: ${(props) => props.textAlign};
105
- cursor: ${(props) => (props.isDisabled ? "not-allowed" : "auto")};
106
- font-size: ${(props) => (props.fontSize ? props.fontSize : "13px")};
113
+ cursor: ${(props) => (props.isDisabled ? 'not-allowed' : 'auto')};
114
+ font-size: ${(props) => (props.fontSize ? props.fontSize : '13px')};
107
115
  color: ${(props) =>
108
116
  props.isError
109
117
  ? props.theme.colors.red
110
118
  : props.fontColor
111
- ? props.fontColor + " !important"
119
+ ? props.fontColor + ' !important'
112
120
  : props.theme.colors.black};
113
- width: ${(props) => (props.inputWidth ? props.inputWidth : "100%")};
114
- min-width: ${(props) => (props.minWidth ? props.minWidth : "unset")};
121
+ width: ${(props) => (props.inputWidth ? props.inputWidth : '100%')};
122
+ min-width: ${(props) => (props.minWidth ? props.minWidth : 'unset')};
115
123
  background-color: ${(props) =>
116
- props.isDisabled ? props.theme.colors.grey5 : "#fff"};
124
+ props.isDisabled ? props.theme.colors.grey5 : '#fff'};
117
125
  box-sizing: border-box;
118
126
 
119
127
  &::placeholder {
@@ -125,12 +133,21 @@ const InputContainer = styled("input", inputProps)`
125
133
  outline: none;
126
134
  }
127
135
  `
136
+ const IconProps = {
137
+ inputIconHeight: String
138
+ }
139
+
140
+ const Icon = styled('img', IconProps)`
141
+ position: absolute;
142
+ right: 10px;
143
+ top: 2px;
144
+ `
128
145
 
129
146
  const InputWrapper = styled.span`
130
147
  position: relative;
131
148
  `
132
149
 
133
- const UnitContainer = styled("span", inputProps)`
150
+ const UnitContainer = styled('span', inputProps)`
134
151
  border-left: 1px solid
135
152
  ${(props) =>
136
153
  props.isError
@@ -150,12 +167,14 @@ const UnitContainer = styled("span", inputProps)`
150
167
  : props.theme.colors.mediumGray};
151
168
  `
152
169
 
153
- const ErrorMessage = styled.div`
154
- font-size: 14px;
155
- color: ${(props) => props.theme.colors.red};
156
- position: absolute;
157
- top: calc(100% + 1px);
158
- `
170
+ // const ErrorMessage = styled.div`
171
+ // margin-top: 5px;
172
+ // line-height: 1;
173
+ // text-transform: none;
174
+ // font-size: 10px;
175
+ // color: ${(props) => props.theme.colors.red};
176
+ // position: absolute;
177
+ // `
159
178
 
160
179
  const LabelWrapper = styled.div`
161
180
  display: flex;
@@ -169,7 +188,7 @@ const LabelText = styled.div`
169
188
  `
170
189
 
171
190
  export default {
172
- name: "input-number",
191
+ name: 'input-number',
173
192
  components: {
174
193
  Container,
175
194
  InputContainer,
@@ -179,130 +198,154 @@ export default {
179
198
  LabelWrapper,
180
199
  LabelText,
181
200
  InfoText,
201
+ Icon
182
202
  },
203
+ inheritAttrs: false,
183
204
  data() {
184
205
  return {
185
- textInput: "",
206
+ textInput: '',
186
207
  isFocused: false,
208
+ warningIcon: warningIcon
209
+ }
210
+ },
211
+ computed: {
212
+ displayedPlaceholder() {
213
+ if (this.placeholder) return this.placeholder
214
+ return `${this.minNumber || 0} ${this.unitName ? this.unitName : ''}`
187
215
  }
188
216
  },
189
217
  props: {
190
218
  placeholder: {
191
219
  required: false,
192
- default: "",
220
+ default: ''
193
221
  },
194
222
  isError: {
195
223
  required: false,
196
- default: false,
224
+ default: false
197
225
  },
198
226
  inputWidth: {
199
227
  required: false,
200
- default: null,
228
+ default: null
201
229
  },
202
230
  minWidth: {
203
231
  required: false,
204
- default: null,
232
+ default: null
205
233
  },
206
234
  value: {
207
235
  required: true,
208
- default: null,
236
+ default: null
209
237
  },
210
238
  clearInput: {
211
239
  required: false,
212
- default: false,
240
+ default: false
213
241
  },
214
242
  errorMessage: {
215
243
  required: false,
216
- default: "Please insert a correct number",
244
+ default: 'Please insert a correct number'
217
245
  },
218
246
  numberPrecision: {
219
247
  required: false,
220
- default: 0,
248
+ default: 0
221
249
  },
222
250
  unitName: {
223
251
  required: false,
224
- default: "",
252
+ default: ''
225
253
  },
226
254
  showLinearUnitName: {
227
255
  required: false,
228
- default: false,
256
+ default: false
229
257
  },
230
258
  disabled: {
231
259
  required: false,
232
- default: false,
260
+ default: false
233
261
  },
234
262
  noBorder: {
235
263
  required: false,
236
- default: false,
264
+ default: false
237
265
  },
238
266
  textAlign: {
239
267
  required: false,
240
- default: "left",
268
+ default: 'left'
241
269
  },
242
270
  fontSize: {
243
271
  required: false,
244
- default: "13px",
272
+ default: '13px'
245
273
  },
246
274
  labelText: {
247
275
  required: false,
248
- default: null,
276
+ default: null
249
277
  },
250
278
  labelInfoText: {
251
279
  required: false,
252
- default: null,
280
+ default: null
253
281
  },
254
282
  labelInfoAlign: {
255
283
  required: false,
256
- default: "right",
284
+ default: 'right'
257
285
  },
258
286
  minNumber: {
259
287
  required: false,
260
- default: null,
288
+ default: null
261
289
  },
262
290
  fontColor: {
263
291
  required: false,
264
- default: null,
292
+ default: null
265
293
  },
266
294
  numberToStringEnabled: {
267
295
  required: false,
268
- default: true,
296
+ default: true
297
+ },
298
+ inputIcon: {
299
+ require: false,
300
+ type: Boolean,
301
+ default: false
302
+ },
303
+ inputIconImage: {
304
+ require: false,
305
+ type: String,
306
+ default: ''
269
307
  },
308
+ inputIconImageClass: {
309
+ require: false,
310
+ type: Array,
311
+ default: () => []
312
+ }
270
313
  },
271
314
  methods: {
272
315
  onChangeHandler(event) {
273
316
  if (isNaN(event)) {
274
317
  event = this.minNumber || this.minNumber === 0 ? this.minNumber : event
275
318
  }
276
- this.$emit("input-change", event)
319
+ this.$emit('input-change', event)
277
320
  },
278
321
  onEvaluateCode(val) {
279
322
  // function to perform math on the code
280
323
  // filter the string in case of any malicious content
281
- let filtered = val.replace(/[^-()\d/*+.,]/g, "")
324
+ let filtered = val.replace(/[^-()\d/*+.,]/g, '')
282
325
  filtered = filtered.split(/([-+*/()])/)
283
326
  let formatted = filtered.map((item) => {
284
327
  if (
285
- item === "+" ||
286
- item === "-" ||
287
- item === "*" ||
288
- item === "/" ||
289
- item === "(" ||
290
- item === ")" ||
291
- item === ""
328
+ item === '+' ||
329
+ item === '-' ||
330
+ item === '*' ||
331
+ item === '/' ||
332
+ item === '(' ||
333
+ item === ')' ||
334
+ item === ''
292
335
  ) {
293
336
  return item
294
337
  } else {
295
338
  let num = stringToNumber({
296
339
  value: item,
297
- numberPrecision: false,
340
+ numberPrecision: false
298
341
  })
299
342
  return num
300
343
  }
301
344
  })
302
- let evaluated = eval(formatted.join(""))
345
+ let evaluated = eval(formatted.join(''))
303
346
  evaluated = stringToNumber({
304
347
  value: evaluated,
305
- numberPrecision: this.numberPrecision,
348
+ numberPrecision: this.numberPrecision
306
349
  })
307
350
  return evaluated
308
351
  },
@@ -315,7 +358,7 @@ export default {
315
358
  this.textInput = numberToString({
316
359
  value:
317
360
  evaluatedInput && value.length ? evaluatedInput : this.minNumber,
318
- numberPrecision: this.numberPrecision,
361
+ numberPrecision: this.numberPrecision
319
362
  })
320
363
  }
321
364
  let adjustedMinValue =
@@ -323,8 +366,8 @@ export default {
323
366
  ? value
324
367
  : this.minNumber || this.minNumber === 0
325
368
  ? this.minNumber
326
- : ""
327
- this.$emit("input-blur", adjustedMinValue)
369
+ : ''
370
+ this.$emit('input-blur', adjustedMinValue)
328
371
  },
329
372
  focusInput() {
330
373
  if (this.disabled) {
@@ -341,38 +384,38 @@ export default {
341
384
  ? value
342
385
  : this.minNumber || this.minNumber === 0
343
386
  ? this.minNumber
344
- : ""
387
+ : ''
345
388
  if ((adjustedMinValue || adjustedMinValue === 0) && !this.isFocused) {
346
389
  let input = this.numberToStringEnabled
347
390
  ? numberToString({
348
391
  value: adjustedMinValue,
349
- numberPrecision: this.numberPrecision,
392
+ numberPrecision: this.numberPrecision
350
393
  })
351
394
  : adjustedMinValue
352
- let unit = this.showLinearUnitName ? "" : this.unitName
353
- return input + " " + unit
395
+ let unit = this.showLinearUnitName ? '' : this.unitName
396
+ return input + ' ' + unit
354
397
  } else if (!adjustedMinValue && adjustedMinValue !== 0) {
355
- return ""
398
+ return ''
356
399
  } else {
357
400
  return this.numberToStringEnabled
358
401
  ? numberToString({
359
402
  value: adjustedMinValue,
360
- numberPrecision: this.numberPrecision,
403
+ numberPrecision: this.numberPrecision
361
404
  })
362
405
  : adjustedMinValue
363
406
  }
364
- },
407
+ }
365
408
  },
366
409
  created() {
367
410
  if (this.value) {
368
411
  this.textInput = numberToString({
369
412
  value: this.value,
370
- numberPrecision: this.numberPrecision,
413
+ numberPrecision: this.numberPrecision
371
414
  })
372
415
  } else if (this.minNumber !== null) {
373
416
  this.textInput = numberToString({
374
417
  value: this.minNumber,
375
- numberPrecision: this.numberPrecision,
418
+ numberPrecision: this.numberPrecision
376
419
  })
377
420
  }
378
421
  },
@@ -380,9 +423,9 @@ export default {
380
423
  clearInput: function (value) {
381
424
  if (value) {
382
425
  // If the value is typed, then we should clear the textInput on Continue
383
- this.textInput = ""
426
+ this.textInput = ''
384
427
  }
385
- },
386
- },
428
+ }
429
+ }
387
430
  }
388
- </script>
431
+ </script>