Skip to content

Commit d930ad1

Browse files
committed
wip
1 parent cb8c57a commit d930ad1

7 files changed

Lines changed: 63 additions & 199 deletions

File tree

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,10 @@
11
<script setup lang="ts">
2-
import { DatePicker } from 'v-calendar'
2+
import { type MaskaDetail } from 'maska'
3+
import { vMaska } from 'maska/vue'
34
import { type Component, computed } from 'vue'
45
import { type Validatable } from '../composables/Validation'
56
import { type Day, day } from '../support/Day'
6-
import SInputBase, { type Color, type Size } from './SInputBase.vue'
7+
import SInputText, { type Color, type Size } from './SInputText.vue'
78
89
export type { Color, Size }
910
@@ -30,26 +31,25 @@ const emit = defineEmits<{
3031
}>()
3132
3233
const classes = computed(() => [
33-
props.size ?? 'small'
34+
props.block && 'block'
3435
])
3536
3637
const value = computed(() => {
3738
return props.modelValue ? day(props.modelValue).format('YYYY-MM-DD') : null
3839
})
3940
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)
41+
function onMaska(detail: MaskaDetail): void {
42+
if (!detail.unmasked) {
43+
emit('update:model-value', null)
44+
} else if (detail.completed) {
45+
emit('update:model-value', day(detail.masked))
46+
}
4847
}
4948
</script>
5049

5150
<template>
52-
<SInputBase
51+
<SInputText
52+
v-maska="{ mask: '####-##-##', eager: true, onMaska }"
5353
class="SInputDate"
5454
:class="classes"
5555
:size
@@ -58,136 +58,36 @@ function onBlur() {
5858
:note
5959
:info
6060
:help
61+
placeholder="YYYY-MM-DD"
6162
:check-icon
6263
:check-text
6364
:check-color
64-
:hide-error
65+
:disabled
66+
:tabindex
67+
:model-value="value"
6568
:validation
69+
:hide-error
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/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: 1 addition & 2 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"
@@ -117,7 +117,6 @@
117117
"punycode": "^2.3.1",
118118
"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",

0 commit comments

Comments
 (0)