@eturnity/eturnity_reusable_components 1.2.34 → 1.2.36

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.
Files changed (42) hide show
  1. package/package.json +1 -1
  2. package/src/App.vue +105 -204
  3. package/src/assets/svgIcons/align_panel.svg +1 -0
  4. package/src/assets/svgIcons/areas_tool.svg +14 -0
  5. package/src/assets/svgIcons/base_layer.svg +3 -0
  6. package/src/assets/svgIcons/bug.svg +6 -0
  7. package/src/assets/svgIcons/direction_arrow.svg +4 -0
  8. package/src/assets/svgIcons/distance_tool.svg +8 -0
  9. package/src/assets/svgIcons/distort_tool.svg +10 -0
  10. package/src/assets/svgIcons/distort_tool2.svg +16 -0
  11. package/src/assets/svgIcons/draggable_corner.svg +5 -0
  12. package/src/assets/svgIcons/draw_tool.svg +3 -0
  13. package/src/assets/svgIcons/flatten.svg +12 -0
  14. package/src/assets/svgIcons/layers_close.svg +4 -0
  15. package/src/assets/svgIcons/layers_open.svg +4 -0
  16. package/src/assets/svgIcons/magic_tool.svg +6 -0
  17. package/src/assets/svgIcons/map_icon.svg +4 -2
  18. package/src/assets/svgIcons/map_settings.svg +3 -0
  19. package/src/assets/svgIcons/margin_tool.svg +4 -0
  20. package/src/assets/svgIcons/obstacle_tool.svg +7 -11
  21. package/src/assets/svgIcons/obstacle_tool_origin.svg +3 -0
  22. package/src/assets/svgIcons/opacity.svg +1 -0
  23. package/src/assets/svgIcons/outline_tool.svg +11 -0
  24. package/src/assets/svgIcons/redo.svg +6 -0
  25. package/src/assets/svgIcons/resizer.svg +5 -0
  26. package/src/assets/svgIcons/roof_layer.svg +3 -0
  27. package/src/assets/svgIcons/rotate_tool.svg +3 -0
  28. package/src/assets/svgIcons/ruler_tool.svg +3 -0
  29. package/src/assets/svgIcons/trim_tool.svg +4 -0
  30. package/src/assets/svgIcons/undo.svg +6 -0
  31. package/src/assets/svgIcons/vertical_tool.svg +3 -0
  32. package/src/assets/theme.js +2 -0
  33. package/src/components/icon/index.vue +13 -10
  34. package/src/components/iconWrapper/index.vue +116 -0
  35. package/src/components/inputs/inputNumber/index.vue +112 -15
  36. package/src/components/inputs/inputText/index.vue +49 -8
  37. package/src/components/inputs/select/index.vue +387 -0
  38. package/src/components/inputs/select/option/index.vue +60 -0
  39. package/src/components/inputs/select/select.stories.js +59 -0
  40. package/src/components/inputs/switchField/index.vue +244 -0
  41. package/src/components/modals/modal/index.vue +7 -2
  42. package/src/helpers/numberConverter.js +1 -0
@@ -0,0 +1,387 @@
1
+ <template>
2
+ <Container
3
+ :selectWidth="selectWidth"
4
+ @mouseenter="mouseEnterHandler"
5
+ @mouseleave="mouseLeaveHandler"
6
+ >
7
+ <input-wrapper
8
+ :hasLabel="!!label && label.length > 0"
9
+ :alignItems="alignItems"
10
+ >
11
+ <label-wrapper v-if="label" >
12
+ <input-label
13
+ :fontColor="labelFontColor || colorMode=='dark'?'white':'eturnityGrey'"
14
+ :fontSize="fontSize">{{ label }}</input-label>
15
+ <info-text
16
+ v-if="infoTextMessage"
17
+ :text="infoTextMessage"
18
+ borderColor="#ccc"
19
+ :size="fontSize ? fontSize : '16px'"
20
+ :alignText="infoTextAlign"
21
+ />
22
+ </label-wrapper>
23
+ <div>
24
+ <selectButton
25
+ ref="select"
26
+ @click="toggleDropdown"
27
+ :isActive="isActive"
28
+ :selectHeight="selectHeight"
29
+ :bgColor="buttonBgColor || colorMode=='dark'?'transparentBlack1':'white'"
30
+ :fontColor="buttonFontColor || colorMode=='dark'?'white':'black'"
31
+ @keydown.native="onKeyDown"
32
+ >
33
+ <inputText
34
+ v-if="isSearchBarVisible"
35
+ ref="searchInput"
36
+ tabindex="0"
37
+ :noBorder="true"
38
+ :inputHeight="selectHeight"
39
+ backgroundColor="transparent"
40
+ :fontColor="buttonFontColor || colorMode=='dark'?'white':'black'"
41
+ :value="textSearch"
42
+ @keydown.stop="onKeyDown"
43
+ @input-change="searchChange" />
44
+ <div v-else>
45
+ <slot name="selector" :selectedValue="selectedValue"></slot>
46
+ </div>
47
+ <Caret :isUp="isDropdownOpen" @click.stop="isSearchBarVisible ? closeDropdown() : toggleDropdown() " >
48
+ <icon name="arrow_up" size="12px" :color="caretColor || colorMode=='dark'?'white':'transparentBlack1'"/>
49
+ </Caret>
50
+ </selectButton>
51
+ <DropdownWrapper>
52
+ <selectDropdown
53
+ ref="dropdown"
54
+ v-show="isDropdownOpen"
55
+ :hoveredIndex="hoveredIndex"
56
+ :isActive="isActive"
57
+ :optionWidth="optionWidth"
58
+ :bgColor="dropdownBgColor || colorMode=='dark'?'black':'white'"
59
+ :fontColor="dropdownFontColor || colorMode=='dark'?'white':'black'"
60
+ :selectedValue="selectedValue"
61
+ @option-selected="optionSelected"
62
+ @option-hovered="optionHovered">
63
+ <slot name="dropdown"></slot>
64
+ </selectDropdown>
65
+ </DropdownWrapper>
66
+ </div>
67
+ </input-wrapper>
68
+ </Container>
69
+ </template>
70
+
71
+ <script>
72
+ //How to use it
73
+ // <Select
74
+ // hoverDropdown="true"
75
+ // selectWidth="100%"
76
+ // optionWidth="50%"
77
+ // label="that is a label"
78
+ // alignItems="vertical"
79
+ // >
80
+ // <template #selector="{selectedValue}">
81
+ // value selected: {{selectedValue}}
82
+ // </template>
83
+ // <template #dropdown>
84
+ // <Option value="1">value one</Option>
85
+ // <Option value="2">value two</Option>
86
+ // <Option value="3">value three</Option>
87
+ // <Option value="4">value four</Option>
88
+ // </template>
89
+ // </Select>
90
+
91
+ import styled from 'vue-styled-components'
92
+ import InfoText from '../../infoText'
93
+ import icon from '../../icon'
94
+ import inputText from '../inputText'
95
+
96
+ const caretAttrs={isUp:Boolean}
97
+ const Caret=styled('div', caretAttrs)`
98
+ position:absolute;
99
+ display:flex;
100
+ align-items:center;
101
+ height:100%;
102
+ right:15px;
103
+ top:-2px
104
+ transform: ${props=>!props.isUp?"rotate(180deg)":""};
105
+ transform-origin: center;
106
+ `
107
+
108
+ const labelAttrs = { fontSize: String }
109
+ const InputLabel = styled('div', labelAttrs)`
110
+ color:${(props) => props.theme.colors[props.fontColor]?props.theme.colors[props.fontColor]:props.fontColor};
111
+ font-size: ${(props) => (props.fontSize ? props.fontSize : '13px')};
112
+ font-weight: 700;
113
+ `
114
+ const inputProps={selectWidth: String, optionWidth: String}
115
+ const Container = styled('div', inputProps)`
116
+ width: ${(props) => (props.selectWidth ? props.selectWidth : '100%')};
117
+ position: relative;
118
+ display: inline-block;
119
+ `
120
+ const LabelWrapper = styled.div`
121
+ display: inline-grid;
122
+ grid-template-columns: auto auto;
123
+ grid-gap: 12px;
124
+ align-items: center;
125
+ justify-content: start;
126
+ `
127
+ const selectButtonAttrs={bgColor:String,fontColor:String,isActive:Boolean,selectHeight:String}
128
+ const selectButton = styled('div',selectButtonAttrs)`
129
+ position:relative;
130
+ box-sizing: border-box;
131
+ border:1px solid red;
132
+ border-radius:4px;
133
+ padding:0px 10px;
134
+ text-align:left;
135
+ border-radius:4px;
136
+ min-height:36px;
137
+ display: grid;
138
+ grid-template-columns:auto 40px;
139
+ align-items: center;
140
+ max-height:${props=>props.selectHeight};
141
+ border:1px solid ${(props)=>props.theme.colors.grey4}
142
+ background-color:${(props) => props.theme.colors[props.bgColor]?props.theme.colors[props.bgColor]:props.bgColor};
143
+ color:${(props) => props.theme.colors[props.fontColor]?props.theme.colors[props.fontColor]:props.fontColor};
144
+ `
145
+ const selectDropdownAttrs={bgColor:String,fontColor:String,selectWidth: String, optionWidth: String,hoveredIndex:Number,selectedValue:Number | String}
146
+ const selectDropdown = styled('div',selectDropdownAttrs)`
147
+ box-sizing: border-box;
148
+ z-index:${props=>props.isActive?'2':'1'};
149
+ position:absolute;
150
+ top:5px;
151
+ padding:10px;
152
+ border:1px solid ${(props)=>props.theme.colors.grey4}
153
+ border-radius:4px;
154
+ display: flex;
155
+ flex-direction: column;
156
+ align-items: flex-start;
157
+ padding: 0px;
158
+ box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
159
+ width: ${(props) => (props.optionWidth ? props.optionWidth : '100%')};
160
+ background-color:${(props) => props.theme.colors[props.bgColor]?props.theme.colors[props.bgColor]:props.bgColor};
161
+ color:${(props) => props.theme.colors[props.fontColor]?props.theme.colors[props.fontColor]:props.fontColor};
162
+ max-height:300px;
163
+ overflow-y:auto;
164
+ & [data-value="${props=>props.selectedValue}"]{
165
+ backdrop-filter: brightness(1.4);
166
+ }
167
+ &>div:nth-child(${props=>props.hoveredIndex}){
168
+ backdrop-filter: brightness(1.2);
169
+ }
170
+ `
171
+ const DropdownWrapper=styled('div')`
172
+ position:relative;
173
+ `
174
+ const inputAttrs = { alignItems: String, hasLabel: Boolean }
175
+ const InputWrapper = styled('div', inputAttrs)`
176
+ position: relative;
177
+ display: grid;
178
+ align-items: center;
179
+ gap: 8px;
180
+ grid-template-columns: ${(props) =>
181
+ props.alignItems === 'vertical' || !props.hasLabel ? '1fr' : 'auto 1fr'};
182
+ `
183
+ export default {
184
+ name: 'RCselect',
185
+
186
+ props: {
187
+ value:{
188
+ required:false,
189
+ default: null
190
+ },
191
+ fontSize:{
192
+ required:false,
193
+ default: null
194
+ },
195
+ label:{
196
+ required:false
197
+ },
198
+ infoTextMessage:{
199
+ required:false
200
+ },
201
+ infoTextAlign:{
202
+ required:false
203
+ },
204
+ selectWidth: {
205
+ required: false,
206
+ default: null
207
+ },
208
+ selectHeight: {
209
+ required: false,
210
+ default: null
211
+ },
212
+ optionWidth: {
213
+ required: false,
214
+ default: null
215
+ },
216
+ hoverDropdown: {
217
+ required: false,
218
+ default: false
219
+ },
220
+ alignItems:{
221
+ required: false,
222
+ default: 'horizontal'
223
+ },
224
+ buttonBgColor:{
225
+ required: false,
226
+ },
227
+ buttonFontColor:{
228
+ required: false,
229
+ },
230
+ dropdownBgColor:{
231
+ required: false,
232
+ },
233
+ dropdownFontColor:{
234
+ required: false,
235
+ },
236
+ caretColor:{
237
+ required:false,
238
+ },
239
+ labelFontColor:{
240
+ required:false
241
+ },
242
+ colorMode:{
243
+ required:false,
244
+ default:'light'
245
+ },
246
+ isSearchable:{
247
+ required:false,
248
+ default:true
249
+ },
250
+ isAutoSearch:{
251
+ required:false,
252
+ default:true
253
+ }
254
+ },
255
+
256
+ components: {
257
+ selectButton,
258
+ selectDropdown,
259
+ Container,
260
+ InputLabel,
261
+ LabelWrapper,
262
+ InfoText,
263
+ InputWrapper,
264
+ DropdownWrapper,
265
+ icon,
266
+ Caret,
267
+ inputText
268
+ },
269
+
270
+ data() {
271
+ return {
272
+ selectedValue: null,
273
+ isDropdownOpen:false,
274
+ isActive:false,
275
+ textSearch:"",
276
+ hoveredIndex:0,
277
+ }
278
+ },
279
+ mounted(){
280
+ this.selectedValue=this.value
281
+ },
282
+ methods:{
283
+ focus(){
284
+ this.isActive=true
285
+ },
286
+ blur(){
287
+ this.isActive=false
288
+ },
289
+ toggleDropdown(e){
290
+ if(this.isSearchBarVisible){return}
291
+ this.isDropdownOpen=!this.isDropdownOpen
292
+ if (this.isDropdownOpen) {
293
+ setTimeout(()=>document.addEventListener('click', this.clickOutside),10)
294
+ } else {
295
+ document.removeEventListener('click', this.clickOutside)
296
+ }
297
+
298
+ },
299
+ openDropdown(){
300
+ this.focus()
301
+ this.isDropdownOpen=true
302
+ setTimeout(()=>document.addEventListener('click', this.clickOutside),10)
303
+ },
304
+ closeDropdown(){
305
+ this.blur()
306
+ this.isDropdownOpen=false
307
+ document.removeEventListener('click', this.clickOutside)
308
+ },
309
+ optionSelected(e){
310
+ this.selectedValue=e
311
+ this.closeDropdown()
312
+ this.blur()
313
+ this.$emit('input-change',e)
314
+ },
315
+ optionHovered(e){
316
+ const optionElement=this.$el.querySelector(`[data-value="${e}"]`)
317
+ if(this.$refs.dropdown){
318
+ this.hoveredIndex=this.$refs.dropdown.$children.map(component=>component.$el).indexOf(optionElement)+1
319
+ }
320
+ },
321
+ mouseEnterHandler(){
322
+ if(this.hoverDropdown){
323
+ this.focus()
324
+ this.isDropdownOpen=true
325
+ }
326
+ },
327
+ mouseLeaveHandler(){
328
+ if(this.hoverDropdown){
329
+ this.blur()
330
+ }
331
+ },
332
+ searchChange(value){
333
+ this.textSearch=value
334
+ this.$emit('search-change',value)
335
+ this.$refs.dropdown.$children.map(component=>component.$el).forEach((el=>{
336
+ if(!el.textContent.toLowerCase().includes(value.toLowerCase())){el.style.display='none'}else{el.style.display='inherit'}
337
+ }))
338
+ },
339
+ clickOutside(event) {
340
+ if (this.$el==event.target || this.$el.contains(event.target)) {
341
+ return
342
+ }
343
+ this.closeDropdown()
344
+ },
345
+ onKeyDown(e){
346
+ if(e.key=='ArrowDown'){
347
+ this.onArrowPress(1)
348
+ } else if(e.key=='ArrowUp'){
349
+ this.onArrowPress(-1)
350
+ } else if(e.key=='Enter'){
351
+ const optionHoveredComponent=this.$refs.dropdown.$children[(this.hoveredIndex-1+this.optionLength)%this.optionLength]
352
+ this.optionSelected(optionHoveredComponent.$el.dataset.value)
353
+ }
354
+
355
+ },
356
+ onArrowPress(dir){
357
+ this.hoveredIndex=((this.hoveredIndex+dir+this.optionLength-1)%this.optionLength)+1
358
+ const optionHoveredComponent=this.$refs.dropdown.$children[(this.hoveredIndex-1+this.optionLength)%this.optionLength]
359
+ const topPos = optionHoveredComponent.$el.offsetTop;
360
+ this.$refs.dropdown.$el.scrollTop = topPos;
361
+ }
362
+ },
363
+ computed: {
364
+ optionLength(){
365
+ if(this.isDropdownOpen){
366
+ return this.$refs.dropdown.$children.length
367
+ }else{
368
+ return 0
369
+ }
370
+ },
371
+ isSearchBarVisible(){
372
+ return this.isSearchable && this.optionLength>=5 && this.isDropdownOpen
373
+ }
374
+ },
375
+ watch:{
376
+ value(val){
377
+ this.selectedValue=val
378
+ },
379
+ isDropdownOpen(val){
380
+ if(val && this.isSearchable){
381
+ this.$nextTick(()=>{if(this.$refs.searchInput){this.$refs.searchInput.$el.querySelector('input').focus()}})
382
+ }
383
+ }
384
+ }
385
+ }
386
+ </script>
387
+
@@ -0,0 +1,60 @@
1
+ <template>
2
+ <optionContainer :data-value="value" :hoveredBgColor="hoveredBgColor || colorMode=='dark'?'#000000':'grey5'" @click="clickHandler" @mouseover="hoverHandler">
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
+ hoverHandler(){
53
+ this.$parent.$emit('option-hovered',this.value)
54
+ }
55
+ },
56
+ computed: {
57
+ }
58
+ }
59
+ </script>
60
+
@@ -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
+