@farm-investimentos/front-mfe-components 11.2.1 → 11.3.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farm-investimentos/front-mfe-components",
3
- "version": "11.2.1",
3
+ "version": "11.3.0",
4
4
  "author": "farm investimentos",
5
5
  "private": false,
6
6
  "main": "./dist/front-mfe-components.common.js",
@@ -10,7 +10,13 @@ export const Primary = () => ({
10
10
  });
11
11
 
12
12
  export const List = () => ({
13
- template: `<farm-btn-multipleimport :optionsList="[{ listenerKey: 1, title: 'XLS teste'}, { listenerKey: 2, title: 'CSV teste novo'}]" />`,
13
+ methods: {
14
+ listener(key) {
15
+ alert('Handler for item ' + key);
16
+ },
17
+ },
18
+ template: `<farm-btn-multipleimport
19
+ :optionsList="[{ listenerKey: 1, title: 'XLS teste'}, { listenerKey: 2, title: 'CSV teste novo'}]"
20
+ @onClick="listener"
21
+ />`,
14
22
  });
15
-
16
- List.storyName = 'Lista';
@@ -1,4 +1,5 @@
1
1
  <template>
2
+ <!--
2
3
  <v-menu content-class="elevation-1" v-model="togglePopover" :offset-y="true" :rounded="'b t-0'">
3
4
  <template v-slot:activator="{ on, attrs }">
4
5
  <farm-btn
@@ -39,39 +40,60 @@
39
40
  </v-list-item>
40
41
  </v-list>
41
42
  </v-menu>
43
+ -->
44
+ <farm-contextmenu v-model="value" :bottom="true">
45
+ <template v-slot:activator="{}">
46
+ <farm-btn outlined title="Importar" color="secondary" @click="toggleValue">
47
+ Importar
48
+ <farm-icon class="ml-2"> chevron-{{ value ? 'up' : 'down' }} </farm-icon>
49
+ </farm-btn>
50
+ </template>
51
+ <farm-list>
52
+ <farm-listitem
53
+ v-for="item in optionsList"
54
+ clickable
55
+ hoverColor="primary"
56
+ hoverColorVariation="lighten"
57
+ :key="'importbutton_key_' + item.title"
58
+ :title="item.title"
59
+ @click="onClick(item.listenerKey)"
60
+ >
61
+ <farm-caption bold tag="span">{{ item.title }}</farm-caption>
62
+ </farm-listitem>
63
+ </farm-list>
64
+ </farm-contextmenu>
42
65
  </template>
43
- <script>
44
- import Vue from 'vue';
45
- import VList from 'vuetify/lib/components/VList/VList';
46
- import VMenu from 'vuetify/lib/components/VMenu';
47
- import VListItem from 'vuetify/lib/components/VList/VListItem';
48
- import { VListItemContent, VListItemTitle } from 'vuetify/lib';
66
+ <script lang="ts">
67
+ import Vue, { PropType } from 'vue';
68
+
69
+ export interface IImportOption {
70
+ title: String;
71
+ listenerKey: String;
72
+ }
49
73
 
50
74
  export default Vue.extend({
51
75
  name: 'farm-btn-multipleimport',
52
- components: {
53
- VList,
54
- VListItem,
55
- VMenu,
56
- VListItemContent,
57
- VListItemTitle,
58
- },
59
76
  props: {
60
77
  /**
61
- * Lista de opções para o menu dropdown
78
+ * Options list
62
79
  */
63
80
  optionsList: {
64
- type: Array,
81
+ type: Array as PropType<Array<IImportOption>>,
65
82
  default: () => [],
66
83
  },
67
84
  },
68
85
  data() {
69
86
  return {
70
- togglePopover: false,
87
+ value: false,
71
88
  };
72
89
  },
90
+ methods: {
91
+ onClick(key) {
92
+ this.$emit('onClick', key);
93
+ },
94
+ toggleValue() {
95
+ this.value = !this.value;
96
+ },
97
+ },
73
98
  });
74
99
  </script>
75
- <style scoped lang="scss">
76
- @import './MultiImportButton.scss';
77
- </style>
@@ -15,5 +15,6 @@ export const Primary = () => ({
15
15
  <farm-chip-invite :status="15" />
16
16
  <farm-chip-invite :status="16" />
17
17
  <farm-chip-invite :status="17" />
18
+ <farm-chip-invite :status="18" />
18
19
  </div>`,
19
20
  });
@@ -1,50 +1,18 @@
1
1
  <template>
2
- <v-chip
3
- small
4
- :class="
5
- `status-chip ${
6
- isFull ? 'status-chip--fullwidth' : ''
7
- } status-chip-${color} status-chip--onboarding`
8
- "
2
+ <farm-chip
3
+ :color="obj.color"
4
+ :outlined="obj.outlined"
5
+ :variation="obj.variation"
6
+ :dense="!isFull"
9
7
  >
10
- <span :class="`${textColor}--text`">
11
- {{ label }}
12
- </span>
13
- </v-chip>
8
+ {{ obj.label }}
9
+ </farm-chip>
14
10
  </template>
15
- <script>
11
+ <script lang="ts">
16
12
  import Vue from 'vue';
17
- const StatusLabel = {
18
- 10: 'CONVIDAR',
19
- 11: 'CONVIDADO',
20
- 12: 'INCOMPLETO',
21
- 13: 'CONCLUÍDO',
22
- 14: 'FALHA/ERRO',
23
- 15: 'EM ANÁLISE',
24
- 16: 'EM ANDAMENTO',
25
- 17: 'EM ESPERA',
26
- 18: 'DECLINADO'
27
- };
28
-
29
- const StatusColor = {
30
- 10: 'secondary',
31
- 11: 'yellow',
32
- 12: 'yellow',
33
- 13: 'success',
34
- 14: 'error',
35
- 15: 'accent',
36
- 16: 'primary',
37
- 17: 'on-wait',
38
- 18: 'error',
39
- };
40
-
41
- import VChip from 'vuetify/lib/components/VChip/';
42
-
13
+ import keys from './keys';
43
14
  export default Vue.extend({
44
15
  name: 'farm-chip-invite',
45
- components: {
46
- VChip,
47
- },
48
16
  props: {
49
17
  /**
50
18
  * Invite status
@@ -58,24 +26,13 @@ export default Vue.extend({
58
26
  */
59
27
  isFull: {
60
28
  type: Boolean,
61
- default: true,
29
+ default: false,
62
30
  },
63
31
  },
64
32
  computed: {
65
- textColor() {
66
- return this.status === 10 || this.status === 16 || this.status === 17
67
- ? ''
68
- : StatusColor[this.status];
69
- },
70
- color() {
71
- return !this.status ? '' : StatusColor[this.status];
72
- },
73
- label() {
74
- return StatusLabel[this.status];
33
+ obj() {
34
+ return keys[this.status];
75
35
  },
76
36
  },
77
37
  });
78
38
  </script>
79
- <style lang="scss" scoped>
80
- @import './ChipInviteStatus.scss';
81
- </style>
@@ -21,16 +21,4 @@ describe('ChipInviteStatus component', () => {
21
21
  expect(wrapper.element).toMatchSnapshot();
22
22
  });
23
23
  });
24
-
25
- describe('Computed properties', () => {
26
- it('Should have text color', () => {
27
- expect(component.textColor).toBeDefined();
28
- });
29
- it('Should have color', () => {
30
- expect(component.color).toBeDefined();
31
- });
32
- it('Should have label', () => {
33
- expect(component.label).toBeDefined();
34
- });
35
- });
36
24
  });
@@ -0,0 +1,11 @@
1
+ export default {
2
+ 10: { label: 'Convidar', color: 'primary' },
3
+ 11: { label: 'Convidado', color: 'warning', outlined: true },
4
+ 12: { label: 'Incompleto', color: 'warning', outlined: true },
5
+ 13: { label: 'Concluído', color: 'primary', outlined: true },
6
+ 14: { label: 'Falha/Erro', color: 'error', outlined: true },
7
+ 15: { label: 'Em Análise', color: 'info', outlined: true },
8
+ 16: { label: 'Em Andamento', color: 'secondary', variation: 'darken' },
9
+ 17: { label: 'Em Espera', color: 'secondary' },
10
+ 18: { label: 'Declinado', color: 'error', outlined: true },
11
+ };
@@ -18,6 +18,7 @@
18
18
  </template>
19
19
  <script lang="ts">
20
20
  import Vue, { ref, watch, reactive, onBeforeUnmount, toRefs } from 'vue';
21
+ import { calculateMainZindex } from '../../helpers';
21
22
 
22
23
  export default Vue.extend({
23
24
  name: 'farm-contextmenu',
@@ -42,7 +43,7 @@ export default Vue.extend({
42
43
  const parent = ref(null);
43
44
  const popup = ref(null);
44
45
  const activator = ref(null);
45
- const styles = reactive({ minWidth: 0, top: 0 } as any);
46
+ const styles = reactive({ minWidth: 0, top: 0, zIndex: 1 } as any);
46
47
  const { bottom } = toRefs(props);
47
48
 
48
49
  const inputValue = ref(props.value);
@@ -111,8 +112,9 @@ export default Vue.extend({
111
112
  offsetTop -= bottomEdge - window.scrollY - clientHeight + 12;
112
113
  }
113
114
 
114
- styles.top = offsetTop + 'px';
115
- styles.left = offsetLeft + 'px';
115
+ styles.top = `${offsetTop}px`;
116
+ styles.left = `${offsetLeft}px`;
117
+ styles.zIndex = calculateMainZindex();
116
118
  };
117
119
 
118
120
  onBeforeUnmount(() => {
File without changes
@@ -0,0 +1,35 @@
1
+ import { withDesign } from 'storybook-addon-designs';
2
+ import TextFieldV2 from './TextFieldV2.vue';
3
+
4
+ export default {
5
+ title: 'Form/TextFieldV2',
6
+ component: TextFieldV2,
7
+ decorators: [withDesign],
8
+ parameters: {
9
+ docs: {
10
+ description: {
11
+ component: `Text field v2<br />
12
+ selector: <em>farm-texfield-v2</em><br />
13
+ <span style="color: var(--farm-extra-1-base);">development</span>
14
+ `,
15
+ },
16
+ },
17
+ design: {
18
+ type: 'figma',
19
+ url: 'https://www.figma.com/file/1f84J4m1IBghWhozQvdyyt/%E2%9C%85---Design-System-%7C-v1?node-id=1503%3A227',
20
+ },
21
+ viewMode: 'docs',
22
+ },
23
+ };
24
+
25
+ export const Primary = () => ({
26
+ data() {
27
+ return {
28
+ v: 'some text',
29
+ };
30
+ },
31
+ template: `<div style="width: 480px">
32
+ <farm-textfield-v2 v-model="v" />
33
+ value: {{ v }}
34
+ </div>`,
35
+ });
@@ -0,0 +1,46 @@
1
+ <template>
2
+ <div class="farm-textfield">
3
+ <div class="farm-textfield--input">
4
+ <input v-bind="$attrs" v-model="innerValue" />
5
+ </div>
6
+ <span class="farm-textfield--text"> hint text</span>
7
+ </div>
8
+ </template>
9
+ <script lang="ts">
10
+ import Vue, { ref, watch } from 'vue';
11
+
12
+ export default Vue.extend({
13
+ name: 'farm-textfield-v2',
14
+ inheritAttrs: true,
15
+ props: {
16
+ /**
17
+ * v-model binding
18
+ */
19
+ value: {},
20
+ },
21
+ setup(props, { emit }) {
22
+ const innerValue = ref(props.value);
23
+
24
+ watch(
25
+ () => props.value,
26
+ () => {
27
+ innerValue.value = props.value;
28
+ }
29
+ );
30
+
31
+ watch(
32
+ () => innerValue.value,
33
+ () => {
34
+ emit('input', innerValue.value);
35
+ }
36
+ );
37
+
38
+ return {
39
+ innerValue,
40
+ };
41
+ },
42
+ });
43
+ </script>
44
+ <style lang="scss" scoped>
45
+ @import 'TextFieldV2';
46
+ </style>
@@ -0,0 +1,20 @@
1
+ import { shallowMount } from '@vue/test-utils';
2
+ import TextFieldV2 from '../TextFieldV2';
3
+
4
+ describe('TextFieldV2 component', () => {
5
+ let wrapper;
6
+
7
+ beforeEach(() => {
8
+ wrapper = shallowMount(TextFieldV2);
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 TextFieldV2 from './TextFieldV2.vue';
2
+
3
+ export { TextFieldV2 };
4
+ export default TextFieldV2;
@@ -1,9 +1,11 @@
1
1
  export default () => {
2
- const zIndex = Math.max(
3
- ...Array.from(document.querySelectorAll('body *'), el =>
4
- parseFloat(window.getComputedStyle(el).zIndex)
5
- ).filter(zIndex => !Number.isNaN(zIndex)),
6
- 0
2
+ const all_z = [];
3
+ document.querySelectorAll('*').forEach(function (elem) {
4
+ all_z.push(elem.style.zIndex);
5
+ });
6
+ const zIndex = Math.max.apply(
7
+ null,
8
+ all_z.map(x => Number(x))
7
9
  );
8
10
 
9
11
  return zIndex;
package/src/main.ts CHANGED
@@ -83,6 +83,7 @@ export * from './components/RadioGroup';
83
83
  export * from './components/Stepper';
84
84
  export * from './components/Switcher';
85
85
  export * from './components/TextField';
86
+ export * from './components/TextFieldV2';
86
87
  export * from './components/Tooltip';
87
88
  export * from './components/Typography';
88
89
 
@@ -1,31 +0,0 @@
1
- .status-chip--onboarding {
2
- font-weight: bold;
3
- .status-chip-yellow {
4
- color: black;
5
- }
6
- &.status-chip.status-chip-accent {
7
- color: var(--v-accent-base) !important;
8
- border: 2px solid var(--v-accent-base) !important;
9
- background-color: white !important;
10
- }
11
- &.status-chip.status-chip-yellow {
12
- color: black !important;
13
- border: 2px solid var(--v-yellow-lighten1) !important;
14
- background-color: white !important;
15
- }
16
- &.status-chip.status-chip-error {
17
- color: var(--v-error-base) !important;
18
- border: 2px solid var(--v-error-base) !important;
19
- background-color: white !important;
20
- }
21
- &.status-chip.status-chip-success {
22
- color: var(--v-secondary-base) !important;
23
- border: 2px solid var(--v-success-base) !important;
24
- background-color: white !important;
25
- }
26
- &.status-chip.status-chip-on-wait {
27
- color: white !important;
28
- border: 2px solid #467d7e !important;
29
- background-color: #467d7e !important;
30
- }
31
- }