@webamoki/web-svelte 0.5.10 → 0.5.12
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.
|
@@ -2,6 +2,9 @@ import { CalendarDate, Time, ZonedDateTime, type DateDuration } from '@internati
|
|
|
2
2
|
import type { Transport } from '@sveltejs/kit';
|
|
3
3
|
import type { Day } from '../types/arktype.js';
|
|
4
4
|
export declare const Days: readonly ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];
|
|
5
|
+
export declare const DayIndex: Record<Day, number>;
|
|
6
|
+
/** Gets the day index of the date */
|
|
7
|
+
export declare function getDayIndex(date: CalendarDate): number;
|
|
5
8
|
/**
|
|
6
9
|
* Gets the day of the week for a given date.
|
|
7
10
|
* @param date - The date to get the day of the week for.
|
|
@@ -12,9 +12,9 @@ export const Days = [
|
|
|
12
12
|
'Saturday',
|
|
13
13
|
'Sunday'
|
|
14
14
|
];
|
|
15
|
-
const DayIndex = Object.fromEntries(Days.map((day, index) => [day, index]));
|
|
15
|
+
export const DayIndex = Object.fromEntries(Days.map((day, index) => [day, index]));
|
|
16
16
|
/** Gets the day index of the date */
|
|
17
|
-
function getDayIndex(date) {
|
|
17
|
+
export function getDayIndex(date) {
|
|
18
18
|
// Always start 0 on Monday
|
|
19
19
|
return getDayOfWeek(date, DEFAULT_LOCALE, 'mon');
|
|
20
20
|
}
|
package/dist/utils/form.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { type } from 'arktype';
|
|
|
2
2
|
import { type SuperValidated } from 'sveltekit-superforms';
|
|
3
3
|
export declare function prepareForm<S extends type.Any<Record<string, unknown>>>(validated: SuperValidated<S['infer']> | S['infer'], schema: S, options?: Partial<{
|
|
4
4
|
invalidateAll: boolean;
|
|
5
|
+
resetForm: boolean;
|
|
5
6
|
onSuccess: (form: Readonly<SuperValidated<S['infer'], App.Superforms.Message, S['infer']>>) => void;
|
|
6
7
|
}>): {
|
|
7
8
|
form: import("sveltekit-superforms").SuperForm<S["infer"], any>;
|
|
@@ -11,6 +12,7 @@ export declare function prepareForm<S extends type.Any<Record<string, unknown>>>
|
|
|
11
12
|
};
|
|
12
13
|
export declare function prepareEmptyForm<S extends type.Any<Record<string, unknown>>>(schema: S, options?: Partial<{
|
|
13
14
|
invalidateAll: boolean;
|
|
15
|
+
resetForm: boolean;
|
|
14
16
|
onSuccess: (form: Readonly<SuperValidated<S['infer'], App.Superforms.Message, S['infer']>>) => void;
|
|
15
17
|
}>): {
|
|
16
18
|
form: import("sveltekit-superforms").SuperForm<S["infer"], any>;
|
package/dist/utils/form.js
CHANGED
|
@@ -4,12 +4,12 @@ import { type } from 'arktype';
|
|
|
4
4
|
import { defaults, fail, superForm, superValidate } from 'sveltekit-superforms';
|
|
5
5
|
import { arktype, arktypeClient } from 'sveltekit-superforms/adapters';
|
|
6
6
|
export function prepareForm(validated, schema, options) {
|
|
7
|
-
const _invalidateAll = options?.invalidateAll === undefined ? false : true;
|
|
8
7
|
const form = superForm(validated, {
|
|
9
8
|
validators: arktypeClient(schema),
|
|
10
9
|
dataType: 'json',
|
|
11
|
-
invalidateAll:
|
|
10
|
+
invalidateAll: options?.invalidateAll ?? false,
|
|
12
11
|
transport: dateTransport,
|
|
12
|
+
resetForm: options?.resetForm ?? true,
|
|
13
13
|
onUpdated({ form }) {
|
|
14
14
|
if (form.valid) {
|
|
15
15
|
options?.onSuccess?.(form);
|
|
@@ -30,12 +30,12 @@ export function prepareForm(validated, schema, options) {
|
|
|
30
30
|
return { form, data: form.form, delayed, errors };
|
|
31
31
|
}
|
|
32
32
|
export function prepareEmptyForm(schema, options) {
|
|
33
|
-
const _invalidateAll = options?.invalidateAll === undefined ? false : true;
|
|
34
33
|
const form = superForm(defaults(arktype(schema)), {
|
|
35
34
|
validators: arktypeClient(schema),
|
|
36
35
|
dataType: 'json',
|
|
37
|
-
invalidateAll:
|
|
36
|
+
invalidateAll: options?.invalidateAll === undefined ? false : true,
|
|
38
37
|
transport: dateTransport,
|
|
38
|
+
resetForm: options?.resetForm === undefined ? true : false,
|
|
39
39
|
onUpdated({ form }) {
|
|
40
40
|
if (form.valid) {
|
|
41
41
|
options?.onSuccess?.(form);
|