@eturnity/eturnity_reusable_components 6.48.2 → 6.50.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eturnity/eturnity_reusable_components",
3
- "version": "6.48.2",
3
+ "version": "6.50.0",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "vue-cli-service serve",
@@ -63,4 +63,4 @@
63
63
  "author": "Aaron Enser",
64
64
  "license": "ISC",
65
65
  "homepage": "https://bitbucket.org/eturnitydevs/eturnity_reusable_components#readme"
66
- }
66
+ }
@@ -0,0 +1,3 @@
1
+ <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M10 0H11H16C17.1046 0 18 0.895431 18 2V12H12C10.8954 12 10 11.1046 10 10V4L0 4V2C0 0.89543 0.895431 0 2 0H10ZM0 6H6C7.10457 6 8 6.89543 8 8V14H18V16C18 17.1046 17.1046 18 16 18H8H7H2C0.895431 18 0 17.1046 0 16V6Z" fill="white"/>
3
+ </svg>
@@ -6,6 +6,7 @@
6
6
  :isDisabled="isDisabled"
7
7
  :customColor="customColor"
8
8
  :noWrap="noWrap"
9
+ :data-id="dataId"
9
10
  >
10
11
  {{ text }}
11
12
  </button-container>
@@ -21,38 +22,45 @@
21
22
  // type="secondary" // primary, secondary, cancel
22
23
  // :isDisabled="true"
23
24
  // :minWidth="minWidth"
25
+ // :dataId="test_data_id"
24
26
  // />
25
27
 
26
- import styled from "vue-styled-components"
28
+ import styled from 'vue-styled-components'
27
29
 
28
30
  const PageContainer = styled.div``
29
31
 
30
- const ButtonAttrs = { type: String, isDisabled: Boolean, minWidth: String, customColor: String, noWrap: Boolean }
31
- const ButtonContainer = styled("div", ButtonAttrs)`
32
+ const ButtonAttrs = {
33
+ type: String,
34
+ isDisabled: Boolean,
35
+ minWidth: String,
36
+ customColor: String,
37
+ noWrap: Boolean
38
+ }
39
+ const ButtonContainer = styled('div', ButtonAttrs)`
32
40
  padding: 7px 15px;
33
41
  font-size: 13px;
34
42
  color: ${(props) => props.theme.colors.white};
35
43
  background-color: ${(props) =>
36
- props.isDisabled
37
- ? props.theme.colors.disabled
38
- : props.customColor
39
- ? props.customColor
40
- : props.type === "primary"
41
- ? props.theme.colors.black
42
- : props.type === "secondary"
43
- ? props.theme.colors.grey3
44
- : props.type === "cancel"
45
- ? props.theme.colors.red
46
- : props.theme.colors.black};
44
+ props.isDisabled
45
+ ? props.theme.colors.disabled
46
+ : props.customColor
47
+ ? props.customColor
48
+ : props.type === 'primary'
49
+ ? props.theme.colors.black
50
+ : props.type === 'secondary'
51
+ ? props.theme.colors.grey3
52
+ : props.type === 'cancel'
53
+ ? props.theme.colors.red
54
+ : props.theme.colors.black};
47
55
  border-radius: 4px;
48
56
  text-align: center;
49
- cursor: ${(props) => (props.isDisabled ? "not-allowed" : "pointer")};
57
+ cursor: ${(props) => (props.isDisabled ? 'not-allowed' : 'pointer')};
50
58
  user-select: none;
51
59
  ${(props) => (props.minWidth ? `min-width: ${props.minWidth};` : '')};
52
60
  ${(props) => (props.noWrap ? `white-space: nowrap;` : '')};
53
61
 
54
62
  &:hover {
55
- opacity: ${(props) => (props.isDisabled ? "1" : "0.8")};
63
+ opacity: ${(props) => (props.isDisabled ? '1' : '0.8')};
56
64
  }
57
65
 
58
66
  &:active {
@@ -61,26 +69,26 @@ const ButtonContainer = styled("div", ButtonAttrs)`
61
69
  `
62
70
 
63
71
  export default {
64
- name: "main-button",
72
+ name: 'main-button',
65
73
  components: {
66
74
  PageContainer,
67
- ButtonContainer,
75
+ ButtonContainer
68
76
  },
69
77
  props: {
70
78
  type: {
71
79
  required: false,
72
- default: "primary",
80
+ default: 'primary'
73
81
  },
74
82
  isDisabled: {
75
83
  required: false,
76
- default: false,
84
+ default: false
77
85
  },
78
86
  text: {
79
- required: true,
87
+ required: true
80
88
  },
81
89
  customColor: {
82
90
  required: false,
83
- default: null,
91
+ default: null
84
92
  },
85
93
  noWrap: {
86
94
  required: false,
@@ -89,7 +97,11 @@ export default {
89
97
  minWidth: {
90
98
  required: false,
91
99
  default: null
100
+ },
101
+ dataId: {
102
+ type: String,
103
+ default: ''
92
104
  }
93
- },
105
+ }
94
106
  }
95
107
  </script>
@@ -8,63 +8,85 @@
8
8
  :color="iconColor"
9
9
  :hoveredBackgroundColor="hoveredBackgroundColor"
10
10
  :isHovered="isHovered"
11
- >
12
- <icon :disabled="disabled"
13
- :size="iconSize"
14
- :name="name"
15
- :color="iconColor"
16
- :hoveredColor="hoveredIconColor"
17
- :isStriked="isStriked"
18
- />
19
-
20
- <caret v-if="hasCaret">
21
- <iconWrapper :disabled="disabled"
22
- size="10px"
23
- name="arrow_down"
24
- :iconColor="iconColor"
25
- :hoveredBackgroundColor="hoveredIconColor"
26
- borderRadius="1px"
27
- />
28
- </caret>
29
- </Wrapper>
30
- </template>
31
-
32
- <script>
33
- // import Icon from "@eturnity/eturnity_reusable_components/src/components/icon"
34
- // How to use:
35
- //<icon
36
- // name="House" //required. a svg file named [name].svg should be present in /assets/svgIcons
37
- // color="red"
38
- // hoveredColor="blue"
39
- // size="60px" by default, this is 30px
40
- // />
41
-
42
- import styled from 'vue-styled-components'
43
- import icon from '../icon'
44
- const wrapperAttrs = { color: String, isHovered:Boolean,borderRadius:String,disabled: Boolean, size: String,backgroundColor:String,hoveredBackgroundColor:String,hasBorder:Boolean }
45
- const Wrapper = styled('div', wrapperAttrs)`
46
- position:relative;
47
- display: inline-flex;
48
- width: ${(props) => props.size};
49
- height: ${(props) => props.size};
50
- border: ${(props) => props.hasBorder? 'solid 1px '+props.theme.colors[props.color] || props.color : ""};
51
- justify-content:center;
52
- align-items:center;
53
- cursor: ${(props) => (props.disabled ? 'not-allowed' : 'pointer')};
54
- background-color: ${(props)=>props.theme.colors[props.backgroundColor] || props.backgroundColor};
55
- border-radius: ${(props) => props.borderRadius};
56
- ${(props)=>(props.isHovered ? 'background-color:'+props.theme.colors[props.hoveredBackgroundColor] || props.hoveredBackgroundColor : "")};
57
- &:hover{
58
- background-color:${(props)=>props.theme.colors[props.hoveredBackgroundColor] || props.hoveredBackgroundColor};
59
- }
60
- `
61
- const caret=styled.div`
62
- position:absolute;
63
- bottom:3px;
64
- right:2px;
65
- height:10px;
66
- `
67
-
11
+ >
12
+ <icon
13
+ :disabled="disabled"
14
+ :size="iconSize"
15
+ :name="name"
16
+ :color="iconColor"
17
+ :hoveredColor="hoveredIconColor"
18
+ :isStriked="isStriked"
19
+ />
20
+
21
+ <caret v-if="hasCaret">
22
+ <iconWrapper
23
+ :disabled="disabled"
24
+ size="10px"
25
+ name="arrow_down"
26
+ :iconColor="iconColor"
27
+ :hoveredBackgroundColor="hoveredIconColor"
28
+ borderRadius="1px"
29
+ />
30
+ </caret>
31
+ </Wrapper>
32
+ </template>
33
+
34
+ <script>
35
+ // import Icon from "@eturnity/eturnity_reusable_components/src/components/icon"
36
+ // How to use:
37
+ //<icon
38
+ // name="House" //required. a svg file named [name].svg should be present in /assets/svgIcons
39
+ // color="red"
40
+ // hoveredColor="blue"
41
+ // size="60px" by default, this is 30px
42
+ // />
43
+
44
+ import styled from 'vue-styled-components'
45
+ import icon from '../icon'
46
+ const wrapperAttrs = {
47
+ color: String,
48
+ isHovered: Boolean,
49
+ borderRadius: String,
50
+ disabled: Boolean,
51
+ size: String,
52
+ backgroundColor: String,
53
+ hoveredBackgroundColor: String,
54
+ hasBorder: Boolean
55
+ }
56
+ const Wrapper = styled('div', wrapperAttrs)`
57
+ position: relative;
58
+ display: inline-flex;
59
+ width: ${(props) => props.size};
60
+ height: ${(props) => props.size};
61
+ border: ${(props) =>
62
+ props.hasBorder
63
+ ? 'solid 1px ' + props.theme.colors[props.color] || props.color
64
+ : ''};
65
+ justify-content: center;
66
+ align-items: center;
67
+ cursor: ${(props) => (props.disabled ? 'not-allowed' : 'pointer')};
68
+ background-color: ${(props) =>
69
+ props.theme.colors[props.backgroundColor] || props.backgroundColor};
70
+ border-radius: ${(props) => props.borderRadius};
71
+ ${(props) =>
72
+ props.isHovered
73
+ ? 'background-color:' +
74
+ props.theme.colors[props.hoveredBackgroundColor] ||
75
+ props.hoveredBackgroundColor
76
+ : ''};
77
+ &:hover {
78
+ background-color: ${(props) =>
79
+ props.theme.colors[props.hoveredBackgroundColor] ||
80
+ props.hoveredBackgroundColor};
81
+ }
82
+ `
83
+ const caret = styled.div`
84
+ position: absolute;
85
+ bottom: 3px;
86
+ right: 2px;
87
+ height: 10px;
88
+ `
89
+
68
90
  export default {
69
91
  name: 'iconWrapper',
70
92
  components: {
@@ -11,6 +11,7 @@
11
11
  <input-checkbox
12
12
  type="checkbox"
13
13
  :checked="isChecked"
14
+ :data-id="dataId"
14
15
  @change="onChangeHandler(!isChecked)"
15
16
  />
16
17
  <div>
@@ -168,6 +169,10 @@ export default {
168
169
  isDisabled: {
169
170
  required: false,
170
171
  default: false
172
+ },
173
+ dataId: {
174
+ type: String,
175
+ default: ''
171
176
  }
172
177
  },
173
178
  methods: {
@@ -84,6 +84,7 @@
84
84
  // inputWidth="150px" //by default, this is 100%
85
85
  // minWidth="100px"
86
86
  // :numberPrecision="3"
87
+ // minDecimals="2"
87
88
  // unitName="pc"
88
89
  // :value="inputValue" //required -- String
89
90
  // @input-change="onInputChange($event)" //required
@@ -358,6 +359,10 @@ export default {
358
359
  required: false,
359
360
  default: 0
360
361
  },
362
+ minDecimals: {
363
+ required: false,
364
+ default: 0
365
+ },
361
366
  unitName: {
362
367
  required: false,
363
368
  default: ''
@@ -498,7 +503,8 @@ export default {
498
503
  } else {
499
504
  let num = stringToNumber({
500
505
  value: item,
501
- numberPrecision: false
506
+ numberPrecision: false,
507
+ minDecimals: this.minDecimals
502
508
  })
503
509
  return num
504
510
  }
@@ -509,7 +515,8 @@ export default {
509
515
  if (typeof evaluated === 'string') {
510
516
  evaluated = stringToNumber({
511
517
  value: evaluated,
512
- numberPrecision: this.numberPrecision
518
+ numberPrecision: this.numberPrecision,
519
+ minDecimals: this.minDecimals
513
520
  })
514
521
  } else if (typeof evaluated === 'number') {
515
522
  evaluated = evaluated.toFixed(this.numberPrecision)
@@ -569,7 +576,8 @@ export default {
569
576
  : this.defaultNumber
570
577
  ? this.defaultNumber
571
578
  : this.minNumber,
572
- numberPrecision: this.numberPrecision
579
+ numberPrecision: this.numberPrecision,
580
+ minDecimals: this.minDecimals
573
581
  })
574
582
  }
575
583
  let adjustedMinValue =
@@ -614,7 +622,8 @@ export default {
614
622
  let input = this.numberToStringEnabled
615
623
  ? numberToString({
616
624
  value: adjustedMinValue,
617
- numberPrecision: this.numberPrecision
625
+ numberPrecision: this.numberPrecision,
626
+ minDecimals: this.minDecimals
618
627
  })
619
628
  : adjustedMinValue
620
629
  let unit = this.showLinearUnitName ? '' : this.unitName
@@ -626,7 +635,8 @@ export default {
626
635
  return this.numberToStringEnabled
627
636
  ? numberToString({
628
637
  value: adjustedMinValue,
629
- numberPrecision: this.numberPrecision
638
+ numberPrecision: this.numberPrecision,
639
+ minDecimals: this.minDecimals
630
640
  })
631
641
  : adjustedMinValue
632
642
  }
@@ -645,7 +655,8 @@ export default {
645
655
 
646
656
  this.textInput = numberToString({
647
657
  value: value && value.length ? value : this.minNumber,
648
- numberPrecision: this.numberPrecision
658
+ numberPrecision: this.numberPrecision,
659
+ minDecimals: this.minDecimals
649
660
  })
650
661
  //this.value=value
651
662
  },
@@ -660,17 +671,20 @@ export default {
660
671
  if (this.value) {
661
672
  this.textInput = numberToString({
662
673
  value: this.value,
663
- numberPrecision: this.numberPrecision
674
+ numberPrecision: this.numberPrecision,
675
+ minDecimals: this.minDecimals
664
676
  })
665
677
  } else if (this.defaultNumber !== null) {
666
678
  this.textInput = numberToString({
667
679
  value: this.defaultNumber,
668
- numberPrecision: this.numberPrecision
680
+ numberPrecision: this.numberPrecision,
681
+ minDecimals: this.minDecimals
669
682
  })
670
683
  } else if (this.minNumber !== null) {
671
684
  this.textInput = numberToString({
672
685
  value: this.minNumber,
673
- numberPrecision: this.numberPrecision
686
+ numberPrecision: this.numberPrecision,
687
+ minDecimals: this.minDecimals
674
688
  })
675
689
  }
676
690
  },
@@ -1,7 +1,12 @@
1
1
  <template>
2
2
  <component-wrapper :layout="layout">
3
3
  <radio-wrapper v-for="(item, index) in options" :key="item.value">
4
- <label-container :size="size" :isDisabled="item.disabled" :isChecked="selectedOption === item.value" :checkmarkColor="checkmarkColor">
4
+ <label-container
5
+ :size="size"
6
+ :isDisabled="item.disabled"
7
+ :isChecked="selectedOption === item.value"
8
+ :checkmarkColor="checkmarkColor"
9
+ >
5
10
  <radio
6
11
  type="radio"
7
12
  :value="selectedOption"
@@ -9,6 +14,7 @@
9
14
  :name="'radioButtons_' + radioName"
10
15
  :checked="selectedOption === item.value"
11
16
  :disabled="item.disabled"
17
+ :data-id="`radio_button_${dataId}_option_${item.value}`"
12
18
  />
13
19
  <span class="checkmark"></span>
14
20
  <label-text :isDisabled="item.disabled">{{ item.label }}</label-text>
@@ -54,17 +60,17 @@
54
60
  // { label: 'Button 4', value: 'button_4', disabled: true }
55
61
  // ]
56
62
 
57
- import styled from "vue-styled-components"
58
- import Modal from "../../modals/modal"
59
- import InfoText from "../../infoText"
63
+ import styled from 'vue-styled-components'
64
+ import Modal from '../../modals/modal'
65
+ import InfoText from '../../infoText'
60
66
 
61
67
  const wrapperProps = {
62
- layout: String,
68
+ layout: String
63
69
  }
64
- const ComponentWrapper = styled("div", wrapperProps)`
70
+ const ComponentWrapper = styled('div', wrapperProps)`
65
71
  display: flex;
66
72
  flex-direction: ${(props) =>
67
- props.layout === "vertical" ? "column" : "row"};
73
+ props.layout === 'vertical' ? 'column' : 'row'};
68
74
  grid-gap: 10px 5px;
69
75
  flex-wrap: wrap;
70
76
  `
@@ -83,8 +89,13 @@ const RadioWrapper = styled.div`
83
89
  grid-gap: 10px;
84
90
  `
85
91
 
86
- const containerProps = { size: String, isDisabled: Boolean, isChecked: Boolean, checkmarkColor: String }
87
- const LabelContainer = styled("label", containerProps)`
92
+ const containerProps = {
93
+ size: String,
94
+ isDisabled: Boolean,
95
+ isChecked: Boolean,
96
+ checkmarkColor: String
97
+ }
98
+ const LabelContainer = styled('label', containerProps)`
88
99
  display: grid;
89
100
  grid-template-columns: auto 1fr auto;
90
101
  grid-gap: 15px;
@@ -92,30 +103,30 @@ const LabelContainer = styled("label", containerProps)`
92
103
  color: ${(props) =>
93
104
  props.isDisabled ? props.theme.colors.grey2 : props.theme.colors.black};
94
105
  position: relative;
95
- cursor: ${(props) => (props.isDisabled ? "not-allowed" : "pointer")};
106
+ cursor: ${(props) => (props.isDisabled ? 'not-allowed' : 'pointer')};
96
107
  font-size: ${(props) =>
97
- props.size === "large"
98
- ? "16px"
99
- : props.size === "medium"
100
- ? "13px"
101
- : "10px"};
108
+ props.size === 'large'
109
+ ? '16px'
110
+ : props.size === 'medium'
111
+ ? '13px'
112
+ : '10px'};
102
113
  user-select: none;
103
114
  flex: auto;
104
115
  align-self: baseline;
105
116
 
106
117
  .checkmark {
107
118
  height: ${(props) =>
108
- props.size === "large"
109
- ? "23px"
110
- : props.size === "medium"
111
- ? "16px"
112
- : "12px"};
119
+ props.size === 'large'
120
+ ? '23px'
121
+ : props.size === 'medium'
122
+ ? '16px'
123
+ : '12px'};
113
124
  width: ${(props) =>
114
- props.size === "large"
115
- ? "23px"
116
- : props.size === "medium"
117
- ? "16px"
118
- : "12px"};
125
+ props.size === 'large'
126
+ ? '23px'
127
+ : props.size === 'medium'
128
+ ? '16px'
129
+ : '12px'};
119
130
  background-color: #fff;
120
131
  border-radius: 100%;
121
132
  border: 1px solid ${(props) => props.theme.colors.mediumGray};
@@ -124,28 +135,29 @@ const LabelContainer = styled("label", containerProps)`
124
135
  justify-content: center;
125
136
 
126
137
  &:after {
127
- content: "";
128
- display: ${(props) => props.isChecked ? 'block' : 'none'};
138
+ content: '';
139
+ display: ${(props) => (props.isChecked ? 'block' : 'none')};
129
140
  width: ${(props) =>
130
- props.size === "large"
131
- ? "10px"
132
- : props.size === "medium"
133
- ? "8px"
134
- : "6px"};
141
+ props.size === 'large'
142
+ ? '10px'
143
+ : props.size === 'medium'
144
+ ? '8px'
145
+ : '6px'};
135
146
  height: ${(props) =>
136
- props.size === "large"
137
- ? "10px"
138
- : props.size === "medium"
139
- ? "8px"
140
- : "6px"};
147
+ props.size === 'large'
148
+ ? '10px'
149
+ : props.size === 'medium'
150
+ ? '8px'
151
+ : '6px'};
141
152
  border-radius: 100%;
142
- background: ${(props) => props.checkmarkColor ? props.checkmarkColor : props.theme.colors.green};
153
+ background: ${(props) =>
154
+ props.checkmarkColor ? props.checkmarkColor : props.theme.colors.green};
143
155
  }
144
156
  }
145
157
  `
146
158
 
147
159
  const textAttrs = { isDisabled: Boolean }
148
- const LabelText = styled("div", textAttrs)`
160
+ const LabelText = styled('div', textAttrs)`
149
161
  color: ${(props) =>
150
162
  props.isDisabled ? props.theme.colors.grey2 : props.theme.colors.black};
151
163
  `
@@ -186,7 +198,7 @@ const ModalImageContainer = styled.div`
186
198
  `
187
199
 
188
200
  export default {
189
- name: "radio-button",
201
+ name: 'radio-button',
190
202
  components: {
191
203
  Radio,
192
204
  ComponentWrapper,
@@ -198,24 +210,24 @@ export default {
198
210
  ModalImage,
199
211
  ModalImageContainer,
200
212
  InfoText,
201
- LabelText,
213
+ LabelText
202
214
  },
203
215
  props: {
204
216
  selectedOption: {
205
217
  required: true,
206
- default: false,
218
+ default: false
207
219
  },
208
220
  options: {
209
221
  required: true,
210
- default: [],
222
+ default: []
211
223
  },
212
224
  layout: {
213
225
  required: false,
214
- default: "horizontal", //2 options: 'vertical' (only 1 per row) & 'horizontal' (many per row)
226
+ default: 'horizontal' //2 options: 'vertical' (only 1 per row) & 'horizontal' (many per row)
215
227
  },
216
228
  size: {
217
229
  required: false,
218
- default: "medium", // small, medium, large
230
+ default: 'medium' // small, medium, large
219
231
  },
220
232
  name: {
221
233
  required: false,
@@ -224,6 +236,10 @@ export default {
224
236
  checkmarkColor: {
225
237
  required: false,
226
238
  default: ''
239
+ },
240
+ dataId: {
241
+ type: String,
242
+ default: 'key'
227
243
  }
228
244
  },
229
245
  data() {
@@ -234,17 +250,18 @@ export default {
234
250
  },
235
251
  methods: {
236
252
  onInputHandler(value) {
237
- this.$emit("on-radio-change", value)
253
+ this.$emit('on-radio-change', value)
238
254
  },
239
255
  isImageOpen(index) {
240
256
  return this.selectedImage === index
241
257
  },
242
258
  toggleImageModal(value) {
243
259
  this.selectedImage = value
244
- },
260
+ }
245
261
  },
246
262
  created() {
247
- this.radioName = this.name.length === 0 ? Math.round(Math.random() * 10000) : this.name
248
- },
263
+ this.radioName =
264
+ this.name.length === 0 ? Math.round(Math.random() * 10000) : this.name
265
+ }
249
266
  }
250
267
  </script>
@@ -492,10 +492,14 @@ export default {
492
492
  this.toggleDropdown()
493
493
  },
494
494
  clickOutside(event) {
495
+ const dropdownRef = this.$refs.dropdown
496
+ // we need to prevent closing on selecting an option, because in the case of
497
+ // a disabled option, we don't want to close the dropdown
495
498
  if (!this.isClickOutsideActive) return
496
499
  if (
497
500
  this.$refs.select.$el == event.target ||
498
- this.$refs.select.$el.contains(event.target)
501
+ this.$refs.select.$el.contains(event.target) ||
502
+ event.target.parentNode === dropdownRef.$el
499
503
  ) {
500
504
  return
501
505
  } else {
@@ -1,10 +1,18 @@
1
1
  <template>
2
2
  <optionContainer
3
3
  :data-value="value"
4
- :hoveredBgColor="colorMode == 'dark' ? '#000000' : 'hoveredBgColor'"
5
- :backgroundColor="colorMode == 'dark' ? 'eturnityGrey' : '#fff'"
4
+ :hoveredBgColor="
5
+ colorMode == 'dark'
6
+ ? '#000000'
7
+ : hoveredBgColor
8
+ ? hoveredBgColor
9
+ : 'grey5'
10
+ "
6
11
  @click="clickHandler"
7
12
  @mouseover="hoverHandler"
13
+ :cursorType="cursorType"
14
+ :backgroundColor="colorMode == 'dark' ? '#000000' : backgroundColor"
15
+ :title="hoverText"
8
16
  >
9
17
  <slot></slot>
10
18
  </optionContainer>
@@ -14,18 +22,29 @@
14
22
  // import selectButton from './selectButton'
15
23
  // import selectDropdown from './selectDropDown'
16
24
  import styled from 'vue-styled-components'
17
- const optionProps = { hoveredBgColor: String, backgroundColor: String }
25
+ const optionProps = {
26
+ hoveredBgColor: String,
27
+ cursorType: String,
28
+ backgroundColor: String
29
+ }
18
30
  const optionContainer = styled('div', optionProps)`
19
31
  display: flex;
20
- cursor: pointer;
32
+ cursor: ${(props) => props.cursorType};
21
33
  flex-direction: row;
22
34
  justify-content: space-between;
23
35
  align-items: center;
24
36
  padding: 12px 10px;
25
37
  gap: 14px;
26
38
  width: 100%;
27
- background-color: ${(props) => props.theme.colors[props.backgroundColor]?props.theme.colors[props.backgroundColor]:props.backgroundColor};
39
+ background-color: ${(props) =>
40
+ props.theme.colors[props.backgroundColor]
41
+ ? props.theme.colors[props.backgroundColor]
42
+ : props.backgroundColor};
28
43
  box-sizing: inherit;
44
+ background-color: ${(props) =>
45
+ props.theme.colors[props.backgroundColor]
46
+ ? props.theme.colors[props.backgroundColor]
47
+ : props.backgroundColor};
29
48
  &:hover {
30
49
  background-color: ${(props) =>
31
50
  props.theme.colors[props.hoveredBgColor]
@@ -47,6 +66,21 @@ export default {
47
66
  colorMode: {
48
67
  required: false,
49
68
  default: 'light'
69
+ },
70
+ cursorType: {
71
+ required: false,
72
+ default: 'cursor'
73
+ },
74
+ backgroundColor: {
75
+ required: false,
76
+ default: 'white'
77
+ },
78
+ hoverText: {
79
+ required: false
80
+ },
81
+ isDisabled: {
82
+ required: false,
83
+ default: false
50
84
  }
51
85
  },
52
86
 
@@ -57,7 +91,12 @@ export default {
57
91
  },
58
92
  methods: {
59
93
  clickHandler() {
60
- this.$parent.$emit('option-selected', this.value)
94
+ if (this.isDisabled) {
95
+ // prevent emitter if the option is disabled
96
+ return
97
+ } else {
98
+ this.$parent.$emit('option-selected', this.value)
99
+ }
61
100
  },
62
101
  hoverHandler() {
63
102
  this.$parent.$emit('option-hovered', this.value)
@@ -1,6 +1,11 @@
1
1
  <template>
2
2
  <container>
3
- <flex-wrapper :size="size" :disabled="disabled" @click="onToggleChange">
3
+ <flex-wrapper
4
+ :size="size"
5
+ :disabled="disabled"
6
+ @click="onToggleChange"
7
+ :data-id="dataId"
8
+ >
4
9
  <label-container
5
10
  v-if="label && labelAlign === 'left'"
6
11
  :hasInfoMessage="!!infoTextMessage"
@@ -69,27 +74,28 @@
69
74
  // :disabled="true"
70
75
  // infoTextAlign="right" // left by default
71
76
  // infoTextMessage="My info message"
77
+ // dataId="test_data_id"
72
78
  // />
73
79
 
74
- import styled from "vue-styled-components"
75
- import InfoText from "../../infoText"
80
+ import styled from 'vue-styled-components'
81
+ import InfoText from '../../infoText'
76
82
 
77
83
  const Container = styled.div`
78
84
  display: inline-block;
79
85
  `
80
86
 
81
87
  const flexAttrs = { size: String, disabled: Boolean }
82
- const FlexWrapper = styled("div", flexAttrs)`
88
+ const FlexWrapper = styled('div', flexAttrs)`
83
89
  display: grid;
84
90
  grid-template-columns: auto 1fr;
85
91
  grid-gap: ${(props) =>
86
- props.size === "medium"
87
- ? "20px"
88
- : props.size === "small"
89
- ? "10px"
90
- : "20px"};
92
+ props.size === 'medium'
93
+ ? '20px'
94
+ : props.size === 'small'
95
+ ? '10px'
96
+ : '20px'};
91
97
  align-items: center;
92
- cursor: ${(props) => (props.disabled ? "not-allowed" : "pointer")};
98
+ cursor: ${(props) => (props.disabled ? 'not-allowed' : 'pointer')};
93
99
  `
94
100
 
95
101
  const toggleAttrs = {
@@ -97,43 +103,43 @@ const toggleAttrs = {
97
103
  fontColor: String,
98
104
  disabled: Boolean,
99
105
  backgroundColor: String,
100
- isChecked: Boolean,
106
+ isChecked: Boolean
101
107
  }
102
- const LabelText = styled("div", toggleAttrs)`
108
+ const LabelText = styled('div', toggleAttrs)`
103
109
  color: ${(props) =>
104
110
  props.fontColor ? props.fontColor : props.theme.colors.darkGray};
105
111
  font-size: ${(props) =>
106
- props.size === "medium"
107
- ? "16px"
108
- : props.size === "small"
109
- ? "13px"
110
- : "16px"};
112
+ props.size === 'medium'
113
+ ? '16px'
114
+ : props.size === 'small'
115
+ ? '13px'
116
+ : '16px'};
111
117
  `
112
118
 
113
- const ToggleWrapper = styled("span", toggleAttrs)`
119
+ const ToggleWrapper = styled('span', toggleAttrs)`
114
120
  display: inline-block;
115
121
  border: ${(props) =>
116
122
  props.disabled
117
- ? "1px solid " + props.theme.colors.disabled
123
+ ? '1px solid ' + props.theme.colors.disabled
118
124
  : props.isChecked
119
125
  ? props.backgroundColor
120
- ? "1px solid " + props.backgroundColor
121
- : "1px solid " + props.theme.colors.green
122
- : "1px solid " + props.theme.colors.grey3}
126
+ ? '1px solid ' + props.backgroundColor
127
+ : '1px solid ' + props.theme.colors.green
128
+ : '1px solid ' + props.theme.colors.grey3}
123
129
  position: relative;
124
- cursor: ${(props) => (props.disabled ? "not-allowed" : "pointer")};
130
+ cursor: ${(props) => (props.disabled ? 'not-allowed' : 'pointer')};
125
131
  width: ${(props) =>
126
- props.size === "medium"
127
- ? "50px"
128
- : props.size === "small"
129
- ? "29px"
130
- : "50px"};
132
+ props.size === 'medium'
133
+ ? '50px'
134
+ : props.size === 'small'
135
+ ? '29px'
136
+ : '50px'};
131
137
  height: ${(props) =>
132
- props.size === "medium"
133
- ? "24px"
134
- : props.size === "small"
135
- ? "16px"
136
- : "24px"};
138
+ props.size === 'medium'
139
+ ? '24px'
140
+ : props.size === 'small'
141
+ ? '16px'
142
+ : '24px'};
137
143
  border-radius: 100px;
138
144
 
139
145
  &:focus {
@@ -149,9 +155,9 @@ const ToggleWrapper = styled("span", toggleAttrs)`
149
155
  const backgroundAttrs = {
150
156
  backgroundColor: String,
151
157
  isChecked: Boolean,
152
- disabled: Boolean,
158
+ disabled: Boolean
153
159
  }
154
- const ToggleBackground = styled("span", backgroundAttrs)`
160
+ const ToggleBackground = styled('span', backgroundAttrs)`
155
161
  display: block;
156
162
  border-radius: 100px;
157
163
  height: 100%;
@@ -171,25 +177,25 @@ const toggleProps = {
171
177
  isChecked: Boolean,
172
178
  toggleColor: String,
173
179
  size: String,
174
- disabled: Boolean,
180
+ disabled: Boolean
175
181
  }
176
- const ToggleDot = styled("span", toggleProps)`
182
+ const ToggleDot = styled('span', toggleProps)`
177
183
  position: absolute;
178
184
  height: ${(props) =>
179
- props.size === "medium"
180
- ? "14px"
181
- : props.size === "small"
182
- ? "10px"
183
- : "14px"};
185
+ props.size === 'medium'
186
+ ? '14px'
187
+ : props.size === 'small'
188
+ ? '10px'
189
+ : '14px'};
184
190
  width: ${(props) =>
185
- props.size === "medium"
186
- ? "14px"
187
- : props.size === "small"
188
- ? "10px"
189
- : "14px"};
191
+ props.size === 'medium'
192
+ ? '14px'
193
+ : props.size === 'small'
194
+ ? '10px'
195
+ : '14px'};
190
196
  left: 3px
191
197
  bottom: ${(props) =>
192
- props.size === "medium" ? "5px" : props.size === "small" ? "2px" : "5px"};
198
+ props.size === 'medium' ? '5px' : props.size === 'small' ? '2px' : '5px'};
193
199
  background-color: ${(props) =>
194
200
  props.disabled
195
201
  ? props.theme.colors.disabled
@@ -202,33 +208,33 @@ const ToggleDot = styled("span", toggleProps)`
202
208
  transition: transform 0.4s ease;
203
209
  transform: ${(props) =>
204
210
  props.isChecked
205
- ? props.size === "medium"
206
- ? "translateX(25px)"
207
- : props.size === "small"
208
- ? "translateX(12px)"
209
- : "translateX(25px)"
210
- : "translateX(0)"};
211
+ ? props.size === 'medium'
212
+ ? 'translateX(25px)'
213
+ : props.size === 'small'
214
+ ? 'translateX(12px)'
215
+ : 'translateX(25px)'
216
+ : 'translateX(0)'};
211
217
 
212
218
  @media (max-width: ${(props) => props.theme.screen.mobile}) {
213
219
  height: 24px;
214
220
  width: 24px;
215
221
  transform: ${(props) =>
216
- props.isChecked ? "translateX(25px)" : "translateX(0)"};
222
+ props.isChecked ? 'translateX(25px)' : 'translateX(0)'};
217
223
  bottom: 8px;
218
224
  }
219
225
  `
220
226
 
221
227
  const labelAttrs = { hasInfoMessage: Boolean }
222
- const LabelContainer = styled("div", labelAttrs)`
228
+ const LabelContainer = styled('div', labelAttrs)`
223
229
  display: inline-grid;
224
230
  grid-template-columns: ${(props) =>
225
- props.hasInfoMessage ? "auto 1fr" : "auto"};
231
+ props.hasInfoMessage ? 'auto 1fr' : 'auto'};
226
232
  grid-gap: 12px;
227
233
  align-items: center;
228
234
  `
229
235
 
230
236
  export default {
231
- name: "toggle",
237
+ name: 'toggle',
232
238
  components: {
233
239
  Container,
234
240
  ToggleBackground,
@@ -237,52 +243,56 @@ export default {
237
243
  FlexWrapper,
238
244
  LabelText,
239
245
  InfoText,
240
- LabelContainer,
246
+ LabelContainer
241
247
  },
242
248
  props: {
243
249
  label: {
244
250
  required: false,
245
- default: "",
251
+ default: ''
246
252
  },
247
253
  isChecked: {
248
254
  required: true,
249
- default: false,
255
+ default: false
250
256
  },
251
257
  toggleColor: {
252
- required: false,
258
+ required: false
253
259
  },
254
260
  backgroundColor: {
255
- required: false,
261
+ required: false
256
262
  },
257
263
  size: {
258
264
  required: false,
259
- default: "small",
265
+ default: 'small'
260
266
  },
261
267
  labelAlign: {
262
268
  required: false,
263
- default: "right",
269
+ default: 'right'
264
270
  },
265
271
  fontColor: {
266
- required: false,
272
+ required: false
267
273
  },
268
274
  disabled: {
269
275
  required: false,
270
- default: false,
276
+ default: false
271
277
  },
272
278
  infoTextMessage: {
273
- required: false,
279
+ required: false
274
280
  },
275
281
  infoTextAlign: {
276
- required: false,
282
+ required: false
277
283
  },
284
+ dataId: {
285
+ type: String,
286
+ default: ''
287
+ }
278
288
  },
279
289
  methods: {
280
290
  onToggleChange() {
281
291
  if (this.disabled) {
282
292
  return
283
293
  }
284
- this.$emit("on-toggle-change", !this.isChecked)
285
- },
286
- },
294
+ this.$emit('on-toggle-change', !this.isChecked)
295
+ }
296
+ }
287
297
  }
288
298
  </script>
@@ -37,7 +37,7 @@ const ContentContainer = styled('div', contentAttrs)`
37
37
  visibility: ${(props) => (props.visible ? 'inherit' : 'hidden')};
38
38
  `
39
39
 
40
- const pageAttrs = { isOpen: Boolean, backdrop: String,position:String }
40
+ const pageAttrs = { isOpen: Boolean, backdrop: String, position: String }
41
41
  const PageWrapper = styled('div', pageAttrs)`
42
42
  position: ${(props) => props.position}
43
43
  display: grid;
@@ -8,6 +8,7 @@
8
8
  <list-item
9
9
  v-if="!item.children"
10
10
  :key="idx"
11
+ :data-id="`sub_menu_settings_${item.key}`"
11
12
  :isActive="activeTab === item.key"
12
13
  @click="$emit('tab-click', { activeKey: item.key })"
13
14
  >
@@ -57,6 +58,7 @@
57
58
  <icon-container
58
59
  :isActive="false"
59
60
  :isButton="true"
61
+ data-id="button_settings_logout"
60
62
  @click="$emit('on-logout')"
61
63
  >
62
64
  <rotate-icon
@@ -134,11 +134,13 @@
134
134
  {{ !!item[option] ? item[option] : '-' }}
135
135
  </span>
136
136
  <template-button
137
+ :key="idx"
137
138
  @click.stop="onTemplateClick(item)"
138
139
  v-else-if="option === 'template' && item.has_template"
139
140
  >{{ $gettext('Use template...') }}</template-button
140
141
  >
141
142
  <no-template
143
+ :key="idx"
142
144
  v-else-if="option === 'template' && !item.has_template"
143
145
  >
144
146
  {{ $gettext('No main component template') }}
@@ -91,19 +91,12 @@ export const stringToNumber = ({
91
91
  return parseFloat(newVal)
92
92
  }
93
93
 
94
- export const numberToString = ({ value, numberPrecision = 0 }) => {
94
+ export const numberToString = ({ value, numberPrecision, minDecimals }) => {
95
+ const minimumRounding = minDecimals ? minDecimals : 0
95
96
  value = parseFloat(value)
96
- let minNumberPrecision
97
- let maxNumberPrecision
98
- if (typeof numberPrecision === 'number') {
99
- minNumberPrecision = numberPrecision
100
- maxNumberPrecision = numberPrecision
101
- } else {
102
- minNumberPrecision = numberPrecision[0]
103
- maxNumberPrecision = numberPrecision[1]
104
- }
105
97
  return value.toLocaleString(langForLocaleString(), {
106
- minimumFractionDigits: minNumberPrecision,
107
- maximumFractionDigits: maxNumberPrecision
98
+ minimumFractionDigits: minimumRounding, // removing this for now. Why do we need this to be a minimum amount?
99
+ maximumFractionDigits:
100
+ numberPrecision < minimumRounding ? minimumRounding : numberPrecision
108
101
  })
109
102
  }