@farm-investimentos/front-mfe-components 12.0.0 → 12.0.2

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": "12.0.0",
3
+ "version": "12.0.2",
4
4
  "author": "farm investimentos",
5
5
  "private": false,
6
6
  "main": "./dist/front-mfe-components.common.js",
@@ -42,15 +42,15 @@ export const Value = () => ({
42
42
  },
43
43
  template: `<div>
44
44
  <div class="d-flex">
45
- <farm-checkbox v-model="option1" value="1" class="mr-2" />
45
+ <farm-checkbox v-model="option1" value="option1" class="mr-2" />
46
46
  option1 : {{option1}}
47
47
  </div>
48
48
  <div class="d-flex align-center">
49
- <farm-checkbox v-model="option2" value="2" class="mr-2 my-2" />
49
+ <farm-checkbox v-model="option2" value="option2" class="mr-2 my-2" />
50
50
  option2 : {{option2}}
51
51
  </div>
52
52
  <div class="d-flex">
53
- <farm-checkbox v-model="option3" value="3" class="mr-2" />
53
+ <farm-checkbox v-model="option3" value="option3" class="mr-2" />
54
54
  option3 : {{option3}}
55
55
  </div>
56
56
  </div>`,
@@ -145,3 +145,29 @@ export const Indeterminate = () => ({
145
145
  <farm-checkbox :indeterminate="true" v-model="isChecked" :value="true" />
146
146
  </div>`,
147
147
  });
148
+
149
+ export const ResetByValue = () => ({
150
+ data() {
151
+ return {
152
+ isChecked: true,
153
+ };
154
+ },
155
+ template: `<div>
156
+ <farm-checkbox v-model="isChecked" :value="true" />
157
+ isChecked (value): {{ isChecked }}
158
+ <farm-btn @click="isChecked = null;">reset</farm-btn>
159
+ </div>`,
160
+ });
161
+
162
+ export const ResetByMethod = () => ({
163
+ data() {
164
+ return {
165
+ isChecked: true,
166
+ };
167
+ },
168
+ template: `<div>
169
+ <farm-checkbox v-model="isChecked" :value="true" ref="checkbox" />
170
+ isChecked (value): {{ isChecked }}
171
+ <farm-btn @click="$refs.checkbox.reset()">reset</farm-btn>
172
+ </div>`,
173
+ });
@@ -1,18 +1,14 @@
1
1
  <template>
2
2
  <div class="farm-checkbox__container" :color="$props.color">
3
- <span
4
- :class="{
5
- 'farm-checkbox': true,
6
- 'farm-checkbox--checked': isChecked,
7
- 'farm-checkbox--disabled': disabled,
8
- 'farm-checkbox--indeterminate': indeterminate,
9
- 'farm-checkbox--lighten': variation === 'lighten',
10
- 'farm-checkbox--darken': variation === 'darken',
11
- 'farm-checkbox--error': showError,
12
- }"
13
- :size="$props.size"
14
- @click="toggleValue"
15
- >
3
+ <span :class="{
4
+ 'farm-checkbox': true,
5
+ 'farm-checkbox--checked': isChecked,
6
+ 'farm-checkbox--disabled': disabled,
7
+ 'farm-checkbox--indeterminate': indeterminate,
8
+ 'farm-checkbox--lighten': variation === 'lighten',
9
+ 'farm-checkbox--darken': variation === 'darken',
10
+ 'farm-checkbox--error': showError,
11
+ }" :size="$props.size" @click="toggleValue">
16
12
  <farm-icon :size="$props.size" v-if="innerValue && !indeterminate">check</farm-icon>
17
13
  <farm-icon :size="$props.size" v-if="indeterminate">minus</farm-icon>
18
14
  </span>
@@ -123,14 +119,16 @@ export default Vue.extend({
123
119
 
124
120
  const showError = computed(() => hasError.value && isTouched.value);
125
121
 
122
+
126
123
  watch(
127
- () => props.value,
128
- () => {
124
+ () => props.modelValue,
125
+ (newValue) => {
129
126
  isTouched.value = true;
130
- innerValue.value = props.value;
127
+ innerValue.value = newValue;
131
128
  validate(innerValue.value);
132
129
  }
133
130
  );
131
+
134
132
 
135
133
  watch(
136
134
  () => props.rules,
@@ -4,14 +4,10 @@
4
4
  <slot name="activator"></slot>
5
5
  </span>
6
6
 
7
- <div
8
- ref="popup"
9
- :class="{
10
- 'farm-contextmenu__popup': true,
11
- 'farm-contextmenu__popup--visible': inputValue,
12
- }"
13
- :style="styles"
14
- >
7
+ <div ref="popup" :class="{
8
+ 'farm-contextmenu__popup': true,
9
+ 'farm-contextmenu__popup--visible': inputValue,
10
+ }" :style="styles">
15
11
  <slot></slot>
16
12
  </div>
17
13
  </div>
@@ -18,6 +18,10 @@
18
18
  &--neutral .farm-icon.farm-icon {
19
19
  color: var(--farm-neutral-darken);
20
20
  }
21
+ &--secondary .farm-icon.farm-icon,
22
+ &--gray .farm-icon.farm-icon {
23
+ color: white;
24
+ }
21
25
  }
22
26
 
23
27
  .farm-icon-box--inverted.farm-icon-box {
@@ -1,12 +1,9 @@
1
1
  <template>
2
- <div
3
- :class="{
4
- 'farm-icon-box': true,
5
- [cssColorClass]: true,
6
- 'farm-icon-box--inverted': inverted,
7
- }"
8
- :size="size"
9
- >
2
+ <div :class="{
3
+ 'farm-icon-box': true,
4
+ [cssColorClass]: true,
5
+ 'farm-icon-box--inverted': inverted,
6
+ }" :size="size">
10
7
  <farm-icon :color="inverted ? 'white' : color" :size="size">{{ iconParsed }}</farm-icon>
11
8
  </div>
12
9
  </template>
@@ -57,10 +54,7 @@ export default Vue.extend({
57
54
  },
58
55
  computed: {
59
56
  iconParsed() {
60
- if (this.icon.indexOf('mdi-') === 0) {
61
- return this.icon.split('mdi-')[1];
62
- }
63
- return this.icon;
57
+ return this.icon.indexOf('mdi-') === 0 ? this.icon.split('mdi-')[1] : this.icon;
64
58
  },
65
59
  cssColorClass() {
66
60
  return `farm-icon-box--${this.color}`;
@@ -24,7 +24,10 @@ export const MaxFileSize = () => ({
24
24
  });
25
25
 
26
26
  export const MaxFilesNumber = () => ({
27
- template: '<farm-multiple-filepicker :maxFileSize="5" :maxFilesNumber="1" />',
27
+ template: `<div>
28
+ <farm-multiple-filepicker :maxFileSize="5" :maxFilesNumber="2" />
29
+ max files allowed: 2
30
+ </div>`,
28
31
  });
29
32
 
30
33
  export const Download = () => ({
@@ -79,16 +79,15 @@
79
79
  </div>
80
80
  </li>
81
81
  </ul>
82
-
83
82
  <farm-btn
84
- v-if="hasFiles"
83
+ v-if="canAddMoreFiles && hasFiles"
85
84
  outlined
86
- title="Escolher Outro"
85
+ title="Escolher Arquivo"
87
86
  class="farm-btn--responsive"
88
87
  :disabled="disabledButton"
89
88
  @click="addMoreFiles"
90
89
  >
91
- Escolher Outro
90
+ Escolher Arquivo
92
91
  </farm-btn>
93
92
  </section>
94
93
  </template>
@@ -145,6 +144,9 @@ export default Vue.extend({
145
144
  hasFiles(): boolean {
146
145
  return this.files.length > 0 || this.downloadFiles.length > 0;
147
146
  },
147
+ canAddMoreFiles(): boolean {
148
+ return this.filesLength < this.maxFilesNumber;
149
+ },
148
150
  filesLength(): number {
149
151
  return this.files.length + this.downloadFiles.length;
150
152
  },
@@ -143,6 +143,18 @@ describe('MultipleFilePicker component', () => {
143
143
  expect(component.disabledButton).toBeTruthy();
144
144
  });
145
145
  });
146
+
147
+ describe('canAddMoreFiles', () => {
148
+ it('should return files and downloadFiles length', async () => {
149
+ await wrapper.setProps({
150
+ maxFilesNumber: 2,
151
+ downloadFiles: [new File([], 'test')],
152
+ });
153
+ component.files = [new File([], 'test2')];
154
+
155
+ expect(component.canAddMoreFiles).toBeFalsy();
156
+ });
157
+ });
146
158
  });
147
159
 
148
160
  describe('Watch', () => {
@@ -1,63 +1,69 @@
1
1
  @import '../../configurations/variables';
2
+ @import '../../configurations/theme-colors';
2
3
 
3
- input[type="radio"] {
4
- -webkit-appearance: none;
5
- appearance: none;
6
- background-color: #ffffff;
7
- margin: 0;
8
- font: inherit;
9
- color: rgba(0, 0, 0, .6);
10
- border: 1.5px solid rgba(0, 0, 0, .6);
11
- border-radius: 50%;
12
- display: grid;
13
- place-content: center;
14
- cursor: pointer;
15
-
16
- &::before {
17
- content: "";
18
- border-radius: 50%;
19
- transform: scale(0);
20
- transition: 120ms transform ease-in-out;
21
- background-color: CanvasText;
22
- }
23
-
24
- &.farm-radio--checked::before {
25
- transform: scale(1);
26
- box-shadow: inset 16px 16px var(--farm-primary-base);
27
- }
28
-
29
- &.farm-radio--checked {
30
- border-color: var(--farm-primary-base);
31
- }
32
-
33
- &:focus {
34
- outline: none;
35
- outline-offset: none;
36
- }
37
-
38
- &:hover {
39
- box-shadow: 0px 0px 0px 8px rgba(0, 0, 0, 0.1);
40
- background-color: rgba(0, 0, 0, 0.1);
41
- border-radius: 50%;
42
- opacity: 1;
43
- }
44
-
45
- &:active {
46
- animation: pulse 0.2s 1 ease-out;
47
- }
48
- }
4
+ input[type='radio'] {
5
+ -webkit-appearance: none;
6
+ appearance: none;
7
+ background-color: #ffffff;
8
+ margin: 0;
9
+ font: inherit;
10
+ color: rgba(0, 0, 0, 0.6);
11
+ border: 1.5px solid rgba(0, 0, 0, 0.6);
12
+ border-radius: 50%;
13
+ display: grid;
14
+ place-content: center;
15
+ cursor: pointer;
16
+
17
+ &::before {
18
+ content: '';
19
+ border-radius: 50%;
20
+ transform: scale(0);
21
+ transition: 120ms transform ease-in-out;
22
+ background-color: CanvasText;
23
+ }
24
+
25
+ &.farm-radio--checked::before {
26
+ transform: scale(1);
27
+ }
28
+
29
+ &:focus {
30
+ outline: none;
31
+ outline-offset: none;
32
+ }
33
+
34
+ &:hover {
35
+ box-shadow: 0px 0px 0px 8px rgba(0, 0, 0, 0.1);
36
+ background-color: rgba(0, 0, 0, 0.1);
37
+ border-radius: 50%;
38
+ opacity: 1;
39
+ }
49
40
 
41
+ &:active {
42
+ animation: pulse 0.2s 1 ease-out;
43
+ }
50
44
 
51
- @each $size,
52
- $value in $sizes {
53
- #{'input[type="radio"][size=' + $size +']'} {
54
- width: $value;
55
- height: $value;
45
+ @each $color in $theme-colors-list {
46
+ &#{'[color=' + $color + ']'} {
47
+ &.farm-radio--checked::before {
48
+ box-shadow: inset 16px 16px themeColor($color, 'base');
49
+ }
56
50
 
57
- &::before {
58
- content: "";
59
- width: $value / 2;
60
- height: $value / 2;
61
- }
62
- }
63
- }
51
+ &.farm-radio--checked {
52
+ border-color: themeColor($color, 'base');
53
+ }
54
+ }
55
+ }
56
+ }
57
+
58
+ @each $size, $value in $sizes {
59
+ #{'input[type="radio"][size=' + $size + ']'} {
60
+ width: $value;
61
+ height: $value;
62
+
63
+ &::before {
64
+ content: '';
65
+ width: $value / 2;
66
+ height: $value / 2;
67
+ }
68
+ }
69
+ }
@@ -1,6 +1,8 @@
1
1
  import { withDesign } from 'storybook-addon-designs';
2
2
  import Radio from './Radio.vue';
3
3
  import sizes from '../../configurations/sizes';
4
+ import baseThemeColors from '../../configurations/_theme-colors-base.scss';
5
+ const colors = Object.keys(baseThemeColors);
4
6
 
5
7
  export default {
6
8
  title: 'Form/Radio',
@@ -96,3 +98,17 @@ export const Sizes = () => ({
96
98
  </div>
97
99
  </div>`,
98
100
  });
101
+
102
+ export const Colors = () => ({
103
+ data() {
104
+ return {
105
+ colors,
106
+ v: 1,
107
+ };
108
+ },
109
+ template: `<div style="width: 480px">
110
+ <div v-for="color in colors" :key="color" class="d-flex flex-row align-center mb-3">
111
+ <farm-radio v-model="v" :value="1" :color="color" />&nbsp;&nbsp;{{ color }}
112
+ </div>
113
+ </div>`,
114
+ });
@@ -5,6 +5,7 @@
5
5
  'farm-radio--checked': isChecked,
6
6
  }"
7
7
  type="radio"
8
+ :color="color"
8
9
  :size="$props.size"
9
10
  :checked="isChecked"
10
11
  :value="value"
@@ -35,6 +36,24 @@ export default Vue.extend({
35
36
  type: String as PropType<'xs' | 'sm' | 'md' | 'lg' | 'xl'>,
36
37
  default: 'md',
37
38
  },
39
+ /**
40
+ * Color
41
+ */
42
+ color: {
43
+ type: String as PropType<
44
+ | 'primary'
45
+ | 'secondary'
46
+ | 'neutral'
47
+ | 'info'
48
+ | 'success'
49
+ | 'error'
50
+ | 'warning'
51
+ | 'success'
52
+ | 'extra-1'
53
+ | 'extra-2'
54
+ >,
55
+ default: 'primary',
56
+ },
38
57
  },
39
58
  computed: {
40
59
  isChecked() {
@@ -211,6 +211,7 @@ export default Vue.extend({
211
211
  const selectItem = item => {
212
212
  selectedText.value = item[itemText.value];
213
213
  innerValue.value = item[itemValue.value];
214
+ isVisible.value = false;
214
215
  };
215
216
 
216
217
  const clickInput = () => {