@xinghunm/compass-ui 0.1.0 → 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/index.d.mts +130 -12
- package/dist/index.d.ts +130 -12
- package/dist/index.js +216 -208
- package/dist/index.mjs +214 -206
- package/package.json +4 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,24 +1,16 @@
|
|
|
1
1
|
import * as React$1 from 'react';
|
|
2
2
|
import React__default, { CSSProperties, ReactElement, ReactNode } from 'react';
|
|
3
3
|
import { Placement } from '@floating-ui/react';
|
|
4
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
+
import { RuleItem } from 'async-validator';
|
|
4
6
|
|
|
5
|
-
interface ButtonBaseProps {
|
|
7
|
+
interface ButtonBaseProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
6
8
|
/** Whether to enable ripple effect */
|
|
7
9
|
hasRipple?: boolean;
|
|
8
|
-
/** Custom class name */
|
|
9
|
-
className?: string;
|
|
10
|
-
/** Custom style */
|
|
11
|
-
style?: React.CSSProperties;
|
|
12
|
-
/** Whether the button is disabled */
|
|
13
|
-
disabled?: boolean;
|
|
14
10
|
/** Ripple background color */
|
|
15
11
|
rippleBgColor?: string;
|
|
16
12
|
/** Ripple opacity */
|
|
17
13
|
rippleOpacity?: number;
|
|
18
|
-
/** Button content */
|
|
19
|
-
children?: React.ReactNode;
|
|
20
|
-
/** Click event handler */
|
|
21
|
-
onClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
22
14
|
}
|
|
23
15
|
|
|
24
16
|
interface ButtonProps extends ButtonBaseProps {
|
|
@@ -854,8 +846,19 @@ interface Theme {
|
|
|
854
846
|
select: SelectTheme;
|
|
855
847
|
pagination: PaginationTheme;
|
|
856
848
|
tree: TreeTheme;
|
|
849
|
+
form: FormTheme;
|
|
857
850
|
};
|
|
858
851
|
}
|
|
852
|
+
interface FormTheme {
|
|
853
|
+
itemMarginBottom: string;
|
|
854
|
+
labelColor: string;
|
|
855
|
+
labelFontSize: string;
|
|
856
|
+
labelMarginBottom: string;
|
|
857
|
+
errorColor: string;
|
|
858
|
+
errorFontSize: string;
|
|
859
|
+
errorMarginTop: string;
|
|
860
|
+
errorMarginBottom: string;
|
|
861
|
+
}
|
|
859
862
|
interface TreeTheme {
|
|
860
863
|
nodeSelectedBg: string;
|
|
861
864
|
nodeHoverBg: string;
|
|
@@ -1151,4 +1154,119 @@ interface InputNumberProps extends Omit<InputFieldProps, 'onChange' | 'value' |
|
|
|
1151
1154
|
|
|
1152
1155
|
declare const InputNumber: React__default.ForwardRefExoticComponent<InputNumberProps & React__default.RefAttributes<HTMLInputElement>>;
|
|
1153
1156
|
|
|
1154
|
-
|
|
1157
|
+
type StoreValue = unknown;
|
|
1158
|
+
type Store = Record<string, StoreValue>;
|
|
1159
|
+
interface FieldData {
|
|
1160
|
+
name: string;
|
|
1161
|
+
value?: StoreValue;
|
|
1162
|
+
touched?: boolean;
|
|
1163
|
+
validating?: boolean;
|
|
1164
|
+
errors?: string[];
|
|
1165
|
+
}
|
|
1166
|
+
/**
|
|
1167
|
+
* Interface for Field Entity (FormItem)
|
|
1168
|
+
*/
|
|
1169
|
+
interface FieldEntity {
|
|
1170
|
+
onStoreChange: () => void;
|
|
1171
|
+
validateRules: (options?: {
|
|
1172
|
+
triggerName?: string;
|
|
1173
|
+
}) => Promise<string[] | null>;
|
|
1174
|
+
getName: () => string;
|
|
1175
|
+
getErrors: () => string[];
|
|
1176
|
+
isFieldValidating: () => boolean;
|
|
1177
|
+
isFieldTouched: () => boolean;
|
|
1178
|
+
props: {
|
|
1179
|
+
name?: string;
|
|
1180
|
+
rules?: RuleItem[];
|
|
1181
|
+
dependencies?: string[];
|
|
1182
|
+
initialValue?: unknown;
|
|
1183
|
+
};
|
|
1184
|
+
}
|
|
1185
|
+
interface Callbacks<Values = Record<string, unknown>> {
|
|
1186
|
+
onValuesChange?: (changedValues: Store, values: Values) => void;
|
|
1187
|
+
onFieldsChange?: (changedFields: FieldData[], allFields: FieldData[]) => void;
|
|
1188
|
+
onFinish?: (values: Values) => void;
|
|
1189
|
+
onFinishFailed?: (errorInfo: ValidateErrorEntity<Values>) => void;
|
|
1190
|
+
}
|
|
1191
|
+
interface ValidateErrorEntity<Values = Record<string, unknown>> {
|
|
1192
|
+
values: Values;
|
|
1193
|
+
errorFields: {
|
|
1194
|
+
name: string;
|
|
1195
|
+
errors: string[];
|
|
1196
|
+
}[];
|
|
1197
|
+
outOfDate: boolean;
|
|
1198
|
+
}
|
|
1199
|
+
interface InternalHooks {
|
|
1200
|
+
registerField: (entity: FieldEntity) => () => void;
|
|
1201
|
+
registerWatch: (callback: (name: string) => void) => () => void;
|
|
1202
|
+
setInitialValues: (values: Store, init: boolean) => void;
|
|
1203
|
+
setCallbacks: (callbacks: Callbacks) => void;
|
|
1204
|
+
dispatch: (action: ReducerAction) => void;
|
|
1205
|
+
getFieldValue: (name: string) => StoreValue;
|
|
1206
|
+
notifyFieldChange: (name: string) => void;
|
|
1207
|
+
}
|
|
1208
|
+
interface FormInstance<Values = Record<string, unknown>> {
|
|
1209
|
+
getFieldValue: (name: string) => StoreValue;
|
|
1210
|
+
getFieldsValue: () => Values;
|
|
1211
|
+
getFieldError: (name: string) => string[];
|
|
1212
|
+
isFieldsTouched: (nameList?: string[]) => boolean;
|
|
1213
|
+
isFieldTouched: (name: string) => boolean;
|
|
1214
|
+
isFieldValidating: (name: string) => boolean;
|
|
1215
|
+
resetFields: (fields?: string[]) => void;
|
|
1216
|
+
setFields: (fields: FieldData[]) => void;
|
|
1217
|
+
setFieldValue: (name: string, value: unknown) => void;
|
|
1218
|
+
setFieldsValue: (values: RecursivePartial<Values>) => void;
|
|
1219
|
+
validateFields: (nameList?: string[]) => Promise<Values>;
|
|
1220
|
+
submit: () => void;
|
|
1221
|
+
getInternalHooks: (secret: string) => InternalHooks | null;
|
|
1222
|
+
}
|
|
1223
|
+
type RecursivePartial<T> = {
|
|
1224
|
+
[P in keyof T]?: T[P] extends (infer U)[] ? RecursivePartial<U>[] : T[P] extends object ? RecursivePartial<T[P]> : T[P];
|
|
1225
|
+
};
|
|
1226
|
+
interface ReducerAction {
|
|
1227
|
+
type: string;
|
|
1228
|
+
payload: unknown;
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
interface FormProps<Values = Record<string, unknown>> {
|
|
1232
|
+
form?: FormInstance<Values>;
|
|
1233
|
+
initialValues?: Store;
|
|
1234
|
+
children?: ReactNode;
|
|
1235
|
+
onFinish?: (values: Values) => void;
|
|
1236
|
+
onFinishFailed?: (errorInfo: ValidateErrorEntity<Values>) => void;
|
|
1237
|
+
onValuesChange?: (changedValues: Store, values: Values) => void;
|
|
1238
|
+
onFieldsChange?: (changedFields: FieldData[], allFields: FieldData[]) => void;
|
|
1239
|
+
className?: string;
|
|
1240
|
+
style?: React__default.CSSProperties;
|
|
1241
|
+
}
|
|
1242
|
+
declare const Form$1: <Values extends Record<string, unknown> = Record<string, unknown>>({ form, initialValues, children, onFinish, onFinishFailed, onValuesChange, onFieldsChange, className, style, }: FormProps<Values>) => react_jsx_runtime.JSX.Element;
|
|
1243
|
+
|
|
1244
|
+
interface FormItemProps {
|
|
1245
|
+
name?: string;
|
|
1246
|
+
label?: string;
|
|
1247
|
+
rules?: RuleItem[];
|
|
1248
|
+
children: ReactElement;
|
|
1249
|
+
validateTrigger?: string | string[];
|
|
1250
|
+
initialValue?: unknown;
|
|
1251
|
+
className?: string;
|
|
1252
|
+
style?: React__default.CSSProperties;
|
|
1253
|
+
}
|
|
1254
|
+
declare const FormItem: React__default.FC<FormItemProps>;
|
|
1255
|
+
|
|
1256
|
+
declare const useForm: <Values extends Record<string, unknown> = Record<string, unknown>>(form?: FormInstance<Values>) => [FormInstance<Values>];
|
|
1257
|
+
|
|
1258
|
+
declare const useWatch: <T = unknown>(name: string | string[], form?: FormInstance) => T;
|
|
1259
|
+
|
|
1260
|
+
type InternalFormType = typeof Form$1;
|
|
1261
|
+
interface FormInterface extends InternalFormType {
|
|
1262
|
+
Item: typeof FormItem;
|
|
1263
|
+
useForm: typeof useForm;
|
|
1264
|
+
useWatch: typeof useWatch;
|
|
1265
|
+
}
|
|
1266
|
+
declare const Form: FormInterface & {
|
|
1267
|
+
Item: typeof FormItem;
|
|
1268
|
+
useForm: typeof useForm;
|
|
1269
|
+
useWatch: typeof useWatch;
|
|
1270
|
+
};
|
|
1271
|
+
|
|
1272
|
+
export { Button, type ButtonProps, ConfigProvider, type ConfigProviderProps, type DataNode, DatePicker, type DatePickerProps, type DateRangePickerProps, Dropdown, type DropdownProps, type FieldData, Form, type FormInstance, type FormItemProps, type FormProps, InputField, type InputFieldProps, InputNumber, type InputNumberProps, type ItemType, Menu, type MenuItemProps, type MenuProps, messageWithHook as Message, type MessageProps, ModalWithStatics as Modal, type ModalBaseProps as ModalProps, Pagination, type PaginationProps, Progress, type ProgressProps, Select, type SelectOption, type SelectProps, type SelectValue, Steps, type StepsProps, Tree, type TreeNodeProps, type TreeProps, type ValidateErrorEntity };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,24 +1,16 @@
|
|
|
1
1
|
import * as React$1 from 'react';
|
|
2
2
|
import React__default, { CSSProperties, ReactElement, ReactNode } from 'react';
|
|
3
3
|
import { Placement } from '@floating-ui/react';
|
|
4
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
+
import { RuleItem } from 'async-validator';
|
|
4
6
|
|
|
5
|
-
interface ButtonBaseProps {
|
|
7
|
+
interface ButtonBaseProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
6
8
|
/** Whether to enable ripple effect */
|
|
7
9
|
hasRipple?: boolean;
|
|
8
|
-
/** Custom class name */
|
|
9
|
-
className?: string;
|
|
10
|
-
/** Custom style */
|
|
11
|
-
style?: React.CSSProperties;
|
|
12
|
-
/** Whether the button is disabled */
|
|
13
|
-
disabled?: boolean;
|
|
14
10
|
/** Ripple background color */
|
|
15
11
|
rippleBgColor?: string;
|
|
16
12
|
/** Ripple opacity */
|
|
17
13
|
rippleOpacity?: number;
|
|
18
|
-
/** Button content */
|
|
19
|
-
children?: React.ReactNode;
|
|
20
|
-
/** Click event handler */
|
|
21
|
-
onClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
22
14
|
}
|
|
23
15
|
|
|
24
16
|
interface ButtonProps extends ButtonBaseProps {
|
|
@@ -854,8 +846,19 @@ interface Theme {
|
|
|
854
846
|
select: SelectTheme;
|
|
855
847
|
pagination: PaginationTheme;
|
|
856
848
|
tree: TreeTheme;
|
|
849
|
+
form: FormTheme;
|
|
857
850
|
};
|
|
858
851
|
}
|
|
852
|
+
interface FormTheme {
|
|
853
|
+
itemMarginBottom: string;
|
|
854
|
+
labelColor: string;
|
|
855
|
+
labelFontSize: string;
|
|
856
|
+
labelMarginBottom: string;
|
|
857
|
+
errorColor: string;
|
|
858
|
+
errorFontSize: string;
|
|
859
|
+
errorMarginTop: string;
|
|
860
|
+
errorMarginBottom: string;
|
|
861
|
+
}
|
|
859
862
|
interface TreeTheme {
|
|
860
863
|
nodeSelectedBg: string;
|
|
861
864
|
nodeHoverBg: string;
|
|
@@ -1151,4 +1154,119 @@ interface InputNumberProps extends Omit<InputFieldProps, 'onChange' | 'value' |
|
|
|
1151
1154
|
|
|
1152
1155
|
declare const InputNumber: React__default.ForwardRefExoticComponent<InputNumberProps & React__default.RefAttributes<HTMLInputElement>>;
|
|
1153
1156
|
|
|
1154
|
-
|
|
1157
|
+
type StoreValue = unknown;
|
|
1158
|
+
type Store = Record<string, StoreValue>;
|
|
1159
|
+
interface FieldData {
|
|
1160
|
+
name: string;
|
|
1161
|
+
value?: StoreValue;
|
|
1162
|
+
touched?: boolean;
|
|
1163
|
+
validating?: boolean;
|
|
1164
|
+
errors?: string[];
|
|
1165
|
+
}
|
|
1166
|
+
/**
|
|
1167
|
+
* Interface for Field Entity (FormItem)
|
|
1168
|
+
*/
|
|
1169
|
+
interface FieldEntity {
|
|
1170
|
+
onStoreChange: () => void;
|
|
1171
|
+
validateRules: (options?: {
|
|
1172
|
+
triggerName?: string;
|
|
1173
|
+
}) => Promise<string[] | null>;
|
|
1174
|
+
getName: () => string;
|
|
1175
|
+
getErrors: () => string[];
|
|
1176
|
+
isFieldValidating: () => boolean;
|
|
1177
|
+
isFieldTouched: () => boolean;
|
|
1178
|
+
props: {
|
|
1179
|
+
name?: string;
|
|
1180
|
+
rules?: RuleItem[];
|
|
1181
|
+
dependencies?: string[];
|
|
1182
|
+
initialValue?: unknown;
|
|
1183
|
+
};
|
|
1184
|
+
}
|
|
1185
|
+
interface Callbacks<Values = Record<string, unknown>> {
|
|
1186
|
+
onValuesChange?: (changedValues: Store, values: Values) => void;
|
|
1187
|
+
onFieldsChange?: (changedFields: FieldData[], allFields: FieldData[]) => void;
|
|
1188
|
+
onFinish?: (values: Values) => void;
|
|
1189
|
+
onFinishFailed?: (errorInfo: ValidateErrorEntity<Values>) => void;
|
|
1190
|
+
}
|
|
1191
|
+
interface ValidateErrorEntity<Values = Record<string, unknown>> {
|
|
1192
|
+
values: Values;
|
|
1193
|
+
errorFields: {
|
|
1194
|
+
name: string;
|
|
1195
|
+
errors: string[];
|
|
1196
|
+
}[];
|
|
1197
|
+
outOfDate: boolean;
|
|
1198
|
+
}
|
|
1199
|
+
interface InternalHooks {
|
|
1200
|
+
registerField: (entity: FieldEntity) => () => void;
|
|
1201
|
+
registerWatch: (callback: (name: string) => void) => () => void;
|
|
1202
|
+
setInitialValues: (values: Store, init: boolean) => void;
|
|
1203
|
+
setCallbacks: (callbacks: Callbacks) => void;
|
|
1204
|
+
dispatch: (action: ReducerAction) => void;
|
|
1205
|
+
getFieldValue: (name: string) => StoreValue;
|
|
1206
|
+
notifyFieldChange: (name: string) => void;
|
|
1207
|
+
}
|
|
1208
|
+
interface FormInstance<Values = Record<string, unknown>> {
|
|
1209
|
+
getFieldValue: (name: string) => StoreValue;
|
|
1210
|
+
getFieldsValue: () => Values;
|
|
1211
|
+
getFieldError: (name: string) => string[];
|
|
1212
|
+
isFieldsTouched: (nameList?: string[]) => boolean;
|
|
1213
|
+
isFieldTouched: (name: string) => boolean;
|
|
1214
|
+
isFieldValidating: (name: string) => boolean;
|
|
1215
|
+
resetFields: (fields?: string[]) => void;
|
|
1216
|
+
setFields: (fields: FieldData[]) => void;
|
|
1217
|
+
setFieldValue: (name: string, value: unknown) => void;
|
|
1218
|
+
setFieldsValue: (values: RecursivePartial<Values>) => void;
|
|
1219
|
+
validateFields: (nameList?: string[]) => Promise<Values>;
|
|
1220
|
+
submit: () => void;
|
|
1221
|
+
getInternalHooks: (secret: string) => InternalHooks | null;
|
|
1222
|
+
}
|
|
1223
|
+
type RecursivePartial<T> = {
|
|
1224
|
+
[P in keyof T]?: T[P] extends (infer U)[] ? RecursivePartial<U>[] : T[P] extends object ? RecursivePartial<T[P]> : T[P];
|
|
1225
|
+
};
|
|
1226
|
+
interface ReducerAction {
|
|
1227
|
+
type: string;
|
|
1228
|
+
payload: unknown;
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
interface FormProps<Values = Record<string, unknown>> {
|
|
1232
|
+
form?: FormInstance<Values>;
|
|
1233
|
+
initialValues?: Store;
|
|
1234
|
+
children?: ReactNode;
|
|
1235
|
+
onFinish?: (values: Values) => void;
|
|
1236
|
+
onFinishFailed?: (errorInfo: ValidateErrorEntity<Values>) => void;
|
|
1237
|
+
onValuesChange?: (changedValues: Store, values: Values) => void;
|
|
1238
|
+
onFieldsChange?: (changedFields: FieldData[], allFields: FieldData[]) => void;
|
|
1239
|
+
className?: string;
|
|
1240
|
+
style?: React__default.CSSProperties;
|
|
1241
|
+
}
|
|
1242
|
+
declare const Form$1: <Values extends Record<string, unknown> = Record<string, unknown>>({ form, initialValues, children, onFinish, onFinishFailed, onValuesChange, onFieldsChange, className, style, }: FormProps<Values>) => react_jsx_runtime.JSX.Element;
|
|
1243
|
+
|
|
1244
|
+
interface FormItemProps {
|
|
1245
|
+
name?: string;
|
|
1246
|
+
label?: string;
|
|
1247
|
+
rules?: RuleItem[];
|
|
1248
|
+
children: ReactElement;
|
|
1249
|
+
validateTrigger?: string | string[];
|
|
1250
|
+
initialValue?: unknown;
|
|
1251
|
+
className?: string;
|
|
1252
|
+
style?: React__default.CSSProperties;
|
|
1253
|
+
}
|
|
1254
|
+
declare const FormItem: React__default.FC<FormItemProps>;
|
|
1255
|
+
|
|
1256
|
+
declare const useForm: <Values extends Record<string, unknown> = Record<string, unknown>>(form?: FormInstance<Values>) => [FormInstance<Values>];
|
|
1257
|
+
|
|
1258
|
+
declare const useWatch: <T = unknown>(name: string | string[], form?: FormInstance) => T;
|
|
1259
|
+
|
|
1260
|
+
type InternalFormType = typeof Form$1;
|
|
1261
|
+
interface FormInterface extends InternalFormType {
|
|
1262
|
+
Item: typeof FormItem;
|
|
1263
|
+
useForm: typeof useForm;
|
|
1264
|
+
useWatch: typeof useWatch;
|
|
1265
|
+
}
|
|
1266
|
+
declare const Form: FormInterface & {
|
|
1267
|
+
Item: typeof FormItem;
|
|
1268
|
+
useForm: typeof useForm;
|
|
1269
|
+
useWatch: typeof useWatch;
|
|
1270
|
+
};
|
|
1271
|
+
|
|
1272
|
+
export { Button, type ButtonProps, ConfigProvider, type ConfigProviderProps, type DataNode, DatePicker, type DatePickerProps, type DateRangePickerProps, Dropdown, type DropdownProps, type FieldData, Form, type FormInstance, type FormItemProps, type FormProps, InputField, type InputFieldProps, InputNumber, type InputNumberProps, type ItemType, Menu, type MenuItemProps, type MenuProps, messageWithHook as Message, type MessageProps, ModalWithStatics as Modal, type ModalBaseProps as ModalProps, Pagination, type PaginationProps, Progress, type ProgressProps, Select, type SelectOption, type SelectProps, type SelectValue, Steps, type StepsProps, Tree, type TreeNodeProps, type TreeProps, type ValidateErrorEntity };
|