Skip to content

Commit bfbc6f5

Browse files
committed
wip
1 parent a54aa7a commit bfbc6f5

File tree

8 files changed

+316
-414
lines changed

8 files changed

+316
-414
lines changed

client.d.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33

44
// this file contains public types which are exposed to external modules
55

6-
declare module 'v-calendar' {
7-
export * from 'v-calendar/dist/types/src/index.d.ts'
8-
export { default } from 'v-calendar/dist/types/src/index.d.ts'
9-
}
10-
116
interface NumberConstructor {
127
isFinite(value: unknown): value is number
138
isInteger(value: unknown): value is number

config/vite.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ export const baseConfig = {
5656
'html2canvas',
5757
'lodash-es',
5858
'markdown-it',
59+
'maska',
5960
'normalize.css',
6061
'ofetch',
6162
'pinia',
6263
'qs',
63-
'v-calendar',
6464
'vue',
6565
'vue-router'
6666
]

lib/components/SInputDate.vue

Lines changed: 28 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<script setup lang="ts">
2-
import { DatePicker } from 'v-calendar'
2+
import { type MaskaDetail } from 'maska'
33
import { type Component, computed } from 'vue'
44
import { type Validatable } from '../composables/Validation'
55
import { type Day, day } from '../support/Day'
6-
import SInputBase, { type Color, type Size } from './SInputBase.vue'
6+
import SInputText, { type Color, type Size } from './SInputText.vue'
77
88
export type { Color, Size }
99
@@ -30,26 +30,24 @@ const emit = defineEmits<{
3030
}>()
3131
3232
const classes = computed(() => [
33-
props.size ?? 'small'
33+
props.block && 'block'
3434
])
3535
3636
const value = computed(() => {
3737
return props.modelValue ? day(props.modelValue).format('YYYY-MM-DD') : null
3838
})
3939
40-
function emitInput(date?: string) {
41-
emit('update:model-value', date ? day(date) : null)
42-
}
43-
44-
function onBlur() {
45-
setTimeout(() => {
46-
props.validation && props.validation.$touch()
47-
}, 100)
40+
function onChange(detail: MaskaDetail): void {
41+
if (!detail.unmasked) {
42+
emit('update:model-value', null)
43+
} else if (detail.completed) {
44+
emit('update:model-value', day(detail.masked))
45+
}
4846
}
4947
</script>
5048

5149
<template>
52-
<SInputBase
50+
<SInputText
5351
class="SInputDate"
5452
:class="classes"
5553
:size
@@ -58,136 +56,38 @@ function onBlur() {
5856
:note
5957
:info
6058
:help
59+
placeholder="YYYY-MM-DD"
6160
:check-icon
6261
:check-text
6362
:check-color
64-
:hide-error
63+
:disabled
64+
:tabindex
65+
:model-value="value"
6566
:validation
67+
:hide-error
68+
:maska="{ mask: '####-##-##', eager: true }"
69+
@maska="onChange"
6670
>
67-
<div class="container">
68-
<DatePicker
69-
v-slot="{ inputValue, inputEvents }"
70-
color="blue"
71-
is-dark
72-
:masks="{ input: 'YYYY-MM-DD' }"
73-
:model-config="{ type: 'string', mask: 'YYYY-MM-DD' }"
74-
:popover="{ placement: 'bottom', visibility: 'click' }"
75-
:model-value="value"
76-
@update:model-value="emitInput"
77-
>
78-
<input
79-
:id="name"
80-
class="input"
81-
:class="{ block, disabled }"
82-
type="text"
83-
placeholder="YYYY-MM-DD"
84-
autocomplete="off"
85-
:value="inputValue"
86-
:disabled
87-
:tabindex
88-
v-on="disabled ? {} : inputEvents"
89-
@blur="onBlur"
90-
>
91-
</DatePicker>
92-
</div>
9371
<template v-if="$slots.info" #info><slot name="info" /></template>
94-
</SInputBase>
72+
</SInputText>
9573
</template>
9674

9775
<style lang="postcss" scoped>
98-
.SInputDate.sm,
99-
.SInputDate.mini {
100-
.input {
101-
padding: 3px 8px;
102-
max-width: 114px;
103-
height: 32px;
104-
line-height: 24px;
105-
font-size: var(--input-font-size, var(--input-mini-font-size));
106-
}
107-
108-
.input.block {
109-
max-width: 100%;
110-
}
76+
.SInputDate.sm :deep(.box),
77+
.SInputDate.mini :deep(.box) {
78+
max-width: 114px;
11179
}
11280
113-
.SInputDate.md {
114-
.input {
115-
padding: 6px 10px;
116-
max-width: 120px;
117-
height: 36px;
118-
line-height: 24px;
119-
font-size: var(--input-font-size, var(--input-small-font-size));
120-
}
121-
122-
.input.block {
123-
max-width: 100%;
124-
}
81+
.SInputDate.md :deep(.box) {
82+
max-width: 120px;
12583
}
12684
127-
.SInputDate.small {
128-
.input {
129-
padding: 5px 12px;
130-
max-width: 136px;
131-
height: 40px;
132-
line-height: 24px;
133-
font-size: var(--input-font-size, 14px);
134-
}
135-
136-
.input.block {
137-
max-width: 100%;
138-
}
85+
.SInputDate.small :deep(.box),
86+
.SInputDate.medium :deep(.box) {
87+
max-width: 136px;
13988
}
14089
141-
.SInputDate.medium {
142-
.input {
143-
padding: 11px 12px;
144-
max-width: 136px;
145-
height: 48px;
146-
line-height: 24px;
147-
font-size: var(--input-font-size, var(--input-medium-font-size));
148-
}
149-
150-
.input.block {
151-
max-width: 100%;
152-
}
153-
}
154-
155-
.SInputDate.has-error {
156-
.input {
157-
border-color: var(--input-error-border-color);
158-
159-
&:focus {
160-
border-color: var(--input-error-border-color);
161-
}
162-
}
163-
}
164-
165-
.input {
166-
display: block;
167-
border: 1px solid var(--input-border-color);
168-
border-radius: 6px;
169-
width: 100%;
170-
font-weight: 400;
171-
font-feature-settings: 'tnum';
172-
background-color: var(--input-bg-color);
173-
transition: border-color 0.25s, background-color 0.25s;
174-
175-
&::placeholder {
176-
color: var(--input-placeholder-color);
177-
}
178-
179-
&:hover {
180-
border-color: var(--input-hover-border-color);
181-
}
182-
183-
&:focus {
184-
border-color: var(--input-focus-border-color);
185-
}
186-
187-
&.disabled {
188-
border-color: var(--input-disabled-border-color);
189-
background-color: var(--input-disabled-bg-color);
190-
cursor: not-allowed;
191-
}
90+
.SInputDate.block :deep(.box) {
91+
max-width: 100%;
19292
}
19393
</style>

lib/components/SInputText.vue

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<script setup lang="ts">
2+
import { type MaskInputOptions, type MaskaDetail } from 'maska'
3+
import { vMaska } from 'maska/vue'
24
import { type Component, computed, ref } from 'vue'
35
import SInputBase, { type Props as BaseProps } from './SInputBase.vue'
46
@@ -8,6 +10,7 @@ export interface Props extends BaseProps {
810
placeholder?: string
911
unitBefore?: Component | string
1012
unitAfter?: Component | string
13+
maska?: string | MaskInputOptions
1114
textColor?: TextColor | ((value: string | null) => TextColor)
1215
align?: Align
1316
disabled?: boolean
@@ -26,6 +29,7 @@ const emit = defineEmits<{
2629
'input': [value: string | null]
2730
'blur': [value: string | null]
2831
'enter': [value: string | null]
32+
'maska': [detail: MaskaDetail]
2933
}>()
3034
3135
const input = ref<HTMLElement | null>(null)
@@ -77,9 +81,10 @@ function emitBlur(e: FocusEvent): void {
7781
}
7882
7983
function emitInput(e: Event): void {
80-
const v = getValue(e)
81-
emit('update:model-value', v)
82-
emit('input', v)
84+
const value = getValue(e)
85+
86+
emit('update:model-value', value)
87+
emit('input', value)
8388
}
8489
8590
function emitEnter(e: KeyboardEvent): void {
@@ -91,6 +96,10 @@ function emitEnter(e: KeyboardEvent): void {
9196
emit('enter', value)
9297
}
9398
99+
function emitMaska(e: CustomEvent<MaskaDetail>): void {
100+
emit('maska', e.detail)
101+
}
102+
94103
function getValue(e: Event | FocusEvent | KeyboardEvent): string | null {
95104
const value = (e.target as HTMLInputElement).value
96105
@@ -131,6 +140,7 @@ function getValue(e: Event | FocusEvent | KeyboardEvent): string | null {
131140
<input
132141
:id="name"
133142
ref="input"
143+
v-maska="maska"
134144
class="input entity"
135145
:class="inputClasses"
136146
:type="type ?? 'text'"
@@ -142,6 +152,7 @@ function getValue(e: Event | FocusEvent | KeyboardEvent): string | null {
142152
@blur="emitBlur"
143153
@input="emitInput"
144154
@keypress.enter="emitEnter"
155+
@maska="emitMaska"
145156
>
146157
<div v-if="showDisplay" class="input display" :class="[textColor]">
147158
{{ displayValue }}

lib/styles/bootstrap.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
@import "normalize.css";
2-
@import "v-calendar/dist/style.css";
32
@import "./variables-deprecated.css";
43
@import "./variables.css";
54
@import "./base.css";

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
"pinia": "^3.0.4",
6363
"postcss": "^8.5.6",
6464
"postcss-nested": "^7.0.2",
65-
"v-calendar": "3.0.1",
6665
"vue": "^3.5.26",
6766
"vue-router": "^4.6.4"
6867
},
@@ -80,6 +79,7 @@
8079
"file-saver": "^2.0.5",
8180
"html2canvas": "^1.4.1",
8281
"magic-string": "^0.30.21",
82+
"maska": "^3.2.0",
8383
"ofetch": "^1.5.1",
8484
"qs": "^6.14.1",
8585
"unplugin-icons": "^22.5.0"
@@ -115,14 +115,13 @@
115115
"postcss": "^8.5.6",
116116
"postcss-nested": "^7.0.2",
117117
"punycode": "^2.3.1",
118-
"release-it": "^19.2.2",
118+
"release-it": "^19.2.3",
119119
"typescript": "~5.9.3",
120-
"v-calendar": "3.0.1",
121120
"vite": "^6.4.1",
122121
"vitepress": "^2.0.0-alpha.15",
123122
"vitest": "^3.2.4",
124123
"vue": "^3.5.26",
125124
"vue-router": "^4.6.4",
126-
"vue-tsc": "^3.2.1"
125+
"vue-tsc": "^3.2.2"
127126
}
128127
}

0 commit comments

Comments
 (0)