@xy-planning-network/trees 0.9.2-rc4 → 0.9.3-rc1

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xy-planning-network/trees",
3
- "version": "0.9.2-rc4",
3
+ "version": "0.9.3-rc1",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "repository": "github:xy-planning-network/trees",
@@ -8,6 +8,7 @@ import {
8
8
  emailPattern,
9
9
  looseToNumber,
10
10
  phonePattern,
11
+ toDatetimeLocal,
11
12
  } from "@/composables/forms"
12
13
  import type { TextLikeInput } from "@/composables/forms"
13
14
  import { computed, ref } from "vue"
@@ -57,14 +58,28 @@ const typeAttributes = computed(() => {
57
58
  const onInput = (e: Event) => {
58
59
  let val = (e.target as HTMLInputElement).value
59
60
 
60
- if (props.type === "number") {
61
- val = looseToNumber(val)
61
+ switch (props.type) {
62
+ case "datetime-local":
63
+ val = val ? new Date(val).toISOString() : val
64
+ break
65
+ case "number":
66
+ val = looseToNumber(val)
67
+ break
62
68
  }
63
69
 
64
70
  modelState.value = val
65
71
 
66
72
  inputValidation(e)
67
73
  }
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
+ })
68
83
  </script>
69
84
 
70
85
  <template>
@@ -91,7 +106,7 @@ const onInput = (e: Event) => {
91
106
  ]"
92
107
  :placeholder="placeholder"
93
108
  :type="type"
94
- :value="modelState"
109
+ :value="inputValue"
95
110
  v-bind="{ ...typeAttributes, ...$attrs }"
96
111
  @input="onInput"
97
112
  @invalid="onInvalid"
@@ -96,3 +96,10 @@ export declare const phonePattern: string;
96
96
  * This is used for the .number modifier in v-model
97
97
  */
98
98
  export declare const looseToNumber: (val: any) => any;
99
+ /**
100
+ * converts an RFC 3339 string to a datetime-local input value string
101
+ * used with BaseInput<type=datetime-local> as a v-model modifier
102
+ * @param dt RFC 3339 date string
103
+ * @returns string
104
+ */
105
+ export declare const toDatetimeLocal: (dt: any) => string;
@@ -0,0 +1,68 @@
1
+ declare const _default: import("vue").DefineComponent<{
2
+ title: {
3
+ type: import("vue").PropType<string>;
4
+ default: string;
5
+ };
6
+ modelValue: {
7
+ type: import("vue").PropType<boolean>;
8
+ required: true;
9
+ };
10
+ content: {
11
+ type: import("vue").PropType<string | string[]>;
12
+ required: true;
13
+ };
14
+ kind: {
15
+ type: import("vue").PropType<"alert" | "warn" | "info" | "success">;
16
+ required: true;
17
+ };
18
+ sticky: {
19
+ type: import("vue").PropType<boolean>;
20
+ default: boolean;
21
+ };
22
+ cancelText: {
23
+ type: import("vue").PropType<string>;
24
+ default: string;
25
+ };
26
+ submitText: {
27
+ type: import("vue").PropType<string>;
28
+ required: true;
29
+ };
30
+ }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
31
+ submit: (e?: void | undefined) => void;
32
+ }, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
33
+ title: {
34
+ type: import("vue").PropType<string>;
35
+ default: string;
36
+ };
37
+ modelValue: {
38
+ type: import("vue").PropType<boolean>;
39
+ required: true;
40
+ };
41
+ content: {
42
+ type: import("vue").PropType<string | string[]>;
43
+ required: true;
44
+ };
45
+ kind: {
46
+ type: import("vue").PropType<"alert" | "warn" | "info" | "success">;
47
+ required: true;
48
+ };
49
+ sticky: {
50
+ type: import("vue").PropType<boolean>;
51
+ default: boolean;
52
+ };
53
+ cancelText: {
54
+ type: import("vue").PropType<string>;
55
+ default: string;
56
+ };
57
+ submitText: {
58
+ type: import("vue").PropType<string>;
59
+ required: true;
60
+ };
61
+ }>> & {
62
+ onSubmit?: ((e?: void | undefined) => any) | undefined;
63
+ }, {
64
+ title: string;
65
+ sticky: boolean;
66
+ cancelText: string;
67
+ }, {}>;
68
+ export default _default;