@farm-investimentos/front-mfe-components 3.4.4 → 3.4.5

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": "3.4.4",
3
+ "version": "3.4.5",
4
4
  "author": "farm investimentos",
5
5
  "private": false,
6
6
  "main": "./dist/front-mfe-components.common.js",
@@ -42,6 +42,7 @@
42
42
  "eslint": "^6.7.2",
43
43
  "eslint-plugin-vue": "^6.2.2",
44
44
  "storybook-addon-designs": "^6.2.1",
45
+ "v-mask": "^2.3.0",
45
46
  "vue-template-compiler": "^2.6.11",
46
47
  "webpack-cli": "^4.9.0"
47
48
  },
@@ -1,8 +1,19 @@
1
+ import { withDesign } from 'storybook-addon-designs';
1
2
  import DefaultTextField from './DefaultTextField.vue';
2
3
 
3
4
  export default {
4
5
  title: 'API/Form/DefaultTextField',
5
6
  component: DefaultTextField,
7
+ decorators: [withDesign],
8
+ parameters: {
9
+ viewMode: 'docs',
10
+ docs: {
11
+ description: {
12
+ component: `Default Text Field with label (inherit from Vuetify)<br />
13
+ selector: <em>farm-textfield-labelled</em>`,
14
+ },
15
+ },
16
+ },
6
17
  };
7
18
 
8
19
  export const Primary = () => ({
@@ -10,7 +21,7 @@ export const Primary = () => ({
10
21
  data() {
11
22
  return {
12
23
  model: 'primary',
13
- item: { label: 'Nome do campo', key: 'key' },
24
+ item: { label: 'Nome do campo', key: 'key', md: 4 },
14
25
  };
15
26
  },
16
27
  template: '<DefaultTextField v-model="model" :item="item" />',
@@ -21,10 +32,12 @@ export const Secondary = () => ({
21
32
  data() {
22
33
  return {
23
34
  model: 'secondary',
24
- item: { label: 'Nome do campo', key: 'key' },
35
+ item: { label: 'Nome do campo', key: 'key', md: 4 },
25
36
  };
26
37
  },
27
- template: '<DefaultTextField :item="item" v-model="model" required="true" />',
38
+ template: `<v-form>
39
+ <DefaultTextField :item="item" v-model="model" :required="true" />
40
+ </v-form>`,
28
41
  });
29
42
 
30
43
  export const ReadOnly = () => ({
@@ -32,12 +45,28 @@ export const ReadOnly = () => ({
32
45
  data() {
33
46
  return {
34
47
  model: 'readonly',
35
- item: { label: 'Nome do campo', key: 'key' },
48
+ item: { label: 'Nome do campo', key: 'key', md: 4 },
36
49
  };
37
50
  },
38
51
  template: '<DefaultTextField :item="item" v-model="model" :readonly="true" />',
39
52
  });
40
53
 
41
- Primary.storyName = 'Básico';
42
- Secondary.storyName = 'Label de obrigatório';
43
- ReadOnly.storyName = 'Input readonly';
54
+ export const Masked = () => ({
55
+ components: { DefaultTextField },
56
+ data() {
57
+ return {
58
+ model: '12345',
59
+ item: { label: 'Máscara (##.###)', key: 'key', md: 4 },
60
+ };
61
+ },
62
+ template: `
63
+ <v-form>
64
+ <DefaultTextField :item="item" v-model="model" mask="##.###" />
65
+ </v-form>
66
+ `,
67
+ });
68
+
69
+ Primary.storyName = 'Basic';
70
+ Secondary.storyName = 'Required field';
71
+ ReadOnly.storyName = 'Readonly input';
72
+ Masked.storyName = 'Masked';
@@ -18,14 +18,20 @@
18
18
  </v-col>
19
19
  </template>
20
20
  <script>
21
+ import Vue from 'vue';
21
22
  import { VTextField } from 'vuetify/lib/components/VTextField';
22
23
  import { VCol } from 'vuetify/lib/components/VGrid';
23
- export default {
24
+
25
+ export default Vue.extend({
26
+ name: 'farm-textfield-labelled',
24
27
  props: {
25
28
  item: {
26
29
  type: Object,
27
30
  required: true,
28
31
  },
32
+ /**
33
+ * v-model
34
+ */
29
35
  value: {
30
36
  required: true,
31
37
  },
@@ -61,6 +67,9 @@ export default {
61
67
  type: String,
62
68
  default: null,
63
69
  },
70
+ /**
71
+ * Input is readonly or not
72
+ */
64
73
  readonly: {
65
74
  type: Boolean,
66
75
  default: false,
@@ -92,5 +101,5 @@ export default {
92
101
  return `${this.forKey}-${this.item.key}`;
93
102
  },
94
103
  },
95
- };
104
+ });
96
105
  </script>
@@ -29,5 +29,26 @@ describe('DefaultTextField component', () => {
29
29
  it('Should have inputId', () => {
30
30
  expect(component.inputId).toEqual('form-key');
31
31
  });
32
+
33
+ it('Should have default inputRules', () => {
34
+ expect(component.inputRules).toEqual([]);
35
+ });
36
+
37
+ it('Should have inputRules from prop', async () => {
38
+ expect(component.inputRules).toEqual([]);
39
+ await wrapper.setProps({
40
+ rules: [jest.fn()],
41
+ });
42
+ expect(component.inputRules.length).toEqual(1);
43
+ });
44
+
45
+ it('Should not have inputRules if disabled', async () => {
46
+ expect(component.inputRules).toEqual([]);
47
+ await wrapper.setProps({
48
+ rules: [jest.fn()],
49
+ disabled: true,
50
+ });
51
+ expect(component.inputRules.length).toEqual(0);
52
+ });
32
53
  });
33
54
  });