@jakubmazanec/ui 0.4.1 → 0.4.2-unstable.aad0af37
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/build/components/data-table/DataTableColumnOrder.d.ts +1 -1
- package/build/components/data-table/DataTableColumnPinning.d.ts +4 -1
- package/build/components/data-table/DataTableFaceting.d.ts +2 -10
- package/build/components/data-table/DataTableFilters.d.ts +3 -9
- package/build/components/data-table/DataTablePagination.d.ts +2 -11
- package/build/components/data-table/DataTableSorting.d.ts +6 -9
- package/build/components/data-table/internals/addFilter.d.ts +1 -1
- package/build/components/data-table/internals/removeFilter.d.ts +1 -1
- package/build/components/useForm.d.ts +6 -5
- package/build/components/useForm.js +7 -3
- package/build/components/useForm.js.map +2 -2
- package/package.json +4 -4
- package/source/components/useForm.ts +17 -6
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export declare const dataTableColumnPinningSchema: z.ZodRecord<z.ZodString, z.ZodEnum<
|
|
2
|
+
export declare const dataTableColumnPinningSchema: z.ZodRecord<z.ZodString, z.ZodEnum<{
|
|
3
|
+
left: "left";
|
|
4
|
+
right: "right";
|
|
5
|
+
}>>;
|
|
3
6
|
export type DataTableColumnPinning = z.infer<typeof dataTableColumnPinningSchema>;
|
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const dataTableFacetingSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
3
|
-
values: z.ZodOptional<z.ZodArray<z.ZodUnknown
|
|
3
|
+
values: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
4
4
|
min: z.ZodOptional<z.ZodUnknown>;
|
|
5
5
|
max: z.ZodOptional<z.ZodUnknown>;
|
|
6
|
-
},
|
|
7
|
-
values?: unknown[] | undefined;
|
|
8
|
-
max?: unknown;
|
|
9
|
-
min?: unknown;
|
|
10
|
-
}, {
|
|
11
|
-
values?: unknown[] | undefined;
|
|
12
|
-
max?: unknown;
|
|
13
|
-
min?: unknown;
|
|
14
|
-
}>>;
|
|
6
|
+
}, z.core.$strip>>;
|
|
15
7
|
export type DataTableFaceting = z.infer<typeof dataTableFacetingSchema>;
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export declare const dataTableFiltersSchema: z.ZodUnion<[z.ZodNull, z.ZodArray<z.ZodObject<{
|
|
2
|
+
export declare const dataTableFiltersSchema: z.ZodUnion<readonly [z.ZodNull, z.ZodArray<z.ZodObject<{
|
|
3
3
|
column: z.ZodString;
|
|
4
|
-
filter: z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodTuple<[z.ZodOptional<z.ZodNullable<z.ZodNumber>>, z.ZodOptional<z.ZodNullable<z.ZodNumber>>], null>]>;
|
|
5
|
-
},
|
|
6
|
-
filter: string | number | boolean | [number | null | undefined, number | null | undefined];
|
|
7
|
-
column: string;
|
|
8
|
-
}, {
|
|
9
|
-
filter: string | number | boolean | [number | null | undefined, number | null | undefined];
|
|
10
|
-
column: string;
|
|
11
|
-
}>, "many">]>;
|
|
4
|
+
filter: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodTuple<[z.ZodOptional<z.ZodNullable<z.ZodNumber>>, z.ZodOptional<z.ZodNullable<z.ZodNumber>>], null>]>;
|
|
5
|
+
}, z.core.$strip>>]>;
|
|
12
6
|
export type DataTableFilters = z.infer<typeof dataTableFiltersSchema>;
|
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const dataTablePaginationSchema: z.ZodObject<{
|
|
3
|
-
/** Page number, starts with 1. */
|
|
4
3
|
page: z.ZodNumber;
|
|
5
|
-
pageSize: z.ZodUnion<[z.ZodLiteral<10>, z.ZodLiteral<25>, z.ZodLiteral<50>, z.ZodLiteral<75>, z.ZodLiteral<100>]>;
|
|
4
|
+
pageSize: z.ZodUnion<readonly [z.ZodLiteral<10>, z.ZodLiteral<25>, z.ZodLiteral<50>, z.ZodLiteral<75>, z.ZodLiteral<100>]>;
|
|
6
5
|
pageCount: z.ZodNumber;
|
|
7
|
-
},
|
|
8
|
-
page: number;
|
|
9
|
-
pageCount: number;
|
|
10
|
-
pageSize: 10 | 25 | 50 | 75 | 100;
|
|
11
|
-
}, {
|
|
12
|
-
page: number;
|
|
13
|
-
pageCount: number;
|
|
14
|
-
pageSize: 10 | 25 | 50 | 75 | 100;
|
|
15
|
-
}>;
|
|
6
|
+
}, z.core.$strip>;
|
|
16
7
|
export type DataTablePagination = z.infer<typeof dataTablePaginationSchema>;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export declare const dataTableSortingSchema: z.ZodUnion<[z.ZodNull, z.ZodObject<{
|
|
2
|
+
export declare const dataTableSortingSchema: z.ZodUnion<readonly [z.ZodNull, z.ZodObject<{
|
|
3
3
|
column: z.ZodString;
|
|
4
|
-
direction: z.ZodEnum<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
},
|
|
9
|
-
direction: "ascending" | "descending";
|
|
10
|
-
column: string;
|
|
11
|
-
}>]>;
|
|
4
|
+
direction: z.ZodEnum<{
|
|
5
|
+
ascending: "ascending";
|
|
6
|
+
descending: "descending";
|
|
7
|
+
}>;
|
|
8
|
+
}, z.core.$strip>]>;
|
|
12
9
|
export type DataTableSorting = z.infer<typeof dataTableSortingSchema>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type DataTableProps } from '../DataTable.js';
|
|
2
2
|
export declare function addFilter(filters: DataTableProps<any, any>['filters'], column: string, newFilter: unknown): {
|
|
3
|
-
filter: string | number | boolean | [number | null | undefined, number | null | undefined];
|
|
4
3
|
column: string;
|
|
4
|
+
filter: string | number | boolean | [(number | null | undefined)?, (number | null | undefined)?];
|
|
5
5
|
}[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type DataTableProps } from '../DataTable.js';
|
|
2
2
|
export declare function removeFilter(filters: DataTableProps<any, any>['filters'], column: string): {
|
|
3
|
-
filter: string | number | boolean | [number | null | undefined, number | null | undefined];
|
|
4
3
|
column: string;
|
|
4
|
+
filter: string | number | boolean | [(number | null | undefined)?, (number | null | undefined)?];
|
|
5
5
|
}[] | null;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { useForm as useBaseForm } from '@conform-to/react';
|
|
2
|
-
import { type
|
|
3
|
-
export type UseFormOptions<S extends
|
|
2
|
+
import { type output, type ZodObject } from 'zod';
|
|
3
|
+
export type UseFormOptions<S extends ZodObject> = {
|
|
4
4
|
schema: S;
|
|
5
5
|
onSubmit?: Parameters<typeof useBaseForm<S>>[0]['onSubmit'] | undefined;
|
|
6
6
|
};
|
|
7
|
-
export
|
|
8
|
-
form:
|
|
9
|
-
fields:
|
|
7
|
+
export type UseFormReturn<S extends ZodObject> = {
|
|
8
|
+
form: ReturnType<typeof useBaseForm<output<S>>>[0];
|
|
9
|
+
fields: ReturnType<typeof useBaseForm<output<S>>>[1];
|
|
10
10
|
};
|
|
11
|
+
export declare function useForm<S extends ZodObject>({ schema, onSubmit, }: UseFormOptions<S>): UseFormReturn<S>;
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
import { useForm as useBaseForm } from "@conform-to/react";
|
|
3
|
-
import { parseWithZod } from "@conform-to/zod";
|
|
4
|
-
export function useForm({
|
|
3
|
+
import { parseWithZod } from "@conform-to/zod/v4";
|
|
4
|
+
export function useForm({
|
|
5
|
+
schema,
|
|
6
|
+
onSubmit
|
|
7
|
+
}) {
|
|
5
8
|
let [form, fields] = useBaseForm({
|
|
6
9
|
shouldValidate: "onBlur",
|
|
7
10
|
shouldRevalidate: "onInput",
|
|
11
|
+
// TODO: fix this
|
|
12
|
+
// @ts-expect-error -- fix this
|
|
8
13
|
onValidate({ formData }) {
|
|
9
14
|
return parseWithZod(formData, { schema });
|
|
10
15
|
},
|
|
11
16
|
onSubmit
|
|
12
|
-
// TODO: remove when this is fixed: https://github.com/edmundhung/conform/issues/697
|
|
13
17
|
});
|
|
14
18
|
return {
|
|
15
19
|
form,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../source/components/useForm.ts"],
|
|
4
|
-
"sourcesContent": ["import {useForm as useBaseForm} from '@conform-to/react';\nimport {parseWithZod} from '@conform-to/zod';\nimport {type
|
|
5
|
-
"mappings": ";AAAA,SAAQ,WAAW,mBAAkB;AACrC,SAAQ,oBAAmB;
|
|
4
|
+
"sourcesContent": ["import {useForm as useBaseForm} from '@conform-to/react';\nimport {parseWithZod} from '@conform-to/zod/v4';\nimport {type output, type ZodObject} from 'zod';\n\nexport type UseFormOptions<S extends ZodObject> = {\n schema: S;\n onSubmit?: Parameters<typeof useBaseForm<S>>[0]['onSubmit'] | undefined;\n};\n\nexport type UseFormReturn<S extends ZodObject> = {\n form: ReturnType<typeof useBaseForm<output<S>>>[0];\n fields: ReturnType<typeof useBaseForm<output<S>>>[1];\n};\n\nexport function useForm<S extends ZodObject>({\n schema,\n onSubmit,\n}: UseFormOptions<S>): UseFormReturn<S> {\n let [form, fields] = useBaseForm({\n shouldValidate: 'onBlur',\n shouldRevalidate: 'onInput',\n // TODO: fix this\n // @ts-expect-error -- fix this\n onValidate({formData}) {\n return parseWithZod(formData, {schema});\n },\n onSubmit,\n });\n\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- false positive\n return {\n form,\n fields,\n } as UseFormReturn<S>;\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAQ,WAAW,mBAAkB;AACrC,SAAQ,oBAAmB;AAapB,gBAAS,QAA6B;AAAA,EAC3C;AAAA,EACA;AACF,GAAwC;AACtC,MAAI,CAAC,MAAM,MAAM,IAAI,YAAY;AAAA,IAC/B,gBAAgB;AAAA,IAChB,kBAAkB;AAAA;AAAA;AAAA,IAGlB,WAAW,EAAC,SAAQ,GAAG;AACrB,aAAO,aAAa,UAAU,EAAC,OAAM,CAAC;AAAA,IACxC;AAAA,IACA;AAAA,EACF,CAAC;AAGD,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jakubmazanec/ui",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2-unstable.aad0af37",
|
|
4
4
|
"description": "React component library.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"typecheck": "tsc --project tsconfig.typecheck.json"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@conform-to/react": "^1.
|
|
37
|
-
"@conform-to/zod": "^1.
|
|
36
|
+
"@conform-to/react": "^1.8.2",
|
|
37
|
+
"@conform-to/zod": "^1.8.2",
|
|
38
38
|
"@dnd-kit/core": "^6.3.1",
|
|
39
39
|
"@dnd-kit/modifiers": "^9.0.0",
|
|
40
40
|
"@dnd-kit/sortable": "^10.0.0",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"culori": "^4.0.1",
|
|
48
48
|
"lodash": "^4.17.21",
|
|
49
49
|
"tailwind-merge": "^3.3.1",
|
|
50
|
-
"zod": "^
|
|
50
|
+
"zod": "^4.0.17"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@chromatic-com/storybook": "^4.0.1",
|
|
@@ -1,24 +1,35 @@
|
|
|
1
1
|
import {useForm as useBaseForm} from '@conform-to/react';
|
|
2
|
-
import {parseWithZod} from '@conform-to/zod';
|
|
3
|
-
import {type
|
|
2
|
+
import {parseWithZod} from '@conform-to/zod/v4';
|
|
3
|
+
import {type output, type ZodObject} from 'zod';
|
|
4
4
|
|
|
5
|
-
export type UseFormOptions<S extends
|
|
5
|
+
export type UseFormOptions<S extends ZodObject> = {
|
|
6
6
|
schema: S;
|
|
7
7
|
onSubmit?: Parameters<typeof useBaseForm<S>>[0]['onSubmit'] | undefined;
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
export
|
|
10
|
+
export type UseFormReturn<S extends ZodObject> = {
|
|
11
|
+
form: ReturnType<typeof useBaseForm<output<S>>>[0];
|
|
12
|
+
fields: ReturnType<typeof useBaseForm<output<S>>>[1];
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export function useForm<S extends ZodObject>({
|
|
16
|
+
schema,
|
|
17
|
+
onSubmit,
|
|
18
|
+
}: UseFormOptions<S>): UseFormReturn<S> {
|
|
11
19
|
let [form, fields] = useBaseForm({
|
|
12
20
|
shouldValidate: 'onBlur',
|
|
13
21
|
shouldRevalidate: 'onInput',
|
|
22
|
+
// TODO: fix this
|
|
23
|
+
// @ts-expect-error -- fix this
|
|
14
24
|
onValidate({formData}) {
|
|
15
25
|
return parseWithZod(formData, {schema});
|
|
16
26
|
},
|
|
17
|
-
onSubmit
|
|
27
|
+
onSubmit,
|
|
18
28
|
});
|
|
19
29
|
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- false positive
|
|
20
31
|
return {
|
|
21
32
|
form,
|
|
22
33
|
fields,
|
|
23
|
-
}
|
|
34
|
+
} as UseFormReturn<S>;
|
|
24
35
|
}
|