@farm-investimentos/front-mfe-components-vue3 0.0.14 → 0.0.17

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farm-investimentos/front-mfe-components-vue3",
3
- "version": "0.0.14",
3
+ "version": "0.0.17",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -30,13 +30,13 @@
30
30
  "not dead"
31
31
  ],
32
32
  "dependencies": {
33
- "@farm-investimentos/front-mfe-libs-ts": "^2.5.0",
33
+ "@farm-investimentos/front-mfe-libs-ts": "3.0.5",
34
34
  "@vuepic/vue-datepicker": "7.2.0",
35
35
  "core-js": "3.33.1",
36
36
  "text-mask-addons": "^3.8.0",
37
37
  "v-mask": "2.3.0",
38
38
  "vue": "3.3.4",
39
- "vuetify": "^3.3.22",
39
+ "vuetify": "3.3.23",
40
40
  "webpack": "^4.39.3"
41
41
  },
42
42
  "devDependencies": {
@@ -16,6 +16,7 @@
16
16
  v-bind="$attrs"
17
17
  :disabled="disabled"
18
18
  :class="classes"
19
+ :size="$props.size"
19
20
  v-else
20
21
  >
21
22
  <span class="farm-btn__content">
@@ -88,7 +88,7 @@ export const OnlyAllowedDates = () => ({
88
88
  data() {
89
89
  return {
90
90
  date: '',
91
- allowedDays: [5, 10, 15, 20, 25],
91
+ allowedDays: ['2023-11-13', '2023-11-18', '2023-11-25', '2023-12-01'],
92
92
  };
93
93
  },
94
94
  template: `<div style='max-width: 320px'>
@@ -17,7 +17,7 @@
17
17
  v-model="dateField"
18
18
  :min-date="minDate"
19
19
  :max-date="maxDate"
20
- :allowed-dates="allowedDaysList"
20
+ :allowed-dates="allowedDays"
21
21
  :day-names="['S', 'T', 'Q', 'Q', 'S', 'S', 'D']"
22
22
  :start-date="internalPickerDate"
23
23
  />
@@ -59,7 +59,7 @@
59
59
  :readonly="readonly"
60
60
  :mask="`${readonly ? '' : '##/##/####'}`"
61
61
  :id="inputId"
62
- :rules="[checkDateValid, checkMax, checkMin, checkRequire, checkIsInAllowedDates]"
62
+ :rules="[checkDateValid, checkMax, checkMin, checkRequire]"
63
63
  @keyup="keyUpInput"
64
64
  />
65
65
  </template>
@@ -112,16 +112,12 @@ export default {
112
112
  default: 'bottom',
113
113
  },
114
114
  /**
115
- * Allowed days to be selected and validated
115
+ * Allowed days to be selected (format YYYY-MM-DD)
116
116
  */
117
117
  allowedDays: {
118
118
  type: Array,
119
119
  default: () => null,
120
120
  },
121
- allowedDatesValidator: {
122
- type: Function,
123
- default: () => true,
124
- },
125
121
  /**
126
122
  * Current month/year to show when opened
127
123
  */
@@ -149,8 +145,7 @@ export default {
149
145
  fieldRange: revertDate(this.modelValue),
150
146
  checkDateValid: value => {
151
147
  if (value.length > 0) {
152
- const isValid = checkDateValid(value);
153
- return isValid ? true : 'Data inválida';
148
+ return checkDateValid(value) ? true : 'Data inválida';
154
149
  }
155
150
  return true;
156
151
  },
@@ -179,15 +174,6 @@ export default {
179
174
  }
180
175
  return true;
181
176
  },
182
- checkIsInAllowedDates: value => {
183
- const dateSelected = convertDate(value);
184
-
185
- if (!this.required && value.length === 0) {
186
- return true;
187
- }
188
-
189
- return this.allowedDatesValidator(dateSelected) || 'Data inválida';
190
- },
191
177
  };
192
178
  },
193
179
  watch: {
@@ -279,12 +265,6 @@ export default {
279
265
  }
280
266
  return null;
281
267
  },
282
- allowedDaysList() {
283
- if (this.allowedDays) {
284
- return this.allowedDays.map(day => new Date().setDate(day));
285
- }
286
- return null;
287
- },
288
268
  },
289
269
  };
290
270
  </script>
@@ -74,25 +74,6 @@ describe('DatePicker component', () => {
74
74
  });
75
75
  expect(component.isDateFieldDisabled).toBe(false);
76
76
  });
77
-
78
- it('should allow all dates', async () => {
79
- await wrapper.setProps({
80
- allowedDates: () => true
81
- });
82
- expect(component.checkIsInAllowedDates('2023-07-03')).toBe(true);
83
- expect(component.checkIsInAllowedDates('2099-12-20')).toBe(true);
84
- expect(component.checkIsInAllowedDates('1985-01-23')).toBe(true);
85
- });
86
-
87
- /*
88
- it('should allow only dates in year 2077', async () => {
89
- await wrapper.setProps({
90
- allowedDates: (value) => new Date(value).getFullYear() === 2077
91
- });
92
- expect(component.checkIsInAllowedDates('2077-05-03')).toBe(true);
93
- expect(component.checkIsInAllowedDates('2023-05-03')).toBe('Data inválida');
94
- });
95
- */
96
77
  });
97
78
 
98
79
  describe('methods', () => {
@@ -1,3 +1,5 @@
1
+ import { computed } from 'vue';
2
+ import { useModal } from '@farm-investimentos/front-mfe-libs-ts';
1
3
  import Modal from './Modal.vue';
2
4
 
3
5
  export default {
@@ -219,81 +221,44 @@ export const Persistent = () => ({
219
221
  </div>`,
220
222
  });
221
223
 
224
+ export const ModalableMixin = () => ({
225
+ components: {
226
+ MixinModableComponent,
227
+ },
228
+ data() {
229
+ return {
230
+ controlModal: false,
231
+ };
232
+ },
233
+ template: `<div>
234
+ <farm-btn @click="controlModal = true">abrir</farm-btn>
235
+ <MixinModableComponent v-model="controlModal" />
236
+ </div>`,
237
+ });
238
+
239
+ const MixinModableComponent = {
240
+ props: {
241
+ modelValue: {
242
+ type: Boolean,
243
+ default: false,
244
+ },
245
+ },
246
+ setup(props, { emit }) {
247
+ const { inputVal, close } = useModal(props, { emit, computed });
248
+ return { inputVal, close, text };
249
+ },
250
+ template: `<farm-modal v-model="inputVal" :offsetTop="48">
251
+ <template v-slot:header>
252
+ <farm-dialog-header title="Título" @onClose="close" />
253
+ </template>
254
+ <template v-slot:content>
255
+ <div v-html="text" />
256
+ </template>
257
+ </farm-modal>`,
258
+ };
259
+
222
260
  const text = `inicio!<br />
223
- teste!<br />
224
- teste!<br />
225
- teste!<br />
226
- teste!<br />
227
- teste!<br />
228
- teste!<br />
229
- teste!<br />
230
- teste!<br />
231
- teste!<br />
232
- teste!<br />
233
- teste 1!<br />
234
- teste!<br />
235
- teste!<br />
236
- teste!<br />
237
- teste!<br />
238
- teste!<br />
239
- teste!<br />
240
- teste!<br />
241
- teste!<br />
242
- teste!<br />
243
- teste!<br />
244
- teste!<br />
245
- teste!<br />
246
- teste!<br />
247
- teste!<br />
248
- teste!<br />
249
- teste!<br />
250
- teste!<br />
251
- teste 2!<br />
252
- teste!<br />
253
- teste!<br />
254
- teste!<br />
255
- teste!<br />
256
- teste!<br />
257
- teste!<br />
258
- teste!<br />
259
- teste!<br />
260
- teste!<br />
261
- teste!<br />
262
- teste!<br />
263
- teste!<br />
264
- teste!<br />
265
- teste!<br />
266
- teste!<br />
267
- teste!<br />
268
- teste!<br />
269
- teste 1!<br />
270
- teste!<br />
271
- teste!<br />
272
- teste!<br />
273
- teste!<br />
274
- teste!<br />
275
- teste!<br />
276
- teste!<br />
277
- teste!<br />
278
- teste!<br />
279
- teste!<br />
280
- teste!<br />
281
- teste!<br />
282
- teste!<br />
283
- teste!<br />
284
- teste!<br />
285
- teste!<br />
286
- teste!<br />
287
- teste 2!<br />
288
- teste!<br />
289
- teste!<br />
290
- teste!<br />
291
- teste!<br />
292
- teste!<br />
293
- teste!<br />
294
- teste!<br />
295
- teste!<br />
296
- teste!<br />
297
- teste!<br />
298
- teste!<br />
299
- teste 3!`;
261
+ ${Array(50)
262
+ .fill()
263
+ .map((_, i) => 'line ' + (i + 1) + '<br />')
264
+ .join('')}`;