@antify/ui 4.1.9 → 4.1.10

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,9 +1,11 @@
1
1
  <script lang="ts" setup>
2
2
  import {
3
- onMounted,
3
+ onMounted, computed,
4
4
  } from 'vue';
5
5
  import AntField from '../forms/AntField.vue';
6
6
  import AntBaseInput from './Elements/AntBaseInput.vue';
7
+ import AntButton from '../AntButton.vue';
8
+ import AntIcon from '../AntIcon.vue';
7
9
  import {
8
10
  Size,
9
11
  } from '../../enums/Size.enum';
@@ -17,11 +19,14 @@ import {
17
19
  useVModel,
18
20
  } from '@vueuse/core';
19
21
  import {
20
- InputState,
22
+ InputState, Grouped, State,
21
23
  } from '../../enums';
22
24
  import {
23
25
  BaseInputType,
24
26
  } from './Elements/__types';
27
+ import {
28
+ faMultiply,
29
+ } from '@fortawesome/free-solid-svg-icons';
25
30
 
26
31
  defineOptions({
27
32
  inheritAttrs: false,
@@ -48,6 +53,7 @@ const props = withDefaults(defineProps<{
48
53
  limiter?: boolean;
49
54
  max?: number;
50
55
  messages?: string[];
56
+ nullable?: boolean;
51
57
  }>(), {
52
58
  state: InputState.base,
53
59
  inputRef: null,
@@ -58,10 +64,12 @@ const props = withDefaults(defineProps<{
58
64
  type: TextInputType.text,
59
65
  limiter: false,
60
66
  messages: () => [],
67
+ nullable: false,
61
68
  });
62
69
 
63
70
  const _value = useVModel(props, 'modelValue', emit);
64
71
  const _inputRef = useVModel(props, 'inputRef', emit);
72
+ const _nullable = computed(() => props.nullable && _value.value);
65
73
 
66
74
  onMounted(() => {
67
75
  handleEnumValidation(props.size, Size, 'size');
@@ -82,20 +90,33 @@ onMounted(() => {
82
90
  :messages="messages"
83
91
  data-e2e="text-input"
84
92
  >
85
- <AntBaseInput
86
- v-model="_value"
87
- v-model:input-ref="_inputRef"
88
- :type="type as unknown as BaseInputType"
89
- wrapper-class="grow"
90
- :state="state"
91
- :size="size"
92
- :skeleton="skeleton"
93
- :disabled="disabled"
94
- :readonly="readonly"
95
- :placeholder="placeholder !== undefined ? placeholder : label"
96
- :show-icon="true"
97
- v-bind="$attrs"
98
- @validate="val => $emit('validate', val)"
99
- />
93
+ <div class="flex">
94
+ <AntBaseInput
95
+ v-model="_value"
96
+ v-model:input-ref="_inputRef"
97
+ :type="type as unknown as BaseInputType"
98
+ wrapper-class="grow"
99
+ :state="state"
100
+ :size="size"
101
+ :skeleton="skeleton"
102
+ :disabled="disabled"
103
+ :readonly="readonly"
104
+ :placeholder="placeholder !== undefined ? placeholder : label"
105
+ :show-icon="true"
106
+ v-bind="$attrs"
107
+ @validate="val => $emit('validate', val)"
108
+ :grouped="_nullable ? Grouped.left : Grouped.none"
109
+ />
110
+ <AntButton
111
+ v-if="_nullable"
112
+ :disabled="disabled"
113
+ :icon-left="faMultiply"
114
+ :grouped="Grouped.right"
115
+ :state="state as unknown as State"
116
+ :skeleton="skeleton"
117
+ :size="size"
118
+ @click="_value = null" data-e2e="clear-button"
119
+ />
120
+ </div>
100
121
  </AntField>
101
122
  </template>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antify/ui",
3
- "version": "4.1.9",
3
+ "version": "4.1.10",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "exports": {