@farm-investimentos/front-mfe-components 15.3.4 → 15.3.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/dist/front-mfe-components.common.js +392 -171
- package/dist/front-mfe-components.common.js.map +1 -1
- package/dist/front-mfe-components.css +1 -1
- package/dist/front-mfe-components.umd.js +392 -171
- package/dist/front-mfe-components.umd.js.map +1 -1
- package/dist/front-mfe-components.umd.min.js +1 -1
- package/dist/front-mfe-components.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ContextMenu/ContextMenu.vue +43 -11
- package/src/components/DatePicker/DatePicker.stories.js +33 -1
- package/src/components/DatePicker/DatePicker.vue +21 -9
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
</div>
|
|
18
18
|
</template>
|
|
19
19
|
<script lang="ts">
|
|
20
|
-
import { ref, watch, reactive, onBeforeUnmount, toRefs, defineComponent } from 'vue';
|
|
20
|
+
import { ref, watch, reactive, onBeforeUnmount, toRefs, defineComponent, nextTick } from 'vue';
|
|
21
21
|
import { calculateMainZindex, isChildOfFixedElement } from '../../helpers';
|
|
22
22
|
|
|
23
23
|
export default defineComponent({
|
|
@@ -38,6 +38,13 @@ export default defineComponent({
|
|
|
38
38
|
type: Boolean,
|
|
39
39
|
default: false,
|
|
40
40
|
},
|
|
41
|
+
/**
|
|
42
|
+
* Aligns the component towards the top
|
|
43
|
+
*/
|
|
44
|
+
top: {
|
|
45
|
+
type: Boolean,
|
|
46
|
+
default: false,
|
|
47
|
+
},
|
|
41
48
|
/**
|
|
42
49
|
* Max height
|
|
43
50
|
*/
|
|
@@ -64,7 +71,7 @@ export default defineComponent({
|
|
|
64
71
|
const parent = ref(null);
|
|
65
72
|
const popup = ref(null);
|
|
66
73
|
const activator = ref(null);
|
|
67
|
-
const { bottom, maxHeight, stayOpen } = toRefs(props);
|
|
74
|
+
const { top, bottom, maxHeight, stayOpen } = toRefs(props);
|
|
68
75
|
|
|
69
76
|
const styles = reactive({
|
|
70
77
|
minWidth: 0,
|
|
@@ -74,7 +81,7 @@ export default defineComponent({
|
|
|
74
81
|
} as any);
|
|
75
82
|
|
|
76
83
|
const inputValue = ref(props.value);
|
|
77
|
-
|
|
84
|
+
|
|
78
85
|
let hasBeenBoostrapped = false;
|
|
79
86
|
|
|
80
87
|
const outClick = event => {
|
|
@@ -114,8 +121,17 @@ export default defineComponent({
|
|
|
114
121
|
hasBeenBoostrapped = true;
|
|
115
122
|
}
|
|
116
123
|
window.addEventListener('click', outClick);
|
|
117
|
-
window.addEventListener('resize', resizeWindowHandler
|
|
124
|
+
window.addEventListener('resize', resizeWindowHandler, {
|
|
125
|
+
passive: true,
|
|
126
|
+
});
|
|
118
127
|
calculatePosition();
|
|
128
|
+
|
|
129
|
+
if (top.value) {
|
|
130
|
+
nextTick(() => {
|
|
131
|
+
const offsetTop = calculateOffsetTop();
|
|
132
|
+
styles.top = `${offsetTop}px`;
|
|
133
|
+
});
|
|
134
|
+
}
|
|
119
135
|
} else {
|
|
120
136
|
styles.top = '-10000px';
|
|
121
137
|
styles.left = '-10000px';
|
|
@@ -125,20 +141,36 @@ export default defineComponent({
|
|
|
125
141
|
}
|
|
126
142
|
);
|
|
127
143
|
|
|
144
|
+
const getElementClientRects = () => ({
|
|
145
|
+
parentBoundingClientRect: parent.value.getBoundingClientRect(),
|
|
146
|
+
activatorBoundingClientRect: activator.value.children[0].getBoundingClientRect(),
|
|
147
|
+
popupClientRect: popup.value.getBoundingClientRect(), // Only has height when popup is showing on screen
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
const calculateOffsetTop = () => {
|
|
151
|
+
const { parentBoundingClientRect, activatorBoundingClientRect, popupClientRect } =
|
|
152
|
+
getElementClientRects();
|
|
153
|
+
|
|
154
|
+
let offsetTop =
|
|
155
|
+
window.scrollY +
|
|
156
|
+
parentBoundingClientRect.top +
|
|
157
|
+
(!bottom.value ? 0 : activatorBoundingClientRect.height);
|
|
158
|
+
|
|
159
|
+
offsetTop = top.value ? offsetTop - popupClientRect.height - 12 : offsetTop;
|
|
160
|
+
|
|
161
|
+
return offsetTop;
|
|
162
|
+
};
|
|
163
|
+
|
|
128
164
|
const calculatePosition = () => {
|
|
129
165
|
if (!parent.value || !activator.value.children[0]) {
|
|
130
166
|
return;
|
|
131
167
|
}
|
|
132
168
|
const activatorChildOfFixedElement = isChildOfFixedElement(activator.value);
|
|
133
169
|
|
|
134
|
-
const parentBoundingClientRect =
|
|
135
|
-
|
|
136
|
-
const popupClientRect = popup.value.getBoundingClientRect();
|
|
170
|
+
const { parentBoundingClientRect, activatorBoundingClientRect, popupClientRect } =
|
|
171
|
+
getElementClientRects();
|
|
137
172
|
|
|
138
|
-
let offsetTop =
|
|
139
|
-
parentBoundingClientRect.top +
|
|
140
|
-
window.scrollY +
|
|
141
|
-
(!bottom.value ? 0 : activatorBoundingClientRect.height);
|
|
173
|
+
let offsetTop = calculateOffsetTop();
|
|
142
174
|
|
|
143
175
|
let offsetLeft = activatorBoundingClientRect.left;
|
|
144
176
|
|
|
@@ -73,6 +73,38 @@ export const IsNull = () => ({
|
|
|
73
73
|
};
|
|
74
74
|
},
|
|
75
75
|
template: `<div style='max-width: 320px'>
|
|
76
|
-
|
|
76
|
+
<farm-input-datepicker inputId="input-custom-id-8" v-model="date" :required="true" />
|
|
77
|
+
</div>`,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
export const BottomFalse = () => ({
|
|
81
|
+
data() {
|
|
82
|
+
return {
|
|
83
|
+
date: '2023-08-01',
|
|
84
|
+
};
|
|
85
|
+
},
|
|
86
|
+
template: `<div style='max-width: 320px'><farm-input-datepicker position="bottom" inputId="input-custom-id-1" v-model="date" /></div>`,
|
|
87
|
+
});
|
|
88
|
+
export const TopPositioned = () => ({
|
|
89
|
+
data() {
|
|
90
|
+
return {
|
|
91
|
+
date: '',
|
|
92
|
+
};
|
|
93
|
+
},
|
|
94
|
+
template: `<div style='max-width: 320px'>
|
|
95
|
+
<farm-input-datepicker inputId="input-custom-id-0" v-model="date" position="top" />
|
|
96
|
+
{{ date }}
|
|
97
|
+
</div>`,
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
export const CenterPositioned = () => ({
|
|
101
|
+
data() {
|
|
102
|
+
return {
|
|
103
|
+
date: '',
|
|
104
|
+
};
|
|
105
|
+
},
|
|
106
|
+
template: `<div style='max-width: 320px'>
|
|
107
|
+
<farm-input-datepicker inputId="input-custom-id-0" v-model="date" position="center" />
|
|
108
|
+
{{ date }}
|
|
77
109
|
</div>`,
|
|
78
110
|
});
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
v-model="menuField"
|
|
5
5
|
ref="contextmenu"
|
|
6
6
|
maxHeight="auto"
|
|
7
|
-
bottom
|
|
7
|
+
:bottom="position === 'bottom'"
|
|
8
|
+
:top="position === 'top'"
|
|
8
9
|
popup-width="320"
|
|
9
10
|
>
|
|
10
11
|
<v-date-picker
|
|
@@ -51,9 +52,13 @@
|
|
|
51
52
|
</farm-contextmenu>
|
|
52
53
|
</template>
|
|
53
54
|
<script lang="ts">
|
|
54
|
-
import { defineComponent } from 'vue';
|
|
55
|
+
import { PropType, defineComponent } from 'vue';
|
|
55
56
|
import { VDatePicker } from 'vuetify/lib/components/VDatePicker';
|
|
56
|
-
import {
|
|
57
|
+
import {
|
|
58
|
+
defaultFormat as dateDefaultFormatter,
|
|
59
|
+
convertDate,
|
|
60
|
+
checkDateValid,
|
|
61
|
+
} from '../../helpers/date';
|
|
57
62
|
import { formatDatePickerHeader } from '../../helpers';
|
|
58
63
|
/**
|
|
59
64
|
* Componente de input com datepicker para data
|
|
@@ -92,6 +97,13 @@ export default defineComponent({
|
|
|
92
97
|
type: String,
|
|
93
98
|
default: null,
|
|
94
99
|
},
|
|
100
|
+
/**
|
|
101
|
+
* Min date (ISO format)
|
|
102
|
+
*/
|
|
103
|
+
position: {
|
|
104
|
+
type: String as PropType<'top' | 'bottom' | 'center'>,
|
|
105
|
+
default: 'bottom',
|
|
106
|
+
},
|
|
95
107
|
/**
|
|
96
108
|
* Required field (inside form)
|
|
97
109
|
*/
|
|
@@ -111,9 +123,9 @@ export default defineComponent({
|
|
|
111
123
|
dateField: this.value,
|
|
112
124
|
fieldRange: s,
|
|
113
125
|
checkDateValid: value => {
|
|
114
|
-
if(value.length > 0) {
|
|
126
|
+
if (value.length > 0) {
|
|
115
127
|
const isValid = checkDateValid(value);
|
|
116
|
-
return
|
|
128
|
+
return isValid ? true : 'Data inválida';
|
|
117
129
|
}
|
|
118
130
|
return true;
|
|
119
131
|
},
|
|
@@ -121,7 +133,7 @@ export default defineComponent({
|
|
|
121
133
|
return this.required ? !!value || value != '' || 'Campo obrigatório' : true;
|
|
122
134
|
},
|
|
123
135
|
checkMax: value => {
|
|
124
|
-
if(!this.required && value.length === 0) {
|
|
136
|
+
if (!this.required && value.length === 0) {
|
|
125
137
|
return true;
|
|
126
138
|
}
|
|
127
139
|
return this.max && new Date(convertDate(value)) > new Date(this.max)
|
|
@@ -129,13 +141,13 @@ export default defineComponent({
|
|
|
129
141
|
: true;
|
|
130
142
|
},
|
|
131
143
|
checkMin: value => {
|
|
132
|
-
if(!this.required && value.length === 0) {
|
|
144
|
+
if (!this.required && value.length === 0) {
|
|
133
145
|
return true;
|
|
134
146
|
}
|
|
135
|
-
if(this.min) {
|
|
147
|
+
if (this.min) {
|
|
136
148
|
const dateSelected = new Date(convertDate(value));
|
|
137
149
|
const dateMin = new Date(convertDate(this.min));
|
|
138
|
-
if(dateSelected.getTime() >= dateMin.getTime()){
|
|
150
|
+
if (dateSelected.getTime() >= dateMin.getTime()) {
|
|
139
151
|
return true;
|
|
140
152
|
}
|
|
141
153
|
return 'A data está fora do período permitido';
|