@event-chat/antd-item 0.2.7 → 0.3.1
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/dist/FormEvent.d.ts +3 -3
- package/dist/FormEvent.d.ts.map +1 -1
- package/dist/FormInput.d.ts +5 -5
- package/dist/FormInput.d.ts.map +1 -1
- package/dist/FormInput.js +3 -6
- package/dist/FormItem.d.ts +7 -4
- package/dist/FormItem.d.ts.map +1 -1
- package/dist/FormItem.js +25 -7
- package/dist/FormList.d.ts +3 -3
- package/dist/FormList.d.ts.map +1 -1
- package/dist/FormList.js +23 -10
- package/dist/utils.d.ts +13 -13
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +5 -5
- package/package.json +2 -2
package/dist/FormEvent.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { FormProps as FormRawProps } from 'antd';
|
|
2
2
|
import { PropsWithChildren } from 'react';
|
|
3
3
|
import { FormEventInstance } from './utils';
|
|
4
|
-
declare const FormEvent: <
|
|
4
|
+
declare const FormEvent: <Name extends string, Group extends string | undefined = undefined, ValuesType = unknown>({ children, form, group, name, ...props }: PropsWithChildren<FormProps<Name, Group, ValuesType>>) => import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
export default FormEvent;
|
|
6
|
-
interface FormProps<
|
|
7
|
-
form?: FormEventInstance<Name, Group>;
|
|
6
|
+
interface FormProps<Name extends string = string, Group extends string | undefined = undefined, ValuesType = unknown> extends Omit<FormRawProps<ValuesType>, 'form'> {
|
|
7
|
+
form?: FormEventInstance<Name, Group, ValuesType>;
|
|
8
8
|
group?: Group;
|
|
9
9
|
name?: Name;
|
|
10
10
|
}
|
package/dist/FormEvent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormEvent.d.ts","sourceRoot":"","sources":["../src/FormEvent.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,IAAI,YAAY,EAAE,MAAM,MAAM,CAAC;AACjD,OAAO,EAAM,iBAAiB,EAAiB,MAAM,OAAO,CAAC;AAC7D,OAAO,EAGL,iBAAiB,EAIlB,MAAM,SAAS,CAAC;AAmCjB,QAAA,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"FormEvent.d.ts","sourceRoot":"","sources":["../src/FormEvent.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,IAAI,YAAY,EAAE,MAAM,MAAM,CAAC;AACjD,OAAO,EAAM,iBAAiB,EAAiB,MAAM,OAAO,CAAC;AAC7D,OAAO,EAGL,iBAAiB,EAIlB,MAAM,SAAS,CAAC;AAmCjB,QAAA,MAAM,SAAS,GACb,IAAI,SAAS,MAAM,EACnB,KAAK,SAAS,MAAM,GAAG,SAAS,GAAG,SAAS,EAC5C,UAAU,GAAG,OAAO,EACpB,2CAMC,iBAAiB,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,4CAwBvD,CAAC;AAEF,eAAe,SAAS,CAAC;AAGzB,UAAU,SAAS,CACjB,IAAI,SAAS,MAAM,GAAG,MAAM,EAC5B,KAAK,SAAS,MAAM,GAAG,SAAS,GAAG,SAAS,EAC5C,UAAU,GAAG,OAAO,CACpB,SAAQ,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC9C,IAAI,CAAC,EAAE,iBAAiB,CAAC,IAAI,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;IAClD,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,IAAI,CAAC,EAAE,IAAI,CAAC;CACb"}
|
package/dist/FormInput.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { EventChatOptions, NamepathType, useEventChat } from '@event-chat/core';
|
|
2
2
|
import { ForwardedRef } from 'react';
|
|
3
3
|
import { ZodType } from 'zod';
|
|
4
|
-
declare const InputInner: <
|
|
5
|
-
declare const FormInput: (<
|
|
4
|
+
declare const InputInner: <Name extends NamepathType, Schema extends ZodType | undefined = undefined>({ name, callback, onChange, ...props }: FormInputProps<Name, Schema>, ref?: ForwardedRef<HTMLInputElement>) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
declare const FormInput: (<Name extends NamepathType, Schema extends ZodType | undefined = undefined>(props: FormInputProps<Name, Schema> & {
|
|
6
6
|
ref?: ForwardedRef<HTMLInputElement>;
|
|
7
7
|
}) => ReturnType<typeof InputInner>) & {
|
|
8
8
|
displayName?: string;
|
|
9
9
|
};
|
|
10
10
|
export default FormInput;
|
|
11
|
-
export interface FormInputProps<
|
|
12
|
-
name?:
|
|
13
|
-
onChange?: (value: Parameters<NonNullable<EventChatOptions<NamepathType, Schema, string,
|
|
11
|
+
export interface FormInputProps<Name extends NamepathType, Schema extends ZodType | undefined = undefined> extends Omit<EventChatOptions<NamepathType, Schema, string, string, undefined>, 'group'> {
|
|
12
|
+
name?: Name;
|
|
13
|
+
onChange?: (value: Parameters<NonNullable<EventChatOptions<NamepathType, Schema, string, string, undefined>['callback']>>[0]['detail'], options: ReturnType<typeof useEventChat>) => void;
|
|
14
14
|
}
|
|
15
15
|
//# sourceMappingURL=FormInput.d.ts.map
|
package/dist/FormInput.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormInput.d.ts","sourceRoot":"","sources":["../src/FormInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAe,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC7F,OAAO,EAAE,YAAY,EAAuB,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAO9B,QAAA,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"FormInput.d.ts","sourceRoot":"","sources":["../src/FormInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAe,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC7F,OA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convertPath = (path)=>('object' == typeof path ? [
|
|
|
8
8
|
] : [
|
|
9
9
|
path
|
|
10
10
|
]).filter(isDefined);
|
|
11
|
-
const InputInner = ({
|
|
11
|
+
const InputInner = ({ name, callback, onChange, ...props }, ref)=>{
|
|
12
12
|
const { group, parent } = useFormEvent();
|
|
13
13
|
const formName = useMemo(()=>{
|
|
14
14
|
const itemName = convertPath(name);
|
|
@@ -21,15 +21,12 @@ const InputInner = ({ async, name, schema, type, callback, debug, onChange }, re
|
|
|
21
21
|
parent
|
|
22
22
|
]);
|
|
23
23
|
const result = useEventChat(formName, {
|
|
24
|
+
...props,
|
|
24
25
|
callback: (record)=>{
|
|
25
26
|
callback?.(record);
|
|
26
27
|
onChange?.(record.detail, result);
|
|
27
28
|
},
|
|
28
|
-
|
|
29
|
-
group,
|
|
30
|
-
schema,
|
|
31
|
-
type,
|
|
32
|
-
debug
|
|
29
|
+
group
|
|
33
30
|
});
|
|
34
31
|
return /*#__PURE__*/ jsx("input", {
|
|
35
32
|
ref: ref
|
package/dist/FormItem.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
import { NamepathType } from '@event-chat/core';
|
|
1
2
|
import { FormItemProps as FormItemRawProps } from 'antd';
|
|
2
3
|
import { ReactNode } from 'react';
|
|
3
4
|
import { ZodType } from 'zod';
|
|
4
5
|
import { FormInputProps } from './FormInput';
|
|
5
|
-
import {
|
|
6
|
-
declare const FormItem: <Schema extends ZodType | undefined = undefined,
|
|
6
|
+
import { FormEventInstance } from './utils';
|
|
7
|
+
declare const FormItem: <Name extends NamepathType, Schema extends ZodType | undefined = undefined, ValueType = unknown>({ async, children, initialValue, name, rules, schema, type, callback, debug, onChange, transform, ...props }: FormItemProps<Name, Schema, ValueType>) => import("react/jsx-runtime").JSX.Element;
|
|
7
8
|
export default FormItem;
|
|
8
|
-
interface FormItemProps<Schema extends ZodType | undefined = undefined,
|
|
9
|
-
children?: ReactNode | ((form:
|
|
9
|
+
interface FormItemProps<Name extends NamepathType, Schema extends ZodType | undefined = undefined, ValueType = unknown> extends Omit<FormItemRawProps, 'children' | 'initialValue' | 'name'>, FormInputProps<Name, Schema> {
|
|
10
|
+
children?: ReactNode | ((form: FormEventInstance<Name, string | undefined, ValueType>) => ReactNode);
|
|
11
|
+
initialValue?: unknown;
|
|
12
|
+
transform?: (value: unknown) => unknown;
|
|
10
13
|
}
|
|
11
14
|
//# sourceMappingURL=FormItem.d.ts.map
|
package/dist/FormItem.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormItem.d.ts","sourceRoot":"","sources":["../src/FormItem.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,gBAAgB,EAAE,MAAM,MAAM,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAC9B,OAAkB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"FormItem.d.ts","sourceRoot":"","sources":["../src/FormItem.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,aAAa,IAAI,gBAAgB,EAAE,MAAM,MAAM,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAC9B,OAAkB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAA+B,MAAM,SAAS,CAAC;AAEzE,QAAA,MAAM,QAAQ,GACZ,IAAI,SAAS,YAAY,EACzB,MAAM,SAAS,OAAO,GAAG,SAAS,GAAG,SAAS,EAC9C,SAAS,GAAG,OAAO,EACnB,8GAaC,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,4CAuCxC,CAAC;AAEF,eAAe,QAAQ,CAAC;AAExB,UAAU,aAAa,CACrB,IAAI,SAAS,YAAY,EACzB,MAAM,SAAS,OAAO,GAAG,SAAS,GAAG,SAAS,EAC9C,SAAS,GAAG,OAAO,CAEnB,SACE,IAAI,CAAC,gBAAgB,EAAE,UAAU,GAAG,cAAc,GAAG,MAAM,CAAC,EAC5D,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,EACL,SAAS,GACT,CAAC,CAAC,IAAI,EAAE,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,SAAS,CAAC,KAAK,SAAS,CAAC,CAAC;IAClF,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC;CACzC"}
|
package/dist/FormItem.js
CHANGED
|
@@ -1,21 +1,39 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { checkDetail } from "@event-chat/core";
|
|
2
3
|
import FormInput from "./FormInput.js";
|
|
3
|
-
import {
|
|
4
|
-
const FormItem = ({ async, children, schema, type, callback, debug, onChange, ...props })=>{
|
|
5
|
-
const
|
|
4
|
+
import { useFormCom, useFormInstance } from "./utils.js";
|
|
5
|
+
const FormItem = ({ async, children, initialValue, name, rules, schema, type, callback, debug, onChange, transform, ...props })=>{
|
|
6
|
+
const { group, emit } = useFormInstance();
|
|
6
7
|
const Form = useFormCom();
|
|
7
8
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
8
9
|
children: [
|
|
9
10
|
/*#__PURE__*/ jsx(Form.Item, {
|
|
10
11
|
...props,
|
|
11
|
-
|
|
12
|
+
initialValue: initialValue,
|
|
13
|
+
name: name,
|
|
14
|
+
rules: schema ? (rules ?? []).concat([
|
|
15
|
+
{
|
|
16
|
+
validator: (_, value)=>checkDetail(value, {
|
|
17
|
+
async,
|
|
18
|
+
schema
|
|
19
|
+
}),
|
|
20
|
+
transform
|
|
21
|
+
}
|
|
22
|
+
]) : rules,
|
|
23
|
+
children: 'function' == typeof children ? (form)=>children({
|
|
24
|
+
...form,
|
|
25
|
+
group,
|
|
26
|
+
name,
|
|
27
|
+
emit
|
|
28
|
+
}) : children
|
|
12
29
|
}),
|
|
13
|
-
void 0 !==
|
|
14
|
-
|
|
30
|
+
void 0 !== name && /*#__PURE__*/ jsx(Form.Item, {
|
|
31
|
+
...props,
|
|
32
|
+
name: name,
|
|
15
33
|
hidden: true,
|
|
16
34
|
children: /*#__PURE__*/ jsx(FormInput, {
|
|
17
35
|
async: async,
|
|
18
|
-
name:
|
|
36
|
+
name: name,
|
|
19
37
|
schema: schema,
|
|
20
38
|
type: type,
|
|
21
39
|
callback: callback,
|
package/dist/FormList.d.ts
CHANGED
|
@@ -3,9 +3,9 @@ import { Form as FormRaw } from 'antd';
|
|
|
3
3
|
import { ComponentProps } from 'react';
|
|
4
4
|
import { ZodType } from 'zod';
|
|
5
5
|
import { FormInputProps } from './FormInput';
|
|
6
|
-
declare const FormList: <
|
|
6
|
+
declare const FormList: <Name extends NamepathType, Schema extends ZodType | undefined = undefined>({ async, initialValue, name, rules, schema, type, callback, children, debug, onChange, ...props }: FormListProps<Name, Schema>) => import("react/jsx-runtime").JSX.Element | null;
|
|
7
7
|
export default FormList;
|
|
8
|
-
interface FormListProps<
|
|
9
|
-
name:
|
|
8
|
+
interface FormListProps<Name extends NamepathType, Schema extends ZodType | undefined = undefined> extends Omit<ComponentProps<typeof FormRaw.List>, 'name'>, Omit<FormInputProps<Name, Schema>, 'name'> {
|
|
9
|
+
name: Name;
|
|
10
10
|
}
|
|
11
11
|
//# sourceMappingURL=FormList.d.ts.map
|
package/dist/FormList.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormList.d.ts","sourceRoot":"","sources":["../src/FormList.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"FormList.d.ts","sourceRoot":"","sources":["../src/FormList.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,IAAI,IAAI,OAAO,EAAE,MAAM,MAAM,CAAC;AACvC,OAAO,EAAE,cAAc,EAAwC,MAAM,OAAO,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAC9B,OAAkB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAcxD,QAAA,MAAM,QAAQ,GAAI,IAAI,SAAS,YAAY,EAAE,MAAM,SAAS,OAAO,GAAG,SAAS,GAAG,SAAS,EAAE,mGAY1F,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,mDA0C7B,CAAC;AAEF,eAAe,QAAQ,CAAC;AAIxB,UAAU,aAAa,CAAC,IAAI,SAAS,YAAY,EAAE,MAAM,SAAS,OAAO,GAAG,SAAS,GAAG,SAAS,CAC/F,SACE,IAAI,CAAC,cAAc,CAAC,OAAO,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,EACjD,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAC5C,IAAI,EAAE,IAAI,CAAC;CACZ"}
|
package/dist/FormList.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { checkDetail } from "@event-chat/core";
|
|
3
|
+
import { memo, useMemo } from "react";
|
|
3
4
|
import FormInput from "./FormInput.js";
|
|
4
|
-
import { FormEventContext,
|
|
5
|
+
import { FormEventContext, useFormCom, useFormEvent } from "./utils.js";
|
|
6
|
+
const isNamepath = (value)=>'string' == typeof value || Number.isInteger(value);
|
|
5
7
|
const FormListInner = ({ children, name: parent })=>{
|
|
6
8
|
const record = useFormEvent();
|
|
7
9
|
return /*#__PURE__*/ jsx(FormEventContext.Provider, {
|
|
@@ -13,26 +15,37 @@ const FormListInner = ({ children, name: parent })=>{
|
|
|
13
15
|
});
|
|
14
16
|
};
|
|
15
17
|
const ListItem = /*#__PURE__*/ memo(FormListInner);
|
|
16
|
-
const FormList = ({ async, name, schema, type, callback, children, debug, onChange, ...props })=>{
|
|
18
|
+
const FormList = ({ async, initialValue, name, rules, schema, type, callback, children, debug, onChange, ...props })=>{
|
|
17
19
|
const Form = useFormCom();
|
|
18
|
-
|
|
20
|
+
const fieldName = useMemo(()=>(Array.isArray(name) ? name.filter(isNamepath) : void 0) ?? (isNamepath(name) ? name : void 0), [
|
|
21
|
+
name
|
|
22
|
+
]);
|
|
23
|
+
return fieldName ? /*#__PURE__*/ jsxs(Fragment, {
|
|
19
24
|
children: [
|
|
20
25
|
/*#__PURE__*/ jsx(Form.List, {
|
|
21
26
|
...props,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
initialValue: initialValue,
|
|
28
|
+
name: fieldName,
|
|
29
|
+
rules: schema ? (rules ?? []).concat([
|
|
30
|
+
{
|
|
31
|
+
validator: (_, value)=>checkDetail(value, {
|
|
32
|
+
async,
|
|
33
|
+
schema
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
]) : rules,
|
|
25
37
|
children: (fields, options, metas)=>/*#__PURE__*/ jsx(ListItem, {
|
|
26
38
|
name: name,
|
|
27
39
|
children: children(fields, options, metas)
|
|
28
40
|
})
|
|
29
41
|
}),
|
|
30
42
|
/*#__PURE__*/ jsx(Form.Item, {
|
|
31
|
-
|
|
43
|
+
...props,
|
|
44
|
+
name: fieldName,
|
|
32
45
|
hidden: true,
|
|
33
46
|
children: /*#__PURE__*/ jsx(FormInput, {
|
|
34
47
|
async: async,
|
|
35
|
-
name:
|
|
48
|
+
name: fieldName,
|
|
36
49
|
schema: schema,
|
|
37
50
|
type: type,
|
|
38
51
|
callback: callback,
|
|
@@ -41,7 +54,7 @@ const FormList = ({ async, name, schema, type, callback, children, debug, onChan
|
|
|
41
54
|
})
|
|
42
55
|
})
|
|
43
56
|
]
|
|
44
|
-
});
|
|
57
|
+
}) : null;
|
|
45
58
|
};
|
|
46
59
|
const src_FormList = FormList;
|
|
47
60
|
export { src_FormList as default };
|
package/dist/utils.d.ts
CHANGED
|
@@ -6,8 +6,7 @@ export declare const AntdCom: {
|
|
|
6
6
|
};
|
|
7
7
|
export declare const FormEventContext: import("react").Context<FormEventContextInstance>;
|
|
8
8
|
export declare const getStringValue: <T extends NamepathType | undefined>(values: T[]) => T | undefined;
|
|
9
|
-
export declare const
|
|
10
|
-
export declare const useForm: <Name extends string, Group extends string | undefined = undefined>(options?: FormOptions<Name, Group>, formInit?: FormEventInstance<Name, Group>) => readonly [import("antd").FormInstance<unknown> & {
|
|
9
|
+
export declare const useForm: <Name extends string, Group extends string | undefined = undefined, ValueType = unknown>(options?: FormOptions<Name, Group>, formInit?: FormEventInstance<Name, Group, ValueType>) => readonly [import("antd").FormInstance<ValueType> & {
|
|
11
10
|
group: Group | undefined;
|
|
12
11
|
name: string;
|
|
13
12
|
emit: <Detail, CustomName extends NamepathType>(detail: Omit<EventDetailType<Detail, CustomName>, "group" | "id" | "origin" | "time" | "type">) => void;
|
|
@@ -19,7 +18,7 @@ export declare const useFormInstance: <ValueType>() => Omit<import("antd").FormI
|
|
|
19
18
|
name: NamepathType | undefined;
|
|
20
19
|
emit: (<Detail, CustomName extends NamepathType>(record: Omit<EventDetailType<Detail, CustomName>, "group" | "id" | "origin" | "time" | "type">) => void) | undefined;
|
|
21
20
|
};
|
|
22
|
-
export declare const useFormCom: () => FormBaseInstance
|
|
21
|
+
export declare const useFormCom: <ValueType = unknown>() => FormBaseInstance<ValueType>;
|
|
23
22
|
export declare const useFormEvent: () => FormEventContextInstance;
|
|
24
23
|
export interface FormEventContextInstance {
|
|
25
24
|
group?: string;
|
|
@@ -27,22 +26,23 @@ export interface FormEventContextInstance {
|
|
|
27
26
|
parent?: NamepathType;
|
|
28
27
|
emit?: <Detail, CustomName extends NamepathType>(record: Omit<EventDetailType<Detail, CustomName>, 'group' | 'id' | 'origin' | 'time' | 'type'>) => void;
|
|
29
28
|
}
|
|
30
|
-
export interface FormEventInstance<Name extends NamepathType, Group extends string | undefined = undefined> extends FormInsType
|
|
29
|
+
export interface FormEventInstance<Name extends NamepathType, Group extends string | undefined = undefined, ValueType = unknown> extends FormInsType<ValueType>, FormOptions<Name, Group> {
|
|
31
30
|
emit?: <Detail, CustomName extends NamepathType>(record: Omit<EventDetailType<Detail, CustomName>, 'group' | 'id' | 'origin' | 'time' | 'type'>) => void;
|
|
32
31
|
}
|
|
33
|
-
type
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
};
|
|
37
|
-
export interface FormBaseInstance extends FC<Pick<ComponentProps<typeof Form>, 'children' | 'form' | 'name'>> {
|
|
38
|
-
Item: FC<Pick<FormItemProps, 'hidden' | 'name'> & {
|
|
39
|
-
children?: ReactNode | ((form: FormInsType) => ReactNode);
|
|
32
|
+
export type FormBaseInstance<ValueType = unknown> = FormType<ValueType> & {
|
|
33
|
+
Item: FC<Pick<FormItemProps, 'hidden' | 'initialValue' | 'name' | 'rules'> & {
|
|
34
|
+
children?: ReactNode | ((form: FormInsType<ValueType>) => ReactNode);
|
|
40
35
|
}>;
|
|
41
|
-
List: FC<Pick<ComponentProps<typeof Form.List>, 'children' | 'name'>>;
|
|
36
|
+
List: FC<Pick<ComponentProps<typeof Form.List>, 'children' | 'initialValue' | 'name' | 'rules'>>;
|
|
42
37
|
useFormInstance: <Value>() => FormInsType<Value>;
|
|
43
|
-
}
|
|
38
|
+
};
|
|
44
39
|
export type FormInsType<ValueType = unknown> = Omit<NonNullable<ComponentProps<typeof Form<ValueType>>['form']>, 'focusField'> & {
|
|
45
40
|
focusField?: NonNullable<ComponentProps<typeof Form>['form']>['focusField'];
|
|
46
41
|
};
|
|
42
|
+
type FormOptions<Name extends NamepathType, Group extends string | undefined = undefined> = {
|
|
43
|
+
group?: Group;
|
|
44
|
+
name?: Name;
|
|
45
|
+
};
|
|
46
|
+
type FormType<ValueType = unknown> = (props: Pick<ComponentProps<typeof Form<ValueType>>, 'children' | 'form' | 'name'> & React.RefAttributes<FormInsType<ValueType>>) => React.ReactElement;
|
|
47
47
|
export {};
|
|
48
48
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAA6B,MAAM,kBAAkB,CAAC;AAC5F,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,EAAE,EAAE,SAAS,EAAsC,MAAM,OAAO,CAAC;AAG1F,eAAO,MAAM,OAAO,EAAE;IACpB,IAAI,CAAC,EAAE,gBAAgB,CAAC;CACpB,CAAC;AAEP,eAAO,MAAM,gBAAgB,mDAA8C,CAAC;AAC5E,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,YAAY,GAAG,SAAS,EAAE,QAAQ,CAAC,EAAE,kBACU,CAAC;AAEzF,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAA6B,MAAM,kBAAkB,CAAC;AAC5F,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,EAAE,EAAE,SAAS,EAAsC,MAAM,OAAO,CAAC;AAG1F,eAAO,MAAM,OAAO,EAAE;IACpB,IAAI,CAAC,EAAE,gBAAgB,CAAC;CACpB,CAAC;AAEP,eAAO,MAAM,gBAAgB,mDAA8C,CAAC;AAC5E,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,YAAY,GAAG,SAAS,EAAE,QAAQ,CAAC,EA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K,CAAC;IACd,IAAI,CAAC,EAAE,IAAI,CAAC;CACb,CAAC;AAEF,KAAK,QAAQ,CAAC,SAAS,GAAG,OAAO,IAAI,CACnC,KAAK,EAAE,IAAI,CAAC,cAAc,CAAC,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,MAAM,CAAC,GAC/E,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,KAC1C,KAAK,CAAC,YAAY,CAAC"}
|
package/dist/utils.js
CHANGED
|
@@ -5,9 +5,6 @@ import zod from "zod";
|
|
|
5
5
|
const AntdCom = {};
|
|
6
6
|
const FormEventContext = createContext({});
|
|
7
7
|
const getStringValue = (values)=>values.find((item)=>void 0 !== item && (!Array.isArray(item) || item.length > 0));
|
|
8
|
-
const convertName = (path)=>'object' == typeof path ? [
|
|
9
|
-
...path
|
|
10
|
-
] : path;
|
|
11
8
|
const useForm = (options, formInit)=>{
|
|
12
9
|
const { group, name, focusField } = formInit ?? {};
|
|
13
10
|
const [form] = Form.useForm(formInit ? {
|
|
@@ -67,9 +64,12 @@ const useFormInstance = ()=>{
|
|
|
67
64
|
emit
|
|
68
65
|
});
|
|
69
66
|
};
|
|
70
|
-
const useFormCom = ()=>
|
|
67
|
+
const useFormCom = ()=>{
|
|
68
|
+
const CustomForm = AntdCom.form;
|
|
69
|
+
return CustomForm ?? Form;
|
|
70
|
+
};
|
|
71
71
|
const useFormEvent = ()=>{
|
|
72
72
|
const record = useContext(FormEventContext);
|
|
73
73
|
return record;
|
|
74
74
|
};
|
|
75
|
-
export { AntdCom, FormEventContext,
|
|
75
|
+
export { AntdCom, FormEventContext, getStringValue, useForm, useFormCom, useFormEvent, useFormInstance };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@event-chat/antd-item",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"storybook-react-rsbuild": "^3.1.0",
|
|
30
30
|
"tsd": "^0.33.0",
|
|
31
31
|
"typescript-eslint": "^8.48.0",
|
|
32
|
-
"@event-chat/core": "0.2.
|
|
32
|
+
"@event-chat/core": "0.2.5"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"@event-chat/core": "*",
|