guestbell-forms 3.0.84 → 3.0.86
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/build/components/button/Button.js +22 -11
- package/build/components/button/Button.js.map +1 -1
- package/build/components/form/Form.d.ts +4 -2
- package/build/components/form/Form.js +36 -27
- package/build/components/form/Form.js.map +1 -1
- package/build/components/form/FormContext.d.ts +1 -14
- package/build/components/form/FormContext.js.map +1 -1
- package/build/components/form/FormValidationContext.d.ts +27 -0
- package/build/components/form/FormValidationContext.js +15 -0
- package/build/components/form/FormValidationContext.js.map +1 -0
- package/build/components/form/FormValidationSummary.d.ts +3 -3
- package/build/components/form/FormValidationSummary.js +3 -3
- package/build/components/form/FormValidationSummary.js.map +1 -1
- package/build/components/form/withFormContext.d.ts +1 -1
- package/build/components/form/withFormContext.js.map +1 -1
- package/build/components/form/withFormValidationContext.d.ts +3 -0
- package/build/components/form/withFormValidationContext.js +25 -0
- package/build/components/form/withFormValidationContext.js.map +1 -0
- package/build/components/submit/Submit.d.ts +3 -2
- package/build/components/submit/Submit.js +5 -5
- package/build/components/submit/Submit.js.map +1 -1
- package/build/dist/report.html +1 -1
- package/package.json +1 -1
- package/src/lib/components/button/Button.tsx +17 -13
- package/src/lib/components/form/Form.tsx +48 -32
- package/src/lib/components/form/FormContext.ts +4 -18
- package/src/lib/components/form/FormValidationContext.ts +40 -0
- package/src/lib/components/form/FormValidationSummary.tsx +12 -7
- package/src/lib/components/form/withFormContext.tsx +14 -11
- package/src/lib/components/form/withFormValidationContext.tsx +29 -0
- package/src/lib/components/submit/Submit.tsx +9 -7
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"FormValidationSummary.js","names":["React","_interopRequireWildcard","require","_Guid","_interopRequireDefault","_withFormContext","_Button","_classnames","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","ArrowIcon","props","createElement","d","defaultProps","xmlns","width","height","viewBox","DefaultComponent","Fragment","componentsWithErrors","map","component","index","className","validation","name","errors","err","errIndex","style","flex","componentApi","focus","scrollTo","Button","icon","circular","type","small","blank","onClick","exports","FormValidationSummaryRaw","PureComponent","constructor","arguments","componentId","guid","render","formContext","keys","components","filter","isValid","console","warn","containerClassName","classNames","headerClassName","footerClassName","length","title","Component","footer","FormValidationSummary","withFormContext"],"sources":["../../../src/lib/components/form/FormValidationSummary.tsx"],"sourcesContent":["import * as React from 'react';\r\nimport guid from '../utils/Guid';\r\nimport { withFormContext } from './withFormContext';\r\nimport { FormContextProps, FormComponentContextState } from './FormContext';\r\nimport { Button } from './../button/Button';\r\nimport classNames from 'classnames';\r\n\r\nimport * as ArrowIcon from 'material-design-icons/maps/svg/production/ic_my_location_24px.svg';\r\n\r\nexport interface FormValidationSummaryComponentProps {\r\n componentsWithErrors: FormComponentContextState[];\r\n}\r\n\r\nexport type FormValidationSummaryProps = {\r\n containerClassName?: string;\r\n headerClassName?: string;\r\n footerClassName?: string;\r\n title?: string | JSX.Element;\r\n footer?: string | JSX.Element;\r\n Component?:\r\n | React.ComponentType<FormValidationSummaryComponentProps>\r\n | React.FC<FormValidationSummaryComponentProps>;\r\n} & FormContextProps;\r\n\r\nexport interface FormValidationSummaryState {}\r\n\r\nexport const DefaultComponent: React.FC<FormValidationSummaryComponentProps> = (\r\n props\r\n) => (\r\n <React.Fragment>\r\n {props.componentsWithErrors.map((component, index) => {\r\n return (\r\n <div key={index} className=\"formValidationSummary__item\">\r\n <div className=\"formValidationSummary__item__header\">\r\n {component.validation.name ? component.validation.name : 'unknown'}\r\n </div>\r\n <div className=\"formValidationSummary__item__errors\">\r\n {component.validation.errors &&\r\n component.validation.errors.map((err, errIndex) => (\r\n <span\r\n className=\"formValidationSummary__item__error\"\r\n key={errIndex}\r\n >\r\n {err}\r\n </span>\r\n ))}\r\n </div>\r\n <div style={{ flex: 'auto' }} />\r\n {component.componentApi &&\r\n component.componentApi.focus &&\r\n component.componentApi.scrollTo && (\r\n <Button\r\n icon={true}\r\n className=\"formValidationSummary__item__locate-button\"\r\n circular={true}\r\n type=\"error\"\r\n small={true}\r\n blank={true}\r\n onClick={() => {\r\n component.componentApi.scrollTo();\r\n component.componentApi.focus();\r\n }}\r\n >\r\n <ArrowIcon />\r\n </Button>\r\n )}\r\n </div>\r\n );\r\n })}\r\n </React.Fragment>\r\n);\r\n\r\nexport class FormValidationSummaryRaw extends React.PureComponent<\r\n FormValidationSummaryProps,\r\n FormValidationSummaryState\r\n> {\r\n public static defaultProps = {\r\n title: 'Hang on',\r\n footer: '... needs fixing',\r\n Component: DefaultComponent,\r\n containerClassName: 'formValidationSummary',\r\n headerClassName: 'formValidationSummary__header',\r\n footerClassName: 'formValidationSummary__footer',\r\n };\r\n\r\n public componentId = guid();\r\n\r\n public render() {\r\n const componentsWithErrors = this.props.formContext\r\n ? Object.keys(this.props.formContext.components)\r\n .map((key) => this.props.formContext.components[key])\r\n .filter((component) => {\r\n if (!component.validation.isValid && !component.validation.name) {\r\n console.warn(\r\n component,\r\n 'Has validation error. FormValidationSummary is present but the component has no validation name'\r\n );\r\n }\r\n return !component.validation.isValid;\r\n })\r\n : [];\r\n const containerClassName = classNames(this.props.containerClassName);\r\n const headerClassName = classNames(this.props.headerClassName);\r\n const footerClassName = classNames(this.props.footerClassName);\r\n return (\r\n componentsWithErrors.length > 0 && (\r\n <div className={containerClassName}>\r\n {this.props.title && (\r\n <div className={headerClassName}>{this.props.title}</div>\r\n )}\r\n <this.props.Component componentsWithErrors={componentsWithErrors} />\r\n {this.props.footer && (\r\n <div className={footerClassName}>{this.props.footer}</div>\r\n )}\r\n </div>\r\n )\r\n );\r\n }\r\n}\r\n\r\nexport const FormValidationSummary =\r\n withFormContext<FormValidationSummaryProps>(FormValidationSummaryRaw);\r\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CA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,kBAAkB,GAAG,IAAAC,mBAAU,EAAC,IAAI,CAAChD,KAAK,CAAC+C,kBAAkB,CAAC;IACpE,MAAME,eAAe,GAAG,IAAAD,mBAAU,EAAC,IAAI,CAAChD,KAAK,CAACiD,eAAe,CAAC;IAC9D,MAAMC,eAAe,GAAG,IAAAF,mBAAU,EAAC,IAAI,CAAChD,KAAK,CAACkD,eAAe,CAAC;IAC9D,OACExC,oBAAoB,CAACyC,MAAM,GAAG,CAAC,iBAC7BlF,KAAA,CAAAgC,aAAA;MAAKa,SAAS,EAAEiC;IAAmB,GAChC,IAAI,CAAC/C,KAAK,CAACoD,KAAK,iBACfnF,KAAA,CAAAgC,aAAA;MAAKa,SAAS,EAAEmC;IAAgB,GAAE,IAAI,CAACjD,KAAK,CAACoD,KAAW,CACzD,eACDnF,KAAA,CAAAgC,aAAA,MAAMD,KAAK,CAACqD,SAAS;MAAC3C,oBAAoB,EAAEA;IAAqB,CAAE,CAAC,EACnE,IAAI,CAACV,KAAK,CAACsD,MAAM,iBAChBrF,KAAA,CAAAgC,aAAA;MAAKa,SAAS,EAAEoC;IAAgB,GAAE,IAAI,CAAClD,KAAK,CAACsD,MAAY,CAExD,CACN;EAEL;AACF;AAACtB,OAAA,CAAAC,wBAAA,GAAAA,wBAAA;AA9CYA,wBAAwB,CAIrB9B,YAAY,GAAG;EAC3BiD,KAAK,EAAE,SAAS;EAChBE,MAAM,EAAE,kBAAkB;EAC1BD,SAAS,EAAE7C,gBAAgB;EAC3BuC,kBAAkB,EAAE,uBAAuB;EAC3CE,eAAe,EAAE,+BAA+B;EAChDC,eAAe,EAAE;AACnB,CAAC;AAqCI,MAAMK,qBAAqB,GAChC,IAAAC,gCAAe,EAA6BvB,wBAAwB,CAAC;AAACD,OAAA,CAAAuB,qBAAA,GAAAA,qBAAA"}
|
1
|
+
{"version":3,"file":"FormValidationSummary.js","names":["React","_interopRequireWildcard","require","_Guid","_interopRequireDefault","_Button","_classnames","_withFormValidationContext","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","ArrowIcon","props","createElement","d","defaultProps","xmlns","width","height","viewBox","DefaultComponent","Fragment","componentsWithErrors","map","component","index","className","validation","name","errors","err","errIndex","style","flex","componentApi","focus","scrollTo","Button","icon","circular","type","small","blank","onClick","exports","FormValidationSummaryRaw","PureComponent","constructor","arguments","componentId","guid","render","formValidationContext","keys","components","filter","isValid","console","warn","containerClassName","classNames","headerClassName","footerClassName","length","title","Component","footer","FormValidationSummary","withFormValidationContext"],"sources":["../../../src/lib/components/form/FormValidationSummary.tsx"],"sourcesContent":["import * as React from 'react';\r\nimport guid from '../utils/Guid';\r\nimport {\r\n FormValidationContextProps,\r\n FormComponentContextState,\r\n} from './FormValidationContext';\r\nimport { Button } from './../button/Button';\r\nimport classNames from 'classnames';\r\n\r\nimport * as ArrowIcon from 'material-design-icons/maps/svg/production/ic_my_location_24px.svg';\r\nimport { withFormValidationContext } from './withFormValidationContext';\r\n\r\nexport interface FormValidationSummaryComponentProps {\r\n componentsWithErrors: FormComponentContextState[];\r\n}\r\n\r\nexport type FormValidationSummaryProps = {\r\n containerClassName?: string;\r\n headerClassName?: string;\r\n footerClassName?: string;\r\n title?: string | JSX.Element;\r\n footer?: string | JSX.Element;\r\n Component?:\r\n | React.ComponentType<FormValidationSummaryComponentProps>\r\n | React.FC<FormValidationSummaryComponentProps>;\r\n} & FormValidationContextProps;\r\n\r\nexport interface FormValidationSummaryState {}\r\n\r\nexport const DefaultComponent: React.FC<FormValidationSummaryComponentProps> = (\r\n props\r\n) => (\r\n <React.Fragment>\r\n {props.componentsWithErrors.map((component, index) => {\r\n return (\r\n <div key={index} className=\"formValidationSummary__item\">\r\n <div className=\"formValidationSummary__item__header\">\r\n {component.validation.name ? component.validation.name : 'unknown'}\r\n </div>\r\n <div className=\"formValidationSummary__item__errors\">\r\n {component.validation.errors &&\r\n component.validation.errors.map((err, errIndex) => (\r\n <span\r\n className=\"formValidationSummary__item__error\"\r\n key={errIndex}\r\n >\r\n {err}\r\n </span>\r\n ))}\r\n </div>\r\n <div style={{ flex: 'auto' }} />\r\n {component.componentApi &&\r\n component.componentApi.focus &&\r\n component.componentApi.scrollTo && (\r\n <Button\r\n icon={true}\r\n className=\"formValidationSummary__item__locate-button\"\r\n circular={true}\r\n type=\"error\"\r\n small={true}\r\n blank={true}\r\n onClick={() => {\r\n component.componentApi.scrollTo();\r\n component.componentApi.focus();\r\n }}\r\n >\r\n <ArrowIcon />\r\n </Button>\r\n )}\r\n </div>\r\n );\r\n })}\r\n </React.Fragment>\r\n);\r\n\r\nexport class FormValidationSummaryRaw extends React.PureComponent<\r\n FormValidationSummaryProps,\r\n FormValidationSummaryState\r\n> {\r\n public static defaultProps = {\r\n title: 'Hang on',\r\n footer: '... needs fixing',\r\n Component: DefaultComponent,\r\n containerClassName: 'formValidationSummary',\r\n headerClassName: 'formValidationSummary__header',\r\n footerClassName: 'formValidationSummary__footer',\r\n };\r\n\r\n public componentId = guid();\r\n\r\n public render() {\r\n const componentsWithErrors = this.props.formValidationContext\r\n ? Object.keys(this.props.formValidationContext.components)\r\n .map((key) => this.props.formValidationContext.components[key])\r\n .filter((component) => {\r\n if (!component.validation.isValid && !component.validation.name) {\r\n console.warn(\r\n component,\r\n 'Has validation error. FormValidationSummary is present but the component has no validation name'\r\n );\r\n }\r\n return !component.validation.isValid;\r\n })\r\n : [];\r\n const containerClassName = classNames(this.props.containerClassName);\r\n const headerClassName = classNames(this.props.headerClassName);\r\n const footerClassName = classNames(this.props.footerClassName);\r\n return (\r\n componentsWithErrors.length > 0 && (\r\n <div className={containerClassName}>\r\n {this.props.title && (\r\n <div className={headerClassName}>{this.props.title}</div>\r\n )}\r\n <this.props.Component componentsWithErrors={componentsWithErrors} />\r\n {this.props.footer && (\r\n <div className={footerClassName}>{this.props.footer}</div>\r\n )}\r\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vB,wBACF,CAAC;AAACD,OAAA,CAAAuB,qBAAA,GAAAA,qBAAA"}
|
@@ -1,3 +1,3 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
import { FormContextProps } from './FormContext';
|
3
|
-
export declare function withFormContext<P extends FormContextProps>(Component: React.ComponentClass<P>): React.ForwardRefExoticComponent<React.RefAttributes<
|
3
|
+
export declare function withFormContext<P extends FormContextProps>(Component: React.ComponentClass<P> | React.ForwardRefExoticComponent<P>): React.ForwardRefExoticComponent<React.RefAttributes<React.ComponentClass<P> | React.ForwardRefExoticComponent<P>> & React.PropsWithoutRef<React.PropsWithChildren<P>>>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"withFormContext.js","names":["React","_interopRequireWildcard","require","_FormContext","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","_extends","assign","bind","target","i","arguments","length","source","apply","withFormContext","Component","WithFormContext","forwardRef","props","ref","createElement","FormContextConsumer","value","formContext"],"sources":["../../../src/lib/components/form/withFormContext.tsx"],"sourcesContent":["import * as React from 'react';\r\nimport { FormContextConsumer, FormContextProps } from './FormContext';\r\n\r\nexport function withFormContext<P extends FormContextProps>(\r\n Component: React.ComponentClass<P>\r\n): React.ForwardRefExoticComponent<\r\n React.RefAttributes<
|
1
|
+
{"version":3,"file":"withFormContext.js","names":["React","_interopRequireWildcard","require","_FormContext","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","_extends","assign","bind","target","i","arguments","length","source","apply","withFormContext","Component","WithFormContext","forwardRef","props","ref","createElement","FormContextConsumer","value","formContext"],"sources":["../../../src/lib/components/form/withFormContext.tsx"],"sourcesContent":["import * as React from 'react';\r\nimport { FormContextConsumer, FormContextProps } from './FormContext';\r\n\r\nexport function withFormContext<P extends FormContextProps>(\r\n Component: React.ComponentClass<P> | React.ForwardRefExoticComponent<P>\r\n): React.ForwardRefExoticComponent<\r\n React.RefAttributes<\r\n React.ComponentClass<P> | React.ForwardRefExoticComponent<P>\r\n > &\r\n React.PropsWithoutRef<React.PropsWithChildren<P>>\r\n> {\r\n const WithFormContext = React.forwardRef<\r\n React.ComponentClass<P> | React.ForwardRefExoticComponent<P>,\r\n P\r\n >((props, ref) => {\r\n return (\r\n <FormContextConsumer>\r\n {(value) => <Component ref={ref} {...props} formContext={value} />}\r\n </FormContextConsumer>\r\n );\r\n });\r\n return WithFormContext;\r\n}\r\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAAsE,SAAAE,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAJ,wBAAAQ,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,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B"}
|
@@ -0,0 +1,3 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import { FormValidationContextProps } from './FormValidationContext';
|
3
|
+
export declare function withFormValidationContext<P extends FormValidationContextProps>(Component: React.ComponentClass<P>): React.ForwardRefExoticComponent<React.RefAttributes<InstanceType<typeof Component>> & React.PropsWithoutRef<React.PropsWithChildren<P>>>;
|
@@ -0,0 +1,25 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.withFormValidationContext = withFormValidationContext;
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
8
|
+
var _FormValidationContext = require("./FormValidationContext");
|
9
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
10
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
11
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
12
|
+
function withFormValidationContext(Component) {
|
13
|
+
const WithFormValidationContext = /*#__PURE__*/React.forwardRef((props, ref) => {
|
14
|
+
return /*#__PURE__*/React.createElement(_FormValidationContext.FormValidationContextConsumer, null, value => {
|
15
|
+
console.log('value', value);
|
16
|
+
return /*#__PURE__*/React.createElement(Component, _extends({
|
17
|
+
ref: ref
|
18
|
+
}, props, {
|
19
|
+
formValidationContext: value
|
20
|
+
}));
|
21
|
+
});
|
22
|
+
});
|
23
|
+
return WithFormValidationContext;
|
24
|
+
}
|
25
|
+
//# sourceMappingURL=withFormValidationContext.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"withFormValidationContext.js","names":["React","_interopRequireWildcard","require","_FormValidationContext","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","_extends","assign","bind","target","i","arguments","length","source","apply","withFormValidationContext","Component","WithFormValidationContext","forwardRef","props","ref","createElement","FormValidationContextConsumer","value","console","log","formValidationContext"],"sources":["../../../src/lib/components/form/withFormValidationContext.tsx"],"sourcesContent":["import * as React from 'react';\r\nimport {\r\n FormValidationContextConsumer,\r\n FormValidationContextProps,\r\n} from './FormValidationContext';\r\n\r\nexport function withFormValidationContext<P extends FormValidationContextProps>(\r\n Component: React.ComponentClass<P>\r\n): React.ForwardRefExoticComponent<\r\n React.RefAttributes<InstanceType<typeof Component>> &\r\n React.PropsWithoutRef<React.PropsWithChildren<P>>\r\n> {\r\n const WithFormValidationContext = React.forwardRef<\r\n InstanceType<typeof Component>,\r\n P\r\n >((props, ref) => {\r\n return (\r\n <FormValidationContextConsumer>\r\n {(value) => {\r\n console.log('value', value);\r\n return (\r\n <Component ref={ref} {...props} formValidationContext={value} />\r\n );\r\n }}\r\n </FormValidationContextConsumer>\r\n );\r\n });\r\n return WithFormValidationContext;\r\n}\r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MAAA,CAAAU,MAAA,GAAAV,MAAA,CAAAU,MAAA,CAAAC,IAAA,eAAAC,MAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAF,CAAA,UAAAG,MAAA,GAAAF,SAAA,CAAAD,CAAA,YAAAV,GAAA,IAAAa,MAAA,QAAAhB,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAU,MAAA,EAAAb,GAAA,KAAAS,MAAA,CAAAT,GAAA,IAAAa,MAAA,CAAAb,GAAA,gBAAAS,MAAA,YAAAH,QAAA,CAAAQ,KAAA,OAAAH,SAAA;AAE1B,SAASI,yBAAyBA,CACvCC,SAAkC,EAIlC;EACA,MAAMC,yBAAyB,gBAAGrC,KAAK,CAACsC,UAAU,CAGhD,CAACC,KAAK,EAAEC,GAAG,KAAK;IAChB,oBACExC,KAAA,CAAAyC,aAAA,CAACtC,sBAAA,CAAAuC,6BAA6B,QAC1BC,KAAK,IAAK;MACVC,OAAO,CAACC,GAAG,CAAC,OAAO,EAAEF,KAAK,CAAC;MAC3B,oBACE3C,KAAA,CAAAyC,aAAA,CAACL,SAAS,EAAAV,QAAA;QAACc,GAAG,EAAEA;MAAI,GAAKD,KAAK;QAAEO,qBAAqB,EAAEH;MAAM,EAAE,CAAC;IAEpE,CAC6B,CAAC;EAEpC,CAAC,CAAC;EACF,OAAON,yBAAyB;AAClC"}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
import { BaseInputProps, BaseInputState, BaseInput } from '../base/input/BaseInput';
|
3
3
|
import { ButtonProps } from '../button/Button';
|
4
|
+
import { FormValidationContextProps } from '../form/FormValidationContext';
|
4
5
|
export declare const defaultSubmitTranslations: {
|
5
6
|
hangOn: string;
|
6
7
|
needsFixing: string;
|
@@ -12,7 +13,7 @@ export type SubmitProps = BaseInputProps<never, SubmitTranslations> & ButtonProp
|
|
12
13
|
validateForm?: boolean;
|
13
14
|
disabledTitle?: string;
|
14
15
|
showValidationSummaryTooltip?: boolean;
|
15
|
-
};
|
16
|
+
} & FormValidationContextProps;
|
16
17
|
export interface SubmitState extends BaseInputState {
|
17
18
|
}
|
18
19
|
export declare class SubmitRaw extends BaseInput<SubmitProps, SubmitState, never, SubmitTranslations> {
|
@@ -133,5 +134,5 @@ export declare const Submit: React.ForwardRefExoticComponent<{
|
|
133
134
|
validateForm?: boolean;
|
134
135
|
disabledTitle?: string;
|
135
136
|
showValidationSummaryTooltip?: boolean;
|
136
|
-
} & React.RefAttributes<SubmitRaw>>;
|
137
|
+
} & FormValidationContextProps & React.RefAttributes<SubmitRaw>>;
|
137
138
|
export default Submit;
|
@@ -7,10 +7,10 @@ exports.defaultSubmitTranslations = exports.default = exports.SubmitRaw = export
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
8
8
|
var _BaseInput = require("../base/input/BaseInput");
|
9
9
|
var _Button = require("../button/Button");
|
10
|
-
var _withFormContext = require("../form/withFormContext");
|
11
10
|
var _FormValidationSummary = require("./../form/FormValidationSummary");
|
12
11
|
var _SubmitValidationSummary = _interopRequireDefault(require("./subComponents/SubmitValidationSummary"));
|
13
12
|
var _withThemeContext = require("../themeProvider/withThemeContext");
|
13
|
+
var _withFormValidationContext = require("../form/withFormValidationContext");
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
15
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
16
16
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
@@ -42,14 +42,14 @@ class SubmitRaw extends _BaseInput.BaseInput {
|
|
42
42
|
type: 'submit',
|
43
43
|
title: disabled ? this.props.disabledTitle : this.props.buttonProps && this.props.buttonProps.title
|
44
44
|
}),
|
45
|
-
tooltip: this.props.tooltip ? this.props.tooltip : this.props.showValidationSummaryTooltip && !this.props.
|
45
|
+
tooltip: this.props.tooltip ? this.props.tooltip : this.props.showValidationSummaryTooltip && this.props.formValidationContext && !this.props.formValidationContext.isFormValid && /*#__PURE__*/React.createElement(_FormValidationSummary.FormValidationSummaryRaw, {
|
46
46
|
title: translations.hangOn,
|
47
47
|
footer: translations.needsFixing,
|
48
48
|
containerClassName: "",
|
49
49
|
headerClassName: "submitValidationSummary__header",
|
50
50
|
footerClassName: "submitValidationSummary__footer",
|
51
51
|
Component: _SubmitValidationSummary.default,
|
52
|
-
|
52
|
+
formValidationContext: this.props.formValidationContext
|
53
53
|
}),
|
54
54
|
tooltipProps: _objectSpread({
|
55
55
|
theme: 'validation'
|
@@ -64,7 +64,7 @@ class SubmitRaw extends _BaseInput.BaseInput {
|
|
64
64
|
}
|
65
65
|
isDisabled() {
|
66
66
|
const disabled = this.getDisabled();
|
67
|
-
return disabled ? disabled : this.props.validateForm && this.props.
|
67
|
+
return disabled ? disabled : this.props.validateForm && this.props.formValidationContext ? !this.props.formValidationContext.isFormValid : false;
|
68
68
|
}
|
69
69
|
}
|
70
70
|
exports.SubmitRaw = SubmitRaw;
|
@@ -75,7 +75,7 @@ SubmitRaw.defaultProps = Object.assign({}, _BaseInput.BaseInput.defaultProps, {
|
|
75
75
|
showValidationSummaryTooltip: true,
|
76
76
|
preventsDefault: true
|
77
77
|
});
|
78
|
-
const Submit = (0, _withThemeContext.withThemeContext)((0,
|
78
|
+
const Submit = (0, _withThemeContext.withThemeContext)((0, _withFormValidationContext.withFormValidationContext)(SubmitRaw), 'submit');
|
79
79
|
exports.Submit = Submit;
|
80
80
|
var _default = Submit;
|
81
81
|
exports.default = _default;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Submit.js","names":["React","_interopRequireWildcard","require","_BaseInput","_Button","_withFormContext","_FormValidationSummary","_SubmitValidationSummary","_interopRequireDefault","_withThemeContext","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","_extends","assign","bind","target","i","arguments","length","source","apply","ownKeys","object","enumerableOnly","keys","getOwnPropertySymbols","symbols","filter","sym","enumerable","push","_objectSpread","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","value","_toPropertyKey","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","TypeError","Number","defaultSubmitTranslations","defaultBaseTranslations","hangOn","needsFixing","exports","SubmitRaw","BaseInput","constructor","props","handleClick","render","disabled","isDisabled","translations","getTranslations","createElement","Button","className","onClick","buttonProps","type","title","disabledTitle","tooltip","showValidationSummaryTooltip","formContext","isFormValid","FormValidationSummaryRaw","footer","containerClassName","headerClassName","footerClassName","Component","SubmitValidationSummary","tooltipProps","theme","children","e","preventsDefault","preventDefault","getDisabled","validateForm","defaultProps","ignoreContext","reRendersWhenContextChanges","Submit","withThemeContext","withFormContext","_default"],"sources":["../../../src/lib/components/submit/Submit.tsx"],"sourcesContent":["// Libs\r\nimport * as React from 'react';\r\nimport {\r\n BaseInputProps,\r\n BaseInputState,\r\n BaseInput,\r\n defaultBaseTranslations,\r\n} from '../base/input/BaseInput';\r\nimport { Button, ButtonProps } from '../button/Button';\r\nimport { withFormContext } from '../form/withFormContext';\r\nimport { FormValidationSummaryRaw } from './../form/FormValidationSummary';\r\nimport SubmitValidationSummary from './subComponents/SubmitValidationSummary';\r\nimport { withThemeContext } from '../themeProvider/withThemeContext';\r\n\r\n// Misc\r\nexport const defaultSubmitTranslations = {\r\n ...defaultBaseTranslations,\r\n hangOn: 'Hang on',\r\n needsFixing: '... needs fixing',\r\n};\r\n\r\nexport type SubmitTranslations = Partial<typeof defaultSubmitTranslations>;\r\n\r\nexport type SubmitProps = BaseInputProps<never, SubmitTranslations> &\r\n ButtonProps & {\r\n onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;\r\n validateForm?: boolean;\r\n disabledTitle?: string;\r\n showValidationSummaryTooltip?: boolean;\r\n };\r\n\r\nexport interface SubmitState extends BaseInputState {}\r\n\r\nexport class SubmitRaw extends BaseInput<\r\n SubmitProps,\r\n SubmitState,\r\n never,\r\n SubmitTranslations\r\n> {\r\n public static defaultProps = Object.assign({}, BaseInput.defaultProps, {\r\n validateForm: true,\r\n ignoreContext: true,\r\n reRendersWhenContextChanges: true,\r\n showValidationSummaryTooltip: true,\r\n preventsDefault: true,\r\n });\r\n\r\n constructor(props: SubmitProps) {\r\n super(props);\r\n this.handleClick = this.handleClick.bind(this);\r\n }\r\n\r\n public render() {\r\n const disabled = this.isDisabled();\r\n const translations = this.getTranslations(defaultSubmitTranslations);\r\n return (\r\n <Button\r\n {...this.props}\r\n className={`${this.props.className ? this.props.className : ''}`}\r\n onClick={this.handleClick}\r\n disabled={disabled}\r\n buttonProps={{\r\n ...this.props.buttonProps,\r\n type: 'submit',\r\n title: disabled\r\n ? this.props.disabledTitle\r\n : this.props.buttonProps && this.props.buttonProps.title,\r\n }}\r\n tooltip={\r\n this.props.tooltip\r\n ? this.props.tooltip\r\n : this.props.showValidationSummaryTooltip &&\r\n !this.props.formContext.isFormValid && (\r\n <FormValidationSummaryRaw\r\n title={translations.hangOn}\r\n footer={translations.needsFixing}\r\n containerClassName=\"\"\r\n headerClassName=\"submitValidationSummary__header\"\r\n footerClassName=\"submitValidationSummary__footer\"\r\n Component={SubmitValidationSummary}\r\n formContext={this.props.formContext}\r\n />\r\n )\r\n }\r\n tooltipProps={{\r\n theme: 'validation',\r\n ...this.props.tooltipProps,\r\n }}\r\n >\r\n {this.props.children}\r\n </Button>\r\n );\r\n }\r\n\r\n private handleClick(e: React.MouseEvent<HTMLButtonElement>) {\r\n if (this.props.preventsDefault) {\r\n e.preventDefault();\r\n }\r\n this.props.onClick && this.props.onClick(e);\r\n }\r\n\r\n private isDisabled() {\r\n const disabled = this.getDisabled();\r\n return disabled\r\n ? disabled\r\n : this.props.validateForm && this.props.formContext\r\n ? !this.props.formContext.isFormValid\r\n : false;\r\n }\r\n}\r\n\r\nexport const Submit = withThemeContext<\r\n SubmitProps,\r\n InstanceType<typeof SubmitRaw>\r\n>(withFormContext<SubmitProps>(SubmitRaw), 'submit');\r\n\r\nexport default Submit;\r\n"],"mappings":";;;;;;AACA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAMA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AACA,IAAAI,sBAAA,GAAAJ,OAAA;AACA,IAAAK,wBAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,iBAAA,GAAAP,OAAA;AAAqE,SAAAM,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAb,wBAAAS,GAAA,EAAAI,WAAA,SAAAA,WAAA,IAAAJ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O,IAAI,IAAI,CAACV,KAAK,CAACU,OAAO,CAACmB,CAAC,CAAC;EAC7C;EAEQzB,UAAUA,CAAA,EAAG;IACnB,MAAMD,QAAQ,GAAG,IAAI,CAAC6B,WAAW,CAAC,CAAC;IACnC,OAAO7B,QAAQ,GACXA,QAAQ,GACR,IAAI,CAACH,KAAK,CAACiC,YAAY,IAAI,IAAI,CAACjC,KAAK,CAACiB,WAAW,GACjD,CAAC,IAAI,CAACjB,KAAK,CAACiB,WAAW,CAACC,WAAW,GACnC,KAAK;EACX;AACF;AAACtB,OAAA,CAAAC,SAAA,GAAAA,SAAA;AA5EYA,SAAS,CAMNqC,YAAY,GAAG3F,MAAM,CAACU,MAAM,CAAC,CAAC,CAAC,EAAE6C,oBAAS,CAACoC,YAAY,EAAE;EACrED,YAAY,EAAE,IAAI;EAClBE,aAAa,EAAE,IAAI;EACnBC,2BAA2B,EAAE,IAAI;EACjCpB,4BAA4B,EAAE,IAAI;EAClCc,eAAe,EAAE;AACnB,CAAC,CAAC;AAkEG,MAAMO,MAAM,GAAG,IAAAC,kCAAgB,EAGpC,IAAAC,gCAAe,EAAc1C,SAAS,CAAC,EAAE,QAAQ,CAAC;AAACD,OAAA,CAAAyC,MAAA,GAAAA,MAAA;AAAA,IAAAG,QAAA,GAEtCH,MAAM;AAAAzC,OAAA,CAAAhE,OAAA,GAAA4G,QAAA"}
|
1
|
+
{"version":3,"file":"Submit.js","names":["React","_interopRequireWildcard","require","_BaseInput","_Button","_FormValidationSummary","_SubmitValidationSummary","_interopRequireDefault","_withThemeContext","_withFormValidationContext","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","_extends","assign","bind","target","i","arguments","length","source","apply","ownKeys","object","enumerableOnly","keys","getOwnPropertySymbols","symbols","filter","sym","enumerable","push","_objectSpread","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","value","_toPropertyKey","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","TypeError","Number","defaultSubmitTranslations","defaultBaseTranslations","hangOn","needsFixing","exports","SubmitRaw","BaseInput","constructor","props","handleClick","render","disabled","isDisabled","translations","getTranslations","createElement","Button","className","onClick","buttonProps","type","title","disabledTitle","tooltip","showValidationSummaryTooltip","formValidationContext","isFormValid","FormValidationSummaryRaw","footer","containerClassName","headerClassName","footerClassName","Component","SubmitValidationSummary","tooltipProps","theme","children","e","preventsDefault","preventDefault","getDisabled","validateForm","defaultProps","ignoreContext","reRendersWhenContextChanges","Submit","withThemeContext","withFormValidationContext","_default"],"sources":["../../../src/lib/components/submit/Submit.tsx"],"sourcesContent":["// Libs\r\nimport * as React from 'react';\r\nimport {\r\n BaseInputProps,\r\n BaseInputState,\r\n BaseInput,\r\n defaultBaseTranslations,\r\n} from '../base/input/BaseInput';\r\nimport { Button, ButtonProps } from '../button/Button';\r\nimport { FormValidationSummaryRaw } from './../form/FormValidationSummary';\r\nimport SubmitValidationSummary from './subComponents/SubmitValidationSummary';\r\nimport { withThemeContext } from '../themeProvider/withThemeContext';\r\nimport { withFormValidationContext } from '../form/withFormValidationContext';\r\nimport { FormValidationContextProps } from '../form/FormValidationContext';\r\n\r\n// Misc\r\nexport const defaultSubmitTranslations = {\r\n ...defaultBaseTranslations,\r\n hangOn: 'Hang on',\r\n needsFixing: '... needs fixing',\r\n};\r\n\r\nexport type SubmitTranslations = Partial<typeof defaultSubmitTranslations>;\r\n\r\nexport type SubmitProps = BaseInputProps<never, SubmitTranslations> &\r\n ButtonProps & {\r\n onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;\r\n validateForm?: boolean;\r\n disabledTitle?: string;\r\n showValidationSummaryTooltip?: boolean;\r\n } & FormValidationContextProps;\r\n\r\nexport interface SubmitState extends BaseInputState {}\r\n\r\nexport class SubmitRaw extends BaseInput<\r\n SubmitProps,\r\n SubmitState,\r\n never,\r\n SubmitTranslations\r\n> {\r\n public static defaultProps = Object.assign({}, BaseInput.defaultProps, {\r\n validateForm: true,\r\n ignoreContext: true,\r\n reRendersWhenContextChanges: true,\r\n showValidationSummaryTooltip: true,\r\n preventsDefault: true,\r\n });\r\n\r\n constructor(props: SubmitProps) {\r\n super(props);\r\n this.handleClick = this.handleClick.bind(this);\r\n }\r\n\r\n public render() {\r\n const disabled = this.isDisabled();\r\n const translations = this.getTranslations(defaultSubmitTranslations);\r\n return (\r\n <Button\r\n {...this.props}\r\n className={`${this.props.className ? this.props.className : ''}`}\r\n onClick={this.handleClick}\r\n disabled={disabled}\r\n buttonProps={{\r\n ...this.props.buttonProps,\r\n type: 'submit',\r\n title: disabled\r\n ? this.props.disabledTitle\r\n : this.props.buttonProps && this.props.buttonProps.title,\r\n }}\r\n tooltip={\r\n this.props.tooltip\r\n ? this.props.tooltip\r\n : this.props.showValidationSummaryTooltip &&\r\n this.props.formValidationContext &&\r\n !this.props.formValidationContext.isFormValid && (\r\n <FormValidationSummaryRaw\r\n title={translations.hangOn}\r\n footer={translations.needsFixing}\r\n containerClassName=\"\"\r\n headerClassName=\"submitValidationSummary__header\"\r\n footerClassName=\"submitValidationSummary__footer\"\r\n Component={SubmitValidationSummary}\r\n formValidationContext={this.props.formValidationContext}\r\n />\r\n )\r\n }\r\n tooltipProps={{\r\n theme: 'validation',\r\n ...this.props.tooltipProps,\r\n }}\r\n >\r\n {this.props.children}\r\n </Button>\r\n );\r\n }\r\n\r\n private handleClick(e: React.MouseEvent<HTMLButtonElement>) {\r\n if (this.props.preventsDefault) {\r\n e.preventDefault();\r\n }\r\n this.props.onClick && this.props.onClick(e);\r\n }\r\n\r\n private isDisabled() {\r\n const disabled = this.getDisabled();\r\n return disabled\r\n ? disabled\r\n : this.props.validateForm && this.props.formValidationContext\r\n ? !this.props.formValidationContext.isFormValid\r\n : false;\r\n }\r\n}\r\n\r\nexport const Submit = withThemeContext<\r\n SubmitProps,\r\n In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AAS,CAACoC,YAAY,EAAE;EACrED,YAAY,EAAE,IAAI;EAClBE,aAAa,EAAE,IAAI;EACnBC,2BAA2B,EAAE,IAAI;EACjCpB,4BAA4B,EAAE,IAAI;EAClCc,eAAe,EAAE;AACnB,CAAC,CAAC;AAmEG,MAAMO,MAAM,GAAG,IAAAC,kCAAgB,EAGpC,IAAAC,oDAAyB,EAAc1C,SAAS,CAAC,EAAE,QAAQ,CAAC;AAACD,OAAA,CAAAyC,MAAA,GAAAA,MAAA;AAAA,IAAAG,QAAA,GAEhDH,MAAM;AAAAzC,OAAA,CAAAhE,OAAA,GAAA4G,QAAA"}
|
package/build/dist/report.html
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
<head>
|
4
4
|
<meta charset="UTF-8"/>
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
6
|
-
<title>guestbell-forms [24 Oct 2024 at
|
6
|
+
<title>guestbell-forms [24 Oct 2024 at 18:23]</title>
|
7
7
|
<link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABrVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+O1foceMD///+J0/qK1Pr7/v8Xdr/9///W8P4UdL7L7P0Scr2r4Pyj3vwad8D5/f/2/f+55f3E6f34+/2H0/ojfMKpzOd0rNgQcb3F3O/j9f7c8v6g3Pz0/P/w+v/q+P7n9v6T1/uQ1vuE0vqLut/y+v+Z2fvt+f+15Pzv9fuc2/vR7v2V2Pvd6/bg9P7I6/285/2y4/yp3/zp8vk8i8kqgMT7/P31+fyv4vxGkcz6/P6/6P3j7vfS5PNnpNUxhcbO7f7F6v3O4vHK3/DA2u631Ouy0eqXweKJud5wqthfoNMMbLvY8f73+v2dxeR8sNtTmdDx9/zX6PSjyeaCtd1YnNGX2PuQveCGt95Nls42h8dLlM3F4vBtAAAAM3RSTlMAAyOx0/sKBvik8opWGBM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lCJrW5EARb7fF+bWdqf3hhyZI1nWJQHgznErZhbjoEsWqi8dQNoE294aldzFurwSABL2XXMf9+H1VQGke9exw5P/AnA5Pv5ngMul7LOvO922iwACu8WkCwLCafvM4CeWPxfA8lNHcWZSoi8EwMAIciKX2Z4SWCMAa3snCZ/G4EA8D6CMLNFsGQhkkz/gQNEBbPCbWsxGUpYVu3z8IyNAknwJkfPMEhLyrdi5RTyUVACkw4GSFRNWJNEW+fgPGwHD8/JxnRuLabN4CGNRkAE23na2+VmEAUmrYymSGjMAYqH84YUIyzgzs3XC7gNgH36Vcc4zKY9o9fgPBXUAiHHwVboBHGLiX6Zcjp1f2wu4tvzZKo0ecPnDtQYDQvJXaBeNzce45Fp28ZQLrEZVuFqgBwOalArKXnW1UzlnSusQKJqKYNuz4tOnI6sZG4zanpemv+7ySU2jbA9h6uhcgpfy6G2PahirDZ6zvq6zDduMVFTKvzw8wgyEdelwY9in3XkEPs3osJuwRQ4qTkfzifndg9Gfc4pdsu82+tTnHZTBa2EAMrqr2t43pguc8tNm7JQVQ2S0ukj2d22dhXYP0/veWtwKrCkNoNimAN5+Xr/oLrxswKbVJjteWrX7eR63o4j9q0GxnaBdWgGA5VStpanIjQmEhV0/nVt5VOFUvix6awJhPcAaTEShgrG+iGyvb5a0Ndb1YGHFPEwoqAinoaykaID1o1pdPNu7XsnCKQ3R+hwWIIhGvORcJUBYXe3Xa3vq/mF/N9V13ugufMkfXn+KHsRD0B8AAAAASUVORK5CYII=" type="image/x-icon" />
|
8
8
|
|
9
9
|
<script>
|
package/package.json
CHANGED
@@ -63,19 +63,22 @@ export interface ButtonState {
|
|
63
63
|
}
|
64
64
|
|
65
65
|
const DefaultButtonComponent: React.FC<ButtonComponentProps> = React.forwardRef(
|
66
|
-
(props, ref) =>
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
66
|
+
(props, ref) => {
|
67
|
+
const { disabled, ...rest } = props.buttonProps ?? {};
|
68
|
+
return (
|
69
|
+
<button
|
70
|
+
ref={ref}
|
71
|
+
// tslint:disable-next-line:no-any
|
72
|
+
{...(rest as any)}
|
73
|
+
{...(props.id && { id: props.id })}
|
74
|
+
className={props.className}
|
75
|
+
onClick={props.onClick}
|
76
|
+
style={props.style}
|
77
|
+
>
|
78
|
+
{props.children}
|
79
|
+
</button>
|
80
|
+
);
|
81
|
+
}
|
79
82
|
);
|
80
83
|
|
81
84
|
export class Button extends React.PureComponent<ButtonProps, ButtonState> {
|
@@ -134,6 +137,7 @@ export class Button extends React.PureComponent<ButtonProps, ButtonState> {
|
|
134
137
|
onClick={this.handleClick}
|
135
138
|
buttonProps={{
|
136
139
|
...this.props.buttonProps,
|
140
|
+
disabled: this.props.disabled,
|
137
141
|
tabIndex: !disabled ? this.props.buttonProps?.tabIndex : -1,
|
138
142
|
}}
|
139
143
|
className={btnClassName}
|
@@ -4,13 +4,17 @@ import * as React from 'react';
|
|
4
4
|
// Misc
|
5
5
|
import {
|
6
6
|
FormContextState,
|
7
|
-
FormComponentContextState,
|
8
7
|
FormContextProvider,
|
9
8
|
ComponentsDict,
|
10
|
-
FormComponentValidationContextStateBase,
|
11
9
|
} from './FormContext';
|
12
10
|
import { withThemeContext } from '../themeProvider/withThemeContext';
|
13
11
|
import { ThemeContextProps } from '../themeProvider/ThemeContext';
|
12
|
+
import {
|
13
|
+
FormComponentContextState,
|
14
|
+
FormComponentValidationContextStateBase,
|
15
|
+
FormValidationContextProvider,
|
16
|
+
FormValidationContextState,
|
17
|
+
} from './FormValidationContext';
|
14
18
|
|
15
19
|
export type FormProps = React.PropsWithChildren<
|
16
20
|
ThemeContextProps & {
|
@@ -28,7 +32,8 @@ export type FormProps = React.PropsWithChildren<
|
|
28
32
|
>;
|
29
33
|
|
30
34
|
export interface FormState {
|
31
|
-
|
35
|
+
formContext: FormContextState;
|
36
|
+
formValidationContext: FormValidationContextState;
|
32
37
|
}
|
33
38
|
|
34
39
|
export class Form extends React.PureComponent<FormProps, FormState> {
|
@@ -46,13 +51,15 @@ export class Form extends React.PureComponent<FormProps, FormState> {
|
|
46
51
|
this.disableComponents = this.disableComponents.bind(this);
|
47
52
|
this.enableComponents = this.enableComponents.bind(this);
|
48
53
|
this.state = {
|
49
|
-
|
54
|
+
formContext: {
|
50
55
|
subscribe: this.subscribe,
|
51
56
|
unSubscribe: this.unSubscribe,
|
52
|
-
isFormValid: true,
|
53
57
|
updateCallback: this.updateCallback,
|
54
58
|
disableComponents: this.disableComponents,
|
55
59
|
enableComponents: this.enableComponents,
|
60
|
+
},
|
61
|
+
formValidationContext: {
|
62
|
+
isFormValid: true,
|
56
63
|
components: {},
|
57
64
|
},
|
58
65
|
};
|
@@ -64,12 +71,12 @@ export class Form extends React.PureComponent<FormProps, FormState> {
|
|
64
71
|
snapshot?: any
|
65
72
|
): void {
|
66
73
|
if (
|
67
|
-
this.state.
|
68
|
-
prevState?.
|
74
|
+
this.state.formValidationContext?.isFormValid !==
|
75
|
+
prevState?.formValidationContext?.isFormValid
|
69
76
|
) {
|
70
|
-
const componentsWithErrors = this.state.
|
71
|
-
? Object.keys(this.state.
|
72
|
-
.map((key) => this.state.
|
77
|
+
const componentsWithErrors = this.state.formContext
|
78
|
+
? Object.keys(this.state.formValidationContext.components)
|
79
|
+
.map((key) => this.state.formValidationContext.components[key])
|
73
80
|
.filter((component) => {
|
74
81
|
if (!component.validation.isValid && !component.validation.name) {
|
75
82
|
console.warn(
|
@@ -81,7 +88,7 @@ export class Form extends React.PureComponent<FormProps, FormState> {
|
|
81
88
|
})
|
82
89
|
: [];
|
83
90
|
this.props.onValidChanged?.(
|
84
|
-
this.state.
|
91
|
+
this.state.formValidationContext?.isFormValid,
|
85
92
|
componentsWithErrors
|
86
93
|
);
|
87
94
|
}
|
@@ -89,7 +96,7 @@ export class Form extends React.PureComponent<FormProps, FormState> {
|
|
89
96
|
|
90
97
|
public disableComponents() {
|
91
98
|
const components = {
|
92
|
-
...this.state.
|
99
|
+
...this.state.formValidationContext.components,
|
93
100
|
...this.props.extraComponents,
|
94
101
|
};
|
95
102
|
Object.keys(components).forEach((key) => {
|
@@ -103,7 +110,7 @@ export class Form extends React.PureComponent<FormProps, FormState> {
|
|
103
110
|
|
104
111
|
public enableComponents() {
|
105
112
|
const components = {
|
106
|
-
...this.state.
|
113
|
+
...this.state.formValidationContext.components,
|
107
114
|
...this.props.extraComponents,
|
108
115
|
};
|
109
116
|
Object.keys(components).forEach((key) => {
|
@@ -117,7 +124,7 @@ export class Form extends React.PureComponent<FormProps, FormState> {
|
|
117
124
|
|
118
125
|
public touchAll() {
|
119
126
|
const components = {
|
120
|
-
...this.state.
|
127
|
+
...this.state.formValidationContext.components,
|
121
128
|
...this.props.extraComponents,
|
122
129
|
};
|
123
130
|
Object.keys(components).forEach((key) => {
|
@@ -131,7 +138,7 @@ export class Form extends React.PureComponent<FormProps, FormState> {
|
|
131
138
|
|
132
139
|
public unTouchAll() {
|
133
140
|
const components = {
|
134
|
-
...this.state.
|
141
|
+
...this.state.formValidationContext.components,
|
135
142
|
...this.props.extraComponents,
|
136
143
|
};
|
137
144
|
Object.keys(components).forEach((key) => {
|
@@ -144,6 +151,7 @@ export class Form extends React.PureComponent<FormProps, FormState> {
|
|
144
151
|
}
|
145
152
|
|
146
153
|
public render() {
|
154
|
+
const validationContext = this.mergeContext();
|
147
155
|
return (
|
148
156
|
<this.props.component
|
149
157
|
{...(this.props.id && { id: this.props.id })}
|
@@ -154,24 +162,26 @@ export class Form extends React.PureComponent<FormProps, FormState> {
|
|
154
162
|
}`}
|
155
163
|
onSubmit={this.onSubmit}
|
156
164
|
>
|
157
|
-
<FormContextProvider value={this.
|
158
|
-
{
|
165
|
+
<FormContextProvider value={this.state.formContext}>
|
166
|
+
<FormValidationContextProvider value={validationContext}>
|
167
|
+
{this.props.children}
|
168
|
+
</FormValidationContextProvider>
|
159
169
|
</FormContextProvider>
|
160
170
|
</this.props.component>
|
161
171
|
);
|
162
172
|
}
|
163
173
|
|
164
|
-
private mergeContext():
|
174
|
+
private mergeContext(): FormValidationContextState {
|
165
175
|
if (!this.props.extraComponents) {
|
166
|
-
return this.state.
|
176
|
+
return this.state.formValidationContext;
|
167
177
|
}
|
168
178
|
const isFormValid =
|
169
|
-
this.state.
|
179
|
+
this.state.formValidationContext.isFormValid &&
|
170
180
|
this.getIsFormValid(this.props.extraComponents);
|
171
181
|
return {
|
172
|
-
...this.state.
|
182
|
+
...this.state.formValidationContext,
|
173
183
|
components: {
|
174
|
-
...this.state.
|
184
|
+
...this.state.formValidationContext.components,
|
175
185
|
...this.props.extraComponents,
|
176
186
|
},
|
177
187
|
isFormValid,
|
@@ -191,18 +201,19 @@ export class Form extends React.PureComponent<FormProps, FormState> {
|
|
191
201
|
this.setState((previousState) => {
|
192
202
|
let components = Object.assign(
|
193
203
|
{},
|
194
|
-
previousState.
|
204
|
+
previousState.formValidationContext.components
|
195
205
|
);
|
196
206
|
if (componentState) {
|
197
207
|
components[componentId] = componentState;
|
198
208
|
}
|
199
209
|
let isFormValid = this.getIsFormValid(components);
|
200
210
|
return {
|
201
|
-
|
202
|
-
...previousState.
|
211
|
+
formValidationContext: {
|
212
|
+
...previousState.formValidationContext,
|
203
213
|
components,
|
204
214
|
isFormValid,
|
205
215
|
},
|
216
|
+
formContext: previousState.formContext,
|
206
217
|
};
|
207
218
|
});
|
208
219
|
}
|
@@ -213,13 +224,14 @@ export class Form extends React.PureComponent<FormProps, FormState> {
|
|
213
224
|
this.setState((previousState) => {
|
214
225
|
let components = Object.assign(
|
215
226
|
{},
|
216
|
-
previousState.
|
227
|
+
previousState.formValidationContext.components
|
217
228
|
);
|
218
229
|
delete components[componentId];
|
219
230
|
let isFormValid = this.getIsFormValid(components);
|
220
231
|
return {
|
221
|
-
|
222
|
-
|
232
|
+
formContext: previousState.formContext,
|
233
|
+
formValidationContext: {
|
234
|
+
...previousState.formValidationContext,
|
223
235
|
components,
|
224
236
|
isFormValid,
|
225
237
|
},
|
@@ -229,7 +241,7 @@ export class Form extends React.PureComponent<FormProps, FormState> {
|
|
229
241
|
}
|
230
242
|
|
231
243
|
private getIsFormValid(
|
232
|
-
components: ComponentsDict = this.state.
|
244
|
+
components: ComponentsDict = this.state.formValidationContext.components,
|
233
245
|
initialValid: boolean = true
|
234
246
|
): boolean {
|
235
247
|
let isFormValid = initialValid;
|
@@ -247,7 +259,10 @@ export class Form extends React.PureComponent<FormProps, FormState> {
|
|
247
259
|
componentState: FormComponentValidationContextStateBase
|
248
260
|
) {
|
249
261
|
this.setState((previousState) => {
|
250
|
-
let components = Object.assign(
|
262
|
+
let components = Object.assign(
|
263
|
+
{},
|
264
|
+
previousState.formValidationContext.components
|
265
|
+
);
|
251
266
|
const previousComponent = components[componentId];
|
252
267
|
if (
|
253
268
|
previousComponent &&
|
@@ -272,11 +287,12 @@ export class Form extends React.PureComponent<FormProps, FormState> {
|
|
272
287
|
}
|
273
288
|
let isFormValid = this.getIsFormValid(components);
|
274
289
|
return {
|
275
|
-
|
276
|
-
...this.state.
|
290
|
+
formValidationContext: {
|
291
|
+
...this.state.formValidationContext,
|
277
292
|
components,
|
278
293
|
isFormValid,
|
279
294
|
},
|
295
|
+
formContext: previousState.formContext,
|
280
296
|
};
|
281
297
|
});
|
282
298
|
}
|
@@ -1,27 +1,15 @@
|
|
1
1
|
import * as React from 'react';
|
2
|
-
import { ValidationError, ComponentApi } from '../base/input';
|
3
2
|
import { PartialBy } from '../utils/Typescript';
|
3
|
+
import {
|
4
|
+
FormComponentContextState,
|
5
|
+
FormComponentValidationContextStateBase,
|
6
|
+
} from './FormValidationContext';
|
4
7
|
|
5
8
|
export type OmitFormContext<P extends FormContextProps> = PartialBy<
|
6
9
|
P,
|
7
10
|
'formContext'
|
8
11
|
>;
|
9
12
|
|
10
|
-
export interface FormComponentValidationContextStateBase {
|
11
|
-
isValid: boolean;
|
12
|
-
errors: ValidationError[];
|
13
|
-
}
|
14
|
-
|
15
|
-
export interface FormComponentValidationContextState
|
16
|
-
extends FormComponentValidationContextStateBase {
|
17
|
-
name: JSX.Element | string;
|
18
|
-
}
|
19
|
-
|
20
|
-
export interface FormComponentContextState {
|
21
|
-
validation: FormComponentValidationContextState;
|
22
|
-
componentApi: ComponentApi;
|
23
|
-
}
|
24
|
-
|
25
13
|
export interface FormContextProps {
|
26
14
|
formContext?: FormContextState;
|
27
15
|
}
|
@@ -36,14 +24,12 @@ export interface FormContextState {
|
|
36
24
|
componentState: FormComponentContextState
|
37
25
|
) => void;
|
38
26
|
unSubscribe: (componentId: string) => void;
|
39
|
-
isFormValid: boolean;
|
40
27
|
updateCallback: (
|
41
28
|
componentId: string,
|
42
29
|
newComponentState: FormComponentValidationContextStateBase
|
43
30
|
) => void;
|
44
31
|
disableComponents: () => void;
|
45
32
|
enableComponents: () => void;
|
46
|
-
components: ComponentsDict;
|
47
33
|
}
|
48
34
|
|
49
35
|
const FormContext = React.createContext<FormContextState | undefined>(
|