@farm-investimentos/front-mfe-components 9.4.0 → 10.0.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 (54) hide show
  1. package/dist/front-mfe-components.common.js +3787 -3383
  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 +3787 -3383
  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/Card/Card.vue +1 -1
  10. package/src/components/Card/CardContent/CardContent.vue +1 -1
  11. package/src/components/Checkbox/Checkbox.vue +6 -1
  12. package/src/components/Chip/Chip.stories.js +11 -0
  13. package/src/components/CopyToClipboard/__tests__/CopyToClipboard.spec.js +5 -1
  14. package/src/components/DatePicker/DatePicker.vue +0 -2
  15. package/src/components/Form/Form.stories.js +29 -4
  16. package/src/components/Icon/Icon.stories.js +3 -1
  17. package/src/components/List/List.scss +0 -0
  18. package/src/components/List/List.stories.js +29 -0
  19. package/src/components/List/List.vue +17 -0
  20. package/src/components/List/__tests__/List.spec.js +20 -0
  21. package/src/components/List/index.ts +4 -0
  22. package/src/components/ListItem/ListItem.scss +37 -0
  23. package/src/components/ListItem/ListItem.stories.js +70 -0
  24. package/src/components/ListItem/ListItem.vue +82 -0
  25. package/src/components/ListItem/__tests__/ListItem.spec.js +20 -0
  26. package/src/components/ListItem/index.ts +4 -0
  27. package/src/components/Logger/Logger.vue +5 -7
  28. package/src/components/Modal/Modal.scss +1 -0
  29. package/src/components/Modal/Modal.stories.js +2 -2
  30. package/src/components/ModalPromptUser/ModalPromptUser.scss +3 -0
  31. package/src/components/ModalPromptUser/ModalPromptUser.stories.js +7 -6
  32. package/src/components/ModalPromptUser/ModalPromptUser.vue +18 -17
  33. package/src/components/PromptUserToConfirm/PromptUserToConfirm.vue +2 -2
  34. package/src/components/RadioGroup/RadioGroup.scss +46 -20
  35. package/src/components/RadioGroup/RadioGroup.stories.js +69 -8
  36. package/src/components/RadioGroup/RadioGroup.vue +68 -46
  37. package/src/components/TableContextMenu/TableContextMenu.scss +5 -2
  38. package/src/components/TableContextMenu/TableContextMenu.stories.js +21 -4
  39. package/src/components/TableContextMenu/TableContextMenu.vue +6 -7
  40. package/src/components/TextField/__tests__/{Label.spec.js → TextField.spec.js} +0 -0
  41. package/src/components/layout/Col/Col.scss +5 -0
  42. package/src/components/layout/Col/Col.stories.js +42 -0
  43. package/src/components/layout/Col/Col.vue +62 -0
  44. package/src/components/layout/Col/__tests__/Col.spec.js +22 -0
  45. package/src/components/layout/Col/index.ts +4 -0
  46. package/src/components/layout/Container/Container.scss +7 -3
  47. package/src/components/layout/Container/Container.stories.js +2 -1
  48. package/src/components/layout/ContainerFooter/ContainerFooter.scss +6 -3
  49. package/src/components/layout/Row/Row.scss +25 -1
  50. package/src/components/layout/Row/Row.stories.js +48 -3
  51. package/src/components/layout/Row/Row.vue +24 -1
  52. package/src/configurations/_variables.scss +2 -2
  53. package/src/examples/Container/Basic.stories.js +20 -4
  54. package/src/main.ts +4 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farm-investimentos/front-mfe-components",
3
- "version": "9.4.0",
3
+ "version": "10.0.0",
4
4
  "author": "farm investimentos",
5
5
  "private": false,
6
6
  "main": "./dist/front-mfe-components.common.js",
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <component class="farm-card" v-bind:is="tag">
2
+ <component class="farm-card" :is="tag">
3
3
  <slot></slot>
4
4
  </component>
5
5
  </template>
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <component v-bind:is="tag" class="farm-card__content" :gutter="gutter">
2
+ <component :is="tag" class="farm-card__content" :gutter="gutter">
3
3
  <slot></slot>
4
4
  </component>
5
5
  </template>
@@ -18,7 +18,7 @@
18
18
  </div>
19
19
  </template>
20
20
  <script lang="ts">
21
- import Vue, { onBeforeMount, PropType, ref, toRefs, watch } from 'vue';
21
+ import Vue, { computed, onBeforeMount, PropType, ref, toRefs, watch } from 'vue';
22
22
  import validateFormStateBuilder from '../../composition/validateFormStateBuilder';
23
23
  import validateFormFieldBuilder from '../../composition/validateFormFieldBuilder';
24
24
  import validateFormMethodBuilder from '../../composition/validateFormMethodBuilder';
@@ -74,6 +74,10 @@ export default Vue.extend({
74
74
  validate(innerValue.value);
75
75
  };
76
76
 
77
+ const hasError = computed(() => {
78
+ return errorBucket.value.length > 0;
79
+ });
80
+
77
81
  watch(
78
82
  () => props.value,
79
83
  () => {
@@ -113,6 +117,7 @@ export default Vue.extend({
113
117
  errorBucket,
114
118
  valid,
115
119
  validatable,
120
+ hasError,
116
121
  toggleValue,
117
122
  reset,
118
123
  validate,
@@ -8,6 +8,17 @@ const variations = ['', 'darken', 'lighten'];
8
8
  export default {
9
9
  title: 'Display/Chips',
10
10
  component: Chip,
11
+ parameters: {
12
+ docs: {
13
+ description: {
14
+ component: `Chip<br />
15
+ selector: <em>farm-chip</em><br />
16
+ <span style="color: green;">ready for use</span>
17
+ `,
18
+ },
19
+ },
20
+ viewMode: 'docs',
21
+ },
11
22
  };
12
23
 
13
24
  export const Primary = () => ({
@@ -5,7 +5,11 @@ describe('CopyToClipboard component', () => {
5
5
  let wrapper;
6
6
 
7
7
  beforeEach(() => {
8
- wrapper = shallowMount(CopyToClipboard);
8
+ wrapper = shallowMount(CopyToClipboard, {
9
+ propsData: {
10
+ toCopy: 'test',
11
+ },
12
+ });
9
13
  });
10
14
 
11
15
  test('Created hook', () => {
@@ -136,8 +136,6 @@ export default Vue.extend({
136
136
  timeZone: 'America/Sao_Paulo',
137
137
  });
138
138
 
139
- console.log(this.getUniversalDate(locatedSelectedDate), this.getUniversalDate(locatedMinDate));
140
-
141
139
  return this.min && this.getUniversalDate(locatedSelectedDate) < this.getUniversalDate(locatedMinDate)
142
140
  ? 'A data está fora do período permitido'
143
141
  : true;
@@ -44,10 +44,10 @@ export const Primary = () => ({
44
44
  },
45
45
  template: `
46
46
  <farm-form v-model="validForm" :style="[styles.vForm]" ref="form">
47
-
48
- <farm-label :required="true">Documento</farm-label>
49
- <farm-textfield v-model="form.document" :rules="[rules.required]" />
50
-
47
+ <div>
48
+ <farm-label :required="true">Documento</farm-label>
49
+ <farm-textfield v-model="form.document" :rules="[rules.required]" />
50
+ </div>
51
51
  <farm-label :required="true">Nome</farm-label>
52
52
  <farm-textfield v-model="form.name" :rules="[rules.required]" />
53
53
 
@@ -144,3 +144,28 @@ export const InitInvalid = () => ({
144
144
  </farm-form>
145
145
  `,
146
146
  });
147
+
148
+ export const RadioGroupReset = () => ({
149
+ data() {
150
+ return {
151
+ checkedValue: 1,
152
+ buttons: [
153
+ { label: 'Button 1', id: 1 },
154
+ { label: 'Button 2', id: 2 },
155
+ { label: 'Button 3', id: 3 },
156
+ ],
157
+ validForm: false,
158
+ styles,
159
+ };
160
+ },
161
+ template: `
162
+ <farm-form v-model="validForm" :style="[styles.vForm]" ref="form">
163
+ <farm-radio-group v-model="checkedValue" column :buttons="buttons" />
164
+
165
+ <div class="footer" :style="[styles.footer]">
166
+ <farm-btn color="secondary" outlined @click="$refs.form.reset()" class="mr-3">Reset</farm-btn>
167
+ <farm-btn color="secondary" :disabled="!validForm">Salvar</farm-btn>
168
+ </div>
169
+ </farm-form>
170
+ `,
171
+ });
@@ -12,7 +12,9 @@ export default {
12
12
  viewMode: 'docs',
13
13
  docs: {
14
14
  description: {
15
- component: `Icon`,
15
+ component: `Icon<br />
16
+ selector: <em>farm-icon<em><br />
17
+ <span style="color: green;">ready for use</span>`,
16
18
  },
17
19
  },
18
20
  },
File without changes
@@ -0,0 +1,29 @@
1
+ import { withDesign } from 'storybook-addon-designs';
2
+ import List from './List.vue';
3
+
4
+ export default {
5
+ title: 'Display/List/List',
6
+ component: List,
7
+ decorators: [withDesign],
8
+ parameters: {
9
+ viewMode: 'docs',
10
+
11
+ docs: {
12
+ description: {
13
+ component: `List<br />
14
+ selector: <em>farm-list</em>`,
15
+ },
16
+ },
17
+ },
18
+ };
19
+
20
+ export const Primary = () => ({
21
+ template: `<farm-list>
22
+ <farm-listitem clickable hoverColor="primary">primary</farm-listitem>
23
+ <farm-listitem clickable hoverColor="extra-1" hoverColorVariation="lighten">extra 1 lighten</farm-listitem>
24
+ <farm-listitem clickable hoverColor="error" hoverColorVariation="lighten">
25
+ <farm-icon size="sm" color="error">trash-can</farm-icon>
26
+ <farm-typography color="error" tag="span">Error</farm-typography>
27
+ </farm-listitem>
28
+ </farm-list>`,
29
+ });
@@ -0,0 +1,17 @@
1
+ <template>
2
+ <ul>
3
+ <slot></slot>
4
+ </ul>
5
+ </template>
6
+ <script lang="ts">
7
+ import Vue from 'vue';
8
+
9
+ export default Vue.extend({
10
+ name: 'farm-list',
11
+ props: {},
12
+ setup() {},
13
+ });
14
+ </script>
15
+ <style lang="scss" scoped>
16
+ @import './List';
17
+ </style>
@@ -0,0 +1,20 @@
1
+ import { shallowMount } from '@vue/test-utils';
2
+ import List from '../List';
3
+
4
+ describe('List component', () => {
5
+ let wrapper;
6
+
7
+ beforeEach(() => {
8
+ wrapper = shallowMount(List);
9
+ });
10
+
11
+ test('Created hook', () => {
12
+ expect(wrapper).toBeDefined();
13
+ });
14
+
15
+ describe('mount component', () => {
16
+ it('renders correctly', () => {
17
+ expect(wrapper.element).toMatchSnapshot();
18
+ });
19
+ });
20
+ });
@@ -0,0 +1,4 @@
1
+ import List from './List.vue';
2
+
3
+ export { List };
4
+ export default List;
@@ -0,0 +1,37 @@
1
+ @import '../../configurations/theme-colors';
2
+
3
+ .farm-listitem {
4
+ list-style-type: none;
5
+ transition: background-color 300ms linear;
6
+ padding: 8px;
7
+ height: 36px;
8
+ display: flex;
9
+ align-items: center;
10
+
11
+ &--clickable {
12
+ cursor: pointer;
13
+ }
14
+
15
+ >a {
16
+ text-decoration: none;
17
+ }
18
+
19
+ &:hover {
20
+
21
+ @each $color in $theme-colors-list {
22
+
23
+ &#{'.farm-listitem--' + $color + '-base'} {
24
+ background-color: themeColor($color);
25
+ }
26
+
27
+ &#{'.farm-listitem--' + $color + '-lighten'} {
28
+ background-color: themeColor($color, 'lighten');
29
+ }
30
+
31
+ &#{'.farm-listitem--' + $color + '-darken'} {
32
+ background-color: themeColor($color, 'darken');
33
+ }
34
+ }
35
+ }
36
+
37
+ }
@@ -0,0 +1,70 @@
1
+ import { withDesign } from 'storybook-addon-designs';
2
+ import ListItem from './ListItem.vue';
3
+
4
+ import baseThemeColors from '../../configurations/_theme-colors-base.scss';
5
+
6
+ const colors = Object.keys(baseThemeColors);
7
+ const variations = ['base', 'darken', 'lighten'];
8
+
9
+ export default {
10
+ title: 'Display/List/ListItem',
11
+ component: ListItem,
12
+ decorators: [withDesign],
13
+ parameters: {
14
+ viewMode: 'docs',
15
+
16
+ docs: {
17
+ description: {
18
+ component: `ListItem<br />
19
+ selector: <em>farm-listitem</em>`,
20
+ },
21
+ },
22
+ },
23
+ };
24
+
25
+ export const Primary = () => ({
26
+ template: '<farm-listitem>aaa</farm-listitem>',
27
+ });
28
+
29
+ export const HoverColors = () => ({
30
+ data() {
31
+ return {
32
+ colors,
33
+ variations,
34
+ };
35
+ },
36
+ template: `<div style="display: flex; flex-direction: row; flex-wrap: wrap;">
37
+ <div class="chips-container" v-for="color in colors" :key="color" style="width: 33.3%; margin-bottom: 32px;">
38
+ <h4>{{ color }}</h4>
39
+ <farm-listitem
40
+ v-for="variation in variations"
41
+ :key="color + '_' + variation"
42
+ :hoverColor="color"
43
+ :hoverColorVariation="variation"
44
+ >
45
+ {{ color }} {{ variation }}
46
+ </farm-listitem>
47
+ </div>
48
+ </div>`,
49
+ });
50
+
51
+ export const ClickableCursor = () => ({
52
+ template: '<farm-listitem clickable>Clickable cursor</farm-listitem>',
53
+ });
54
+
55
+ export const ClickListener = () => ({
56
+ methods: {
57
+ onClick() {
58
+ alert('Clicked')
59
+ }
60
+ },
61
+ template:
62
+ `<farm-listitem
63
+ clickable
64
+ hoverColor="error"
65
+ hoverColorVariation="lighten"
66
+ @click="onClick"
67
+ >
68
+ try me
69
+ </farm-listitem>`,
70
+ });
@@ -0,0 +1,82 @@
1
+ <template>
2
+ <li
3
+ @click="onClick"
4
+ :class="{
5
+ 'farm-listitem': true,
6
+ [cssColorWithVariation]: cssColorWithVariation,
7
+ 'farm-listitem--clickable': clickable || to,
8
+ }"
9
+ >
10
+ <router-link :to="to" v-if="to">
11
+ <slot></slot>
12
+ </router-link>
13
+ <template v-else>
14
+ <slot></slot>
15
+ </template>
16
+ </li>
17
+ </template>
18
+ <script lang="ts">
19
+ import Vue, { computed, PropType, toRefs } from 'vue';
20
+
21
+ export default Vue.extend({
22
+ name: 'farm-listitem',
23
+ props: {
24
+ to: {
25
+ type: String,
26
+ default: null,
27
+ },
28
+ /**
29
+ * Color on hover
30
+ */
31
+ hoverColor: {
32
+ type: [String, null] as PropType<
33
+ | 'primary'
34
+ | 'secondary'
35
+ | 'neutral'
36
+ | 'error'
37
+ | 'warning'
38
+ | 'info'
39
+ | 'extra-1'
40
+ | 'extra-2'
41
+ >,
42
+ default: null,
43
+ },
44
+ /**
45
+ * Color variation on hover
46
+ */
47
+ hoverColorVariation: {
48
+ type: [String, null] as PropType<'base' | 'lighten' | 'darken'>,
49
+ default: 'base',
50
+ },
51
+ /**
52
+ * Is clickable
53
+ */
54
+ clickable: {
55
+ type: Boolean,
56
+ default: false,
57
+ },
58
+ },
59
+ setup(props, { emit }) {
60
+ const { hoverColor, hoverColorVariation } = toRefs(props);
61
+
62
+ const cssColorWithVariation = computed((): String => {
63
+ if (!hoverColor.value) {
64
+ return null;
65
+ }
66
+ return `farm-listitem--${hoverColor.value}-${hoverColorVariation.value}`;
67
+ });
68
+
69
+ const onClick = () => {
70
+ emit('click');
71
+ };
72
+
73
+ return {
74
+ cssColorWithVariation,
75
+ onClick,
76
+ };
77
+ },
78
+ });
79
+ </script>
80
+ <style lang="scss" scoped>
81
+ @import './ListItem';
82
+ </style>
@@ -0,0 +1,20 @@
1
+ import { shallowMount } from '@vue/test-utils';
2
+ import ListItem from '../ListItem';
3
+
4
+ describe('ListItem component', () => {
5
+ let wrapper;
6
+
7
+ beforeEach(() => {
8
+ wrapper = shallowMount(ListItem);
9
+ });
10
+
11
+ test('Created hook', () => {
12
+ expect(wrapper).toBeDefined();
13
+ });
14
+
15
+ describe('mount component', () => {
16
+ it('renders correctly', () => {
17
+ expect(wrapper.element).toMatchSnapshot();
18
+ });
19
+ });
20
+ });
@@ -0,0 +1,4 @@
1
+ import ListItem from './ListItem.vue';
2
+
3
+ export { ListItem };
4
+ export default ListItem;
@@ -1,9 +1,11 @@
1
1
  <template>
2
2
  <section class="logger">
3
3
  <template v-for="(item, index) in items">
4
- <LoggerItem :item="item" :key="index" />
4
+ <farm-logger-item :item="item" :key="`logger_item_${index}`" />
5
5
  <div
6
+ v-if="hasDivider(index)"
6
7
  :class="{
8
+ 'logger__divider': true,
7
9
  'logger__divider--success': isPreviousLogAndCurrentLogSuccess(index),
8
10
  'logger__divider--error': isPreviousLogAndCurrentLogError(index),
9
11
  'logger__divider--success-to-error':
@@ -11,8 +13,6 @@
11
13
  'logger__divider--error-to-success':
12
14
  isPreviousLogSuccessAndCurrentLogError(index),
13
15
  }"
14
- v-if="hasDivider(index)"
15
- class="logger__divider"
16
16
  :key="'divider_' + index"
17
17
  ></div>
18
18
  </template>
@@ -21,11 +21,9 @@
21
21
  <script lang="ts">
22
22
  import Vue, { PropType } from 'vue';
23
23
  import ILoggerItem from './LoggerItem/ILoggerItem';
24
- import LoggerItem from './LoggerItem/';
25
24
 
26
25
  export default Vue.extend({
27
26
  name: 'farm-logger',
28
- components: { LoggerItem },
29
27
  props: {
30
28
  /*
31
29
  * List of logger items
@@ -57,6 +55,6 @@ export default Vue.extend({
57
55
  },
58
56
  });
59
57
  </script>
60
- <style lang="sass" scoped>
61
- @import './Logger.scss'
58
+ <style lang="scss" scoped>
59
+ @import './Logger';
62
60
  </style>
@@ -36,6 +36,7 @@
36
36
  max-height: calc(100vh - 64px);
37
37
  overflow-y: auto;
38
38
  width: 100%;
39
+ padding: 0 16px;
39
40
  }
40
41
 
41
42
  &--header {
@@ -7,8 +7,8 @@ export default {
7
7
  docs: {
8
8
  description: {
9
9
  component: `Modal<br />
10
- selector: <em>farm-modal</em>
11
- <span style="color: yellow;">wait</span>
10
+ selector: <em>farm-modal</em><br />
11
+ <span style="color: green;">ready for use</span>
12
12
  `,
13
13
  },
14
14
  },
@@ -0,0 +1,3 @@
1
+ section.modal-content {
2
+ margin: 32px 0 16px;
3
+ }
@@ -10,7 +10,8 @@ export default {
10
10
  docs: {
11
11
  description: {
12
12
  component: `Modal Prompt User to Confirm<br />
13
- selector: <em>farm-prompt-user</em>`,
13
+ selector: <em>farm-prompt-user</em><br />
14
+ <span style="color: green;">ready for use</span>`,
14
15
  },
15
16
  },
16
17
  design: {
@@ -28,10 +29,10 @@ export const Primary = () => ({
28
29
  },
29
30
  template: `<div>
30
31
  <farm-prompt-user match="CONFIRMAR" title="Título" subtitle="Digite CONFIRMAR para habilitar" v-model="showPrompt" />
31
- click:
32
- <v-btn color="secondary" @click="showPrompt = true;">
32
+ click:
33
+ <farm-btn color="primary" @click="showPrompt = true;">
33
34
  reabrir
34
- </v-btn>
35
+ </farm-btn>
35
36
  </div>`,
36
37
  });
37
38
  export const Error = () => ({
@@ -42,8 +43,8 @@ export const Error = () => ({
42
43
  },
43
44
  template: `<div>
44
45
  <farm-prompt-user match="REMOVER" title="Título" subtitle="Digite REMOVER para habilitar" v-model="showPrompt" confirmColor="error" confirmLabel="Remover" />
45
- <v-btn color="secondary" @click="showPrompt = true;">
46
+ <farm-btn color="primary" @click="showPrompt = true;">
46
47
  reabrir
47
- </v-btn>
48
+ </farm-btn>
48
49
  </div>`,
49
50
  });
@@ -1,37 +1,35 @@
1
1
  <template>
2
- <v-dialog content-class="modal-default modal-default-small" v-model="inputVal">
3
- <DialogHeader :title="title" @onClose="close" />
4
-
5
- <v-main>
6
- <section class="mt-9">
7
- <PromptUserToConfirm
2
+ <farm-modal v-model="inputVal" size="sm" :offsetTop="48" :offsetBottom="68">
3
+ <template v-slot:header>
4
+ <DialogHeader :title="title" @onClose="close" />
5
+ </template>
6
+ <template v-slot:content>
7
+ <section class="modal-content">
8
+ <farm-promptusertoconfirm
8
9
  v-if="inputVal"
9
- :match="match"
10
10
  v-model="canConfirm"
11
+ :match="match"
11
12
  :title="subtitle"
12
13
  />
13
14
  </section>
15
+ </template>
16
+
17
+ <template v-slot:footer>
14
18
  <DialogFooter
15
- @onClose="close"
16
19
  :confirmColor="confirmColor"
17
20
  :confirmLabel="confirmLabel"
18
- @onConfirm="confirm"
19
21
  :isConfirmDisabled="!canConfirm"
22
+ @onConfirm="confirm"
23
+ @onClose="close"
20
24
  />
21
- </v-main>
22
- </v-dialog>
25
+ </template>
26
+ </farm-modal>
23
27
  </template>
24
28
  <script lang="ts">
25
29
  import Vue from 'vue';
26
- import { VDialog } from 'vuetify/lib/components/VDialog';
27
- import { VMain } from 'vuetify/lib/components/VMain';
28
30
 
29
31
  export default Vue.extend({
30
32
  name: 'farm-prompt-user',
31
- components: {
32
- VDialog,
33
- VMain,
34
- },
35
33
  props: {
36
34
  /**
37
35
  * Habilita/desabilita o modal
@@ -101,3 +99,6 @@ export default Vue.extend({
101
99
  },
102
100
  });
103
101
  </script>
102
+ <style lang="scss" scoped>
103
+ @import './ModalPromptUser';
104
+ </style>
@@ -1,12 +1,12 @@
1
1
  <template>
2
2
  <v-form v-model="formVal" autocomplete="off">
3
- <div v-html="title"></div>
3
+ <farm-caption v-html="title" color="gray" />
4
4
  <v-row>
5
5
  <v-col cols="12" sm="12" class="mt-3 v-col-fieldset-default">
6
6
  <v-text-field
7
+ v-model="matchInput"
7
8
  id="form-confirm-remove"
8
9
  color="secondary"
9
- v-model="matchInput"
10
10
  outlined
11
11
  dense
12
12
  :rules="[rules.checkRemove]"