@farm-investimentos/front-mfe-components 9.2.2 → 9.2.4

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.
@@ -0,0 +1,86 @@
1
+ <template>
2
+ <transition name="fade">
3
+ <div :class="{ 'farm-modal': true, ['farm-modal--size-' + size]: true }" v-if="inputValue">
4
+ <div class="farm-modal--container">
5
+ <div class="farm-modal--header">
6
+ <slot name="header"></slot>
7
+ </div>
8
+ <div class="farm-modal--content" :style="styles">
9
+ <slot name="content"></slot>
10
+ </div>
11
+ <div class="farm-modal--footer">
12
+ <slot name="footer"></slot>
13
+ </div>
14
+ </div>
15
+ <div class="farm-modal--overlay" @click="close()"></div>
16
+ </div>
17
+ </transition>
18
+ </template>
19
+ <script lang="ts">
20
+ import Vue, { PropType, ref, toRefs, watch } from 'vue';
21
+
22
+ export default Vue.extend({
23
+ name: 'farm-modal',
24
+ props: {
25
+ /**
26
+ * v-model binding
27
+ */
28
+ value: { type: Boolean, required: true, default: true },
29
+ /**
30
+ * Is persistent
31
+ */
32
+ persistent: { type: Boolean, default: false },
33
+ size: {
34
+ type: String as PropType<'xs' | 'sm' | 'md' | 'default'>,
35
+ default: 'default',
36
+ },
37
+ /**
38
+ * content offset, in pixels, from the top
39
+ */
40
+ offsetTop: {
41
+ type: Number,
42
+ default: 0,
43
+ },
44
+ /**
45
+ * content offset, in pixels, from the bottom
46
+ */
47
+ offsetBottom: {
48
+ type: Number,
49
+ default: 0,
50
+ },
51
+ },
52
+ setup(props, { emit }) {
53
+ const { offsetTop, offsetBottom, persistent, size } = toRefs(props);
54
+ const inputValue = ref(props.value);
55
+ const styles = {
56
+ paddingTop: offsetTop.value + 'px',
57
+ paddingBottom: offsetBottom.value + 'px',
58
+ };
59
+
60
+ const close = () => {
61
+ if (persistent.value) {
62
+ return false;
63
+ }
64
+ inputValue.value = false;
65
+ emit('input', false);
66
+ };
67
+
68
+ watch(
69
+ () => props.value,
70
+ newValue => {
71
+ inputValue.value = newValue;
72
+ }
73
+ );
74
+
75
+ return {
76
+ inputValue,
77
+ styles,
78
+ close,
79
+ size,
80
+ };
81
+ },
82
+ });
83
+ </script>
84
+ <style lang="scss" scoped>
85
+ @import './Modal';
86
+ </style>
@@ -0,0 +1,21 @@
1
+ import { shallowMount } from '@vue/test-utils';
2
+
3
+ import Modal from '../index';
4
+
5
+ describe('Modal component', () => {
6
+ let wrapper;
7
+ let component;
8
+
9
+ beforeEach(() => {
10
+ wrapper = shallowMount(Modal, {
11
+ propsData: {
12
+ value: false,
13
+ },
14
+ });
15
+ component = wrapper.vm;
16
+ });
17
+
18
+ test('Modal created', () => {
19
+ expect(wrapper).toBeDefined();
20
+ });
21
+ });
@@ -0,0 +1,4 @@
1
+ import Modal from './Modal.vue';
2
+
3
+ export { Modal };
4
+ export default Modal;
package/src/main.ts CHANGED
@@ -62,6 +62,7 @@ export * from './components/Buttons/MultiImportButton';
62
62
  export * from './components/Card';
63
63
  export * from './components/Checkbox';
64
64
  export * from './components/Chip';
65
+ export * from './components/CopyToClipboard';
65
66
  export * from './components/Logos/ProductLogo';
66
67
  export * from './components/Logos/OriginatorLogo';
67
68
  export * from './components/ResetTableRowSelection';
@@ -72,7 +73,7 @@ export * from './components/Label';
72
73
  export * from './components/Logger';
73
74
  export * from './components/Logger/LoggerItem';
74
75
  export * from './components/Icon';
75
- export * from './components/CopyToClipboard';
76
+ export * from './components/Modal';
76
77
  export * from './components/ProgressBar';
77
78
  export * from './components/Stepper';
78
79
  export * from './components/Switcher';