@farm-investimentos/front-mfe-components 14.1.1 → 14.1.2

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",
3
- "version": "14.1.1",
3
+ "version": "14.1.2",
4
4
  "author": "farm investimentos",
5
5
  "private": false,
6
6
  "main": "./dist/front-mfe-components.common.js",
@@ -5,16 +5,15 @@
5
5
  .datepicker :deep(.v-btn--active) {
6
6
  background: var(--farm-primary-base);
7
7
  }
8
- .datepicker :deep(.v-date-picker-table__current) {
9
- border-color: var(--farm-primary-base);
10
- color: var(--farm-primary-base);
8
+
9
+ .datepicker :deep(.v-picker__body) {
10
+ width: 341px !important;
11
11
  }
12
- .datepicker :deep(.v-date-picker-table__current.v-btn--active) {
13
- color: white;
14
- }
15
- .btn-clean {
12
+
13
+ .btn-cancel {
16
14
  margin: 0 8px;
17
15
  }
16
+
18
17
  .farm-contextmenu {
19
18
  width: 100%;
20
- }
19
+ }
@@ -14,18 +14,23 @@
14
14
  scrollable
15
15
  locale="pt-br"
16
16
  class="datepicker"
17
+ show-adjacent-months
18
+ :header-date-format="formatDatePickerHeader"
17
19
  :max="max"
18
20
  :min="min"
19
21
  >
20
- <farm-btn outlined color="secondary" @click="closeDatepicker" title="Fechar">
21
- Fechar
22
+ <farm-btn plain title="Limpar" color="primary" :disabled="isDisabled" @click="clear">
23
+ Limpar
22
24
  </farm-btn>
23
- <farm-btn outlined class="btn-clean" @click="clear"> Limpar </farm-btn>
25
+ <farm-btn outlined class="btn-cancel" title="Cancelar" @click="closeDatepicker">
26
+ Cancelar
27
+ </farm-btn>
28
+
24
29
  <farm-btn class="ml-2" title="Confirmar" :disabled="!dateField.length" @click="save()">
25
- Confirmar
30
+ Confirmar <farm-icon>check</farm-icon>
26
31
  </farm-btn>
27
32
  </v-date-picker>
28
- <template v-slot:activator="{ }">
33
+ <template v-slot:activator="{}">
29
34
  <farm-textfield-v2
30
35
  icon="calendar"
31
36
  v-model="fieldRange"
@@ -45,6 +50,7 @@
45
50
  import Vue from 'vue';
46
51
  import { VDatePicker } from 'vuetify/lib/components/VDatePicker';
47
52
  import { defaultFormat as dateDefaultFormatter, convertDate } from '../../helpers/date';
53
+ import { formatDatePickerHeader } from '../../helpers';
48
54
  /**
49
55
  * Componente de input com datepicker para data
50
56
  */
@@ -186,6 +192,7 @@ export default Vue.extend({
186
192
  this.menuField = false;
187
193
  this.$refs.contextmenu.inputValue = false;
188
194
  },
195
+ formatDatePickerHeader,
189
196
  },
190
197
  computed: {
191
198
  inputVal: {
@@ -196,6 +203,9 @@ export default Vue.extend({
196
203
  this.$emit('input', val);
197
204
  },
198
205
  },
206
+ isDisabled(): boolean {
207
+ return this.value.length === 0 ? true : false;
208
+ },
199
209
  },
200
210
  });
201
211
  </script>
@@ -9,22 +9,27 @@
9
9
  >
10
10
  <v-date-picker
11
11
  v-if="menuField"
12
- class="datepicker"
12
+ class="rangedatepicker datepicker"
13
13
  v-model="dateField"
14
14
  no-title
15
15
  scrollable
16
16
  range
17
- :max="max"
18
- :min="min"
17
+ show-adjacent-months
18
+ :header-date-format="formatDatePickerHeader"
19
19
  color="secondary"
20
20
  locale="pt-br"
21
+ :max="max"
22
+ :min="min"
21
23
  >
22
- <farm-btn outlined color="secondary" @click="closeDatepicker" title="Fechar">
23
- Fechar
24
+ <farm-btn plain title="Limpar" color="primary" :disabled="isDisabled" @click="clear">
25
+ Limpar
26
+ </farm-btn>
27
+ <farm-btn outlined class="btn-cancel" title="Cancelar" @click="closeDatepicker">
28
+ Cancelar
24
29
  </farm-btn>
25
- <farm-btn outlined class="btn-clean" @click="clear"> Limpar </farm-btn>
26
- <farm-btn class="ml-2" title="Confirmar" :disabled="dateField.length != 2" @click="save()">
27
- Confirmar
30
+
31
+ <farm-btn class="ml-2" title="Confirmar" :disabled="!dateField.length" @click="save()">
32
+ Confirmar <farm-icon>check</farm-icon>
28
33
  </farm-btn>
29
34
  </v-date-picker>
30
35
  <template v-slot:activator="{}">
@@ -44,6 +49,7 @@
44
49
  import Vue from 'vue';
45
50
  import { VDatePicker } from 'vuetify/lib/components/VDatePicker';
46
51
  import { defaultFormat as dateDefaultFormatter } from '../../helpers/date';
52
+ import { formatDatePickerHeader } from '../../helpers';
47
53
  /**
48
54
  * Componente de input com datepicker para range de data
49
55
  */
@@ -136,6 +142,7 @@ export default Vue.extend({
136
142
  this.menuField = false;
137
143
  this.$refs.contextmenu.inputValue = false;
138
144
  },
145
+ formatDatePickerHeader,
139
146
  },
140
147
  computed: {
141
148
  inputVal: {
@@ -149,6 +156,9 @@ export default Vue.extend({
149
156
  canConfirm() {
150
157
  return !this.dateField || this.dateField.length == 1;
151
158
  },
159
+ isDisabled() {
160
+ return this.value?.length === 0 ? true : false;
161
+ },
152
162
  },
153
163
  });
154
164
  </script>
@@ -28,9 +28,11 @@
28
28
  margin-right: 8px;
29
29
  }
30
30
 
31
- ::v-deep .farm-listitem:hover .farm-checkbox .farm-icon {
31
+ :deep(.farm-listitem:hover .farm-checkbox .farm-icon) {
32
32
  color: var(--farm-primary-lighten);
33
33
  }
34
- ::v-deep .farm-listitem:hover .farm-checkbox.farm-checkbox--checked .farm-icon {
34
+
35
+
36
+ :deep(.farm-listitem:hover .farm-checkbox.farm-checkbox--checked .farm-icon) {
35
37
  color: white;
36
- }
38
+ }
@@ -47,11 +47,11 @@
47
47
  <div class="farm-textfield--input farm-textfield--input--iconed">
48
48
  <input
49
49
  v-bind="$attrs"
50
- :id="$props.id"
51
50
  v-model="selectedText"
52
51
  ref="inputField"
52
+ readonly
53
+ :id="$props.id"
53
54
  @click="clickInput"
54
- @keyup="onKeyUp"
55
55
  @blur="onBlur"
56
56
  @focusin="onFocus(true)"
57
57
  @focusout="onFocus(false)"
@@ -81,12 +81,13 @@
81
81
  </template>
82
82
 
83
83
  <script lang="ts">
84
- import Vue, { computed, onBeforeMount, PropType, ref, toRefs, watch } from 'vue';
84
+ import Vue, { computed, onBeforeMount, PropType, toRefs, watch } from 'vue';
85
85
  import validateFormStateBuilder from '../../composition/validateFormStateBuilder';
86
86
  import validateFormFieldBuilder from '../../composition/validateFormFieldBuilder';
87
87
  import validateFormMethodBuilder from '../../composition/validateFormMethodBuilder';
88
88
  import deepEqual from '../../composition/deepEqual';
89
89
  import randomId from '../../helpers/randomId';
90
+ import { buildData } from './composition';
90
91
 
91
92
  export default Vue.extend({
92
93
  name: 'farm-select',
@@ -217,16 +218,19 @@ export default Vue.extend({
217
218
  },
218
219
  setup(props, { emit }) {
219
220
  const { rules, items, itemText, itemValue, disabled, multiple } = toRefs(props);
220
- const innerValue = ref(props.value);
221
- const isTouched = ref(false);
222
- const isFocus = ref(false);
223
- const isBlured = ref(false);
224
- const isVisible = ref(false);
225
- const selectedText = ref('');
226
- const multipleValues = ref(Array.isArray(props.value) ? [...props.value] : []);
227
- const checked = ref('1');
228
- const notChecked = ref(false);
229
- const inputField = ref();
221
+
222
+ const {
223
+ multipleValues,
224
+ innerValue,
225
+ isTouched,
226
+ isFocus,
227
+ isBlured,
228
+ isVisible,
229
+ selectedText,
230
+ checked,
231
+ notChecked,
232
+ inputField,
233
+ } = buildData(props);
230
234
 
231
235
  const { errorBucket, valid, validatable } = validateFormStateBuilder();
232
236
 
@@ -300,10 +304,6 @@ export default Vue.extend({
300
304
  emit('input', innerValue.value);
301
305
  };
302
306
 
303
- const onKeyUp = (event: Event) => {
304
- emit('keyup', event);
305
- };
306
-
307
307
  const onBlur = (event: Event) => {
308
308
  isBlured.value = true;
309
309
  validate(innerValue.value);
@@ -413,7 +413,6 @@ export default Vue.extend({
413
413
  validate,
414
414
  reset,
415
415
  selectItem,
416
- onKeyUp,
417
416
  onBlur,
418
417
  onFocus,
419
418
  clickInput,
@@ -0,0 +1,27 @@
1
+ import buildData from '../composition/buildData';
2
+
3
+ describe('buildData', () => {
4
+ it('should initialize with empty arrays and false values', () => {
5
+ const props = { value: [] };
6
+ const result = buildData(props);
7
+
8
+ expect(result.multipleValues.value).toEqual([]);
9
+ expect(result.innerValue.value).toEqual([]);
10
+ expect(result.isTouched.value).toBe(false);
11
+ expect(result.isFocus.value).toBe(false);
12
+ expect(result.isBlured.value).toBe(false);
13
+ expect(result.isVisible.value).toBe(false);
14
+ expect(result.selectedText.value).toBe('');
15
+ expect(result.checked.value).toBe('1');
16
+ expect(result.notChecked.value).toBe(false);
17
+ expect(result.inputField.value).toBe(undefined);
18
+ });
19
+
20
+ it('should initialize with provided values', () => {
21
+ const props = { value: 'test' };
22
+ const result = buildData(props);
23
+
24
+ expect(result.multipleValues.value).toEqual([]);
25
+ expect(result.innerValue.value).toBe('test');
26
+ });
27
+ });
@@ -0,0 +1,27 @@
1
+ import { ref } from 'vue';
2
+
3
+ export default function (props) {
4
+ const multipleValues = ref(Array.isArray(props.value) ? [...props.value] : []);
5
+ const innerValue = ref(props.value);
6
+ const isTouched = ref(false);
7
+ const isFocus = ref(false);
8
+ const isBlured = ref(false);
9
+ const isVisible = ref(false);
10
+ const selectedText = ref('');
11
+ const checked = ref('1');
12
+ const notChecked = ref(false);
13
+ const inputField = ref();
14
+
15
+ return {
16
+ multipleValues,
17
+ innerValue,
18
+ isTouched,
19
+ isFocus,
20
+ isBlured,
21
+ isVisible,
22
+ selectedText,
23
+ checked,
24
+ notChecked,
25
+ inputField,
26
+ };
27
+ }
@@ -0,0 +1,3 @@
1
+ import buildData from './buildData';
2
+
3
+ export { buildData };
@@ -0,0 +1,19 @@
1
+ const monthNumberToMonthName = {
2
+ '01': 'Janeiro',
3
+ '02': 'Fevereiro',
4
+ '03': 'Março',
5
+ '04': 'Abril',
6
+ '05': 'Maio',
7
+ '06': 'Junho',
8
+ '07': 'Julho',
9
+ '08': 'Agosto',
10
+ '09': 'Setembro',
11
+ '10': 'Outubro',
12
+ '11': 'Novembro',
13
+ '12': 'Dezembro',
14
+ };
15
+
16
+ export function formatDatePickerHeader(date: string): string {
17
+ const [year, month] = date.split('-');
18
+ return `${month ? monthNumberToMonthName[month] + ' ' : ''}${year}`;
19
+ }
@@ -0,0 +1,3 @@
1
+ import { formatDatePickerHeader } from './formatDatePickerHeader';
2
+ export { default as calculateMainZindex } from './calculateMainZindex';
3
+ export { formatDatePickerHeader };
@@ -1,6 +1,7 @@
1
1
  @import 'vuejs-dialog/dist/vuejs-dialog.min';
2
2
  @import '../components/Buttons/DefaultButton/DefaultButton.scss';
3
3
 
4
+
4
5
  .dg-main-content {
5
6
  font-family: Montserrat, sans-serif !important;
6
7
  }
@@ -27,6 +28,11 @@
27
28
  margin: 24px 0;
28
29
  font-size: 12px;
29
30
  line-height: 20px;
31
+ word-break: break-all;
32
+
33
+ ul {
34
+ margin-left: 16px;
35
+ }
30
36
  }
31
37
 
32
38
  .dg-content-footer {
@@ -53,7 +59,7 @@
53
59
  background-color: rgba(0, 0, 0, .46);
54
60
  }
55
61
 
56
- .dg-parent-nofooter{
62
+ .dg-parent-nofooter {
57
63
  .dg-content-footer {
58
64
  display: none;
59
65
  }
@@ -73,6 +79,7 @@
73
79
  .dg-btn--ok {
74
80
  @extend .farm-btn--error;
75
81
  }
82
+
76
83
  .dg-title {
77
84
  color: var(--farm-error-base);
78
85
  }
@@ -92,7 +92,7 @@ tr.v-data-table__empty-wrapper {
92
92
  }
93
93
  .v-date-picker-header {
94
94
  display: grid;
95
- grid-template-columns: 1fr 2rem 2rem;
95
+ grid-template-columns: 1fr 60px 36px;
96
96
  grid-template-areas: ' a b c ';
97
97
  margin-top: 0.5rem;
98
98
 
@@ -106,6 +106,124 @@ tr.v-data-table__empty-wrapper {
106
106
  grid-area: c;
107
107
  }
108
108
  }
109
+
110
+ .v-date-picker-table__current.v-btn--active {
111
+ color: white;
112
+ }
113
+ .v-date-picker-header {
114
+ padding: 0;
115
+ margin-top: 16px;
116
+ margin-bottom: 16px;
117
+ margin-left: 4px;
118
+
119
+ .mdi-chevron-left::before,
120
+ .mdi-chevron-right::before {
121
+ color: var(--farm-neutral-darken);
122
+ font-size: 20px;
123
+ font-weight: 900;
124
+ }
125
+ }
126
+
127
+ .v-picker__body:has(div > .v-date-picker-years) {
128
+ li {
129
+ color: var(--farm-neutral-darken);
130
+ font-size: 12px;
131
+ font-weight: 500;
132
+ width: 70px;
133
+ margin: 0 auto;
134
+ border-radius: 5px;
135
+
136
+ &.active {
137
+ color: #fff;
138
+ background-color: var(--farm-primary-base);
139
+ border: 1px solid var(--farm-primary-base);
140
+ }
141
+
142
+ &:hover:not(.active) {
143
+ background-color: var(--farm-primary-lighten);
144
+ }
145
+ }
146
+ }
147
+
148
+ .v-date-picker-header__value {
149
+ button {
150
+ padding-left: 0;
151
+ }
152
+ }
153
+
154
+ .v-picker__actions {
155
+ margin-bottom: 24px;
156
+ }
157
+
158
+ .v-date-picker-table {
159
+ padding: 0 40px;
160
+ margin-bottom: 24px;
161
+
162
+ table {
163
+ height: 100%;
164
+ }
165
+
166
+ table thead th {
167
+ color: var(--farm-neutral-darken);
168
+ font-size: 16px;
169
+ font-weight: 700;
170
+ }
171
+
172
+ table tbody td .v-btn {
173
+ color: var(--farm-neutral-darken);
174
+ font-size: 12px;
175
+ font-weight: 500;
176
+ }
177
+
178
+ table tbody td .v-btn.v-btn--disabled {
179
+ color: var(--farm-gray-lighten);
180
+ }
181
+
182
+ table tbody td .v-btn.v-date-picker-table__current,
183
+ .v-btn.v-btn--active {
184
+ border-radius: 5px;
185
+ border-color: var(--farm-primary-base);
186
+ border-width: 2px;
187
+ }
188
+
189
+ table tbody td .v-btn.v-date-picker-table__current {
190
+ color: var(--farm-primary-base);
191
+ }
192
+
193
+ table tbody td .v-btn.v-btn--active {
194
+ color: white;
195
+ }
196
+
197
+ table tbody td .v-btn--rounded {
198
+ border-radius: 5px;
199
+ }
200
+
201
+ table tbody td .v-btn {
202
+ &:not(.v-btn--active):hover::before {
203
+ background-color: var(--farm-primary-lighten);
204
+ opacity: 1;
205
+ }
206
+ &::before {
207
+ background-color: transparent;
208
+ }
209
+ }
210
+ }
211
+
212
+ &.rangedatepicker .v-date-picker-table {
213
+ table tbody td .v-btn.v-btn--active {
214
+ &:not(.v-date-picker--first-in-range, .v-date-picker--last-in-range) {
215
+ background: var(--farm-primary-lighten);
216
+ color: var(--farm-primary-base);
217
+ border-radius: 0;
218
+ width: 37px;
219
+ }
220
+
221
+ &.v-date-picker--first-in-range,
222
+ &.v-date-picker--last-in-range {
223
+ width: 37px;
224
+ }
225
+ }
226
+ }
109
227
  }
110
228
 
111
229
  .v-icon.v-icon__extral4 {
@@ -1 +0,0 @@
1
- export { default as calculateMainZindex } from './calculateMainZindex';