@farm-investimentos/front-mfe-components 12.2.3 → 13.0.1

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": "12.2.3",
3
+ "version": "13.0.1",
4
4
  "author": "farm investimentos",
5
5
  "private": false,
6
6
  "main": "./dist/front-mfe-components.common.js",
@@ -67,7 +67,7 @@ export const withDismissableShowAgain = () => ({
67
67
  data() {
68
68
  return {
69
69
  v: true,
70
- }
70
+ };
71
71
  },
72
72
  template: `<div>
73
73
  <farm-alertbox v-model="v" dismissable>alert box</farm-alertbox>
@@ -2,9 +2,9 @@
2
2
  @import '../../../configurations/mixins';
3
3
  @import '../../../configurations/theme-colors';
4
4
  $butonSizes: (
5
- "xs": 12px,
6
- "sm": 16px,
7
- "md": 24px,
5
+ "xs": 20px,
6
+ "sm": 28px,
7
+ "md": 32px,
8
8
  "lg": 48px,
9
9
  "xl": 56px,
10
10
  'default': 36px,
@@ -225,7 +225,7 @@ export const Rounded = () => ({
225
225
  export const Sizes = () => ({
226
226
  data() {
227
227
  return {
228
- sizes: ['xs', 'sm', 'md', 'lg', 'xl'],
228
+ sizes: ['xs', 'sm', 'md', 'lg', 'xl', 'default'],
229
229
  styles: {
230
230
  display: 'flex',
231
231
  flexDirection: 'row',
@@ -52,6 +52,13 @@ export default Vue.extend({
52
52
  type: Boolean,
53
53
  default: false,
54
54
  },
55
+ /**
56
+ * Popup Width
57
+ */
58
+ popupWidth: {
59
+ type: [Number, String],
60
+ default: null,
61
+ },
55
62
  },
56
63
  setup(props, { emit }) {
57
64
  const parent = ref(null);
@@ -127,10 +134,14 @@ export default Vue.extend({
127
134
 
128
135
  let offsetLeft = activatorBoundingClientRect.left;
129
136
 
130
- styles.minWidth =
131
- (activatorBoundingClientRect.width > 96
132
- ? parseInt(activatorBoundingClientRect.width)
133
- : 96) + 'px';
137
+ if (props.popupWidth) {
138
+ styles.minWidth = props.popupWidth + 'px';
139
+ } else {
140
+ styles.minWidth =
141
+ (activatorBoundingClientRect.width > 96
142
+ ? parseInt(activatorBoundingClientRect.width)
143
+ : 96) + 'px';
144
+ }
134
145
 
135
146
  if (activatorBoundingClientRect.width < 96) {
136
147
  const w = popupClientRect.width < 96 ? 96 : popupClientRect.width;
@@ -0,0 +1,20 @@
1
+ .datepicker :deep(.v-picker__actions) {
2
+ padding: 0;
3
+ margin: 0 16px 16px;
4
+ }
5
+ .datepicker :deep(.v-btn--active) {
6
+ background: var(--farm-primary-base);
7
+ }
8
+ .datepicker :deep(.v-date-picker-table__current) {
9
+ border-color: var(--farm-primary-base);
10
+ color: var(--farm-primary-base);
11
+ }
12
+ .datepicker :deep(.v-date-picker-table__current.v-btn--active) {
13
+ color: white;
14
+ }
15
+ .btn-clean {
16
+ margin: 0 8px;
17
+ }
18
+ .farm-contextmenu {
19
+ width: 100%;
20
+ }
@@ -29,25 +29,40 @@ export const Primary = () => ({
29
29
  });
30
30
 
31
31
  export const InitValue = () => ({
32
- template: `<div style='max-width: 320px'><farm-input-datepicker inputId="input-custom-id-1" value="2021-08-01" /></div>`,
32
+ data() {
33
+ return {
34
+ date: '2023-08-01',
35
+ };
36
+ },
37
+ template: `<div style='max-width: 320px'><farm-input-datepicker inputId="input-custom-id-1" v-model="date" /></div>`,
33
38
  });
34
39
 
35
40
  export const MinMaxDates = () => ({
41
+ data() {
42
+ return {
43
+ date: '',
44
+ };
45
+ },
36
46
  template: `<div style='max-width: 320px'>
37
- <farm-input-datepicker inputId="input-custom-id-2" max="2021-12-02" min="2021-07-01" />
47
+ <farm-input-datepicker inputId="input-custom-id-2" max="2021-12-02" min="2021-07-01" v-model="date" />
38
48
  max="2021-12-02" min="2021-07-01"
39
49
  </div>`,
40
50
  });
41
51
 
42
52
  export const RequiredDates = () => ({
53
+ data() {
54
+ return {
55
+ date: '',
56
+ };
57
+ },
43
58
  template: `<div style='max-width: 320px'>
44
- <farm-input-datepicker inputId="input-custom-id-3" :required="true" />
59
+ <farm-input-datepicker inputId="input-custom-id-3" v-model="date" :required="true" />
45
60
  </div>`,
46
61
  });
47
62
 
48
- export const ReadonlyFalse = () => ({
63
+ export const Readonly = () => ({
49
64
  template: `<div style='max-width: 320px'>
50
- <farm-input-datepicker :readonly="false" inputId="input-custom-id-3"/>
65
+ <farm-input-datepicker :readonly="true" value="2021-08-01" inputId="input-custom-id-3"/>
51
66
  </div>`,
52
67
  });
53
68
 
@@ -1,50 +1,48 @@
1
1
  <template>
2
- <v-menu
3
- ref="menuField"
2
+ <farm-contextmenu
3
+ stay-open
4
4
  v-model="menuField"
5
- :close-on-content-click="false"
6
- :return-value.sync="fieldRange"
7
- transition="scale-transition"
8
- offset-y
9
- min-width="290px"
5
+ ref="contextmenu"
6
+ maxHeight="auto"
7
+ bottom
8
+ popup-width="320"
10
9
  >
11
- <template v-slot:activator="{}">
12
- <farm-textfield-v2
13
- icon="calendar"
14
- v-model="fieldRange"
15
- autocomplete="off"
16
- :readonly="readonly"
17
- :mask="`${readonly ? '' : '##/##/####'}`"
18
- :id="inputId"
19
- :rules="[checkMax, checkMin, checkRequire]"
20
- @keyup="keyUpInput"
21
- @click="openDatepicker"
22
- @onClickIcon="openDatepicker"
23
- />
24
- </template>
25
10
  <v-date-picker
26
11
  v-if="menuField"
27
12
  v-model="dateField"
28
13
  no-title
29
14
  scrollable
30
- color="secondary"
31
15
  locale="pt-br"
16
+ class="datepicker"
32
17
  :max="max"
33
18
  :min="min"
34
19
  >
35
20
  <farm-btn outlined color="secondary" @click="closeDatepicker" title="Fechar">
36
21
  Fechar
37
22
  </farm-btn>
38
- <farm-btn outlined class="ml-2" @click="clear"> Limpar </farm-btn>
23
+ <farm-btn outlined class="btn-clean" @click="clear"> Limpar </farm-btn>
39
24
  <farm-btn class="ml-2" title="Confirmar" :disabled="!dateField.length" @click="save()">
40
25
  Confirmar
41
26
  </farm-btn>
42
27
  </v-date-picker>
43
- </v-menu>
28
+ <template v-slot:activator="{ }">
29
+ <farm-textfield-v2
30
+ icon="calendar"
31
+ v-model="fieldRange"
32
+ autocomplete="off"
33
+ :readonly="readonly"
34
+ :mask="`${readonly ? '' : '##/##/####'}`"
35
+ :id="inputId"
36
+ :rules="[checkMax, checkMin, checkRequire]"
37
+ @keyup="keyUpInput"
38
+ @click="openDatepicker"
39
+ @onClickIcon="openDatepicker"
40
+ />
41
+ </template>
42
+ </farm-contextmenu>
44
43
  </template>
45
44
  <script lang="ts">
46
45
  import Vue from 'vue';
47
- import { VMenu } from 'vuetify/lib/components/VMenu';
48
46
  import { VDatePicker } from 'vuetify/lib/components/VDatePicker';
49
47
  import { defaultFormat as dateDefaultFormatter, convertDate } from '../../helpers/date';
50
48
  /**
@@ -53,7 +51,6 @@ import { defaultFormat as dateDefaultFormatter, convertDate } from '../../helper
53
51
  export default Vue.extend({
54
52
  name: 'farm-input-datepicker',
55
53
  components: {
56
- VMenu,
57
54
  VDatePicker,
58
55
  },
59
56
  props: {
@@ -155,8 +152,10 @@ export default Vue.extend({
155
152
  return dateDefaultFormatter(date);
156
153
  },
157
154
  save() {
158
- this.$refs.menuField.save(this.formatDateRange(this.dateField));
155
+ this.formatDateRange(this.dateField);
159
156
  this.inputVal = this.dateField;
157
+ this.menuField = false;
158
+ this.closeDatepicker();
160
159
  },
161
160
  clear() {
162
161
  this.dateField = '';
@@ -185,6 +184,7 @@ export default Vue.extend({
185
184
  },
186
185
  closeDatepicker() {
187
186
  this.menuField = false;
187
+ this.$refs.contextmenu.inputValue = false;
188
188
  },
189
189
  },
190
190
  computed: {
@@ -200,7 +200,5 @@ export default Vue.extend({
200
200
  });
201
201
  </script>
202
202
  <style lang="scss" scoped>
203
- .theme--light.v-input.v-input--dense.v-text-field.v-text-field--outlined.error--text:after {
204
- content: '' !important;
205
- }
203
+ @import './DatePicker.scss';
206
204
  </style>
@@ -25,7 +25,7 @@ export default {
25
25
  export const Primary = () => ({
26
26
  data() {
27
27
  return {
28
- date: [],
28
+ date: null,
29
29
  };
30
30
  },
31
31
  template: `<div style='max-width: 320px'>
@@ -34,8 +34,16 @@ export const Primary = () => ({
34
34
  </div>`,
35
35
  });
36
36
 
37
- export const Secondary = () => ({
38
- template: `<RangeDatePicker inputId="input-custom-id" :value="['2021-08-01', '2021-08-05']" />`,
37
+ export const InitialValue = () => ({
38
+ data() {
39
+ return {
40
+ date: ['2023-08-01', '2023-08-05'],
41
+ };
42
+ },
43
+ template: `<div style='max-width: 320px'>
44
+ <RangeDatePicker inputId="input-custom-id" :value="date" />
45
+ date: {{ date }}
46
+ </div>`,
39
47
  });
40
48
 
41
49
  export const MinMax = () => ({
@@ -1,27 +1,15 @@
1
1
  <template>
2
- <v-menu
3
- ref="menuField"
2
+ <farm-contextmenu
3
+ stay-open
4
4
  v-model="menuField"
5
- :close-on-content-click="false"
6
- :nudge-right="40"
7
- :return-value.sync="fieldRange"
8
- transition="scale-transition"
9
- offset-y
10
- min-width="290px"
5
+ ref="contextmenu"
6
+ maxHeight="auto"
7
+ bottom
8
+ popup-width="320"
11
9
  >
12
- <template v-slot:activator="{}">
13
- <farm-textfield-v2
14
- v-model="fieldRange"
15
- icon="calendar"
16
- readonly
17
- :id="inputId"
18
- :rules="required ? [requiredRule] : []"
19
- @click="openDatepicker"
20
- @onClickIcon="openDatepicker"
21
- />
22
- </template>
23
10
  <v-date-picker
24
11
  v-if="menuField"
12
+ class="datepicker"
25
13
  v-model="dateField"
26
14
  no-title
27
15
  scrollable
@@ -34,18 +22,27 @@
34
22
  <farm-btn outlined color="secondary" @click="closeDatepicker" title="Fechar">
35
23
  Fechar
36
24
  </farm-btn>
37
- <farm-btn outlined class="ml-2" @click="clear()" title="Limpar"> Limpar</farm-btn>
38
- <farm-btn class="ml-2" :disabled="canConfirm" @click="save()" title="Confirmar">
25
+ <farm-btn outlined class="btn-clean" @click="clear"> Limpar </farm-btn>
26
+ <farm-btn class="ml-2" title="Confirmar" :disabled="!dateField.length" @click="save()">
39
27
  Confirmar
40
28
  </farm-btn>
41
29
  </v-date-picker>
42
- </v-menu>
30
+ <template v-slot:activator="{}">
31
+ <farm-textfield-v2
32
+ v-model="fieldRange"
33
+ icon="calendar"
34
+ readonly
35
+ :id="inputId"
36
+ :rules="required ? [requiredRule] : []"
37
+ @click="openDatepicker"
38
+ @onClickIcon="openDatepicker"
39
+ />
40
+ </template>
41
+ </farm-contextmenu>
43
42
  </template>
44
43
  <script>
45
44
  import Vue from 'vue';
46
- import { VMenu } from 'vuetify/lib/components/VMenu';
47
45
  import { VDatePicker } from 'vuetify/lib/components/VDatePicker';
48
- import DefaultButton from '../Buttons/DefaultButton';
49
46
  import { defaultFormat as dateDefaultFormatter } from '../../helpers/date';
50
47
  /**
51
48
  * Componente de input com datepicker para range de data
@@ -53,9 +50,7 @@ import { defaultFormat as dateDefaultFormatter } from '../../helpers/date';
53
50
  export default Vue.extend({
54
51
  name: 'farm-input-rangedatepicker',
55
52
  components: {
56
- VMenu,
57
53
  VDatePicker,
58
- 'farm-btn': DefaultButton,
59
54
  },
60
55
  props: {
61
56
  /**
@@ -70,9 +65,7 @@ export default Vue.extend({
70
65
  */
71
66
  value: {
72
67
  type: Array,
73
- default: () => {
74
- return [];
75
- },
68
+ default: () => [],
76
69
  },
77
70
  /**
78
71
  * Variável usada para definir a data máxima (yyyy-mm-dd)
@@ -100,7 +93,7 @@ export default Vue.extend({
100
93
  const s = this.formatDateRange(this.value);
101
94
  return {
102
95
  menuField: false,
103
- dateField: this.value,
96
+ dateField: this.value || [],
104
97
  fieldRange: s,
105
98
  requiredRule: value => {
106
99
  return !!value || value != '' || 'Campo obrigatório';
@@ -127,9 +120,10 @@ export default Vue.extend({
127
120
  return dateDefaultFormatter(dateStart) + ' a ' + dateDefaultFormatter(dateEnd);
128
121
  },
129
122
  save() {
130
- this.$refs.menuField.save(this.formatDateRange(this.dateField));
123
+ this.formatDateRange(this.dateField);
131
124
  this.inputVal = this.dateField;
132
125
  this.menuField = false;
126
+ this.closeDatepicker();
133
127
  },
134
128
  clear() {
135
129
  this.dateField = [];
@@ -140,6 +134,7 @@ export default Vue.extend({
140
134
  },
141
135
  closeDatepicker() {
142
136
  this.menuField = false;
137
+ this.$refs.contextmenu.inputValue = false;
143
138
  },
144
139
  },
145
140
  computed: {
@@ -158,7 +153,5 @@ export default Vue.extend({
158
153
  });
159
154
  </script>
160
155
  <style lang="scss" scoped>
161
- .theme--light.v-input.v-input--dense.v-text-field.v-text-field--outlined.error--text:after {
162
- content: '' !important;
163
- }
156
+ @import '../DatePicker/DatePicker.scss';
164
157
  </style>
@@ -1,8 +1,8 @@
1
1
  $colors: primary, secondary, error, accent, info, success, warning, gray, yellow, white;
2
2
  $sizes: (
3
3
  "xs": 12px,
4
- "sm": 16px,
5
- "md": 24px,
4
+ "sm": 14px,
5
+ "md": 20px,
6
6
  "lg": 36px,
7
7
  "xl": 40px
8
8
  );