@eturnity/eturnity_reusable_components 1.2.31-3d-master.7 → 1.2.31-3d-master.9

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.31-3d-master.7",
3
+ "version": "1.2.31-3d-master.9",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "vue-cli-service serve",
package/src/App.vue CHANGED
@@ -54,11 +54,11 @@
54
54
  </template>
55
55
  </input-number>
56
56
  <Select
57
- hoverDropdown="true"
58
57
  selectWidth="100%"
59
58
  optionWidth="50%"
60
59
  label="that is a label"
61
60
  alignItems="vertical"
61
+ colorMode="light"
62
62
  >
63
63
  <template #selector="{selectedValue}">
64
64
  value selected: {{selectedValue}}
@@ -70,6 +70,66 @@
70
70
  <Option value="4">value four</Option>
71
71
  </template>
72
72
  </Select>
73
+ <Select
74
+ selectWidth="100%"
75
+ optionWidth="50%"
76
+ label="that is a label"
77
+ alignItems="vertical"
78
+ >
79
+ <template #selector="{selectedValue}">
80
+ value selected: {{selectedValue}}
81
+ </template>
82
+ <template #dropdown>
83
+ <Option value="1">value one</Option>
84
+ <Option value="2">value two</Option>
85
+ <Option value="3">value three</Option>
86
+ <Option value="4">value four</Option>
87
+ </template>
88
+ </Select>
89
+ <Select
90
+ selectWidth="100%"
91
+ optionWidth="50%"
92
+ label="that is a label"
93
+ alignItems="vertical"
94
+ colorMode="dark"
95
+ >
96
+ <template #selector="{selectedValue}">
97
+ value selected: {{selectedValue}}
98
+ </template>
99
+ <template #dropdown>
100
+ <Option value="1">value one</Option>
101
+ <Option value="2">value two</Option>
102
+ <Option value="3">value three</Option>
103
+ <Option value="4">value four</Option>
104
+ </template>
105
+ </Select>
106
+ <hr>
107
+ <SwitchField
108
+ @on-switch-change="onInputChange($event)"
109
+ :options="[{value:0,content:'zero'},{value:1,content:'one'},{value:2,content:'two'}]"
110
+ :value="1"
111
+ label="label"
112
+ toggleColor="red"
113
+ size="large"
114
+ backgroundColor="blue"
115
+ labelAlign="left"
116
+ fontColor="black"
117
+ :disabled="false"
118
+ />
119
+ <div :style="{padding:'50px',backgroundColor:'#1e1e1e'}">
120
+ <SwitchField
121
+ @on-switch-change="onInputChange($event)"
122
+ :options="[{value:'test',content:'zero'},{value:'1',content:'one'},{value:'2',content:'two'}]"
123
+ value='test'
124
+ label="label"
125
+ toggleColor="red"
126
+ size="large"
127
+ backgroundColor="blue"
128
+ labelAlign="left"
129
+ colorMode="dark"
130
+ alignItems="vertical"
131
+ />
132
+ </div>
73
133
  </div>
74
134
  </modal>
75
135
  </page-container>
@@ -84,6 +144,8 @@ import InputNumber from "@/components/inputs/inputNumber"
84
144
  import Select from "@/components/inputs/select"
85
145
  import Option from "@/components/inputs/select/option"
86
146
  import Modal from "@/components/modals/modal"
147
+ import SwitchField from "@/components/inputs/switchField"
148
+
87
149
  // import TableDropdown from "@/components/tableDropdown"
88
150
 
89
151
  const PageContainer = styled.div`
@@ -104,7 +166,8 @@ export default {
104
166
  InputNumber,
105
167
  Modal,
106
168
  Option,
107
- Select
169
+ Select,
170
+ SwitchField
108
171
  },
109
172
  data() {
110
173
  return {
@@ -456,8 +456,11 @@ export default {
456
456
  return evaluated
457
457
  },
458
458
  onInput(value){
459
- let evaluatedInput = this.onEvaluateCode(value)
460
- this.$emit('on-input',evaluatedInput)
459
+ try{
460
+ const evaluatedVal=this.onEvaluateCode(value)
461
+ this.$emit('on-input',evaluatedVal)
462
+ }catch(err){
463
+ }
461
464
  },
462
465
  onInputBlur(e) {
463
466
  this.isFocused = false
@@ -534,8 +537,8 @@ export default {
534
537
  },
535
538
  interact(e) {
536
539
  e.preventDefault()
537
- let value=parseInt(this.value || 0)
538
-
540
+ let value=parseFloat(this.value || 0)
541
+ console.log("value",value)
539
542
  value+=parseFloat(this.interactionStep)*parseInt(e.movementX)
540
543
  this.$emit('on-input',value)
541
544
 
@@ -1,11 +1,18 @@
1
1
  <template>
2
- <Container :selectWidth="selectWidth" v-click-outside="closeDropdown">
2
+ <Container
3
+ :selectWidth="selectWidth"
4
+ v-click-outside="closeDropdown"
5
+ @mouseenter="mouseEnterHandler"
6
+ @mouseleave="mouseLeaveHandler"
7
+ >
3
8
  <input-wrapper
4
9
  :hasLabel="!!label && label.length > 0"
5
10
  :alignItems="alignItems"
6
11
  >
7
- <label-wrapper v-if="label">
8
- <input-label :fontSize="fontSize">{{ label }}</input-label>
12
+ <label-wrapper v-if="label" >
13
+ <input-label
14
+ :fontColor="labelFontColor || colorMode=='dark'?'white':'eturnityGrey'"
15
+ :fontSize="fontSize">{{ label }}</input-label>
9
16
  <info-text
10
17
  v-if="infoTextMessage"
11
18
  :text="infoTextMessage"
@@ -15,16 +22,25 @@
15
22
  />
16
23
  </label-wrapper>
17
24
  <div>
18
- <selectButton @click="toggleDropdown" @mouseenter="mouseEnterHandler">
25
+ <selectButton
26
+ @click="toggleDropdown"
27
+ :isActive="isActive"
28
+ :bgColor="buttonBgColor || colorMode=='dark'?'transparentBlack1':'white'"
29
+ :fontColor="buttonFontColor || colorMode=='dark'?'white':'black'"
30
+
31
+ >
19
32
  <slot name="selector" :selectedValue="selectedValue"></slot>
20
33
  <Caret :isUp="isDropdownOpen">
21
- <icon name="arrow_up" size="12px"/>
34
+ <icon name="arrow_up" size="12px" :color="caretColor || colorMode=='dark'?'white':'transparentBlack1'"/>
22
35
  </Caret>
23
36
  </selectButton>
24
37
  <DropdownWrapper>
25
38
  <selectDropdown
26
39
  v-if="isDropdownOpen"
40
+ :isActive="isActive"
27
41
  :optionWidth="optionWidth"
42
+ :bgColor="dropdownBgColor || colorMode=='dark'?'black':'white'"
43
+ :fontColor="dropdownFontColor || colorMode=='dark'?'white':'black'"
28
44
  @option-selected="optionSelected">
29
45
  <slot name="dropdown"></slot>
30
46
  </selectDropdown>
@@ -56,7 +72,8 @@
56
72
 
57
73
  import styled from 'vue-styled-components'
58
74
  import InfoText from '../../infoText'
59
- import icon from '@/components/icon'
75
+ import icon from '../../icon'
76
+
60
77
  const caretAttrs={isUp:Boolean}
61
78
  const Caret=styled('div', caretAttrs)`
62
79
  position:absolute;
@@ -64,14 +81,14 @@
64
81
  align-items:center;
65
82
  height:100%;
66
83
  right:15px;
67
- top:2px
84
+ top:-2px
68
85
  transform: ${props=>!props.isUp?"rotate(180deg)":""};
69
- transform-origin: 6px 17px;
86
+ transform-origin: center;
70
87
  `
71
88
 
72
89
  const labelAttrs = { fontSize: String }
73
90
  const InputLabel = styled('div', labelAttrs)`
74
- color: ${(props) => props.theme.colors.eturnityGrey};
91
+ color:${(props) => props.theme.colors[props.fontColor]?props.theme.colors[props.fontColor]:props.fontColor};
75
92
  font-size: ${(props) => (props.fontSize ? props.fontSize : '13px')};
76
93
  font-weight: 700;
77
94
  `
@@ -88,8 +105,8 @@ const LabelWrapper = styled.div`
88
105
  align-items: center;
89
106
  justify-content: start;
90
107
  `
91
-
92
- const selectButton = styled('div')`
108
+ const selectButtonAttrs={bgColor:String,fontColor:String,isActive:Boolean}
109
+ const selectButton = styled('div',selectButtonAttrs)`
93
110
  position:relative;
94
111
  box-sizing: border-box;
95
112
  border:1px solid red;
@@ -101,24 +118,29 @@ const LabelWrapper = styled.div`
101
118
  display: flex;
102
119
  align-items: center;
103
120
  border:1px solid ${(props)=>props.theme.colors.grey4}
104
-
105
- `
106
- const selectDropdown = styled('div',inputProps)`
121
+ background-color:${(props) => props.theme.colors[props.bgColor]?props.theme.colors[props.bgColor]:props.bgColor};
122
+ color:${(props) => props.theme.colors[props.fontColor]?props.theme.colors[props.fontColor]:props.fontColor};
123
+ `
124
+ const selectDropdownAttrs={bgColor:String,fontColor:String,selectWidth: String, optionWidth: String}
125
+ const selectDropdown = styled('div',selectDropdownAttrs)`
107
126
  box-sizing: border-box;
108
- z-index: 1;
109
- position:absolute
127
+ z-index:${props=>props.isActive?'2':'1'};
128
+ position:absolute;
110
129
  top:5px;
111
130
  padding:10px;
112
131
  border:1px solid ${(props)=>props.theme.colors.grey4}
113
132
  border-radius:4px;
114
- background-color:white;
115
133
  display: flex;
116
134
  flex-direction: column;
117
135
  align-items: flex-start;
118
136
  padding: 0px;
119
137
  box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
120
138
  width: ${(props) => (props.optionWidth ? props.optionWidth : '100%')};
121
- `
139
+ background-color:${(props) => props.theme.colors[props.bgColor]?props.theme.colors[props.bgColor]:props.bgColor};
140
+ color:${(props) => props.theme.colors[props.fontColor]?props.theme.colors[props.fontColor]:props.fontColor};
141
+ max-height:300px;
142
+ overflow-y:scroll;
143
+ `
122
144
  const DropdownWrapper=styled('div')`
123
145
  position:relative;
124
146
  `
@@ -167,6 +189,28 @@ const InputWrapper = styled('div', inputAttrs)`
167
189
  alignItems:{
168
190
  required: false,
169
191
  default: 'horizontal'
192
+ },
193
+ buttonBgColor:{
194
+ required: false,
195
+ },
196
+ buttonFontColor:{
197
+ required: false,
198
+ },
199
+ dropdownBgColor:{
200
+ required: false,
201
+ },
202
+ dropdownFontColor:{
203
+ required: false,
204
+ },
205
+ caretColor:{
206
+ required:false,
207
+ },
208
+ labelFontColor:{
209
+ required:false
210
+ },
211
+ colorMode:{
212
+ required:false,
213
+ default:'light'
170
214
  }
171
215
  },
172
216
 
@@ -186,29 +230,43 @@ const InputWrapper = styled('div', inputAttrs)`
186
230
  data() {
187
231
  return {
188
232
  selectedValue: null,
189
- isDropdownOpen:false
233
+ isDropdownOpen:false,
234
+ isActive:false,
190
235
  }
191
236
  },
192
237
  created(){
193
238
  this.selectedValue=this.value
194
239
  },
195
240
  methods:{
241
+ focus(){
242
+ this.isActive=true
243
+ },
244
+ blur(){
245
+ this.isActive=false
246
+ },
196
247
  toggleDropdown(){
248
+ this.focus()
197
249
  this.isDropdownOpen=!this.isDropdownOpen
198
250
  },
199
251
  closeDropdown(){
252
+ this.blur()
200
253
  this.isDropdownOpen=false
201
254
  },
202
255
  optionSelected(e){
203
256
  this.selectedValue=e
204
257
  this.closeDropdown()
258
+ this.blur()
205
259
  this.$emit('input-change',e)
206
260
  },
207
261
  mouseEnterHandler(){
262
+ this.focus()
208
263
  if(this.hoverDropdown){
209
264
  this.isDropdownOpen=true
210
265
  }
211
266
  },
267
+ mouseLeaveHandler(){
268
+ this.blur()
269
+ },
212
270
  },
213
271
  computed: {
214
272
  }
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <optionContainer @click="clickHandler">
2
+ <optionContainer :hoveredBgColor="hoveredBgColor || colorMode=='dark'?'#000000':'grey5'" @click="clickHandler">
3
3
  <slot></slot>
4
4
  </optionContainer>
5
5
  </template>
@@ -8,20 +8,19 @@
8
8
  // import selectButton from './selectButton'
9
9
  // import selectDropdown from './selectDropDown'
10
10
  import styled from 'vue-styled-components'
11
-
12
- const optionContainer = styled('div')`
11
+ const optionProps={hoveredBgColor:String}
12
+ const optionContainer = styled('div',optionProps)`
13
13
  display:flex;
14
- height:40px;
15
14
  cursor: pointer;
16
15
  flex-direction: row;
17
16
  justify-content: space-between;
18
17
  align-items: center;
19
- padding: 0px 15px;
18
+ padding: 12px 15px;
20
19
  gap: 14px;
21
20
  width:100%;
22
21
  box-sizing:inherit;
23
22
  &:hover{
24
- background-color:${(props)=>props.theme.colors.grey5};
23
+ background-color:${(props) => props.theme.colors[props.hoveredBgColor]?props.theme.colors[props.hoveredBgColor]:props.hoveredBgColor};
25
24
  }
26
25
  `
27
26
 
@@ -32,6 +31,13 @@
32
31
  value: {
33
32
  required: true
34
33
  },
34
+ hoveredBgColor:{
35
+ required:false,
36
+ },
37
+ colorMode:{
38
+ required:false,
39
+ default:'light'
40
+ }
35
41
  },
36
42
 
37
43
  components: {optionContainer},
@@ -41,9 +47,6 @@
41
47
  },
42
48
  methods:{
43
49
  clickHandler(){
44
- console.log('click from option component')
45
- console.log(this.$parent)
46
- console.log(this.$parent.$parent)
47
50
  this.$parent.$emit('option-selected',this.value)
48
51
  }
49
52
  },
@@ -0,0 +1,239 @@
1
+ <template>
2
+ <container>
3
+ <flex-wrapper :size="size" :disabled="disabled" :alignItems="alignItems" :label="label">
4
+ <label-container
5
+ v-if="label && labelAlign === 'left'"
6
+ :hasInfoMessage="!!infoTextMessage"
7
+ :colorMode="colorMode"
8
+ >
9
+ <label-text :size="size">{{ label }}</label-text>
10
+ <info-text
11
+ v-if="infoTextMessage"
12
+ :text="infoTextMessage"
13
+ borderColor="#ccc"
14
+ size="14px"
15
+ :alignText="infoTextAlign"
16
+ />
17
+ </label-container>
18
+
19
+ <switch-wrapper
20
+ :size="size"
21
+ :disabled="disabled"
22
+ :backgroundColor="backgroundColor"
23
+ >
24
+ <switchOption
25
+ v-for="(item,index) in options"
26
+ :key="index"
27
+ @click="selectItem(item.value)"
28
+ :isActive="selectedValue==item.value"
29
+ :colorMode="colorMode"
30
+ :primaryColor="primaryColor"
31
+ :secondaryColor="secondaryColor"
32
+ :inactiveColor="inactiveColor"
33
+ >
34
+ {{ item.content }}
35
+ </switchOption>
36
+ </switch-wrapper>
37
+ <label-container
38
+ v-if="label && labelAlign === 'right'"
39
+ :hasInfoMessage="!!infoTextMessage"
40
+ >
41
+ <label-text :size="size" :fontColor="fontColor">{{ label }}</label-text>
42
+ <info-text
43
+ @click.native.stop
44
+ v-if="infoTextMessage"
45
+ :text="infoTextMessage"
46
+ borderColor="#ccc"
47
+ size="14px"
48
+ :alignText="infoTextAlign"
49
+ />
50
+ </label-container>
51
+ </flex-wrapper>
52
+ </container>
53
+ </template>
54
+
55
+ <script>
56
+ // import Toggle from "@eturnity/eturnity_reusable_components/src/components/inputs/toggle"
57
+ // To use:
58
+ // <SwitchField
59
+ // @on-switch-change="onInputChange($event)"
60
+ // :options="[{value:0,content:'zero'},{value:1,content:'one'},{value:2,content:'two'}]"
61
+ // :value="1"
62
+ // label="label"
63
+ // toggleColor="red"
64
+ // size="large"
65
+ // backgroundColor="blue"
66
+ // labelAlign="left"
67
+ // fontColor="black"
68
+ // :disabled="false"
69
+ // />
70
+
71
+ import styled from "vue-styled-components"
72
+ import InfoText from "../../infoText"
73
+ import theme from "../../../assets/theme"
74
+ const Container = styled.div`
75
+ display: inline-block;
76
+ `
77
+
78
+ const flexAttrs = { label:String,size: String, disabled: Boolean,alignItems: String }
79
+ const FlexWrapper = styled("div", flexAttrs)`
80
+ display: grid;
81
+ grid-template-columns: auto 1fr;
82
+ grid-gap: 10px;
83
+ align-items: center;
84
+ cursor: ${(props) => (props.disabled ? "not-allowed" : "pointer")};
85
+ grid-template-columns: ${(props) =>
86
+ props.alignItems === 'vertical' || !props.label ? '1fr' : 'auto 1fr'};
87
+ `
88
+
89
+ const toggleAttrs = {
90
+ size: String,
91
+ fontColor: String,
92
+ disabled: Boolean,
93
+ backgroundColor: String,
94
+ isChecked: Boolean,
95
+ }
96
+ const LabelText = styled("div", toggleAttrs)`
97
+ color: white;
98
+ font-size: 13px;
99
+ font-family: 'Lato-Bold',Arial;
100
+ `
101
+
102
+ const SwitchWrapper = styled("span", toggleAttrs)`
103
+ display: flex;
104
+ position: relative;
105
+ cursor: ${(props) => (props.disabled ? "not-allowed" : "pointer")};
106
+ height: ${(props) =>
107
+ props.size === "medium"
108
+ ? "24px"
109
+ : props.size === "small"
110
+ ? "16px"
111
+ : "24px"};
112
+ `
113
+ const optionAttrs={isActive:Boolean,primaryColor:String,secondaryColor:String,inactiveColor:String}
114
+ const switchOption=styled('div',optionAttrs)`
115
+ color:${props=>props.isActive?props.primaryColor:props.inactiveColor};
116
+ background-color:${props=>props.isActive?props.secondaryColor:"transparent"};
117
+ border:1px solid ${props=>props.isActive?props.secondaryColor:props.inactiveColor};
118
+ display:flex;
119
+ align-items:center;
120
+ font-size: 14px;
121
+ line-height: 1;
122
+ text-align: center;
123
+ padding: 10px;
124
+ margin-right: -1px;
125
+ transition: all 0.1s ease-in-out;
126
+ overflow:hidden;
127
+ & :hover{
128
+ cursor: pointer;
129
+ }
130
+ &:first-child {
131
+ border-radius: 4px 0 0 4px;
132
+ }
133
+ &:last-child {
134
+ border-radius: 0 4px 4px 0;
135
+ }
136
+
137
+ `
138
+
139
+ const labelAttrs = { hasInfoMessage: Boolean }
140
+ const LabelContainer = styled("div", labelAttrs)`
141
+ display: inline-grid;
142
+ grid-template-columns: ${(props) =>
143
+ props.hasInfoMessage ? "auto 1fr" : "auto"};
144
+ grid-gap: 12px;
145
+ align-items: center;
146
+ `
147
+
148
+ export default {
149
+ name: "switchField",
150
+ components: {
151
+ Container,
152
+ SwitchWrapper,
153
+ FlexWrapper,
154
+ LabelText,
155
+ InfoText,
156
+ LabelContainer,
157
+ switchOption,
158
+ },
159
+ props: {
160
+ label: {
161
+ required: false,
162
+ default: "",
163
+ },
164
+ toggleColor: {
165
+ required: false,
166
+ },
167
+ backgroundColor: {
168
+ required: false,
169
+ },
170
+ size: {
171
+ required: false,
172
+ default: "small",
173
+ },
174
+ labelAlign: {
175
+ required: false,
176
+ default: "left",
177
+ },
178
+ fontColor: {
179
+ required: false,
180
+ },
181
+ disabled: {
182
+ required: false,
183
+ default: false,
184
+ },
185
+ infoTextMessage: {
186
+ required: false,
187
+ },
188
+ infoTextAlign: {
189
+ required: false,
190
+ },
191
+ colorMode: {
192
+ required: false,
193
+ default:'light'
194
+ },
195
+ alignItems:{
196
+ required: false,
197
+ default: 'horizontal'
198
+ },
199
+ options:{
200
+ required:true
201
+ },
202
+ value:{
203
+ required:false,
204
+ default:null
205
+ },
206
+ },
207
+ data() {
208
+ return {
209
+ selectedValue:null,
210
+ primaryColor:"white",
211
+ secondaryColor:"black",
212
+ inactiveColor:"grey6"
213
+ }
214
+ },
215
+ created(){
216
+ this.selectedValue=this.value
217
+
218
+ if(this.colorMode=='dark'){
219
+ this.primaryColor=theme.colors.black
220
+ this.secondaryColor=theme.colors.white
221
+ this.inactiveColor=theme.colors.grey6
222
+ }else{
223
+ this.primaryColor=theme.colors.white
224
+ this.secondaryColor=theme.colors.black
225
+ this.inactiveColor=theme.colors.grey6
226
+ }
227
+ },
228
+ methods: {
229
+ selectItem(value){
230
+ if (this.disabled) {
231
+ return
232
+ }
233
+ this.selectedValue=value
234
+ this.$emit("on-switch-change", this.selectedValue)
235
+ },
236
+ },
237
+ }
238
+ </script>
239
+