@weni/unnnic-system 3.12.3-alpha.5 → 3.12.3-alpha.6

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.
Files changed (33) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/components/MultiSelect/index.vue.d.ts +636 -1
  3. package/dist/components/MultiSelect/index.vue.d.ts.map +1 -1
  4. package/dist/components/Select/index.vue.d.ts +636 -1
  5. package/dist/components/Select/index.vue.d.ts.map +1 -1
  6. package/dist/components/index.d.ts +12 -6
  7. package/dist/components/index.d.ts.map +1 -1
  8. package/dist/components/ui/popover/PopoverContent.vue.d.ts +4 -2
  9. package/dist/components/ui/popover/PopoverContent.vue.d.ts.map +1 -1
  10. package/dist/{es-a9e51a05.mjs → es-ea43343d.mjs} +1 -1
  11. package/dist/{index-ade761d4.mjs → index-f40272b0.mjs} +7584 -7496
  12. package/dist/{pt-br-5395459d.mjs → pt-br-fdb63719.mjs} +1 -1
  13. package/dist/style.css +1 -1
  14. package/dist/unnnic.mjs +1 -1
  15. package/dist/unnnic.umd.js +33 -33
  16. package/package.json +1 -1
  17. package/src/components/FormElement/FormElement.vue +1 -1
  18. package/src/components/ModalDialog/ModalDialog.vue +1 -1
  19. package/src/components/MultiSelect/__tests__/MultiSelect.spec.js +5 -4
  20. package/src/components/MultiSelect/__tests__/__snapshots__/MultiSelect.spec.js.snap +5 -5
  21. package/src/components/MultiSelect/index.vue +43 -3
  22. package/src/components/Radio/Radio.vue +1 -1
  23. package/src/components/Select/__tests__/__snapshots__/Select.spec.js.snap +4 -4
  24. package/src/components/Select/index.vue +11 -1
  25. package/src/components/Switch/Switch.vue +1 -1
  26. package/src/components/TemplatePreview/TemplatePreview.vue +2 -2
  27. package/src/components/TemplatePreview/TemplatePreviewModal.vue +1 -1
  28. package/src/components/ToolTip/ToolTip.vue +1 -1
  29. package/src/components/ui/popover/PopoverContent.vue +16 -13
  30. package/src/components/ui/popover/PopoverOption.vue +1 -1
  31. package/src/stories/MultiSelect.stories.js +4 -2
  32. package/src/stories/Popover.stories.js +5 -0
  33. package/src/stories/Select.stories.js +5 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weni/unnnic-system",
3
- "version": "3.12.3-alpha.5",
3
+ "version": "3.12.3-alpha.6",
4
4
  "type": "commonjs",
5
5
  "files": [
6
6
  "dist",
@@ -18,8 +18,8 @@
18
18
  <slot></slot>
19
19
 
20
20
  <section
21
- class="unnnic-form-element__hints-container"
22
21
  v-if="message || error || !!$slots.rightMessage"
22
+ class="unnnic-form-element__hints-container"
23
23
  >
24
24
  <section class="unnnic-form-element__message-container">
25
25
  <p
@@ -102,8 +102,8 @@ export default {
102
102
  UnnnicDialogTitle,
103
103
  UnnnicDialogFooter,
104
104
  },
105
- inheritAttrs: false,
106
105
  mixins: [UnnnicI18n],
106
+ inheritAttrs: false,
107
107
  props: {
108
108
  modelValue: {
109
109
  type: Boolean,
@@ -282,19 +282,20 @@ describe('UnnnicMultiSelect.vue', () => {
282
282
 
283
283
  describe('computed properties', () => {
284
284
  test('calculatedMaxHeight returns correct value', () => {
285
- const maxHeight = wrapper.vm.calculatedMaxHeight;
285
+ const maxHeight = wrapper.vm.calculatedPopoverHeight;
286
+ console.log(maxHeight);
286
287
  expect(maxHeight).toBe('228px');
287
288
  });
288
289
 
289
290
  test('calculatedMaxHeight includes search height when enabled', async () => {
290
291
  await wrapper.setProps({ enableSearch: true });
291
- const maxHeight = wrapper.vm.calculatedMaxHeight;
292
+ const maxHeight = wrapper.vm.calculatedPopoverHeight;
292
293
  expect(maxHeight).toBe('295px');
293
294
  });
294
295
 
295
296
  test('calculatedMaxHeight returns unset when no options', async () => {
296
297
  await wrapper.setProps({ options: [] });
297
- const maxHeight = wrapper.vm.calculatedMaxHeight;
298
+ const maxHeight = wrapper.vm.calculatedPopoverHeight;
298
299
  expect(maxHeight).toBe('unset');
299
300
  });
300
301
 
@@ -458,7 +459,7 @@ describe('UnnnicMultiSelect.vue', () => {
458
459
  test('handles empty options array', async () => {
459
460
  await wrapper.setProps({ options: [] });
460
461
  expect(wrapper.vm.filteredOptions).toEqual([]);
461
- expect(wrapper.vm.calculatedMaxHeight).toBe('unset');
462
+ expect(wrapper.vm.calculatedPopoverHeight).toBe('unset');
462
463
  });
463
464
 
464
465
  test('handles empty modelValue array', async () => {
@@ -1,7 +1,7 @@
1
1
  // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
2
 
3
3
  exports[`UnnnicMultiSelect.vue > snapshot testing > matches snapshot with default props 1`] = `
4
- "<div data-v-03c7fb50="" class="unnnic-multi-select"><button data-v-9d52eef8="" data-v-03c7fb50="" class="unnnic-popover-trigger" id="reka-popover-trigger-v-0" type="button" aria-haspopup="dialog" aria-expanded="false" aria-controls="" data-state="closed">
4
+ "<div data-v-03c7fb50="" class="unnnic-multi-select"><button data-v-9d52eef8="" data-v-03c7fb50="" class="unnnic-popover-trigger w-full" id="reka-popover-trigger-v-0" type="button" aria-haspopup="dialog" aria-expanded="false" aria-controls="" data-state="closed">
5
5
  <section data-v-9f8d6c86="" data-v-d890ad85="" data-v-03c7fb50="" class="unnnic-form-element unnnic-form md unnnic-multi-select__input" data-testid="form-element">
6
6
  <!--v-if-->
7
7
  <div data-v-a0d36167="" data-v-d890ad85="" class="text-input size--md unnnic-multi-select__input unnnic-form-input" hascloudycolor="false" mask=""><input data-v-86533b41="" data-v-a0d36167="" class="unnnic-multi-select__input unnnic-form-input input-itself input size-md normal input--has-icon-right use-focus-prop unnnic-multi-select__input unnnic-form-input input-itself" hascloudycolor="false" placeholder="" iconleft="" iconright="keyboard_arrow_down" iconleftclickable="false" iconrightclickable="false" showclear="false" type="text" readonly="" value="">
@@ -19,7 +19,7 @@ exports[`UnnnicMultiSelect.vue > snapshot testing > matches snapshot with defaul
19
19
  `;
20
20
 
21
21
  exports[`UnnnicMultiSelect.vue > snapshot testing > matches snapshot with disabled state 1`] = `
22
- "<div data-v-03c7fb50="" class="unnnic-multi-select"><button data-v-9d52eef8="" data-v-03c7fb50="" class="unnnic-popover-trigger" id="reka-popover-trigger-v-0" type="button" aria-haspopup="dialog" aria-expanded="false" aria-controls="" data-state="closed">
22
+ "<div data-v-03c7fb50="" class="unnnic-multi-select"><button data-v-9d52eef8="" data-v-03c7fb50="" class="unnnic-popover-trigger w-full" id="reka-popover-trigger-v-0" type="button" aria-haspopup="dialog" aria-expanded="false" aria-controls="" data-state="closed">
23
23
  <section data-v-9f8d6c86="" data-v-d890ad85="" data-v-03c7fb50="" class="unnnic-form-element unnnic-form-element--disabled unnnic-form md unnnic-multi-select__input" data-testid="form-element">
24
24
  <!--v-if-->
25
25
  <div data-v-a0d36167="" data-v-d890ad85="" class="text-input size--md unnnic-multi-select__input unnnic-form-input" hascloudycolor="false" mask=""><input data-v-86533b41="" data-v-a0d36167="" class="unnnic-multi-select__input unnnic-form-input input-itself input size-md normal input--has-icon-right use-focus-prop unnnic-multi-select__input unnnic-form-input input-itself" hascloudycolor="false" placeholder="" iconleft="" iconright="keyboard_arrow_down" iconleftclickable="false" iconrightclickable="false" showclear="false" type="text" readonly="" value="" disabled="">
@@ -37,7 +37,7 @@ exports[`UnnnicMultiSelect.vue > snapshot testing > matches snapshot with disabl
37
37
  `;
38
38
 
39
39
  exports[`UnnnicMultiSelect.vue > snapshot testing > matches snapshot with multiple selected values 1`] = `
40
- "<div data-v-03c7fb50="" class="unnnic-multi-select"><button data-v-9d52eef8="" data-v-03c7fb50="" class="unnnic-popover-trigger" id="reka-popover-trigger-v-0" type="button" aria-haspopup="dialog" aria-expanded="false" aria-controls="" data-state="closed">
40
+ "<div data-v-03c7fb50="" class="unnnic-multi-select"><button data-v-9d52eef8="" data-v-03c7fb50="" class="unnnic-popover-trigger w-full" id="reka-popover-trigger-v-0" type="button" aria-haspopup="dialog" aria-expanded="false" aria-controls="" data-state="closed">
41
41
  <section data-v-9f8d6c86="" data-v-d890ad85="" data-v-03c7fb50="" class="unnnic-form-element unnnic-form md unnnic-multi-select__input" data-testid="form-element">
42
42
  <!--v-if-->
43
43
  <div data-v-a0d36167="" data-v-d890ad85="" class="text-input size--md unnnic-multi-select__input unnnic-form-input" hascloudycolor="false" mask=""><input data-v-86533b41="" data-v-a0d36167="" class="unnnic-multi-select__input unnnic-form-input input-itself input size-md normal input--has-icon-right input--has-clear-icon use-focus-prop unnnic-multi-select__input unnnic-form-input input-itself" hascloudycolor="false" placeholder="" iconleft="" iconright="keyboard_arrow_down" iconleftclickable="false" iconrightclickable="false" showclear="true" type="text" readonly="" value="Option 1, Option 2">
@@ -53,7 +53,7 @@ exports[`UnnnicMultiSelect.vue > snapshot testing > matches snapshot with multip
53
53
  `;
54
54
 
55
55
  exports[`UnnnicMultiSelect.vue > snapshot testing > matches snapshot with search enabled 1`] = `
56
- "<div data-v-03c7fb50="" class="unnnic-multi-select"><button data-v-9d52eef8="" data-v-03c7fb50="" class="unnnic-popover-trigger" id="reka-popover-trigger-v-0" type="button" aria-haspopup="dialog" aria-expanded="false" aria-controls="" data-state="closed">
56
+ "<div data-v-03c7fb50="" class="unnnic-multi-select"><button data-v-9d52eef8="" data-v-03c7fb50="" class="unnnic-popover-trigger w-full" id="reka-popover-trigger-v-0" type="button" aria-haspopup="dialog" aria-expanded="false" aria-controls="" data-state="closed">
57
57
  <section data-v-9f8d6c86="" data-v-d890ad85="" data-v-03c7fb50="" class="unnnic-form-element unnnic-form md unnnic-multi-select__input" data-testid="form-element">
58
58
  <!--v-if-->
59
59
  <div data-v-a0d36167="" data-v-d890ad85="" class="text-input size--md unnnic-multi-select__input unnnic-form-input" hascloudycolor="false" mask=""><input data-v-86533b41="" data-v-a0d36167="" class="unnnic-multi-select__input unnnic-form-input input-itself input size-md normal input--has-icon-right use-focus-prop unnnic-multi-select__input unnnic-form-input input-itself" hascloudycolor="false" placeholder="" iconleft="" iconright="keyboard_arrow_down" iconleftclickable="false" iconrightclickable="false" showclear="false" type="text" readonly="" value="">
@@ -71,7 +71,7 @@ exports[`UnnnicMultiSelect.vue > snapshot testing > matches snapshot with search
71
71
  `;
72
72
 
73
73
  exports[`UnnnicMultiSelect.vue > snapshot testing > matches snapshot with selected values 1`] = `
74
- "<div data-v-03c7fb50="" class="unnnic-multi-select"><button data-v-9d52eef8="" data-v-03c7fb50="" class="unnnic-popover-trigger" id="reka-popover-trigger-v-0" type="button" aria-haspopup="dialog" aria-expanded="false" aria-controls="" data-state="closed">
74
+ "<div data-v-03c7fb50="" class="unnnic-multi-select"><button data-v-9d52eef8="" data-v-03c7fb50="" class="unnnic-popover-trigger w-full" id="reka-popover-trigger-v-0" type="button" aria-haspopup="dialog" aria-expanded="false" aria-controls="" data-state="closed">
75
75
  <section data-v-9f8d6c86="" data-v-d890ad85="" data-v-03c7fb50="" class="unnnic-form-element unnnic-form md unnnic-multi-select__input" data-testid="form-element">
76
76
  <!--v-if-->
77
77
  <div data-v-a0d36167="" data-v-d890ad85="" class="text-input size--md unnnic-multi-select__input unnnic-form-input" hascloudycolor="false" mask=""><input data-v-86533b41="" data-v-a0d36167="" class="unnnic-multi-select__input unnnic-form-input input-itself input size-md normal input--has-icon-right input--has-clear-icon use-focus-prop unnnic-multi-select__input unnnic-form-input input-itself" hascloudycolor="false" placeholder="" iconleft="" iconright="keyboard_arrow_down" iconleftclickable="false" iconrightclickable="false" showclear="true" type="text" readonly="" value="Option 1">
@@ -4,8 +4,9 @@
4
4
  :open="openPopover"
5
5
  @update:open="openPopover = $event"
6
6
  >
7
- <PopoverTrigger>
7
+ <PopoverTrigger class="w-full">
8
8
  <UnnnicInput
9
+ ref="multiSelectInputRef"
9
10
  :modelValue="inputValue"
10
11
  class="unnnic-multi-select__input"
11
12
  readonly
@@ -24,7 +25,9 @@
24
25
  </PopoverTrigger>
25
26
  <PopoverContent
26
27
  align="start"
27
- :style="{ maxHeight: calculatedMaxHeight, overflow: 'auto' }"
28
+ class="h-full"
29
+ :style="popoverContentCustomStyles"
30
+ :width="inputWidthString"
28
31
  >
29
32
  <div class="unnnic-multi-select__content">
30
33
  <UnnnicInput
@@ -35,6 +38,12 @@
35
38
  iconLeft="search"
36
39
  @update:model-value="handleSearch"
37
40
  />
41
+ <p
42
+ v-if="filteredOptions.length === 0"
43
+ class="unnnic-multi-select__content-no-results"
44
+ >
45
+ {{ $t('without_results') }}
46
+ </p>
38
47
  <div class="unnnic-multi-select__options">
39
48
  <UnnnicMultiSelectOption
40
49
  v-for="(option, index) in filteredOptions"
@@ -59,6 +68,7 @@ import { computed, ref } from 'vue';
59
68
  import { Popover, PopoverTrigger, PopoverContent } from '../ui/popover';
60
69
  import UnnnicInput from '../Input/Input.vue';
61
70
  import UnnnicMultiSelectOption from './MultSelectOption.vue';
71
+ import { useElementSize } from '@vueuse/core';
62
72
 
63
73
  defineOptions({
64
74
  name: 'UnnnicMultiSelect',
@@ -103,8 +113,26 @@ const props = withDefaults(defineProps<MultiSelectProps>(), {
103
113
  });
104
114
 
105
115
  const openPopover = ref(false);
116
+ const multiSelectInputRef = ref<HTMLInputElement | null>(null);
117
+ const { width: inputWidth } = useElementSize(multiSelectInputRef);
106
118
 
107
- const calculatedMaxHeight = computed(() => {
119
+ const inputWidthString = computed(() => {
120
+ return `${inputWidth.value}px`;
121
+ });
122
+
123
+ const popoverContentCustomStyles = computed(() => {
124
+ const emptyFilteredOptions = filteredOptions.value?.length === 0;
125
+ return {
126
+ overflow: 'auto',
127
+ display: 'flex',
128
+ flexDirection: 'column',
129
+ minHeight: calculatedPopoverHeight.value,
130
+ maxHeight: emptyFilteredOptions ? 'unset' : calculatedPopoverHeight.value,
131
+ height: emptyFilteredOptions ? calculatedPopoverHeight.value : 'unset',
132
+ };
133
+ });
134
+
135
+ const calculatedPopoverHeight = computed(() => {
108
136
  if (!props.options || props.options.length === 0) return 'unset';
109
137
  const popoverSearchGap = props.enableSearch ? 16 : 0;
110
138
  const popoverGap = 24;
@@ -212,6 +240,18 @@ const handleSelectOption = (
212
240
  padding: 0;
213
241
  margin: 0;
214
242
  gap: $unnnic-space-4;
243
+
244
+ height: -webkit-fill-available;
245
+
246
+ &-no-results {
247
+ margin: 0;
248
+ display: flex;
249
+ align-items: center;
250
+ justify-content: center;
251
+ height: 100%;
252
+ font: $unnnic-font-emphasis;
253
+ color: $unnnic-color-fg-muted;
254
+ }
215
255
  }
216
256
 
217
257
  &__options {
@@ -12,9 +12,9 @@
12
12
  type="radio"
13
13
  :disabled="disabled"
14
14
  :checked="computedModelValue === value"
15
- @change="click"
16
15
  :name="computedName"
17
16
  v-bind="pick($attrs, ['id'])"
17
+ @change="click"
18
18
  />
19
19
 
20
20
  <p
@@ -1,7 +1,7 @@
1
1
  // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
2
 
3
3
  exports[`UnnnicSelect.vue > snapshot testing > matches snapshot with default props 1`] = `
4
- "<div data-v-6077efb7="" class="unnnic-select"><button data-v-9d52eef8="" data-v-6077efb7="" class="unnnic-popover-trigger" id="reka-popover-trigger-v-0" type="button" aria-haspopup="dialog" aria-expanded="false" aria-controls="" data-state="closed">
4
+ "<div data-v-6077efb7="" class="unnnic-select"><button data-v-9d52eef8="" data-v-6077efb7="" class="unnnic-popover-trigger w-full" id="reka-popover-trigger-v-0" type="button" aria-haspopup="dialog" aria-expanded="false" aria-controls="" data-state="closed">
5
5
  <section data-v-9f8d6c86="" data-v-d890ad85="" data-v-6077efb7="" class="unnnic-form-element unnnic-form md unnnic-select__input" data-testid="form-element">
6
6
  <!--v-if-->
7
7
  <div data-v-a0d36167="" data-v-d890ad85="" class="text-input size--md unnnic-select__input unnnic-form-input" hascloudycolor="false" mask=""><input data-v-86533b41="" data-v-a0d36167="" class="unnnic-select__input unnnic-form-input input-itself input size-md normal input--has-icon-right use-focus-prop unnnic-select__input unnnic-form-input input-itself" hascloudycolor="false" placeholder="" iconleft="" iconright="keyboard_arrow_down" iconleftclickable="false" iconrightclickable="false" showclear="false" type="text" readonly="" value="">
@@ -19,7 +19,7 @@ exports[`UnnnicSelect.vue > snapshot testing > matches snapshot with default pro
19
19
  `;
20
20
 
21
21
  exports[`UnnnicSelect.vue > snapshot testing > matches snapshot with disabled state 1`] = `
22
- "<div data-v-6077efb7="" class="unnnic-select"><button data-v-9d52eef8="" data-v-6077efb7="" class="unnnic-popover-trigger" id="reka-popover-trigger-v-0" type="button" aria-haspopup="dialog" aria-expanded="false" aria-controls="" data-state="closed">
22
+ "<div data-v-6077efb7="" class="unnnic-select"><button data-v-9d52eef8="" data-v-6077efb7="" class="unnnic-popover-trigger w-full" id="reka-popover-trigger-v-0" type="button" aria-haspopup="dialog" aria-expanded="false" aria-controls="" data-state="closed">
23
23
  <section data-v-9f8d6c86="" data-v-d890ad85="" data-v-6077efb7="" class="unnnic-form-element unnnic-form-element--disabled unnnic-form md unnnic-select__input" data-testid="form-element">
24
24
  <!--v-if-->
25
25
  <div data-v-a0d36167="" data-v-d890ad85="" class="text-input size--md unnnic-select__input unnnic-form-input" hascloudycolor="false" mask=""><input data-v-86533b41="" data-v-a0d36167="" class="unnnic-select__input unnnic-form-input input-itself input size-md normal input--has-icon-right use-focus-prop unnnic-select__input unnnic-form-input input-itself" hascloudycolor="false" placeholder="" iconleft="" iconright="keyboard_arrow_down" iconleftclickable="false" iconrightclickable="false" showclear="false" type="text" readonly="" value="" disabled="">
@@ -37,7 +37,7 @@ exports[`UnnnicSelect.vue > snapshot testing > matches snapshot with disabled st
37
37
  `;
38
38
 
39
39
  exports[`UnnnicSelect.vue > snapshot testing > matches snapshot with search enabled 1`] = `
40
- "<div data-v-6077efb7="" class="unnnic-select"><button data-v-9d52eef8="" data-v-6077efb7="" class="unnnic-popover-trigger" id="reka-popover-trigger-v-0" type="button" aria-haspopup="dialog" aria-expanded="false" aria-controls="" data-state="closed">
40
+ "<div data-v-6077efb7="" class="unnnic-select"><button data-v-9d52eef8="" data-v-6077efb7="" class="unnnic-popover-trigger w-full" id="reka-popover-trigger-v-0" type="button" aria-haspopup="dialog" aria-expanded="false" aria-controls="" data-state="closed">
41
41
  <section data-v-9f8d6c86="" data-v-d890ad85="" data-v-6077efb7="" class="unnnic-form-element unnnic-form md unnnic-select__input" data-testid="form-element">
42
42
  <!--v-if-->
43
43
  <div data-v-a0d36167="" data-v-d890ad85="" class="text-input size--md unnnic-select__input unnnic-form-input" hascloudycolor="false" mask=""><input data-v-86533b41="" data-v-a0d36167="" class="unnnic-select__input unnnic-form-input input-itself input size-md normal input--has-icon-right use-focus-prop unnnic-select__input unnnic-form-input input-itself" hascloudycolor="false" placeholder="" iconleft="" iconright="keyboard_arrow_down" iconleftclickable="false" iconrightclickable="false" showclear="false" type="text" readonly="" value="">
@@ -55,7 +55,7 @@ exports[`UnnnicSelect.vue > snapshot testing > matches snapshot with search enab
55
55
  `;
56
56
 
57
57
  exports[`UnnnicSelect.vue > snapshot testing > matches snapshot with selected value 1`] = `
58
- "<div data-v-6077efb7="" class="unnnic-select"><button data-v-9d52eef8="" data-v-6077efb7="" class="unnnic-popover-trigger" id="reka-popover-trigger-v-0" type="button" aria-haspopup="dialog" aria-expanded="false" aria-controls="" data-state="closed">
58
+ "<div data-v-6077efb7="" class="unnnic-select"><button data-v-9d52eef8="" data-v-6077efb7="" class="unnnic-popover-trigger w-full" id="reka-popover-trigger-v-0" type="button" aria-haspopup="dialog" aria-expanded="false" aria-controls="" data-state="closed">
59
59
  <section data-v-9f8d6c86="" data-v-d890ad85="" data-v-6077efb7="" class="unnnic-form-element unnnic-form md unnnic-select__input" data-testid="form-element">
60
60
  <!--v-if-->
61
61
  <div data-v-a0d36167="" data-v-d890ad85="" class="text-input size--md unnnic-select__input unnnic-form-input" hascloudycolor="false" mask=""><input data-v-86533b41="" data-v-a0d36167="" class="unnnic-select__input unnnic-form-input input-itself input size-md normal input--has-icon-right input--has-clear-icon use-focus-prop unnnic-select__input unnnic-form-input input-itself" hascloudycolor="false" placeholder="" iconleft="" iconright="keyboard_arrow_down" iconleftclickable="false" iconrightclickable="false" showclear="true" type="text" readonly="" value="Option 1">
@@ -7,8 +7,9 @@
7
7
  :open="openPopover"
8
8
  @update:open="openPopover = $event"
9
9
  >
10
- <PopoverTrigger>
10
+ <PopoverTrigger class="w-full">
11
11
  <UnnnicInput
12
+ ref="selectInputRef"
12
13
  :modelValue="inputValue"
13
14
  class="unnnic-select__input"
14
15
  readonly
@@ -29,6 +30,7 @@
29
30
  align="start"
30
31
  :class="'h-full'"
31
32
  :style="popoverContentCustomStyles"
33
+ :width="inputWidthString"
32
34
  >
33
35
  <div class="unnnic-select__content">
34
36
  <UnnnicInput
@@ -67,6 +69,8 @@
67
69
 
68
70
  <script setup lang="ts">
69
71
  import { computed, ref, watch, nextTick } from 'vue';
72
+ import { useElementSize } from '@vueuse/core';
73
+
70
74
  import UnnnicInput from '../Input/Input.vue';
71
75
 
72
76
  import {
@@ -128,6 +132,12 @@ const emit = defineEmits<{
128
132
  }>();
129
133
 
130
134
  const openPopover = ref(false);
135
+ const selectInputRef = ref<HTMLInputElement | null>(null);
136
+ const { width: inputWidth } = useElementSize(selectInputRef);
137
+
138
+ const inputWidthString = computed(() => {
139
+ return `${inputWidth.value}px`;
140
+ });
131
141
 
132
142
  watch(openPopover, () => {
133
143
  if (!openPopover.value) {
@@ -19,8 +19,8 @@
19
19
  type="checkbox"
20
20
  :disabled="disabled"
21
21
  :checked="modelValue"
22
- @change="toggleState"
23
22
  v-bind="pick($attrs, ['id', 'name'])"
23
+ @change="toggleState"
24
24
  />
25
25
 
26
26
  <p
@@ -13,11 +13,11 @@
13
13
  }`"
14
14
  >
15
15
  <img
16
- class="unnnic-template-preview__header__media__preview"
17
16
  v-if="
18
17
  template?.header.type === 'MEDIA' &&
19
18
  template?.header.mediaType === 'IMAGE'
20
19
  "
20
+ class="unnnic-template-preview__header__media__preview"
21
21
  :src="template.header.src || imagePreview"
22
22
  />
23
23
  <template
@@ -50,8 +50,8 @@
50
50
  />
51
51
  </template>
52
52
  <h1
53
- class="unnnic-template-preview__header__text__preview"
54
53
  v-else-if="template?.header.type === 'TEXT'"
54
+ class="unnnic-template-preview__header__text__preview"
55
55
  >
56
56
  {{ template.header.text }}
57
57
  </h1>
@@ -1,10 +1,10 @@
1
1
  <template>
2
2
  <UnnnicModalDialog
3
3
  :modelValue="modelValue"
4
- @update:modelValue="$event === false && $emit('close')"
5
4
  :title="defaultTranslations.title[props.locale]"
6
5
  :showCloseIcon="true"
7
6
  class="unnnic-template-preview-modal"
7
+ @update:model-value="$event === false && $emit('close')"
8
8
  >
9
9
  <UnnnicTemplatePreview :template="template" />
10
10
  </UnnnicModalDialog>
@@ -17,8 +17,8 @@
17
17
  <template v-if="enableHtml">
18
18
  <!-- eslint-disable-next-line vue/no-v-html -->
19
19
  <section
20
- v-html="text"
21
20
  data-testid="tooltip-html-content"
21
+ v-html="text"
22
22
  ></section>
23
23
  </template>
24
24
  <template
@@ -2,14 +2,13 @@
2
2
  <PopoverPortal>
3
3
  <PopoverContent
4
4
  v-bind="{ ...forwarded, ...$attrs }"
5
+ :style="{ width: contentWidth, zIndex: popoverZIndex }"
5
6
  :class="
6
7
  cn(
7
8
  'unnnic-popover',
8
- `unnnic-popover--size-${props.size}`,
9
9
  'bg-popover text-popover-foreground outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',
10
10
  )
11
11
  "
12
- :style="{ zIndex: popoverZIndex }"
13
12
  >
14
13
  <section :class="`unnnic-popover__content ${props.class || ''}`">
15
14
  <component
@@ -45,7 +44,8 @@ const props = withDefaults(
45
44
  defineProps<
46
45
  PopoverContentProps & {
47
46
  class?: HTMLAttributes['class'];
48
- size?: 'small' | 'medium' | 'large';
47
+ size?: string;
48
+ width?: string;
49
49
  }
50
50
  >(),
51
51
  {
@@ -53,6 +53,7 @@ const props = withDefaults(
53
53
  sideOffset: 4,
54
54
  size: 'medium',
55
55
  class: '',
56
+ width: '',
56
57
  },
57
58
  );
58
59
  const emits = defineEmits<PopoverContentEmits>();
@@ -83,6 +84,18 @@ const footerChildren = computed(() => {
83
84
  (vnode: VNode) => getComponentName(vnode) === 'UnnnicPopoverFooter',
84
85
  );
85
86
  });
87
+
88
+ const contentWidth = computed(() => {
89
+ if (props.width) return props.width;
90
+
91
+ const sizes = {
92
+ small: '240px',
93
+ medium: '320px',
94
+ large: '400px',
95
+ };
96
+
97
+ return sizes[props.size as keyof typeof sizes];
98
+ });
86
99
  </script>
87
100
 
88
101
  <style lang="scss">
@@ -109,16 +122,6 @@ $popover-space: $unnnic-space-4;
109
122
  border-radius: $unnnic-border-radius-pill;
110
123
  }
111
124
 
112
- &--size-small {
113
- width: 240px;
114
- }
115
- &--size-medium {
116
- width: 320px;
117
- }
118
- &--size-large {
119
- width: 400px;
120
- }
121
-
122
125
  &__content {
123
126
  padding: $popover-space;
124
127
  }
@@ -76,7 +76,7 @@ const schemeColor = computed(() => {
76
76
  .unnnic-popover-option {
77
77
  cursor: pointer;
78
78
  border-radius: $unnnic-radius-2;
79
- padding: $unnnic-space-2;
79
+ padding: $unnnic-space-2 $unnnic-space-4;
80
80
  font: $unnnic-font-emphasis;
81
81
  display: flex;
82
82
  gap: $unnnic-space-2;
@@ -97,8 +97,10 @@ export default {
97
97
  };
98
98
  },
99
99
  template: `
100
- <p>modelValue: {{ exampleValue }}</p>
101
- <unnnic-multi-select v-model="exampleValue" v-bind="args" @update:search="handleSearch" />
100
+ <div style="width: 300px;">
101
+ <p>modelValue: {{ exampleValue }}</p>
102
+ <unnnic-multi-select v-model="exampleValue" v-bind="args" @update:search="handleSearch" />
103
+ </div>
102
104
  `,
103
105
  }),
104
106
  };
@@ -26,6 +26,11 @@ export default {
26
26
  },
27
27
  },
28
28
  argTypes: {
29
+ width: {
30
+ control: { type: 'text' },
31
+ description:
32
+ 'The width of the popover. This overrides the size prop. If not provided, the size prop will be used.',
33
+ },
29
34
  size: {
30
35
  control: { type: 'select' },
31
36
  options: ['small', 'medium', 'large'],
@@ -97,8 +97,11 @@ export default {
97
97
  };
98
98
  },
99
99
  template: `
100
- <p>modelValue: {{ exampleValue }}</p>
101
- <unnnic-select v-model="exampleValue" v-bind="args" @update:search="handleSearch" />
100
+ <div style="width: 300px;">
101
+ <p>modelValue: {{ exampleValue }}</p>
102
+ <unnnic-select v-model="exampleValue" v-bind="args" @update:search="handleSearch" />
103
+ </div>
104
+
102
105
  `,
103
106
  }),
104
107
  };