@eturnity/eturnity_reusable_components 8.16.2--EPDM-14330.4 → 8.16.2--EPDM-14330.6
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 +1 -1
- package/src/assets/svgIcons/ac_power.svg +4 -0
- package/src/assets/svgIcons/arrow_long_left.svg +3 -0
- package/src/assets/svgIcons/arrow_long_right.svg +3 -0
- package/src/assets/svgIcons/chassis_ground_symbol.svg +27 -0
- package/src/assets/svgIcons/dc_power.svg +8 -0
- package/src/assets/svgIcons/double_arrow_long.svg +4 -0
- package/src/assets/svgIcons/ed_ac.svg +3 -0
- package/src/assets/svgIcons/ed_acgrid.svg +4 -0
- package/src/assets/svgIcons/ed_arrow_both.svg +7 -0
- package/src/assets/svgIcons/ed_arrow_left.svg +7 -0
- package/src/assets/svgIcons/ed_arrow_right.svg +7 -0
- package/src/assets/svgIcons/ed_battery.svg +10 -0
- package/src/assets/svgIcons/ed_batteryacinverter.svg +16 -0
- package/src/assets/svgIcons/ed_batteryintegratedinverter.svg +19 -0
- package/src/assets/svgIcons/ed_cirquitbreaker.svg +4 -0
- package/src/assets/svgIcons/ed_cirquitbreaker_magnetic.svg +6 -0
- package/src/assets/svgIcons/ed_cirquitbreaker_thermal.svg +4 -0
- package/src/assets/svgIcons/ed_cirquitbreaker_thermal_magnetic.svg +5 -0
- package/src/assets/svgIcons/ed_consumption.svg +3 -0
- package/src/assets/svgIcons/ed_dc.svg +6 -0
- package/src/assets/svgIcons/ed_disconnector.svg +4 -0
- package/src/assets/svgIcons/ed_disconnector_fuse.svg +4 -0
- package/src/assets/svgIcons/ed_disconnector_fuse_switch.svg +4 -0
- package/src/assets/svgIcons/ed_disconnector_loadbreak switch.svg +4 -0
- package/src/assets/svgIcons/ed_disconnector_switch.svg +4 -0
- package/src/assets/svgIcons/ed_disconnector_switch_auto_release.svg +5 -0
- package/src/assets/svgIcons/ed_energymanagement_rectangle.svg +3 -0
- package/src/assets/svgIcons/ed_evcharger.svg +19 -0
- package/src/assets/svgIcons/ed_flexiblecomponent_circle.svg +3 -0
- package/src/assets/svgIcons/ed_flexiblecomponent_square.svg +3 -0
- package/src/assets/svgIcons/ed_fuse.svg +3 -0
- package/src/assets/svgIcons/ed_ground.svg +5 -0
- package/src/assets/svgIcons/ed_heatpump.svg +4 -0
- package/src/assets/svgIcons/ed_icon_battery.svg +9 -0
- package/src/assets/svgIcons/ed_icon_circle.svg +3 -0
- package/src/assets/svgIcons/ed_icon_heatpump.svg +3 -0
- package/src/assets/svgIcons/ed_icon_inverter.svg +8 -0
- package/src/assets/svgIcons/ed_icon_optimizer.svg +11 -0
- package/src/assets/svgIcons/ed_integratedbatteryinverter.svg +10 -0
- package/src/assets/svgIcons/ed_inverter-blank.svg +3 -0
- package/src/assets/svgIcons/ed_mainsconnection.svg +3 -0
- package/src/assets/svgIcons/ed_meter_arrowleft.svg +4 -0
- package/src/assets/svgIcons/ed_meter_arrowright.svg +4 -0
- package/src/assets/svgIcons/ed_meter_bidirectional.svg +5 -0
- package/src/assets/svgIcons/ed_networkandsystemprotection_double.svg +14 -0
- package/src/assets/svgIcons/ed_networkandsystemprotection_single.svg +7 -0
- package/src/assets/svgIcons/ed_pvpanel.svg +7 -0
- package/src/assets/svgIcons/ed_rcd.svg +5 -0
- package/src/assets/svgIcons/ed_rcd_simple.svg +3 -0
- package/src/assets/svgIcons/ed_spd.svg +6 -0
- package/src/assets/svgIcons/ed_stringwithoptimizer.svg +33 -0
- package/src/assets/svgIcons/ed_stringwithoutoptimizer.svg +17 -0
- package/src/assets/svgIcons/ed_transformer.svg +3 -0
- package/src/assets/svgIcons/filter.svg +3 -0
- package/src/assets/svgIcons/ground_symbol.svg +28 -0
- package/src/assets/svgIcons/move_left.svg +3 -0
- package/src/assets/svgIcons/move_right.svg +3 -0
- package/src/assets/svgIcons/rectangle.svg +3 -0
- package/src/assets/svgIcons/refresh.svg +3 -0
- package/src/assets/svgIcons/text_icon.svg +3 -0
- package/src/assets/theme.js +17 -1
- package/src/components/banner/infoBanner/InfoBanner.spec.js +29 -42
- package/src/components/barchart/BottomFields.vue +253 -0
- package/src/components/barchart/ChartControls.vue +113 -0
- package/src/components/barchart/SelectionBox.vue +150 -0
- package/src/components/barchart/composables/index.js +5 -0
- package/src/components/barchart/composables/useAxisCalculations.js +104 -0
- package/src/components/barchart/composables/useChartData.js +114 -0
- package/src/components/barchart/composables/useChartScroll.js +61 -0
- package/src/components/barchart/composables/useSelection.js +75 -0
- package/src/components/barchart/composables/useTooltip.js +100 -0
- package/src/components/barchart/index.vue +385 -0
- package/src/components/barchart/styles/bottomFields.js +66 -0
- package/src/components/barchart/styles/chart.js +272 -0
- package/src/components/barchart/styles/chartControls.js +59 -0
- package/src/components/buttons/buttonIcon/index.vue +5 -0
- package/src/components/buttons/splitButtons/index.vue +86 -0
- package/src/components/collapsableInfoText/index.vue +2 -2
- package/src/components/errorMessage/errorMessage.spec.js +34 -0
- package/src/components/errorMessage/errorMessage.stories.js +35 -0
- package/src/components/filter/filterSettings.vue +2 -0
- package/src/components/filterComponent/viewFilter.vue +577 -0
- package/src/components/filterComponent/viewSort.vue +242 -12
- package/src/components/icon/index.vue +32 -9
- package/src/components/infoText/index.vue +2 -2
- package/src/components/infoText/infoText.spec.js +6 -1
- package/src/components/inputs/inputNumber/index.vue +14 -2
- package/src/components/inputs/searchInput/index.vue +18 -2
- package/src/components/inputs/select/index.vue +109 -19
- package/src/components/inputs/select/option/index.vue +5 -0
- package/src/components/modals/actionModal/actionModal.spec.js +52 -0
- package/src/components/modals/actionModal/actionModal.stories.js +53 -0
- package/src/components/modals/actionModal/index.vue +6 -6
- package/src/components/modals/infoModal/index.vue +49 -19
- package/src/components/modals/infoModal/infoModal.spec.js +55 -0
- package/src/components/modals/infoModal/infoModal.stories.js +47 -0
- package/src/components/modals/modal/index.vue +16 -5
- package/src/components/pageSubtitle/PageSubtitle.stories.js +0 -1
- package/src/helpers/isObjectEqual.js +22 -0
- package/src/helpers/translateLang.js +95 -24
- package/src/main.js +1 -0
@@ -109,11 +109,7 @@
|
|
109
109
|
>
|
110
110
|
<slot name="selector" :selected-value="selectedValue"></slot>
|
111
111
|
</Selector>
|
112
|
-
<Caret
|
113
|
-
class="caret_dropdown"
|
114
|
-
:color-mode="colorMode"
|
115
|
-
@click.stop="toggleCaretDropdown"
|
116
|
-
>
|
112
|
+
<Caret class="caret_dropdown" :color-mode="colorMode">
|
117
113
|
<Icon
|
118
114
|
v-if="isDropdownOpen"
|
119
115
|
:color="
|
@@ -137,17 +133,19 @@
|
|
137
133
|
</Caret>
|
138
134
|
</SelectButton>
|
139
135
|
<DropdownWrapper ref="dropdownWrapperRef" :no-relative="noRelative">
|
140
|
-
<
|
136
|
+
<Component
|
137
|
+
:is="shouldUseTeleport ? 'Teleport' : 'div'"
|
138
|
+
:to="shouldUseTeleport ? 'body' : undefined"
|
139
|
+
>
|
141
140
|
<SelectDropdown
|
142
141
|
v-show="isSelectDropdownShown"
|
143
142
|
ref="dropdown"
|
144
143
|
:bg-color="
|
145
|
-
|
146
|
-
colorMode == 'dark' ||
|
147
|
-
colorMode == 'transparent'
|
144
|
+
colorMode == 'dark' || colorMode == 'transparent'
|
148
145
|
? 'black'
|
149
146
|
: 'white'
|
150
147
|
"
|
148
|
+
class="rc-select-dropdown"
|
151
149
|
:dropdown-position="dropdownPosition"
|
152
150
|
:font-color="
|
153
151
|
dropdownFontColor ||
|
@@ -167,17 +165,30 @@
|
|
167
165
|
:hovered-index="hoveredIndex"
|
168
166
|
:hovered-value="hoveredValue"
|
169
167
|
:is-active="isActive"
|
168
|
+
:is-fixed-dropdown-position="isFixedDropdownPosition"
|
169
|
+
:is-parent-modal="isParentModal"
|
170
|
+
:is-teleport="shouldUseTeleport"
|
170
171
|
:min-width="minWidth"
|
171
172
|
:no-relative="noRelative"
|
172
173
|
:option-width="getOptionWidth"
|
173
174
|
:selected-value="selectedValue"
|
175
|
+
:style="
|
176
|
+
shouldUseTeleport
|
177
|
+
? {
|
178
|
+
transform: `translate(${dropdownPosition?.left}px, ${
|
179
|
+
noRelative ? 'auto' : `${dropdownPosition?.top}px`
|
180
|
+
})`,
|
181
|
+
}
|
182
|
+
: undefined
|
183
|
+
"
|
184
|
+
@click.stop
|
174
185
|
@mouseleave="optionLeave"
|
175
186
|
@option-hovered="optionHovered"
|
176
187
|
@option-selected="optionSelected"
|
177
188
|
>
|
178
189
|
<slot name="dropdown"></slot>
|
179
190
|
</SelectDropdown>
|
180
|
-
</
|
191
|
+
</Component>
|
181
192
|
</DropdownWrapper>
|
182
193
|
</SelectButtonWrapper>
|
183
194
|
</InputWrapper>
|
@@ -208,7 +219,7 @@
|
|
208
219
|
// </template>
|
209
220
|
// </Select>
|
210
221
|
|
211
|
-
import { Teleport } from 'vue'
|
222
|
+
import { Teleport, inject } from 'vue'
|
212
223
|
import styled from 'vue3-styled-components'
|
213
224
|
import InfoText from '../../infoText'
|
214
225
|
import Icon from '../../icon'
|
@@ -392,14 +403,18 @@
|
|
392
403
|
selectedValue: Number | String,
|
393
404
|
noRelative: Boolean,
|
394
405
|
minWidth: String,
|
406
|
+
isParentModal: Boolean,
|
407
|
+
isFixedDropdownPosition: Boolean,
|
408
|
+
isTeleport: Boolean,
|
395
409
|
}
|
396
410
|
const SelectDropdown = styled('div', selectDropdownAttrs)`
|
397
411
|
box-sizing: border-box;
|
398
|
-
z-index: ${(props) =>
|
399
|
-
|
400
|
-
|
401
|
-
props.
|
402
|
-
|
412
|
+
z-index: ${(props) =>
|
413
|
+
props.isActive ? '2' : props.isParentModal ? '9999999' : '99999'};
|
414
|
+
position: ${(props) =>
|
415
|
+
props.isFixedDropdownPosition ? 'fixed' : 'absolute'};
|
416
|
+
top: ${(props) => (props.isTeleport ? '0px' : '4px')};
|
417
|
+
left: 0px;
|
403
418
|
border: ${BORDER_WIDTH} solid ${(props) => props.theme.colors.grey4};
|
404
419
|
border-radius: 4px;
|
405
420
|
display: flex;
|
@@ -647,6 +662,23 @@
|
|
647
662
|
type: String,
|
648
663
|
required: false,
|
649
664
|
},
|
665
|
+
isFixedDropdownPosition: {
|
666
|
+
type: Boolean,
|
667
|
+
required: false,
|
668
|
+
default: false,
|
669
|
+
},
|
670
|
+
shouldUseTeleport: {
|
671
|
+
type: Boolean,
|
672
|
+
required: false,
|
673
|
+
default: true,
|
674
|
+
},
|
675
|
+
},
|
676
|
+
setup() {
|
677
|
+
const modalRef = inject('modalRef')
|
678
|
+
|
679
|
+
return {
|
680
|
+
modalRef,
|
681
|
+
}
|
650
682
|
},
|
651
683
|
|
652
684
|
data() {
|
@@ -664,6 +696,10 @@
|
|
664
696
|
},
|
665
697
|
dropdownWidth: null,
|
666
698
|
hoveredValue: null,
|
699
|
+
isDisplayedAtBottom: true,
|
700
|
+
selectTopPosition: 0,
|
701
|
+
selectAndDropdownDistance: 0,
|
702
|
+
animationFrameId: null,
|
667
703
|
}
|
668
704
|
},
|
669
705
|
computed: {
|
@@ -721,6 +757,9 @@
|
|
721
757
|
/windows phone/i.test(userAgent)
|
722
758
|
)
|
723
759
|
},
|
760
|
+
isParentModal() {
|
761
|
+
return !!this.modalRef
|
762
|
+
},
|
724
763
|
},
|
725
764
|
watch: {
|
726
765
|
value(val) {
|
@@ -734,8 +773,13 @@
|
|
734
773
|
}, 10)
|
735
774
|
await this.$nextTick()
|
736
775
|
this.handleSetDropdownOffet()
|
776
|
+
if (!this.isFixedDropdownPosition) this.calculateSelectTopPosition()
|
737
777
|
} else {
|
738
778
|
this.dropdownPosition.left = null
|
779
|
+
if (this.animationFrameId) {
|
780
|
+
cancelAnimationFrame(this.animationFrameId)
|
781
|
+
this.animationFrameId = null
|
782
|
+
}
|
739
783
|
setTimeout(() => {
|
740
784
|
this.isClickOutsideActive = false
|
741
785
|
}, 10)
|
@@ -748,11 +792,30 @@
|
|
748
792
|
})
|
749
793
|
}
|
750
794
|
},
|
795
|
+
isSelectDropdownShown(isShown) {
|
796
|
+
if (!isShown) return
|
797
|
+
// Need to wait for 1ms to make sure the dropdown menu is shown in the DOM
|
798
|
+
// before getting the distance between the select and the dropdown menu
|
799
|
+
setTimeout(() => {
|
800
|
+
this.getDistanceBetweenSelectAndDropdownMenu()
|
801
|
+
}, 100)
|
802
|
+
},
|
803
|
+
selectTopPosition() {
|
804
|
+
this.dropdownPosition.top =
|
805
|
+
this.selectTopPosition +
|
806
|
+
this.$refs.select.$el.clientHeight +
|
807
|
+
this.selectAndDropdownDistance
|
808
|
+
},
|
751
809
|
},
|
752
810
|
mounted() {
|
753
811
|
this.observeDropdownHeight()
|
754
812
|
this.observeSelectWidth()
|
755
813
|
window.addEventListener('resize', this.handleSetDropdownOffet)
|
814
|
+
if (!this.isFixedDropdownPosition)
|
815
|
+
document.body.addEventListener(
|
816
|
+
'scroll',
|
817
|
+
this.calculateSelectTopPosition
|
818
|
+
)
|
756
819
|
},
|
757
820
|
beforeMount() {
|
758
821
|
this.selectedValue = this.value
|
@@ -761,6 +824,12 @@
|
|
761
824
|
window.removeEventListener('resize', this.handleSetDropdownOffet)
|
762
825
|
if (this.dropdownResizeObserver) this.dropdownResizeObserver.disconnect()
|
763
826
|
if (this.selectResizeObserver) this.selectResizeObserver.disconnect()
|
827
|
+
if (!this.isFixedDropdownPosition) {
|
828
|
+
document.body.removeEventListener(
|
829
|
+
'scroll',
|
830
|
+
this.calculateSelectTopPosition
|
831
|
+
)
|
832
|
+
}
|
764
833
|
},
|
765
834
|
unmounted() {
|
766
835
|
document.removeEventListener('click', this.clickOutside)
|
@@ -836,7 +905,9 @@
|
|
836
905
|
this.$refs.select.$el == event.target ||
|
837
906
|
this.$refs.select.$el.contains(event.target) ||
|
838
907
|
event.target.id === 'more-button' ||
|
839
|
-
event.target.
|
908
|
+
event.target.closest('.options-container') ||
|
909
|
+
event.target.parentNode === dropdownRef.$el ||
|
910
|
+
dropdownRef.$el.contains(event.target)
|
840
911
|
) {
|
841
912
|
return
|
842
913
|
} else {
|
@@ -866,11 +937,11 @@
|
|
866
937
|
return
|
867
938
|
}
|
868
939
|
await this.$nextTick()
|
869
|
-
|
940
|
+
this.isDisplayedAtBottom = await this.generateDropdownPosition()
|
870
941
|
// If the dropdown menu is going to be displayed at the bottom,
|
871
942
|
// we need reverify its position after a dom update (nextTick)
|
872
943
|
await this.$nextTick()
|
873
|
-
if (isDisplayedAtBottom) this.generateDropdownPosition()
|
944
|
+
if (this.isDisplayedAtBottom) this.generateDropdownPosition()
|
874
945
|
},
|
875
946
|
async generateDropdownPosition() {
|
876
947
|
const isDropdownNotCompletelyVisible =
|
@@ -963,6 +1034,25 @@
|
|
963
1034
|
}
|
964
1035
|
}
|
965
1036
|
},
|
1037
|
+
getDistanceBetweenSelectAndDropdownMenu() {
|
1038
|
+
const wholeSelectTopPosition =
|
1039
|
+
this.selectTopPosition + this.$refs.select.$el.clientHeight
|
1040
|
+
this.selectAndDropdownDistance =
|
1041
|
+
this.dropdownPosition.top - wholeSelectTopPosition
|
1042
|
+
},
|
1043
|
+
calculateSelectTopPosition() {
|
1044
|
+
const selectRef = this.$refs.select
|
1045
|
+
if (selectRef) {
|
1046
|
+
const currentTopPosition =
|
1047
|
+
selectRef.$el.getBoundingClientRect().top + window.scrollY
|
1048
|
+
if (this.selectTopPosition !== currentTopPosition) {
|
1049
|
+
this.selectTopPosition = currentTopPosition
|
1050
|
+
}
|
1051
|
+
}
|
1052
|
+
this.animationFrameId = requestAnimationFrame(
|
1053
|
+
this.calculateSelectTopPosition
|
1054
|
+
)
|
1055
|
+
},
|
966
1056
|
},
|
967
1057
|
}
|
968
1058
|
</script>
|
@@ -0,0 +1,52 @@
|
|
1
|
+
/* eslint-disable */
|
2
|
+
import { mount } from '@vue/test-utils'
|
3
|
+
import ActionModal from '@/components/modals/actionModal'
|
4
|
+
import theme from '@/assets/theme'
|
5
|
+
|
6
|
+
describe('ActionModal Component', () => {
|
7
|
+
let wrapper
|
8
|
+
|
9
|
+
beforeEach(() => {
|
10
|
+
wrapper = mount(ActionModal, {
|
11
|
+
props: {
|
12
|
+
isOpen: true,
|
13
|
+
buttonText: 'Close',
|
14
|
+
},
|
15
|
+
slots: {
|
16
|
+
title: 'Sample title',
|
17
|
+
body: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed tincidunt commodo mollis. Fusce urna felis, malesuada sed elementum et, fermentum ac massa. Integer in massa vel orci fermentum bibendum in ut ante. Donec risus risus, luctus quis ex a, pulvinar placerat lacus. Sed pharetra augue a elit volutpat, eu dignissim ex pretium. Aenean imperdiet, nulla in pharetra rutrum, mauris mauris tincidunt tellus, non tempus quam lorem laoreet lectus.',
|
18
|
+
buttons: '<button @click="closeAction">Close</button>',
|
19
|
+
},
|
20
|
+
global: {
|
21
|
+
provide: {
|
22
|
+
theme,
|
23
|
+
},
|
24
|
+
},
|
25
|
+
})
|
26
|
+
})
|
27
|
+
|
28
|
+
test('renders ActionModal component with default props', () => {
|
29
|
+
expect(wrapper.find('[data-test-id="actionModal"]').exists()).toBe(true)
|
30
|
+
|
31
|
+
expect(wrapper.vm.isOpen).toBe(true)
|
32
|
+
})
|
33
|
+
|
34
|
+
test('action modal slots is display when user passed slots content', () => {
|
35
|
+
const modalTitleEl = wrapper.find('[data-test-id="modal_title"]')
|
36
|
+
expect(modalTitleEl.text()).toBe('Sample title')
|
37
|
+
|
38
|
+
const modalBodyEl = wrapper.find('[data-test-id="modal_body"]')
|
39
|
+
expect(modalBodyEl.text()).toContain('Lorem ipsum dolor sit amet')
|
40
|
+
|
41
|
+
const modalActionButton = wrapper.find('[data-test-id="modal_buttons"]')
|
42
|
+
expect(modalActionButton.text()).toContain('Close')
|
43
|
+
})
|
44
|
+
|
45
|
+
test('action modal on-close event is emitted when modal close button is clicked', async () => {
|
46
|
+
const modalCloseButton = wrapper.find('.close')
|
47
|
+
|
48
|
+
modalCloseButton.trigger('click')
|
49
|
+
await wrapper.vm.$nextTick()
|
50
|
+
expect(wrapper.emitted('on-close')).toBeTruthy()
|
51
|
+
})
|
52
|
+
})
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import ActionModal from './index.vue'
|
2
|
+
|
3
|
+
export default {
|
4
|
+
title: 'Components/ActionModal',
|
5
|
+
component: ActionModal,
|
6
|
+
tags: ['autodocs'],
|
7
|
+
parameters: {
|
8
|
+
layout: 'centered',
|
9
|
+
},
|
10
|
+
}
|
11
|
+
|
12
|
+
// import ActionModal from "@eturnity/eturnity_reusable_components/src/components/modals/ActionModal"
|
13
|
+
// This is a reusable modal component that can be used to display information to the user.
|
14
|
+
// To use:
|
15
|
+
// <ActionModal :isOpen="isOpen" @on-close="$emit('on-close-summary')" >
|
16
|
+
// <template #title>
|
17
|
+
// <h1>Header</h1>
|
18
|
+
// </template>
|
19
|
+
// <template #body>
|
20
|
+
// <p>Body</p>
|
21
|
+
// </template>
|
22
|
+
// <template #buttons>
|
23
|
+
// <button @click="closeModal">Close</button>
|
24
|
+
// </template>
|
25
|
+
// </ActionModal>
|
26
|
+
|
27
|
+
export const Default = {
|
28
|
+
args: {
|
29
|
+
isOpen: true,
|
30
|
+
},
|
31
|
+
render: (args) => ({
|
32
|
+
components: { ActionModal },
|
33
|
+
setup() {
|
34
|
+
return { args }
|
35
|
+
},
|
36
|
+
template: `
|
37
|
+
<ActionModal v-bind="args">
|
38
|
+
<template #title>Sample title</template>
|
39
|
+
<template #body>
|
40
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed tincidunt commodo mollis. Fusce urna felis,
|
41
|
+
malesuada sed elementum et, fermentum ac massa. Integer in massa vel orci fermentum bibendum in ut ante.
|
42
|
+
Donec risus risus, luctus quis ex a, pulvinar placerat lacus. Sed pharetra augue a elit volutpat, eu dignissim
|
43
|
+
ex pretium. Aenean imperdiet, nulla in pharetra rutrum, mauris mauris tincidunt tellus, non tempus quam lorem
|
44
|
+
laoreet lectus.
|
45
|
+
</template>
|
46
|
+
<template #buttons>
|
47
|
+
<button @click="saveAction">Save</button>
|
48
|
+
<button @click="closeAction">Close</button>
|
49
|
+
</template>
|
50
|
+
</ActionModal>
|
51
|
+
`,
|
52
|
+
}),
|
53
|
+
}
|
@@ -1,13 +1,13 @@
|
|
1
1
|
<template>
|
2
|
-
<Modal :is-open="isOpen" @on-close="closeModal">
|
2
|
+
<Modal data-test-id="actionModal" :is-open="isOpen" @on-close="closeModal">
|
3
3
|
<ModalContainer>
|
4
|
-
<ModalTitle v-if="$slots.title">
|
4
|
+
<ModalTitle v-if="$slots.title" data-test-id="modal_title">
|
5
5
|
<slot name="title"></slot>
|
6
6
|
</ModalTitle>
|
7
|
-
<TextContainer v-if="$slots.body">
|
7
|
+
<TextContainer v-if="$slots.body" data-test-id="modal_body">
|
8
8
|
<slot name="body"></slot>
|
9
9
|
</TextContainer>
|
10
|
-
<ButtonContainer v-if="$slots.buttons">
|
10
|
+
<ButtonContainer v-if="$slots.buttons" data-test-id="modal_buttons">
|
11
11
|
<slot name="buttons"></slot>
|
12
12
|
</ButtonContainer>
|
13
13
|
</ModalContainer>
|
@@ -23,7 +23,7 @@
|
|
23
23
|
`
|
24
24
|
const ModalTitle = styled.div`
|
25
25
|
color: ${(props) => props.theme.colors.black};
|
26
|
-
font-family:
|
26
|
+
font-family: inherit;
|
27
27
|
font-size: 18px;
|
28
28
|
font-style: normal;
|
29
29
|
font-weight: 700;
|
@@ -37,7 +37,7 @@
|
|
37
37
|
`
|
38
38
|
const TextContainer = styled.div`
|
39
39
|
color: ${(props) => props.theme.colors.black};
|
40
|
-
font-family:
|
40
|
+
font-family: inherit;
|
41
41
|
font-size: 13px;
|
42
42
|
font-style: normal;
|
43
43
|
font-weight: 400;
|
@@ -1,48 +1,78 @@
|
|
1
1
|
<template>
|
2
|
-
<
|
2
|
+
<RCModal data-test-id="infoModal" :is-open="isOpen" @on-close="closeModal">
|
3
3
|
<ModalContainer>
|
4
|
-
<
|
4
|
+
<ModalTitle v-if="$slots.title" data-test-id="modal_title">
|
5
5
|
<slot name="title"></slot>
|
6
|
-
</
|
7
|
-
<
|
6
|
+
</ModalTitle>
|
7
|
+
<TextContainer v-if="$slots.body" data-test-id="modal_body">
|
8
8
|
<slot name="body"></slot>
|
9
|
-
</
|
10
|
-
<
|
11
|
-
<
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
</ButtonContainer>
|
19
|
-
</template>
|
9
|
+
</TextContainer>
|
10
|
+
<ButtonContainer>
|
11
|
+
<RCMainButton
|
12
|
+
min-width="150px"
|
13
|
+
:text="buttonText"
|
14
|
+
type="primary"
|
15
|
+
@click="closeModal"
|
16
|
+
/>
|
17
|
+
</ButtonContainer>
|
20
18
|
</ModalContainer>
|
21
|
-
</
|
19
|
+
</RCModal>
|
22
20
|
</template>
|
23
21
|
<script>
|
24
22
|
import styled from 'vue3-styled-components'
|
25
|
-
import
|
23
|
+
import RCModal from '../modal'
|
26
24
|
import RCMainButton from '../../buttons/mainButton'
|
25
|
+
|
27
26
|
const ModalContainer = styled.div`
|
28
27
|
width: 450px;
|
29
28
|
min-height: 205px;
|
30
29
|
padding: 40px 40px 30px 40px;
|
31
30
|
`
|
31
|
+
const ModalTitle = styled.div`
|
32
|
+
color: ${(props) => props.theme.colors.black};
|
33
|
+
font-family: inherit;
|
34
|
+
font-size: 18px;
|
35
|
+
font-style: normal;
|
36
|
+
font-weight: 700;
|
37
|
+
line-height: 120%;
|
38
|
+
text-transform: uppercase;
|
39
|
+
`
|
32
40
|
const ButtonContainer = styled.div`
|
33
41
|
display: inline-flex;
|
34
42
|
align-items: flex-start;
|
35
43
|
gap: 20px;
|
36
44
|
`
|
45
|
+
const TextContainer = styled.div`
|
46
|
+
color: ${(props) => props.theme.colors.black};
|
47
|
+
font-family: inherit;
|
48
|
+
font-size: 13px;
|
49
|
+
font-style: normal;
|
50
|
+
font-weight: 400;
|
51
|
+
line-height: normal;
|
52
|
+
padding: 30px 0px;
|
53
|
+
white-space: pre-wrap;
|
54
|
+
`
|
55
|
+
|
37
56
|
export default {
|
38
57
|
name: 'InfoModal',
|
39
58
|
components: {
|
59
|
+
RCModal,
|
40
60
|
ModalContainer,
|
61
|
+
ModalTitle,
|
41
62
|
ButtonContainer,
|
42
|
-
|
63
|
+
TextContainer,
|
43
64
|
RCMainButton,
|
44
65
|
},
|
45
|
-
props:
|
66
|
+
props: {
|
67
|
+
isOpen: {
|
68
|
+
type: Boolean,
|
69
|
+
required: true,
|
70
|
+
},
|
71
|
+
buttonText: {
|
72
|
+
type: String,
|
73
|
+
default: 'Got it',
|
74
|
+
},
|
75
|
+
},
|
46
76
|
methods: {
|
47
77
|
closeModal() {
|
48
78
|
this.$emit('on-close')
|
@@ -0,0 +1,55 @@
|
|
1
|
+
/* eslint-disable */
|
2
|
+
import { mount } from '@vue/test-utils'
|
3
|
+
import InfoModal from '@/components/modals/infoModal'
|
4
|
+
import theme from '@/assets/theme'
|
5
|
+
|
6
|
+
jest.mock('@/components/icon/iconCache.mjs', () => ({
|
7
|
+
// need to mock this due to how jest handles import.meta
|
8
|
+
fetchIcon: jest.fn(() => Promise.resolve('')),
|
9
|
+
}))
|
10
|
+
|
11
|
+
|
12
|
+
describe('InfoModal Component', () => {
|
13
|
+
let wrapper
|
14
|
+
|
15
|
+
beforeEach(() => {
|
16
|
+
wrapper = mount(InfoModal, {
|
17
|
+
props: {
|
18
|
+
isOpen: true,
|
19
|
+
buttonText: 'Close',
|
20
|
+
},
|
21
|
+
slots: {
|
22
|
+
title: 'Sample title',
|
23
|
+
body: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed tincidunt commodo mollis. Fusce urna felis, malesuada sed elementum et, fermentum ac massa. Integer in massa vel orci fermentum bibendum in ut ante. Donec risus risus, luctus quis ex a, pulvinar placerat lacus. Sed pharetra augue a elit volutpat, eu dignissim ex pretium. Aenean imperdiet, nulla in pharetra rutrum, mauris mauris tincidunt tellus, non tempus quam lorem laoreet lectus.',
|
24
|
+
},
|
25
|
+
global: {
|
26
|
+
provide: {
|
27
|
+
theme,
|
28
|
+
},
|
29
|
+
},
|
30
|
+
})
|
31
|
+
})
|
32
|
+
|
33
|
+
test('renders InfoModal component with default props', () => {
|
34
|
+
expect(wrapper.find('[data-test-id="infoModal"]').exists()).toBe(true)
|
35
|
+
|
36
|
+
expect(wrapper.vm.isOpen).toBe(true)
|
37
|
+
expect(wrapper.vm.buttonText).toContain('Close')
|
38
|
+
})
|
39
|
+
|
40
|
+
test('info modal slots is display when user passed slots content', () => {
|
41
|
+
const modalTitleEl = wrapper.find('[data-test-id="modal_title"]')
|
42
|
+
expect(modalTitleEl.text()).toBe('Sample title')
|
43
|
+
|
44
|
+
const modalBodyEl = wrapper.find('[data-test-id="modal_body"]')
|
45
|
+
expect(modalBodyEl.text()).toContain('Lorem ipsum dolor sit amet')
|
46
|
+
})
|
47
|
+
|
48
|
+
test('info modal on-close event is emitted when modal close button is clicked', async () => {
|
49
|
+
const modalCloseButton = wrapper.find('.close')
|
50
|
+
|
51
|
+
modalCloseButton.trigger('click')
|
52
|
+
await wrapper.vm.$nextTick()
|
53
|
+
expect(wrapper.emitted('on-close')).toBeTruthy()
|
54
|
+
})
|
55
|
+
})
|
@@ -0,0 +1,47 @@
|
|
1
|
+
import InfoModal from './index.vue'
|
2
|
+
|
3
|
+
export default {
|
4
|
+
title: 'Components/InfoModal',
|
5
|
+
component: InfoModal,
|
6
|
+
tags: ['autodocs'],
|
7
|
+
parameters: {
|
8
|
+
layout: 'centered',
|
9
|
+
},
|
10
|
+
}
|
11
|
+
|
12
|
+
// import InfoModal from "@eturnity/eturnity_reusable_components/src/components/modals/infoModal"
|
13
|
+
// This is a reusable modal component that can be used to display information to the user.
|
14
|
+
// To use:
|
15
|
+
// <InfoModal :isOpen="isOpen" @on-close="$emit('on-close-summary')" >
|
16
|
+
// <template #title>
|
17
|
+
// <h1>Header</h1>
|
18
|
+
// </template>
|
19
|
+
// <template #body>
|
20
|
+
// <p>Body</p>
|
21
|
+
// </template>
|
22
|
+
// </InfoModal>
|
23
|
+
|
24
|
+
export const Default = {
|
25
|
+
args: {
|
26
|
+
isOpen: true,
|
27
|
+
buttonText: 'Close',
|
28
|
+
},
|
29
|
+
render: (args) => ({
|
30
|
+
components: { InfoModal },
|
31
|
+
setup() {
|
32
|
+
return { args }
|
33
|
+
},
|
34
|
+
template: `
|
35
|
+
<InfoModal v-bind="args">
|
36
|
+
<template #title>Sample title</template>
|
37
|
+
<template #body>
|
38
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed tincidunt commodo mollis. Fusce urna felis,
|
39
|
+
malesuada sed elementum et, fermentum ac massa. Integer in massa vel orci fermentum bibendum in ut ante.
|
40
|
+
Donec risus risus, luctus quis ex a, pulvinar placerat lacus. Sed pharetra augue a elit volutpat, eu dignissim
|
41
|
+
ex pretium. Aenean imperdiet, nulla in pharetra rutrum, mauris mauris tincidunt tellus, non tempus quam lorem
|
42
|
+
laoreet lectus.
|
43
|
+
</template>
|
44
|
+
</InfoModal>
|
45
|
+
`,
|
46
|
+
}),
|
47
|
+
}
|
@@ -1,8 +1,10 @@
|
|
1
1
|
<template>
|
2
2
|
<PageWrapper
|
3
3
|
v-if="isOpen"
|
4
|
+
ref="modalRef"
|
4
5
|
:add-padding-top="addPaddingTop"
|
5
6
|
:backdrop="backdrop"
|
7
|
+
class="rc-modal-wrapper"
|
6
8
|
:is-open="isOpen"
|
7
9
|
:position="position"
|
8
10
|
>
|
@@ -36,6 +38,7 @@
|
|
36
38
|
// <div>Data....</div>
|
37
39
|
// </modal>
|
38
40
|
|
41
|
+
import { ref, provide } from 'vue'
|
39
42
|
import styled from 'vue3-styled-components'
|
40
43
|
import CloseButton from '../../buttons/closeButton'
|
41
44
|
import Spinner from '../../spinner'
|
@@ -58,14 +61,14 @@
|
|
58
61
|
props.backdrop == 'dark'
|
59
62
|
? 'rgba(0, 0, 0, 0.4)'
|
60
63
|
: 'rgba(255, 255, 255, 0.9)'};
|
61
|
-
z-index:
|
64
|
+
z-index: 9999999;
|
62
65
|
overflow: auto;
|
63
66
|
padding-top: ${(props) => (props.addPaddingTop ? '80px' : '0')};
|
64
67
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
`
|
68
|
+
@media (max-width: 425px) {
|
69
|
+
background: white;
|
70
|
+
}
|
71
|
+
`
|
69
72
|
|
70
73
|
const modalContainerAttrs = { overflow: String, isLoading: Boolean }
|
71
74
|
const ModalContainer = styled('div', modalContainerAttrs)`
|
@@ -163,6 +166,14 @@
|
|
163
166
|
default: false,
|
164
167
|
},
|
165
168
|
},
|
169
|
+
setup() {
|
170
|
+
const modalRef = ref(null)
|
171
|
+
provide('modalRef', modalRef)
|
172
|
+
|
173
|
+
return {
|
174
|
+
modalRef,
|
175
|
+
}
|
176
|
+
},
|
166
177
|
watch: {
|
167
178
|
isOpen: {
|
168
179
|
immediate: true,
|