@eturnity/eturnity_reusable_components 1.2.26--EPDM-3834.1 → 1.2.26--EPDM-3834.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eturnity/eturnity_reusable_components",
3
- "version": "1.2.26--EPDM-3834.1",
3
+ "version": "1.2.26--EPDM-3834.2",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "vue-cli-service serve",
@@ -12,7 +12,7 @@
12
12
  ref="dropdownItem"
13
13
  :isNested="isNested"
14
14
  :class="{
15
- 'table-dropdown-item': item.type !== 'input',
15
+ 'table-dropdown-item': item.type !== 'input'
16
16
  }"
17
17
  >
18
18
  <nested-container :isNested="isNested">
@@ -32,7 +32,7 @@
32
32
  (item.value === '' || item.value === '-')
33
33
  "
34
34
  :key="idx"
35
- >{{ $gettext("Use template...") }}</template-button
35
+ >{{ $gettext('Use template...') }}</template-button
36
36
  >
37
37
  <template-link
38
38
  v-else-if="
@@ -49,7 +49,7 @@
49
49
  <div>{{ item.value }}</div>
50
50
  </template-link>
51
51
  <no-template v-if="item.type && item.type === 'no-template'">
52
- {{ $gettext("No main component template") }}
52
+ {{ $gettext('No main component template') }}
53
53
  </no-template>
54
54
  <input-container
55
55
  v-if="item.type === 'input'"
@@ -82,7 +82,7 @@
82
82
  </text-container>
83
83
  </nested-container>
84
84
  </component-item>
85
- <arrow-container class="arrow-container">
85
+ <arrow-container class="arrow-container" :isDisabled="disabled">
86
86
  <arrow-wrapper :showArchived="showArchived">
87
87
  <et-popover
88
88
  v-if="showArchived"
@@ -122,7 +122,7 @@
122
122
  </search-container>
123
123
  <spinner v-if="optionsLoading" />
124
124
  <empty-text v-else-if="!optionsLoading && !optionItems.length">
125
- {{ emptyText ? emptyText : $gettext("No components found.") }}
125
+ {{ emptyText ? emptyText : $gettext('No components found.') }}
126
126
  </empty-text>
127
127
  <options-item
128
128
  v-else
@@ -136,19 +136,19 @@
136
136
  >
137
137
  <template v-for="(option, idx) in optionsDisplay">
138
138
  <span v-if="option !== 'template'" :key="idx">
139
- {{ !!item[option] ? item[option] : "-" }}
139
+ {{ !!item[option] ? item[option] : '-' }}
140
140
  </span>
141
141
  <template-button
142
142
  @click.stop="onTemplateClick(item)"
143
143
  v-else-if="option === 'template' && item.has_template"
144
144
  :key="idx"
145
- >{{ $gettext("Use template...") }}</template-button
145
+ >{{ $gettext('Use template...') }}</template-button
146
146
  >
147
147
  <no-template
148
148
  v-else-if="option === 'template' && !item.has_template"
149
149
  :key="idx"
150
150
  >
151
- {{ $gettext("No main component template") }}
151
+ {{ $gettext('No main component template') }}
152
152
  </no-template>
153
153
  </template>
154
154
  </options-item>
@@ -159,7 +159,7 @@
159
159
  >
160
160
  <custom-name>{{ getCustomName }}</custom-name>
161
161
  <custom-subtext
162
- >({{ $gettext("custom_component") }})</custom-subtext
162
+ >({{ $gettext('custom_component') }})</custom-subtext
163
163
  >
164
164
  </custom-container>
165
165
  </options-container>
@@ -188,18 +188,18 @@
188
188
  // :optionsDisplay="['display_name', 'company_item_number']" // Array. what should be displayed
189
189
  // :disabled="true"
190
190
  // />
191
- import styled from "vue-styled-components"
192
- import Spinner from "@eturnity/eturnity_reusable_components/src/components/spinner"
193
- import SearchInput from "@eturnity/eturnity_reusable_components/src/components/inputs/searchInput"
194
- import InputText from "@eturnity/eturnity_reusable_components/src/components/inputs/inputText"
191
+ import styled from 'vue-styled-components'
192
+ import Spinner from '@eturnity/eturnity_reusable_components/src/components/spinner'
193
+ import SearchInput from '@eturnity/eturnity_reusable_components/src/components/inputs/searchInput'
194
+ import InputText from '@eturnity/eturnity_reusable_components/src/components/inputs/inputText'
195
195
 
196
196
  const rowAttrs = { disabled: Boolean, isOpen: Boolean }
197
- const DropdownRow = styled("div", rowAttrs)`
198
- cursor: ${(props) => (props.disabled ? "not-allowed" : "pointer")};
197
+ const DropdownRow = styled('div', rowAttrs)`
198
+ cursor: ${(props) => (props.disabled ? 'not-allowed' : 'pointer')};
199
199
  display: contents;
200
200
 
201
201
  input {
202
- cursor: ${(props) => (!props.isOpen ? "pointer !important" : "inherit")};
202
+ cursor: ${(props) => (!props.isOpen ? 'pointer !important' : 'inherit')};
203
203
  }
204
204
 
205
205
  .input-placeholder {
@@ -209,8 +209,8 @@ const DropdownRow = styled("div", rowAttrs)`
209
209
  `
210
210
 
211
211
  const ItemAttrs = { isNested: Boolean }
212
- const ComponentItem = styled("td", ItemAttrs)`
213
- padding-left: ${(props) => (props.isNested ? "14px !important" : "0")};
212
+ const ComponentItem = styled('td', ItemAttrs)`
213
+ padding-left: ${(props) => (props.isNested ? '14px !important' : '0')};
214
214
  overflow: hidden;
215
215
  text-overflow: ellipsis;
216
216
  padding-right: 0 !important;
@@ -234,7 +234,7 @@ const ComponentItem = styled("td", ItemAttrs)`
234
234
  `
235
235
 
236
236
  const containerAttrs = { colSpan: Number, width: String }
237
- const ComponentContainer = styled("div", containerAttrs)`
237
+ const ComponentContainer = styled('div', containerAttrs)`
238
238
  display: contents;
239
239
  align-items: center;
240
240
  background-color: ${(props) => props.theme.colors.white};
@@ -254,11 +254,13 @@ const ArrowUp = styled.img`
254
254
  transition: transform 150ms ease;
255
255
  `
256
256
 
257
- const ArrowContainer = styled.td`
257
+ const ArrowAttrs = { isDisabled: Boolean }
258
+ const ArrowContainer = styled('td', ArrowAttrs)`
258
259
  border-bottom: 1px solid ${(props) => props.theme.colors.grey4};
259
260
  background-clip: content-box;
260
261
  padding: 8px 0 7px 0 !important;
261
262
  border-radius: 0 4px 4px 0;
263
+ cursor: ${(props) => (props.isDisabled ? 'not-allowed !important' : 'auto')};
262
264
 
263
265
  @media not all and (min-resolution: 0.001dpcm) {
264
266
  @supports (-webkit-appearance: none) {
@@ -274,22 +276,22 @@ const ArrowContainer = styled.td`
274
276
  `
275
277
 
276
278
  const arrowAttrs = { showArchived: Boolean }
277
- const ArrowWrapper = styled("div", arrowAttrs)`
279
+ const ArrowWrapper = styled('div', arrowAttrs)`
278
280
  display: grid;
279
281
  grid-template-columns: ${(props) =>
280
- props.showArchived ? "auto auto" : "auto"};
282
+ props.showArchived ? 'auto auto' : 'auto'};
281
283
  align-items: center;
282
284
  justify-items: center;
283
285
  height: 100%;
284
286
  `
285
287
 
286
288
  const optionsAttrs = { top: Number, left: Number }
287
- const OptionsContainer = styled("div", optionsAttrs)`
289
+ const OptionsContainer = styled('div', optionsAttrs)`
288
290
  position: absolute;
289
291
  display: grid;
290
292
  grid-template-rows: 1fr auto;
291
- top: ${(props) => props.top + "px"};
292
- left: ${(props) => props.left + "px"};
293
+ top: ${(props) => props.top + 'px'};
294
+ left: ${(props) => props.left + 'px'};
293
295
  width: auto;
294
296
  max-height: 360px;
295
297
  min-height: 200px;
@@ -319,7 +321,7 @@ const OptionsWrapper = styled.div`
319
321
  min-width: 400px; // kind of an arbitrary number until we know all use cases
320
322
  `
321
323
 
322
- const OptionsItem = styled("div", containerAttrs)`
324
+ const OptionsItem = styled('div', containerAttrs)`
323
325
  display: grid;
324
326
  /* grid-template-columns: 1fr repeat(
325
327
  ${(props) => props.colSpan},
@@ -409,21 +411,21 @@ const TextContainer = styled.div`
409
411
 
410
412
  const NestedIcon = styled.div`
411
413
  background-image: ${() =>
412
- `url(${require("../../assets/icons/subposition_marker.svg")})`};
414
+ `url(${require('../../assets/icons/subposition_marker.svg')})`};
413
415
  height: 10px;
414
416
  width: 6px;
415
417
  `
416
418
 
417
419
  const NestedAttrs = { isNested: Boolean }
418
- const NestedContainer = styled("div", NestedAttrs)`
420
+ const NestedContainer = styled('div', NestedAttrs)`
419
421
  display: grid;
420
422
  grid-gap: 5px;
421
- grid-template-columns: ${(props) => (props.isNested ? "auto 1fr" : "1fr")};
423
+ grid-template-columns: ${(props) => (props.isNested ? 'auto 1fr' : '1fr')};
422
424
  align-items: center;
423
425
  `
424
426
 
425
427
  export default {
426
- name: "table-dropdown",
428
+ name: 'table-dropdown',
427
429
  components: {
428
430
  DropdownRow,
429
431
  ComponentItem,
@@ -449,64 +451,64 @@ export default {
449
451
  ArrowContainer,
450
452
  TextContainer,
451
453
  NestedIcon,
452
- NestedContainer,
454
+ NestedContainer
453
455
  },
454
456
  props: {
455
457
  colSpan: {
456
458
  required: false,
457
- default: 1,
459
+ default: 1
458
460
  },
459
461
  customInputDisabled: {
460
462
  // whether the input field should be disabled
461
463
  required: false,
462
- default: true,
464
+ default: true
463
465
  },
464
466
  allowFreeInputs: {
465
467
  // whether we allow the user to select a custom input
466
468
  required: false,
467
- default: false,
469
+ default: false
468
470
  },
469
471
  tableItems: {
470
- required: true,
472
+ required: true
471
473
  },
472
474
  showArchived: {
473
475
  required: false,
474
- default: false,
476
+ default: false
475
477
  },
476
478
  isOpen: {
477
479
  required: true,
478
- default: false,
480
+ default: false
479
481
  },
480
482
  optionsLoading: {
481
483
  required: false,
482
- default: false,
484
+ default: false
483
485
  },
484
486
  emptyText: {
485
487
  required: false,
486
- default: null,
488
+ default: null
487
489
  },
488
490
  optionItems: {
489
- required: true,
491
+ required: true
490
492
  },
491
493
  optionsDisplay: {
492
494
  required: true,
493
- default: [], // should be like ['display_name', 'company_item_number', 'description']
495
+ default: [] // should be like ['display_name', 'company_item_number', 'description']
494
496
  },
495
497
  disabled: {
496
498
  required: false,
497
- default: false,
499
+ default: false
498
500
  },
499
501
  isNested: {
500
502
  required: false,
501
- default: false,
502
- },
503
+ default: false
504
+ }
503
505
  },
504
506
  data() {
505
507
  return {
506
- inputText: "",
508
+ inputText: '',
507
509
  wasClicked: false, // prevents custom-name from being triggered on the <input-text />
508
510
  dynamicWidth: [], // for numbers
509
- dynamicGridWidth: [], // for grid values
511
+ dynamicGridWidth: [] // for grid values
510
512
  }
511
513
  },
512
514
  methods: {
@@ -516,19 +518,19 @@ export default {
516
518
  }
517
519
  this.wasClicked = false
518
520
  if (!this.isOpen) {
519
- document.addEventListener("click", this.clickOutside)
520
- this.$emit("dropdown-search", "")
521
+ document.addEventListener('click', this.clickOutside)
522
+ this.$emit('dropdown-search', '')
521
523
  this.$nextTick(() => {
522
524
  this.scrollToItem()
523
525
  })
524
- this.$emit("toggle-dropdown-open", { close: false })
526
+ this.$emit('toggle-dropdown-open', { close: false })
525
527
  this.$nextTick(() => {
526
528
  this.$refs.searchInput.$el.children[0].children[0].focus()
527
529
  })
528
530
  } else {
529
- document.removeEventListener("click", this.clickOutside)
530
- this.$emit("toggle-dropdown-open", { close: true })
531
- this.inputText = ""
531
+ document.removeEventListener('click', this.clickOutside)
532
+ this.$emit('toggle-dropdown-open', { close: true })
533
+ this.inputText = ''
532
534
  }
533
535
  },
534
536
  onInputClick() {
@@ -539,29 +541,29 @@ export default {
539
541
  scrollToItem() {
540
542
  if (this.$refs.optionsContainer) {
541
543
  this.$refs.optionsContainer.$el.scrollIntoView({
542
- behavior: "smooth",
543
- block: "center",
544
+ behavior: 'smooth',
545
+ block: 'center'
544
546
  })
545
547
  }
546
548
  },
547
549
  onTemplateClick(item) {
548
- this.$emit("on-template-click", item)
550
+ this.$emit('on-template-click', item)
549
551
  },
550
552
  onSelectedTemplateClick(item) {
551
- this.$emit("on-selected-template-click", item)
553
+ this.$emit('on-selected-template-click', item)
552
554
  },
553
555
  onItemClick(item) {
554
556
  this.wasClicked = true
555
- this.$emit("item-selected", item)
557
+ this.$emit('item-selected', item)
556
558
  },
557
559
  onSearch(value) {
558
560
  this.inputText = value
559
- this.$emit("dropdown-search", value)
561
+ this.$emit('dropdown-search', value)
560
562
  },
561
563
  getItemLocation(value) {
562
564
  let ref = this.$refs.dropdownItem[0]
563
565
  let location = ref.$el.getBoundingClientRect()[value]
564
- if (value === "top") {
566
+ if (value === 'top') {
565
567
  location = location + window.scrollY + 40
566
568
  }
567
569
  return location
@@ -570,34 +572,34 @@ export default {
570
572
  if (event.target === this.$el || this.$el.contains(event.target)) {
571
573
  return
572
574
  }
573
- this.inputText = ""
575
+ this.inputText = ''
574
576
  // 'close: true' is needed in case a box is open and another box is clicked on
575
577
  // so this one will close properly
576
- document.removeEventListener("click", this.clickOutside)
577
- this.$emit("toggle-dropdown-open", { close: true })
578
+ document.removeEventListener('click', this.clickOutside)
579
+ this.$emit('toggle-dropdown-open', { close: true })
578
580
  },
579
581
  onCustomNameClick() {
580
582
  this.wasClicked = true
581
- this.$emit("on-custom-input-name", this.inputText)
582
- this.$emit("toggle-dropdown-open", { close: true })
583
- this.inputText = ""
583
+ this.$emit('on-custom-input-name', this.inputText)
584
+ this.$emit('toggle-dropdown-open', { close: true })
585
+ this.inputText = ''
584
586
  },
585
587
  onCustomInputChange(event) {
586
588
  if (this.wasClicked) {
587
589
  return
588
590
  }
589
- this.$emit("custom-input-change", event)
591
+ this.$emit('custom-input-change', event)
590
592
  },
591
593
  setDropdownWidth(options) {
592
594
  this.dynamicWidth = []
593
595
  options.map((item) => {
594
596
  this.optionsDisplay.map((header, index) => {
595
597
  let value =
596
- header === "template"
597
- ? this.$gettext("No main component template")
598
+ header === 'template'
599
+ ? this.$gettext('No main component template')
598
600
  : item[header]
599
601
 
600
- value = !!value ? value : ""
602
+ value = !!value ? value : ''
601
603
 
602
604
  if (
603
605
  this.optionsDisplay.length &&
@@ -605,27 +607,27 @@ export default {
605
607
  value.length > this.dynamicWidth[index])
606
608
  ) {
607
609
  if (Array.isArray(this.dynamicGridWidth)) {
608
- this.dynamicGridWidth[index] = value.length + "ch"
610
+ this.dynamicGridWidth[index] = value.length + 'ch'
609
611
  }
610
612
  this.dynamicWidth[index] = value.length
611
613
  }
612
614
  })
613
615
  })
614
616
  if (this.dynamicGridWidth.length === this.optionsDisplay.length) {
615
- this.dynamicGridWidth = this.dynamicGridWidth.join(" ")
617
+ this.dynamicGridWidth = this.dynamicGridWidth.join(' ')
616
618
  }
617
- },
619
+ }
618
620
  },
619
621
  computed: {
620
622
  getCustomName() {
621
623
  return this.inputText
622
- },
624
+ }
623
625
  },
624
626
  watch: {
625
627
  isOpen(newVal) {
626
628
  if (newVal) {
627
- document.addEventListener("click", this.clickOutside)
628
- this.$emit("dropdown-search", "")
629
+ document.addEventListener('click', this.clickOutside)
630
+ this.$emit('dropdown-search', '')
629
631
  this.$nextTick(() => {
630
632
  this.$refs.searchInput.$el.children[0].children[0].focus()
631
633
  })
@@ -638,7 +640,7 @@ export default {
638
640
  if (val && val.length) {
639
641
  this.setDropdownWidth(val)
640
642
  }
641
- },
642
- },
643
+ }
644
+ }
643
645
  }
644
646
  </script>