guestbell-forms 2.0.306 → 2.0.307

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.
@@ -8,6 +8,7 @@ export declare type FormProps = React.PropsWithChildren<ThemeContextProps & {
8
8
  onSubmit?: () => void;
9
9
  extraComponents?: ComponentsDict;
10
10
  component?: keyof JSX.IntrinsicElements;
11
+ onValidChanged?: (isValid: boolean) => void;
11
12
  }>;
12
13
  export interface FormState {
13
14
  contextState: FormContextState;
@@ -19,6 +20,7 @@ export declare class Form extends React.PureComponent<FormProps, FormState> {
19
20
  component: keyof JSX.IntrinsicElements;
20
21
  };
21
22
  constructor(props: FormProps);
23
+ componentDidUpdate(prevProps: Readonly<FormProps>, prevState: Readonly<FormState>, snapshot?: any): void;
22
24
  disableComponents(): void;
23
25
  enableComponents(): void;
24
26
  touchAll(): void;
@@ -38,6 +40,7 @@ declare const _default: React.ForwardRefExoticComponent<ThemeContextProps & {
38
40
  onSubmit?: () => void;
39
41
  extraComponents?: ComponentsDict;
40
42
  component?: keyof JSX.IntrinsicElements;
43
+ onValidChanged?: (isValid: boolean) => void;
41
44
  } & {
42
45
  children?: React.ReactNode;
43
46
  } & React.RefAttributes<Form>>;
@@ -50,6 +50,16 @@ class Form extends React.PureComponent {
50
50
  };
51
51
  }
52
52
 
53
+ componentDidUpdate(prevProps, prevState, snapshot) {
54
+ var _this$state$contextSt, _prevState$contextSta;
55
+
56
+ if (((_this$state$contextSt = this.state.contextState) === null || _this$state$contextSt === void 0 ? void 0 : _this$state$contextSt.isFormValid) !== (prevState === null || prevState === void 0 ? void 0 : (_prevState$contextSta = prevState.contextState) === null || _prevState$contextSta === void 0 ? void 0 : _prevState$contextSta.isFormValid)) {
57
+ var _this$props$onValidCh, _this$props, _this$state$contextSt2;
58
+
59
+ (_this$props$onValidCh = (_this$props = this.props).onValidChanged) === null || _this$props$onValidCh === void 0 ? void 0 : _this$props$onValidCh.call(_this$props, (_this$state$contextSt2 = this.state.contextState) === null || _this$state$contextSt2 === void 0 ? void 0 : _this$state$contextSt2.isFormValid);
60
+ }
61
+ }
62
+
53
63
  disableComponents() {
54
64
  const components = _objectSpread(_objectSpread({}, this.state.contextState.components), this.props.extraComponents);
55
65
 
@@ -1 +1 @@
1
- {"version":3,"file":"Form.js","names":["Form","React","PureComponent","constructor","props","e","preventDefault","onSubmit","subscribe","bind","unSubscribe","updateCallback","disableComponents","enableComponents","state","contextState","isFormValid","components","extraComponents","Object","keys","forEach","key","component","componentApi","disableComponent","enableComponent","touchAll","touch","unTouchAll","unTouch","render","id","className","mergeContext","children","getIsFormValid","componentId","componentState","setState","previousState","assign","initialValid","validation","isValid","previousComponent","noValidate","showExpandAll","withThemeContext"],"sources":["../../../src/lib/components/form/Form.tsx"],"sourcesContent":["// Libs\r\nimport * as React from 'react';\r\n\r\n// Misc\r\nimport {\r\n FormContextState,\r\n FormComponentContextState,\r\n FormContextProvider,\r\n ComponentsDict,\r\n} from './FormContext';\r\nimport { withThemeContext } from '../themeProvider/withThemeContext';\r\nimport { ThemeContextProps } from '../themeProvider/ThemeContext';\r\n\r\nexport type FormProps = React.PropsWithChildren<\r\n ThemeContextProps & {\r\n id?: string;\r\n className?: string;\r\n noValidate?: boolean;\r\n onSubmit?: () => void;\r\n extraComponents?: ComponentsDict;\r\n component?: keyof JSX.IntrinsicElements;\r\n }\r\n>;\r\n\r\nexport interface FormState {\r\n contextState: FormContextState;\r\n}\r\n\r\nexport class Form extends React.PureComponent<FormProps, FormState> {\r\n public static defaultProps = {\r\n noValidate: false,\r\n showExpandAll: true,\r\n component: 'form' as keyof JSX.IntrinsicElements,\r\n };\r\n\r\n constructor(props: FormProps) {\r\n super(props);\r\n this.subscribe = this.subscribe.bind(this);\r\n this.unSubscribe = this.unSubscribe.bind(this);\r\n this.updateCallback = this.updateCallback.bind(this);\r\n this.disableComponents = this.disableComponents.bind(this);\r\n this.enableComponents = this.enableComponents.bind(this);\r\n this.state = {\r\n contextState: {\r\n subscribe: this.subscribe,\r\n unSubscribe: this.unSubscribe,\r\n isFormValid: true,\r\n updateCallback: this.updateCallback,\r\n disableComponents: this.disableComponents,\r\n enableComponents: this.enableComponents,\r\n components: {},\r\n },\r\n };\r\n }\r\n\r\n public disableComponents() {\r\n const components = {\r\n ...this.state.contextState.components,\r\n ...this.props.extraComponents,\r\n };\r\n Object.keys(components).forEach(key => {\r\n const component = components[key];\r\n component &&\r\n component.componentApi &&\r\n component.componentApi.disableComponent &&\r\n component.componentApi.disableComponent();\r\n });\r\n }\r\n\r\n public enableComponents() {\r\n const components = {\r\n ...this.state.contextState.components,\r\n ...this.props.extraComponents,\r\n };\r\n Object.keys(components).forEach(key => {\r\n const component = components[key];\r\n component &&\r\n component.componentApi &&\r\n component.componentApi.enableComponent &&\r\n component.componentApi.enableComponent();\r\n });\r\n }\r\n\r\n public touchAll() {\r\n const components = {\r\n ...this.state.contextState.components,\r\n ...this.props.extraComponents,\r\n };\r\n Object.keys(components).forEach(key => {\r\n const component = components[key];\r\n component &&\r\n component.componentApi &&\r\n component.componentApi.touch &&\r\n component.componentApi.touch();\r\n });\r\n }\r\n\r\n public unTouchAll() {\r\n const components = {\r\n ...this.state.contextState.components,\r\n ...this.props.extraComponents,\r\n };\r\n Object.keys(components).forEach(key => {\r\n const component = components[key];\r\n component &&\r\n component.componentApi &&\r\n component.componentApi.unTouch &&\r\n component.componentApi.unTouch();\r\n });\r\n }\r\n\r\n public render() {\r\n return (\r\n <this.props.component\r\n {...(this.props.id && { id: this.props.id })}\r\n noValidate={true}\r\n role=\"form\"\r\n className={`input__form validation-form ${\r\n this.props.className ? this.props.className : ''\r\n }`}\r\n onSubmit={this.onSubmit}\r\n >\r\n <FormContextProvider value={this.mergeContext()}>\r\n {this.props.children}\r\n </FormContextProvider>\r\n </this.props.component>\r\n );\r\n }\r\n\r\n private mergeContext(): FormContextState {\r\n if (!this.props.extraComponents) {\r\n return this.state.contextState;\r\n }\r\n const isFormValid =\r\n this.state.contextState.isFormValid &&\r\n this.getIsFormValid(this.props.extraComponents);\r\n return {\r\n ...this.state.contextState,\r\n components: {\r\n ...this.state.contextState.components,\r\n ...this.props.extraComponents,\r\n },\r\n isFormValid,\r\n };\r\n }\r\n\r\n private onSubmit = (e: React.FormEvent) => {\r\n e.preventDefault();\r\n this.props.onSubmit && this.props.onSubmit();\r\n };\r\n\r\n private subscribe(\r\n componentId: string,\r\n componentState: FormComponentContextState\r\n ) {\r\n if (componentId) {\r\n this.setState(previousState => {\r\n let components = Object.assign(\r\n {},\r\n previousState.contextState.components\r\n );\r\n if (componentState) {\r\n components[componentId] = componentState;\r\n }\r\n let isFormValid = this.getIsFormValid(components);\r\n return {\r\n contextState: {\r\n ...previousState.contextState,\r\n components,\r\n isFormValid,\r\n },\r\n };\r\n });\r\n }\r\n }\r\n\r\n private unSubscribe(componentId: string) {\r\n if (componentId) {\r\n this.setState(previousState => {\r\n let components = Object.assign(\r\n {},\r\n previousState.contextState.components\r\n );\r\n delete components[componentId];\r\n let isFormValid = this.getIsFormValid(components);\r\n return {\r\n contextState: {\r\n ...previousState.contextState,\r\n components,\r\n isFormValid,\r\n },\r\n };\r\n });\r\n }\r\n }\r\n\r\n private getIsFormValid(\r\n components: ComponentsDict = this.state.contextState.components,\r\n initialValid: boolean = true\r\n ): boolean {\r\n let isFormValid = initialValid;\r\n Object.keys(components).forEach(key => {\r\n const component = components[key];\r\n if (component && component.validation && !component.validation.isValid) {\r\n isFormValid = false;\r\n }\r\n });\r\n return isFormValid;\r\n }\r\n\r\n private updateCallback(\r\n componentId: string,\r\n componentState: FormComponentContextState\r\n ) {\r\n this.setState(previousState => {\r\n let components = Object.assign({}, previousState.contextState.components);\r\n const previousComponent = components[componentId];\r\n if (componentState && previousComponent) {\r\n components[componentId] = {\r\n ...previousComponent,\r\n ...componentState,\r\n validation: {\r\n ...previousComponent.validation,\r\n ...componentState.validation,\r\n },\r\n };\r\n }\r\n let isFormValid = this.getIsFormValid(components);\r\n return {\r\n contextState: {\r\n ...this.state.contextState,\r\n components,\r\n isFormValid,\r\n },\r\n };\r\n });\r\n }\r\n}\r\n\r\nexport default withThemeContext<FormProps, InstanceType<typeof Form>>(\r\n Form,\r\n 'form'\r\n);\r\n"],"mappings":";;;;;;;AACA;;AAGA;;AAMA;;;;;;;;;;;;;;AAkBO,MAAMA,IAAN,SAAmBC,KAAK,CAACC,aAAzB,CAA6D;EAOlEC,WAAW,CAACC,KAAD,EAAmB;IAC5B,MAAMA,KAAN;;IAD4B,kCA+GVC,CAAD,IAAwB;MACzCA,CAAC,CAACC,cAAF;MACA,KAAKF,KAAL,CAAWG,QAAX,IAAuB,KAAKH,KAAL,CAAWG,QAAX,EAAvB;IACD,CAlH6B;;IAE5B,KAAKC,SAAL,GAAiB,KAAKA,SAAL,CAAeC,IAAf,CAAoB,IAApB,CAAjB;IACA,KAAKC,WAAL,GAAmB,KAAKA,WAAL,CAAiBD,IAAjB,CAAsB,IAAtB,CAAnB;IACA,KAAKE,cAAL,GAAsB,KAAKA,cAAL,CAAoBF,IAApB,CAAyB,IAAzB,CAAtB;IACA,KAAKG,iBAAL,GAAyB,KAAKA,iBAAL,CAAuBH,IAAvB,CAA4B,IAA5B,CAAzB;IACA,KAAKI,gBAAL,GAAwB,KAAKA,gBAAL,CAAsBJ,IAAtB,CAA2B,IAA3B,CAAxB;IACA,KAAKK,KAAL,GAAa;MACXC,YAAY,EAAE;QACZP,SAAS,EAAE,KAAKA,SADJ;QAEZE,WAAW,EAAE,KAAKA,WAFN;QAGZM,WAAW,EAAE,IAHD;QAIZL,cAAc,EAAE,KAAKA,cAJT;QAKZC,iBAAiB,EAAE,KAAKA,iBALZ;QAMZC,gBAAgB,EAAE,KAAKA,gBANX;QAOZI,UAAU,EAAE;MAPA;IADH,CAAb;EAWD;;EAEML,iBAAiB,GAAG;IACzB,MAAMK,UAAU,mCACX,KAAKH,KAAL,CAAWC,YAAX,CAAwBE,UADb,GAEX,KAAKb,KAAL,CAAWc,eAFA,CAAhB;;IAIAC,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EAGpB;IACA,KAAKC,QAAL,CAAcC,aAAa,IAAI;MAC7B,IAAIvB,UAAU,GAAGE,MAAM,CAACsB,MAAP,CAAc,EAAd,EAAkBD,aAAa,CAACzB,YAAd,CAA2BE,UAA7C,CAAjB;MACA,MAAM4B,iBAAiB,GAAG5B,UAAU,CAACoB,WAAD,CAApC;;MACA,IAAIC,cAAc,IAAIO,iBAAtB,EAAyC;QACvC5B,UAAU,CAACoB,WAAD,CAAV,iDACKQ,iBADL,GAEKP,cAFL;UAGEK,UAAU,kCACLE,iBAAiB,CAACF,UADb,GAELL,cAAc,CAACK,UAFV;QAHZ;MAQD;;MACD,IAAI3B,WAAW,GAAG,KAAKoB,cAAL,CAAoBnB,UAApB,CAAlB;MACA,OAAO;QACLF,YAAY,kCACP,KAAKD,KAAL,CAAWC,YADJ;UAEVE,UAFU;UAGVD;QAHU;MADP,CAAP;IAOD,CArBD;EAsBD;;AAhNiE;;;;gBAAvDhB,I,kBACkB;EAC3B8C,UAAU,EAAE,KADe;EAE3BC,aAAa,EAAE,IAFY;EAG3BxB,SAAS,EAAE;AAHgB,C;;eAkNhB,IAAAyB,kCAAA,EACbhD,IADa,EAEb,MAFa,C"}
1
+ {"version":3,"file":"Form.js","names":["Form","React","PureComponent","constructor","props","e","preventDefault","onSubmit","subscribe","bind","unSubscribe","updateCallback","disableComponents","enableComponents","state","contextState","isFormValid","components","componentDidUpdate","prevProps","prevState","snapshot","onValidChanged","extraComponents","Object","keys","forEach","key","component","componentApi","disableComponent","enableComponent","touchAll","touch","unTouchAll","unTouch","render","id","className","mergeContext","children","getIsFormValid","componentId","componentState","setState","previousState","assign","initialValid","validation","isValid","previousComponent","noValidate","showExpandAll","withThemeContext"],"sources":["../../../src/lib/components/form/Form.tsx"],"sourcesContent":["// Libs\r\nimport * as React from 'react';\r\n\r\n// Misc\r\nimport {\r\n FormContextState,\r\n FormComponentContextState,\r\n FormContextProvider,\r\n ComponentsDict,\r\n} from './FormContext';\r\nimport { withThemeContext } from '../themeProvider/withThemeContext';\r\nimport { ThemeContextProps } from '../themeProvider/ThemeContext';\r\n\r\nexport type FormProps = React.PropsWithChildren<\r\n ThemeContextProps & {\r\n id?: string;\r\n className?: string;\r\n noValidate?: boolean;\r\n onSubmit?: () => void;\r\n extraComponents?: ComponentsDict;\r\n component?: keyof JSX.IntrinsicElements;\r\n onValidChanged?: (isValid: boolean) => void;\r\n }\r\n>;\r\n\r\nexport interface FormState {\r\n contextState: FormContextState;\r\n}\r\n\r\nexport class Form extends React.PureComponent<FormProps, FormState> {\r\n public static defaultProps = {\r\n noValidate: false,\r\n showExpandAll: true,\r\n component: 'form' as keyof JSX.IntrinsicElements,\r\n };\r\n\r\n constructor(props: FormProps) {\r\n super(props);\r\n this.subscribe = this.subscribe.bind(this);\r\n this.unSubscribe = this.unSubscribe.bind(this);\r\n this.updateCallback = this.updateCallback.bind(this);\r\n this.disableComponents = this.disableComponents.bind(this);\r\n this.enableComponents = this.enableComponents.bind(this);\r\n this.state = {\r\n contextState: {\r\n subscribe: this.subscribe,\r\n unSubscribe: this.unSubscribe,\r\n isFormValid: true,\r\n updateCallback: this.updateCallback,\r\n disableComponents: this.disableComponents,\r\n enableComponents: this.enableComponents,\r\n components: {},\r\n },\r\n };\r\n }\r\n\r\n public componentDidUpdate(\r\n prevProps: Readonly<FormProps>,\r\n prevState: Readonly<FormState>,\r\n snapshot?: any\r\n ): void {\r\n if (\r\n this.state.contextState?.isFormValid !==\r\n prevState?.contextState?.isFormValid\r\n ) {\r\n this.props.onValidChanged?.(this.state.contextState?.isFormValid);\r\n }\r\n }\r\n\r\n public disableComponents() {\r\n const components = {\r\n ...this.state.contextState.components,\r\n ...this.props.extraComponents,\r\n };\r\n Object.keys(components).forEach(key => {\r\n const component = components[key];\r\n component &&\r\n component.componentApi &&\r\n component.componentApi.disableComponent &&\r\n component.componentApi.disableComponent();\r\n });\r\n }\r\n\r\n public enableComponents() {\r\n const components = {\r\n ...this.state.contextState.components,\r\n ...this.props.extraComponents,\r\n };\r\n Object.keys(components).forEach(key => {\r\n const component = components[key];\r\n component &&\r\n component.componentApi &&\r\n component.componentApi.enableComponent &&\r\n component.componentApi.enableComponent();\r\n });\r\n }\r\n\r\n public touchAll() {\r\n const components = {\r\n ...this.state.contextState.components,\r\n ...this.props.extraComponents,\r\n };\r\n Object.keys(components).forEach(key => {\r\n const component = components[key];\r\n component &&\r\n component.componentApi &&\r\n component.componentApi.touch &&\r\n component.componentApi.touch();\r\n });\r\n }\r\n\r\n public unTouchAll() {\r\n const components = {\r\n ...this.state.contextState.components,\r\n ...this.props.extraComponents,\r\n };\r\n Object.keys(components).forEach(key => {\r\n const component = components[key];\r\n component &&\r\n component.componentApi &&\r\n component.componentApi.unTouch &&\r\n component.componentApi.unTouch();\r\n });\r\n }\r\n\r\n public render() {\r\n return (\r\n <this.props.component\r\n {...(this.props.id && { id: this.props.id })}\r\n noValidate={true}\r\n role=\"form\"\r\n className={`input__form validation-form ${\r\n this.props.className ? this.props.className : ''\r\n }`}\r\n onSubmit={this.onSubmit}\r\n >\r\n <FormContextProvider value={this.mergeContext()}>\r\n {this.props.children}\r\n </FormContextProvider>\r\n </this.props.component>\r\n );\r\n }\r\n\r\n private mergeContext(): FormContextState {\r\n if (!this.props.extraComponents) {\r\n return this.state.contextState;\r\n }\r\n const isFormValid =\r\n this.state.contextState.isFormValid &&\r\n this.getIsFormValid(this.props.extraComponents);\r\n return {\r\n ...this.state.contextState,\r\n components: {\r\n ...this.state.contextState.components,\r\n ...this.props.extraComponents,\r\n },\r\n isFormValid,\r\n };\r\n }\r\n\r\n private onSubmit = (e: React.FormEvent) => {\r\n e.preventDefault();\r\n this.props.onSubmit && this.props.onSubmit();\r\n };\r\n\r\n private subscribe(\r\n componentId: string,\r\n componentState: FormComponentContextState\r\n ) {\r\n if (componentId) {\r\n this.setState(previousState => {\r\n let components = Object.assign(\r\n {},\r\n previousState.contextState.components\r\n );\r\n if (componentState) {\r\n components[componentId] = componentState;\r\n }\r\n let isFormValid = this.getIsFormValid(components);\r\n return {\r\n contextState: {\r\n ...previousState.contextState,\r\n components,\r\n isFormValid,\r\n },\r\n };\r\n });\r\n }\r\n }\r\n\r\n private unSubscribe(componentId: string) {\r\n if (componentId) {\r\n this.setState(previousState => {\r\n let components = Object.assign(\r\n {},\r\n previousState.contextState.components\r\n );\r\n delete components[componentId];\r\n let isFormValid = this.getIsFormValid(components);\r\n return {\r\n contextState: {\r\n ...previousState.contextState,\r\n components,\r\n isFormValid,\r\n },\r\n };\r\n });\r\n }\r\n }\r\n\r\n private getIsFormValid(\r\n components: ComponentsDict = this.state.contextState.components,\r\n initialValid: boolean = true\r\n ): boolean {\r\n let isFormValid = initialValid;\r\n Object.keys(components).forEach(key => {\r\n const component = components[key];\r\n if (component && component.validation && !component.validation.isValid) {\r\n isFormValid = false;\r\n }\r\n });\r\n return isFormValid;\r\n }\r\n\r\n private updateCallback(\r\n componentId: string,\r\n componentState: FormComponentContextState\r\n ) {\r\n this.setState(previousState => {\r\n let components = Object.assign({}, previousState.contextState.components);\r\n const previousComponent = components[componentId];\r\n if (componentState && previousComponent) {\r\n components[componentId] = {\r\n ...previousComponent,\r\n ...componentState,\r\n validation: {\r\n ...previousComponent.validation,\r\n ...componentState.validation,\r\n },\r\n };\r\n }\r\n let isFormValid = this.getIsFormValid(components);\r\n return {\r\n contextState: {\r\n ...this.state.contextState,\r\n components,\r\n isFormValid,\r\n },\r\n };\r\n });\r\n }\r\n}\r\n\r\nexport default withThemeContext<FormProps, InstanceType<typeof Form>>(\r\n Form,\r\n 'form'\r\n);\r\n"],"mappings":";;;;;;;AACA;;AAGA;;AAMA;;;;;;;;;;;;;;AAmBO,MAAMA,IAAN,SAAmBC,KAAK,CAACC,aAAzB,CAA6D;EAOlEC,WAAW,CAACC,KAAD,EAAmB;IAC5B,MAAMA,KAAN;;IAD4B,kCA4HVC,CAAD,IAAwB;MACzCA,CAAC,CAACC,cAAF;MACA,KAAKF,KAAL,CAAWG,QAAX,IAAuB,KAAKH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AAU,GAAGO,MAAM,CAACsB,MAAP,CAAc,EAAd,EAAkBD,aAAa,CAAC9B,YAAd,CAA2BE,UAA7C,CAAjB;MACA,MAAMiC,iBAAiB,GAAGjC,UAAU,CAACyB,WAAD,CAApC;;MACA,IAAIC,cAAc,IAAIO,iBAAtB,EAAyC;QACvCjC,UAAU,CAACyB,WAAD,CAAV,iDACKQ,iBADL,GAEKP,cAFL;UAGEK,UAAU,kCACLE,iBAAiB,CAACF,UADb,GAELL,cAAc,CAACK,UAFV;QAHZ;MAQD;;MACD,IAAIhC,WAAW,GAAG,KAAKyB,cAAL,CAAoBxB,UAApB,CAAlB;MACA,OAAO;QACLF,YAAY,kCACP,KAAKD,KAAL,CAAWC,YADJ;UAEVE,UAFU;UAGVD;QAHU;MADP,CAAP;IAOD,CArBD;EAsBD;;AA7NiE;;;;gBAAvDhB,I,kBACkB;EAC3BmD,UAAU,EAAE,KADe;EAE3BC,aAAa,EAAE,IAFY;EAG3BxB,SAAS,EAAE;AAHgB,C;;eA+NhB,IAAAyB,kCAAA,EACbrD,IADa,EAEb,MAFa,C"}
@@ -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 [5 Oct 2022 at 13:51]</title>
6
+ <title>guestbell-forms [5 Oct 2022 at 14:2]</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/bg9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
  {
2
- "version": "2.0.306",
2
+ "version": "2.0.307",
3
3
  "description": "React forms with validation as used in GuestBell",
4
4
  "keywords": [
5
5
  "react",