@eturnity/eturnity_reusable_components 8.13.13-epic-shading.1 → 8.13.13-qa-16-03-26.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.
Files changed (34) hide show
  1. package/package.json +1 -1
  2. package/src/DemoCharts.vue +424 -0
  3. package/src/TestChart.vue +241 -0
  4. package/src/assets/svgIcons/refresh.svg +3 -0
  5. package/src/assets/theme.js +16 -1
  6. package/src/components/barchart/BottomFields.vue +253 -0
  7. package/src/components/barchart/ChartControls.vue +113 -0
  8. package/src/components/barchart/SelectionBox.vue +150 -0
  9. package/src/components/barchart/composables/index.js +5 -0
  10. package/src/components/barchart/composables/useAxisCalculations.js +104 -0
  11. package/src/components/barchart/composables/useChartData.js +114 -0
  12. package/src/components/barchart/composables/useChartScroll.js +61 -0
  13. package/src/components/barchart/composables/useSelection.js +75 -0
  14. package/src/components/barchart/composables/useTooltip.js +100 -0
  15. package/src/components/barchart/index.vue +376 -0
  16. package/src/components/barchart/styles/bottomFields.js +66 -0
  17. package/src/components/barchart/styles/chart.js +259 -0
  18. package/src/components/barchart/styles/chartControls.js +59 -0
  19. package/src/components/buttons/splitButtons/index.vue +86 -0
  20. package/src/components/collapsableInfoText/index.vue +2 -2
  21. package/src/components/inputs/checkbox/index.vue +2 -2
  22. package/src/components/inputs/inputNumber/index.vue +78 -80
  23. package/src/components/inputs/select/index.vue +89 -16
  24. package/src/components/modals/modal/index.vue +15 -5
  25. package/src/helpers/isObjectEqual.js +22 -0
  26. package/src/helpers/numberConverter.js +1 -1
  27. package/src/main.js +8 -0
  28. package/src/router/dynamicRoutes.js +12 -0
  29. package/src/assets/icons/collapse_arrow_icon_white.svg +0 -1
  30. package/src/assets/svgIcons/house_sun.svg +0 -3
  31. package/src/components/draggableCard/defaultProps.js +0 -16
  32. package/src/components/draggableCard/draggableCard.spec.js +0 -99
  33. package/src/components/draggableCard/draggableCard.stories.js +0 -79
  34. package/src/components/draggableCard/index.vue +0 -363
@@ -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="
@@ -142,12 +138,11 @@
142
138
  v-show="isSelectDropdownShown"
143
139
  ref="dropdown"
144
140
  :bg-color="
145
- dropdownBgColor ||
146
- colorMode == 'dark' ||
147
- colorMode == 'transparent'
141
+ colorMode == 'dark' || colorMode == 'transparent'
148
142
  ? 'black'
149
143
  : 'white'
150
144
  "
145
+ class="rc-select-dropdown"
151
146
  :dropdown-position="dropdownPosition"
152
147
  :font-color="
153
148
  dropdownFontColor ||
@@ -167,10 +162,17 @@
167
162
  :hovered-index="hoveredIndex"
168
163
  :hovered-value="hoveredValue"
169
164
  :is-active="isActive"
165
+ :is-fixed-dropdown-position="isFixedDropdownPosition"
166
+ :is-parent-modal="isParentModal"
170
167
  :min-width="minWidth"
171
168
  :no-relative="noRelative"
172
169
  :option-width="getOptionWidth"
173
170
  :selected-value="selectedValue"
171
+ :style="{
172
+ transform: `translate(${dropdownPosition?.left}px, ${
173
+ noRelative ? 'auto' : `${dropdownPosition?.top}px`
174
+ })`,
175
+ }"
174
176
  @mouseleave="optionLeave"
175
177
  @option-hovered="optionHovered"
176
178
  @option-selected="optionSelected"
@@ -208,7 +210,7 @@
208
210
  // </template>
209
211
  // </Select>
210
212
 
211
- import { Teleport } from 'vue'
213
+ import { Teleport, inject } from 'vue'
212
214
  import styled from 'vue3-styled-components'
213
215
  import InfoText from '../../infoText'
214
216
  import Icon from '../../icon'
@@ -392,14 +394,17 @@
392
394
  selectedValue: Number | String,
393
395
  noRelative: Boolean,
394
396
  minWidth: String,
397
+ isParentModal: Boolean,
398
+ isFixedDropdownPosition: Boolean,
395
399
  }
396
400
  const SelectDropdown = styled('div', selectDropdownAttrs)`
397
401
  box-sizing: border-box;
398
- z-index: ${(props) => (props.isActive ? '2' : '99999')};
399
- position: absolute;
400
- top: ${(props) =>
401
- props.noRelative ? 'auto' : props.dropdownPosition?.top + 'px'};
402
- left: ${(props) => props.dropdownPosition?.left}px;
402
+ z-index: ${(props) =>
403
+ props.isActive ? '2' : props.isParentModal ? '9999999' : '99999'};
404
+ position: ${(props) =>
405
+ props.isFixedDropdownPosition ? 'fixed' : 'absolute'};
406
+ top: 0px;
407
+ left: 0px;
403
408
  border: ${BORDER_WIDTH} solid ${(props) => props.theme.colors.grey4};
404
409
  border-radius: 4px;
405
410
  display: flex;
@@ -647,6 +652,11 @@
647
652
  type: String,
648
653
  required: false,
649
654
  },
655
+ isFixedDropdownPosition: {
656
+ type: Boolean,
657
+ required: false,
658
+ default: false,
659
+ },
650
660
  },
651
661
 
652
662
  data() {
@@ -664,6 +674,17 @@
664
674
  },
665
675
  dropdownWidth: null,
666
676
  hoveredValue: null,
677
+ isDisplayedAtBottom: true,
678
+ selectTopPosition: 0,
679
+ selectAndDropdownDistance: 0,
680
+ animationFrameId: null,
681
+ }
682
+ },
683
+ setup() {
684
+ const modalRef = inject('modalRef')
685
+
686
+ return {
687
+ modalRef,
667
688
  }
668
689
  },
669
690
  computed: {
@@ -721,6 +742,9 @@
721
742
  /windows phone/i.test(userAgent)
722
743
  )
723
744
  },
745
+ isParentModal() {
746
+ return !!this.modalRef
747
+ },
724
748
  },
725
749
  watch: {
726
750
  value(val) {
@@ -734,8 +758,13 @@
734
758
  }, 10)
735
759
  await this.$nextTick()
736
760
  this.handleSetDropdownOffet()
761
+ if (!this.isFixedDropdownPosition) this.calculateSelectTopPosition()
737
762
  } else {
738
763
  this.dropdownPosition.left = null
764
+ if (this.animationFrameId) {
765
+ cancelAnimationFrame(this.animationFrameId)
766
+ this.animationFrameId = null
767
+ }
739
768
  setTimeout(() => {
740
769
  this.isClickOutsideActive = false
741
770
  }, 10)
@@ -748,11 +777,30 @@
748
777
  })
749
778
  }
750
779
  },
780
+ isSelectDropdownShown(isShown) {
781
+ if (!isShown) return
782
+ // Need to wait for 1ms to make sure the dropdown menu is shown in the DOM
783
+ // before getting the distance between the select and the dropdown menu
784
+ setTimeout(() => {
785
+ this.getDistanceBetweenSelectAndDropdownMenu()
786
+ }, 100)
787
+ },
788
+ selectTopPosition() {
789
+ this.dropdownPosition.top =
790
+ this.selectTopPosition +
791
+ this.$refs.select.$el.clientHeight +
792
+ this.selectAndDropdownDistance
793
+ },
751
794
  },
752
795
  mounted() {
753
796
  this.observeDropdownHeight()
754
797
  this.observeSelectWidth()
755
798
  window.addEventListener('resize', this.handleSetDropdownOffet)
799
+ if (!this.isFixedDropdownPosition)
800
+ document.body.addEventListener(
801
+ 'scroll',
802
+ this.calculateSelectTopPosition
803
+ )
756
804
  },
757
805
  beforeMount() {
758
806
  this.selectedValue = this.value
@@ -761,6 +809,12 @@
761
809
  window.removeEventListener('resize', this.handleSetDropdownOffet)
762
810
  if (this.dropdownResizeObserver) this.dropdownResizeObserver.disconnect()
763
811
  if (this.selectResizeObserver) this.selectResizeObserver.disconnect()
812
+ if (!this.isFixedDropdownPosition) {
813
+ document.body.removeEventListener(
814
+ 'scroll',
815
+ this.calculateSelectTopPosition
816
+ )
817
+ }
764
818
  },
765
819
  unmounted() {
766
820
  document.removeEventListener('click', this.clickOutside)
@@ -866,11 +920,11 @@
866
920
  return
867
921
  }
868
922
  await this.$nextTick()
869
- const isDisplayedAtBottom = await this.generateDropdownPosition()
923
+ this.isDisplayedAtBottom = await this.generateDropdownPosition()
870
924
  // If the dropdown menu is going to be displayed at the bottom,
871
925
  // we need reverify its position after a dom update (nextTick)
872
926
  await this.$nextTick()
873
- if (isDisplayedAtBottom) this.generateDropdownPosition()
927
+ if (this.isDisplayedAtBottom) this.generateDropdownPosition()
874
928
  },
875
929
  async generateDropdownPosition() {
876
930
  const isDropdownNotCompletelyVisible =
@@ -963,6 +1017,25 @@
963
1017
  }
964
1018
  }
965
1019
  },
1020
+ getDistanceBetweenSelectAndDropdownMenu() {
1021
+ const wholeSelectTopPosition =
1022
+ this.selectTopPosition + this.$refs.select.$el.clientHeight
1023
+ this.selectAndDropdownDistance =
1024
+ this.dropdownPosition.top - wholeSelectTopPosition
1025
+ },
1026
+ calculateSelectTopPosition() {
1027
+ const selectRef = this.$refs.select
1028
+ if (selectRef) {
1029
+ const currentTopPosition =
1030
+ selectRef.$el.getBoundingClientRect().top + window.scrollY
1031
+ if (this.selectTopPosition !== currentTopPosition) {
1032
+ this.selectTopPosition = currentTopPosition
1033
+ }
1034
+ }
1035
+ this.animationFrameId = requestAnimationFrame(
1036
+ this.calculateSelectTopPosition
1037
+ )
1038
+ },
966
1039
  },
967
1040
  }
968
1041
  </script>
@@ -1,6 +1,7 @@
1
1
  <template>
2
2
  <PageWrapper
3
3
  v-if="isOpen"
4
+ ref="modalRef"
4
5
  :add-padding-top="addPaddingTop"
5
6
  :backdrop="backdrop"
6
7
  :is-open="isOpen"
@@ -36,6 +37,7 @@
36
37
  // <div>Data....</div>
37
38
  // </modal>
38
39
 
40
+ import { ref, provide } from 'vue'
39
41
  import styled from 'vue3-styled-components'
40
42
  import CloseButton from '../../buttons/closeButton'
41
43
  import Spinner from '../../spinner'
@@ -58,14 +60,14 @@
58
60
  props.backdrop == 'dark'
59
61
  ? 'rgba(0, 0, 0, 0.4)'
60
62
  : 'rgba(255, 255, 255, 0.9)'};
61
- z-index: 99999;
63
+ z-index: 9999999;
62
64
  overflow: auto;
63
65
  padding-top: ${(props) => (props.addPaddingTop ? '80px' : '0')};
64
66
 
65
- @media (max-width: 425px) {
66
- background: white;
67
- }
68
- `
67
+ @media (max-width: 425px) {
68
+ background: white;
69
+ }
70
+ `
69
71
 
70
72
  const modalContainerAttrs = { overflow: String, isLoading: Boolean }
71
73
  const ModalContainer = styled('div', modalContainerAttrs)`
@@ -163,6 +165,14 @@
163
165
  default: false,
164
166
  },
165
167
  },
168
+ setup() {
169
+ const modalRef = ref(null)
170
+ provide('modalRef', modalRef)
171
+
172
+ return {
173
+ modalRef,
174
+ }
175
+ },
166
176
  watch: {
167
177
  isOpen: {
168
178
  immediate: true,
@@ -0,0 +1,22 @@
1
+ import { toRaw } from 'vue'
2
+
3
+ export default function isObjectEqual(obj1, obj2) {
4
+ obj1 = toRaw(obj1)
5
+ obj2 = toRaw(obj2)
6
+ if (obj1 === obj2) return true
7
+ if (obj1 === null || obj2 === null) return false
8
+ if (typeof obj1 !== 'object' || typeof obj2 !== 'object') return false
9
+
10
+ const isArray1 = Array.isArray(obj1)
11
+ const isArray2 = Array.isArray(obj2)
12
+ if (isArray1 !== isArray2) return false
13
+
14
+ const keys1 = Object.keys(obj1)
15
+ if (keys1.length !== Object.keys(obj2).length) return false
16
+
17
+ return keys1.every(
18
+ (key) =>
19
+ Object.prototype.hasOwnProperty.call(obj2, key) &&
20
+ isObjectEqual(obj1[key], obj2[key])
21
+ )
22
+ }
@@ -94,7 +94,7 @@ export const stringToNumber = ({
94
94
 
95
95
  export const numberToString = ({ value, numberPrecision, minDecimals }) => {
96
96
  const minimumRounding = minDecimals ? minDecimals : 0
97
- value = parseFloat(value)
97
+ value = !Number.isNaN(parseFloat(value)) ? parseFloat(value) : 0
98
98
  return value.toLocaleString(langForLocaleString(), {
99
99
  minimumFractionDigits: minimumRounding, // removing this for now. Why do we need this to be a minimum amount?
100
100
  maximumFractionDigits:
package/src/main.js CHANGED
@@ -2,6 +2,14 @@ import App from './App.vue'
2
2
  import { createApp } from 'vue'
3
3
  import router from './router/dynamicRoutes'
4
4
 
5
+ const link = document.createElement('link')
6
+ link.href =
7
+ 'https://fonts.googleapis.com/css2?family=Figtree:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300&display=swap'
8
+ link.rel = 'stylesheet'
9
+ document.getElementsByTagName('head')[0].appendChild(link)
10
+
5
11
  const app = createApp(App)
12
+
13
+ app.config.globalProperties.$c = console
6
14
  app.use(router)
7
15
  app.mount('#app')
@@ -1,6 +1,8 @@
1
1
  import { createRouter, createWebHistory } from 'vue-router'
2
2
  import Test from '@/Test.vue'
3
3
  import Toggle from '@/components/inputs/toggle/index.vue'
4
+ import TestChart from '@/TestChart.vue'
5
+ import DemoCharts from '@/DemoCharts.vue'
4
6
 
5
7
  const routes = [
6
8
  {
@@ -13,6 +15,16 @@ const routes = [
13
15
  name: 'Toggle',
14
16
  component: Toggle,
15
17
  },
18
+ {
19
+ path: '/test-chart',
20
+ name: 'TestChart',
21
+ component: TestChart,
22
+ },
23
+ {
24
+ path: '/demo-charts',
25
+ name: 'DemoCharts',
26
+ component: DemoCharts,
27
+ },
16
28
  ]
17
29
 
18
30
  const router = createRouter({
@@ -1 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 8 5"><g data-name="Layer 2"><path fill="#ffffff" d="M0 0h8L4 5 0 0z" data-name="Layer 1"/></g></svg>
@@ -1,3 +0,0 @@
1
- <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
2
- <path fill-rule="evenodd" clip-rule="evenodd" d="M8 0.5C8.27614 0.5 8.5 0.723858 8.5 1V2.86667C8.5 3.14281 8.27614 3.36667 8 3.36667C7.72386 3.36667 7.5 3.14281 7.5 2.86667V1C7.5 0.723858 7.72386 0.5 8 0.5ZM0.5 8C0.5 7.72386 0.723858 7.5 1 7.5H2.86667C3.14281 7.5 3.36667 7.72386 3.36667 8C3.36667 8.27614 3.14281 8.5 2.86667 8.5H1C0.723858 8.5 0.5 8.27614 0.5 8ZM12.6333 8C12.6333 7.72386 12.8572 7.5 13.1333 7.5H15C15.2761 7.5 15.5 7.72386 15.5 8C15.5 8.27614 15.2761 8.5 15 8.5H13.1333C12.8572 8.5 12.6333 8.27614 12.6333 8ZM8.99987 10.8145C9.09475 11.0816 9.39061 11.2244 9.64095 11.0915C10.059 10.8696 10.4293 10.5644 10.728 10.1927C11.1343 9.6872 11.3922 9.0787 11.4728 8.43514C11.5535 7.79158 11.4537 7.13827 11.1847 6.54812C10.9156 5.95796 10.4879 5.45417 9.94915 5.09297C9.41045 4.73177 8.78197 4.52736 8.13385 4.50256C7.48573 4.47776 6.84347 4.63353 6.27873 4.9525C5.71399 5.27148 5.24899 5.7411 4.93563 6.30896C4.70526 6.72642 4.56349 7.1849 4.51696 7.65586C4.48909 7.93792 4.73355 8.15738 5.01665 8.14374C5.29975 8.1301 5.51274 7.8874 5.55771 7.60756C5.60274 7.32731 5.69588 7.05561 5.83426 6.80486C6.05573 6.40352 6.38437 6.07162 6.7835 5.84619C7.18262 5.62076 7.63654 5.51066 8.0946 5.52819C8.55265 5.54572 8.99683 5.69019 9.37756 5.94546C9.75829 6.20074 10.0606 6.55679 10.2507 6.97388C10.4409 7.39098 10.5114 7.8527 10.4544 8.30754C10.3974 8.76237 10.2152 9.19242 9.928 9.54971C9.74858 9.77293 9.5326 9.96227 9.29044 10.1103C9.04864 10.2582 8.90499 10.5474 8.99987 10.8145ZM5.17261 9.95833C5.36097 9.79137 5.64409 9.79046 5.83352 9.95621L8.82925 12.5775C8.93776 12.6724 9 12.8096 9 12.9538V14.5C9 14.7761 9.22386 15 9.5 15C9.77614 15 10 14.7761 10 14.5V12.9538C10 12.5212 9.81328 12.1097 9.48776 11.8249L6.49202 9.20363C5.92373 8.70638 5.0744 8.7091 4.5093 9.20998L1.50504 11.8728C1.18385 12.1575 1 12.5662 1 12.9954V14.5C1 14.7761 1.22386 15 1.5 15C1.77614 15 2 14.7761 2 14.5V12.9954C2 12.8523 2.06128 12.7161 2.16835 12.6212L5.17261 9.95833ZM3.40391 2.69668C3.20865 2.50142 2.89206 2.50142 2.6968 2.69668C2.50154 2.89194 2.50154 3.20852 2.6968 3.40379L4.01673 4.72372C4.212 4.91898 4.52858 4.91898 4.72384 4.72372C4.9191 4.52846 4.9191 4.21187 4.72384 4.01661L3.40391 2.69668ZM11.2764 4.01661C11.0811 4.21187 11.0811 4.52846 11.2764 4.72372C11.4716 4.91898 11.7882 4.91898 11.9835 4.72372L13.3034 3.40379C13.4987 3.20852 13.4987 2.89194 13.3034 2.69668C13.1081 2.50142 12.7916 2.50142 12.5963 2.69668L11.2764 4.01661ZM11.9835 11.2762C11.7882 11.081 11.4716 11.081 11.2764 11.2762C11.0811 11.4715 11.0811 11.7881 11.2764 11.9833L12.5963 13.3033C12.7916 13.4985 13.1081 13.4985 13.3034 13.3033C13.4987 13.108 13.4987 12.7914 13.3034 12.5962L11.9835 11.2762Z" fill="black"/>
3
- </svg>
@@ -1,16 +0,0 @@
1
- const defaultProps = {
2
- title: 'Sample Title',
3
- infoText: 'Sample Info Text',
4
- initialPosition: { top: '0px', left: '0px' },
5
- minWidth: '284px',
6
- maxWidth: '284px',
7
- dragTargets: ['document'],
8
- dragBounds: {},
9
- sampleBody1:
10
- 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
11
- sampleBody2:
12
- 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.',
13
- sampleFooter: 'Sample footer',
14
- }
15
-
16
- export default defaultProps
@@ -1,99 +0,0 @@
1
- import { mount } from '@vue/test-utils'
2
- import DraggableCard from '@/components/draggableCard'
3
- import defaultProps from './defaultProps'
4
-
5
- jest.mock('@/components/icon/iconCache.mjs', () => ({
6
- // need to mock this due to how jest handles import.meta
7
- fetchIcon: jest.fn(() => Promise.resolve('mocked-icon-url.svg')),
8
- }))
9
-
10
- describe('DraggableCard.vue', () => {
11
- it('renders properly with required props', () => {
12
- const wrapper = mount(DraggableCard, { props: defaultProps })
13
- expect(
14
- wrapper.find('[data-test-id="draggable_card_header"]').text()
15
- ).toContain(defaultProps.title)
16
-
17
- // Expect no footer rendered if not provided
18
- const footerElement = wrapper.find('[data-test-id="draggable_card_footer"]')
19
- expect(footerElement.exists()).toBe(false)
20
- })
21
-
22
- it('renders body slot content correctly', () => {
23
- const wrapper = mount(DraggableCard, {
24
- props: defaultProps,
25
- slots: {
26
- body: `
27
- <div class="custom_body1">${defaultProps.sampleBody1}</div>
28
- <div class="custom_body2">${defaultProps.sampleBody2}</div>
29
- `,
30
- },
31
- })
32
- expect(wrapper.find('.custom_body1').exists()).toBe(true)
33
- expect(wrapper.text()).toContain(defaultProps.sampleBody1)
34
- expect(wrapper.find('.custom_body2').exists()).toBe(true)
35
- expect(wrapper.text()).toContain(defaultProps.sampleBody2)
36
- })
37
-
38
- it('renders footer slot content correctly', () => {
39
- const wrapper = mount(DraggableCard, {
40
- props: defaultProps,
41
- slots: {
42
- footer: `<div class="custom_footer">${defaultProps.sampleFooter}</div>`,
43
- },
44
- })
45
- expect(
46
- wrapper.find('[data-test-id="draggable_card_footer"]').exists()
47
- ).toBe(true)
48
- expect(wrapper.find('.custom_footer').exists()).toBe(true)
49
- expect(wrapper.text()).toContain(defaultProps.sampleFooter)
50
- })
51
-
52
- it('emits "on-close" when close button is clicked', async () => {
53
- const wrapper = mount(DraggableCard, { props: defaultProps })
54
- await wrapper
55
- .find('[data-test-id="draggable_card_close_button"]')
56
- .trigger('click')
57
- expect(wrapper.emitted('on-close')).toBeTruthy()
58
- })
59
-
60
- it('toggles collapse state when arrow icon is clicked', async () => {
61
- const wrapper = mount(DraggableCard, {
62
- props: { ...defaultProps, isCollapsible: true },
63
- })
64
- expect(wrapper.vm.isCollapsed).toBe(false)
65
- await wrapper
66
- .find('[data-test-id="draggable_card_collapse_button"]')
67
- .trigger('click')
68
- expect(wrapper.vm.isCollapsed).toBe(true)
69
- })
70
-
71
- it('handles drag start event', async () => {
72
- const wrapper = mount(DraggableCard, { props: defaultProps })
73
- await wrapper
74
- .find('[data-test-id="draggable_card_drag_icon"]')
75
- .trigger('mousedown', { clientX: 100, clientY: 100 })
76
- expect(wrapper.vm.isDragging).toBe(true)
77
- })
78
-
79
- it('handles drag move event', async () => {
80
- const wrapper = mount(DraggableCard, { props: defaultProps })
81
- wrapper.vm.onDragStart(
82
- { preventDefault: () => {}, clientX: 100, clientY: 100 },
83
- false
84
- )
85
- wrapper.vm.onDrag({ preventDefault: () => {}, clientX: 120, clientY: 120 })
86
- expect(wrapper.vm.eventCoordinates.x).toBe(120)
87
- expect(wrapper.vm.eventCoordinates.y).toBe(120)
88
- })
89
-
90
- it('handles drag end event', async () => {
91
- const wrapper = mount(DraggableCard, { props: defaultProps })
92
- wrapper.vm.onDragStart(
93
- { preventDefault: () => {}, clientX: 100, clientY: 100 },
94
- false
95
- )
96
- wrapper.vm.onDragEnd()
97
- expect(wrapper.vm.isDragging).toBe(false)
98
- })
99
- })
@@ -1,79 +0,0 @@
1
- import defaultProps from './defaultProps'
2
- import DraggableCard from './index.vue'
3
- import styled from 'vue3-styled-components'
4
- import theme from '@/assets/theme'
5
-
6
- export default {
7
- title: 'DraggableCard',
8
- component: DraggableCard,
9
- tags: ['autodocs'],
10
- }
11
-
12
- const TextContainer = styled.div`
13
- font-family: ${theme.fonts.mainFont};
14
- color: ${theme.colors.white};
15
- font-weight: 400;
16
- font-size: 14px;
17
- line-height: 21px;
18
- letter-spacing: 0%;
19
- `
20
-
21
- const CompleteTemplate = (args) => {
22
- return {
23
- components: { DraggableCard, TextContainer },
24
- setup() {
25
- return { args }
26
- },
27
- template: `
28
- <DraggableCard v-bind="args">
29
- <template #body>
30
- <TextContainer>{{ args.sampleBody1 }}</TextContainer>
31
- <TextContainer>{{ args.sampleBody2 }}</TextContainer>
32
- </template>
33
- <template #footer>
34
- <TextContainer>{{ args.sampleFooter }}</TextContainer>
35
- </template>
36
- </DraggableCard>
37
- `,
38
- }
39
- }
40
-
41
- export const Default = CompleteTemplate.bind({})
42
- Default.args = {
43
- ...defaultProps,
44
- }
45
-
46
- export const NotCollapsible = CompleteTemplate.bind({})
47
- NotCollapsible.args = {
48
- ...defaultProps,
49
- isCollapsible: false,
50
- }
51
-
52
- export const AdjustWidth = CompleteTemplate.bind({})
53
- AdjustWidth.args = {
54
- ...defaultProps,
55
- minWidth: '100px',
56
- maxWidth: '500px',
57
- }
58
-
59
- const NoFooterTemplate = (args) => {
60
- return {
61
- components: { DraggableCard, TextContainer },
62
- setup() {
63
- return { args }
64
- },
65
- template: `
66
- <DraggableCard v-bind="args">
67
- <template #body>
68
- <TextContainer>{{ args.sampleBody1 }}</TextContainer>
69
- <TextContainer>{{ args.sampleBody2 }}</TextContainer>
70
- </template>
71
- </DraggableCard>
72
- `,
73
- }
74
- }
75
-
76
- export const NoFooter = NoFooterTemplate.bind({})
77
- NoFooter.args = {
78
- ...defaultProps,
79
- }