@xy-planning-network/trees 0.9.3-rc1 → 0.9.3-rc2
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/package.json
CHANGED
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
emailPattern,
|
|
9
9
|
looseToNumber,
|
|
10
10
|
phonePattern,
|
|
11
|
-
toDatetimeLocal,
|
|
12
11
|
} from "@/composables/forms"
|
|
13
12
|
import type { TextLikeInput } from "@/composables/forms"
|
|
14
13
|
import { computed, ref } from "vue"
|
|
@@ -58,28 +57,14 @@ const typeAttributes = computed(() => {
|
|
|
58
57
|
const onInput = (e: Event) => {
|
|
59
58
|
let val = (e.target as HTMLInputElement).value
|
|
60
59
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
val = val ? new Date(val).toISOString() : val
|
|
64
|
-
break
|
|
65
|
-
case "number":
|
|
66
|
-
val = looseToNumber(val)
|
|
67
|
-
break
|
|
60
|
+
if (props.type === "number") {
|
|
61
|
+
val = looseToNumber(val)
|
|
68
62
|
}
|
|
69
63
|
|
|
70
64
|
modelState.value = val
|
|
71
65
|
|
|
72
66
|
inputValidation(e)
|
|
73
67
|
}
|
|
74
|
-
|
|
75
|
-
const inputValue = computed(() => {
|
|
76
|
-
switch (props.type) {
|
|
77
|
-
case "datetime-local":
|
|
78
|
-
return toDatetimeLocal(modelState.value)
|
|
79
|
-
default:
|
|
80
|
-
return modelState.value
|
|
81
|
-
}
|
|
82
|
-
})
|
|
83
68
|
</script>
|
|
84
69
|
|
|
85
70
|
<template>
|
|
@@ -106,7 +91,7 @@ const inputValue = computed(() => {
|
|
|
106
91
|
]"
|
|
107
92
|
:placeholder="placeholder"
|
|
108
93
|
:type="type"
|
|
109
|
-
:value="
|
|
94
|
+
:value="modelState"
|
|
110
95
|
v-bind="{ ...typeAttributes, ...$attrs }"
|
|
111
96
|
@input="onInput"
|
|
112
97
|
@invalid="onInvalid"
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import InputLabel from "./InputLabel.vue"
|
|
3
|
+
import InputHelp from "./InputHelp.vue"
|
|
4
|
+
import InputError from "./InputError.vue"
|
|
5
|
+
import {
|
|
6
|
+
useInputField,
|
|
7
|
+
defaultInputProps,
|
|
8
|
+
toDatetimeLocal,
|
|
9
|
+
} from "@/composables/forms"
|
|
10
|
+
import type { DateTimeInput } from "@/composables/forms"
|
|
11
|
+
import { computed, ref } from "vue"
|
|
12
|
+
|
|
13
|
+
defineOptions({
|
|
14
|
+
inheritAttrs: false,
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
const props = withDefaults(defineProps<DateTimeInput>(), defaultInputProps)
|
|
18
|
+
|
|
19
|
+
defineEmits(["update:modelValue", "update:error"])
|
|
20
|
+
const input = ref<HTMLInputElement | null>(null)
|
|
21
|
+
const {
|
|
22
|
+
errorState,
|
|
23
|
+
modelState,
|
|
24
|
+
inputID,
|
|
25
|
+
isRequired,
|
|
26
|
+
onInvalid,
|
|
27
|
+
inputValidation,
|
|
28
|
+
} = useInputField(props)
|
|
29
|
+
|
|
30
|
+
const inputValue = computed(() => toDatetimeLocal(modelState.value))
|
|
31
|
+
|
|
32
|
+
const onInput = (e: Event) => {
|
|
33
|
+
let val = (e.target as HTMLInputElement).value
|
|
34
|
+
|
|
35
|
+
modelState.value = val ? new Date(val).toISOString() : val
|
|
36
|
+
|
|
37
|
+
inputValidation(e)
|
|
38
|
+
}
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<template>
|
|
42
|
+
<div>
|
|
43
|
+
<InputLabel
|
|
44
|
+
:id="`${inputID}-label`"
|
|
45
|
+
class="mb-2"
|
|
46
|
+
:for="inputID"
|
|
47
|
+
:label="label"
|
|
48
|
+
:required="isRequired"
|
|
49
|
+
/>
|
|
50
|
+
<input
|
|
51
|
+
:id="inputID"
|
|
52
|
+
ref="input"
|
|
53
|
+
:aria-labelledby="label ? `${inputID}-label` : undefined"
|
|
54
|
+
:aria-describedby="help ? `${inputID}-help` : undefined"
|
|
55
|
+
:aria-errormessage="errorState ? `${inputID}-error` : undefined"
|
|
56
|
+
:class="[
|
|
57
|
+
'block w-full rounded-md border-0 py-2 shadow-sm ring-1 ring-inset focus:ring-2 sm:text-sm sm:leading-6',
|
|
58
|
+
'disabled:cursor-not-allowed disabled:bg-gray-50 disabled:text-gray-700 disabled:ring-gray-200',
|
|
59
|
+
errorState
|
|
60
|
+
? 'text-red-900 ring-red-700 placeholder:text-red-300 focus:ring-red-700'
|
|
61
|
+
: 'text-gray-900 ring-gray-300 placeholder:text-gray-400 focus:ring-xy-blue-500',
|
|
62
|
+
]"
|
|
63
|
+
:placeholder="placeholder"
|
|
64
|
+
type="datetime-local"
|
|
65
|
+
:value="inputValue"
|
|
66
|
+
v-bind="$attrs"
|
|
67
|
+
@input="onInput"
|
|
68
|
+
@invalid="onInvalid"
|
|
69
|
+
/>
|
|
70
|
+
<InputHelp :id="`${inputID}-help`" class="mt-1" :text="help" />
|
|
71
|
+
<InputError :id="`${inputID}-error`" class="mt-0.5" :text="errorState" />
|
|
72
|
+
</div>
|
|
73
|
+
</template>
|