@farm-investimentos/front-mfe-components 11.6.2 → 11.7.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.
Files changed (35) hide show
  1. package/dist/front-mfe-components.common.js +806 -643
  2. package/dist/front-mfe-components.common.js.map +1 -1
  3. package/dist/front-mfe-components.css +1 -1
  4. package/dist/front-mfe-components.umd.js +806 -643
  5. package/dist/front-mfe-components.umd.js.map +1 -1
  6. package/dist/front-mfe-components.umd.min.js +1 -1
  7. package/dist/front-mfe-components.umd.min.js.map +1 -1
  8. package/package.json +1 -1
  9. package/src/components/DatePicker/DatePicker.stories.js +7 -12
  10. package/src/components/DatePicker/DatePicker.vue +9 -17
  11. package/src/components/FilePicker/FilePicker.vue +10 -15
  12. package/src/components/FilePicker/__tests__/FilePicker.spec.js +12 -4
  13. package/src/components/Form/Form.stories.js +53 -47
  14. package/src/components/MainFilter/MainFilter.scss +1 -1
  15. package/src/components/MainFilter/MainFilter.vue +14 -8
  16. package/src/components/MainFilter/__tests__/MainFilter.spec.js +4 -0
  17. package/src/components/RangeDatePicker/RangeDatePicker.stories.js +23 -25
  18. package/src/components/RangeDatePicker/RangeDatePicker.vue +6 -14
  19. package/src/components/ResourceMetaInfo/ResourceMetaInfo.scss +14 -0
  20. package/src/components/ResourceMetaInfo/ResourceMetaInfo.stories.js +119 -0
  21. package/src/components/ResourceMetaInfo/ResourceMetaInfo.vue +100 -0
  22. package/src/components/ResourceMetaInfo/__tests__/ResourceMetaInfo.spec.js +128 -0
  23. package/src/components/ResourceMetaInfo/index.ts +4 -0
  24. package/src/components/Tabs/Tabs.stories.js +11 -0
  25. package/src/components/TextFieldV2/TextFieldV2.scss +14 -2
  26. package/src/components/TextFieldV2/TextFieldV2.stories.js +1 -0
  27. package/src/components/TextFieldV2/TextFieldV2.vue +7 -4
  28. package/src/components/Typography/BodyText/BodyText.stories.js +2 -2
  29. package/src/components/Typography/Caption/Caption.stories.js +2 -1
  30. package/src/components/Typography/Heading/Heading.stories.js +2 -1
  31. package/src/components/Typography/OverlayText/OverlayText.stories.js +2 -1
  32. package/src/components/Typography/Subtitle/Subtitle.stories.js +2 -3
  33. package/src/components/layout/Basic.stories.js +21 -0
  34. package/src/components/layout/Container/Container.scss +1 -0
  35. package/src/main.ts +2 -1
@@ -0,0 +1,119 @@
1
+ import ResourceMetaInfo from './ResourceMetaInfo.vue';
2
+
3
+ export default {
4
+ title: 'Display/ResourceMetaInfo',
5
+ component: ResourceMetaInfo,
6
+ parameters: {
7
+ docs: {
8
+ description: {
9
+ component: `ResourceMetaInfo<br />
10
+ selector: <em>farm-resource-metainfo</em><br />
11
+ <span style="color: var(--farm-primary-base);">ready for use</span>
12
+ `,
13
+ },
14
+ },
15
+ viewMode: 'docs',
16
+ },
17
+ };
18
+
19
+ export const Primary = () => ({
20
+ data() {
21
+ return {
22
+ value: false,
23
+ info: {
24
+ createdAt: '21/10/2022',
25
+ updatedAt: '21/10/2022',
26
+ username: 'Test User',
27
+ updatedHours: '10:10:10',
28
+ },
29
+ };
30
+ },
31
+ template: `<div>
32
+ <farm-resource-metainfo :infos="info" />
33
+ </div>`,
34
+ });
35
+
36
+ export const WithoutUpdate = () => ({
37
+ data() {
38
+ return {
39
+ value: false,
40
+ info: {
41
+ createdAt: '21/10/2022',
42
+ updatedAt: null,
43
+ username: 'Test User',
44
+ updatedHours: '10:10:10',
45
+ },
46
+ };
47
+ },
48
+ template: `<div>
49
+ <farm-resource-metainfo :infos="info" />
50
+ </div>`,
51
+ });
52
+
53
+ export const WithoutCreate = () => ({
54
+ data() {
55
+ return {
56
+ value: false,
57
+ info: {
58
+ createdAt: null,
59
+ updatedAt: '21/10/2022',
60
+ username: 'Test User',
61
+ updatedHours: '10:10:10',
62
+ },
63
+ };
64
+ },
65
+ template: `<div>
66
+ <farm-resource-metainfo :infos="info" />
67
+ </div>`,
68
+ });
69
+
70
+ export const ShowUpdateWithNA = () => ({
71
+ data() {
72
+ return {
73
+ value: false,
74
+ info: {
75
+ createdAt: null,
76
+ updatedAt: null,
77
+ username: null,
78
+ updatedHours: null,
79
+ },
80
+ };
81
+ },
82
+ template: `<div>
83
+ <farm-resource-metainfo :infos="info" show-empty-update />
84
+ </div>`,
85
+ });
86
+
87
+ export const ShowCreateWithNA = () => ({
88
+ data() {
89
+ return {
90
+ value: false,
91
+ info: {
92
+ createdAt: null,
93
+ updatedAt: null,
94
+ username: null,
95
+ updatedHours: null,
96
+ },
97
+ };
98
+ },
99
+ template: `<div>
100
+ <farm-resource-metainfo :infos="info" show-empty-create />
101
+ </div>`,
102
+ });
103
+
104
+ export const ShowBothWithNA = () => ({
105
+ data() {
106
+ return {
107
+ value: false,
108
+ info: {
109
+ createdAt: null,
110
+ updatedAt: null,
111
+ username: null,
112
+ updatedHours: null,
113
+ },
114
+ };
115
+ },
116
+ template: `<div>
117
+ <farm-resource-metainfo :infos="info" show-empty-create show-empty-update />
118
+ </div>`,
119
+ });
@@ -0,0 +1,100 @@
1
+ <template>
2
+ <div class="farm-resource-metainfo">
3
+ <div v-if="showCreate">
4
+ <farm-icon color="gray" size="sm">calendar-blank</farm-icon>
5
+ <farm-caption color="gray" variation="regular">
6
+ Data de cadastro:
7
+ <farm-caption color="gray" variation="medium" tag="span">
8
+ {{ formattedCreatedAt }}
9
+ </farm-caption>
10
+ </farm-caption>
11
+ </div>
12
+ <div v-if="showUpdate">
13
+ <farm-icon color="gray" size="sm">history</farm-icon>
14
+
15
+ <farm-caption color="gray" variation="regular">
16
+ Última atualização feita por
17
+ <farm-caption color="gray" variation="medium" tag="span">
18
+ {{ formattedUsername }}
19
+ </farm-caption>
20
+ , dia
21
+ <farm-caption color="gray" variation="medium" tag="span">
22
+ {{ formattedUpdatedAt }}
23
+ </farm-caption>
24
+ às
25
+ <farm-caption color="gray" variation="medium" tag="span">
26
+ {{ formattedUpdatedHours }}
27
+ </farm-caption>
28
+ </farm-caption>
29
+ </div>
30
+ </div>
31
+ </template>
32
+ <script lang="ts">
33
+ import Vue, { computed, PropType, toRefs } from 'vue';
34
+
35
+ interface ResourceMetaInfoProps {
36
+ createdAt: string;
37
+ updatedAt: string;
38
+ username: string;
39
+ updatedHours: string;
40
+ }
41
+
42
+ export default Vue.extend({
43
+ name: 'farm-resource-metainfo',
44
+ props: {
45
+ /**
46
+ * Object with the metadata information
47
+ */
48
+ infos: {
49
+ required: true,
50
+ type: Object as PropType<ResourceMetaInfoProps>,
51
+ },
52
+ /**
53
+ * Show create metadata info if empty?
54
+ */
55
+ showEmptyCreate: {
56
+ type: Boolean,
57
+ default: false,
58
+ },
59
+ /**
60
+ * Show update metadata info if empty?
61
+ */
62
+ showEmptyUpdate: {
63
+ type: Boolean,
64
+ default: false,
65
+ },
66
+ },
67
+ setup(props) {
68
+ const { infos, showEmptyCreate, showEmptyUpdate } = toRefs(props);
69
+
70
+ const showUpdate = computed(
71
+ () =>
72
+ (infos.value.updatedAt !== null && infos.value.updatedAt !== undefined) ||
73
+ showEmptyUpdate.value
74
+ );
75
+
76
+ const showCreate = computed(
77
+ () =>
78
+ (infos.value.createdAt !== null && infos.value.createdAt !== undefined) ||
79
+ showEmptyCreate.value
80
+ );
81
+
82
+ const formattedCreatedAt = computed(() => infos.value.createdAt || 'N/A');
83
+ const formattedUpdatedAt = computed(() => infos.value.updatedAt || 'N/A');
84
+ const formattedUsername = computed(() => infos.value.username || 'N/A');
85
+ const formattedUpdatedHours = computed(() => infos.value.updatedHours || 'N/A');
86
+
87
+ return {
88
+ showUpdate,
89
+ showCreate,
90
+ formattedCreatedAt,
91
+ formattedUpdatedAt,
92
+ formattedUsername,
93
+ formattedUpdatedHours,
94
+ };
95
+ },
96
+ });
97
+ </script>
98
+ <style lang="scss" scoped>
99
+ @import 'ResourceMetaInfo';
100
+ </style>
@@ -0,0 +1,128 @@
1
+ import { shallowMount } from '@vue/test-utils';
2
+ import ResourceMetaInfo from '../ResourceMetaInfo.vue';
3
+
4
+ describe('ResourceMetaInfo component', () => {
5
+ let wrapper;
6
+ let component;
7
+
8
+ beforeEach(() => {
9
+ wrapper = shallowMount(ResourceMetaInfo, {
10
+ propsData: {
11
+ infos: {
12
+ createdAt: '21/10/2022',
13
+ updatedAt: '21/10/2022',
14
+ username: 'Test User',
15
+ updatedHours: '10:10:10',
16
+ },
17
+ },
18
+ });
19
+
20
+ component = wrapper.vm;
21
+ });
22
+
23
+ test('Created hook', () => {
24
+ expect(wrapper).toBeDefined();
25
+ });
26
+
27
+ describe('mount component', () => {
28
+ it('renders correctly', () => {
29
+ expect(wrapper.element).toMatchSnapshot();
30
+ });
31
+ });
32
+
33
+ describe('Computed', () => {
34
+ describe('showUpdate', () => {
35
+ it('should return true when it has an update date', () => {
36
+ expect(component.showUpdate).toBeTruthy();
37
+ });
38
+
39
+ it('should return false when it has not an update date', async () => {
40
+ await wrapper.setProps({
41
+ infos: { updatedAt: null },
42
+ });
43
+ expect(component.showUpdate).toBeFalsy();
44
+ });
45
+
46
+ it('should return true when it has not an update date but showEmptyUpdate is true', async () => {
47
+ await wrapper.setProps({
48
+ infos: { updatedAt: null },
49
+ showEmptyUpdate: true,
50
+ });
51
+ expect(component.showUpdate).toBeTruthy();
52
+ });
53
+ });
54
+
55
+ describe('showCreate', () => {
56
+ it('should return true when it has an create date', () => {
57
+ expect(component.showCreate).toBeTruthy();
58
+ });
59
+
60
+ it('should return false when it has not an create date', async () => {
61
+ await wrapper.setProps({
62
+ infos: { createAt: null },
63
+ });
64
+ expect(component.showCreate).toBeFalsy();
65
+ });
66
+
67
+ it('should return true when it has not an update date but showEmptyCreate is true', async () => {
68
+ await wrapper.setProps({
69
+ infos: { createAt: null },
70
+ showEmptyCreate: true,
71
+ });
72
+ expect(component.showCreate).toBeTruthy();
73
+ });
74
+ });
75
+
76
+ describe('formattedCreatedAt', () => {
77
+ it('should return infos createdAt', () => {
78
+ expect(component.formattedCreatedAt).toBe('21/10/2022');
79
+ });
80
+
81
+ it('should return N/A when infos createdAt is empty', async () => {
82
+ await wrapper.setProps({
83
+ infos: { createAt: null },
84
+ });
85
+ expect(component.formattedCreatedAt).toBe('N/A');
86
+ });
87
+ });
88
+
89
+ describe('formattedUpdatedAt', () => {
90
+ it('should return infos updatedAt', () => {
91
+ expect(component.formattedUpdatedAt).toBe('21/10/2022');
92
+ });
93
+
94
+ it('should return N/A when infos updatedAt is empty', async () => {
95
+ await wrapper.setProps({
96
+ infos: { updatedAt: null },
97
+ });
98
+ expect(component.formattedUpdatedAt).toBe('N/A');
99
+ });
100
+ });
101
+
102
+ describe('formattedUsername', () => {
103
+ it('should return infos updatedAt', () => {
104
+ expect(component.formattedUsername).toBe('Test User');
105
+ });
106
+
107
+ it('should return N/A when infos username is empty', async () => {
108
+ await wrapper.setProps({
109
+ infos: { username: null },
110
+ });
111
+ expect(component.formattedUsername).toBe('N/A');
112
+ });
113
+ });
114
+
115
+ describe('formattedUpdatedHours', () => {
116
+ it('should return infos updatedHours', () => {
117
+ expect(component.formattedUpdatedHours).toBe('10:10:10');
118
+ });
119
+
120
+ it('should return N/A when infos updatedHours is empty', async () => {
121
+ await wrapper.setProps({
122
+ infos: { updatedHours: null },
123
+ });
124
+ expect(component.formattedUpdatedHours).toBe('N/A');
125
+ });
126
+ });
127
+ });
128
+ });
@@ -0,0 +1,4 @@
1
+ import ResourceMetaInfo from './ResourceMetaInfo.vue';
2
+
3
+ export { ResourceMetaInfo };
4
+ export default ResourceMetaInfo;
@@ -3,6 +3,17 @@ import Tabs from './Tabs.vue';
3
3
  export default {
4
4
  title: 'Display/Tabs',
5
5
  component: Tabs,
6
+ parameters: {
7
+ docs: {
8
+ description: {
9
+ component: `Tabs<br />
10
+ selector: <em>farm-tabs</em><br />
11
+ <span style="color: var(--farm-primary-base);">ready for use</span>
12
+ `,
13
+ },
14
+ },
15
+ viewMode: 'docs',
16
+ },
6
17
  };
7
18
 
8
19
  export const Primary = () => ({
@@ -1,5 +1,6 @@
1
1
  .farm-textfield {
2
2
  height: 64px;
3
+
3
4
  &--input {
4
5
  display: flex;
5
6
  align-items: center;
@@ -11,19 +12,30 @@
11
12
  padding: 8px;
12
13
  margin-bottom: 4px;
13
14
 
14
- > button {
15
+ >button {
15
16
  display: flex;
16
17
  }
17
18
 
18
19
  &>input {
19
20
  flex: 1;
20
21
  outline: none;
21
- color: var(--farm-neutral-darken);
22
+ color: var(--farm-text-primary);
22
23
  font-size: 12px;
23
24
  font-weight: 400;
24
25
  }
25
26
 
26
27
  width: 100%;
28
+
29
+ }
30
+
31
+ &--disabled {
32
+ input {
33
+ color: var(--farm-gray-base);
34
+ }
35
+ .farm-icon {
36
+ color: var(--farm-gray-lighten);
37
+ cursor: default;
38
+ }
27
39
  }
28
40
 
29
41
  .farm-caption {
@@ -52,6 +52,7 @@ export const Disabled = () => ({
52
52
  },
53
53
  template: `<div style="width: 480px">
54
54
  <farm-textfield-v2 v-model="v" disabled />
55
+ <farm-textfield-v2 v-model="v" disabled icon="book" />
55
56
  </div>`,
56
57
  });
57
58
 
@@ -7,6 +7,7 @@
7
7
  'farm-textfield--touched': isTouched,
8
8
  'farm-textfield--blured': isBlured,
9
9
  'farm-textfield--error': hasError,
10
+ 'farm-textfield--disabled': disabled,
10
11
  }"
11
12
  >
12
13
  <div class="farm-textfield--input">
@@ -20,9 +21,10 @@
20
21
  <input
21
22
  v-bind="$attrs"
22
23
  v-model="innerValue"
23
- v-mask="mask"
24
+ v-mask="mask"
24
25
  :disabled="disabled"
25
26
  :readonly="readonly"
27
+ @click="$emit('click')"
26
28
  @keyup="onKeyUp"
27
29
  @blur="onBlur"
28
30
  />
@@ -34,7 +36,6 @@
34
36
  <farm-icon color="gray" size="20px">{{ icon }}</farm-icon>
35
37
  </button>
36
38
  </div>
37
-
38
39
  <farm-caption v-if="showErrorText" color="error" variation="regular">
39
40
  {{ errorBucket[0] }}
40
41
  </farm-caption>
@@ -156,12 +157,14 @@ export default Vue.extend({
156
157
 
157
158
  let validate = validateFormMethodBuilder(errorBucket, valid, fieldValidator);
158
159
 
159
- const onKeyUp = () => {
160
+ const onKeyUp = (event: Event) => {
160
161
  isTouched.value = true;
162
+ emit('keyup', event);
161
163
  };
162
164
 
163
- const onBlur = () => {
165
+ const onBlur = (event: Event) => {
164
166
  isBlured.value = true;
167
+ emit('blur', event);
165
168
  };
166
169
 
167
170
  const reset = () => {
@@ -7,7 +7,8 @@ export default {
7
7
  docs: {
8
8
  description: {
9
9
  component: `BodyText<br />
10
- selector: <em>farm-bodytext</em>
10
+ selector: <em>farm-bodytext</em><br />
11
+ <span style="color: var(--farm-primary-base);">ready for use</span>
11
12
  `,
12
13
  },
13
14
  },
@@ -37,7 +38,6 @@ export const Primary = () => ({
37
38
  });
38
39
 
39
40
  export const CustomTag = () => ({
40
- components: { 'farm-bodytext': BodyText },
41
41
  data() {
42
42
  return {
43
43
  tags: ['p', 'span', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'legend', 'label', 'li'],
@@ -7,7 +7,8 @@ export default {
7
7
  docs: {
8
8
  description: {
9
9
  component: `Caption<br />
10
- selector: <em>farm-caption</em>
10
+ selector: <em>farm-caption</em><br />
11
+ <span style="color: var(--farm-primary-base);">ready for use</span>
11
12
  `,
12
13
  },
13
14
  },
@@ -7,7 +7,8 @@ export default {
7
7
  docs: {
8
8
  description: {
9
9
  component: `Heading<br />
10
- selector: <em>farm-heading</em>
10
+ selector: <em>farm-heading</em><br />
11
+ <span style="color: var(--farm-primary-base);">ready for use</span>
11
12
  `,
12
13
  },
13
14
  },
@@ -7,7 +7,8 @@ export default {
7
7
  docs: {
8
8
  description: {
9
9
  component: `OverlayText<br />
10
- selector: <em>farm-overlaytext</em>
10
+ selector: <em>farm-overlaytext</em><br />
11
+ <span style="color: var(--farm-primary-base);">ready for use</span>
11
12
  `,
12
13
  },
13
14
  },
@@ -7,7 +7,8 @@ export default {
7
7
  docs: {
8
8
  description: {
9
9
  component: `Subtitle<br />
10
- selector: <em>farm-subtitle</em>
10
+ selector: <em>farm-subtitle</em><br />
11
+ <span style="color: var(--farm-primary-base);">ready for use</span>
11
12
  `,
12
13
  },
13
14
  },
@@ -16,7 +17,6 @@ export default {
16
17
  };
17
18
 
18
19
  export const Primary = () => ({
19
- components: { 'farm-subtitle': Subtitle },
20
20
  data() {
21
21
  return {
22
22
  types: [1, 2],
@@ -37,7 +37,6 @@ export const Primary = () => ({
37
37
  });
38
38
 
39
39
  export const CustomTag = () => ({
40
- components: { 'farm-subtitle': Subtitle },
41
40
  data() {
42
41
  return {
43
42
  tags: ['p', 'span', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'legend', 'label', 'li'],
@@ -73,3 +73,24 @@ export const Tertiary = () => ({
73
73
  </farm-container>
74
74
  `,
75
75
  });
76
+
77
+ export const WithTabs = () => ({
78
+ data() {
79
+ return {
80
+ steps: [
81
+ { label: 'Step 1', icon: '' },
82
+ { label: 'Step 2', icon: 'monitor' },
83
+ { label: 'Step 3', icon: 'book' },
84
+ { label: 'Step 4', icon: '' },
85
+ ],
86
+ currentStep: 3,
87
+ };
88
+ },
89
+ template: `
90
+ <farm-container>
91
+ <farm-row extra-decrease>
92
+ <farm-tabs :tabs="steps" :showCounter="false" class="mt-n6" />
93
+ </farm-row>
94
+ </farm-container>
95
+ `,
96
+ });
@@ -16,6 +16,7 @@
16
16
  margin: gutter('lg');
17
17
  padding: gutter('lg');
18
18
  box-shadow: 0px 3px 1px -2px rgb(0 0 0 / 20%), 0px 2px 2px 0px rgb(0 0 0 / 14%), 0px 1px 5px 0px rgb(0 0 0 / 12%) !important;
19
+ overflow: hidden;
19
20
 
20
21
  // deprecated
21
22
  .container-main__footer-buttons-right {
package/src/main.ts CHANGED
@@ -23,6 +23,7 @@ import CardContext from './components/CardContext';
23
23
  import DefaultButton from './components/Buttons/DefaultButton';
24
24
  import Collapsible from './components/Collapsible';
25
25
  import IdCaption from './components/IdCaption';
26
+ import ResourceMetaInfo from './components/ResourceMetaInfo';
26
27
 
27
28
  export {
28
29
  DataTableEmptyWrapper,
@@ -47,6 +48,7 @@ export {
47
48
  CardContext,
48
49
  Collapsible,
49
50
  IdCaption,
51
+ ResourceMetaInfo,
50
52
  };
51
53
 
52
54
  export * from './components/AlertBox';
@@ -94,4 +96,3 @@ export * from './components/layout/Container';
94
96
  export * from './components/layout/ContainerFooter';
95
97
  export * from './components/layout/Row';
96
98
  export * from './components/layout/Line';
97
-