@farm-investimentos/front-mfe-components 11.0.3 → 11.1.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 (45) hide show
  1. package/dist/front-mfe-components.common.js +688 -436
  2. package/dist/front-mfe-components.common.js.map +1 -1
  3. package/dist/front-mfe-components.css +2 -2
  4. package/dist/front-mfe-components.umd.js +688 -436
  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/Checkbox/Checkbox.scss +10 -0
  10. package/src/components/Checkbox/Checkbox.stories.js +15 -1
  11. package/src/components/Checkbox/Checkbox.vue +9 -1
  12. package/src/components/Collapsible/Collapsible.vue +1 -1
  13. package/src/components/ContextMenu/ContextMenu.scss +32 -0
  14. package/src/components/ContextMenu/ContextMenu.stories.js +104 -0
  15. package/src/components/ContextMenu/ContextMenu.vue +129 -0
  16. package/src/components/ContextMenu/__tests__/ContextMenu.spec.js +20 -0
  17. package/src/components/ContextMenu/index.ts +5 -0
  18. package/src/components/DataTableHeader/DataTableHeader.scss +9 -1
  19. package/src/components/DataTableHeader/DataTableHeader.stories.js +48 -24
  20. package/src/components/DataTableHeader/DataTableHeader.vue +7 -11
  21. package/src/components/DatePicker/DatePicker.vue +6 -0
  22. package/src/components/DialogHeader/DialogHeader.stories.js +11 -0
  23. package/src/components/DialogHeader/DialogHeader.vue +8 -9
  24. package/src/components/FilePicker/FilePicker.vue +1 -2
  25. package/src/components/Form/Form.stories.js +41 -0
  26. package/src/components/Form/Form.vue +2 -0
  27. package/src/components/Icon/Icon.scss +9 -4
  28. package/src/components/Icon/Icon.stories.js +4 -3
  29. package/src/components/Icon/Icon.vue +6 -5
  30. package/src/components/IconBox/IconBox.scss +5 -4
  31. package/src/components/IconBox/IconBox.stories.js +2 -1
  32. package/src/components/IconBox/IconBox.vue +16 -6
  33. package/src/components/IconBox/__tests__/IconBox.spec.js +1 -1
  34. package/src/components/IdCaption/IdCaption.stories.js +18 -0
  35. package/src/components/IdCaption/IdCaption.vue +21 -2
  36. package/src/components/RangeDatePicker/RangeDatePicker.vue +6 -0
  37. package/src/components/Switcher/Switcher.scss +6 -0
  38. package/src/components/Switcher/Switcher.stories.js +28 -0
  39. package/src/components/Switcher/Switcher.vue +27 -2
  40. package/src/components/TableContextMenu/TableContextMenu.scss +15 -1
  41. package/src/components/TableContextMenu/TableContextMenu.stories.js +17 -4
  42. package/src/components/TableContextMenu/TableContextMenu.vue +39 -36
  43. package/src/helpers/date.js +3 -0
  44. package/src/main.ts +1 -0
  45. package/src/components/Switcher/Switcher.api.stories.js +0 -20
@@ -54,6 +54,7 @@ export const Primary = () => ({
54
54
  <farm-label :required="true">True/false</farm-label>
55
55
  <farm-checkbox v-model="form.checkbox" :rules="[rules.checked]" />
56
56
 
57
+
57
58
  <div class="footer" :style="[styles.footer]">
58
59
  <farm-btn color="secondary" outlined @click="$refs.form.reset()" class="mr-3">Reset</farm-btn>
59
60
  <farm-btn color="secondary" :disabled="!validForm">Salvar</farm-btn>
@@ -169,3 +170,43 @@ export const RadioGroupReset = () => ({
169
170
  </farm-form>
170
171
  `,
171
172
  });
173
+
174
+ export const DatePickers = () => ({
175
+ data() {
176
+ return {
177
+ birthDate: '',
178
+ rangeDate: [],
179
+ validForm: false,
180
+ styles,
181
+ };
182
+ },
183
+ template: `
184
+ <farm-form v-model="validForm" :style="[styles.vForm]" ref="form">
185
+
186
+ <farm-label :required="true">Birthdate: {{ birthDate }}</farm-label>
187
+ <DatePicker
188
+ ref="birthDate"
189
+ inputId="form-pf-birthDate"
190
+ class="mt-4"
191
+ v-model="birthDate"
192
+ :readonly="true"
193
+ :required="true"
194
+ />
195
+
196
+ <farm-label :required="true">Range: {{ rangeDate }}</farm-label>
197
+ <RangeDatePicker
198
+ ref="rangeDate"
199
+ inputId="form-pf-rangeDate"
200
+ class="mt-4"
201
+ v-model="rangeDate"
202
+ :readonly="true"
203
+ :required="true"
204
+ />
205
+
206
+ <div class="footer" :style="[styles.footer]">
207
+ <farm-btn color="secondary" outlined @click="$refs.form.reset()" class="mr-3">Reset</farm-btn>
208
+ <farm-btn color="secondary" :disabled="!validForm">Salvar</farm-btn>
209
+ </div>
210
+ </farm-form>
211
+ `,
212
+ });
@@ -48,6 +48,8 @@ export default Vue.extend({
48
48
  validationFields.push($leaf.$children[0]);
49
49
  } else if ($leaf.validatable) {
50
50
  validationFields.push($leaf);
51
+ } else {
52
+ recursiveFormField($leaf);
51
53
  }
52
54
  });
53
55
  };
@@ -1,4 +1,5 @@
1
1
  @import '../../configurations/variables';
2
+ @import '../../configurations/theme-colors';
2
3
 
3
4
  .farm-icon {
4
5
  align-items: center;
@@ -10,16 +11,20 @@
10
11
  position: relative;
11
12
  text-indent: 0;
12
13
 
13
- @each $color in $colors {
14
- &#{'.farm-icon--' + $color} {
15
- color: var(--v-#{$color}-base);
14
+ @each $color in $theme-colors-list {
15
+ &#{'--' + $color} {
16
+ color: var(--farm-#{$color}-base);
16
17
  }
17
18
  }
18
19
 
20
+ &--gray-base {
21
+ color: var(--farm-neutral-darken);
22
+ }
23
+
19
24
  @each $size,
20
25
  $value in $sizes {
21
26
  &#{'.farm-icon[size=' + $size +']'} {
22
27
  font-size: $value;
23
28
  }
24
29
  }
25
- }
30
+ }
@@ -1,5 +1,6 @@
1
1
  import { withDesign } from 'storybook-addon-designs';
2
- import colors from '../../configurations/colors';
2
+ import baseThemeColors from '../../configurations/_theme-colors-base.scss';
3
+ const colors = Object.keys(baseThemeColors);
3
4
  import sizes from '../../configurations/sizes';
4
5
  import iconsList from './icons_list';
5
6
 
@@ -22,7 +23,7 @@ export default {
22
23
 
23
24
  export const Atom = () => ({
24
25
  template: `<div class="icons-container">
25
- <farm-icon color="secondary">
26
+ <farm-icon color="primary">
26
27
  book
27
28
  </farm-icon>
28
29
  </div>`,
@@ -31,7 +32,7 @@ export const Atom = () => ({
31
32
  export const Colors = () => ({
32
33
  data() {
33
34
  return {
34
- colors,
35
+ colors: [...colors, 'gray'],
35
36
  };
36
37
  },
37
38
  template: `<div class="icons-container">
@@ -18,14 +18,15 @@ export default Vue.extend({
18
18
  type: String as PropType<
19
19
  | 'primary'
20
20
  | 'secondary'
21
- | 'error'
22
- | 'extra'
23
- | 'accent'
21
+ | 'neutral'
24
22
  | 'info'
25
23
  | 'success'
24
+ | 'error'
25
+ | 'warning'
26
+ | 'success'
27
+ | 'extra-1'
28
+ | 'extra-2'
26
29
  | 'gray'
27
- | 'yellow'
28
- | 'white'
29
30
  >,
30
31
  default: 'primary',
31
32
  },
@@ -1,4 +1,5 @@
1
1
  @import '../../configurations/variables';
2
+ @import '../../configurations/theme-colors';
2
3
 
3
4
  .farm-icon-box {
4
5
  width: 48px;
@@ -8,17 +9,17 @@
8
9
  justify-content: center;
9
10
  align-items: center;
10
11
 
11
- @each $color in $colors {
12
+ @each $color in $theme-colors-list {
12
13
  &#{'--' + $color} {
13
- background: var(--v-#{$color}-lighten5);
14
+ background: var(--farm-#{$color}-lighten);
14
15
  }
15
16
  }
16
17
  }
17
18
 
18
19
  .farm-icon-box--inverted.farm-icon-box {
19
- @each $color in $colors {
20
+ @each $color in $theme-colors-list {
20
21
  &#{'--' + $color} {
21
- background: var(--v-#{$color}-base);
22
+ background: var(--farm-#{$color}-base);
22
23
  }
23
24
  }
24
25
 
@@ -1,6 +1,7 @@
1
1
  import { withDesign } from 'storybook-addon-designs';
2
2
  import IconBox from './IconBox';
3
- import colors from '../../configurations/colors';
3
+ import baseThemeColors from '../../configurations/_theme-colors-base.scss';
4
+ const colors = Object.keys(baseThemeColors);
4
5
  import sizes from '../../configurations/sizes';
5
6
  import('../Icon/Icons.stories.scss');
6
7
 
@@ -7,9 +7,7 @@
7
7
  }"
8
8
  :size="size"
9
9
  >
10
- <farm-icon :color="inverted ? 'white' : color" :size="size">{{
11
- iconParsed
12
- }}</farm-icon>
10
+ <farm-icon :color="inverted ? 'white' : color" :size="size">{{ iconParsed }}</farm-icon>
13
11
  </div>
14
12
  </template>
15
13
 
@@ -30,15 +28,27 @@ export default Vue.extend({
30
28
  * Color
31
29
  */
32
30
  color: {
33
- type: String,
34
- default: 'secondary',
31
+ type: String as PropType<
32
+ | 'primary'
33
+ | 'secondary'
34
+ | 'neutral'
35
+ | 'info'
36
+ | 'success'
37
+ | 'error'
38
+ | 'warning'
39
+ | 'success'
40
+ | 'extra-1'
41
+ | 'extra-2'
42
+ | 'gray'
43
+ >,
44
+ default: 'primary',
35
45
  },
36
46
  size: {
37
47
  type: String as PropType<'xs' | 'sm' | 'md' | 'lg' | 'xl'>,
38
48
  default: 'md',
39
49
  },
40
50
  /**
41
- * INverted
51
+ * Inverted
42
52
  */
43
53
  inverted: {
44
54
  type: Boolean,
@@ -31,7 +31,7 @@ describe('IconBox component', () => {
31
31
  });
32
32
 
33
33
  it('get cssColorClass', () => {
34
- expect(component.cssColorClass).toEqual('farm-icon-box--secondary');
34
+ expect(component.cssColorClass).toEqual('farm-icon-box--primary');
35
35
  });
36
36
  });
37
37
  });
@@ -114,3 +114,21 @@ export const NoTextToClip = () => ({
114
114
  </farm-idcaption>
115
115
  `,
116
116
  });
117
+
118
+ export const IconBoxCustomColor = () => ({
119
+ template: `
120
+ <farm-idcaption
121
+ icon="account-box-outline"
122
+ copyText="texto a copiar"
123
+ iconBoxColor="error"
124
+ :link="true"
125
+ >
126
+ <template v-slot:title>
127
+ Upper Line Text
128
+ </template>
129
+ <template v-slot:subtitle>
130
+ Lower: Line Text Line Text Line Text
131
+ </template>
132
+ </farm-idcaption>
133
+ `,
134
+ });
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <div class="idcaption">
3
- <farm-icon-box v-if="icon" :icon="icon" color="secondary" size="md" />
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 }"
6
6
  >
@@ -24,7 +24,7 @@
24
24
  </template>
25
25
 
26
26
  <script lang="ts">
27
- import Vue, { computed } from 'vue';
27
+ import Vue, { computed, PropType } from 'vue';
28
28
  export default Vue.extend({
29
29
  name: 'farm-idcaption',
30
30
  props: {
@@ -34,6 +34,25 @@ export default Vue.extend({
34
34
  icon: {
35
35
  type: String,
36
36
  },
37
+ /**
38
+ * IconBox Color
39
+ */
40
+ iconBoxColor: {
41
+ type: String as PropType<
42
+ | 'primary'
43
+ | 'secondary'
44
+ | 'neutral'
45
+ | 'info'
46
+ | 'success'
47
+ | 'error'
48
+ | 'warning'
49
+ | 'success'
50
+ | 'extra-1'
51
+ | 'extra-2'
52
+ | 'gray'
53
+ >,
54
+ default: 'primary',
55
+ },
37
56
  /**
38
57
  * copy to clipboard
39
58
  */
@@ -116,6 +116,12 @@ export default Vue.extend({
116
116
  this.dateField = newValue;
117
117
  this.fieldRange = this.formatDateRange(newValue);
118
118
  },
119
+ fieldRange(newValue) {
120
+ if (!newValue) {
121
+ this.dateField = [];
122
+ this.save();
123
+ }
124
+ },
119
125
  },
120
126
  methods: {
121
127
  formatDateRange(date) {
@@ -17,9 +17,15 @@
17
17
  &:focus {
18
18
  outline: 0;
19
19
  }
20
+
20
21
  &[block] {
21
22
  display: block;
22
23
  }
24
+
25
+ &--disabled {
26
+ opacity: 0.6;
27
+ cursor: default;
28
+ }
23
29
  }
24
30
 
25
31
  .farm-switch__background {
@@ -0,0 +1,28 @@
1
+ import Switch from './Switcher';
2
+
3
+ export default {
4
+ title: 'Form/Switcher',
5
+ component: Switch,
6
+ };
7
+
8
+ export const Primary = () => ({
9
+ data() {
10
+ return {
11
+ selectedValue: false,
12
+ };
13
+ },
14
+ template: `<div>
15
+ <farm-switcher v-model="selectedValue" block />
16
+ </div>`,
17
+ });
18
+
19
+ export const Disabled = () => ({
20
+ data() {
21
+ return {
22
+ selectedValue: false,
23
+ };
24
+ },
25
+ template: `<div>
26
+ <farm-switcher v-model="selectedValue" block :disabled="true" />
27
+ </div>`,
28
+ });
@@ -1,5 +1,10 @@
1
1
  <template>
2
- <div class="farm-switch" role="checkbox" @click="toggle" @keydown.space.prevent="toggle">
2
+ <div
3
+ :class="{ 'farm-switch': true, 'farm-switch--disabled': isDisabled }"
4
+ role="checkbox"
5
+ @click="toggle"
6
+ @keydown.space.prevent="toggle"
7
+ >
3
8
  <span class="farm-switch__background" :class="backgroundStyles" />
4
9
  <span class="farm-switch__indicator" :style="indicatorStyles" />
5
10
  </div>
@@ -10,10 +15,22 @@ import Vue from 'vue';
10
15
  export default Vue.extend({
11
16
  name: 'farm-switcher',
12
17
  props: {
18
+ /**
19
+ * v-model binding
20
+ */
13
21
  value: {
14
22
  type: Boolean,
15
23
  required: true,
16
24
  },
25
+ /**
26
+ * Is disabled?
27
+ */
28
+ disabled: { type: Boolean, default: false },
29
+ },
30
+ data() {
31
+ return {
32
+ isDisabled: this.disabled,
33
+ };
17
34
  },
18
35
  computed: {
19
36
  backgroundStyles() {
@@ -26,13 +43,21 @@ export default Vue.extend({
26
43
  return { transform: this.value ? 'translateX(16px)' : 'translateX(0)' };
27
44
  },
28
45
  },
46
+ watch: {
47
+ disabled(newValue: boolean) {
48
+ this.isDisabled = newValue;
49
+ },
50
+ },
29
51
  methods: {
30
52
  toggle() {
53
+ if (this.isDisabled) {
54
+ return false;
55
+ }
31
56
  this.$emit('input', !this.value);
32
57
  },
33
58
  },
34
59
  });
35
60
  </script>
36
61
  <style lang="scss" scoped>
37
- @import 'Switcher.scss';
62
+ @import 'Switcher';
38
63
  </style>
@@ -1,8 +1,22 @@
1
- [role='menuitem'] {
1
+ .v-list-item.v-list-item--link {
2
2
  border-bottom: 1px solid var(--farm-stroke-base);
3
3
  }
4
4
 
5
5
  .v-list-item__title {
6
+ display: flex;
7
+ align-items: center;
8
+
9
+
10
+ }
11
+
12
+ ::v-deep .v-application--wrap {
13
+ min-height: auto;
14
+ font-family: 'Montserrat', sans-serif !important;
15
+ }
16
+
17
+ .farm-listitem {
18
+ padding: auto 8px;
19
+
6
20
  .farm-icon {
7
21
  vertical-align: sub;
8
22
  margin-right: 8px;
@@ -23,13 +23,13 @@ export default {
23
23
  };
24
24
 
25
25
  export const Primary = () => ({
26
- template: `<div>
26
+ template: `<div style="padding-left: 80px">
27
27
  <farm-context-menu :items="[{ label: 'Remover', icon: { color: 'error', type: 'open-in-new' } }]" />
28
28
  </div>`,
29
29
  });
30
30
 
31
31
  export const Icons = () => ({
32
- template: `<div>
32
+ template: `<div style="padding-left: 80px">
33
33
  <farm-context-menu
34
34
  ref="icons"
35
35
  :items="[{ label: 'Remover', icon: { color: 'error', type: 'delete' } }]"
@@ -41,13 +41,26 @@ export const Multi = () => ({
41
41
  data() {
42
42
  return {
43
43
  items: [
44
- { label: 'Novo', icon: { color: 'grey', type: 'open-in-new' } },
44
+ { label: 'Novo', icon: { type: 'open-in-new' } },
45
45
  { label: 'Editar', icon: { color: 'secondary', type: 'open-in-new' } },
46
46
  { label: 'Remover', icon: { color: 'error', type: 'delete' } },
47
47
  ],
48
48
  };
49
49
  },
50
- template: `<div>
50
+ template: `<div style="padding-left: 80px">
51
51
  <farm-context-menu ref="multi" :items="items" />
52
52
  </div>`,
53
53
  });
54
+
55
+ export const ClickHandler = () => ({
56
+ data() {
57
+ return {
58
+ editItem: () => {
59
+ alert('Click handler');
60
+ },
61
+ };
62
+ },
63
+ template: `<div style="padding-left: 80px">
64
+ <farm-context-menu :items="[{ label: 'Click me', icon: { type: 'open-in-new' }, handler: 'edit' }]" @edit="editItem()" />
65
+ </div>`,
66
+ });
@@ -1,62 +1,65 @@
1
1
  <template>
2
- <v-menu>
3
- <template v-slot:activator="{ on, attrs }">
4
- <farm-btn icon v-bind="attrs" v-on="on" title="Abrir opções" color="secondary">
2
+ <farm-contextmenu v-model="value">
3
+ <template v-slot:activator="{}">
4
+ <farm-btn icon @click="toggleValue" title="Abrir opções" color="secondary">
5
5
  <farm-icon size="md">dots-horizontal</farm-icon>
6
6
  </farm-btn>
7
7
  </template>
8
-
9
- <v-list dense class="pa-0">
10
- <v-list-item
8
+ <farm-list>
9
+ <farm-listitem
11
10
  v-for="item in items"
12
- :key="item.label"
13
- :title="item.label"
11
+ clickable
12
+ hoverColorVariation="lighten"
13
+ :key="'tablecontextmenu_item_' + item.label"
14
+ :hoverColor="item.icon.color || 'primary'"
14
15
  @click="onClick(item.handler)"
15
16
  >
16
- <v-list-item-content>
17
- <v-list-item-title>
18
- <farm-icon
19
- v-if="item.icon"
20
- size="md"
21
- :color="item.icon.color || 'secondary'"
22
- >
23
- {{ item.icon.type }}
24
- </farm-icon>
25
- {{ item.label }}
26
- </v-list-item-title>
27
- </v-list-item-content>
28
- </v-list-item>
29
- </v-list>
30
- </v-menu>
17
+ <farm-icon v-if="item.icon" size="sm" :color="item.icon.color || 'primary'">
18
+ {{ item.icon.type }}
19
+ </farm-icon>
20
+ <farm-caption bold tag="span">{{ item.label }}</farm-caption>
21
+ </farm-listitem>
22
+ </farm-list>
23
+ </farm-contextmenu>
31
24
  </template>
32
25
  <script lang="ts">
33
- import Vue from 'vue';
34
- import { VMenu } from 'vuetify/lib/components/VMenu';
35
- import { VList } from 'vuetify/lib/components/VList';
36
- import VListItem from 'vuetify/lib/components/VList/VListItem';
37
- import { VListItemContent, VListItemTitle } from 'vuetify/lib';
26
+ import Vue, { PropType } from 'vue';
27
+
28
+ export interface IContextMenuOption {
29
+ label: string;
30
+ handler: string;
31
+ icon: IContextMenuOptionIcon;
32
+ }
33
+
34
+ export interface IContextMenuOptionIcon {
35
+ color?: string;
36
+ type: string;
37
+ }
38
38
 
39
39
  export default Vue.extend({
40
40
  name: 'farm-context-menu',
41
- components: {
42
- VMenu,
43
- VList,
44
- VListItem,
45
- VListItemContent,
46
- VListItemTitle,
47
- },
41
+ components: {},
48
42
  props: {
49
43
  items: {
50
- type: Array,
44
+ type: Array as PropType<Array<IContextMenuOption>>,
51
45
  required: true,
52
46
  },
53
47
  },
48
+ data() {
49
+ return {
50
+ value: false,
51
+ };
52
+ },
54
53
  methods: {
55
54
  onClick(handler) {
56
55
  if (handler !== undefined) {
57
56
  this.$emit(handler);
57
+ // handler();
58
58
  }
59
59
  },
60
+ toggleValue() {
61
+ this.value = !this.value;
62
+ },
60
63
  },
61
64
  });
62
65
  </script>
@@ -6,6 +6,9 @@ export const defaultFormat = (data, UTCTimeZone = true) => {
6
6
  };
7
7
 
8
8
  export const convertDate = (data) => {
9
+ if(!data) {
10
+ return null;
11
+ }
9
12
  let newdate = data.split("/").reverse().join("-");
10
13
  return newdate;
11
14
  };
package/src/main.ts CHANGED
@@ -62,6 +62,7 @@ export * from './components/Buttons/MultiImportButton';
62
62
  export * from './components/Card';
63
63
  export * from './components/Checkbox';
64
64
  export * from './components/Chip';
65
+ export * from './components/ContextMenu';
65
66
  export * from './components/CopyToClipboard';
66
67
  export * from './components/Logos/ProductLogo';
67
68
  export * from './components/Logos/OriginatorLogo';
@@ -1,20 +0,0 @@
1
- import Switch from './Switcher';
2
-
3
- export default {
4
- title: 'Form/Switcher',
5
- component: Switch,
6
- };
7
-
8
- export const Primary = () => ({
9
- components: { 'farm-switch': Switch },
10
- data() {
11
- return {
12
- selectedValue: false,
13
- };
14
- },
15
- template: `<div>
16
- <farm-switch v-model="selectedValue" block />
17
- </div>`,
18
- });
19
-
20
- Primary.storyName = 'Basic';