@farm-investimentos/front-mfe-components 11.11.3 → 11.12.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.11.3",
3
+ "version": "11.12.0",
4
4
  "author": "farm investimentos",
5
5
  "private": false,
6
6
  "main": "./dist/front-mfe-components.common.js",
@@ -78,6 +78,7 @@ export default Vue.extend({
78
78
  () => inputValue.value,
79
79
  newValue => {
80
80
  if (newValue) {
81
+ styles.display = 'block';
81
82
  if (!hasBeenBoostrapped) {
82
83
  document.querySelector('body').appendChild(popup.value);
83
84
  hasBeenBoostrapped = true;
@@ -86,6 +87,7 @@ export default Vue.extend({
86
87
  window.addEventListener('resize', resizeWindowHandler);
87
88
  calculatePosition();
88
89
  } else {
90
+ styles.display = 'none';
89
91
  styles.top = 0;
90
92
  styles.left = 0;
91
93
  styles.zIndex = 0;
@@ -107,8 +109,6 @@ export default Vue.extend({
107
109
  window.scrollY +
108
110
  (!bottom.value ? 0 : activatorBoundingClientRect.height);
109
111
 
110
- //
111
-
112
112
  let offsetLeft = activatorBoundingClientRect.left;
113
113
 
114
114
  styles.minWidth =
@@ -6,7 +6,11 @@ describe('DataTablePaginator component', () => {
6
6
  let component;
7
7
 
8
8
  beforeEach(() => {
9
- wrapper = shallowMount(DataTablePaginator);
9
+ wrapper = shallowMount(DataTablePaginator, {
10
+ propsData: {
11
+ title: '',
12
+ },
13
+ });
10
14
  component = wrapper.vm;
11
15
  });
12
16
 
@@ -1,29 +1,16 @@
1
- section {
2
- display: flex;
3
- flex-direction: row;
4
-
5
- .farm-btn {
6
- margin-left: 16px;
7
- }
8
-
9
- fieldset {
10
- border: 0;
11
- }
12
-
13
- .farm-tooltip {
14
- margin-left: 4px;
15
- }
1
+ .farm-tooltip {
2
+ margin-left: 4px;
3
+ }
16
4
 
5
+ .farm-btn {
6
+ margin-left: 12px;
17
7
  }
18
8
 
19
9
  @media screen and (max-width: 600px) {
20
- section {
21
- flex-direction: column;
22
- margin-bottom: 1rem;
23
-
24
- .farm-btn {
25
- margin-left: 0;
26
- margin-top: 0 !important;
27
- }
10
+ .farm-btn {
11
+ width: calc(100% - 24px);
12
+ margin-left: 12px;
13
+ margin-top: 0 !important;
28
14
  }
15
+
29
16
  }
@@ -32,29 +32,46 @@ export const WithSlot = () => ({
32
32
  template: '<farm-form-mainfilter>With Slot</farm-form-mainfilter>',
33
33
  });
34
34
 
35
- export const MainFilters = () => ({
35
+ export const Tooltip = () => ({
36
36
  data() {
37
37
  return {
38
- showFilters: false,
39
- items: [1, 2, 3, 4, 5],
38
+ text: 'Some long tooltip text to be placed here!',
40
39
  };
41
40
  },
42
- template: `<div style="max-width: 480px">
43
- <farm-form-mainfilter @onClick="showFilters = !showFilters" :showFilters="showFilters" />
44
- <section v-if="showFilters">
45
- <v-select :items="items" />
46
- </section>
41
+ template: `
42
+ <div style="max-width: 480px; padding-top: 32px; margin-left: 32px;">
43
+ <farm-form-mainfilter label="Label" :tooltip="text" />
47
44
  </div>`,
48
45
  });
49
46
 
50
- export const Tooltip = () => ({
47
+ export const Application = () => ({
51
48
  data() {
52
49
  return {
53
- text: 'Some long tooltip text to be placed here!',
50
+ showFilters: false,
54
51
  };
55
52
  },
56
- template: `
57
- <div style="max-width: 480px; padding-top: 32px; margin-left: 32px;">
58
- <farm-form-mainfilter label="Label" :tooltip="text" />
53
+ template: `<div>
54
+ <farm-row>
55
+ <farm-col md="6">
56
+ <farm-form-mainfilter @onClick="showFilters = !showFilters" :showFilters="showFilters" />
57
+ </farm-col>
58
+ </farm-row>
59
+ <farm-row v-if="showFilters">
60
+ <farm-col cols="12">
61
+ Aqui são os filtros extras
62
+ </farm-col>
63
+ <farm-col cols="12" md="3">
64
+ <farm-textfield />
65
+ </farm-col>
66
+ <farm-col cols="12" md="3">
67
+ <farm-textfield />
68
+ </farm-col>
69
+ <farm-col cols="12" md="3">
70
+ <farm-textfield />
71
+ </farm-col>
72
+ <farm-col cols="12" md="3">
73
+ <farm-textfield />
74
+ </farm-col>
75
+ </farm-row>
59
76
  </div>`,
60
- });
77
+ });
@@ -1,6 +1,6 @@
1
1
  <template>
2
- <section :class="{ 'justify-end': justifyEnd === true }">
3
- <fieldset v-if="hasInitialInput">
2
+ <farm-row :class="{ 'justify-end': justifyEnd === true }">
3
+ <farm-col v-if="hasInitialInput" md="6">
4
4
  <farm-label :for="elementId">
5
5
  {{ !hasSlotData ? label : '' }}
6
6
  <slot v-if="hasSlotData"></slot>
@@ -14,16 +14,16 @@
14
14
  </farm-tooltip>
15
15
  </farm-label>
16
16
  <farm-textfield-v2 v-model="inputValue" :id="elementId" @keyup="onKeyUp" />
17
- </fieldset>
17
+ </farm-col>
18
18
  <farm-btn
19
19
  v-if="hasExtraFilters"
20
- class="farm-btn--responsive mt-14 mt-sm-8"
20
+ class="mt-14 mt-sm-8"
21
21
  @click="onFilterClick"
22
22
  >
23
23
  <farm-icon class="mr-2">{{ extraFiltersBtnIcon }}</farm-icon>
24
24
  {{ extraFiltersBtnLabel }}
25
25
  </farm-btn>
26
- </section>
26
+ </farm-row>
27
27
  </template>
28
28
 
29
29
  <script lang="ts">
@@ -27,7 +27,7 @@
27
27
  </template>
28
28
 
29
29
  <script lang="ts">
30
- import Vue, { PropType, reactive, ref, toRefs, watch } from 'vue';
30
+ import Vue, { onBeforeUnmount, onMounted, PropType, reactive, ref, toRefs, watch } from 'vue';
31
31
  import { calculateMainZindex } from '../../helpers';
32
32
 
33
33
  export default Vue.extend({
@@ -61,6 +61,7 @@ export default Vue.extend({
61
61
  },
62
62
  },
63
63
  setup(props, { emit }) {
64
+ let hasBeenBoostrapped = false;
64
65
  const { offsetTop, offsetBottom, persistent, size } = toRefs(props);
65
66
  const inputValue = ref(props.value);
66
67
  const styleObject = reactive({ zIndex: 1 });
@@ -84,18 +85,33 @@ export default Vue.extend({
84
85
  newValue => {
85
86
  inputValue.value = newValue;
86
87
  if (newValue) {
87
- (styleObject.zIndex = calculateMainZindex()),
88
- window.addEventListener('keyup', escHandler);
88
+ bootstrap();
89
89
  }
90
90
  }
91
91
  );
92
92
 
93
+ onMounted(() => {
94
+ bootstrap();
95
+ });
96
+
93
97
  const escHandler = event => {
94
98
  if (event.key === 'Escape') {
95
99
  close();
96
100
  }
97
101
  };
98
102
 
103
+ const bootstrap = () => {
104
+ styleObject.zIndex = calculateMainZindex();
105
+ window.addEventListener('keyup', escHandler);
106
+ hasBeenBoostrapped = true;
107
+ };
108
+
109
+ onBeforeUnmount(() => {
110
+ if (hasBeenBoostrapped) {
111
+ window.removeEventListener('resize', escHandler);
112
+ }
113
+ });
114
+
99
115
  return {
100
116
  inputValue,
101
117
  styles,
@@ -1,3 +1,5 @@
1
+ @import '../../configurations/variables';
2
+
1
3
  input[type="radio"] {
2
4
  -webkit-appearance: none;
3
5
  appearance: none;
@@ -5,8 +7,6 @@ input[type="radio"] {
5
7
  margin: 0;
6
8
  font: inherit;
7
9
  color: rgba(0, 0, 0, .6);
8
- width: 24px;
9
- height: 24px;
10
10
  border: 1.5px solid rgba(0, 0, 0, .6);
11
11
  border-radius: 50%;
12
12
  display: grid;
@@ -15,8 +15,6 @@ input[type="radio"] {
15
15
 
16
16
  &::before {
17
17
  content: "";
18
- width: 10px;
19
- height: 10px;
20
18
  border-radius: 50%;
21
19
  transform: scale(0);
22
20
  transition: 120ms transform ease-in-out;
@@ -47,4 +45,19 @@ input[type="radio"] {
47
45
  &:active {
48
46
  animation: pulse 0.2s 1 ease-out;
49
47
  }
48
+ }
49
+
50
+
51
+ @each $size,
52
+ $value in $sizes {
53
+ #{'input[type="radio"][size=' + $size +']'} {
54
+ width: $value;
55
+ height: $value;
56
+
57
+ &::before {
58
+ content: "";
59
+ width: $value / 2;
60
+ height: $value / 2;
61
+ }
62
+ }
50
63
  }
@@ -1,5 +1,6 @@
1
1
  import { withDesign } from 'storybook-addon-designs';
2
2
  import Radio from './Radio.vue';
3
+ import sizes from '../../configurations/sizes';
3
4
 
4
5
  export default {
5
6
  title: 'Form/Radio',
@@ -10,7 +11,7 @@ export default {
10
11
  description: {
11
12
  component: `Radio<br />
12
13
  selector: <em>farm-radio</em><br />
13
- <span style="color: var(--farm-extra-1-base);">development</span>
14
+ <span style="color: var(--farm-primary-base);">ready for use</span>
14
15
  `,
15
16
  },
16
17
  design: {
@@ -81,3 +82,17 @@ export const Checked = () => ({
81
82
  v-model: {{ v }}
82
83
  </div>`,
83
84
  });
85
+
86
+ export const Sizes = () => ({
87
+ data() {
88
+ return {
89
+ sizes,
90
+ v: 1,
91
+ };
92
+ },
93
+ template: `<div style="width: 480px">
94
+ <div v-for="size in sizes" :key="size" class="d-flex flex-row align-center mb-3">
95
+ <farm-radio v-model="v" :value="size" :size="size" />&nbsp;&nbsp;{{ size }}
96
+ </div>
97
+ </div>`,
98
+ });
@@ -5,13 +5,14 @@
5
5
  'farm-radio--checked': isChecked,
6
6
  }"
7
7
  type="radio"
8
+ :size="$props.size"
8
9
  :checked="isChecked"
9
10
  :value="value"
10
11
  @click="onClick"
11
12
  />
12
13
  </template>
13
14
  <script lang="ts">
14
- import Vue from 'vue';
15
+ import Vue, { PropType } from 'vue';
15
16
 
16
17
  export default Vue.extend({
17
18
  name: 'farm-radio',
@@ -27,6 +28,13 @@ export default Vue.extend({
27
28
  * Value to be set to v-model
28
29
  */
29
30
  value: { type: [String, Number, Boolean], required: true },
31
+ /**
32
+ * Size
33
+ */
34
+ size: {
35
+ type: String as PropType<'xs' | 'sm' | 'md' | 'lg' | 'xl'>,
36
+ default: 'md',
37
+ },
30
38
  },
31
39
  computed: {
32
40
  isChecked() {
@@ -4,14 +4,24 @@ import Radio from '../Radio.vue';
4
4
 
5
5
  describe('Radio component', () => {
6
6
  let wrapper;
7
+ let component;
7
8
 
8
9
  beforeEach(() => {
9
10
  wrapper = shallowMount(Radio, {
10
- propsData: {},
11
+ propsData: {
12
+ value: 1,
13
+ },
11
14
  });
15
+ component = wrapper.vm;
12
16
  });
13
17
 
14
18
  test('Radio created', () => {
15
19
  expect(wrapper).toBeDefined();
16
20
  });
21
+
22
+ describe('computed properties', () => {
23
+ it('get isRound false', () => {
24
+ expect(component.isChecked).toBeFalsy();
25
+ });
26
+ });
17
27
  });
@@ -1,11 +1,10 @@
1
1
  import RadioGroup from './RadioGroup';
2
- import baseThemeColors from '../../configurations/_theme-colors-base.scss';
3
-
4
- const colors = Object.keys(baseThemeColors);
2
+ import { withDesign } from 'storybook-addon-designs';
5
3
 
6
4
  export default {
7
5
  title: 'Form/RadioGroup',
8
6
  component: RadioGroup,
7
+ decorators: [withDesign],
9
8
  parameters: {
10
9
  docs: {
11
10
  description: {
@@ -5,7 +5,11 @@ describe('RadioGroup component', () => {
5
5
  let wrapper;
6
6
 
7
7
  beforeEach(() => {
8
- wrapper = shallowMount(RadioGroup, {});
8
+ wrapper = shallowMount(RadioGroup, {
9
+ propsData: {
10
+ value: 1,
11
+ },
12
+ });
9
13
  });
10
14
 
11
15
  test('Created hook', () => {
@@ -1,5 +1,7 @@
1
1
  import { withDesign } from 'storybook-addon-designs';
2
2
  import ValueCaption from '.';
3
+ import baseThemeColors from '../../configurations/_theme-colors-base.scss';
4
+ const colors = Object.keys(baseThemeColors);
3
5
 
4
6
  export default {
5
7
  title: 'Display/ValueCaption',
@@ -31,3 +33,26 @@ export const Primary = () => ({
31
33
  </farm-valuecaption>
32
34
  `,
33
35
  });
36
+
37
+ export const Colors = () => ({
38
+ data() {
39
+ return {
40
+ colors: [...colors],
41
+ };
42
+ },
43
+ template: `<div class="d-flex flex-column">
44
+ <farm-valuecaption
45
+ icon="account-box-outline"
46
+ v-for="color of colors":key="color"
47
+ :iconBoxColor="color"
48
+ class="mb-3"
49
+ >
50
+ <template v-slot:title>
51
+ color: {{ color }}
52
+ </template>
53
+ <template v-slot:subtitle>
54
+ R$ 1.000,00
55
+ </template>
56
+ </farm-valuecaption>
57
+ </div>`,
58
+ });