@weni/unnnic-system 2.0.11 → 2.0.13

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": "@weni/unnnic-system",
3
- "version": "2.0.11",
3
+ "version": "2.0.13",
4
4
  "type": "commonjs",
5
5
  "files": [
6
6
  "dist",
@@ -1,10 +1,22 @@
1
1
  <template>
2
- <aside v-if="modelValue" class="unnnic-drawer">
3
- <section class="unnnic-drawer__overlay"></section>
4
- <transition appear name="drawer">
2
+ <aside
3
+ v-if="modelValue"
4
+ class="unnnic-drawer"
5
+ >
6
+ <section
7
+ class="unnnic-drawer__overlay"
8
+ @click.stop="close"
9
+ />
10
+ <transition
11
+ appear
12
+ name="drawer"
13
+ >
5
14
  <section
6
15
  v-if="showDrawer"
7
- :class="['unnnic-drawer__container', wide && 'unnnic-drawer__container--wide']"
16
+ :class="[
17
+ 'unnnic-drawer__container',
18
+ wide && 'unnnic-drawer__container--wide',
19
+ ]"
8
20
  >
9
21
  <header class="unnnic-drawer__header">
10
22
  <section class="unnnic-drawer__title-container">
@@ -27,17 +39,24 @@
27
39
  <section class="unnnic-drawer__content">
28
40
  <slot name="content"></slot>
29
41
  </section>
30
- <footer v-if="showFooter" class="unnnic-drawer__footer">
42
+ <footer
43
+ v-if="showFooter"
44
+ class="unnnic-drawer__footer"
45
+ >
31
46
  <unnnic-button
32
47
  v-if="secondaryButtonText"
33
48
  size="large"
34
49
  type="tertiary"
50
+ :disabled="disabledSecondaryButton"
51
+ :loading="loadingSecondaryButton"
35
52
  :text="secondaryButtonText"
36
53
  @click="$emit('secondaryButtonClick')"
37
54
  />
38
55
  <unnnic-button
39
56
  v-if="primaryButtonText"
40
57
  size="large"
58
+ :disabled="disabledPrimaryButton"
59
+ :loading="loadingPrimaryButton"
41
60
  :type="primaryButtonType"
42
61
  :text="primaryButtonText"
43
62
  @click="$emit('primaryButtonClick')"
@@ -72,6 +91,22 @@ export default {
72
91
  description: {
73
92
  type: String,
74
93
  },
94
+ disabledPrimaryButton: {
95
+ type: Boolean,
96
+ default: false,
97
+ },
98
+ disabledSecondaryButton: {
99
+ type: Boolean,
100
+ default: false,
101
+ },
102
+ loadingPrimaryButton: {
103
+ type: Boolean,
104
+ default: false,
105
+ },
106
+ loadingSecondaryButton: {
107
+ type: Boolean,
108
+ default: false,
109
+ },
75
110
  primaryButtonText: {
76
111
  type: String,
77
112
  },
@@ -93,8 +128,8 @@ export default {
93
128
  },
94
129
  computed: {
95
130
  showFooter() {
96
- return !!(this.primaryButtonText || this.secondaryButtonText)
97
- }
131
+ return !!(this.primaryButtonText || this.secondaryButtonText);
132
+ },
98
133
  },
99
134
  methods: {
100
135
  close() {
@@ -141,8 +176,8 @@ export default {
141
176
 
142
177
  .drawer-leave-active,
143
178
  .drawer-leave-to {
144
- display: none;
145
- animation: drawerClose 200ms ease-in;
179
+ display: none;
180
+ animation: drawerClose 200ms ease-in;
146
181
  }
147
182
 
148
183
  .unnnic-drawer {
@@ -156,10 +191,9 @@ export default {
156
191
 
157
192
  .unnnic-drawer__overlay {
158
193
  z-index: 9;
159
- background-color: rgba(0,0,0,0.4);
194
+ background-color: rgba(0, 0, 0, 0.4);
160
195
  width: 100%;
161
196
  height: 100%;
162
-
163
197
  }
164
198
 
165
199
  .unnnic-drawer__container {
@@ -173,7 +207,7 @@ export default {
173
207
  justify-content: space-between;
174
208
  height: 100%;
175
209
  background-color: $unnnic-color-neutral-white;
176
- width: calc(100%/3);
210
+ width: calc(100% / 3);
177
211
 
178
212
  &--wide {
179
213
  width: 50%;
@@ -185,7 +219,6 @@ export default {
185
219
  border-bottom: 1px solid $unnnic-color-neutral-soft;
186
220
  padding: $unnnic-spacing-md;
187
221
  .unnnic-drawer__title-container {
188
-
189
222
  .unnnic-drawer__title {
190
223
  color: $unnnic-color-neutral-darkest;
191
224
  font-family: $unnnic-font-family-secondary;
@@ -207,19 +240,14 @@ export default {
207
240
  margin: $unnnic-spacing-nano;
208
241
  transform: rotate(180deg);
209
242
  display: flex;
210
- }
243
+ }
211
244
  }
212
245
 
213
246
  .unnnic-drawer__content {
214
247
  overflow-y: auto;
215
248
  color: $unnnic-color-neutral-cloudy;
216
- padding: $unnnic-spacing-md $unnnic-spacing-md 0 $unnnic-spacing-md ;
249
+ padding: $unnnic-spacing-md $unnnic-spacing-md 0 $unnnic-spacing-md;
217
250
  flex: 1 0 0;
218
- :deep(*) {
219
- margin: 0;
220
- padding: 0;
221
- box-sizing: border-box;
222
- }
223
251
  }
224
252
 
225
253
  .unnnic-drawer__footer {
@@ -231,4 +259,4 @@ export default {
231
259
  }
232
260
  }
233
261
  }
234
- </style>
262
+ </style>
@@ -1,16 +1,12 @@
1
1
  <template>
2
- <div
3
- @keydown="onKeyDownSelect"
4
- v-on-click-outside="onClickOutside"
5
- class="unnnic-select-smart"
6
- >
7
- <DropdownSkeleton
2
+ <div @keydown="onKeyDownSelect" v-on-click-outside="onClickOutside" class="unnnic-select-smart">
3
+ <dropdown-skeleton
8
4
  type="manual"
9
5
  :modelValue="active || null"
10
6
  position="bottom"
11
7
  ref="dropdown-skeleton"
12
8
  >
13
- <TextInput
9
+ <text-input
14
10
  class="unnnic-select-smart__input"
15
11
  ref="selectSmartInput"
16
12
  :modelValue="inputValue"
@@ -19,11 +15,9 @@
19
15
  :size="size"
20
16
  :disabled="disabled"
21
17
  :readonly="!isAutocompleteAllowed"
22
- :iconLeft="
23
- isAutocompleteAllowed && autocompleteIconLeft ? 'search-1' : ''
24
- "
25
- :iconRight="active ? 'arrow-button-up-1' : 'arrow-button-down-1'"
26
- :iconRightClickable="!disabled"
18
+ :icon-left="isAutocompleteAllowed && autocompleteIconLeft ? 'search-1' : ''"
19
+ :icon-right="active ? 'arrow-button-up-1' : 'arrow-button-down-1'"
20
+ :icon-right-clickable="!disabled"
27
21
  @icon-right-click="handleClickInput"
28
22
  @click.stop="handleClickInput"
29
23
  @update:modelValue="searchValue = $event"
@@ -40,7 +34,7 @@
40
34
  }"
41
35
  >
42
36
  <div :style="{ overflow: 'auto' }">
43
- <SelectSmartMultipleHeader
37
+ <select-smart-multiple-header
44
38
  v-if="multiple"
45
39
  :selectedOptions="modelValue"
46
40
  :withoutSelectsMessage="multipleWithoutSelectsMessage"
@@ -59,16 +53,14 @@
59
53
  },
60
54
  ]"
61
55
  >
62
- <SelectSmartOption
56
+ <select-smart-option
63
57
  v-for="(option, index) in filterOptions(options)"
64
58
  :key="option.value"
65
59
  :label="option.label"
66
60
  :description="option.description"
67
61
  :tabindex="index"
68
62
  :size="size"
69
- :active="
70
- option.value === modelValue || optionIsSelected(option)
71
- "
63
+ :active="option.value === modelValue || optionIsSelected(option)"
72
64
  :focused="focusedOption && focusedOption.value === option.value"
73
65
  :allowCheckbox="!!multiple"
74
66
  @click="handleSelect(option)"
@@ -83,7 +75,7 @@
83
75
  </div>
84
76
  </div>
85
77
  </template>
86
- </DropdownSkeleton>
78
+ </dropdown-skeleton>
87
79
  </div>
88
80
  </template>
89
81
 
@@ -163,6 +155,10 @@ export default {
163
155
  type: Boolean,
164
156
  default: false,
165
157
  },
158
+ selectFirst: {
159
+ type: Boolean,
160
+ default: true,
161
+ }
166
162
  },
167
163
 
168
164
  data() {
@@ -202,7 +198,7 @@ export default {
202
198
  this.searchValue = this.selectedLabel;
203
199
  });
204
200
  }
205
- } else if (this.options?.[0] && this.options?.[0].value) {
201
+ } else if (this.selectFirst && this.options?.[0] && this.options?.[0].value) {
206
202
  this.selectOption(this.options?.[0]);
207
203
  }
208
204
  },
@@ -259,8 +255,7 @@ export default {
259
255
  return isValueMatch && option.value !== '';
260
256
  }
261
257
 
262
- const isEmptyOption =
263
- option.value === '' && this.modelValue.length === 0;
258
+ const isEmptyOption = option.value === '' && this.modelValue.length === 0;
264
259
  return isEmptyOption || isValueMatch;
265
260
  });
266
261
 
@@ -278,9 +273,7 @@ export default {
278
273
  },
279
274
 
280
275
  hasDescriptionOptions() {
281
- return this.options.some(
282
- (item) => typeof item.description !== 'undefined',
283
- );
276
+ return this.options.some((item) => typeof item.description !== 'undefined');
284
277
  },
285
278
 
286
279
  autocompletePlaceholder() {
@@ -314,9 +307,7 @@ export default {
314
307
 
315
308
  methods: {
316
309
  optionIsSelected(option) {
317
- return this.modelValue.some(
318
- (selectedOption) => selectedOption.value === option.value,
319
- );
310
+ return this.modelValue.some((selectedOption) => selectedOption.value === option.value);
320
311
  },
321
312
 
322
313
  clearSelectedOptions() {
@@ -363,18 +354,13 @@ export default {
363
354
 
364
355
  const getNumber = (str) => parseInt(str.match(/\d+/)?.[0], 10) || 0;
365
356
 
366
- const filteredOptions = options.filter(
367
- ({ value, label }, index, self) => {
368
- const labelWithoutAccents = normalizeLabel(label);
369
- const isValueUnique =
370
- self.findIndex((option) => option.value === value) === index;
371
- const matchesSearchTerms = searchTerms.every((term) =>
372
- labelWithoutAccents.includes(term),
373
- );
357
+ const filteredOptions = options.filter(({ value, label }, index, self) => {
358
+ const labelWithoutAccents = normalizeLabel(label);
359
+ const isValueUnique = self.findIndex((option) => option.value === value) === index;
360
+ const matchesSearchTerms = searchTerms.every((term) => labelWithoutAccents.includes(term));
374
361
 
375
- return isValueUnique && matchesSearchTerms && value;
376
- },
377
- );
362
+ return isValueUnique && matchesSearchTerms && value;
363
+ });
378
364
 
379
365
  if (this.orderedByIndex) {
380
366
  return filteredOptions;
@@ -410,8 +396,7 @@ export default {
410
396
  valueByType = this.modelValue?.[0]?.value;
411
397
  }
412
398
  if (type === 'focused') {
413
- valueByType =
414
- this.focusedOption?.value || this.modelValue.at(-1)?.value;
399
+ valueByType = this.focusedOption?.value || this.modelValue.at(-1)?.value;
415
400
  }
416
401
  return options.findIndex((option) => option.value === valueByType);
417
402
  },
@@ -419,11 +404,7 @@ export default {
419
404
  scrollToOption(optionIndex, scrollBlock = 'nearest') {
420
405
  const elementScroll = this.$refs.selectSmartOptionsScrollArea;
421
406
 
422
- if (
423
- elementScroll &&
424
- optionIndex >= 0 &&
425
- optionIndex < elementScroll.childNodes.length
426
- ) {
407
+ if (elementScroll && optionIndex >= 0 && optionIndex < elementScroll.childNodes.length) {
427
408
  const optionElement = elementScroll.childNodes[optionIndex];
428
409
 
429
410
  if (optionElement instanceof HTMLElement) {
@@ -433,8 +414,7 @@ export default {
433
414
  },
434
415
 
435
416
  selectOption(option) {
436
- const selectedOption =
437
- option.value === null || option.value.length === 0 ? null : option;
417
+ const selectedOption = option.value === null || option.value.length === 0 ? null : option;
438
418
 
439
419
  this.$emit(
440
420
  'update:modelValue',
@@ -448,9 +428,7 @@ export default {
448
428
  );
449
429
 
450
430
  if (indexToRemove !== -1) {
451
- const newModelValue = this.modelValue;
452
- newModelValue.splice(indexToRemove, 1);
453
- this.$emit('update:modelValue', newModelValue);
431
+ this.modelValue.splice(indexToRemove, 1);
454
432
  }
455
433
 
456
434
  if (this.multiple) {
@@ -522,8 +500,7 @@ export default {
522
500
  this.scrollToOption(newIndex);
523
501
  }
524
502
 
525
- const newOption =
526
- options[newIndex === undefined ? focusedOptionIndex : newIndex];
503
+ const newOption = options[newIndex === undefined ? focusedOptionIndex : newIndex];
527
504
  this.focusedOption = newOption;
528
505
  }
529
506
  },
@@ -647,8 +624,7 @@ export default {
647
624
  }
648
625
 
649
626
  &:disabled {
650
- box-shadow: inset 0 0 0 $unnnic-border-width-thinner
651
- $unnnic-color-neutral-cleanest;
627
+ box-shadow: inset 0 0 0 $unnnic-border-width-thinner $unnnic-color-neutral-cleanest;
652
628
 
653
629
  cursor: not-allowed;
654
630
 
@@ -1,7 +1,14 @@
1
1
  import unnnicDrawer from '../components/Drawer/Drawer.vue';
2
2
  import unnnicButton from '../components/Button/Button.vue';
3
3
 
4
- const primaryButtonTypeOptions = ['primary', 'secondary', 'tertiary', 'alternative', 'warning', 'attention']
4
+ const primaryButtonTypeOptions = [
5
+ 'primary',
6
+ 'secondary',
7
+ 'tertiary',
8
+ 'alternative',
9
+ 'warning',
10
+ 'attention',
11
+ ];
5
12
 
6
13
  export default {
7
14
  title: 'Example/Drawer',
@@ -9,7 +16,14 @@ export default {
9
16
  argTypes: {
10
17
  title: { control: { type: 'text' } },
11
18
  description: { control: { type: 'text' } },
12
- primaryButtonType: { options: primaryButtonTypeOptions, control: { type: 'select' } },
19
+ primaryButtonType: {
20
+ options: primaryButtonTypeOptions,
21
+ control: { type: 'select' },
22
+ },
23
+ disabledPrimaryButton: { control: { type: 'boolean' } },
24
+ disabledSecondaryButton: { control: { type: 'boolean' } },
25
+ loadingPrimaryButton: { control: { type: 'boolean' } },
26
+ loadingSecondaryButton: { control: { type: 'boolean' } },
13
27
  primaryButtonText: { control: { type: 'text' } },
14
28
  secondaryButtonText: { control: { type: 'text' } },
15
29
  modelValue: { control: { type: 'boolean' } },
@@ -20,7 +34,7 @@ export default {
20
34
  const Template = (args) => ({
21
35
  props: Object.keys(args),
22
36
  setup() {
23
- return { args }
37
+ return { args };
24
38
  },
25
39
  components: { unnnicDrawer, unnnicButton },
26
40
  data() {
@@ -30,11 +44,11 @@ const Template = (args) => ({
30
44
  },
31
45
  methods: {
32
46
  primaryClick() {
33
- console.log('primaryClick')
47
+ console.log('primaryClick');
34
48
  },
35
49
  secondaryClick() {
36
- console.log('secondaryClick')
37
- }
50
+ console.log('secondaryClick');
51
+ },
38
52
  },
39
53
  template: `
40
54
  <div>
@@ -42,7 +56,7 @@ const Template = (args) => ({
42
56
  <button @click="opened = !opened">Change</button>
43
57
  <unnnic-drawer v-bind="args" v-model="opened" @close="opened = false" @primaryButtonClick="primaryClick" @secondaryButtonClick="secondaryClick">
44
58
  <template #content>
45
- <p>Conteúdo</p>
59
+ <p style="padding: 0; margin:0;">Conteúdo</p>
46
60
  </template>
47
61
  </unnnic-drawer>
48
62
  </div>
@@ -70,7 +84,7 @@ const TemplateOveflowed = (args) => ({
70
84
  props: Object.keys(args),
71
85
  components: { unnnicDrawer, unnnicButton },
72
86
  setup() {
73
- return { args }
87
+ return { args };
74
88
  },
75
89
  data() {
76
90
  return {
@@ -83,7 +97,7 @@ const TemplateOveflowed = (args) => ({
83
97
  <button @click="opened = !opened">Change</button>
84
98
  <unnnic-drawer v-bind="args" v-model="opened" @close="opened = false">
85
99
  <template #content>
86
- <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed interdum dolor viverra, aliquam metus dictum, vehicula felis. Nulla sapien nisi, laoreet sit amet nisi sed, consectetur ornare odio. Nullam facilisis a ligula quis accumsan. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Phasellus et sodales ex. Donec mauris dui, tempor eget lorem vel, blandit consequat tellus. Maecenas ut justo vitae orci commodo consectetur eget id nisl. Donec auctor sollicitudin ex at lacinia. Integer lobortis, eros nec congue facilisis, augue nisl elementum nibh, pharetra euismod odio turpis eu lorem. Vivamus a tristique tellus.</p>
100
+ <p style="padding: 0; margin:0;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed interdum dolor viverra, aliquam metus dictum, vehicula felis. Nulla sapien nisi, laoreet sit amet nisi sed, consectetur ornare odio. Nullam facilisis a ligula quis accumsan. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Phasellus et sodales ex. Donec mauris dui, tempor eget lorem vel, blandit consequat tellus. Maecenas ut justo vitae orci commodo consectetur eget id nisl. Donec auctor sollicitudin ex at lacinia. Integer lobortis, eros nec congue facilisis, augue nisl elementum nibh, pharetra euismod odio turpis eu lorem. Vivamus a tristique tellus.</p>
87
101
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed interdum dolor viverra, aliquam metus dictum, vehicula felis. Nulla sapien nisi, laoreet sit amet nisi sed, consectetur ornare odio. Nullam facilisis a ligula quis accumsan. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Phasellus et sodales ex. Donec mauris dui, tempor eget lorem vel, blandit consequat tellus. Maecenas ut justo vitae orci commodo consectetur eget id nisl. Donec auctor sollicitudin ex at lacinia. Integer lobortis, eros nec congue facilisis, augue nisl elementum nibh, pharetra euismod odio turpis eu lorem. Vivamus a tristique tellus.</p>
88
102
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed interdum dolor viverra, aliquam metus dictum, vehicula felis. Nulla sapien nisi, laoreet sit amet nisi sed, consectetur ornare odio. Nullam facilisis a ligula quis accumsan. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Phasellus et sodales ex. Donec mauris dui, tempor eget lorem vel, blandit consequat tellus. Maecenas ut justo vitae orci commodo consectetur eget id nisl. Donec auctor sollicitudin ex at lacinia. Integer lobortis, eros nec congue facilisis, augue nisl elementum nibh, pharetra euismod odio turpis eu lorem. Vivamus a tristique tellus.</p>
89
103
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed interdum dolor viverra, aliquam metus dictum, vehicula felis. Nulla sapien nisi, laoreet sit amet nisi sed, consectetur ornare odio. Nullam facilisis a ligula quis accumsan. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Phasellus et sodales ex. Donec mauris dui, tempor eget lorem vel, blandit consequat tellus. Maecenas ut justo vitae orci commodo consectetur eget id nisl. Donec auctor sollicitudin ex at lacinia. Integer lobortis, eros nec congue facilisis, augue nisl elementum nibh, pharetra euismod odio turpis eu lorem. Vivamus a tristique tellus.</p>
@@ -108,7 +122,7 @@ const TemplateVideo = (args) => ({
108
122
  props: Object.keys(args),
109
123
  components: { unnnicDrawer, unnnicButton },
110
124
  setup() {
111
- return { args }
125
+ return { args };
112
126
  },
113
127
  data() {
114
128
  return {
@@ -133,4 +147,4 @@ ContentVideo.args = {
133
147
  title: 'Title',
134
148
  description: 'Description',
135
149
  wide: true,
136
- };
150
+ };
@@ -0,0 +1,59 @@
1
+ import unnnicSelectSmart from '../components/SelectSmart/SelectSmart.vue';
2
+
3
+ export default {
4
+ title: 'Form/SelectSmart2',
5
+ component: unnnicSelectSmart,
6
+ argTypes: {
7
+ 'on-update:model-value': { action: '@update:model-value' },
8
+ size: { control: { type: 'select', options: ['md', 'sm'] } },
9
+ type: { control: { type: 'select', options: ['normal', 'error'] } },
10
+ },
11
+ };
12
+
13
+ const Template = (args, { argTypes }) => ({
14
+ props: Object.keys(argTypes),
15
+
16
+ components: {
17
+ unnnicSelectSmart,
18
+ },
19
+
20
+ data() {
21
+ return {
22
+ selected: [],
23
+ options: [
24
+ {
25
+ value: 't1',
26
+ label: 'teste 1'
27
+ },
28
+ {
29
+ value: 't2',
30
+ label: 'teste 2'
31
+ },
32
+ {
33
+ value: 't3',
34
+ label: 'teste 3'
35
+ },
36
+ ]
37
+ };
38
+ },
39
+
40
+ template: `
41
+ <div>
42
+ <pre>v-model: {{ content }}</pre>
43
+ <unnnic-select-smart :options="options" v-model="selected" multiple :selectFirst="false" />
44
+ </div>
45
+ `,
46
+
47
+ methods: {},
48
+ });
49
+
50
+ export const Default = Template.bind({});
51
+
52
+ Default.args = {
53
+ label: 'Label',
54
+ placeholder: 'Placeholder',
55
+ maxLength: 150,
56
+ disabled: false,
57
+ type: 'normal',
58
+ errors: [],
59
+ };