@eturnity/eturnity_reusable_components 1.2.19-EPDM-3412.0 → 1.2.19-EPDM-3412.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eturnity/eturnity_reusable_components",
3
- "version": "1.2.19-EPDM-3412.0",
3
+ "version": "1.2.19-EPDM-3412.1",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "vue-cli-service serve",
package/src/App.vue CHANGED
@@ -2,45 +2,27 @@
2
2
  <ThemeProvider :theme="getTheme()" :style="{ height: '100%' }">
3
3
  <page-container>
4
4
  <br />
5
- <modal backdrop="dark" :isLoading="false" :isOpen="true">
6
- <main-table titleText="My Table">
7
- <thead>
8
- <tr>
9
- <th>Column 1</th>
10
- <th>Column 2</th>
11
- <th>Column 3</th>
12
- <div />
13
- </tr>
14
- </thead>
15
- <tbody>
16
- <tr>
17
- <!-- <table-dropdown
18
- :colSpan="3"
19
- :tableItems="getDropdownValues()"
20
- @toggle-dropdown-open="toggleDropdownOpen()"
21
- @item-selected="onItemSelected({ item: $event, index })"
22
- :isOpen="isDropdownOpen()"
23
- :optionItems="itemOptions"
24
- :optionsDisplay="['display_name', 'company_item_number', 'model']"
25
- /> -->
26
- <td>Test</td>
27
- <div class="icons-container">
28
- <three-dots :options="listOptions" :isLoading="false" />
29
- </div>
30
- </tr>
31
- </tbody>
32
- </main-table>
33
- </modal>
34
- <br />
35
- <toggle
36
- @on-toggle-change="onInputChange($event)"
37
- :isChecked="inputValue"
38
- label="My Label Text"
39
- infoTextMessage="This is my test message"
40
- infoTextAlign="right"
41
- labelAlign="right"
42
- :disabled="false"
43
- />
5
+ <input-number
6
+ :value="inputValue"
7
+ @input-change="inputValue = $event"
8
+ inputWidth="250px"
9
+ slotSize="50%"
10
+ ><InputAnnexContainer>
11
+ <span>123m2</span>
12
+ <info-text size="10" alignArrow="right" text="infoText ceci est le text"></info-text>
13
+ </InputAnnexContainer>
14
+ </input-number>
15
+ <input-number
16
+ :value="inputValue"
17
+ @input-change="inputValue = $event"
18
+ inputWidth="250px"
19
+ slotSize="50%"
20
+ :isError="true"
21
+ ><InputAnnexContainer>
22
+ <span>123m2</span>
23
+ <info-text :style="{'justify-self': 'end'}" size="12" alignArrow="center" text="infoText ceci est le text">This is the tooltip text</info-text>
24
+ </InputAnnexContainer>
25
+ </input-number>
44
26
  <br />
45
27
 
46
28
  <p>InputText</p>
@@ -83,6 +65,11 @@ import Spinner from "@/components/spinner"
83
65
  import ExternalButton from "@/components/buttons/externalButton"
84
66
  import InputText from "@/components/inputs/inputText"
85
67
  // import TableDropdown from "@/components/tableDropdown"
68
+ const InputAnnexContainer = styled.div`
69
+ display: grid;
70
+ grid-template-columns: auto auto;
71
+ grid-gap: 10px;
72
+ `
86
73
 
87
74
  const PageContainer = styled.div`
88
75
  padding: 40px;
@@ -93,9 +80,6 @@ export default {
93
80
  components: {
94
81
  ThemeProvider,
95
82
  PageContainer,
96
- MainTable,
97
- ThreeDots,
98
- Toggle,
99
83
  InputNumber,
100
84
  PageSubtitle,
101
85
  Spinner,
@@ -1,34 +1,25 @@
1
1
  <template>
2
2
  <component-wrapper>
3
- <icon-wrapper>
3
+ <icon-wrapper :size="size">
4
4
  <icon-img
5
5
  :isActive="showInfo"
6
6
  :size="size"
7
7
  :borderColor="borderColor"
8
8
  @click.prevent="toggleShowInfo()"
9
- @mouseenter="toggleShowInfo()"
10
- @mouseleave="toggleShowInfo()"
9
+ @mouseenter="openTrigger == 'onHover' ? toggleShowInfo() : ''"
10
+ @mouseleave="openTrigger == 'onHover' ? toggleShowInfo() : ''"
11
11
  >
12
- <svg
13
- class="img-icon"
14
- :width="size"
15
- :height="size"
16
- viewBox="0 0 24 24"
17
- fill="none"
18
- xmlns="http://www.w3.org/2000/svg"
19
- >
20
- <path
21
- class="img-icon"
22
- d="M20.4853 3.51469C18.2188 1.24823 15.2053 0 12 0C8.79469 0 5.78123 1.24823 3.51469 3.51469C1.24823 5.78123 0 8.79469 0 12C0 15.2053 1.24823 18.2188 3.51469 20.4853C5.78123 22.7518 8.79469 24 12 24C15.2053 24 18.2188 22.7518 20.4853 20.4853C22.7518 18.2188 24 15.2053 24 12C24 8.79469 22.7518 5.78123 20.4853 3.51469ZM12 3.28125C13.4216 3.28125 14.5781 4.4378 14.5781 5.85938C14.5781 7.28095 13.4216 8.4375 12 8.4375C10.5784 8.4375 9.42188 7.28095 9.42188 5.85938C9.42188 4.4378 10.5784 3.28125 12 3.28125ZM15.2812 19.6875H8.71875V18.2812H10.125V11.9167H8.71875V10.5104H13.875V18.2812H15.2812V19.6875Z"
23
- fill="#D5D5D5"
24
- />
25
- </svg>
12
+ <icon :size="size + 'px'" name="info" :color="iconColor" />
26
13
  </icon-img>
27
14
  <text-overlay
28
15
  v-if="showInfo"
29
16
  :borderColor="borderColor"
30
17
  :alignText="alignText"
31
- >
18
+ :width="width"
19
+ :halfComputedTextInfoWidth="halfComputedTextInfoWidth"
20
+ :alignArrow="alignArrow"
21
+ :iconSize="size"
22
+ ><slot />
32
23
  {{ text }}
33
24
  </text-overlay>
34
25
  </icon-wrapper>
@@ -44,22 +35,21 @@
44
35
  // size="20"
45
36
  // alignText="right" // default is left
46
37
  // />
38
+ import theme from '@/assets/theme.js'
39
+ import styled from 'vue-styled-components'
40
+ import icon from '../icon'
47
41
 
48
- import styled from "vue-styled-components"
49
-
50
- const IconWrapper = styled.div`
51
- position: relative;
52
- `
53
-
54
- const textAttrs = { borderColor: String, alignText: String }
55
- const TextOverlay = styled("div", textAttrs)`
42
+ const textAttrs = { iconSize:Number, borderColor: String, alignArrow:String, alignText: String, width:String,halfComputedTextInfoWidth:Number }
43
+ const TextOverlay = styled('div', textAttrs)`
56
44
  position: absolute;
57
- top: 26px;
58
- right: ${(props) => (props.alignText === "left" ? "-10px" : "inherit")};
59
- left: ${(props) => (props.alignText === "left" ? "inherit" : "-10px")};
45
+ top: ${(props) => (parseInt(props.iconSize) + 15)}px;
46
+ ${(props) => (props.alignArrow === 'left' ? 'left: '+((props.iconSize/2)-18)+'px;' :
47
+ props.alignArrow === 'center' ? 'left: calc((-'+props.width+' + '+props.iconSize+'px)/2 - 7px);':
48
+ 'right: '+((props.iconSize/2)-17)+'px;')};
49
+ text-align: ${(props) => props.alignText};
60
50
  background: ${(props) => props.theme.colors.black};
61
51
  padding: 10px;
62
- width: max-content;
52
+ width: ${(props) => props.width };
63
53
  max-width: 400px;
64
54
  font-size: 13px;
65
55
  font-weight: 400;
@@ -68,12 +58,13 @@ const TextOverlay = styled("div", textAttrs)`
68
58
  color: ${(props) => props.theme.colors.white};
69
59
 
70
60
  :before {
71
- content: "";
61
+ content: '';
72
62
  background-color: ${(props) => props.theme.colors.black};
73
63
  position: absolute;
74
64
  top: 2px;
75
- right: ${(props) => (props.alignText === "left" ? "-12px" : "inherit")};
76
- left: ${(props) => (props.alignText === "left" ? "inherit" : "40px")};
65
+ ${(props) => (props.alignArrow === 'left' ? 'left:40px;' :
66
+ props.alignArrow=='center' ? 'left: calc(50% + 19px);' :
67
+ 'right:-13px;')};
77
68
  height: 8px;
78
69
  width: 8px;
79
70
  transform-origin: center center;
@@ -82,18 +73,15 @@ const TextOverlay = styled("div", textAttrs)`
82
73
  `
83
74
 
84
75
  const iconAttrs = { isActive: Boolean, size: String, borderColor: String }
85
- const IconImg = styled("div", iconAttrs)`
86
- cursor: pointer;
87
- height: ${(props) => props.size + "px"};
88
76
 
89
- .img-icon {
90
- fill: ${(props) =>
91
- props.isActive
92
- ? props.borderColor
93
- ? props.borderColor
94
- : props.theme.colors.secondary
95
- : props.theme.colors.mediumGray};
96
- }
77
+ const IconWrapper = styled('div', iconAttrs)`
78
+ position: relative;
79
+ top: 1px;
80
+ height: ${(props) => props.size}px;
81
+ `
82
+ const IconImg = styled('div', iconAttrs)`
83
+ cursor: pointer;
84
+ height: ${(props) => props.size}px;
97
85
  `
98
86
 
99
87
  const ComponentWrapper = styled.div`
@@ -101,38 +89,51 @@ const ComponentWrapper = styled.div`
101
89
  `
102
90
 
103
91
  export default {
104
- name: "info-text",
92
+ name: 'info-text',
105
93
  components: {
106
94
  IconWrapper,
107
95
  TextOverlay,
108
96
  ComponentWrapper,
109
97
  IconImg,
98
+ icon
110
99
  },
111
100
  props: {
112
101
  text: {
113
- required: true,
102
+ required: false,
114
103
  },
115
104
  borderColor: {
116
105
  required: false,
117
- default: null,
106
+ default: null
118
107
  },
119
108
  size: {
120
109
  required: false,
121
- default: "20",
110
+ default: '14'
122
111
  },
123
112
  alignText: {
124
113
  required: false,
125
- default: "left", // "left" or "right"
114
+ default: 'left' // "left" or "right"
115
+ },
116
+ alignArrow:{
117
+ required:false,
118
+ default:'center'
119
+ },
120
+ openTrigger:{
121
+ required:false,
122
+ default: 'onClick'
126
123
  },
124
+ width:{
125
+ required:false,
126
+ default:'165px'
127
+ }
127
128
  },
128
129
  methods: {
129
130
  toggleShowInfo() {
130
131
  this.showInfo = !this.showInfo
131
132
 
132
133
  if (this.showInfo) {
133
- document.addEventListener("click", this.clickOutside)
134
+ document.addEventListener('click', this.clickOutside)
134
135
  } else {
135
- document.removeEventListener("click", this.clickOutside)
136
+ document.removeEventListener('click', this.clickOutside)
136
137
  }
137
138
  },
138
139
  clickOutside(event) {
@@ -140,12 +141,24 @@ export default {
140
141
  return
141
142
  }
142
143
  this.toggleShowInfo()
143
- },
144
+ }
144
145
  },
145
146
  data() {
146
147
  return {
147
148
  showInfo: false,
148
149
  }
149
150
  },
151
+ computed: {
152
+ iconColor() {
153
+ return this.isActive
154
+ ? this.borderColor
155
+ ? this.borderColor
156
+ : theme.colors.secondary
157
+ : theme.colors.mediumGray
158
+ },
159
+ halfComputedTextInfoWidth() {
160
+ return parseInt(this.width)/2;
161
+ }
162
+ }
150
163
  }
151
- </script>
164
+ </script>
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <container>
2
+ <container :inputWidth="inputWidth">
3
3
  <label-wrapper v-if="labelText">
4
4
  <label-text>
5
5
  {{ labelText }}
@@ -8,7 +8,7 @@
8
8
  v-if="labelInfoText"
9
9
  :text="labelInfoText"
10
10
  borderColor="#ccc"
11
- size="13"
11
+ size="14"
12
12
  :alignText="labelInfoAlign"
13
13
  />
14
14
  </label-wrapper>
@@ -32,9 +32,15 @@
32
32
  :fontSize="fontSize"
33
33
  :fontColor="fontColor"
34
34
  v-on="$listeners"
35
+ :hasSlot="hasSlot"
36
+ :slotSize="slotSize"
35
37
  />
38
+ <slot-container v-if="hasSlot" :slotSize="slotSize" :isError="isError">
39
+ <slot></slot>
40
+ </slot-container>
41
+
36
42
  <unit-container
37
- v-if="unitName && showLinearUnitName"
43
+ v-if="unitName && showLinearUnitName && !hasSlot"
38
44
  :hasLength="!!textInput.length"
39
45
  :isError="isError"
40
46
  >{{ unitName }}</unit-container
@@ -83,10 +89,6 @@ import {
83
89
  import InfoText from '../../infoText'
84
90
  import ErrorMessage from '../../errorMessage'
85
91
  import warningIcon from '../../../assets/icons/error_icon.png'
86
- const Container = styled.div`
87
- width: 100%;
88
- position: relative;
89
- `
90
92
 
91
93
  const inputProps = {
92
94
  isError: Boolean,
@@ -97,8 +99,16 @@ const inputProps = {
97
99
  noBorder: Boolean,
98
100
  textAlign: String,
99
101
  fontSize: String,
100
- fontColor: String
102
+ fontColor: String,
103
+ hasSlot: Boolean,
104
+ slotSize: String
101
105
  }
106
+
107
+ const Container = styled('div', inputProps)`
108
+ width: ${(props) => (props.inputWidth ? props.inputWidth : '100%')};
109
+ position: relative;
110
+ `
111
+
102
112
  const InputContainer = styled('input', inputProps)`
103
113
  border: ${(props) =>
104
114
  props.isError
@@ -106,8 +116,15 @@ const InputContainer = styled('input', inputProps)`
106
116
  : props.noBorder
107
117
  ? 'none'
108
118
  : '1px solid ' + props.theme.colors.mediumGray};
109
- padding: ${(props) =>
110
- props.hasUnit ? '11px 40px 11px 10px' : '11px 5px 11px 10px'};
119
+ padding-top: 11px;
120
+ padding-bottom: 11px;
121
+ padding-left: 10px;
122
+ padding-right: ${(props) =>
123
+ props.slotSize
124
+ ? 'calc(' + props.slotSize + ' + 10px)'
125
+ : props.hasUnit
126
+ ? '40px'
127
+ : '5px'};
111
128
  border-radius: 4px;
112
129
  text-align: ${(props) => props.textAlign};
113
130
  cursor: ${(props) => (props.isDisabled ? 'not-allowed' : 'auto')};
@@ -159,6 +176,7 @@ const UnitContainer = styled('span', inputProps)`
159
176
  right: 10px;
160
177
  top: 0;
161
178
  padding-left: 10px;
179
+ text-align: right;
162
180
  color: ${(props) =>
163
181
  props.isError
164
182
  ? props.theme.colors.red
@@ -167,14 +185,34 @@ const UnitContainer = styled('span', inputProps)`
167
185
  : props.theme.colors.mediumGray};
168
186
  `
169
187
 
170
- // const ErrorMessage = styled.div`
171
- // margin-top: 5px;
172
- // line-height: 1;
173
- // text-transform: none;
174
- // font-size: 10px;
175
- // color: ${(props) => props.theme.colors.red};
176
- // position: absolute;
177
- // `
188
+ const SlotContainer = styled('span', inputProps)`
189
+ text-align: right;
190
+ border-left: 1px solid
191
+ ${(props) =>
192
+ props.isError
193
+ ? props.theme.colors.red
194
+ : props.hasLength
195
+ ? props.theme.colors.black
196
+ : props.theme.colors.mediumGray};
197
+ position: absolute;
198
+ width: ${(props) =>
199
+ props.slotSize ? 'calc(' + props.slotSize + ' - 10px)' : 'fit-content'};
200
+ right: 10px;
201
+ top: 0;
202
+ padding-left: 10px;
203
+ color: ${(props) =>
204
+ props.isError
205
+ ? props.theme.colors.red
206
+ : props.hasLength
207
+ ? props.theme.colors.black
208
+ : props.theme.colors.mediumGray};
209
+ `
210
+ const ErrorMessage = styled.div`
211
+ font-size: 14px;
212
+ color: ${(props) => props.theme.colors.red};
213
+ position: absolute;
214
+ top: calc(100% + 1px);
215
+ `
178
216
 
179
217
  const LabelWrapper = styled.div`
180
218
  display: flex;
@@ -198,7 +236,9 @@ export default {
198
236
  LabelWrapper,
199
237
  LabelText,
200
238
  InfoText,
201
- Icon
239
+ Icon,
240
+ SlotContainer,
241
+ InfoText
202
242
  },
203
243
  inheritAttrs: false,
204
244
  data() {
@@ -281,7 +321,7 @@ export default {
281
321
  },
282
322
  labelInfoAlign: {
283
323
  required: false,
284
- default: 'right'
324
+ default: 'left'
285
325
  },
286
326
  minNumber: {
287
327
  required: false,
@@ -309,6 +349,17 @@ export default {
309
349
  require: false,
310
350
  type: Array,
311
351
  default: () => []
352
+ },
353
+ slotSize: {
354
+ required: false
355
+ }
356
+ },
357
+ computed: {
358
+ hasSlot() {
359
+ return !!this.$slots.default
360
+ },
361
+ computedSlotSize() {
362
+ return this.slotSize || this.$slots['default'][0].elm.clientWidth
312
363
  }
313
364
  },
314
365
  methods: {
@@ -4,6 +4,9 @@ export const stringToNumber = ({
4
4
  allowNegative
5
5
  }) => {
6
6
  // This is for saving. It converts our input string to a readable number
7
+ if (value === undefined) {
8
+ value = ''
9
+ }
7
10
  let newVal = value.toString()
8
11
  const selectedLang = localStorage.getItem('lang')
9
12
  // The first replace will replace not allowed characters with a blank