@antify/ui 3.1.2 → 3.1.4

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.
@@ -1,15 +1,12 @@
1
1
  <script lang="ts" setup>
2
2
  import {
3
- computed, ref,
3
+ computed, onMounted, ref,
4
4
  } from 'vue';
5
5
  import {
6
6
  classesToObjectSyntax,
7
7
  } from '../utils';
8
8
  import {
9
- vOnClickOutside,
10
- } from '@vueuse/components';
11
- import {
12
- onKeyStroke,
9
+ onKeyStroke, onClickOutside,
13
10
  } from '@vueuse/core';
14
11
  import {
15
12
  autoUpdate, flip, offset, useFloating, shift,
@@ -20,10 +17,12 @@ const props = withDefaults(defineProps<{
20
17
  dropdownClasses?: string | Record<string, boolean>;
21
18
  contentPadding?: boolean;
22
19
  isClickable?: boolean;
20
+ expanded?: boolean;
23
21
  }>(), {
24
22
  contentPadding: true,
25
23
  dropdownClasses: '',
26
24
  isClickable: true,
25
+ expanded: false,
27
26
  });
28
27
  const emit = defineEmits([
29
28
  'update:showDropdown',
@@ -61,26 +60,30 @@ onKeyStroke('Escape', (e: KeyboardEvent) => {
61
60
  }
62
61
  });
63
62
 
64
- const onClickOutside = [
65
- () => {
63
+ onMounted(() => {
64
+ onClickOutside(reference, () => {
66
65
  emit('update:showDropdown', false);
67
- },
68
- {
66
+ }, {
69
67
  ignore: [
70
68
  floating,
71
69
  ],
72
- },
73
- ];
70
+ });
71
+ });
74
72
  </script>
75
73
 
76
74
  <template>
77
75
  <div
78
76
  class="relative flex"
79
77
  data-e2e="dropdown"
78
+ :class="{
79
+ 'w-full': expanded,
80
+ }"
80
81
  >
81
82
  <div
82
83
  ref="reference"
83
- v-on-click-outside="onClickOutside"
84
+ :class="{
85
+ 'w-full': expanded,
86
+ }"
84
87
  >
85
88
  <slot />
86
89
  </div>
@@ -5,9 +5,6 @@ import {
5
5
  import {
6
6
  AntField,
7
7
  } from './Elements';
8
- import {
9
- useVModel,
10
- } from '@vueuse/core';
11
8
  import AntCheckbox from './AntCheckbox.vue';
12
9
  import {
13
10
  computed, onMounted, ref, watch,
@@ -48,7 +45,6 @@ const props = withDefaults(
48
45
  messages: () => [],
49
46
  },
50
47
  );
51
- const _modelValue = useVModel(props, 'modelValue', emit);
52
48
  const containerClasses = computed(() => ({
53
49
  'flex gap-2.5': true,
54
50
  'flex-row': props.direction === Direction.row,
@@ -56,7 +52,7 @@ const containerClasses = computed(() => ({
56
52
  }));
57
53
  const containerRef = ref<null | HTMLElement>(null);
58
54
 
59
- watch(_modelValue, (val) => {
55
+ watch(() => props.modelValue, (val) => {
60
56
  if ([
61
57
  InputState.danger,
62
58
  InputState.warning,
@@ -74,18 +70,21 @@ watch(() => props.skeleton, (val) => {
74
70
  });
75
71
 
76
72
  function updateValue(value: string) {
77
- if (_modelValue.value === null) {
78
- return _modelValue.value = [
73
+ if (props.modelValue === null) {
74
+ return emit('update:modelValue', [
79
75
  value,
80
- ];
76
+ ]);
81
77
  }
82
78
 
83
- const index = _modelValue.value.indexOf(value);
79
+ const index = props.modelValue.indexOf(value);
84
80
 
85
81
  if (index === -1) {
86
- _modelValue.value.push(value);
82
+ emit('update:modelValue', [
83
+ ...(props.modelValue || []),
84
+ value,
85
+ ]);
87
86
  } else {
88
- _modelValue.value.splice(index, 1);
87
+ emit('update:modelValue', (props.modelValue || []).filter((item, i) => i !== index));
89
88
  }
90
89
  }
91
90
 
@@ -96,7 +95,7 @@ function hasFocusedCheckbox() {
96
95
  function onBlurCheckbox() {
97
96
  setTimeout(() => {
98
97
  if (!hasFocusedCheckbox()) {
99
- emit('validate', _modelValue.value);
98
+ emit('validate', props.modelValue);
100
99
  }
101
100
  }, 100);
102
101
  }
@@ -126,7 +125,7 @@ onMounted(() => {
126
125
  <AntCheckbox
127
126
  v-for="(checkbox, index) in checkboxes"
128
127
  :key="`checkbox-group-${index}`"
129
- :model-value="_modelValue !== null ? _modelValue?.indexOf(checkbox.value) !== -1 : null"
128
+ :model-value="modelValue !== null ? modelValue?.indexOf(checkbox.value) !== -1 : null"
130
129
  :size="size"
131
130
  :state="state"
132
131
  :skeleton="skeleton"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antify/ui",
3
- "version": "3.1.2",
3
+ "version": "3.1.4",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "exports": {