@sfxcode/nuxt-ui-formkit 1.2.0 → 1.2.2
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/README.md +25 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/components/FUAutoForm.d.vue.ts +65 -0
- package/dist/runtime/components/FUAutoForm.vue +59 -0
- package/dist/runtime/components/FUAutoForm.vue.d.ts +65 -0
- package/dist/runtime/components/FUDataEdit.d.vue.ts +1 -1
- package/dist/runtime/components/FUDataEdit.vue.d.ts +1 -1
- package/dist/runtime/components/FUDataView.d.vue.ts +1 -1
- package/dist/runtime/components/FUDataView.vue.d.ts +1 -1
- package/dist/runtime/components/inputs/FUCalendar.d.vue.ts +15 -5
- package/dist/runtime/components/inputs/FUCalendar.vue +16 -4
- package/dist/runtime/components/inputs/FUCalendar.vue.d.ts +15 -5
- package/dist/runtime/components/inputs/FUInputDate.d.vue.ts +18 -5
- package/dist/runtime/components/inputs/FUInputDate.vue +24 -6
- package/dist/runtime/components/inputs/FUInputDate.vue.d.ts +18 -5
- package/dist/runtime/composables/useFormKitAutoForm.d.ts +38 -0
- package/dist/runtime/composables/useFormKitAutoForm.js +349 -0
- package/dist/runtime/composables/useFormKitForm.d.ts +11 -0
- package/dist/runtime/composables/useFormKitForm.js +38 -0
- package/dist/runtime/composables/useFormKitMultiStep.d.ts +5 -0
- package/dist/runtime/composables/useFormKitMultiStep.js +65 -0
- package/dist/runtime/composables/useFormKitRepeater.d.ts +4 -0
- package/dist/runtime/composables/useFormKitRepeater.js +138 -0
- package/dist/runtime/formkit/createNuxtUiFormkitConfig.d.ts +19 -0
- package/dist/runtime/formkit/createNuxtUiFormkitConfig.js +12 -0
- package/dist/runtime/formkit/createNuxtUiFormkitConfig.mjs +12 -0
- package/dist/runtime/formkit/definitions/index.d.ts +3 -0
- package/dist/runtime/formkit/definitions/index.js +4 -0
- package/dist/runtime/formkit/definitions/index.mjs +4 -0
- package/dist/runtime/formkit/definitions/input.js +2 -2
- package/dist/runtime/formkit/definitions/input.mjs +2 -2
- package/dist/runtime/formkit/definitions/multiStep.d.ts +3 -0
- package/dist/runtime/formkit/definitions/multiStep.js +90 -0
- package/dist/runtime/formkit/definitions/multiStep.mjs +90 -0
- package/dist/runtime/formkit/definitions/repeater.js +3 -119
- package/dist/runtime/formkit/definitions/repeater.mjs +3 -119
- package/dist/runtime/formkit/index.d.ts +10 -0
- package/dist/runtime/formkit/index.js +1 -0
- package/dist/runtime/formkit/index.mjs +1 -0
- package/dist/runtime/formkit/plugins/index.d.ts +1 -0
- package/dist/runtime/formkit/plugins/index.js +1 -0
- package/dist/runtime/formkit/plugins/index.mjs +1 -0
- package/dist/runtime/plugin.js +2 -1
- package/dist/runtime/utils/dateValueConversion.d.ts +36 -0
- package/dist/runtime/utils/dateValueConversion.js +80 -0
- package/package.json +6 -3
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { DateValue } from '@internationalized/date';
|
|
2
|
+
import { CalendarDate, CalendarDateTime, ZonedDateTime } from '@internationalized/date';
|
|
3
|
+
export type DateValueType = 'calendar' | 'date' | 'iso';
|
|
4
|
+
export interface DateConversionOptions {
|
|
5
|
+
granularity?: 'day' | 'hour' | 'minute' | 'second';
|
|
6
|
+
hideTimeZone?: boolean;
|
|
7
|
+
timeZone?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function isDateValue(value: unknown): value is DateValue;
|
|
10
|
+
/**
|
|
11
|
+
* Converts an external value (JS `Date`, ISO 8601 string, or an already-native
|
|
12
|
+
* `DateValue`) into the `DateValue` that `UInputDate`/`UCalendar` require.
|
|
13
|
+
*/
|
|
14
|
+
export declare function toDateValue(value: unknown, options?: DateConversionOptions): DateValue | undefined;
|
|
15
|
+
/** Same as {@link toDateValue}, but also handles the `{ start, end }` range shape. */
|
|
16
|
+
export declare function toDateValueOrRange(value: unknown, options?: DateConversionOptions): CalendarDate | CalendarDateTime | ZonedDateTime | {
|
|
17
|
+
start: DateValue | undefined;
|
|
18
|
+
end: DateValue | undefined;
|
|
19
|
+
} | undefined;
|
|
20
|
+
/** Same as {@link toDateValueOrRange}, but also handles arrays (multiple-selection mode). */
|
|
21
|
+
export declare function toDateValueOrRangeOrArray(value: unknown, options?: DateConversionOptions): CalendarDate | CalendarDateTime | ZonedDateTime | {
|
|
22
|
+
start: DateValue | undefined;
|
|
23
|
+
end: DateValue | undefined;
|
|
24
|
+
} | DateValue[] | undefined;
|
|
25
|
+
/** Converts a `DateValue` emitted by `UInputDate`/`UCalendar` back into the shape the form value should take. */
|
|
26
|
+
export declare function fromDateValue(value: DateValue | undefined, valueType: DateValueType, timeZone?: string): DateValue | Date | string | undefined;
|
|
27
|
+
/** Same as {@link fromDateValue}, but also handles the `{ start, end }` range shape. */
|
|
28
|
+
export declare function fromDateValueOrRange(value: unknown, valueType: DateValueType, timeZone?: string): string | CalendarDate | CalendarDateTime | ZonedDateTime | Date | {
|
|
29
|
+
start: string | DateValue | Date | undefined;
|
|
30
|
+
end: string | DateValue | Date | undefined;
|
|
31
|
+
} | undefined;
|
|
32
|
+
/** Same as {@link fromDateValueOrRange}, but also handles arrays (multiple-selection mode). */
|
|
33
|
+
export declare function fromDateValueOrRangeOrArray(value: unknown, valueType: DateValueType, timeZone?: string): string | CalendarDate | CalendarDateTime | ZonedDateTime | Date | {
|
|
34
|
+
start: string | DateValue | Date | undefined;
|
|
35
|
+
end: string | DateValue | Date | undefined;
|
|
36
|
+
} | (string | DateValue | Date | undefined)[] | undefined;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { CalendarDate, CalendarDateTime, ZonedDateTime, fromDate, getLocalTimeZone, parseAbsolute, parseDate, parseDateTime, toCalendarDate, toCalendarDateTime } from "@internationalized/date";
|
|
2
|
+
const ISO_DATE_ONLY = /^\d{4}-\d{2}-\d{2}$/;
|
|
3
|
+
const ISO_HAS_ZONE = /(?:Z|[+-]\d{2}:\d{2})(?:\[[^\]]+\])?$/;
|
|
4
|
+
export function isDateValue(value) {
|
|
5
|
+
return value instanceof CalendarDate || value instanceof CalendarDateTime || value instanceof ZonedDateTime;
|
|
6
|
+
}
|
|
7
|
+
function isRangeLike(value) {
|
|
8
|
+
return typeof value === "object" && value !== null && "start" in value && "end" in value;
|
|
9
|
+
}
|
|
10
|
+
export function toDateValue(value, options = {}) {
|
|
11
|
+
if (value === void 0 || value === null || value === "") {
|
|
12
|
+
return void 0;
|
|
13
|
+
}
|
|
14
|
+
if (isDateValue(value)) {
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
const timeZone = options.timeZone ?? getLocalTimeZone();
|
|
18
|
+
const withTime = options.granularity != null && options.granularity !== "day";
|
|
19
|
+
if (value instanceof Date) {
|
|
20
|
+
const zoned = fromDate(value, timeZone);
|
|
21
|
+
if (!withTime) {
|
|
22
|
+
return toCalendarDate(zoned);
|
|
23
|
+
}
|
|
24
|
+
return options.hideTimeZone ? toCalendarDateTime(zoned) : zoned;
|
|
25
|
+
}
|
|
26
|
+
if (typeof value === "string") {
|
|
27
|
+
if (!withTime && ISO_DATE_ONLY.test(value)) {
|
|
28
|
+
return parseDate(value);
|
|
29
|
+
}
|
|
30
|
+
if (withTime && !ISO_HAS_ZONE.test(value)) {
|
|
31
|
+
return parseDateTime(value);
|
|
32
|
+
}
|
|
33
|
+
const zoned = parseAbsolute(value, timeZone);
|
|
34
|
+
return withTime ? options.hideTimeZone ? toCalendarDateTime(zoned) : zoned : toCalendarDate(zoned);
|
|
35
|
+
}
|
|
36
|
+
return void 0;
|
|
37
|
+
}
|
|
38
|
+
export function toDateValueOrRange(value, options = {}) {
|
|
39
|
+
if (isRangeLike(value)) {
|
|
40
|
+
return {
|
|
41
|
+
start: toDateValue(value.start, options),
|
|
42
|
+
end: toDateValue(value.end, options)
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return toDateValue(value, options);
|
|
46
|
+
}
|
|
47
|
+
export function toDateValueOrRangeOrArray(value, options = {}) {
|
|
48
|
+
if (Array.isArray(value)) {
|
|
49
|
+
return value.map((item) => toDateValue(item, options)).filter((item) => item !== void 0);
|
|
50
|
+
}
|
|
51
|
+
return toDateValueOrRange(value, options);
|
|
52
|
+
}
|
|
53
|
+
export function fromDateValue(value, valueType, timeZone) {
|
|
54
|
+
if (value === void 0 || value === null) {
|
|
55
|
+
return void 0;
|
|
56
|
+
}
|
|
57
|
+
if (valueType === "calendar") {
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
const jsDate = value instanceof ZonedDateTime ? value.toDate() : value.toDate(timeZone ?? getLocalTimeZone());
|
|
61
|
+
if (valueType === "date") {
|
|
62
|
+
return jsDate;
|
|
63
|
+
}
|
|
64
|
+
return value.toString();
|
|
65
|
+
}
|
|
66
|
+
export function fromDateValueOrRange(value, valueType, timeZone) {
|
|
67
|
+
if (isRangeLike(value)) {
|
|
68
|
+
return {
|
|
69
|
+
start: fromDateValue(value.start, valueType, timeZone),
|
|
70
|
+
end: fromDateValue(value.end, valueType, timeZone)
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
return fromDateValue(value, valueType, timeZone);
|
|
74
|
+
}
|
|
75
|
+
export function fromDateValueOrRangeOrArray(value, valueType, timeZone) {
|
|
76
|
+
if (Array.isArray(value)) {
|
|
77
|
+
return value.map((item) => fromDateValue(item, valueType, timeZone));
|
|
78
|
+
}
|
|
79
|
+
return fromDateValueOrRange(value, valueType, timeZone);
|
|
80
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sfxcode/nuxt-ui-formkit",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "FormKit integration for Nuxt UI - Seamlessly connect FormKit form handling with Nuxt UI components",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Tom",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"dev": "npm run dev:prepare && nuxi dev playground",
|
|
79
79
|
"dev:build": "nuxi build playground",
|
|
80
80
|
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
|
81
|
-
"release": "npm run lint && npm run test && npm run prepack && changelogen --
|
|
81
|
+
"release": "npm run lint && npm run test && npm run prepack && changelogen --patch --release && npm publish --access=public && git push --follow-tags",
|
|
82
82
|
"lint": "eslint .",
|
|
83
83
|
"test": "vitest run",
|
|
84
84
|
"test:watch": "vitest watch",
|
|
@@ -109,6 +109,7 @@
|
|
|
109
109
|
"@nuxt/test-utils": "^4.0.3",
|
|
110
110
|
"@types/node": "latest",
|
|
111
111
|
"@vitejs/plugin-vue": "^6.0.7",
|
|
112
|
+
"@vue/test-utils": "^2.4.11",
|
|
112
113
|
"changelogen": "^0.6.2",
|
|
113
114
|
"codemirror": "^6.0.2",
|
|
114
115
|
"eslint": "^10.6.0",
|
|
@@ -118,11 +119,13 @@
|
|
|
118
119
|
"sass-embedded": "^1.100.0",
|
|
119
120
|
"typescript": "~6.0.3",
|
|
120
121
|
"unbuild": "^3.6.1",
|
|
122
|
+
"valibot": "^1.4.2",
|
|
121
123
|
"vitepress": "2.0.0-alpha.17",
|
|
122
124
|
"vitest": "^4.1.9",
|
|
123
125
|
"vue": "^3.5.39",
|
|
124
126
|
"vue-i18n": "^11.4.6",
|
|
125
|
-
"vue-tsc": "^3.3.6"
|
|
127
|
+
"vue-tsc": "^3.3.6",
|
|
128
|
+
"zod": "^4.4.3"
|
|
126
129
|
},
|
|
127
130
|
"packageManager": "pnpm@11.1.2+sha512.415a1cc25974731e75455c1468371be74c5aa5fb7621b50d4056d222451609f11412f23fd602e6169f1e060466641f798597e1be961a10688836a67b16569499"
|
|
128
131
|
}
|