@farm-investimentos/front-mfe-components-vue3 0.6.0 → 0.6.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farm-investimentos/front-mfe-components-vue3",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,9 +20,11 @@
20
20
  "build:components": "vue-cli-service build --target lib --name front-mfe-components src/main.ts",
21
21
  "lint": "vue-cli-service lint --fix",
22
22
  "serve": "vue-cli-service serve",
23
+ "serve:storybook": "http-server ./storybook-static/",
23
24
  "storybook": "storybook dev -p 6006",
24
25
  "test:coverage": "jest --coverage",
25
- "test:unit": "jest"
26
+ "test:unit": "jest",
27
+ "prepare": "husky"
26
28
  },
27
29
  "browserslist": [
28
30
  "> 1%",
@@ -74,6 +76,7 @@
74
76
  "eslint": "^6.7.2",
75
77
  "eslint-plugin-import": "^2.29.0",
76
78
  "eslint-plugin-vue": "^7.1.0",
79
+ "husky": "^9.0.11",
77
80
  "jest": "29.7.0",
78
81
  "jest-environment-jsdom": "^29.0.0",
79
82
  "npm-run-all2": "^6.0.6",
@@ -1,7 +1,6 @@
1
1
  <template>
2
2
  <span
3
- v-bind="$props"
4
-
3
+ v-bind="$props"
5
4
  :class="{
6
5
  'farm-chip': true,
7
6
  'farm-chip--dense': dense,
@@ -6,7 +6,9 @@ describe('Chip component', () => {
6
6
  let wrapper;
7
7
 
8
8
  beforeEach(() => {
9
- wrapper = shallowMount(Chip, {});
9
+ wrapper = shallowMount(Chip, {
10
+ modelValue: ''
11
+ });
10
12
  });
11
13
 
12
14
  test('Created hook', () => {
@@ -7,6 +7,16 @@
7
7
  align-items: center;
8
8
  justify-content: space-between;
9
9
  cursor: pointer;
10
+
11
+ &--custom {
12
+ position: relative;
13
+ cursor: pointer;
14
+ }
15
+
16
+ &--plain {
17
+ cursor: default;
18
+ pointer-events: none;
19
+ }
10
20
  }
11
21
 
12
22
  &__content-title {
@@ -19,6 +29,12 @@
19
29
  display: flex;
20
30
  align-items: center;
21
31
  justify-content: space-between;
32
+
33
+ &--custom {
34
+ position: absolute;
35
+ right: 0;
36
+ top: 3px;
37
+ }
22
38
  }
23
39
 
24
40
  &__icon {
@@ -141,12 +141,242 @@ export const Dense = () => ({
141
141
  '<farm-collapsible icon="plus" title="With Icon" textChip="chip" dense showChip>collapsible content</farm-collapsible>',
142
142
  });
143
143
 
144
- Primary.storyName = 'Basic';
145
- Title.storyName = 'Title';
146
- Icon.storyName = 'Icon';
147
- Export.storyName = 'Export';
148
- Opened.storyName = 'Opened';
149
- ColorIcons.storyName = 'Icon Colors';
150
- ColorsChips.storyName = 'Chip Colors';
151
- ColorsOutlinedChips.storyName = 'Outlined';
152
- Dense.storyName = 'Dense';
144
+ export const Disabled = () => ({
145
+ data() {
146
+ return {
147
+ clicked: false,
148
+ };
149
+ },
150
+ template: `<farm-box>
151
+ clicked: {{clicked}}
152
+ <farm-collapsible
153
+ icon="clipboard"
154
+ title="With Button"
155
+ :disabled-button="true"
156
+ :has-button="true"
157
+ @onClick="value => clicked = !clicked" >collapsible content</farm-collapsible>
158
+ </farm-box>`,
159
+ });
160
+
161
+ export const Custom = () => ({
162
+ template: `
163
+ <farm-collapsible title="" custom open>
164
+ <template #custom>
165
+ <farm-row justify="space-between" align="center">
166
+ <farm-col md="6">
167
+ <farm-caption>caption</farm-caption>
168
+ </farm-col>
169
+ <farm-col md="6" justify="end"
170
+ align="end">
171
+ <farm-btn
172
+
173
+ >
174
+ custom
175
+ </farm-btn>
176
+ </farm-col>
177
+ </farm-row>
178
+ </template>
179
+ collapsible content
180
+ </farm-collapsible>
181
+ `,
182
+ });
183
+
184
+ export const CustomHeaderContent = () => ({
185
+ template: `
186
+ <farm-collapsible title="" custom-header>
187
+ <template #header-content>
188
+ <farm-row>
189
+ <farm-col md="12">
190
+ <farm-bodytext color="success">initial text</farm-bodytext>
191
+ </farm-col>
192
+ </farm-row>
193
+
194
+ <farm-row class="pt-4">
195
+ <farm-col class="collapsible-stories-class-with-line">
196
+ <farm-caption variation="semiBold"
197
+ >text here</farm-caption
198
+ >
199
+ 123455
200
+ </farm-col>
201
+ <farm-col class="collapsible-stories-class-with-line">
202
+ <farm-caption variation="semiBold"
203
+ >label here</farm-caption
204
+ >
205
+
206
+ <farm-caption variation="medium" class="my-1">R$ 1000</farm-caption>
207
+ </farm-col>
208
+
209
+ <farm-col class="collapsible-stories-class-with-line">
210
+ <farm-caption variation="semiBold">LABEL HERE</farm-caption>
211
+
212
+ <farm-caption variation="medium" class="my-1">R$ 1000</farm-caption>
213
+ </farm-col>
214
+
215
+ <farm-col>
216
+ <farm-caption variation="semiBold"
217
+ >Label here (text here)</farm-caption
218
+ >
219
+ <farm-caption variation="medium" class="my-1">value here</farm-caption>
220
+ </farm-col>
221
+ </farm-row>
222
+ </template>
223
+
224
+ <farm-bodytext >collapsible content</farm-bodytext>
225
+ </farm-collapsible>
226
+ `,
227
+ });
228
+
229
+ export const CustomBodyContent = () => ({
230
+ template: `
231
+ <farm-collapsible title="simple title" custom-body>
232
+ <farm-row extraDecrease style="background-color:#f5f5f5;" class="px-4">
233
+ <farm-col class="collapsible-stories-class-with-line">
234
+ <farm-caption variation="semiBold"
235
+ >text here</farm-caption
236
+ >
237
+ 123455
238
+ </farm-col>
239
+ <farm-col class="collapsible-stories-class-with-line">
240
+ <farm-caption variation="semiBold"
241
+ >label here</farm-caption
242
+ >
243
+
244
+ <farm-caption variation="medium" class="my-1">R$ 1000</farm-caption>
245
+ </farm-col>
246
+
247
+ <farm-col class="collapsible-stories-class-with-line">
248
+ <farm-caption variation="semiBold">LABEL HERE</farm-caption>
249
+
250
+ <farm-caption variation="medium" class="my-1">R$ 1000</farm-caption>
251
+ </farm-col>
252
+
253
+ <farm-col>
254
+ <farm-caption variation="semiBold"
255
+ >Label here (text here)</farm-caption
256
+ >
257
+ <farm-caption variation="medium" class="my-1">value here</farm-caption>
258
+ </farm-col>
259
+ </farm-row>
260
+ </farm-collapsible>
261
+ `,
262
+ });
263
+
264
+ export const CustomHeaderAndBodyContent = () => ({
265
+ template: `
266
+ <farm-collapsible title="" custom-header custom-body>
267
+
268
+ <template #header-content>
269
+ <div class="mb-4">
270
+ <farm-row>
271
+ <farm-col md="12">
272
+ <farm-bodytext color="success">initial text</farm-bodytext>
273
+ </farm-col>
274
+ </farm-row>
275
+
276
+ <farm-row class="pt-4">
277
+ <farm-col class="collapsible-stories-class-with-line">
278
+ <farm-caption variation="semiBold"
279
+ >text here</farm-caption
280
+ >
281
+ 123455
282
+ </farm-col>
283
+ <farm-col class="collapsible-stories-class-with-line">
284
+ <farm-caption variation="semiBold"
285
+ >label here</farm-caption
286
+ >
287
+
288
+ <farm-caption variation="medium" class="my-1">R$ 1000</farm-caption>
289
+ </farm-col>
290
+
291
+ <farm-col class="collapsible-stories-class-with-line">
292
+ <farm-caption variation="semiBold">LABEL HERE</farm-caption>
293
+
294
+ <farm-caption variation="medium" class="my-1">R$ 1000</farm-caption>
295
+ </farm-col>
296
+
297
+ <farm-col>
298
+ <farm-caption variation="semiBold"
299
+ >Label here (text here)</farm-caption
300
+ >
301
+ <farm-caption variation="medium" class="my-1">value here</farm-caption>
302
+ </farm-col>
303
+ </farm-row>
304
+ </div>
305
+ </template>
306
+
307
+ <farm-row extraDecrease style="background-color:#f5f5f5;" class="mt-5 px-2">
308
+ <farm-col class="collapsible-stories-class-with-line">
309
+ <farm-caption variation="semiBold"
310
+ >text here</farm-caption
311
+ >
312
+ 123455
313
+ </farm-col>
314
+ <farm-col class="collapsible-stories-class-with-line">
315
+ <farm-caption variation="semiBold"
316
+ >label here</farm-caption
317
+ >
318
+
319
+ <farm-caption variation="medium" class="my-1">R$ 1000</farm-caption>
320
+ </farm-col>
321
+
322
+ <farm-col class="collapsible-stories-class-with-line">
323
+ <farm-caption variation="semiBold">LABEL HERE</farm-caption>
324
+
325
+ <farm-caption variation="medium" class="my-1">R$ 1000</farm-caption>
326
+ </farm-col>
327
+
328
+ <farm-col>
329
+ <farm-caption variation="semiBold"
330
+ >Label here (text here)</farm-caption
331
+ >
332
+ <farm-caption variation="medium" class="my-1">value here</farm-caption>
333
+ </farm-col>
334
+ </farm-row>
335
+ </farm-collapsible>
336
+ `,
337
+ });
338
+
339
+ export const Plain = () => ({
340
+ template: `
341
+ <farm-collapsible title="" custom-header plain>
342
+ <template #header-content>
343
+ <farm-row>
344
+ <farm-col md="12">
345
+ <farm-bodytext color="success">initial text</farm-bodytext>
346
+ </farm-col>
347
+ </farm-row>
348
+
349
+ <farm-row class="pt-4">
350
+ <farm-col class="collapsible-stories-class-with-line">
351
+ <farm-caption variation="semiBold"
352
+ >text here</farm-caption
353
+ >
354
+ 123455
355
+ </farm-col>
356
+ <farm-col class="collapsible-stories-class-with-line">
357
+ <farm-caption variation="semiBold"
358
+ >label here</farm-caption
359
+ >
360
+
361
+ <farm-caption variation="medium" class="my-1">R$ 1000</farm-caption>
362
+ </farm-col>
363
+
364
+ <farm-col class="collapsible-stories-class-with-line">
365
+ <farm-caption variation="semiBold">LABEL HERE</farm-caption>
366
+
367
+ <farm-caption variation="medium" class="my-1">R$ 1000</farm-caption>
368
+ </farm-col>
369
+
370
+ <farm-col>
371
+ <farm-caption variation="semiBold"
372
+ >Label here (text here)</farm-caption
373
+ >
374
+ <farm-caption variation="medium" class="my-1">value here</farm-caption>
375
+ </farm-col>
376
+ </farm-row>
377
+ </template>
378
+
379
+ <farm-bodytext >collapsible content</farm-bodytext>
380
+ </farm-collapsible>
381
+ `,
382
+ });
@@ -1,14 +1,21 @@
1
1
  <template>
2
2
  <farm-card class="collapsible">
3
- <farm-card-content gutter="md">
3
+ <farm-card-content
4
+ gutter="md"
5
+ :class="{ 'pb-0': customBody }"
6
+ >
4
7
  <div
8
+ v-if="!customHeader"
5
9
  class="collapsible__header"
6
10
  @click="onToggleCollapsible(status)"
7
11
  >
8
- <div class="collapsible__content-title">
12
+ <div
13
+ class="collapsible__content-title"
14
+ :class="{ 'full-width': custom, 'pb-4': customBody }"
15
+ >
9
16
  <div
10
17
  class="collapsible__icon collapsible__icon--main"
11
- v-if="icon !== ''"
18
+ v-if="icon !== '' && !custom"
12
19
  >
13
20
  <farm-icon
14
21
  size="md"
@@ -20,17 +27,23 @@
20
27
  <farm-heading
21
28
  type="6"
22
29
  color="black"
30
+ v-if="!custom"
23
31
  >
24
32
  {{ title }}
25
33
  </farm-heading>
26
34
  <farm-btn
27
35
  outlined
28
36
  class="ml-6"
29
- v-if="hasButton"
30
- @click.stop="$emit('onClick')"
37
+ v-if="hasButton && !custom"
38
+ :disabled="disabledButton"
39
+ @click.stop="onClick()"
31
40
  >
32
41
  {{ labelButton }}
33
42
  </farm-btn>
43
+ <slot
44
+ name="custom"
45
+ v-if="custom"
46
+ ></slot>
34
47
  </div>
35
48
  <div class="collapsible__content-right">
36
49
  <div
@@ -56,7 +69,42 @@
56
69
  </div>
57
70
  </div>
58
71
  </div>
59
- <transition name="fade">
72
+
73
+ <div
74
+ v-if="customHeader"
75
+ class="collapsible__header--custom"
76
+ :class="plain ? 'collapsible__header--plain' : ''"
77
+ @click="onToggleCollapsible(status)"
78
+ >
79
+ <slot name="header-content"></slot>
80
+ <div
81
+ v-if="!plain"
82
+ class="collapsible__content-right--custom"
83
+ >
84
+ <div class="collapsible__icon collapsible__icon--arrow">
85
+ <farm-icon
86
+ size="md"
87
+ color="primary"
88
+ >
89
+ {{ arrowIcon }}
90
+ </farm-icon>
91
+ </div>
92
+ </div>
93
+ </div>
94
+
95
+ <transition
96
+ v-if="customBody"
97
+ name="fade"
98
+ >
99
+ <div v-show="status">
100
+ <slot></slot>
101
+ </div>
102
+ </transition>
103
+
104
+ <transition
105
+ v-else
106
+ name="fade"
107
+ >
60
108
  <div
61
109
  class="collapsible__body"
62
110
  v-show="status"
@@ -98,42 +146,56 @@ export default {
98
146
  default: false,
99
147
  },
100
148
  /**
101
- * show Chip
149
+ * Show Chip?
102
150
  */
103
151
  showChip: {
104
152
  type: Boolean,
105
153
  default: false,
106
154
  },
107
155
  /**
108
- * text of Chip
156
+ * Chip text?
109
157
  */
110
158
  textChip: {
111
159
  type: String,
112
160
  default: '',
113
161
  },
114
162
  /**
115
- * has butotn
163
+ * Has button?
116
164
  */
117
165
  hasButton: {
118
166
  type: Boolean,
119
167
  default: false,
120
168
  },
121
169
  /**
122
- * export button
170
+ * plain layout
171
+ */
172
+ plain: {
173
+ type: Boolean,
174
+ default: false,
175
+ },
176
+ /**
177
+ * Disabled button
178
+ */
179
+ disabledButton: {
180
+ type: Boolean,
181
+ default: false,
182
+ },
183
+ /**
184
+ * Export button?
123
185
  */
124
186
  onExport: {
125
187
  type: Boolean,
126
188
  default: false,
127
189
  },
128
190
  /**
129
- * label button
191
+ * Button label
130
192
  */
131
193
  labelButton: {
132
194
  type: String,
133
195
  default: 'Exportar',
134
196
  },
135
197
  /**
136
- * color of Chip
198
+ * Chip color
137
199
  */
138
200
  colorChip: {
139
201
  type: String as PropType<
@@ -168,26 +230,47 @@ export default {
168
230
  default: 'secondary-green',
169
231
  },
170
232
  /**
171
- * Is dense
233
+ * Is dense?
172
234
  */
173
235
  dense: {
174
236
  type: Boolean,
175
237
  default: false,
176
238
  },
177
239
  /**
178
- * Is outlined
240
+ * Is outlined?
179
241
  */
180
242
  outlined: {
181
243
  type: Boolean,
182
244
  default: false,
183
245
  },
184
246
  /**
185
- * Is variation
247
+ * Is variation?
186
248
  */
187
249
  variation: {
188
250
  type: String,
189
251
  default: 'base',
190
252
  },
253
+ /**
254
+ * Is custom?
255
+ */
256
+ custom: {
257
+ type: Boolean,
258
+ default: false,
259
+ },
260
+ /**
261
+ * Is custom body?
262
+ */
263
+ customBody: {
264
+ type: Boolean,
265
+ default: false,
266
+ },
267
+ /**
268
+ * Is custom header?
269
+ */
270
+ customHeader: {
271
+ type: Boolean,
272
+ default: false,
273
+ },
191
274
  },
192
275
 
193
276
  setup(props, { emit }) {
@@ -201,10 +284,15 @@ export default {
201
284
  emit('open', status.value);
202
285
  }
203
286
 
287
+ function onClick() {
288
+ emit('onClick');
289
+ }
290
+
204
291
  return {
205
292
  status,
206
293
  arrowIcon,
207
294
  onToggleCollapsible,
295
+ onClick,
208
296
  };
209
297
  },
210
298
  };
@@ -28,6 +28,14 @@ describe('Collapsible component', () => {
28
28
  expect(wrapper.emitted().open).toBeDefined();
29
29
  });
30
30
  });
31
+
32
+ describe('onClick', () => {
33
+ it('should emit event', () => {
34
+ component.onClick();
35
+ expect(wrapper.emitted().onClick).toBeDefined();
36
+ });
37
+ });
38
+
31
39
  });
32
40
 
33
41
  describe('Computed properties', () => {
@@ -112,7 +112,7 @@ export const AllowedDates = () => ({
112
112
  <farm-col cols="12">
113
113
  allowed dates: {{ allowedDates }}<br />
114
114
  selected date: {{ date }}
115
- <farm-col>
115
+ </farm-col>
116
116
  </farm-row>`,
117
117
  });
118
118
 
@@ -131,7 +131,7 @@ export const DisabledDates = () => ({
131
131
  <farm-col cols="12">
132
132
  disabled dates: {{ disabledDates }}<br />
133
133
  selected date: {{ date }}
134
- <farm-col>
134
+ </farm-col>
135
135
  </farm-row>`,
136
136
  });
137
137
 
@@ -78,7 +78,32 @@ export const Application = () => ({
78
78
 
79
79
  export const FullWidth = () => ({
80
80
  template: `
81
- <div style="max-width: 480px; padding-top: 32px; margin-left: 32px;">
81
+ <farm-box>
82
82
  <farm-form-mainfilter label="Label" fullWidth :hasExtraFilters="false"/>
83
- </div>`,
83
+ </farm-box>`,
84
+ });
85
+
86
+ export const InitialValue = () => ({
87
+ template: `
88
+ <farm-row>
89
+ <farm-col md="4">
90
+ <farm-form-mainfilter label="Label" initialValue="with initial value" />
91
+ </farm-col>
92
+ </farm-row>`,
93
+ });
94
+
95
+ export const onInputChange = () => ({
96
+ setup() {
97
+ function handler(value) {
98
+ alert(`onInputChange: ${value}`);
99
+ }
100
+
101
+ return { handler };
102
+ },
103
+ template: `
104
+ <farm-row>
105
+ <farm-col md="4">
106
+ <farm-form-mainfilter label="Label" @onInputChange="handler" />
107
+ </farm-col>
108
+ </farm-row>`,
84
109
  });