revdev-components 0.20.0 → 0.22.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.
@@ -13,7 +13,8 @@ export interface RegularDialogProps {
13
13
  cancelText?: string;
14
14
  footerClassName?: string;
15
15
  contentClassName?: string;
16
- hideOk?: boolean;
16
+ okHide?: boolean;
17
+ okDisabled?: boolean;
17
18
  onOk?: () => void;
18
19
  onClose?: () => void;
19
20
  open?: boolean;
@@ -1,19 +1,17 @@
1
1
  import React from "react";
2
2
  import { FormInstance } from "antd/lib/form";
3
- import { Store } from "antd/es/form/interface";
4
3
  import { FieldData } from "../interfaces";
5
4
  export interface FormOptions {
6
5
  valid: boolean;
7
6
  }
8
- export interface AppFormProps {
7
+ export interface AppFormProps<T = any> {
9
8
  children?: React.ReactNode | ((options: FormOptions) => React.ReactNode);
10
9
  className?: string;
11
- onFinish?: (values: any) => void;
12
- onValuesChange?: (changedValues: any, values: any) => void;
13
- onChange?: (values: any) => void;
10
+ onFinish?: (values: T) => void;
11
+ onValuesChange?: (changedValues: Partial<T>, values: T) => void;
14
12
  onFieldsChange?: (changedFields: FieldData[], allFields: FieldData[]) => void;
15
13
  form?: FormInstance;
16
14
  onValid?: (valid: boolean) => void;
17
- initialValues?: Store;
15
+ initialValues?: T;
18
16
  }
19
- export declare const AppForm: React.FC<AppFormProps>;
17
+ export declare function AppForm<T = any>({ form: propForm, children, className, onFinish, onValuesChange, onFieldsChange, onValid, initialValues, }: AppFormProps<T>): React.ReactElement<AppFormProps<T>>;
package/build/index.js CHANGED
@@ -4620,28 +4620,11 @@ function useForm(form) {
4620
4620
  var newForm = antd.Form.useForm()[0];
4621
4621
  return form ? form : newForm;
4622
4622
  }
4623
- var AppForm = function (_a) {
4624
- var propForm = _a.form, children = _a.children, className = _a.className, onFinish = _a.onFinish, onValuesChange = _a.onValuesChange, onChange = _a.onChange, onFieldsChange = _a.onFieldsChange, onValid = _a.onValid, initialValues = _a.initialValues;
4623
+ function AppForm(_a) {
4624
+ var propForm = _a.form, children = _a.children, className = _a.className, onFinish = _a.onFinish, onValuesChange = _a.onValuesChange, onFieldsChange = _a.onFieldsChange, onValid = _a.onValid, initialValues = _a.initialValues;
4625
4625
  var form = useForm(propForm);
4626
4626
  var _b = React.useState(false), valid = _b[0], setValid = _b[1];
4627
4627
  var values = antd.Form.useWatch([], form);
4628
- var handleValuesChange = React.useCallback(function (changedValues, values) {
4629
- if (onValuesChange) {
4630
- onValuesChange(changedValues, values);
4631
- }
4632
- }, [form, onValuesChange]);
4633
- var handleFieldsChange = React.useCallback(function (changedFields, allFields) {
4634
- if (onFieldsChange) {
4635
- onFieldsChange(changedFields, allFields);
4636
- }
4637
- if (onChange) {
4638
- var allValues_1 = {};
4639
- allFields.forEach(function (x) {
4640
- allValues_1[x.name] = x.value;
4641
- });
4642
- onChange(allValues_1);
4643
- }
4644
- }, [form, onFieldsChange, onChange]);
4645
4628
  React.useEffect(function () {
4646
4629
  form
4647
4630
  .validateFields({ validateOnly: true })
@@ -4651,8 +4634,8 @@ var AppForm = function (_a) {
4651
4634
  React.useEffect(function () {
4652
4635
  onValid === null || onValid === void 0 ? void 0 : onValid(valid);
4653
4636
  }, [onValid, valid]);
4654
- return (React.createElement(antd.Form, { form: form, onFinish: onFinish, className: classNames(s$g.root, className), layout: "vertical", onValuesChange: handleValuesChange, onFieldsChange: handleFieldsChange, initialValues: initialValues }, typeof children === "function" ? children({ valid: valid }) : children));
4655
- };
4637
+ return (React.createElement(antd.Form, { form: form, onFinish: onFinish, className: classNames(s$g.root, className), layout: "vertical", onValuesChange: onValuesChange, onFieldsChange: onFieldsChange, initialValues: initialValues }, typeof children === "function" ? children({ valid: valid }) : children));
4638
+ }
4656
4639
 
4657
4640
  var s$f = {"root":"index-module_root__2S1Jp"};
4658
4641
 
@@ -4814,7 +4797,7 @@ var InfoDialog = function (_a) {
4814
4797
  var s$8 = {"root":"index-module_root__BQI-i","header":"index-module_header__OUCQj","title":"index-module_title__HPbDC","close":"index-module_close__-FN6K","content":"index-module_content__BpXha","footer":"index-module_footer__xqKte"};
4815
4798
 
4816
4799
  var RegularDialog = function (_a) {
4817
- var titleIcon = _a.titleIcon, titlePrefix = _a.titlePrefix, title = _a.title, children = _a.children, _b = _a.hideFooter, hideFooter = _b === void 0 ? false : _b, className = _a.className, width = _a.width, okText = _a.okText, cancelText = _a.cancelText, footerClassName = _a.footerClassName, contentClassName = _a.contentClassName, hideOk = _a.hideOk, onOk = _a.onOk, onClose = _a.onClose, _c = _a.open, open = _c === void 0 ? true : _c;
4800
+ var titleIcon = _a.titleIcon, titlePrefix = _a.titlePrefix, title = _a.title, children = _a.children, _b = _a.hideFooter, hideFooter = _b === void 0 ? false : _b, className = _a.className, width = _a.width, okText = _a.okText, cancelText = _a.cancelText, footerClassName = _a.footerClassName, contentClassName = _a.contentClassName, okHide = _a.okHide, okDisabled = _a.okDisabled, onOk = _a.onOk, onClose = _a.onClose, _c = _a.open, open = _c === void 0 ? true : _c;
4818
4801
  var close = React.useMemo(function () {
4819
4802
  return React.createElement(RegularIcon, { name: "cross", className: s$8.close, onClick: onClose });
4820
4803
  }, [onClose]);
@@ -4851,7 +4834,7 @@ var RegularDialog = function (_a) {
4851
4834
  React.createElement("div", { className: classNames(s$8.content, contentClassName) }, children),
4852
4835
  hideFooter ? null : (React.createElement("div", { className: classNames(s$8.footer, footerClassName) },
4853
4836
  React.createElement(antd.Button, { onClick: onClose }, cancelText || "Cancel"),
4854
- hideOk ? null : (React.createElement(antd.Button, { type: "primary", onClick: handleOk }, okText || "OK"))))));
4837
+ okHide ? null : (React.createElement(antd.Button, { type: "primary", onClick: handleOk, disabled: okDisabled }, okText || "OK"))))));
4855
4838
  };
4856
4839
 
4857
4840
  var s$7 = {"root":"index-module_root__9mhio"};
@@ -1,9 +1,9 @@
1
1
  export interface FieldData {
2
- touched: boolean;
3
- validating: boolean;
4
- errors: string[];
5
- warnings: string[];
2
+ touched?: boolean;
3
+ validating?: boolean;
4
+ errors?: string[];
5
+ warnings?: string[];
6
6
  name: string;
7
- validated: boolean;
7
+ validated?: boolean;
8
8
  value?: any;
9
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "revdev-components",
3
- "version": "0.20.0",
3
+ "version": "0.22.0",
4
4
  "main": "build/index.js",
5
5
  "module": "build/index.esm.js",
6
6
  "scripts": {