design-system-next 2.7.43 → 2.7.45
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/dist/design-system-next.js +4305 -4184
- package/dist/design-system-next.js.gz +0 -0
- package/dist/main.css +1 -1
- package/dist/main.css.gz +0 -0
- package/dist/package.json.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/date-picker/use-date-picker.ts +3 -10
- package/src/components/input/input.ts +6 -2
- package/src/components/input/input.vue +11 -6
- package/src/components/input/use-input.ts +33 -3
|
@@ -15,6 +15,8 @@ interface InputClasses {
|
|
|
15
15
|
prefixSlotClasses: string;
|
|
16
16
|
trailingSlotClasses: string;
|
|
17
17
|
helperClasses: string;
|
|
18
|
+
charCountClasses: string;
|
|
19
|
+
helperContainerClasses: string;
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
export const useInput = (
|
|
@@ -22,13 +24,21 @@ export const useInput = (
|
|
|
22
24
|
emit: SetupContext<InputEmitTypes>['emit'],
|
|
23
25
|
slots: Record<string, unknown>,
|
|
24
26
|
) => {
|
|
25
|
-
const { active, error, disabled, offsetSize } = toRefs(props);
|
|
27
|
+
const { active, error, disabled, offsetSize, showCharCount, maxLength } = toRefs(props);
|
|
26
28
|
|
|
27
29
|
const inputTextRef = ref(null);
|
|
28
30
|
|
|
29
31
|
const { focused } = useFocus(inputTextRef);
|
|
30
32
|
|
|
31
33
|
const modelValue = useVModel(props, 'modelValue', emit);
|
|
34
|
+
|
|
35
|
+
const currentLength = computed(() => {
|
|
36
|
+
return modelValue.value ? String(modelValue.value).length : 0;
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const hasCharLimit = computed(() => {
|
|
40
|
+
return maxLength.value !== undefined && maxLength.value > 0;
|
|
41
|
+
});
|
|
32
42
|
|
|
33
43
|
const inputClasses: ComputedRef<InputClasses> = computed(() => {
|
|
34
44
|
const baseClasses = classNames('spr-flex spr-flex-col spr-gap-size-spacing-4xs');
|
|
@@ -99,11 +109,19 @@ export const useInput = (
|
|
|
99
109
|
'spr-text-mushroom-300': !error.value,
|
|
100
110
|
'spr-text-tomato-600': error.value,
|
|
101
111
|
});
|
|
112
|
+
|
|
113
|
+
const helperContainerClasses = classNames('spr-flex spr-flex-row spr-items-start spr-justify-between spr-w-full', {
|
|
114
|
+
'spr-mt-1': showCharCount.value || props.displayHelper,
|
|
115
|
+
});
|
|
102
116
|
|
|
103
|
-
const helperClasses = classNames('spr-body-sm-regular spr-flex spr-items-center spr-gap-size-spacing-5xs', {
|
|
117
|
+
const helperClasses = classNames('spr-body-sm-regular spr-flex spr-items-center spr-gap-size-spacing-5xs spr-flex-1', {
|
|
104
118
|
'spr-text-color-danger-base': error.value,
|
|
105
119
|
'spr-text-color-supporting': !error.value,
|
|
106
120
|
});
|
|
121
|
+
|
|
122
|
+
const charCountClasses = classNames('spr-ml-auto spr-body-2xs-regular spr-text-right spr-text-xs spr-text-color-supporting', {
|
|
123
|
+
'spr-text-color-danger-base': hasCharLimit.value && currentLength.value >= (maxLength.value || 0),
|
|
124
|
+
});
|
|
107
125
|
|
|
108
126
|
return {
|
|
109
127
|
baseClasses,
|
|
@@ -114,11 +132,21 @@ export const useInput = (
|
|
|
114
132
|
prefixSlotClasses,
|
|
115
133
|
trailingSlotClasses,
|
|
116
134
|
helperClasses,
|
|
135
|
+
charCountClasses,
|
|
136
|
+
helperContainerClasses,
|
|
117
137
|
};
|
|
118
138
|
});
|
|
119
139
|
|
|
120
140
|
const onInput = (event: Event) => {
|
|
121
|
-
|
|
141
|
+
const target = event.target as HTMLInputElement;
|
|
142
|
+
let value: string | number = target.value;
|
|
143
|
+
|
|
144
|
+
// Convert to number if type is number
|
|
145
|
+
if (props.type === 'number' && value !== '') {
|
|
146
|
+
value = Number(value);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
modelValue.value = value;
|
|
122
150
|
};
|
|
123
151
|
|
|
124
152
|
const disableClickEvent = (event: Event) => {
|
|
@@ -133,5 +161,7 @@ export const useInput = (
|
|
|
133
161
|
inputClasses,
|
|
134
162
|
onInput,
|
|
135
163
|
disableClickEvent,
|
|
164
|
+
currentLength,
|
|
165
|
+
hasCharLimit,
|
|
136
166
|
};
|
|
137
167
|
};
|