epicmaxco / vuestic-ui

Vuestic UI is an open-source Vue 3 component library designed for rapid development, easy maintenance, and high accessibility. Maintained by Epicmax (@epicmaxco).
https://vuestic.dev
MIT License
3.45k stars 338 forks source link

[va-date] should support string as model value #1485

Open wossig opened 2 years ago

wossig commented 2 years ago

Vuestic-ui version: 1.3.4

Steps to reproduce https://codesandbox.io/s/gallant-khorana-gf1nl?file=/src/App.vue

What is the expected behavior? date input should support string as model value, in most scenarios which data come from the server by JSON, the date will be a plain string, with that says, we must covert string to Date manually in javascript, that's not makesence.

What is the current behavior?

Other information

asvae commented 2 years ago

Thanks. I see your point!


We have a couple of props (formatDate, parseDate), but I'm not sure if these achieve what we need to. Which is:

Should be something like this:

<va-date-input/ v-model="dateFromBackend" ...>
<p>{{dateFromBackend}}</p> <!-- 23.03.2022 -->

Also some props are missing descriptions in docs, so we can improve this as well in scope of this issue.

LighthouseKeeperYN commented 2 years ago

@asvae I think we could support ISO 8601 by dafault or go a hard (and painful) way and implement something like format parsing similar to moment. parseDate and formatDate actually looks redundant to me since you can achieve same result simply by handling value and input instead of using v-model.

m0ksem commented 2 years ago

parseDate and formatDate are ui methods, they are used to convert date to string in the input. We use Date object because it is universal, which can not be said about string.

Let's support strings made with JSON.parse() as modelValue as well as Date object.

m0ksem commented 2 years ago

Probably this is already implemented. Check if it works both for VaTimeInput and VaDateInput. Maybe this also must work for VaTimePicker and VaDatePicker.

Also, would be nice to have it implemented in scope of this task: https://github.com/epicmaxco/vuestic-ui/issues/1942

DM me for details.

m0ksem commented 2 years ago

See https://github.com/epicmaxco/vuestic-ui/issues/1942