@farm-investimentos/front-mfe-components 15.4.1 → 15.4.3
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 +147 -130
- 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 +147 -130
- 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/DatePicker/DatePicker.stories.js +13 -0
- package/src/components/DatePicker/DatePicker.vue +10 -1
- package/src/components/DatePicker/__tests__/DatePicker.spec.js +17 -0
- package/src/components/SelectAutoComplete/SelectAutoComplete.vue +1 -1
package/package.json
CHANGED
|
@@ -94,6 +94,19 @@ export const OnlyAllowedDates = () => ({
|
|
|
94
94
|
template: `<div style='max-width: 320px'><farm-input-datepicker position="bottom" :allowed-dates="allowedDates" inputId="input-custom-id-1" v-model="date" /></div>`,
|
|
95
95
|
});
|
|
96
96
|
|
|
97
|
+
export const WithInitialMonth = () => ({
|
|
98
|
+
data() {
|
|
99
|
+
return {
|
|
100
|
+
date: '',
|
|
101
|
+
pickerDate: '2023-01'
|
|
102
|
+
};
|
|
103
|
+
},
|
|
104
|
+
template: `<div style='max-width: 320px'>
|
|
105
|
+
<farm-input-datepicker inputId="input-custom-id-0" v-model="date" position="center" :picker-date.sync="pickerDate" />
|
|
106
|
+
{{ date }}
|
|
107
|
+
</div>`,
|
|
108
|
+
});
|
|
109
|
+
|
|
97
110
|
export const TopPositioned = () => ({
|
|
98
111
|
data() {
|
|
99
112
|
return {
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
:max="max"
|
|
21
21
|
:min="min"
|
|
22
22
|
:allowed-dates="allowedDates"
|
|
23
|
+
:picker-date.sync="internalPickerDate"
|
|
23
24
|
>
|
|
24
25
|
<farm-btn plain title="Limpar" color="primary" :disabled="isDisabled" @click="clear">
|
|
25
26
|
Limpar
|
|
@@ -110,7 +111,14 @@ export default defineComponent({
|
|
|
110
111
|
*/
|
|
111
112
|
allowedDates: {
|
|
112
113
|
type: Function,
|
|
113
|
-
default: () =>
|
|
114
|
+
default: () => true,
|
|
115
|
+
},
|
|
116
|
+
/**
|
|
117
|
+
* Current month/year to show when opened
|
|
118
|
+
*/
|
|
119
|
+
pickerDate: {
|
|
120
|
+
type: String,
|
|
121
|
+
default: '',
|
|
114
122
|
},
|
|
115
123
|
/**
|
|
116
124
|
* Required field (inside form)
|
|
@@ -127,6 +135,7 @@ export default defineComponent({
|
|
|
127
135
|
data() {
|
|
128
136
|
const s = this.formatDateRange(this.value);
|
|
129
137
|
return {
|
|
138
|
+
internalPickerDate: this.pickerDate,
|
|
130
139
|
menuField: false,
|
|
131
140
|
dateField: this.value,
|
|
132
141
|
fieldRange: s,
|
|
@@ -73,6 +73,23 @@ describe('DatePicker component', () => {
|
|
|
73
73
|
});
|
|
74
74
|
expect(component.isDateFieldDisabled).toBe(false);
|
|
75
75
|
});
|
|
76
|
+
|
|
77
|
+
it('should allow all dates', async () => {
|
|
78
|
+
await wrapper.setProps({
|
|
79
|
+
allowedDates: () => true
|
|
80
|
+
});
|
|
81
|
+
expect(component.checkIsInAllowedDates('2023-07-03')).toBe(true);
|
|
82
|
+
expect(component.checkIsInAllowedDates('2099-12-20')).toBe(true);
|
|
83
|
+
expect(component.checkIsInAllowedDates('1985-01-23')).toBe(true);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('should allow only dates in year 2077', async () => {
|
|
87
|
+
await wrapper.setProps({
|
|
88
|
+
allowedDates: (value) => new Date(value).getFullYear() === 2077
|
|
89
|
+
});
|
|
90
|
+
expect(component.checkIsInAllowedDates('2077-05-03')).toBe(true);
|
|
91
|
+
expect(component.checkIsInAllowedDates('2023-05-03')).toBe('Data inválida');
|
|
92
|
+
});
|
|
76
93
|
});
|
|
77
94
|
|
|
78
95
|
describe('methods', () => {
|