@farm-investimentos/front-mfe-components 12.1.3 → 12.2.0

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 (31) hide show
  1. package/dist/front-mfe-components.common.js +583 -5427
  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 +583 -5427
  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/Chip/Chip.stories.js +6 -0
  10. package/src/components/Chip/Chip.vue +1 -1
  11. package/src/components/DialogHeader/DialogHeader.scss +3 -0
  12. package/src/components/DialogHeader/DialogHeader.stories.js +6 -0
  13. package/src/components/IdCaption/IdCaption.scss +15 -9
  14. package/src/components/IdCaption/IdCaption.stories.js +15 -10
  15. package/src/components/IdCaption/IdCaption.vue +16 -16
  16. package/src/components/ModalPromptUser/ModalPromptUser.stories.js +21 -0
  17. package/src/components/ModalPromptUser/ModalPromptUser.vue +1 -0
  18. package/src/components/SelectModalOptions/SelectModalOptions.scss +5 -0
  19. package/src/components/SelectModalOptions/SelectModalOptions.vue +81 -99
  20. package/src/components/SelectModalOptions/__tests__/SelectModalOptions.spec.js +1 -0
  21. package/src/components/TextArea/TextArea.scss +62 -0
  22. package/src/components/TextArea/TextArea.stories.js +136 -0
  23. package/src/components/TextArea/TextArea.vue +179 -0
  24. package/src/components/TextArea/__tests__/TextArea.spec.js +48 -0
  25. package/src/components/TextArea/index.ts +4 -0
  26. package/src/components/TextFieldV2/TextFieldV2.stories.js +0 -24
  27. package/src/components/Typography/Typography.scss +2 -5
  28. package/src/configurations/_mixins.scss +7 -0
  29. package/src/main.ts +1 -0
  30. package/src/examples/inputs/Password.stories.js +0 -42
  31. 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.3",
3
+ "version": "12.2.0",
4
4
  "author": "farm investimentos",
5
5
  "private": false,
6
6
  "main": "./dist/front-mfe-components.common.js",
@@ -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,5 +28,6 @@ header {
26
28
  align-items: center;
27
29
  width: 100%;
28
30
  margin-bottom: 0;
31
+ @include ellipsis;
29
32
  }
30
33
  }
@@ -61,3 +61,9 @@ export const TemplateSlot = () => ({
61
61
  </farm-dialog-header>
62
62
  </div>`,
63
63
  });
64
+
65
+ export const VeryLongTitle = () => ({
66
+ template: `<div style="max-width: 480px; position: relative;">
67
+ <farm-dialog-header title="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec tincidunt leo nec orci hendrerit, in sagittis magna tincidunt." />
68
+ </div>`,
69
+ });
@@ -1,16 +1,25 @@
1
+ @import '../../configurations/mixins';
2
+
1
3
  .idcaption {
2
4
  display: flex;
3
5
  min-height: 48px;
6
+ max-width: 100%;
7
+
4
8
  .farm-icon-box {
5
9
  margin-right: 8px;
6
10
  }
7
11
 
12
+ &.farm-idcaption--noicon .idcaption__body {
13
+ max-width: 100%;
14
+ }
15
+
8
16
  &__body {
9
17
 
10
18
  display: flex;
11
19
  flex-direction: column;
12
20
  justify-content: space-between;
13
21
  align-content: flex-start;
22
+ max-width: calc(100% - 48px);
14
23
 
15
24
  &--single {
16
25
  justify-content: center;
@@ -21,22 +30,19 @@
21
30
  margin-bottom: 0;
22
31
  display: flex;
23
32
  flex: none;
33
+ position: relative;
34
+ align-items: center;
35
+ height: 18px;
24
36
 
25
37
  >span {
26
- position: relative;
38
+ max-width: 100%;
39
+ @include ellipsis;
27
40
  }
28
41
  }
29
42
 
30
- .farm-btn,
31
43
  .farm-tooltip {
32
- position: absolute;
33
- right: -30px;
34
- top: -8px;
44
+ padding-right: 1px;
35
45
  }
36
46
  }
37
47
 
38
- .farm-btn--clickable {
39
- position: absolute;
40
- top: -50%;
41
- }
42
48
  }
@@ -23,11 +23,17 @@ export default {
23
23
  };
24
24
 
25
25
  export const Primary = () => ({
26
+ methods: {
27
+ onLinkClick() {
28
+ alert('onLinkClick');
29
+ }
30
+ },
26
31
  template: `
27
32
  <farm-idcaption
28
33
  icon="account-box-outline"
29
34
  copyText="texto a copiar"
30
35
  :link="true"
36
+ @onLinkClick="onLinkClick"
31
37
  >
32
38
  <template v-slot:title>
33
39
  Upper Line Text
@@ -77,7 +83,6 @@ export const NoUpperText = () => ({
77
83
  <farm-idcaption
78
84
  icon="account-box-outline"
79
85
  copyText="texto a copiar"
80
- :link="true"
81
86
  >
82
87
  <template v-slot:subtitle>
83
88
  Lower:Line Text
@@ -90,7 +95,6 @@ export const NoBottomText = () => ({
90
95
  template: `
91
96
  <farm-idcaption
92
97
  icon="account-box-outline"
93
- copyText="texto a copiar"
94
98
  :link="true"
95
99
  >
96
100
  <template v-slot:title>
@@ -100,10 +104,11 @@ export const NoBottomText = () => ({
100
104
  `,
101
105
  });
102
106
 
103
- export const NoTextToClip = () => ({
107
+ export const NoTextToCopy = () => ({
104
108
  template: `
105
109
  <farm-idcaption
106
- icon="account-box-outline"
110
+ icon="account-box-outline"
111
+ copyText=""
107
112
  :link="true"
108
113
  >
109
114
  <template v-slot:title>
@@ -185,20 +190,20 @@ export const CustomTooltipColor = () => ({
185
190
  `,
186
191
  });
187
192
 
188
-
189
- export const Teste = () => ({
193
+ export const LongTitles = () => ({
190
194
  template: `
195
+ <farm-col sm="3">
191
196
  <farm-idcaption
192
197
  icon="account-box-outline"
193
- copy-text=""
198
+ copyText="texto a copiar"
194
199
  :link="true"
195
200
  >
196
201
  <template v-slot:title>
197
- Upper Line Text
202
+ Upper Line Text Upper Line Text
198
203
  </template>
199
204
  <template v-slot:subtitle>
200
- 0
205
+ Lower: Line Text Line Text Line Text Line
201
206
  </template>
202
207
  </farm-idcaption>
203
- `,
208
+ </farm-col>`,
204
209
  });
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div class="idcaption farm-idcaption">
2
+ <div :class="{ idcaption: true, 'farm-idcaption': true, 'farm-idcaption--noicon': !icon }">
3
3
  <farm-icon-box v-if="icon" :icon="icon" :color="iconBoxColor" size="md" />
4
4
  <div
5
5
  :class="{ idcaption__body: true, 'idcaption__body--single': !hasTitle || !hasSubtitle }"
@@ -7,28 +7,28 @@
7
7
  <farm-caption variation="medium" v-if="hasTitle">
8
8
  <span>
9
9
  <slot name="title"></slot>
10
- <farm-btn
11
- v-if="link"
12
- icon
13
- color="primary"
14
- class="farm-btn--clickable"
15
- @click="$emit('onLinkClick')"
16
- >
17
- <farm-icon size="xs">open-in-new</farm-icon>
18
- </farm-btn>
19
10
  </span>
11
+ <farm-btn
12
+ v-if="link"
13
+ icon
14
+ color="primary"
15
+ class="farm-btn--clickable"
16
+ @click="$emit('onLinkClick')"
17
+ >
18
+ <farm-icon size="xs">open-in-new</farm-icon>
19
+ </farm-btn>
20
20
  </farm-caption>
21
21
 
22
22
  <farm-caption variation="regular" color="gray" v-if="hasSubtitle">
23
23
  <span>
24
24
  <slot name="subtitle"></slot>
25
- <farm-copytoclipboard
26
- v-if="copyText"
27
- :toCopy="copyText"
28
- :successMessage="successMessage"
29
- :tooltipColor="tooltipColor"
30
- />
31
25
  </span>
26
+ <farm-copytoclipboard
27
+ v-if="copyText"
28
+ :toCopy="copyText"
29
+ :successMessage="successMessage"
30
+ :tooltipColor="tooltipColor"
31
+ />
32
32
  </farm-caption>
33
33
  </div>
34
34
  </div>
@@ -71,4 +71,25 @@ export const ButtonLabels = () => ({
71
71
  reabrir
72
72
  </farm-btn>
73
73
  </div>`,
74
+ });
75
+
76
+ export const Slot = () => ({
77
+ data() {
78
+ return {
79
+ showPrompt: false,
80
+ };
81
+ },
82
+ template: `<div>
83
+ <farm-prompt-user match="CONFIRMAR" title="Título" subtitle="" v-model="showPrompt">
84
+ <template v-slot:subtitle>
85
+ <farm-caption>Using caption and <farm-chip dense>chip</farm-chip></farm-caption>
86
+ <br />
87
+ Digite <strong>CONFIRMAR</strong> para habilitar
88
+ </template>
89
+ </farm-prompt-user>
90
+ click:
91
+ <farm-btn color="primary" @click="showPrompt = true;">
92
+ reabrir
93
+ </farm-btn>
94
+ </div>`,
74
95
  });
@@ -5,6 +5,7 @@
5
5
  </template>
6
6
  <template v-slot:content>
7
7
  <section class="modal-content">
8
+ <slot name="subtitle"></slot>
8
9
  <farm-promptusertoconfirm
9
10
  v-if="inputVal"
10
11
  v-model="canConfirm"
@@ -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,62 @@
1
+ .farm-textarea {
2
+ min-height: 64px;
3
+
4
+ &--textarea {
5
+ display: flex;
6
+ align-items: center;
7
+ gap: 8px;
8
+ border: 1px solid;
9
+ border-color: var(--farm-gray-lighten);
10
+ min-height: 36px;
11
+ border-radius: 5px;
12
+ padding: 8px 0 0 8px;
13
+ margin-bottom: 4px;
14
+ background-color: white;
15
+ width: 100%;
16
+
17
+
18
+ &>textarea {
19
+ flex: 1;
20
+ outline: none;
21
+ color: var(--farm-text-primary);
22
+ font-size: 12px;
23
+ font-weight: 400;
24
+ max-width: 100%;
25
+ max-height: 100%;
26
+ }
27
+ }
28
+
29
+ &--disabled {
30
+ textarea {
31
+ color: var(--farm-gray-base);
32
+ }
33
+ }
34
+
35
+ .farm-caption {
36
+ line-height: 12px;
37
+ }
38
+ }
39
+
40
+ .farm-textarea--touched.farm-textarea--validatable {
41
+ &.farm-textarea--error {
42
+ .farm-textarea {
43
+ &--textarea {
44
+ border-color: var(--farm-error-base);
45
+
46
+ &>textarea {
47
+ color: var(--farm-neutral-darken);
48
+ }
49
+ }
50
+ }
51
+ }
52
+ }
53
+
54
+ .farm-textarea--blured.farm-textarea--validatable:not(.farm-textarea--error) {
55
+ .farm-textarea--textarea {
56
+ border-color: var(--farm-primary-base);
57
+
58
+ &>textarea {
59
+ color: var(--farm-neutral-darken);
60
+ }
61
+ }
62
+ }