@eturnity/eturnity_reusable_components 7.8.1 → 7.8.2-EPDM-7779.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": "7.8.1",
3
+ "version": "7.8.2-EPDM-7779.1",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "vue-cli-service serve",
@@ -63,7 +63,7 @@
63
63
  @input-change="searchChange"
64
64
  @click.native.stop
65
65
  />
66
- <selector v-else>
66
+ <selector :selectWidth="selectorWidth" v-else>
67
67
  <slot name="selector" :selectedValue="selectedValue"></slot>
68
68
  </selector>
69
69
  <Caret @click.stop="toggleCaretDropdown">
@@ -142,20 +142,26 @@ import InfoText from '../../infoText'
142
142
  import icon from '../../icon'
143
143
  import inputText from '../inputText'
144
144
 
145
+ const CARET_WIDTH = 30
146
+ const ELLIPSIS_WIDTH = 16
147
+
145
148
  const Caret = styled.div`
146
149
  display: flex;
147
150
  align-items: center;
148
151
  justify-content: center;
149
- width: 30px;
150
- min-width: 30px;
152
+ width: ${CARET_WIDTH}px;
153
+ min-width: ${CARET_WIDTH}px;
151
154
  height: 100%;
152
155
  align-items: stretch
153
156
  cursor: pointer;
154
157
  margin-left: auto;
155
158
  `
156
159
 
157
- const Selector = styled.div`
158
- width: 100%;
160
+ const Selector = styled('div', { selectWidth: String })`
161
+ max-width: ${(props) => props.selectWidth};
162
+ white-space: nowrap;
163
+ text-overflow: ellipsis;
164
+ overflow: hidden;
159
165
  `
160
166
 
161
167
  const labelAttrs = { fontSize: String, fontColor: String }
@@ -164,7 +170,7 @@ const InputLabel = styled('div', labelAttrs)`
164
170
  props.theme.colors[props.fontColor]
165
171
  ? props.theme.colors[props.fontColor]
166
172
  : props.fontColor};
167
- font-size: ${(props) => (props.fontSize ? props.fontSize : '13px')};
173
+ font-size: ${(props) => props.fontSize};
168
174
  font-weight: 700;
169
175
  `
170
176
  const optionalLabel = styled.span`
@@ -299,7 +305,7 @@ export default {
299
305
  },
300
306
  fontSize: {
301
307
  required: false,
302
- default: null
308
+ default: '13px'
303
309
  },
304
310
  label: {
305
311
  required: false
@@ -546,26 +552,27 @@ export default {
546
552
  this.$refs.dropdown.$el.scrollTop = topPos
547
553
  }
548
554
  }
555
+ },
556
+ clearSearch() {
557
+ this.textSearch = ''
549
558
  }
550
559
  },
551
560
  computed: {
552
561
  optionLength() {
553
562
  if (this.isDropdownOpen) {
554
- // this filterRef is needed to check for the # of children on Filter dropdowns
555
- const filterRef =
556
- this.$refs.dropdown.$children &&
557
- this.$refs.dropdown.$children.length > 1
558
- ? this.$refs.dropdown.$children
559
- : this.$refs.dropdown.$children[0].$children
560
- ? this.$refs.dropdown.$children[0].$children
561
- : this.$refs.dropdown.$children
562
- return filterRef.length
563
- } else {
564
- return 0
563
+ return this.$refs.dropdown.$el.childElementCount
565
564
  }
565
+
566
+ return 0
566
567
  },
567
568
  isSearchBarVisible() {
568
- return this.isSearchable && this.optionLength >= 5 && this.isDropdownOpen
569
+ // Removed the optionLength condition, because if there were no result/options when we searched, we still need to show the search input
570
+ return this.isSearchable && this.isDropdownOpen
571
+ },
572
+ selectorWidth() {
573
+ const currentWidth = this.selectWidth ? this.selectWidth : '100%'
574
+
575
+ return `calc(${currentWidth} - ${CARET_WIDTH + ELLIPSIS_WIDTH}px)`
569
576
  }
570
577
  },
571
578
  watch: {
@@ -6,7 +6,7 @@
6
6
  @click.native="onOutsideClose()"
7
7
  :backdrop="backdrop"
8
8
  >
9
- <modal-container @click.stop>
9
+ <modal-container @click="onClickModalContainer">
10
10
  <spinner v-if="isLoading" size="50px" :limitedToModal="true" />
11
11
  <content-container :visible="!isLoading">
12
12
  <slot />
@@ -27,7 +27,7 @@
27
27
  // import Modal from "@eturnity/eturnity_reusable_components/src/components/modals/modal"
28
28
  // This is a more flexible modal box, where the parent can decide how the body of the modal looks
29
29
  // To use:
30
- // <modal :isOpen="isOpen" @on-close="$emit('on-close-summary')" :preventOutsideClose="true" :isLoading="true" :hideClose="true">
30
+ // <modal :isOpen="isOpen" @on-close="$emit('on-close-summary')" :preventOutsideClose="true" :isLoading="true" :hideClose="true" :stopPropagation="false">
31
31
  // <div>Data....</div>
32
32
  // </modal>
33
33
 
@@ -156,6 +156,10 @@ export default {
156
156
  position: {
157
157
  required: false,
158
158
  default: 'fixed'
159
+ },
160
+ stopPropagation: {
161
+ type: Boolean,
162
+ default: true
159
163
  }
160
164
  },
161
165
  methods: {
@@ -167,6 +171,11 @@ export default {
167
171
  if (!this.preventOutsideClose) {
168
172
  this.$emit('on-close')
169
173
  }
174
+ },
175
+ onClickModalContainer(event) {
176
+ if (this.stopPropagation) {
177
+ event.stopPropagation()
178
+ }
170
179
  }
171
180
  },
172
181
  watch: {
@@ -38,11 +38,12 @@
38
38
  {{ child.name }}
39
39
  </option-child>
40
40
  </children-container>
41
- <options-container v-if="!isLoading">
41
+ <options-container v-if="!isLoading" :textWrap="textWrap">
42
42
  <option-item
43
43
  v-for="(item, index) in options"
44
44
  :key="item.value"
45
45
  tabindex="0"
46
+ :textWrap="textWrap"
46
47
  @click.stop="onSelect({ item: item, hasChildren: hasChildren(item) })"
47
48
  @keyup.enter="
48
49
  onSelect({ item: item, hasChildren: hasChildren(item) })
@@ -56,8 +57,8 @@
56
57
  v-if="hasChildren(item)"
57
58
  />
58
59
  <span>
59
- {{ item.name }}
60
- </span>
60
+ {{ item.name }}
61
+ </span>
61
62
  </option-item>
62
63
  </options-container>
63
64
  </template>
@@ -184,22 +185,20 @@ const LoadingContainer = styled.div`
184
185
  background: #fff;
185
186
  `
186
187
 
187
- const OptionsContainer = styled.div`
188
+ const OptionsContainerAttrs = { textWrap: Boolean }
189
+ const OptionsContainer = styled('div', OptionsContainerAttrs)`
188
190
  border: 1px solid ${(props) => props.theme.colors.grey3};
189
191
  display: grid;
190
192
  grid-template-columns: 1fr;
191
- min-width: 220px;
192
- max-width: 220px;
193
- width: max-content;
193
+ ${(props) => props.textWrap ? 'width: 220px' : 'width: max-content' };
194
194
  border-radius: 4px;
195
195
  background-color: #fff;
196
196
  max-height: 220px;
197
197
  overflow: auto;
198
198
  height: max-content;
199
- white-space: normal;
200
199
  `
201
200
 
202
- const optionAttrs = { isDisabled: Boolean }
201
+ const optionAttrs = { isDisabled: Boolean, textWrap: Boolean }
203
202
  const OptionItem = styled('div', optionAttrs)`
204
203
  padding: 12px;
205
204
  cursor: ${(props) => (props.isDisabled ? 'not-allowed' : 'pointer')};
@@ -207,6 +206,7 @@ const OptionItem = styled('div', optionAttrs)`
207
206
  position: relative;
208
207
  ${(props) => (props.isDisabled ? `background-color: ${ props.theme.colors.grey5 }!important` : '')};
209
208
  ${(props) => (props.isDisabled ? `color: ${ props.theme.colors.grey2 }` : '')};
209
+ ${(props) => props.textWrap ? '' : 'white-space: nowrap'};
210
210
 
211
211
  &:hover {
212
212
  background-color: #ebeef4;
@@ -288,6 +288,10 @@ export default {
288
288
  isLoading: {
289
289
  required: false,
290
290
  default: false
291
+ },
292
+ textWrap: {
293
+ required: false,
294
+ default: true
291
295
  }
292
296
  },
293
297
  data() {