@eturnity/eturnity_reusable_components 1.2.1-beta.1 → 1.2.1

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