@eturnity/eturnity_reusable_components 7.10.0 → 7.12.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": "7.10.0",
3
+ "version": "7.12.0",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "vue-cli-service serve",
@@ -46,8 +46,8 @@
46
46
  @keydown.native="onKeyDown"
47
47
  :showBorder="showBorder"
48
48
  :data-id="dataId"
49
- :isDraggable="isDraggable"
50
- >
49
+ :paddingLeft="paddingLeft"
50
+ >
51
51
  <draggableInputHandle v-if="isDraggable && !isSearchBarVisible" :height="selectHeight" />
52
52
  <inputText
53
53
  v-if="isSearchBarVisible"
@@ -65,7 +65,7 @@
65
65
  @input-change="searchChange"
66
66
  @click.native.stop
67
67
  />
68
- <selector v-else>
68
+ <selector v-else :selectWidth="selectWidth" :paddingLeft="paddingLeft">
69
69
  <slot name="selector" :selectedValue="selectedValue"></slot>
70
70
  </selector>
71
71
  <Caret @click.stop="toggleCaretDropdown">
@@ -145,20 +145,26 @@ import icon from '../../icon'
145
145
  import inputText from '../inputText'
146
146
  import draggableInputHandle from '../../draggableInputHandle'
147
147
 
148
+ const CARET_WIDTH = '30px'
149
+ const BORDER_WIDTH = '1px'
150
+
148
151
  const Caret = styled.div`
149
152
  display: flex;
150
153
  align-items: center;
151
154
  justify-content: center;
152
- width: 30px;
153
- min-width: 30px;
155
+ width: ${CARET_WIDTH};
156
+ min-width: ${CARET_WIDTH};
154
157
  height: 100%;
155
- align-items: stretch
158
+ align-items: stretch;
156
159
  cursor: pointer;
157
160
  margin-left: auto;
158
161
  `
159
162
 
160
- const Selector = styled.div`
161
- width: 100%;
163
+ const Selector = styled('div', { selectWidth: String, paddingLeft: String })`
164
+ max-width: ${(props) => `calc(${props.selectWidth} - (${CARET_WIDTH} + ${props.paddingLeft} + (${BORDER_WIDTH} * 2)))`};
165
+ white-space: nowrap;
166
+ text-overflow: ellipsis;
167
+ overflow: hidden;
162
168
  `
163
169
 
164
170
  const labelAttrs = { fontSize: String, fontColor: String }
@@ -167,7 +173,7 @@ const InputLabel = styled('div', labelAttrs)`
167
173
  props.theme.colors[props.fontColor]
168
174
  ? props.theme.colors[props.fontColor]
169
175
  : props.fontColor};
170
- font-size: ${(props) => (props.fontSize ? props.fontSize : '13px')};
176
+ font-size: ${(props) => props.fontSize};
171
177
  font-weight: 700;
172
178
  `
173
179
  const optionalLabel = styled.span`
@@ -175,7 +181,7 @@ const optionalLabel = styled.span`
175
181
  `
176
182
  const inputProps = { selectWidth: String, optionWidth: String }
177
183
  const Container = styled('div', inputProps)`
178
- width: ${(props) => (props.selectWidth ? props.selectWidth : '100%')};
184
+ width: ${(props) => props.selectWidth};
179
185
  position: relative;
180
186
  display: inline-block;
181
187
  `
@@ -204,15 +210,14 @@ const selectButtonAttrs = {
204
210
  selectMinHeight: String,
205
211
  isSearchBarVisible: Boolean,
206
212
  showBorder: Boolean,
207
- isDraggable: Boolean,
213
+ paddingLeft: String
208
214
  }
209
215
  const selectButton = styled('div', selectButtonAttrs)`
210
216
  position: relative;
211
217
  box-sizing: border-box;
212
218
  border-radius: 4px;
213
- padding-left:${(props) => (props.isSearchBarVisible ? '0' : props.isDraggable?'30px':'15px')};
219
+ ${(props) => (props.isSearchBarVisible ? '' : `padding-left: ${props.paddingLeft}` )};
214
220
  text-align: left;
215
- border-radius: 4px;
216
221
  min-height: ${(props) =>
217
222
  props.selectHeight
218
223
  ? props.selectHeight
@@ -227,7 +232,7 @@ const selectButton = styled('div', selectButtonAttrs)`
227
232
  ${({ showBorder, theme, hasError }) =>
228
233
  showBorder &&
229
234
  `
230
- border:1px solid ${hasError ? theme.colors.red : theme.colors.grey4}
235
+ border: ${BORDER_WIDTH} solid ${hasError ? theme.colors.red : theme.colors.grey4}
231
236
  `}
232
237
  background-color:${(props) =>
233
238
  props.disabled
@@ -249,7 +254,6 @@ const selectDropdownAttrs = {
249
254
  hoveredBgColor: String,
250
255
  bgColor: String,
251
256
  fontColor: String,
252
- selectWidth: String,
253
257
  optionWidth: String,
254
258
  hoveredIndex: Number,
255
259
  hoveredValue: Number | String,
@@ -260,7 +264,7 @@ const selectDropdown = styled('div', selectDropdownAttrs)`
260
264
  z-index:${(props) => (props.isActive ? '2' : '1')};
261
265
  position:absolute;
262
266
  top:5px;
263
- border:1px solid ${(props) => props.theme.colors.grey4}
267
+ border: ${BORDER_WIDTH} solid ${(props) => props.theme.colors.grey4};
264
268
  border-radius:4px;
265
269
  display: flex;
266
270
  flex-direction: column;
@@ -307,7 +311,7 @@ export default {
307
311
  },
308
312
  fontSize: {
309
313
  required: false,
310
- default: null
314
+ default: '13px'
311
315
  },
312
316
  label: {
313
317
  required: false
@@ -327,8 +331,9 @@ export default {
327
331
  required: false
328
332
  },
329
333
  selectWidth: {
334
+ type: String,
330
335
  required: false,
331
- default: null
336
+ default: '100%'
332
337
  },
333
338
  selectHeight: {
334
339
  type: String,
@@ -437,6 +442,7 @@ export default {
437
442
  data() {
438
443
  return {
439
444
  selectedValue: null,
445
+ paddingLeft: this.isDraggable ? '30px' : '15px',
440
446
  isDropdownOpen: false,
441
447
  isActive: false,
442
448
  textSearch: '',
@@ -511,9 +517,6 @@ export default {
511
517
  }
512
518
  })
513
519
  },
514
- onSelectSlotClick() {
515
- this.toggleDropdown()
516
- },
517
520
  clickOutside(event) {
518
521
  const dropdownRef = this.$refs.dropdown
519
522
  // we need to prevent closing on selecting an option, because in the case of
@@ -559,26 +562,21 @@ export default {
559
562
  this.$refs.dropdown.$el.scrollTop = topPos
560
563
  }
561
564
  }
565
+ },
566
+ clearSearch() {
567
+ this.textSearch = ''
562
568
  }
563
569
  },
564
570
  computed: {
565
571
  optionLength() {
566
572
  if (this.isDropdownOpen) {
567
- // this filterRef is needed to check for the # of children on Filter dropdowns
568
- const filterRef =
569
- this.$refs.dropdown.$children &&
570
- this.$refs.dropdown.$children.length > 1
571
- ? this.$refs.dropdown.$children
572
- : this.$refs.dropdown.$children[0].$children
573
- ? this.$refs.dropdown.$children[0].$children
574
- : this.$refs.dropdown.$children
575
- return filterRef.length
576
- } else {
577
- return 0
573
+ return this.$refs.dropdown.$el.childElementCount
578
574
  }
575
+
576
+ return 0
579
577
  },
580
578
  isSearchBarVisible() {
581
- return this.isSearchable && this.optionLength >= 5 && this.isDropdownOpen
579
+ return this.isSearchable && this.isDropdownOpen
582
580
  }
583
581
  },
584
582
  watch: {
@@ -5,7 +5,7 @@
5
5
  :class="{ visible: isOpen, hidden: !isOpen }"
6
6
  :backdrop="backdrop"
7
7
  >
8
- <modal-container @click.stop>
8
+ <modal-container @click="onClickModalContainer">
9
9
  <spinner v-if="isLoading" size="50px" :limitedToModal="true" />
10
10
  <content-container :visible="!isLoading">
11
11
  <slot />
@@ -26,7 +26,7 @@
26
26
  // import Modal from "@eturnity/eturnity_reusable_components/src/components/modals/modal"
27
27
  // This is a more flexible modal box, where the parent can decide how the body of the modal looks
28
28
  // To use:
29
- // <modal :isOpen="isOpen" @on-close="$emit('on-close-summary')" :isLoading="true" :hideClose="true">
29
+ // <modal :isOpen="isOpen" @on-close="$emit('on-close-summary')" :isLoading="true" :hideClose="true" :stopPropagation="false">
30
30
  // <div>Data....</div>
31
31
  // </modal>
32
32
 
@@ -151,6 +151,10 @@ export default {
151
151
  position: {
152
152
  required: false,
153
153
  default: 'fixed'
154
+ },
155
+ stopPropagation: {
156
+ type: Boolean,
157
+ default: true
154
158
  }
155
159
  },
156
160
  beforeDestroy() {
@@ -164,6 +168,11 @@ export default {
164
168
  if (key === 'Escape') {
165
169
  this.onCloseModal()
166
170
  }
171
+ },
172
+ onClickModalContainer(event) {
173
+ if (this.stopPropagation) {
174
+ event.stopPropagation()
175
+ }
167
176
  }
168
177
  },
169
178
  watch: {