@farm-investimentos/front-mfe-components 12.2.1 → 12.2.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": "12.2.1",
3
+ "version": "12.2.2",
4
4
  "author": "farm investimentos",
5
5
  "private": false,
6
6
  "main": "./dist/front-mfe-components.common.js",
@@ -62,3 +62,17 @@ export const Colors = () => ({
62
62
  <farm-alertbox class="mt-3" v-for="color of colors" :key="'random_10_' + color" :color="color" icon="book" dismissable>alert box</farm-alertbox>
63
63
  </div> `,
64
64
  });
65
+
66
+ export const withDismissableShowAgain = () => ({
67
+ data() {
68
+ return {
69
+ v: true,
70
+ }
71
+ },
72
+ template: `<div>
73
+ <farm-alertbox v-model="v" dismissable>alert box</farm-alertbox>
74
+ <farm-btn v-if="!v" @click="v = true;">
75
+ show
76
+ </farm-btn>
77
+ </div>`,
78
+ });
@@ -44,6 +44,7 @@
44
44
 
45
45
  <script lang="ts">
46
46
  import Vue, { ref, PropType } from 'vue';
47
+ import valueWatcher from './valueWatcher';
47
48
 
48
49
  export default Vue.extend({
49
50
  name: 'farm-alertbox',
@@ -87,20 +88,29 @@ export default Vue.extend({
87
88
  >,
88
89
  default: 'primary',
89
90
  },
91
+ value: {
92
+ type: Boolean,
93
+ default: true,
94
+ },
90
95
  },
91
- setup() {
96
+ setup(props, { emit }) {
92
97
  const visible = ref(true);
93
98
 
94
99
  function close() {
95
100
  visible.value = false;
101
+ emit('input', false);
96
102
  }
97
103
 
104
+ valueWatcher(props, visible);
105
+
98
106
  return {
99
107
  visible,
100
108
  close,
101
109
  };
102
110
  },
103
111
  });
112
+
113
+
104
114
  </script>
105
115
  <style lang="scss" scoped>
106
116
  @import './AlertBox';
@@ -0,0 +1,15 @@
1
+ import { ref, reactive } from 'vue';
2
+ import valueWatcher from '../valueWatcher';
3
+
4
+ describe('valueWatcher', () => {
5
+ it('Should change value for visible', done => {
6
+ const visible = ref(false);
7
+ const mockProps = reactive({ value: false });
8
+ valueWatcher(mockProps, visible);
9
+ mockProps.value = true;
10
+ setTimeout(() => {
11
+ expect(visible.value).toBeTruthy();
12
+ done();
13
+ });
14
+ });
15
+ });
@@ -0,0 +1,10 @@
1
+ import { Ref, watch } from 'vue';
2
+
3
+ export default function (props, visible: Ref) {
4
+ watch(
5
+ () => props.value,
6
+ (newValue: boolean) => {
7
+ visible.value = newValue;
8
+ }
9
+ );
10
+ }
@@ -160,15 +160,17 @@
160
160
  background-color: var(--farm-#{$color}-base);
161
161
  color: white;
162
162
 
163
- ::v-deep .farm-btn__content {
164
- i.mdi {
165
- color: white;
166
- }
167
-
168
- .farm-btn__content i.mdi {
169
- color: black;
163
+ &:not(.farm-btn--outlined):not(.farm-btn--plain):not(.farm-btn--icon) {
164
+ ::v-deep .farm-btn__content {
165
+ i.mdi {
166
+ color: white;
167
+ }
168
+ .farm-btn__content i.mdi {
169
+ color: black;
170
+ }
170
171
  }
171
172
  }
173
+
172
174
  }
173
175
 
174
176
  .farm-btn--extra,
@@ -172,17 +172,17 @@ export const Icons = () => ({
172
172
  template: `<div class="buttons-container">
173
173
  <h4>Full</h4>
174
174
  <farm-btn v-for="color of colors":key="'random_3_' + color" :color="color">
175
- <v-icon>mdi-book</v-icon> book
175
+ <farm-icon>book</farm-icon> book
176
176
  </farm-btn>
177
177
 
178
178
  <h4>Outlined</h4>
179
179
  <farm-btn v-for="color of colors":key="color + 'outlined'" :color="color" outlined>
180
- <v-icon>mdi-book</v-icon> book
180
+ <farm-icon>book</farm-icon> book
181
181
  </farm-btn>
182
182
 
183
183
  <h4>Plain</h4>
184
184
  <farm-btn v-for="color of colors":key="color + 'plain'" :color="color" plain>
185
- <v-icon>mdi-book</v-icon> book
185
+ <farm-icon color="primary">book</farm-icon> book
186
186
  </farm-btn>
187
187
 
188
188
 
@@ -35,8 +35,12 @@ export const Primary = () => ({
35
35
  };
36
36
  },
37
37
  template: `<div style="width: 120px;">
38
- <farm-select v-model="v" :items="items" />
38
+ <farm-label for="select_id">
39
+ label
40
+ </farm-label>
41
+ <farm-select id="select_id" v-model="v" :items="items" />
39
42
  v-model: {{ v }}
43
+
40
44
  </div>`,
41
45
  });
42
46
 
@@ -1,6 +1,5 @@
1
1
  <template>
2
2
  <div
3
- class="farm-textfield"
4
3
  :class="{
5
4
  'farm-textfield': true,
6
5
  'farm-textfield--validatable': rules.length > 0,
@@ -11,8 +10,9 @@
11
10
  'farm-textfield--hiddendetails': hideDetails,
12
11
  }"
13
12
  v-if="!readonly && !disabled"
13
+ :id="customId"
14
14
  >
15
- <farm-contextmenu bottom v-model="isVisible" :stay-open="multiple">
15
+ <farm-contextmenu bottom v-model="isVisible" :stay-open="multiple" ref="contextmenu">
16
16
  <farm-list v-if="!readonly">
17
17
  <farm-listitem
18
18
  v-for="(item, index) in items"
@@ -29,15 +29,15 @@
29
29
  value="1"
30
30
  size="sm"
31
31
  v-if="isChecked(item)"
32
- ></farm-checkbox>
32
+ />
33
33
  <farm-checkbox
34
34
  class="farm-select__checkbox"
35
35
  v-model="checked"
36
36
  value="2"
37
37
  size="sm"
38
38
  v-else-if="multiple"
39
- ></farm-checkbox
40
- ><farm-caption bold tag="span">{{ item[itemText] }}</farm-caption>
39
+ />
40
+ <farm-caption bold tag="span">{{ item[itemText] }}</farm-caption>
41
41
  </farm-listitem>
42
42
  <farm-listitem v-if="!items || items.length === 0">
43
43
  {{ noDataText }}
@@ -46,9 +46,9 @@
46
46
  <template v-slot:activator="{}">
47
47
  <div class="farm-textfield--input farm-textfield--input--iconed">
48
48
  <input
49
+ v-bind="$attrs"
50
+ :id="$props.id"
49
51
  v-model="selectedText"
50
- :disabled="disabled"
51
- :readonly="true"
52
52
  @click="clickInput"
53
53
  @keyup="onKeyUp"
54
54
  @blur="onBlur"
@@ -75,6 +75,7 @@ import validateFormStateBuilder from '../../composition/validateFormStateBuilder
75
75
  import validateFormFieldBuilder from '../../composition/validateFormFieldBuilder';
76
76
  import validateFormMethodBuilder from '../../composition/validateFormMethodBuilder';
77
77
  import deepEqual from '../../composition/deepEqual';
78
+ import randomId from '../../helpers/randomId';
78
79
 
79
80
  export default Vue.extend({
80
81
  name: 'farm-select',
@@ -152,6 +153,13 @@ export default Vue.extend({
152
153
  type: Boolean,
153
154
  default: false,
154
155
  },
156
+ /**
157
+ * Select id
158
+ */
159
+ id: {
160
+ type: String,
161
+ default: '',
162
+ },
155
163
  },
156
164
  setup(props, { emit }) {
157
165
  const { rules, items, itemText, itemValue, disabled, multiple } = toRefs(props);
@@ -173,6 +181,8 @@ export default Vue.extend({
173
181
  return errorBucket.value.length > 0;
174
182
  });
175
183
 
184
+ const customId = 'farm-select-' + (props.id || randomId(2));
185
+
176
186
  const showErrorText = computed(() => hasError.value && isTouched.value);
177
187
 
178
188
  watch(
@@ -334,6 +344,7 @@ export default Vue.extend({
334
344
  isTouched,
335
345
  isBlured,
336
346
  isVisible,
347
+ customId,
337
348
  showErrorText,
338
349
  validate,
339
350
  reset,
@@ -17,8 +17,9 @@
17
17
  }"
18
18
  >
19
19
  <textarea
20
- v-bind="$attrs"
21
20
  v-model="innerValue"
21
+ v-bind="$attrs"
22
+ :id="$props.id"
22
23
  :rows="$props.rows"
23
24
  :disabled="disabled"
24
25
  :readonly="readonly"
@@ -42,6 +43,7 @@ import validateFormStateBuilder from '../../composition/validateFormStateBuilder
42
43
  import validateFormFieldBuilder from '../../composition/validateFormFieldBuilder';
43
44
  import validateFormMethodBuilder from '../../composition/validateFormMethodBuilder';
44
45
  import deepEqual from '../../composition/deepEqual';
46
+ import randomId from '../../helpers/randomId';
45
47
 
46
48
  export default Vue.extend({
47
49
  name: 'farm-textarea',
@@ -95,6 +97,13 @@ export default Vue.extend({
95
97
  type: Boolean,
96
98
  default: false,
97
99
  },
100
+ /**
101
+ * Select id
102
+ */
103
+ id: {
104
+ type: String,
105
+ default: '',
106
+ },
98
107
  },
99
108
  setup(props, { emit }) {
100
109
  const { rules } = toRefs(props);
@@ -109,6 +118,7 @@ export default Vue.extend({
109
118
  const hasError = computed(() => {
110
119
  return errorBucket.value.length > 0;
111
120
  });
121
+ const customId = 'farm-textarea-' + (props.id || randomId(2));
112
122
 
113
123
  const showErrorText = computed(() => hasError.value && isTouched.value);
114
124
 
@@ -171,6 +181,7 @@ export default Vue.extend({
171
181
  valid,
172
182
  validatable,
173
183
  hasError,
184
+ customId,
174
185
  isTouched,
175
186
  isBlured,
176
187
  showErrorText,
@@ -39,7 +39,10 @@ export const Primary = () => ({
39
39
  };
40
40
  },
41
41
  template: `<div style="width: 480px;">
42
- <farm-textfield-v2 v-model="v" />
42
+ <farm-label for="select_label">
43
+ label
44
+ </farm-label>
45
+ <farm-textfield-v2 id="select_label" v-model="v" />
43
46
  v-model: {{ v }}
44
47
  </div>`,
45
48
  });
@@ -10,6 +10,7 @@
10
10
  'farm-textfield--disabled': disabled,
11
11
  'farm-textfield--hiddendetails': hideDetails,
12
12
  }"
13
+ :id="customId"
13
14
  >
14
15
  <div
15
16
  :class="{
@@ -28,6 +29,7 @@
28
29
  v-bind="$attrs"
29
30
  v-model="innerValue"
30
31
  v-mask="mask"
32
+ :id="$props.id"
31
33
  :disabled="disabled"
32
34
  :readonly="readonly"
33
35
  @click="$emit('click')"
@@ -61,6 +63,7 @@ import validateFormStateBuilder from '../../composition/validateFormStateBuilder
61
63
  import validateFormFieldBuilder from '../../composition/validateFormFieldBuilder';
62
64
  import validateFormMethodBuilder from '../../composition/validateFormMethodBuilder';
63
65
  import deepEqual from '../../composition/deepEqual';
66
+ import randomId from '../../helpers/randomId';
64
67
 
65
68
  export default Vue.extend({
66
69
  name: 'farm-textfield-v2',
@@ -125,6 +128,13 @@ export default Vue.extend({
125
128
  type: Boolean,
126
129
  default: false,
127
130
  },
131
+ /**
132
+ * Input id
133
+ */
134
+ id: {
135
+ type: String,
136
+ default: '',
137
+ },
128
138
  },
129
139
  setup(props, { emit }) {
130
140
  const { rules } = toRefs(props);
@@ -139,6 +149,7 @@ export default Vue.extend({
139
149
  const hasError = computed(() => {
140
150
  return errorBucket.value.length > 0;
141
151
  });
152
+ const customId = 'farm-textfield-' + (props.id || randomId(2));
142
153
 
143
154
  const showErrorText = computed(() => hasError.value && isTouched.value);
144
155
 
@@ -201,6 +212,7 @@ export default Vue.extend({
201
212
  valid,
202
213
  validatable,
203
214
  hasError,
215
+ customId,
204
216
  isTouched,
205
217
  isBlured,
206
218
  showErrorText,
@@ -0,0 +1,9 @@
1
+ export default (length: number) => {
2
+ let text = '';
3
+ const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
4
+
5
+ for (let i = 0; i < length; i++) {
6
+ text += possible.charAt(Math.floor(Math.random() * possible.length));
7
+ }
8
+ return text;
9
+ };