@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farm-investimentos/front-mfe-components",
3
- "version": "11.0.3",
3
+ "version": "11.1.1",
4
4
  "author": "farm investimentos",
5
5
  "private": false,
6
6
  "main": "./dist/front-mfe-components.common.js",
@@ -1,4 +1,5 @@
1
1
  @import '../../configurations/theme-colors';
2
+ @import '../../configurations/variables';
2
3
 
3
4
  .farm-checkbox__container {
4
5
  display: flex;
@@ -46,6 +47,7 @@
46
47
  &--disabled {
47
48
  border-color: #dadada;
48
49
  cursor: default;
50
+ opacity: 0.6;
49
51
 
50
52
  &.farm-checkbox--checked {
51
53
  background-color: #dadada;
@@ -56,4 +58,12 @@
56
58
  color: white;
57
59
  }
58
60
 
61
+ }
62
+
63
+ @each $size,
64
+ $value in $sizes {
65
+ #{'.farm-checkbox[size=' + $size +']'} {
66
+ width: $value;
67
+ height: $value;
68
+ }
59
69
  }
@@ -1,6 +1,6 @@
1
1
  import Checkbox from './Checkbox';
2
2
  import baseThemeColors from '../../configurations/_theme-colors-base.scss';
3
-
3
+ import sizes from '../../configurations/sizes';
4
4
  const colors = Object.keys(baseThemeColors);
5
5
  const variations = ['', 'darken', 'lighten'];
6
6
 
@@ -92,3 +92,17 @@ export const Colors = () => ({
92
92
  </div>
93
93
  </div>`,
94
94
  });
95
+
96
+ export const Sizes = () => ({
97
+ data() {
98
+ return {
99
+ sizes,
100
+ isChecked: true,
101
+ };
102
+ },
103
+ template: `<div style="display: flex; flex-direction: column; flex-wrap: wrap;">
104
+ <div v-for="size of sizes">
105
+ <farm-checkbox v-model="isChecked" :size="size" :label="size" /><br />
106
+ </div>
107
+ </div>`,
108
+ });
@@ -8,9 +8,10 @@
8
8
  'farm-checkbox--lighten': variation === 'lighten',
9
9
  'farm-checkbox--darken': variation === 'darken',
10
10
  }"
11
+ :size="$props.size"
11
12
  @click="toggleValue"
12
13
  >
13
- <farm-icon size="sm" v-if="innerValue">check</farm-icon>
14
+ <farm-icon :size="$props.size" v-if="innerValue">check</farm-icon>
14
15
  </span>
15
16
  <farm-label v-if="label">
16
17
  {{ label }}
@@ -57,6 +58,13 @@ export default Vue.extend({
57
58
  type: Array as PropType<Array<Function>>,
58
59
  default: () => [],
59
60
  },
61
+ /**
62
+ * Size
63
+ */
64
+ size: {
65
+ type: String as PropType<'xs' | 'sm' | 'md' | 'lg' | 'xl'>,
66
+ default: 'md',
67
+ },
60
68
  },
61
69
  setup(props, { emit }) {
62
70
  const innerValue = ref(props.value);
@@ -4,7 +4,7 @@
4
4
  <div class="collapsible__header" @click="onToggleCollapsible(status)">
5
5
  <div class="collapsible__content-title">
6
6
  <div class="collapsible__icon collapsible__icon--main" v-if="icon !== ''">
7
- <farm-icon color="secondary" size="md">
7
+ <farm-icon size="md">
8
8
  {{ icon }}
9
9
  </farm-icon>
10
10
  </div>
@@ -0,0 +1,32 @@
1
+ @import '../../configurations/mixins';
2
+
3
+ .farm-contextmenu {
4
+ display: inline-block;
5
+ }
6
+
7
+ .farm-contextmenu__popup {
8
+ visibility: hidden;
9
+ opacity: 0;
10
+ position: absolute;
11
+ display: block;
12
+ overflow-y: auto;
13
+ overflow-x: hidden;
14
+ contain: content;
15
+ font-family: 'Montserrat', sans-serif !important;
16
+
17
+ transform-origin: left top;
18
+ transition: visibility 0.1s linear, opacity 0.1s linear;
19
+
20
+ border-radius: 4px;
21
+ left: 0;
22
+
23
+ background: #FFFFFF;
24
+ border: 1px solid var(--farm-stroke-base);
25
+ @include addShadow;
26
+ border-radius: 5px;
27
+
28
+ &--visible {
29
+ opacity: 1;
30
+ visibility: visible;
31
+ }
32
+ }
@@ -0,0 +1,104 @@
1
+ import { withDesign } from 'storybook-addon-designs';
2
+ import ContextMenu from './';
3
+
4
+ export default {
5
+ title: 'Interactions/ContextMenu',
6
+ component: ContextMenu,
7
+ decorators: [withDesign],
8
+ parameters: {
9
+ docs: {
10
+ description: {
11
+ component: `ContextMenu<br />
12
+ selector: <em>farm-contextmenu</em><br />
13
+ <span style="color: var(--farm-primary-base);">ready for use</span>
14
+ `,
15
+ },
16
+ },
17
+ viewMode: 'docs',
18
+ },
19
+ };
20
+
21
+ export const Primary = () => ({
22
+ data() {
23
+ return {
24
+ value: false,
25
+ };
26
+ },
27
+ methods: {
28
+ toggleValue() {
29
+ this.value = !this.value;
30
+ },
31
+ },
32
+ template: `<div style="padding-left: 120px; padding-top: 80px; display: flex;">
33
+ <farm-contextmenu v-model="value">
34
+ some text
35
+ <template v-slot:activator="{ on, attrs }">
36
+ <farm-btn @click="toggleValue">toggle</farm-btn>
37
+ </template>
38
+ </farm-contextmenu>
39
+ </div>`,
40
+ });
41
+
42
+ export const LongContent = () => ({
43
+ data() {
44
+ return {
45
+ value: false,
46
+ };
47
+ },
48
+ methods: {
49
+ toggleValue() {
50
+ this.value = !this.value;
51
+ },
52
+ },
53
+ template: `<div style="padding-left: 120px; padding-top: 80px;">
54
+ <farm-contextmenu v-model="value">
55
+ <div style="width: 160px">long content<br />
56
+ with breakline</div>
57
+ <template v-slot:activator="{ on, attrs }">
58
+ <farm-btn @click="toggleValue">toggle</farm-btn>
59
+ </template>
60
+ </farm-contextmenu>
61
+ </div>`,
62
+ });
63
+
64
+ export const Bottom = () => ({
65
+ data() {
66
+ return {
67
+ value: false,
68
+ };
69
+ },
70
+ methods: {
71
+ toggleValue() {
72
+ this.value = !this.value;
73
+ },
74
+ },
75
+ template: `<div style="padding-left: 120px; padding-top: 80px; display: flex;">
76
+ <farm-contextmenu v-model="value" :bottom="true">
77
+ some text
78
+ <template v-slot:activator="{ on, attrs }">
79
+ <farm-btn @click="toggleValue">toggle</farm-btn>
80
+ </template>
81
+ </farm-contextmenu>
82
+ </div>`,
83
+ });
84
+
85
+ export const ComplexContent = () => ({
86
+ data() {
87
+ return {
88
+ value: false,
89
+ };
90
+ },
91
+ methods: {
92
+ toggleValue() {
93
+ this.value = !this.value;
94
+ },
95
+ },
96
+ template: `<div style="padding-left: 120px; padding-top: 80px; display: flex;">
97
+ <farm-contextmenu v-model="value">
98
+ <farm-chip>farm chip</farm-chip>
99
+ <template v-slot:activator="{ on, attrs }">
100
+ <farm-btn @click="toggleValue">toggle</farm-btn>
101
+ </template>
102
+ </farm-contextmenu>
103
+ </div>`,
104
+ });
@@ -0,0 +1,129 @@
1
+ <template>
2
+ <div class="farm-contextmenu" ref="parent">
3
+ <span ref="activator">
4
+ <slot name="activator"></slot>
5
+ </span>
6
+
7
+ <div
8
+ ref="popup"
9
+ :class="{
10
+ 'farm-contextmenu__popup': true,
11
+ 'farm-contextmenu__popup--visible': inputValue,
12
+ }"
13
+ :style="styles"
14
+ >
15
+ <slot></slot>
16
+ </div>
17
+ </div>
18
+ </template>
19
+ <script lang="ts">
20
+ import Vue, { onMounted, ref, watch, reactive, onBeforeUnmount, toRefs } from 'vue';
21
+
22
+ export default Vue.extend({
23
+ name: 'farm-contextmenu',
24
+ props: {
25
+ /**
26
+ * Control visibility
27
+ * v-model bind
28
+ */
29
+ value: {
30
+ type: Boolean,
31
+ default: undefined,
32
+ },
33
+ /**
34
+ * Aligns the component towards the bottom
35
+ */
36
+ bottom: {
37
+ type: Boolean,
38
+ default: false,
39
+ },
40
+ },
41
+ setup(props, { emit }) {
42
+ const parent = ref(null);
43
+ const popup = ref(null);
44
+ const activator = ref(null);
45
+ const styles = reactive({ minWidth: 0, top: 0 } as any);
46
+ const { bottom } = toRefs(props);
47
+
48
+ const inputValue = ref(props.value);
49
+
50
+ let hasBeenBoostrapped = false;
51
+
52
+ const outClick = (event: Event) => {
53
+ if (activator && !activator.value.contains(event.target)) {
54
+ emit('input', false);
55
+ }
56
+ };
57
+
58
+ const resizeWindowHandler = () => {
59
+ calculatePosition();
60
+ };
61
+
62
+ watch(
63
+ () => props.value,
64
+ newValue => {
65
+ if (newValue) {
66
+ if (!hasBeenBoostrapped) {
67
+ document.querySelector('body').appendChild(popup.value);
68
+
69
+ hasBeenBoostrapped = true;
70
+ }
71
+ window.addEventListener('click', outClick);
72
+ window.addEventListener('resize', resizeWindowHandler);
73
+
74
+ calculatePosition();
75
+ } else {
76
+ window.removeEventListener('click', outClick);
77
+ }
78
+ inputValue.value = newValue;
79
+ }
80
+ );
81
+
82
+ const calculatePosition = () => {
83
+ const parentBoundingClientRect = parent.value.getBoundingClientRect();
84
+ const popupClientRect = popup.value.getBoundingClientRect();
85
+
86
+ const offsetTop =
87
+ parentBoundingClientRect.top +
88
+ window.scrollY +
89
+ (!bottom.value ? 0 : parentBoundingClientRect.height);
90
+
91
+ let offsetLeft = parentBoundingClientRect.left;
92
+ if (popupClientRect.width > parentBoundingClientRect.width) {
93
+ offsetLeft =
94
+ offsetLeft + parentBoundingClientRect.width / 2 - popupClientRect.width / 2;
95
+ }
96
+ styles.minWidth =
97
+ parentBoundingClientRect.width > 96
98
+ ? parseInt(parentBoundingClientRect.width)
99
+ : 96 + 'px';
100
+ styles.top = offsetTop + 'px';
101
+ styles.left = offsetLeft + 'px';
102
+ };
103
+
104
+ onMounted(() => {
105
+ calculatePosition();
106
+ });
107
+
108
+ onBeforeUnmount(() => {
109
+ if (hasBeenBoostrapped) {
110
+ window.removeEventListener('resize', resizeWindowHandler);
111
+ window.removeEventListener('click', outClick);
112
+ document.querySelector('body').removeChild(popup.value);
113
+ }
114
+ });
115
+
116
+ return {
117
+ parent,
118
+ popup,
119
+ activator,
120
+ styles,
121
+ inputValue,
122
+ };
123
+ },
124
+ });
125
+ </script>
126
+
127
+ <style lang="scss" scoped>
128
+ @import './ContextMenu';
129
+ </style>
@@ -0,0 +1,20 @@
1
+ import { shallowMount } from '@vue/test-utils';
2
+ import ContextMenu from '../ContextMenu';
3
+
4
+ describe('ContextMenu component', () => {
5
+ let wrapper;
6
+
7
+ beforeEach(() => {
8
+ wrapper = shallowMount(ContextMenu, {});
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,5 @@
1
+ import ContextMenu from './ContextMenu.vue';
2
+
3
+ export default ContextMenu;
4
+
5
+ export { ContextMenu };
@@ -2,6 +2,7 @@
2
2
  position: relative;
3
3
  color: var(--v-primary-base);
4
4
  font-size: 12px;
5
+
5
6
  .farm-icon {
6
7
  position: absolute;
7
8
  right: -20px;
@@ -17,11 +18,18 @@
17
18
 
18
19
  th.sortable {
19
20
  cursor: pointer;
21
+
20
22
  &:not(.active) {
21
23
  &:hover {
22
- .v-icon {
24
+ .farm-icon {
23
25
  opacity: 0.5 !important;
24
26
  }
25
27
  }
26
28
  }
27
29
  }
30
+
31
+ th span.span-checkbox {
32
+ display: flex;
33
+ justify-content: start;
34
+ padding-left: 4px;
35
+ }
@@ -1,40 +1,64 @@
1
+ import { withDesign } from 'storybook-addon-designs';
1
2
  import DataTableHeader from './DataTableHeader.vue';
2
3
 
3
4
  export default {
4
5
  title: 'Display/Table/DataTableHeader',
5
6
  component: DataTableHeader,
7
+ decorators: [withDesign],
8
+ parameters: {
9
+ docs: {
10
+ description: {
11
+ component: `DataTable Header<br />
12
+ selector: <em>farm-datatable-header</em><br />
13
+ <span style="color: var(--farm-primary-base);">ready for use</span>
14
+ `,
15
+ },
16
+ },
17
+ viewMode: 'docs',
18
+ },
6
19
  };
7
20
 
8
21
  export const Primary = () => ({
9
22
  data() {
10
23
  return {
11
- headers: [
12
- {
13
- text: 'Grupo',
14
- sortable: true,
15
- value: 'name',
16
- align: 'left',
17
- },
18
- {
19
- text: 'Aprovado',
20
- sortable: true,
21
- value: 'approvedAmount',
22
- align: 'center',
23
- width: 320,
24
- },
25
- {
26
- text: 'Disponível',
27
- sortable: false,
28
- value: 'availableAmount',
29
- align: 'center',
30
- width: 160,
31
- },
32
- ],
24
+ headers,
25
+ sortClick: [],
26
+ firstSelected: false,
27
+ };
28
+ },
29
+ template: `<farm-datatable-header :headers="headers" :sortClick="sortClick" :firstSelected="firstSelected" />`,
30
+ });
31
+
32
+ export const CheckBox = () => ({
33
+ data() {
34
+ return {
35
+ headers,
33
36
  sortClick: [],
34
37
  firstSelected: false,
35
38
  };
36
39
  },
37
- template: `<DataTableHeader :headers="headers" :sortClick="sortClick" :firstSelected="firstSelected" />`,
40
+ template: `<farm-datatable-header :headers="headers" :sortClick="sortClick" :firstSelected="firstSelected" :showCheckbox="true" :selectedIndex="1" />`,
38
41
  });
39
42
 
40
- Primary.storyName = 'Básico';
43
+ const headers = [
44
+ {
45
+ text: 'Grupo',
46
+ sortable: true,
47
+ value: 'name',
48
+ align: 'left',
49
+ },
50
+ {
51
+ text: 'Aprovado',
52
+ sortable: true,
53
+ value: 'approvedAmount',
54
+ align: 'center',
55
+ width: 320,
56
+ },
57
+ {
58
+ text: 'Disponível',
59
+ sortable: false,
60
+ value: 'availableAmount',
61
+ align: 'center',
62
+ width: 160,
63
+ },
64
+ ];
@@ -33,31 +33,26 @@
33
33
  </farm-icon>
34
34
  </span>
35
35
 
36
- <span v-if="isTHDataTableSelect(item) && showCheckbox">
37
- <v-simple-checkbox
36
+ <span v-if="isTHDataTableSelect(item) && showCheckbox" class="span-checkbox">
37
+ <!--
38
38
  :indeterminate="headerProps.someItems && !headerProps.everyItem"
39
- v-model="inputVal"
40
- @input="selectAll"
41
- ></v-simple-checkbox>
39
+ -->
40
+ <farm-checkbox size="sm" v-model="inputVal" @input="selectAll" />
42
41
  </span>
43
42
  </th>
44
43
  </tr>
45
44
  </thead>
46
45
  </template>
47
46
 
48
- <script>
47
+ <script lang="ts">
49
48
  /* eslint-disable */
50
49
  import Vue from 'vue';
51
- import VSimpleCheckbox from 'vuetify/lib/components/VCheckbox/VSimpleCheckbox';
52
50
 
53
51
  export default Vue.extend({
54
52
  name: 'farm-datatable-header',
55
- components: {
56
- VSimpleCheckbox,
57
- },
58
53
  props: {
59
54
  /**
60
- * Cabeçalho
55
+ * Headers
61
56
  */
62
57
  headers: {
63
58
  type: Array,
@@ -100,6 +95,7 @@ export default Vue.extend({
100
95
  * Hide/show checkbox
101
96
  */
102
97
  showCheckbox: {
98
+ type: Boolean,
103
99
  default: true,
104
100
  },
105
101
  },
@@ -143,6 +143,12 @@ export default Vue.extend({
143
143
  this.dateField = newValue;
144
144
  this.fieldRange = this.formatDateRange(newValue);
145
145
  },
146
+ fieldRange(newValue) {
147
+ if (!newValue) {
148
+ this.dateField = '';
149
+ this.save();
150
+ }
151
+ },
146
152
  },
147
153
  methods: {
148
154
  formatDateRange(date) {
@@ -3,6 +3,17 @@ import DialogHeader from './DialogHeader.vue';
3
3
  export default {
4
4
  title: 'Display/Dialog/DialogHeader',
5
5
  component: DialogHeader,
6
+ parameters: {
7
+ docs: {
8
+ description: {
9
+ component: `Dialog Header<br />
10
+ selector: <em>farm-dialog-header</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 = () => ({
@@ -7,16 +7,15 @@
7
7
 
8
8
  <slot></slot>
9
9
 
10
- <farm-icon
10
+ <farm-btn
11
11
  v-if="hasCloseIcon"
12
- role="button"
13
- title="Fechar"
12
+ icon
14
13
  class="farm-dialog-header__close"
15
- color="secondary"
14
+ title="Fechar"
16
15
  @click="onClose"
17
16
  >
18
- close-thick
19
- </farm-icon>
17
+ <farm-icon role="button"> close-thick </farm-icon>
18
+ </farm-btn>
20
19
  </header>
21
20
  </template>
22
21
  <script lang="ts">
@@ -28,21 +27,21 @@ export default Vue.extend({
28
27
  name: 'farm-dialog-header',
29
28
  props: {
30
29
  /**
31
- * Título
30
+ * Title
32
31
  */
33
32
  title: {
34
33
  type: String,
35
34
  default: '',
36
35
  },
37
36
  /**
38
- * Ícone - usa os do material icons
37
+ * Icon
39
38
  */
40
39
  iconTitle: {
41
40
  type: String,
42
41
  default: null,
43
42
  },
44
43
  /**
45
- * Ícone - se possui o ícone de fechar
44
+ * Has close icon?
46
45
  */
47
46
  hasCloseIcon: {
48
47
  type: Boolean,
@@ -7,7 +7,7 @@
7
7
  :accept="acceptedFileTypes"
8
8
  />
9
9
  <div v-if="!selectedFile" class="selectfile-container">
10
- <farm-icon color="secondary">cloud-upload</farm-icon>
10
+ <farm-icon>cloud-upload</farm-icon>
11
11
  <p>Clique para selecionar ou arraste o arquivo aqui</p>
12
12
  </div>
13
13
  <div v-if="selectedFile || maxSizeReach" class="reset-container">
@@ -21,7 +21,6 @@
21
21
 
22
22
  <farm-btn
23
23
  outlined
24
- color="secondary"
25
24
  class="farm-btn--responsive"
26
25
  title="Escolher outro"
27
26
  @click="reset"