@eturnity/eturnity_reusable_components 1.2.33 → 1.2.34-3d-master.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 +1 -1
- package/src/App.vue +96 -205
- package/src/assets/svgIcons/areas_tool.svg +14 -0
- package/src/assets/svgIcons/base_layer.svg +3 -0
- package/src/assets/svgIcons/bug.svg +6 -0
- package/src/assets/svgIcons/direction_arrow.svg +4 -0
- package/src/assets/svgIcons/distance_tool.svg +8 -0
- package/src/assets/svgIcons/distort_tool.svg +10 -0
- package/src/assets/svgIcons/distort_tool2.svg +16 -0
- package/src/assets/svgIcons/draggable_corner.svg +5 -0
- package/src/assets/svgIcons/draw_tool.svg +3 -0
- package/src/assets/svgIcons/flatten.svg +12 -0
- package/src/assets/svgIcons/layers_close.svg +4 -0
- package/src/assets/svgIcons/layers_open.svg +4 -0
- package/src/assets/svgIcons/magic_tool.svg +6 -0
- package/src/assets/svgIcons/map_icon.svg +4 -2
- package/src/assets/svgIcons/map_settings.svg +3 -0
- package/src/assets/svgIcons/margin_tool.svg +4 -0
- package/src/assets/svgIcons/obstacle_tool.svg +7 -11
- package/src/assets/svgIcons/obstacle_tool_origin.svg +3 -0
- package/src/assets/svgIcons/opacity.svg +1 -0
- package/src/assets/svgIcons/outline_tool.svg +11 -0
- package/src/assets/svgIcons/redo.svg +6 -0
- package/src/assets/svgIcons/resizer.svg +5 -0
- package/src/assets/svgIcons/roof_layer.svg +3 -0
- package/src/assets/svgIcons/rotate_tool.svg +3 -0
- package/src/assets/svgIcons/ruler_tool.svg +3 -0
- package/src/assets/svgIcons/trim_tool.svg +4 -0
- package/src/assets/svgIcons/undo.svg +6 -0
- package/src/assets/svgIcons/vertical_tool.svg +3 -0
- package/src/assets/theme.js +2 -0
- package/src/components/icon/index.vue +11 -10
- package/src/components/iconWrapper/index.vue +116 -0
- package/src/components/inputs/inputNumber/index.vue +113 -15
- package/src/components/inputs/inputText/index.vue +42 -8
- package/src/components/inputs/select/index.vue +280 -0
- package/src/components/inputs/select/option/index.vue +57 -0
- package/src/components/inputs/select/select.stories.js +59 -0
- package/src/components/inputs/switchField/index.vue +244 -0
- package/src/components/modals/modal/index.vue +9 -4
- package/src/helpers/numberConverter.js +1 -0
@@ -0,0 +1,280 @@
|
|
1
|
+
<template>
|
2
|
+
<Container
|
3
|
+
:selectWidth="selectWidth"
|
4
|
+
v-click-outside="closeDropdown"
|
5
|
+
@mouseenter="mouseEnterHandler"
|
6
|
+
@mouseleave="mouseLeaveHandler"
|
7
|
+
>
|
8
|
+
<input-wrapper
|
9
|
+
:hasLabel="!!label && label.length > 0"
|
10
|
+
:alignItems="alignItems"
|
11
|
+
>
|
12
|
+
<label-wrapper v-if="label" >
|
13
|
+
<input-label
|
14
|
+
:fontColor="labelFontColor || colorMode=='dark'?'white':'eturnityGrey'"
|
15
|
+
:fontSize="fontSize">{{ label }}</input-label>
|
16
|
+
<info-text
|
17
|
+
v-if="infoTextMessage"
|
18
|
+
:text="infoTextMessage"
|
19
|
+
borderColor="#ccc"
|
20
|
+
:size="fontSize ? fontSize : '16px'"
|
21
|
+
:alignText="infoTextAlign"
|
22
|
+
/>
|
23
|
+
</label-wrapper>
|
24
|
+
<div>
|
25
|
+
<selectButton
|
26
|
+
@click="toggleDropdown"
|
27
|
+
:isActive="isActive"
|
28
|
+
:bgColor="buttonBgColor || colorMode=='dark'?'transparentBlack1':'white'"
|
29
|
+
:fontColor="buttonFontColor || colorMode=='dark'?'white':'black'"
|
30
|
+
|
31
|
+
>
|
32
|
+
<slot name="selector" :selectedValue="selectedValue"></slot>
|
33
|
+
<Caret :isUp="isDropdownOpen">
|
34
|
+
<icon name="arrow_up" size="12px" :color="caretColor || colorMode=='dark'?'white':'transparentBlack1'"/>
|
35
|
+
</Caret>
|
36
|
+
</selectButton>
|
37
|
+
<DropdownWrapper>
|
38
|
+
<selectDropdown
|
39
|
+
v-if="isDropdownOpen"
|
40
|
+
:isActive="isActive"
|
41
|
+
:optionWidth="optionWidth"
|
42
|
+
:bgColor="dropdownBgColor || colorMode=='dark'?'black':'white'"
|
43
|
+
:fontColor="dropdownFontColor || colorMode=='dark'?'white':'black'"
|
44
|
+
@option-selected="optionSelected">
|
45
|
+
<slot name="dropdown"></slot>
|
46
|
+
</selectDropdown>
|
47
|
+
</DropdownWrapper>
|
48
|
+
</div>
|
49
|
+
</input-wrapper>
|
50
|
+
</Container>
|
51
|
+
</template>
|
52
|
+
|
53
|
+
<script>
|
54
|
+
//How to use it
|
55
|
+
// <Select
|
56
|
+
// hoverDropdown="true"
|
57
|
+
// selectWidth="100%"
|
58
|
+
// optionWidth="50%"
|
59
|
+
// label="that is a label"
|
60
|
+
// alignItems="vertical"
|
61
|
+
// >
|
62
|
+
// <template #selector="{selectedValue}">
|
63
|
+
// value selected: {{selectedValue}}
|
64
|
+
// </template>
|
65
|
+
// <template #dropdown>
|
66
|
+
// <Option value="1">value one</Option>
|
67
|
+
// <Option value="2">value two</Option>
|
68
|
+
// <Option value="3">value three</Option>
|
69
|
+
// <Option value="4">value four</Option>
|
70
|
+
// </template>
|
71
|
+
// </Select>
|
72
|
+
|
73
|
+
import styled from 'vue-styled-components'
|
74
|
+
import InfoText from '../../infoText'
|
75
|
+
import icon from '../../icon'
|
76
|
+
|
77
|
+
const caretAttrs={isUp:Boolean}
|
78
|
+
const Caret=styled('div', caretAttrs)`
|
79
|
+
position:absolute;
|
80
|
+
display:flex;
|
81
|
+
align-items:center;
|
82
|
+
height:100%;
|
83
|
+
right:15px;
|
84
|
+
top:-2px
|
85
|
+
transform: ${props=>!props.isUp?"rotate(180deg)":""};
|
86
|
+
transform-origin: center;
|
87
|
+
`
|
88
|
+
|
89
|
+
const labelAttrs = { fontSize: String }
|
90
|
+
const InputLabel = styled('div', labelAttrs)`
|
91
|
+
color:${(props) => props.theme.colors[props.fontColor]?props.theme.colors[props.fontColor]:props.fontColor};
|
92
|
+
font-size: ${(props) => (props.fontSize ? props.fontSize : '13px')};
|
93
|
+
font-weight: 700;
|
94
|
+
`
|
95
|
+
const inputProps={selectWidth: String, optionWidth: String}
|
96
|
+
const Container = styled('div', inputProps)`
|
97
|
+
width: ${(props) => (props.selectWidth ? props.selectWidth : '100%')};
|
98
|
+
position: relative;
|
99
|
+
display: inline-block;
|
100
|
+
`
|
101
|
+
const LabelWrapper = styled.div`
|
102
|
+
display: inline-grid;
|
103
|
+
grid-template-columns: auto auto;
|
104
|
+
grid-gap: 12px;
|
105
|
+
align-items: center;
|
106
|
+
justify-content: start;
|
107
|
+
`
|
108
|
+
const selectButtonAttrs={bgColor:String,fontColor:String,isActive:Boolean}
|
109
|
+
const selectButton = styled('div',selectButtonAttrs)`
|
110
|
+
position:relative;
|
111
|
+
box-sizing: border-box;
|
112
|
+
border:1px solid red;
|
113
|
+
border-radius:4px;
|
114
|
+
padding:10px 15px;
|
115
|
+
text-align:left;
|
116
|
+
border-radius:4px;
|
117
|
+
min-height:36px;
|
118
|
+
display: flex;
|
119
|
+
align-items: center;
|
120
|
+
border:1px solid ${(props)=>props.theme.colors.grey4}
|
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)`
|
126
|
+
box-sizing: border-box;
|
127
|
+
z-index:${props=>props.isActive?'2':'1'};
|
128
|
+
position:absolute;
|
129
|
+
top:5px;
|
130
|
+
padding:10px;
|
131
|
+
border:1px solid ${(props)=>props.theme.colors.grey4}
|
132
|
+
border-radius:4px;
|
133
|
+
display: flex;
|
134
|
+
flex-direction: column;
|
135
|
+
align-items: flex-start;
|
136
|
+
padding: 0px;
|
137
|
+
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
|
138
|
+
width: ${(props) => (props.optionWidth ? props.optionWidth : '100%')};
|
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
|
+
`
|
144
|
+
const DropdownWrapper=styled('div')`
|
145
|
+
position:relative;
|
146
|
+
`
|
147
|
+
const inputAttrs = { alignItems: String, hasLabel: Boolean }
|
148
|
+
const InputWrapper = styled('div', inputAttrs)`
|
149
|
+
position: relative;
|
150
|
+
display: grid;
|
151
|
+
align-items: center;
|
152
|
+
gap: 8px;
|
153
|
+
grid-template-columns: ${(props) =>
|
154
|
+
props.alignItems === 'vertical' || !props.hasLabel ? '1fr' : 'auto 1fr'};
|
155
|
+
`
|
156
|
+
export default {
|
157
|
+
name: 'RCselect',
|
158
|
+
|
159
|
+
props: {
|
160
|
+
value:{
|
161
|
+
required:false,
|
162
|
+
default: null
|
163
|
+
},
|
164
|
+
fontSize:{
|
165
|
+
required:false,
|
166
|
+
default: null
|
167
|
+
},
|
168
|
+
label:{
|
169
|
+
required:false
|
170
|
+
},
|
171
|
+
infoTextMessage:{
|
172
|
+
required:false
|
173
|
+
},
|
174
|
+
infoTextAlign:{
|
175
|
+
required:false
|
176
|
+
},
|
177
|
+
selectWidth: {
|
178
|
+
required: false,
|
179
|
+
default: null
|
180
|
+
},
|
181
|
+
optionWidth: {
|
182
|
+
required: false,
|
183
|
+
default: null
|
184
|
+
},
|
185
|
+
hoverDropdown: {
|
186
|
+
required: false,
|
187
|
+
default: false
|
188
|
+
},
|
189
|
+
alignItems:{
|
190
|
+
required: false,
|
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'
|
214
|
+
}
|
215
|
+
},
|
216
|
+
|
217
|
+
components: {
|
218
|
+
selectButton,
|
219
|
+
selectDropdown,
|
220
|
+
Container,
|
221
|
+
InputLabel,
|
222
|
+
LabelWrapper,
|
223
|
+
InfoText,
|
224
|
+
InputWrapper,
|
225
|
+
DropdownWrapper,
|
226
|
+
icon,
|
227
|
+
Caret
|
228
|
+
},
|
229
|
+
|
230
|
+
data() {
|
231
|
+
return {
|
232
|
+
selectedValue: null,
|
233
|
+
isDropdownOpen:false,
|
234
|
+
isActive:false,
|
235
|
+
}
|
236
|
+
},
|
237
|
+
created(){
|
238
|
+
this.selectedValue=this.value
|
239
|
+
},
|
240
|
+
methods:{
|
241
|
+
focus(){
|
242
|
+
this.isActive=true
|
243
|
+
},
|
244
|
+
blur(){
|
245
|
+
this.isActive=false
|
246
|
+
},
|
247
|
+
toggleDropdown(){
|
248
|
+
this.focus()
|
249
|
+
this.isDropdownOpen=!this.isDropdownOpen
|
250
|
+
},
|
251
|
+
closeDropdown(){
|
252
|
+
this.blur()
|
253
|
+
this.isDropdownOpen=false
|
254
|
+
},
|
255
|
+
optionSelected(e){
|
256
|
+
this.selectedValue=e
|
257
|
+
this.closeDropdown()
|
258
|
+
this.blur()
|
259
|
+
this.$emit('input-change',e)
|
260
|
+
},
|
261
|
+
mouseEnterHandler(){
|
262
|
+
this.focus()
|
263
|
+
if(this.hoverDropdown){
|
264
|
+
this.isDropdownOpen=true
|
265
|
+
}
|
266
|
+
},
|
267
|
+
mouseLeaveHandler(){
|
268
|
+
this.blur()
|
269
|
+
},
|
270
|
+
},
|
271
|
+
computed: {
|
272
|
+
},
|
273
|
+
watch:{
|
274
|
+
value(val){
|
275
|
+
this.selectedValue=val
|
276
|
+
}
|
277
|
+
}
|
278
|
+
}
|
279
|
+
</script>
|
280
|
+
|
@@ -0,0 +1,57 @@
|
|
1
|
+
<template>
|
2
|
+
<optionContainer :hoveredBgColor="hoveredBgColor || colorMode=='dark'?'#000000':'grey5'" @click="clickHandler">
|
3
|
+
<slot></slot>
|
4
|
+
</optionContainer>
|
5
|
+
</template>
|
6
|
+
|
7
|
+
<script>
|
8
|
+
// import selectButton from './selectButton'
|
9
|
+
// import selectDropdown from './selectDropDown'
|
10
|
+
import styled from 'vue-styled-components'
|
11
|
+
const optionProps={hoveredBgColor:String}
|
12
|
+
const optionContainer = styled('div',optionProps)`
|
13
|
+
display:flex;
|
14
|
+
cursor: pointer;
|
15
|
+
flex-direction: row;
|
16
|
+
justify-content: space-between;
|
17
|
+
align-items: center;
|
18
|
+
padding: 12px 15px;
|
19
|
+
gap: 14px;
|
20
|
+
width:100%;
|
21
|
+
box-sizing:inherit;
|
22
|
+
&:hover{
|
23
|
+
background-color:${(props) => props.theme.colors[props.hoveredBgColor]?props.theme.colors[props.hoveredBgColor]:props.hoveredBgColor};
|
24
|
+
}
|
25
|
+
`
|
26
|
+
|
27
|
+
export default {
|
28
|
+
name: 'RCoption',
|
29
|
+
|
30
|
+
props: {
|
31
|
+
value: {
|
32
|
+
required: true
|
33
|
+
},
|
34
|
+
hoveredBgColor:{
|
35
|
+
required:false,
|
36
|
+
},
|
37
|
+
colorMode:{
|
38
|
+
required:false,
|
39
|
+
default:'light'
|
40
|
+
}
|
41
|
+
},
|
42
|
+
|
43
|
+
components: {optionContainer},
|
44
|
+
|
45
|
+
data() {
|
46
|
+
return {}
|
47
|
+
},
|
48
|
+
methods:{
|
49
|
+
clickHandler(){
|
50
|
+
this.$parent.$emit('option-selected',this.value)
|
51
|
+
}
|
52
|
+
},
|
53
|
+
computed: {
|
54
|
+
}
|
55
|
+
}
|
56
|
+
</script>
|
57
|
+
|
@@ -0,0 +1,59 @@
|
|
1
|
+
import Select from "./index.vue"
|
2
|
+
import Option from "./option/index.vue"
|
3
|
+
|
4
|
+
export default {
|
5
|
+
title: "select",
|
6
|
+
component: Select,
|
7
|
+
// argTypes: {},
|
8
|
+
}
|
9
|
+
|
10
|
+
const Template = (args, { argTypes }) => ({
|
11
|
+
// Components used in your story `template` are defined in the `components` object
|
12
|
+
components: { Select,Option },
|
13
|
+
// The story's `args` need to be mapped into the template through the `setup()` method
|
14
|
+
props: Object.keys(argTypes),
|
15
|
+
template: `<Select v-bind="$props">
|
16
|
+
<template #selector="{selectedValue}">
|
17
|
+
value selected: {{selectedValue}}
|
18
|
+
</template>
|
19
|
+
<template #dropdown>
|
20
|
+
<Option value="1">value one</Option>
|
21
|
+
<Option value="2">value two</Option>
|
22
|
+
<Option value="3">value three</Option>
|
23
|
+
<Option value="4">value four</Option>
|
24
|
+
</template>
|
25
|
+
</Select>`,
|
26
|
+
|
27
|
+
// import Select from "@eturnity/eturnity_reusable_components/src/components/inputs/select"
|
28
|
+
// import Option from "@eturnity/eturnity_reusable_components/src/components/inputs/select/option"
|
29
|
+
// To use:
|
30
|
+
// How to use it
|
31
|
+
// <Select
|
32
|
+
// hoverDropdown="true"
|
33
|
+
// selectWidth="100%"
|
34
|
+
// optionWidth="50%"
|
35
|
+
// label="that is a label"
|
36
|
+
// alignItems="vertical"
|
37
|
+
// >
|
38
|
+
// <template #selector="{selectedValue}">
|
39
|
+
// value selected: {{selectedValue}}
|
40
|
+
// </template>
|
41
|
+
// <template #dropdown>
|
42
|
+
// <Option value="1">value one</Option>
|
43
|
+
// <Option value="2">value two</Option>
|
44
|
+
// <Option value="3">value three</Option>
|
45
|
+
// <Option value="4">value four</Option>
|
46
|
+
// </template>
|
47
|
+
// </Select>
|
48
|
+
})
|
49
|
+
|
50
|
+
export const Default = Template.bind({})
|
51
|
+
Default.args = {
|
52
|
+
hoverDropdown="true"
|
53
|
+
selectWidth="100%"
|
54
|
+
optionWidth="50%"
|
55
|
+
label="that is a label"
|
56
|
+
alignItems="vertical"
|
57
|
+
value="2"
|
58
|
+
}
|
59
|
+
|
@@ -0,0 +1,244 @@
|
|
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
|
+
watch:{
|
238
|
+
value(val){
|
239
|
+
this.selectedValue=val
|
240
|
+
}
|
241
|
+
}
|
242
|
+
}
|
243
|
+
</script>
|
244
|
+
|
@@ -1,5 +1,6 @@
|
|
1
1
|
<template>
|
2
2
|
<page-wrapper
|
3
|
+
:position="position"
|
3
4
|
:isOpen="isOpen"
|
4
5
|
:class="{ visible: isOpen, hidden: !isOpen }"
|
5
6
|
@click.native="onOutsideClose()"
|
@@ -36,9 +37,9 @@ const ContentContainer = styled('div', contentAttrs)`
|
|
36
37
|
visibility: ${(props) => (props.visible ? 'inherit' : 'hidden')};
|
37
38
|
`
|
38
39
|
|
39
|
-
const pageAttrs = { isOpen: Boolean, backdrop: String }
|
40
|
+
const pageAttrs = { isOpen: Boolean, backdrop: String,position:String }
|
40
41
|
const PageWrapper = styled('div', pageAttrs)`
|
41
|
-
position:
|
42
|
+
position: ${(props) => props.position}
|
42
43
|
display: grid;
|
43
44
|
top: 0;
|
44
45
|
left: 0;
|
@@ -76,7 +77,7 @@ const ModalContainer = styled.div`
|
|
76
77
|
border-radius: 4px;
|
77
78
|
background: white;
|
78
79
|
margin: 0 auto;
|
79
|
-
overflow:
|
80
|
+
overflow: initial;
|
80
81
|
max-width: 95%;
|
81
82
|
max-height: 95%;
|
82
83
|
min-width: 100px;
|
@@ -132,6 +133,10 @@ export default {
|
|
132
133
|
backdrop: {
|
133
134
|
required: false,
|
134
135
|
default: 'white'
|
136
|
+
},
|
137
|
+
position: {
|
138
|
+
required: false,
|
139
|
+
default: 'fixed'
|
135
140
|
}
|
136
141
|
},
|
137
142
|
methods: {
|
@@ -151,4 +156,4 @@ export default {
|
|
151
156
|
}
|
152
157
|
}
|
153
158
|
}
|
154
|
-
</script>
|
159
|
+
</script>
|
@@ -94,6 +94,7 @@ export const numberToString = ({ value, numberPrecision }) => {
|
|
94
94
|
? 'fr-fr'
|
95
95
|
: localStorage.getItem('lang')
|
96
96
|
: 'en-US'
|
97
|
+
if(selectedLang=="null"){selectedLang='en-US'}
|
97
98
|
value=parseFloat(value)
|
98
99
|
return value.toLocaleString(selectedLang, {
|
99
100
|
minimumFractionDigits: numberPrecision,
|