@weni/unnnic-system 3.1.0 → 3.1.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": "@weni/unnnic-system",
3
- "version": "3.1.0",
3
+ "version": "3.1.1",
4
4
  "type": "commonjs",
5
5
  "files": [
6
6
  "dist",
@@ -86,6 +86,7 @@
86
86
  :active="
87
87
  option.value === modelValue || optionIsSelected(option)
88
88
  "
89
+ :disabled="optionIsSelected(option) && option.disableRemove"
89
90
  :focused="focusedOption && focusedOption.value === option.value"
90
91
  :allowCheckbox="!!multiple"
91
92
  :activeColor="type === 'secondary' ? 'secondary' : 'primary'"
@@ -142,6 +143,10 @@ export default {
142
143
  value: 'option1',
143
144
  label: 'Option1',
144
145
  },
146
+ {
147
+ value: 'option2',
148
+ label: 'Option2',
149
+ },
145
150
  ],
146
151
  },
147
152
  modelValue: {
@@ -203,6 +208,10 @@ export default {
203
208
  type: Boolean,
204
209
  default: false,
205
210
  },
211
+ multipleLimit: {
212
+ type: [Number, null],
213
+ default: null,
214
+ },
206
215
  },
207
216
 
208
217
  emits: ['update:searchValue', 'onChange', 'update:modelValue'],
@@ -363,11 +372,23 @@ export default {
363
372
 
364
373
  handleSelect(option) {
365
374
  if (option) {
366
- if (this.multiple && this.optionIsSelected(option)) {
375
+ if (
376
+ this.multiple &&
377
+ this.optionIsSelected(option) &&
378
+ !option.disableRemove
379
+ ) {
367
380
  this.unselectOption(option);
368
381
  return;
369
382
  }
370
383
 
384
+ if(this.multiple && option.disableRemove && this.optionIsSelected(option)) {
385
+ return;
386
+ }
387
+
388
+ if (this.multipleLimit && this.modelValue.length >= this.multipleLimit) {
389
+ return;
390
+ }
391
+
371
392
  this.selectOption(option);
372
393
  }
373
394
  },
@@ -10,7 +10,7 @@
10
10
  :key="option.value"
11
11
  class="unnnic-select-smart__options__multiple__selecteds__option"
12
12
  :text="option.label"
13
- hasCloseIcon
13
+ :hasCloseIcon="!option.disableRemove"
14
14
  @close="unselectOption(option)"
15
15
  />
16
16
  <p
@@ -19,6 +19,7 @@
19
19
  data-testid="checkbox"
20
20
  :modelValue="active"
21
21
  :size="size"
22
+ :disabled="disabled"
22
23
  />
23
24
  <div>
24
25
  <span
@@ -77,6 +78,10 @@ export default {
77
78
  type: Boolean,
78
79
  default: null,
79
80
  },
81
+ disabled: {
82
+ type: Boolean,
83
+ default: false,
84
+ },
80
85
  allowCheckbox: {
81
86
  type: Boolean,
82
87
  default: false,
@@ -284,7 +284,7 @@ export const Multiple = {
284
284
  { value: 'spain', label: 'Espanha' },
285
285
  { value: 'saudi_arabia', label: 'Arábia Saudita' },
286
286
  ],
287
- multiple: true,
287
+ multiple:true,
288
288
  multipleWithoutSelectsMessage: 'No country selected yet :(',
289
289
  },
290
290
  };