@event-chat/antd-item 0.2.7 → 0.3.0
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/FormInput.d.ts +4 -4
- 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 +2 -3
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -4
- package/package.json +2 -2
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: <Schema extends ZodType | undefined = undefined, Type extends string | undefined = undefined>({
|
|
5
|
-
declare const FormInput: (<Schema extends ZodType | undefined = undefined, Type extends string | undefined = undefined>(props: FormInputProps<Schema, Type> & {
|
|
4
|
+
declare const InputInner: <Name extends NamepathType, Schema extends ZodType | undefined = undefined, Type extends string | undefined = undefined>({ name, callback, onChange, ...props }: FormInputProps<Name, Schema, Type>, ref?: ForwardedRef<HTMLInputElement>) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
declare const FormInput: (<Name extends NamepathType, Schema extends ZodType | undefined = undefined, Type extends string | undefined = undefined>(props: FormInputProps<Name, Schema, Type> & {
|
|
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<Schema extends ZodType | undefined = undefined, Type extends string | undefined = undefined> extends Omit<EventChatOptions<NamepathType, Schema, string, Type, undefined>, 'group' | 'token'> {
|
|
12
|
-
name?:
|
|
11
|
+
export interface FormInputProps<Name extends NamepathType, Schema extends ZodType | undefined = undefined, Type extends string | undefined = undefined> extends Omit<EventChatOptions<NamepathType, Schema, string, Type, undefined>, 'group' | 'token'> {
|
|
12
|
+
name?: Name;
|
|
13
13
|
onChange?: (value: Parameters<NonNullable<EventChatOptions<NamepathType, Schema, string, Type, 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,GACd,MAAM,SAAS,OAAO,GAAG,SAAS,GAAG,SAAS,EAC9C,IAAI,SAAS,MAAM,GAAG,SAAS,GAAG,SAAS,EAE3C,
|
|
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,GACd,IAAI,SAAS,YAAY,EACzB,MAAM,SAAS,OAAO,GAAG,SAAS,GAAG,SAAS,EAC9C,IAAI,SAAS,MAAM,GAAG,SAAS,GAAG,SAAS,EAE3C,wCAAwC,cAAc,CAAC,IAAI,EAAE,MAAM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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, Type extends string | undefined = undefined>({ async, children, schema, type, callback, debug, onChange, ...props }: FormItemProps<Schema, Type>) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
import { FormEventInstance } from './utils';
|
|
7
|
+
declare const FormItem: <Name extends NamepathType, Schema extends ZodType | undefined = undefined, Type extends string | undefined = undefined>({ async, children, initialValue, name, rules, schema, type, callback, debug, onChange, transform, ...props }: FormItemProps<Name, Schema, Type>) => import("react/jsx-runtime").JSX.Element;
|
|
7
8
|
export default FormItem;
|
|
8
|
-
interface FormItemProps<Schema extends ZodType | undefined = undefined, Type extends string | undefined = undefined> extends Omit<FormItemRawProps, 'children' | 'name'>, FormInputProps<Schema, Type> {
|
|
9
|
-
children?: ReactNode | ((form:
|
|
9
|
+
interface FormItemProps<Name extends NamepathType, Schema extends ZodType | undefined = undefined, Type extends string | undefined = undefined> extends Omit<FormItemRawProps, 'children' | 'initialValue' | 'name'>, FormInputProps<Name, Schema, Type> {
|
|
10
|
+
children?: ReactNode | ((form: FormEventInstance<Name, string | undefined>) => 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,IAAI,SAAS,MAAM,GAAG,SAAS,GAAG,SAAS,EAC3C,8GAaC,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,4CAuCnC,CAAC;AAEF,eAAe,QAAQ,CAAC;AAExB,UAAU,aAAa,CACrB,IAAI,SAAS,YAAY,EACzB,MAAM,SAAS,OAAO,GAAG,SAAS,GAAG,SAAS,EAC9C,IAAI,SAAS,MAAM,GAAG,SAAS,GAAG,SAAS,CAE3C,SACE,IAAI,CAAC,gBAAgB,EAAE,UAAU,GAAG,cAAc,GAAG,MAAM,CAAC,EAC5D,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC;IACpC,QAAQ,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC,IAAI,EAAE,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC,KAAK,SAAS,CAAC,CAAC;IAC1F,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: <Schema extends ZodType | undefined = undefined, Type extends string | undefined = undefined>({ async, name, schema, type, callback, children, debug, onChange, ...props }: FormListProps<Schema, Type>) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
declare const FormList: <Name extends NamepathType, Schema extends ZodType | undefined = undefined, Type extends string | undefined = undefined>({ async, initialValue, name, rules, schema, type, callback, children, debug, onChange, ...props }: FormListProps<Name, Schema, Type>) => import("react/jsx-runtime").JSX.Element | null;
|
|
7
7
|
export default FormList;
|
|
8
|
-
interface FormListProps<Schema extends ZodType | undefined = undefined, Type extends string | undefined = undefined> extends Omit<ComponentProps<typeof FormRaw.List>, 'name'>, Omit<FormInputProps<Schema, Type>, 'name'> {
|
|
9
|
-
name:
|
|
8
|
+
interface FormListProps<Name extends NamepathType, Schema extends ZodType | undefined = undefined, Type extends string | undefined = undefined> extends Omit<ComponentProps<typeof FormRaw.List>, 'name'>, Omit<FormInputProps<Name, Schema, Type>, '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,GACZ,IAAI,SAAS,YAAY,EACzB,MAAM,SAAS,OAAO,GAAG,SAAS,GAAG,SAAS,EAC9C,IAAI,SAAS,MAAM,GAAG,SAAS,GAAG,SAAS,EAC3C,mGAYC,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,mDA0CnC,CAAC;AAEF,eAAe,QAAQ,CAAC;AAIxB,UAAU,aAAa,CACrB,IAAI,SAAS,YAAY,EACzB,MAAM,SAAS,OAAO,GAAG,SAAS,GAAG,SAAS,EAC9C,IAAI,SAAS,MAAM,GAAG,SAAS,GAAG,SAAS,CAE3C,SACE,IAAI,CAAC,cAAc,CAAC,OAAO,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,EACjD,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAClD,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,7 +6,6 @@ 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 convertName: (path?: NamepathType) => string | number | (string | number)[] | undefined;
|
|
10
9
|
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> & {
|
|
11
10
|
group: Group | undefined;
|
|
12
11
|
name: string;
|
|
@@ -35,10 +34,10 @@ type FormOptions<Name extends NamepathType, Group extends string | undefined = u
|
|
|
35
34
|
name?: Name;
|
|
36
35
|
};
|
|
37
36
|
export interface FormBaseInstance extends FC<Pick<ComponentProps<typeof Form>, 'children' | 'form' | 'name'>> {
|
|
38
|
-
Item: FC<Pick<FormItemProps, 'hidden' | 'name'> & {
|
|
37
|
+
Item: FC<Pick<FormItemProps, 'hidden' | 'initialValue' | 'name' | 'rules'> & {
|
|
39
38
|
children?: ReactNode | ((form: FormInsType) => ReactNode);
|
|
40
39
|
}>;
|
|
41
|
-
List: FC<Pick<ComponentProps<typeof Form.List>, 'children' | 'name'>>;
|
|
40
|
+
List: FC<Pick<ComponentProps<typeof Form.List>, 'children' | 'initialValue' | 'name' | 'rules'>>;
|
|
42
41
|
useFormInstance: <Value>() => FormInsType<Value>;
|
|
43
42
|
}
|
|
44
43
|
export type FormInsType<ValueType = unknown> = Omit<NonNullable<ComponentProps<typeof Form<ValueType>>['form']>, 'focusField'> & {
|
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,E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AI,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAC3D,YAAY,CACb,GAAG;IACF,UAAU,CAAC,EAAE,WAAW,CAAC,cAAc,CAAC,OAAO,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;CAC7E,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 ? {
|
|
@@ -72,4 +69,4 @@ const useFormEvent = ()=>{
|
|
|
72
69
|
const record = useContext(FormEventContext);
|
|
73
70
|
return record;
|
|
74
71
|
};
|
|
75
|
-
export { AntdCom, FormEventContext,
|
|
72
|
+
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.0",
|
|
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": "*",
|