@farm-investimentos/front-mfe-components 12.1.4 → 12.2.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 (29) hide show
  1. package/dist/front-mfe-components.common.js +602 -5422
  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 +602 -5422
  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 +2 -2
  9. package/src/components/Chip/Chip.stories.js +6 -0
  10. package/src/components/Chip/Chip.vue +1 -1
  11. package/src/components/DialogHeader/DialogHeader.scss +3 -3
  12. package/src/components/IdCaption/IdCaption.scss +3 -3
  13. package/src/components/Select/Select.vue +8 -0
  14. package/src/components/SelectModalOptions/SelectModalOptions.scss +5 -0
  15. package/src/components/SelectModalOptions/SelectModalOptions.vue +81 -99
  16. package/src/components/SelectModalOptions/__tests__/SelectModalOptions.spec.js +1 -0
  17. package/src/components/TextArea/TextArea.scss +66 -0
  18. package/src/components/TextArea/TextArea.stories.js +136 -0
  19. package/src/components/TextArea/TextArea.vue +188 -0
  20. package/src/components/TextArea/__tests__/TextArea.spec.js +48 -0
  21. package/src/components/TextArea/index.ts +4 -0
  22. package/src/components/TextFieldV2/TextFieldV2.scss +4 -0
  23. package/src/components/TextFieldV2/TextFieldV2.stories.js +0 -24
  24. package/src/components/TextFieldV2/TextFieldV2.vue +21 -7
  25. package/src/components/Typography/Typography.scss +2 -5
  26. package/src/configurations/_mixins.scss +7 -0
  27. package/src/main.ts +1 -0
  28. package/src/examples/inputs/Password.stories.js +0 -42
  29. package/src/examples/inputs/Select.stories.js +0 -27
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farm-investimentos/front-mfe-components",
3
- "version": "12.1.4",
3
+ "version": "12.2.1",
4
4
  "author": "farm investimentos",
5
5
  "private": false,
6
6
  "main": "./dist/front-mfe-components.common.js",
@@ -10,7 +10,7 @@
10
10
  "serve": "vue-cli-service serve",
11
11
  "build": "npm run build:components",
12
12
  "build:components": "vue-cli-service build --target lib --name front-mfe-components src/main.ts",
13
- "lint": "vue-cli-service lint",
13
+ "lint": "vue-cli-service lint --fix",
14
14
  "storybook": "start-storybook -p 6006",
15
15
  "build-storybook": "build-storybook",
16
16
  "test:unit": "jest --updateSnapshot",
@@ -87,4 +87,10 @@ export const CustomTypography = () => ({
87
87
  <farm-bodytext :type="2">BodyText 2</farm-bodytext>
88
88
  </farm-chip>
89
89
  </div>`,
90
+ });
91
+
92
+ export const Ellipsis = () => ({
93
+ template: `<div style="width: 100px;">
94
+ <farm-chip color="primary">Very long text here</farm-chip>
95
+ </div>`,
90
96
  });
@@ -8,7 +8,7 @@
8
8
  'farm-chip--darken': variation === 'darken',
9
9
  }"
10
10
  >
11
- <farm-typography tag="span" size="sm" color="white"> <slot></slot> </farm-typography>
11
+ <farm-typography tag="span" size="sm" color="white" ellipsis> <slot></slot> </farm-typography>
12
12
  </span>
13
13
  </template>
14
14
  <script lang="ts">
@@ -1,3 +1,5 @@
1
+ @import '../../configurations/mixins';
2
+
1
3
  .farm-dialog-header__close {
2
4
  position: absolute;
3
5
  margin-top: 0;
@@ -26,8 +28,6 @@ header {
26
28
  align-items: center;
27
29
  width: 100%;
28
30
  margin-bottom: 0;
29
- white-space: nowrap;
30
- overflow: hidden;
31
- text-overflow: ellipsis;
31
+ @include ellipsis;
32
32
  }
33
33
  }
@@ -1,3 +1,5 @@
1
+ @import '../../configurations/mixins';
2
+
1
3
  .idcaption {
2
4
  display: flex;
3
5
  min-height: 48px;
@@ -34,9 +36,7 @@
34
36
 
35
37
  >span {
36
38
  max-width: 100%;
37
- white-space: nowrap;
38
- overflow: hidden;
39
- text-overflow: ellipsis;
39
+ @include ellipsis;
40
40
  }
41
41
  }
42
42
 
@@ -8,6 +8,7 @@
8
8
  'farm-textfield--blured': isBlured,
9
9
  'farm-textfield--error': hasError,
10
10
  'farm-textfield--disabled': disabled,
11
+ 'farm-textfield--hiddendetails': hideDetails,
11
12
  }"
12
13
  v-if="!readonly && !disabled"
13
14
  >
@@ -144,6 +145,13 @@ export default Vue.extend({
144
145
  type: Boolean,
145
146
  default: false,
146
147
  },
148
+ /**
149
+ * Hides hint and validation errors
150
+ */
151
+ hideDetails: {
152
+ type: Boolean,
153
+ default: false,
154
+ },
147
155
  },
148
156
  setup(props, { emit }) {
149
157
  const { rules, items, itemText, itemValue, disabled, multiple } = toRefs(props);
@@ -0,0 +1,5 @@
1
+ ::v-deep .farm-textfield--input {
2
+ input {
3
+ cursor: pointer !important;
4
+ }
5
+ }
@@ -1,104 +1,87 @@
1
1
  <template>
2
- <v-col cols="12" sm="12" :md="config.md ? config.md : 2" class="v-col-fieldset-default">
3
- <div class="v-text-field">
4
- <label :for="inputId">
5
- {{ label }}
6
- <span class="required" v-if="config.required">*</span>
7
- </label>
8
- <v-text-field
9
- append-icon="mdi-magnify "
10
- color="secondary"
11
- outlined
12
- v-on:keyup="clearTextField"
13
- dense
14
- readonly
15
- :id="inputId"
16
- :value="selectedValueText"
17
- @click="openModal"
18
- />
19
- </div>
20
- <v-dialog content-class="modal-default modal-default-small" v-model="showModal">
21
- <DialogHeader class="dialog-header" :title="modalTitle" @onClose="closeModal" />
2
+ <farm-col cols="12" :md="config.md ? config.md : 2">
3
+ <farm-label :for="inputId" :required="config.required">
4
+ {{ label }}
5
+ </farm-label>
6
+ <farm-textfield-v2
7
+ ref="searchTextField"
8
+ icon="magnify"
9
+ readonly
10
+ :id="inputId"
11
+ :value="selectedValueText"
12
+ @click="openModal"
13
+ @keyup="clearTextField"
14
+ />
22
15
 
23
- <v-main class="mt-9">
24
- <Loader class="text-center mb-2" v-if="isLoading" />
25
- <fieldset class="fieldset-default mx-4 mb-3" v-if="!isLoading">
26
- <label for="searchInput"> {{ label }} </label>
27
- <v-text-field
28
- color="secondary"
29
- id="searchInput"
30
- outlined
31
- dense
32
- hide-details
33
- :placeholder="placeholder"
34
- v-model="searchValue"
35
- />
36
- </fieldset>
16
+ <farm-modal v-model="showModal" size="sm" :offsetTop="48" :offsetBottom="68">
17
+ <template v-slot:header>
18
+ <farm-dialog-header :title="modalTitle" @onClose="closeModal" />
19
+ </template>
20
+ <template v-slot:content>
21
+ <div class="mx-n4">
22
+ <farm-box class="mt-3">
23
+ <farm-loader class="text-center mb-2" v-if="isLoading" />
24
+ <fieldset class="fieldset-default mx-4 mb-3" v-if="!isLoading">
25
+ <farm-label for="searchInput"> {{ label }} </farm-label>
26
+ <farm-textfield-v2
27
+ id="searchInput"
28
+ v-model="searchValue"
29
+ :placeholder="placeholder"
30
+ />
31
+ </fieldset>
37
32
 
38
- <v-data-table
39
- v-if="!isLoading"
40
- id="inputModalOptionsTable"
41
- class="v-data-table__clickable v-data-table__select-modal"
42
- hide-default-footer
43
- hide-default-header
44
- :items="items"
45
- :headers="headers"
46
- :options.sync="pagination"
47
- :search="searchValue"
48
- :custom-filter="customFilter"
49
- @click:row="handleClick"
50
- @pagination="handlePagination"
51
- >
52
- <template slot="no-data">
53
- <DataTableEmptyWrapper />
54
- </template>
55
- <template slot="no-results">
56
- <DataTableEmptyWrapper />
57
- </template>
58
- <template v-slot:[`item.label`]="{ item }">
59
- <td :title="getItemLabel(item)" aria-role="button">
60
- {{ getItemLabel(item) }}
61
- </td>
62
- </template>
33
+ <v-data-table
34
+ v-if="!isLoading"
35
+ id="inputModalOptionsTable"
36
+ class="v-data-table__clickable v-data-table__select-modal"
37
+ hide-default-footer
38
+ hide-default-header
39
+ :items="items"
40
+ :headers="headers"
41
+ :options.sync="pagination"
42
+ :search="searchValue"
43
+ :custom-filter="customFilter"
44
+ @click:row="handleClick"
45
+ @pagination="handlePagination"
46
+ >
47
+ <template slot="no-data">
48
+ <farm-emptywrapper />
49
+ </template>
50
+ <template slot="no-results">
51
+ <farm-emptywrapper />
52
+ </template>
53
+ <template v-slot:[`item.label`]="{ item }">
54
+ <td :title="getItemLabel(item)" aria-role="button">
55
+ {{ getItemLabel(item) }}
56
+ </td>
57
+ </template>
63
58
 
64
- <template v-slot:footer>
65
- <DataTablePaginator
66
- class="my-6"
67
- hidePerPageOptions
68
- :initialLimitPerPage="pagination.itemsPerPage"
69
- :page="pagination.page"
70
- :totalPages="pagination.pages"
71
- @onChangePage="onChangePage"
72
- />
73
- </template>
74
- </v-data-table>
75
- </v-main>
76
- <DialogFooter :hasConfirm="false" @onClose="closeModal" />
77
- </v-dialog>
78
- </v-col>
59
+ <template v-slot:footer>
60
+ <farm-datatable-paginator
61
+ class="my-6"
62
+ hidePerPageOptions
63
+ :initialLimitPerPage="pagination.itemsPerPage"
64
+ :page="pagination.page"
65
+ :totalPages="pagination.pages"
66
+ @onChangePage="onChangePage"
67
+ />
68
+ </template>
69
+ </v-data-table>
70
+ </farm-box>
71
+ </div>
72
+ </template>
73
+
74
+ <template v-slot:footer>
75
+ <farm-dialog-footer :hasConfirm="false" @onClose="closeModal" />
76
+ </template>
77
+ </farm-modal>
78
+ </farm-col>
79
79
  </template>
80
- <script>
80
+ <script lang="ts">
81
81
  import Vue from 'vue';
82
- import VTextField from 'vuetify/lib/components/VTextField';
83
- import { VCol } from 'vuetify/lib/components/VGrid';
84
- import { VMain } from 'vuetify/lib/components/VMain';
85
- import { VDataTable } from 'vuetify/lib/components/VDataTable/';
86
- import { VDialog } from 'vuetify/lib/components/VDialog/';
87
- import { DialogHeader, DialogFooter, DataTableEmptyWrapper, DataTablePaginator } from '../../main';
88
82
 
89
83
  export default Vue.extend({
90
84
  name: 'farm-select-modal-options',
91
- components: {
92
- VTextField,
93
- VCol,
94
- VMain,
95
- VDataTable,
96
- VDialog,
97
- DialogHeader,
98
- DialogFooter,
99
- DataTableEmptyWrapper,
100
- DataTablePaginator,
101
- },
102
85
  props: {
103
86
  /**
104
87
  * Input Label
@@ -248,8 +231,12 @@ export default Vue.extend({
248
231
  this.showModal = true;
249
232
  },
250
233
  closeModal() {
234
+ this.focusOnInput();
251
235
  this.showModal = false;
252
236
  },
237
+ focusOnInput() {
238
+ this.$refs.searchTextField.$el.firstChild.firstElementChild.focus();
239
+ },
253
240
  onChangePage(newPage) {
254
241
  this.pagination.page = newPage;
255
242
  },
@@ -263,6 +250,7 @@ export default Vue.extend({
263
250
  this.inputVal = item[this.selectIdentifier];
264
251
  this.showModal = false;
265
252
  this.selectedItem = item;
253
+ this.focusOnInput();
266
254
  },
267
255
  customFilter(_, search, item) {
268
256
  const label = this.getItemLabel(item);
@@ -277,11 +265,5 @@ export default Vue.extend({
277
265
  });
278
266
  </script>
279
267
  <style lang="scss" scoped>
280
- .v-text-field::v-deep {
281
- margin-top: 0;
282
- padding-top: 0;
283
- input {
284
- cursor: pointer;
285
- }
286
- }
268
+ @import 'SelectModalOptions.scss';
287
269
  </style>
@@ -19,6 +19,7 @@ describe('SelectModalOptions component', () => {
19
19
  },
20
20
  });
21
21
  component = wrapper.vm;
22
+ jest.spyOn(component, 'focusOnInput').mockImplementationOnce(() => {});
22
23
  });
23
24
 
24
25
  test('SelectModalOptions created', () => {
@@ -0,0 +1,66 @@
1
+ .farm-textarea {
2
+ min-height: 64px;
3
+
4
+ &--hiddendetails {
5
+ height: 40px;
6
+ }
7
+
8
+ &--textarea {
9
+ display: flex;
10
+ align-items: center;
11
+ gap: 8px;
12
+ border: 1px solid;
13
+ border-color: var(--farm-gray-lighten);
14
+ min-height: 36px;
15
+ border-radius: 5px;
16
+ padding: 8px 0 0 8px;
17
+ margin-bottom: 4px;
18
+ background-color: white;
19
+ width: 100%;
20
+
21
+
22
+ &>textarea {
23
+ flex: 1;
24
+ outline: none;
25
+ color: var(--farm-text-primary);
26
+ font-size: 12px;
27
+ font-weight: 400;
28
+ max-width: 100%;
29
+ max-height: 100%;
30
+ }
31
+ }
32
+
33
+ &--disabled {
34
+ textarea {
35
+ color: var(--farm-gray-base);
36
+ }
37
+ }
38
+
39
+ .farm-caption {
40
+ line-height: 12px;
41
+ }
42
+ }
43
+
44
+ .farm-textarea--touched.farm-textarea--validatable {
45
+ &.farm-textarea--error {
46
+ .farm-textarea {
47
+ &--textarea {
48
+ border-color: var(--farm-error-base);
49
+
50
+ &>textarea {
51
+ color: var(--farm-neutral-darken);
52
+ }
53
+ }
54
+ }
55
+ }
56
+ }
57
+
58
+ .farm-textarea--blured.farm-textarea--validatable:not(.farm-textarea--error) {
59
+ .farm-textarea--textarea {
60
+ border-color: var(--farm-primary-base);
61
+
62
+ &>textarea {
63
+ color: var(--farm-neutral-darken);
64
+ }
65
+ }
66
+ }
@@ -0,0 +1,136 @@
1
+ import { withDesign } from 'storybook-addon-designs';
2
+ import TextArea from './TextArea.vue';
3
+
4
+ export default {
5
+ title: 'Form/TextArea',
6
+ component: TextArea,
7
+ decorators: [withDesign],
8
+ parameters: {
9
+ docs: {
10
+ description: {
11
+ component: `Text Area<br />
12
+ selector: <em>farm-textarea</em><br />
13
+ <span style="color: var(--farm-primary-base);">ready for use</span>
14
+ `,
15
+ },
16
+ },
17
+ design: {
18
+ type: 'figma',
19
+ url: 'https://www.figma.com/file/jnZXo2e0nRJ3fVXl4Et8t4/%E2%9C%8D-Design-System-%7C-BACKUP-(10%2F10%2F2022)?node-id=2491%3A4487',
20
+ },
21
+ viewMode: 'docs',
22
+ },
23
+ };
24
+
25
+ export const Primary = () => ({
26
+ data() {
27
+ return {
28
+ v: 'input text',
29
+ };
30
+ },
31
+ template: `<div style="width: 480px;">
32
+ <farm-textarea v-model="v" />
33
+ v-model: {{ v }}
34
+ </div>`,
35
+ });
36
+
37
+ export const Rows = () => ({
38
+ data() {
39
+ return {
40
+ v: 'input text',
41
+ };
42
+ },
43
+ template: `<div style="width: 480px;">
44
+ <farm-textarea v-model="v" rows="10" />
45
+ <farm-textarea v-model="v" rows="3" />
46
+ </div>`,
47
+ });
48
+
49
+ export const Disabled = () => ({
50
+ data() {
51
+ return {
52
+ v: 'input text',
53
+ };
54
+ },
55
+ template: `<div style="width: 480px">
56
+ <farm-textarea v-model="v" disabled />
57
+ </div>`,
58
+ });
59
+
60
+ export const Readonly = () => ({
61
+ data() {
62
+ return {
63
+ v: 'input text',
64
+ };
65
+ },
66
+ template: `<div style="width: 480px">
67
+ <farm-textarea v-model="v" readonly />
68
+ </div>`,
69
+ });
70
+
71
+ export const Validate = () => ({
72
+ data() {
73
+ return {
74
+ v1: 'input 1',
75
+ v2: '',
76
+ v4: '',
77
+ rules: {
78
+ required: value => !!value || 'Required field',
79
+ email: v =>
80
+ !v ||
81
+ /^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/.test(v) ||
82
+ 'Must be an e-mail',
83
+ },
84
+ };
85
+ },
86
+ template: `<div style="width: 480px">
87
+ <farm-label required>Required field</farm-label>
88
+ <farm-textarea v-model="v1" :rules="[rules.required]" />
89
+
90
+ <farm-label>E-mail</farm-label>
91
+ <farm-textarea v-model="v2" :rules="[rules.email]" />
92
+
93
+ <farm-label required>Required field with hint</farm-label>
94
+ <farm-textarea v-model="v4" :rules="[rules.required]" hint="hint text" />
95
+
96
+ </div>`,
97
+ });
98
+
99
+ export const HintText = () => ({
100
+ data() {
101
+ return {
102
+ v: 'input text',
103
+ };
104
+ },
105
+ template: `<div style="width: 480px; display: flex;">
106
+ <farm-textarea v-model="v" hint="Hint text" />
107
+ </div>`,
108
+ });
109
+
110
+ export const Reset = () => ({
111
+ data() {
112
+ return {
113
+ v: 'input text',
114
+ rules: {
115
+ required: value => !!value || 'Required field',
116
+ },
117
+ };
118
+ },
119
+ methods: {
120
+ reset() {
121
+ this.$refs.input.reset();
122
+ this.$refs.inputValidatable.reset();
123
+ },
124
+ },
125
+ template: `<div style="width: 480px">
126
+
127
+ <farm-label>Not Required</farm-label>
128
+ <farm-textarea v-model="v" ref="input" />
129
+
130
+ <farm-label required>Required</farm-label>
131
+ <farm-textarea v-model="v" ref="inputValidatable" :rules="[rules.required]" />
132
+
133
+ <farm-btn @click="reset">reset</farm-btn>
134
+
135
+ </div>`,
136
+ });