@xy-planning-network/trees 0.9.3-rc1 → 0.9.3-rc3

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.3-rc1",
3
+ "version": "0.9.3-rc3",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "repository": "github:xy-planning-network/trees",
@@ -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
- 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
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="inputValue"
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>
@@ -22,6 +22,9 @@ export interface DateRangeInput extends Input {
22
22
  maxRange?: number;
23
23
  startDate?: number;
24
24
  }
25
+ export interface DateTimeInput extends Input {
26
+ modelValue?: string | null;
27
+ }
25
28
  export interface TextLikeInput extends Input {
26
29
  modelValue?: string | number | null;
27
30
  type: TextInputType;
@@ -48,7 +51,8 @@ export declare const defaultInputProps: {
48
51
  modelValue: undefined;
49
52
  placeholder: string;
50
53
  };
51
- export type TextInputType = "date" | "datetime-local" | "email" | "month" | "number" | "password" | "search" | "tel" | "text" | "time" | "url" | "week";
54
+ export declare const textInputTypes: readonly ["date", "email", "month", "number", "password", "search", "tel", "text", "time", "url", "week"];
55
+ export type TextInputType = (typeof textInputTypes)[number];
52
56
  /**
53
57
  * useInputField provides a number of computed values, refs, and methods to support
54
58
  * wiring up reactive inputs.
package/types/entry.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { Plugin } from "vue";
2
2
  import BaseAPI, { isHttpCancel, isHttpError, setBaseAPIDefaults } from "./api/base";
3
3
  import type { HttpPromise, HttpError, QueryParams, ReqOptions, ReqPayload, TrailsPromise, TrailsPromisePaged, TrailsResp, TrailsRespPaged } from "./api/client";
4
- import { emailPattern, looseToNumber, phonePattern, useInputField } from "./composables/forms";
4
+ import type * as InputTypes from "./composables/forms";
5
+ import { emailPattern, looseToNumber, phonePattern, textInputTypes, useInputField } from "./composables/forms";
5
6
  import { useModel } from "./composables/setupHelpers";
6
7
  import { debounce as debounceFn, debounceLeading } from "./helpers/Debounce";
7
8
  import { throttle as throttleFn } from "./helpers/Throttle";
@@ -11,6 +12,7 @@ export * from "./composables/index";
11
12
  export * from "./lib-components/index";
12
13
  export { BaseAPI, isHttpCancel, isHttpError, setBaseAPIDefaults };
13
14
  export type { HttpPromise, HttpError, QueryParams, ReqOptions, ReqPayload, TrailsPromise, TrailsPromisePaged, TrailsResp, TrailsRespPaged, };
14
- export { emailPattern, looseToNumber, phonePattern, useInputField };
15
+ export type { InputTypes };
16
+ export { emailPattern, looseToNumber, phonePattern, textInputTypes, useInputField, };
15
17
  export { useModel };
16
18
  export { debounceFn, debounceLeading, throttleFn };
@@ -4,7 +4,7 @@ declare const _default: import("vue").DefineComponent<{
4
4
  default: string;
5
5
  };
6
6
  type: {
7
- type: import("vue").PropType<import("../../composables/forms").TextInputType>;
7
+ type: import("vue").PropType<"number" | "time" | "text" | "search" | "date" | "email" | "month" | "password" | "tel" | "url" | "week">;
8
8
  required: true;
9
9
  };
10
10
  modelValue: {
@@ -30,7 +30,7 @@ declare const _default: import("vue").DefineComponent<{
30
30
  default: string;
31
31
  };
32
32
  type: {
33
- type: import("vue").PropType<import("../../composables/forms").TextInputType>;
33
+ type: import("vue").PropType<"number" | "time" | "text" | "search" | "date" | "email" | "month" | "password" | "tel" | "url" | "week">;
34
34
  required: true;
35
35
  };
36
36
  modelValue: {
@@ -0,0 +1,47 @@
1
+ declare const _default: import("vue").DefineComponent<{
2
+ label: {
3
+ type: import("vue").PropType<string>;
4
+ default: string;
5
+ };
6
+ modelValue: {
7
+ type: import("vue").PropType<string | null>;
8
+ default: undefined;
9
+ };
10
+ help: {
11
+ type: import("vue").PropType<string>;
12
+ default: string;
13
+ };
14
+ placeholder: {
15
+ type: import("vue").PropType<string>;
16
+ default: string;
17
+ };
18
+ }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
19
+ "update:modelValue": (...args: any[]) => void;
20
+ "update:error": (...args: any[]) => void;
21
+ }, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
22
+ label: {
23
+ type: import("vue").PropType<string>;
24
+ default: string;
25
+ };
26
+ modelValue: {
27
+ type: import("vue").PropType<string | null>;
28
+ default: undefined;
29
+ };
30
+ help: {
31
+ type: import("vue").PropType<string>;
32
+ default: string;
33
+ };
34
+ placeholder: {
35
+ type: import("vue").PropType<string>;
36
+ default: string;
37
+ };
38
+ }>> & {
39
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
40
+ "onUpdate:error"?: ((...args: any[]) => any) | undefined;
41
+ }, {
42
+ label: string;
43
+ modelValue: string | null;
44
+ help: string;
45
+ placeholder: string;
46
+ }, {}>;
47
+ export default _default;
@@ -25,6 +25,7 @@ import { default as XYSpinner } from "./indicators/XYSpinner.vue";
25
25
  import { default as BaseInput } from "./forms/BaseInput.vue";
26
26
  import { default as Checkbox } from "./forms/Checkbox.vue";
27
27
  import { default as DateRangePicker } from "./forms/DateRangePicker.vue";
28
+ import { default as DateTime } from "./forms/DateTimeInput.vue";
28
29
  import { default as InputError } from "./forms/InputError.vue";
29
30
  import { default as InputHelp } from "./forms/InputHelp.vue";
30
31
  import { default as InputLabel } from "./forms/InputLabel.vue";
@@ -36,7 +37,7 @@ import { default as Select } from "./forms/Select.vue";
36
37
  import { default as TextArea } from "./forms/TextArea.vue";
37
38
  import { default as YesOrNoRadio } from "./forms/YesOrNoRadio.vue";
38
39
  export { ActionsDropdown, Cards, ContentModal, DateFilter, DetailList, DownloadCell, Flash, InlineAlert, Modal, SidebarLayout, Slideover, StackedLayout, Popover, PopoverContent, PopoverPosition, // Type export
39
- Paginator, Spinner, DataTable, Steps, DynamicTable, Tabs, Toggle, Tooltip, BaseInput, Checkbox, DateRangePicker, InputError, InputHelp, InputLabel, FieldsetLegend, MultiCheckboxes, Radio, RadioCards, Select, TextArea, YesOrNoRadio, XYSpinner, };
40
+ Paginator, Spinner, DataTable, Steps, DynamicTable, Tabs, Toggle, Tooltip, BaseInput, Checkbox, DateRangePicker, DateTime, InputError, InputHelp, InputLabel, FieldsetLegend, MultiCheckboxes, Radio, RadioCards, Select, TextArea, YesOrNoRadio, XYSpinner, };
40
41
  /**
41
42
  * declare global component types for App.use(Trees)
42
43
  */
@@ -65,6 +66,7 @@ export interface TreesComponents {
65
66
  BaseInput: typeof BaseInput;
66
67
  Checkbox: typeof Checkbox;
67
68
  DateRangePicker: typeof DateRangePicker;
69
+ DateTime: typeof DateTime;
68
70
  InputError: typeof InputError;
69
71
  InputHelp: typeof InputHelp;
70
72
  InputLabel: typeof InputLabel;