@xinghunm/compass-ui 0.1.0 → 0.2.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 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,107 @@ 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
- export { Button, type ButtonProps, ConfigProvider, type ConfigProviderProps, type DataNode, DatePicker, type DatePickerProps, type DateRangePickerProps, Dropdown, type DropdownProps, 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 };
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: () => Promise<string[] | null>;
1172
+ getName: () => string;
1173
+ getErrors: () => string[];
1174
+ props: {
1175
+ name?: string;
1176
+ rules?: RuleItem[];
1177
+ dependencies?: string[];
1178
+ initialValue?: unknown;
1179
+ };
1180
+ }
1181
+ interface Callbacks<Values = Record<string, unknown>> {
1182
+ onValuesChange?: (changedValues: Store, values: Values) => void;
1183
+ onFinish?: (values: Values) => void;
1184
+ onFinishFailed?: (errorInfo: ValidateErrorEntity<Values>) => void;
1185
+ }
1186
+ interface ValidateErrorEntity<Values = Record<string, unknown>> {
1187
+ values: Values;
1188
+ errorFields: {
1189
+ name: string;
1190
+ errors: string[];
1191
+ }[];
1192
+ outOfDate: boolean;
1193
+ }
1194
+ interface InternalHooks {
1195
+ registerField: (entity: FieldEntity) => () => void;
1196
+ setInitialValues: (values: Store, init: boolean) => void;
1197
+ setCallbacks: (callbacks: Callbacks) => void;
1198
+ dispatch: (action: ReducerAction) => void;
1199
+ getFieldValue: (name: string) => StoreValue;
1200
+ }
1201
+ interface FormInstance<Values = Record<string, unknown>> {
1202
+ getFieldValue: (name: string) => StoreValue;
1203
+ getFieldsValue: () => Values;
1204
+ getFieldError: (name: string) => string[];
1205
+ isFieldsTouched: (nameList?: string[]) => boolean;
1206
+ isFieldTouched: (name: string) => boolean;
1207
+ isFieldValidating: (name: string) => boolean;
1208
+ resetFields: (fields?: string[]) => void;
1209
+ setFields: (fields: FieldData[]) => void;
1210
+ setFieldValue: (name: string, value: unknown) => void;
1211
+ setFieldsValue: (values: RecursivePartial<Values>) => void;
1212
+ validateFields: (nameList?: string[]) => Promise<Values>;
1213
+ submit: () => void;
1214
+ getInternalHooks: (secret: string) => InternalHooks | null;
1215
+ }
1216
+ type RecursivePartial<T> = {
1217
+ [P in keyof T]?: T[P] extends (infer U)[] ? RecursivePartial<U>[] : T[P] extends object ? RecursivePartial<T[P]> : T[P];
1218
+ };
1219
+ interface ReducerAction {
1220
+ type: string;
1221
+ payload: unknown;
1222
+ }
1223
+
1224
+ interface FormProps<Values = Record<string, unknown>> {
1225
+ form?: FormInstance<Values>;
1226
+ initialValues?: Store;
1227
+ children?: ReactNode;
1228
+ onFinish?: (values: Values) => void;
1229
+ onFinishFailed?: (errorInfo: ValidateErrorEntity<Values>) => void;
1230
+ onValuesChange?: (changedValues: Store, values: Values) => void;
1231
+ className?: string;
1232
+ style?: React__default.CSSProperties;
1233
+ }
1234
+ declare const Form$1: <Values extends Record<string, unknown> = Record<string, unknown>>({ form, initialValues, children, onFinish, onFinishFailed, onValuesChange, className, style, }: FormProps<Values>) => react_jsx_runtime.JSX.Element;
1235
+
1236
+ interface FormItemProps {
1237
+ name?: string;
1238
+ label?: string;
1239
+ rules?: RuleItem[];
1240
+ children: ReactElement;
1241
+ validateTrigger?: string | string[];
1242
+ initialValue?: unknown;
1243
+ className?: string;
1244
+ style?: React__default.CSSProperties;
1245
+ }
1246
+ declare const FormItem: React__default.FC<FormItemProps>;
1247
+
1248
+ declare const useForm: <Values extends Record<string, unknown> = Record<string, unknown>>(form?: FormInstance<Values>) => [FormInstance<Values>];
1249
+
1250
+ type InternalFormType = typeof Form$1;
1251
+ interface FormInterface extends InternalFormType {
1252
+ Item: typeof FormItem;
1253
+ useForm: typeof useForm;
1254
+ }
1255
+ declare const Form: FormInterface & {
1256
+ Item: typeof FormItem;
1257
+ useForm: typeof useForm;
1258
+ };
1259
+
1260
+ 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,107 @@ 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
- export { Button, type ButtonProps, ConfigProvider, type ConfigProviderProps, type DataNode, DatePicker, type DatePickerProps, type DateRangePickerProps, Dropdown, type DropdownProps, 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 };
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: () => Promise<string[] | null>;
1172
+ getName: () => string;
1173
+ getErrors: () => string[];
1174
+ props: {
1175
+ name?: string;
1176
+ rules?: RuleItem[];
1177
+ dependencies?: string[];
1178
+ initialValue?: unknown;
1179
+ };
1180
+ }
1181
+ interface Callbacks<Values = Record<string, unknown>> {
1182
+ onValuesChange?: (changedValues: Store, values: Values) => void;
1183
+ onFinish?: (values: Values) => void;
1184
+ onFinishFailed?: (errorInfo: ValidateErrorEntity<Values>) => void;
1185
+ }
1186
+ interface ValidateErrorEntity<Values = Record<string, unknown>> {
1187
+ values: Values;
1188
+ errorFields: {
1189
+ name: string;
1190
+ errors: string[];
1191
+ }[];
1192
+ outOfDate: boolean;
1193
+ }
1194
+ interface InternalHooks {
1195
+ registerField: (entity: FieldEntity) => () => void;
1196
+ setInitialValues: (values: Store, init: boolean) => void;
1197
+ setCallbacks: (callbacks: Callbacks) => void;
1198
+ dispatch: (action: ReducerAction) => void;
1199
+ getFieldValue: (name: string) => StoreValue;
1200
+ }
1201
+ interface FormInstance<Values = Record<string, unknown>> {
1202
+ getFieldValue: (name: string) => StoreValue;
1203
+ getFieldsValue: () => Values;
1204
+ getFieldError: (name: string) => string[];
1205
+ isFieldsTouched: (nameList?: string[]) => boolean;
1206
+ isFieldTouched: (name: string) => boolean;
1207
+ isFieldValidating: (name: string) => boolean;
1208
+ resetFields: (fields?: string[]) => void;
1209
+ setFields: (fields: FieldData[]) => void;
1210
+ setFieldValue: (name: string, value: unknown) => void;
1211
+ setFieldsValue: (values: RecursivePartial<Values>) => void;
1212
+ validateFields: (nameList?: string[]) => Promise<Values>;
1213
+ submit: () => void;
1214
+ getInternalHooks: (secret: string) => InternalHooks | null;
1215
+ }
1216
+ type RecursivePartial<T> = {
1217
+ [P in keyof T]?: T[P] extends (infer U)[] ? RecursivePartial<U>[] : T[P] extends object ? RecursivePartial<T[P]> : T[P];
1218
+ };
1219
+ interface ReducerAction {
1220
+ type: string;
1221
+ payload: unknown;
1222
+ }
1223
+
1224
+ interface FormProps<Values = Record<string, unknown>> {
1225
+ form?: FormInstance<Values>;
1226
+ initialValues?: Store;
1227
+ children?: ReactNode;
1228
+ onFinish?: (values: Values) => void;
1229
+ onFinishFailed?: (errorInfo: ValidateErrorEntity<Values>) => void;
1230
+ onValuesChange?: (changedValues: Store, values: Values) => void;
1231
+ className?: string;
1232
+ style?: React__default.CSSProperties;
1233
+ }
1234
+ declare const Form$1: <Values extends Record<string, unknown> = Record<string, unknown>>({ form, initialValues, children, onFinish, onFinishFailed, onValuesChange, className, style, }: FormProps<Values>) => react_jsx_runtime.JSX.Element;
1235
+
1236
+ interface FormItemProps {
1237
+ name?: string;
1238
+ label?: string;
1239
+ rules?: RuleItem[];
1240
+ children: ReactElement;
1241
+ validateTrigger?: string | string[];
1242
+ initialValue?: unknown;
1243
+ className?: string;
1244
+ style?: React__default.CSSProperties;
1245
+ }
1246
+ declare const FormItem: React__default.FC<FormItemProps>;
1247
+
1248
+ declare const useForm: <Values extends Record<string, unknown> = Record<string, unknown>>(form?: FormInstance<Values>) => [FormInstance<Values>];
1249
+
1250
+ type InternalFormType = typeof Form$1;
1251
+ interface FormInterface extends InternalFormType {
1252
+ Item: typeof FormItem;
1253
+ useForm: typeof useForm;
1254
+ }
1255
+ declare const Form: FormInterface & {
1256
+ Item: typeof FormItem;
1257
+ useForm: typeof useForm;
1258
+ };
1259
+
1260
+ 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 };