@wavemaker/app-rn-runtime 12.0.0-next.141211 → 12.0.0-next.141216
Sign up to get free protection for your applications and to get access to all the features.
- app-rn-runtime/components/advanced/carousel/carousel.component.js +1 -0
- app-rn-runtime/components/advanced/carousel/carousel.component.js.map +1 -1
- app-rn-runtime/components/basic/audio/audio.component.js +9 -2
- app-rn-runtime/components/basic/audio/audio.component.js.map +1 -1
- app-rn-runtime/components/basic/audio/audio.styles.js +7 -0
- app-rn-runtime/components/basic/audio/audio.styles.js.map +1 -1
- app-rn-runtime/components/basic/custom/custom.component.js +1 -1
- app-rn-runtime/components/basic/custom/custom.component.js.map +1 -1
- app-rn-runtime/components/basic/lottie/lottie.component.js +3 -1
- app-rn-runtime/components/basic/lottie/lottie.component.js.map +1 -1
- app-rn-runtime/components/basic/search/search.component.js +1 -1
- app-rn-runtime/components/basic/search/search.component.js.map +1 -1
- app-rn-runtime/components/basic/search/search.props.js +1 -0
- app-rn-runtime/components/basic/search/search.props.js.map +1 -1
- app-rn-runtime/components/basic/skeleton/skeleton.component.js +2 -0
- app-rn-runtime/components/basic/skeleton/skeleton.component.js.map +1 -1
- app-rn-runtime/components/basic/video/video.component.js +6 -0
- app-rn-runtime/components/basic/video/video.component.js.map +1 -1
- app-rn-runtime/components/basic/video/video.styles.js +7 -1
- app-rn-runtime/components/basic/video/video.styles.js.map +1 -1
- app-rn-runtime/components/container/container.component.js +8 -1
- app-rn-runtime/components/container/container.component.js.map +1 -1
- app-rn-runtime/components/container/container.props.js +1 -0
- app-rn-runtime/components/container/container.props.js.map +1 -1
- app-rn-runtime/components/container/tabs/tabpane/tabpane.props.js +1 -0
- app-rn-runtime/components/container/tabs/tabpane/tabpane.props.js.map +1 -1
- app-rn-runtime/components/container/tabs/tabs.component.js +3 -1
- app-rn-runtime/components/container/tabs/tabs.component.js.map +1 -1
- app-rn-runtime/components/container/wizard/wizardstep/wizardstep.component.js +4 -0
- app-rn-runtime/components/container/wizard/wizardstep/wizardstep.component.js.map +1 -1
- app-rn-runtime/components/data/form/form-field/form-field.component.js +2 -1
- app-rn-runtime/components/data/form/form-field/form-field.component.js.map +1 -1
- app-rn-runtime/components/input/baseinput/baseinput.component.js +46 -10
- app-rn-runtime/components/input/baseinput/baseinput.component.js.map +1 -1
- app-rn-runtime/components/input/basenumber/basenumber.component.js +19 -6
- app-rn-runtime/components/input/basenumber/basenumber.component.js.map +1 -1
- app-rn-runtime/components/input/calendar/calendar.component.js +25 -0
- app-rn-runtime/components/input/calendar/calendar.component.js.map +1 -1
- app-rn-runtime/components/input/calendar/calendar.styles.js +19 -0
- app-rn-runtime/components/input/calendar/calendar.styles.js.map +1 -1
- app-rn-runtime/components/input/checkbox/checkbox.component.js +23 -3
- app-rn-runtime/components/input/checkbox/checkbox.component.js.map +1 -1
- app-rn-runtime/components/input/checkbox/checkbox.styles.js +19 -2
- app-rn-runtime/components/input/checkbox/checkbox.styles.js.map +1 -1
- app-rn-runtime/components/input/chips/chips.component.js +16 -2
- app-rn-runtime/components/input/chips/chips.component.js.map +1 -1
- app-rn-runtime/components/input/chips/chips.styles.js +8 -0
- app-rn-runtime/components/input/chips/chips.styles.js.map +1 -1
- app-rn-runtime/components/input/currency/currency.component.js +14 -4
- app-rn-runtime/components/input/currency/currency.component.js.map +1 -1
- app-rn-runtime/components/input/currency/currency.styles.js +43 -1
- app-rn-runtime/components/input/currency/currency.styles.js.map +1 -1
- app-rn-runtime/components/input/epoch/base-datetime.component.js +26 -5
- app-rn-runtime/components/input/epoch/base-datetime.component.js.map +1 -1
- app-rn-runtime/components/input/epoch/datetime/datetime.props.js +6 -0
- app-rn-runtime/components/input/epoch/datetime/datetime.props.js.map +1 -1
- app-rn-runtime/components/input/epoch/datetime/datetime.styles.js +13 -0
- app-rn-runtime/components/input/epoch/datetime/datetime.styles.js.map +1 -1
- app-rn-runtime/components/input/epoch/wheelpickermodal/date/date-picker-modal.component.js +7 -4
- app-rn-runtime/components/input/epoch/wheelpickermodal/date/date-picker-modal.component.js.map +1 -1
- app-rn-runtime/components/input/epoch/wheelpickermodal/date/date-picker-modal.props.js +3 -0
- app-rn-runtime/components/input/epoch/wheelpickermodal/date/date-picker-modal.props.js.map +1 -1
- app-rn-runtime/components/input/epoch/wheelpickermodal/time/time-picker-modal.component.js +7 -4
- app-rn-runtime/components/input/epoch/wheelpickermodal/time/time-picker-modal.component.js.map +1 -1
- app-rn-runtime/components/input/epoch/wheelpickermodal/time/time-picker-modal.props.js +3 -0
- app-rn-runtime/components/input/epoch/wheelpickermodal/time/time-picker-modal.props.js.map +1 -1
- app-rn-runtime/components/input/number/number.component.js +17 -3
- app-rn-runtime/components/input/number/number.component.js.map +1 -1
- app-rn-runtime/components/input/number/number.styles.js +24 -1
- app-rn-runtime/components/input/number/number.styles.js.map +1 -1
- app-rn-runtime/components/input/radioset/radioset.component.js +12 -7
- app-rn-runtime/components/input/radioset/radioset.component.js.map +1 -1
- app-rn-runtime/components/input/radioset/radioset.props.js +1 -0
- app-rn-runtime/components/input/radioset/radioset.props.js.map +1 -1
- app-rn-runtime/components/input/radioset/radioset.styles.js +6 -0
- app-rn-runtime/components/input/radioset/radioset.styles.js.map +1 -1
- app-rn-runtime/components/input/select/select.component.js +11 -3
- app-rn-runtime/components/input/select/select.component.js.map +1 -1
- app-rn-runtime/components/input/select/select.styles.js +24 -0
- app-rn-runtime/components/input/select/select.styles.js.map +1 -1
- app-rn-runtime/components/input/switch/switch.component.js +13 -3
- app-rn-runtime/components/input/switch/switch.component.js.map +1 -1
- app-rn-runtime/components/input/switch/switch.styles.js +15 -0
- app-rn-runtime/components/input/switch/switch.styles.js.map +1 -1
- app-rn-runtime/components/input/text/text.component.js +5 -2
- app-rn-runtime/components/input/text/text.component.js.map +1 -1
- app-rn-runtime/components/input/text/text.props.js +1 -0
- app-rn-runtime/components/input/text/text.props.js.map +1 -1
- app-rn-runtime/components/input/text/text.styles.js +3 -0
- app-rn-runtime/components/input/text/text.styles.js.map +1 -1
- app-rn-runtime/components/input/textarea/textarea.component.js +3 -1
- app-rn-runtime/components/input/textarea/textarea.component.js.map +1 -1
- app-rn-runtime/components/input/textarea/textarea.styles.js +3 -0
- app-rn-runtime/components/input/textarea/textarea.styles.js.map +1 -1
- app-rn-runtime/components/input/toggle/toggle.component.js +6 -0
- app-rn-runtime/components/input/toggle/toggle.component.js.map +1 -1
- app-rn-runtime/components/input/toggle/toggle.props.js +2 -0
- app-rn-runtime/components/input/toggle/toggle.props.js.map +1 -1
- app-rn-runtime/components/input/toggle/toggle.styles.js +7 -0
- app-rn-runtime/components/input/toggle/toggle.styles.js.map +1 -1
- app-rn-runtime/components/page/content/content.component.js +4 -19
- app-rn-runtime/components/page/content/content.component.js.map +1 -1
- app-rn-runtime/components/page/left-panel/left-panel.component.js +4 -1
- app-rn-runtime/components/page/left-panel/left-panel.component.js.map +1 -1
- app-rn-runtime/components/page/page-content/page-content.component.js +43 -12
- app-rn-runtime/components/page/page-content/page-content.component.js.map +1 -1
- app-rn-runtime/core/AppConfig.js.map +1 -1
- app-rn-runtime/core/base.component.js +31 -5
- app-rn-runtime/core/base.component.js.map +1 -1
- app-rn-runtime/core/components/textinput.component.js +9 -7
- app-rn-runtime/core/components/textinput.component.js.map +1 -1
- app-rn-runtime/core/storage.service.js +15 -0
- app-rn-runtime/core/storage.service.js.map +1 -1
- app-rn-runtime/core/wm-component-tree.js +58 -0
- app-rn-runtime/core/wm-component-tree.js.map +1 -0
- app-rn-runtime/package.json +13 -6
- app-rn-runtime/runtime/App.js +21 -2
- app-rn-runtime/runtime/App.js.map +1 -1
- app-rn-runtime/runtime/App.navigator.js +1 -0
- app-rn-runtime/runtime/App.navigator.js.map +1 -1
- app-rn-runtime/runtime/base-fragment.component.js +18 -0
- app-rn-runtime/runtime/base-fragment.component.js.map +1 -1
- app-rn-runtime/runtime/base-page.component.js +38 -2
- app-rn-runtime/runtime/base-page.component.js.map +1 -1
- app-rn-runtime/runtime/base-partial.component.js +3 -0
- app-rn-runtime/runtime/base-partial.component.js.map +1 -1
- app-rn-runtime/runtime/navigator/drawer.navigator.js +19 -10
- app-rn-runtime/runtime/navigator/drawer.navigator.js.map +1 -1
- app-rn-runtime/runtime/services/app-modal.service.js +4 -4
- app-rn-runtime/runtime/services/app-modal.service.js.map +1 -1
- app-rn-runtime/styles/theme.js +5 -0
- app-rn-runtime/styles/theme.js.map +1 -1
- app-rn-runtime/styles/theme.variables.js +1 -1
- app-rn-runtime/styles/theme.variables.js.map +1 -1
- app-rn-runtime/variables/http.service.js +5 -1
- app-rn-runtime/variables/http.service.js.map +1 -1
- app-rn-runtime/variables/live-variable.js +14 -0
- app-rn-runtime/variables/live-variable.js.map +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["React","View","BaseComponent","BaseComponentState","WmWizardstepProps","DEFAULT_CLASS","WmWizardstepState","constructor","args","_defineProperty","WmWizardstep","props","componentDidMount","wizard","parent","addWizardStep","onPropertyChange","name","$new","$old","refresh","setTimeout","forceUpdate","setActive","updateState","active","
|
1
|
+
{"version":3,"names":["React","View","BaseComponent","BaseComponentState","WmWizardstepProps","DEFAULT_CLASS","WmWizardstepState","constructor","args","_defineProperty","WmWizardstep","props","componentDidMount","wizard","parent","addWizardStep","onPropertyChange","name","$new","$old","refresh","setTimeout","forceUpdate","setActive","updateState","active","state","showContent","invokeEventCallback","setInActive","isVisible","invokeNextCB","index","proxy","invokePrevCB","invokeSkipCB","renderWidget","createElement","style","styles","root","_background","children"],"sources":["wizardstep.component.tsx"],"sourcesContent":["import React from 'react';\nimport { View } from 'react-native';\nimport { BaseComponent, BaseComponentState } from '@wavemaker/app-rn-runtime/core/base.component';\n\nimport WmWizardstepProps from './wizardstep.props';\nimport { DEFAULT_CLASS, WmWizardstepStyles } from './wizardstep.styles';\nimport WmWizard from '../wizard.component';\nimport { isBoolean } from 'lodash-es';\n\nexport class WmWizardstepState extends BaseComponentState<WmWizardstepProps> {\n active = false;\n showContent: boolean = false;\n}\n\nexport default class WmWizardstep extends BaseComponent<WmWizardstepProps, WmWizardstepState, WmWizardstepStyles> {\n\n constructor(props: WmWizardstepProps) {\n super(props, DEFAULT_CLASS, new WmWizardstepProps(), new WmWizardstepState());\n }\n\n componentDidMount() {\n const wizard = (this.parent) as WmWizard;\n // When skeleton is enabled in the wizard component, the parent would be WMSkeleton which doesnot have addWizardStep function\n if(wizard.addWizardStep) {\n wizard.addWizardStep(this);\n }\n super.componentDidMount();\n }\n\n onPropertyChange(name: string, $new: any, $old: any) {\n super.onPropertyChange(name, $new, $old);\n switch(name) {\n case 'title':\n const wizard = (this.parent) as WmWizard;\n wizard?.refresh();\n break;\n case 'disableprev':\n case 'disablenext':\n case 'disabledone':\n case 'enableskip':\n setTimeout(() => {\n this.parent.forceUpdate();\n }, 10);\n break;\n }\n }\n\n setActive() {\n this.updateState({\n active: true\n } as WmWizardstepState, () => {\n if(this.state.showContent) {\n this.invokeEventCallback('onLoad', [this]);\n }\n });\n }\n\n setInActive() {\n this.updateState({\n active: false\n } as WmWizardstepState);\n }\n\n isVisible() {\n return super.isVisible() && this.state.active;\n }\n\n invokeNextCB(index: number) : boolean {\n return this.invokeEventCallback('onNext', [this.proxy, this, index]);\n }\n\n invokePrevCB(index: number) : boolean {\n return this.invokeEventCallback('onPrev', [this.proxy, this, index]);\n }\n\n invokeSkipCB(index: number) {\n this.invokeEventCallback('onSkip', [this.proxy, this, index]);\n }\n renderWidget(props: WmWizardstepProps) {\n if(!this.state.showContent && this.isVisible()){\n this.updateState({showContent: true} as WmWizardstepState, ()=>{\n this.invokeEventCallback('onLoad', [this]);\n });\n }\n return this.state.showContent && (<View style={this.styles.root}>{this._background}{props.children}</View>);\n }\n}\n"],"mappings":";;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,IAAI,QAAQ,cAAc;AACnC,SAASC,aAAa,EAAEC,kBAAkB,QAAQ,+CAA+C;AAEjG,OAAOC,iBAAiB,MAAM,oBAAoB;AAClD,SAASC,aAAa,QAA4B,qBAAqB;AAIvE,OAAO,MAAMC,iBAAiB,SAASH,kBAAkB,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220
|
}
|
221
221
|
renderWidget(props) {
|
222
222
|
var childrenWithProps = React.Children.map(props.renderFormFields(this.proxy).props.children, child => {
|
223
|
+
var _child$props;
|
223
224
|
return /*#__PURE__*/React.cloneElement(child, {
|
224
|
-
datavalue: props.datavalue,
|
225
|
+
datavalue: props.datavalue || (child === null || child === void 0 || (_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.datavalue),
|
225
226
|
value: this.value,
|
226
227
|
isValid: this.state.isValid,
|
227
228
|
maskchar: props.maskchar,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["React","Text","View","BaseComponent","BaseComponentState","isEqual","isNil","get","find","cloneDeep","forEach","keys","WmFormFieldProps","DEFAULT_CLASS","PERFORMANCE_LOGGER","WmFormFieldState","constructor","args","_defineProperty","WmFormField","props","form","formScope","componentDidMount","_this$form","_this$form2","_this$form3","formwidget","formKey","formWidgets","name","registerFormFields","formFields","onFieldChangeEvt","$new","$old","isDefault","notifyChanges","updateState","datavalue","invokeEventCallback","undefined","validateFormField","updateDataOutput","call","observeOn","fields","field","formfield","f","proxy","notifyForFields","push","validate","setTimeout","getPromiseList","validators","arr","fn","promise","Function","bind","Promise","setAsyncValidators","_asyncValidatorFn","all","then","err","validationMsg","hasOwnProperty","messageKeys","toString","setInvalidState","setValidators","_cloneValidators","_syncValidators","obj","index","key","defaultValidatorMessages","value","propsObj","updateFormWidgetDataset","res","displayField","dataset","data","datafield","displayfield","state","msg","isValid","validationmessage","onPropertyChange","debug","applyDefaultValue","setPrimaryKey","setReadOnlyState","updateMode","_this$formwidget","readonly","_this$formwidget2","_this$_syncValidators","_this$formwidget3","errorType","errormsg","errorMessage","renderWidget","childrenWithProps","Children","map","renderFormFields","children","child","cloneElement","maskchar","displayformat","invokeEvent","triggerValidation","onFieldChange","formRef","placeholder","createElement","style","styles","root","_background","_extends","getTestPropsForLabel","errorMsg"],"sources":["form-field.component.tsx"],"sourcesContent":["import React from 'react';\nimport {Text, View} from 'react-native';\nimport { BaseComponent, BaseComponentState } from '@wavemaker/app-rn-runtime/core/base.component';\nimport { widgetsWithUndefinedValue } from '@wavemaker/app-rn-runtime/core/utils';\nimport { isEqual, isNil, get, find, cloneDeep, forEach, keys } from 'lodash';\n\nimport WmFormFieldProps from './form-field.props';\nimport { DEFAULT_CLASS, WmFormFieldStyles } from './form-field.styles';\nimport {PERFORMANCE_LOGGER} from \"@wavemaker/app-rn-runtime/core/logger\";\n\nexport class WmFormFieldState extends BaseComponentState<WmFormFieldProps> {\n isValid = true;\n}\n\nexport default class WmFormField extends BaseComponent<WmFormFieldProps, WmFormFieldState, WmFormFieldStyles> {\n public form: any;\n public formwidget: any;\n public _syncValidators: any;\n public defaultValidatorMessages: any = [];\n private notifyForFields: any = [];\n private _asyncValidatorFn: any;\n constructor(props: WmFormFieldProps) {\n super(props, DEFAULT_CLASS, new WmFormFieldProps(), new WmFormFieldState());\n if (!this.form) {\n this.form = props.formScope && props.formScope();\n }\n }\n\n componentDidMount() {\n super.componentDidMount();\n this.formwidget = (this.props.formKey && this.form?.formWidgets[this.props.formKey])\n || (this.props.name && this.form?.formWidgets[this.props.name]);\n this.form?.registerFormFields(this.form.formFields, this.form.formWidgets);\n }\n\n onFieldChangeEvt(name: string, $new: any, $old: any, isDefault: boolean) {\n this.notifyChanges();\n if (!isEqual($old, $new)) {\n this.updateState({ props: { datavalue: $new }} as WmFormFieldState, () => {\n !isDefault && this.invokeEventCallback('onChange', [undefined, this, $new, $old]);\n this.validateFormField();\n });\n if (this.form) {\n this.form.updateDataOutput.call(this.form, get(this.props, 'formKey', this.props.name), $new);\n }\n }\n }\n\n // Registers observer of validation fields\n observeOn(fields: any) {\n forEach(fields, (field) => {\n const formfield = find(this.form.formFields, (f) => f.proxy.name === field);\n if (formfield) {\n formfield.notifyForFields.push(this);\n }\n });\n }\n\n // Notifies changes to observing validation fields\n notifyChanges() {\n forEach(this.notifyForFields, (field) => {\n field.formwidget.validate(field.formwidget.datavalue);\n setTimeout(() => field.validateFormField());\n });\n }\n\n getPromiseList(validators: any) {\n const arr: any = [];\n forEach(validators, (fn) => {\n let promise = fn;\n if (fn instanceof Function && fn.bind) {\n promise = fn(this.formwidget.proxy, this.form);\n }\n if (promise instanceof Promise) {\n arr.push(promise);\n }\n });\n return arr;\n }\n\n // this method sets the asyncValidation on the form field. Assigns validationmessages from the returned response\n setAsyncValidators(validators: any) {\n this._asyncValidatorFn = () => {\n return Promise.all(this.getPromiseList(validators)).then(() => {\n return null;\n }, err => {\n let validationMsg: string;\n // if err obj has validationMessage key, then set validationMessage using this value\n // else return the value of the first key in the err object as validation message.\n if (err.hasOwnProperty('errorMessage')) {\n validationMsg = get(err, 'errorMessage');\n } else {\n const messageKeys = keys(err);\n validationMsg = (err[messageKeys[0]]).toString();\n }\n this.setInvalidState(validationMsg);\n return err;\n })\n };\n }\n\n // sets the default validation on the form field\n setValidators(validators: any) {\n let _cloneValidators = cloneDeep(validators);\n this._syncValidators = [];\n forEach(_cloneValidators, (obj, index) => {\n // custom validation is bound to function.\n if (obj && obj instanceof Function) {\n // passing formwidget and form as arguments to the obj (i.e. validator function)\n _cloneValidators[index] = obj.bind(undefined, this.formwidget.proxy, this.form);\n this._syncValidators.push(_cloneValidators[index]);\n } else {\n // checks for default validator like required, maxchars etc.\n const key = get(obj, 'type');\n this.defaultValidatorMessages[key] = get(obj, 'errorMessage');\n const value = get(obj, 'validator');\n let propsObj: any = {\n props: {}\n };\n propsObj.props[key] = value;\n key === 'required' && this.updateState(propsObj as WmFormFieldState);\n this.formwidget.updateState(propsObj as WmFormFieldState);\n }\n });\n }\n\n updateFormWidgetDataset(res: any, displayField: string) {\n this.formwidget.updateState({\n props: {\n dataset: res.data,\n datafield: 'All Fields',\n displayfield: this.formwidget.state.props.displayfield || displayField,\n }\n } as WmFormFieldState);\n }\n\n setInvalidState(msg: string) {\n this.updateState({\n isValid: false,\n props: {\n validationmessage: msg\n }\n } as WmFormFieldState)\n this.formwidget.updateState({\n isValid: false,\n props: {\n validationmessage: msg\n }\n } as WmFormFieldState);\n }\n\n onPropertyChange(name: string, $new: any, $old: any) {\n switch (name) {\n case 'datavalue':\n if (!isEqual($old, $new)) {\n PERFORMANCE_LOGGER.debug(`form field ${this.props.name} changed from ${$old} to ${$new}`);\n }\n break;\n case 'defaultvalue':\n if (!isEqual($old, $new)) {\n get(this, 'form') && this.form.applyDefaultValue(this);\n }\n break;\n case 'primary-key':\n if ($new) {\n this.form.setPrimaryKey(this.props.name);\n }\n break;\n }\n }\n\n setReadOnlyState(updateMode: any) {\n this.formwidget?.updateState({\n props: {\n readonly: !updateMode,\n }\n } as WmFormFieldState);\n }\n\n validateFormField() {\n if (this.formwidget?.state.isValid === false) {\n const errorType = this.formwidget?.state?.errorType;\n let validationMsg = get(this.defaultValidatorMessages, errorType);\n if (validationMsg) {\n if (validationMsg instanceof Function) {\n // passing formwidget and form as arguments to the errorMessage function.\n validationMsg = validationMsg(this.formwidget.proxy, this.form);\n }\n this.updateState({ props: {\n validationmessage: validationMsg\n }} as WmFormFieldState);\n }\n this.updateState({ isValid: false} as WmFormFieldState);\n } else {\n this.updateState({ isValid: true } as WmFormFieldState);\n }\n\n this._syncValidators?.forEach((fn: any) => {\n const errormsg = fn();\n let validationMsg = errormsg?.errorMessage;\n if (validationMsg) {\n if (validationMsg instanceof Function) {\n // passing formwidget and form as arguments to the errorMessage function.\n validationMsg = validationMsg(this.formwidget.proxy, this.form);\n }\n this.setInvalidState(validationMsg);\n }\n })\n\n this._asyncValidatorFn && this._asyncValidatorFn();\n\n }\n\n get value(){\n return this.state.props.datavalue;\n }\n\n renderWidget(props: WmFormFieldProps) {\n var childrenWithProps = React.Children.map(props.renderFormFields(this.proxy).props.children, (child) => {\n return React.cloneElement(child, {\n datavalue: props.datavalue,\n value: this.value,\n isValid: this.state.isValid,\n maskchar: props.maskchar,\n displayformat: props.displayformat,\n invokeEvent: this.invokeEventCallback.bind(this),\n triggerValidation: this.validateFormField.bind(this),\n onFieldChange: this.onFieldChangeEvt.bind(this),\n formRef: props.formRef,\n ...(!isNil(props?.placeholder) ? { placeholder: props.placeholder } : {})\n });\n });\n return (\n <View style={this.styles.root}>{this._background}{childrenWithProps}\n {this.state.isValid === false && <Text {...this.getTestPropsForLabel('error_msg')} style={this.styles.errorMsg}>{props.validationmessage}</Text>}\n </View>\n );\n }\n}\n"],"mappings":";;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAAQC,IAAI,EAAEC,IAAI,QAAO,cAAc;AACvC,SAASC,aAAa,EAAEC,kBAAkB,QAAQ,+CAA+C;AAEjG,SAASC,OAAO,EAAEC,KAAK,EAAEC,GAAG,EAAEC,IAAI,EAAEC,SAAS,EAAEC,OAAO,EAAEC,IAAI,QAAQ,QAAQ;AAE5E,OAAOC,gBAAgB,MAAM,oBAAoB;AACjD,SAASC,aAAa,QAA2B,qBAAqB;AACtE,SAAQC,kBAAkB,QAAO,uCAAuC;AAExE,OAAO,MAAMC,gBAAgB,SAASX,kBAAkB,CAAmB;EAAAY,YAAA,GAAAC,IAAA;IAAA,SAAAA,IAAA;IAAAC,eAAA,kBAC/D,IAAI;EAAA;AAChB;AAEA,eAAe,MAAMC,WAAW,SAAShB,aAAa,CAAwD;EAO5Ga,WAAWA,CAACI,KAAuB,EAAE;IACnC,KAAK,CAACA,KAAK,EAAEP,aAAa,EAAE,IAAID,gBAAgB,CAAC,CAAC,EAAE,IAAIG,gBAAgB,CAAC,CAAC,CAAC;IAACG,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA,mCAJvC,EAAE;IAAAA,eAAA,0BACV,EAAE;IAAAA,eAAA;IAI/B,IAAI,CAAC,IAAI,CAACG,IAAI,EAAE;MACd,IAAI,CAACA,IAAI,GAAGD,KAAK,CAACE,SAAS,IAAIF,KAAK,CAACE,SAAS,CAAC,CAAC;IAClD;EACF;EAEAC,iBAAiBA,CAAA,EAAG;IAAA,IAAAC,UAAA,EAAAC,WAAA,EAAAC,WAAA;IAClB,KAAK,CAACH,iBAAi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Q;QACxBC,aAAa,EAAEhG,KAAK,CAACgG,aAAa;QAClCC,WAAW,EAAE,IAAI,CAAC7E,mBAAmB,CAACqB,IAAI,CAAC,IAAI,CAAC;QAChDyD,iBAAiB,EAAE,IAAI,CAAC5E,iBAAiB,CAACmB,IAAI,CAAC,IAAI,CAAC;QACpD0D,aAAa,EAAE,IAAI,CAACtF,gBAAgB,CAAC4B,IAAI,CAAC,IAAI,CAAC;QAC/C2D,OAAO,EAAEpG,KAAK,CAACoG,OAAO;QACtB,IAAI,CAAClH,KAAK,CAACc,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEqG,WAAW,CAAC,GAAG;UAAEA,WAAW,EAAErG,KAAK,CAACqG;QAAY,CAAC,GAAG,CAAC,CAAC;MACzE,CAAC,CAAC;IACP,CAAC,CAAC;IACF,oBACEzH,KAAA,CAAA0H,aAAA,CAACxH,IAAI;MAACyH,KAAK,EAAE,IAAI,CAACC,MAAM,CAACC;IAAK,GAAE,IAAI,CAACC,WAAW,EAAElB,iBAAiB,EAChE,IAAI,CAACnB,KAAK,CAACE,OAAO,KAAK,KAAK,iBAAI3F,KAAA,CAAA0H,aAAA,CAACzH,IAAI,EAAA8H,QAAA,KAAK,IAAI,CAACC,oBAAoB,CAAC,WAAW,CAAC;MAAEL,KAAK,EAAE,IAAI,CAACC,MAAM,CAACK;IAAS,IAAE7G,KAAK,CAACwE,iBAAwB,CAC3I,CAAC;EAEX;AACF","ignoreList":[]}
|
1
|
+
{"version":3,"names":["React","Text","View","BaseComponent","BaseComponentState","isEqual","isNil","get","find","cloneDeep","forEach","keys","WmFormFieldProps","DEFAULT_CLASS","PERFORMANCE_LOGGER","WmFormFieldState","constructor","args","_defineProperty","WmFormField","props","form","formScope","componentDidMount","_this$form","_this$form2","_this$form3","formwidget","formKey","formWidgets","name","registerFormFields","formFields","onFieldChangeEvt","$new","$old","isDefault","notifyChanges","updateState","datavalue","invokeEventCallback","undefined","validateFormField","updateDataOutput","call","observeOn","fields","field","formfield","f","proxy","notifyForFields","push","validate","setTimeout","getPromiseList","validators","arr","fn","promise","Function","bind","Promise","setAsyncValidators","_asyncValidatorFn","all","then","err","validationMsg","hasOwnProperty","messageKeys","toString","setInvalidState","setValidators","_cloneValidators","_syncValidators","obj","index","key","defaultValidatorMessages","value","propsObj","updateFormWidgetDataset","res","displayField","dataset","data","datafield","displayfield","state","msg","isValid","validationmessage","onPropertyChange","debug","applyDefaultValue","setPrimaryKey","setReadOnlyState","updateMode","_this$formwidget","readonly","_this$formwidget2","_this$_syncValidators","_this$formwidget3","errorType","errormsg","errorMessage","renderWidget","childrenWithProps","Children","map","renderFormFields","children","child","_child$props","cloneElement","maskchar","displayformat","invokeEvent","triggerValidation","onFieldChange","formRef","placeholder","createElement","style","styles","root","_background","_extends","getTestPropsForLabel","errorMsg"],"sources":["form-field.component.tsx"],"sourcesContent":["import React from 'react';\nimport {Text, View} from 'react-native';\nimport { BaseComponent, BaseComponentState } from '@wavemaker/app-rn-runtime/core/base.component';\nimport { widgetsWithUndefinedValue } from '@wavemaker/app-rn-runtime/core/utils';\nimport { isEqual, isNil, get, find, cloneDeep, forEach, keys } from 'lodash';\n\nimport WmFormFieldProps from './form-field.props';\nimport { DEFAULT_CLASS, WmFormFieldStyles } from './form-field.styles';\nimport {PERFORMANCE_LOGGER} from \"@wavemaker/app-rn-runtime/core/logger\";\n\nexport class WmFormFieldState extends BaseComponentState<WmFormFieldProps> {\n isValid = true;\n}\n\nexport default class WmFormField extends BaseComponent<WmFormFieldProps, WmFormFieldState, WmFormFieldStyles> {\n public form: any;\n public formwidget: any;\n public _syncValidators: any;\n public defaultValidatorMessages: any = [];\n private notifyForFields: any = [];\n private _asyncValidatorFn: any;\n constructor(props: WmFormFieldProps) {\n super(props, DEFAULT_CLASS, new WmFormFieldProps(), new WmFormFieldState());\n if (!this.form) {\n this.form = props.formScope && props.formScope();\n }\n }\n\n componentDidMount() {\n super.componentDidMount();\n this.formwidget = (this.props.formKey && this.form?.formWidgets[this.props.formKey])\n || (this.props.name && this.form?.formWidgets[this.props.name]);\n this.form?.registerFormFields(this.form.formFields, this.form.formWidgets);\n }\n\n onFieldChangeEvt(name: string, $new: any, $old: any, isDefault: boolean) {\n this.notifyChanges();\n if (!isEqual($old, $new)) {\n this.updateState({ props: { datavalue: $new }} as WmFormFieldState, () => {\n !isDefault && this.invokeEventCallback('onChange', [undefined, this, $new, $old]);\n this.validateFormField();\n });\n if (this.form) {\n this.form.updateDataOutput.call(this.form, get(this.props, 'formKey', this.props.name), $new);\n }\n }\n }\n\n // Registers observer of validation fields\n observeOn(fields: any) {\n forEach(fields, (field) => {\n const formfield = find(this.form.formFields, (f) => f.proxy.name === field);\n if (formfield) {\n formfield.notifyForFields.push(this);\n }\n });\n }\n\n // Notifies changes to observing validation fields\n notifyChanges() {\n forEach(this.notifyForFields, (field) => {\n field.formwidget.validate(field.formwidget.datavalue);\n setTimeout(() => field.validateFormField());\n });\n }\n\n getPromiseList(validators: any) {\n const arr: any = [];\n forEach(validators, (fn) => {\n let promise = fn;\n if (fn instanceof Function && fn.bind) {\n promise = fn(this.formwidget.proxy, this.form);\n }\n if (promise instanceof Promise) {\n arr.push(promise);\n }\n });\n return arr;\n }\n\n // this method sets the asyncValidation on the form field. Assigns validationmessages from the returned response\n setAsyncValidators(validators: any) {\n this._asyncValidatorFn = () => {\n return Promise.all(this.getPromiseList(validators)).then(() => {\n return null;\n }, err => {\n let validationMsg: string;\n // if err obj has validationMessage key, then set validationMessage using this value\n // else return the value of the first key in the err object as validation message.\n if (err.hasOwnProperty('errorMessage')) {\n validationMsg = get(err, 'errorMessage');\n } else {\n const messageKeys = keys(err);\n validationMsg = (err[messageKeys[0]]).toString();\n }\n this.setInvalidState(validationMsg);\n return err;\n })\n };\n }\n\n // sets the default validation on the form field\n setValidators(validators: any) {\n let _cloneValidators = cloneDeep(validators);\n this._syncValidators = [];\n forEach(_cloneValidators, (obj, index) => {\n // custom validation is bound to function.\n if (obj && obj instanceof Function) {\n // passing formwidget and form as arguments to the obj (i.e. validator function)\n _cloneValidators[index] = obj.bind(undefined, this.formwidget.proxy, this.form);\n this._syncValidators.push(_cloneValidators[index]);\n } else {\n // checks for default validator like required, maxchars etc.\n const key = get(obj, 'type');\n this.defaultValidatorMessages[key] = get(obj, 'errorMessage');\n const value = get(obj, 'validator');\n let propsObj: any = {\n props: {}\n };\n propsObj.props[key] = value;\n key === 'required' && this.updateState(propsObj as WmFormFieldState);\n this.formwidget.updateState(propsObj as WmFormFieldState);\n }\n });\n }\n\n updateFormWidgetDataset(res: any, displayField: string) {\n this.formwidget.updateState({\n props: {\n dataset: res.data,\n datafield: 'All Fields',\n displayfield: this.formwidget.state.props.displayfield || displayField,\n }\n } as WmFormFieldState);\n }\n\n setInvalidState(msg: string) {\n this.updateState({\n isValid: false,\n props: {\n validationmessage: msg\n }\n } as WmFormFieldState)\n this.formwidget.updateState({\n isValid: false,\n props: {\n validationmessage: msg\n }\n } as WmFormFieldState);\n }\n\n onPropertyChange(name: string, $new: any, $old: any) {\n switch (name) {\n case 'datavalue':\n if (!isEqual($old, $new)) {\n PERFORMANCE_LOGGER.debug(`form field ${this.props.name} changed from ${$old} to ${$new}`);\n }\n break;\n case 'defaultvalue':\n if (!isEqual($old, $new)) {\n get(this, 'form') && this.form.applyDefaultValue(this);\n }\n break;\n case 'primary-key':\n if ($new) {\n this.form.setPrimaryKey(this.props.name);\n }\n break;\n }\n }\n\n setReadOnlyState(updateMode: any) {\n this.formwidget?.updateState({\n props: {\n readonly: !updateMode,\n }\n } as WmFormFieldState);\n }\n\n validateFormField() {\n if (this.formwidget?.state.isValid === false) {\n const errorType = this.formwidget?.state?.errorType;\n let validationMsg = get(this.defaultValidatorMessages, errorType);\n if (validationMsg) {\n if (validationMsg instanceof Function) {\n // passing formwidget and form as arguments to the errorMessage function.\n validationMsg = validationMsg(this.formwidget.proxy, this.form);\n }\n this.updateState({ props: {\n validationmessage: validationMsg\n }} as WmFormFieldState);\n }\n this.updateState({ isValid: false} as WmFormFieldState);\n } else {\n this.updateState({ isValid: true } as WmFormFieldState);\n }\n\n this._syncValidators?.forEach((fn: any) => {\n const errormsg = fn();\n let validationMsg = errormsg?.errorMessage;\n if (validationMsg) {\n if (validationMsg instanceof Function) {\n // passing formwidget and form as arguments to the errorMessage function.\n validationMsg = validationMsg(this.formwidget.proxy, this.form);\n }\n this.setInvalidState(validationMsg);\n }\n })\n\n this._asyncValidatorFn && this._asyncValidatorFn();\n\n }\n\n get value(){\n return this.state.props.datavalue;\n }\n\n renderWidget(props: WmFormFieldProps) {\n var childrenWithProps = React.Children.map(props.renderFormFields(this.proxy).props.children, (child) => {\n return React.cloneElement(child, {\n datavalue: props.datavalue || child?.props?.datavalue,\n value: this.value,\n isValid: this.state.isValid,\n maskchar: props.maskchar,\n displayformat: props.displayformat,\n invokeEvent: this.invokeEventCallback.bind(this),\n triggerValidation: this.validateFormField.bind(this),\n onFieldChange: this.onFieldChangeEvt.bind(this),\n formRef: props.formRef,\n ...(!isNil(props?.placeholder) ? { placeholder: props.placeholder } : {})\n });\n });\n return (\n <View style={this.styles.root}>{this._background}{childrenWithProps}\n {this.state.isValid === false && <Text {...this.getTestPropsForLabel('error_msg')} style={this.styles.errorMsg}>{props.validationmessage}</Text>}\n </View>\n );\n }\n}\n"],"mappings":";;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAAQC,IAAI,EAAEC,IAAI,QAAO,cAAc;AACvC,SAASC,aAAa,EAAEC,kBAAkB,QAAQ,+CAA+C;AAEjG,SAASC,OAAO,EAAEC,KAAK,EAAEC,GAAG,EAAEC,IAAI,EAAEC,SAAS,EAAEC,OAAO,EAAEC,IAAI,QAAQ,QAAQ;AAE5E,OAAOC,gBAAgB,MAAM,oBAAoB;AACjD,SAASC,aAAa,QAA2B,qBAAqB;AACtE,SAAQC,kBAAkB,QAAO,uCAAuC;AAExE,OAAO,MAAMC,gBAAgB,SAASX,kBAAkB,CAAmB;EAAAY,YAAA,GAAAC,IAAA;IAAA,SAAA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AA2H,aAAA,CAACzH,IAAI;MAAC0H,KAAK,EAAE,IAAI,CAACC,MAAM,CAACC;IAAK,GAAE,IAAI,CAACC,WAAW,EAAEnB,iBAAiB,EAChE,IAAI,CAACnB,KAAK,CAACE,OAAO,KAAK,KAAK,iBAAI3F,KAAA,CAAA2H,aAAA,CAAC1H,IAAI,EAAA+H,QAAA,KAAK,IAAI,CAACC,oBAAoB,CAAC,WAAW,CAAC;MAAEL,KAAK,EAAE,IAAI,CAACC,MAAM,CAACK;IAAS,IAAE9G,KAAK,CAACwE,iBAAwB,CAC3I,CAAC;EAEX;AACF","ignoreList":[]}
|
@@ -12,6 +12,7 @@ export class BaseInputState extends BaseComponentState {
|
|
12
12
|
super(...args);
|
13
13
|
_defineProperty(this, "keyboardType", 'default');
|
14
14
|
_defineProperty(this, "isValid", true);
|
15
|
+
_defineProperty(this, "isInputFocused", false);
|
15
16
|
_defineProperty(this, "textValue", '');
|
16
17
|
_defineProperty(this, "isDefault", false);
|
17
18
|
_defineProperty(this, "errorType", '');
|
@@ -24,6 +25,7 @@ export class BaseInputComponent extends BaseComponent {
|
|
24
25
|
_defineProperty(this, "widgetRef", null);
|
25
26
|
_defineProperty(this, "isTouched", false);
|
26
27
|
_defineProperty(this, "cursor", 0);
|
28
|
+
_defineProperty(this, "timer", null);
|
27
29
|
}
|
28
30
|
focus() {
|
29
31
|
var _this$widgetRef;
|
@@ -65,17 +67,40 @@ export class BaseInputComponent extends BaseComponent {
|
|
65
67
|
onChange(event) {
|
66
68
|
if (this.state.props.updateon === 'default') {
|
67
69
|
this.updateDatavalue(event.target.value, event);
|
70
|
+
} else if (this.state.props.updateon === 'lazy') {
|
71
|
+
if (this.timer !== null) {
|
72
|
+
clearTimeout(this.timer);
|
73
|
+
this.timer = null;
|
74
|
+
}
|
75
|
+
this.timer = setTimeout(() => {
|
76
|
+
this.updateDatavalue(event.target.value, event);
|
77
|
+
}, 300);
|
68
78
|
}
|
69
79
|
}
|
70
80
|
onChangeText(value) {
|
71
|
-
this.
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
this.validate(value);
|
76
|
-
this.updateDatavalue(value, null);
|
81
|
+
if (this.state.props.updateon === 'lazy') {
|
82
|
+
if (this.timer !== null) {
|
83
|
+
clearTimeout(this.timer);
|
84
|
+
this.timer = null;
|
77
85
|
}
|
78
|
-
|
86
|
+
this.timer = setTimeout(() => {
|
87
|
+
this.updateState({
|
88
|
+
textValue: value
|
89
|
+
}, () => {
|
90
|
+
this.validate(value);
|
91
|
+
this.updateDatavalue(value, null);
|
92
|
+
});
|
93
|
+
}, 300);
|
94
|
+
} else {
|
95
|
+
this.updateState({
|
96
|
+
textValue: value
|
97
|
+
}, () => {
|
98
|
+
if (this.state.props.updateon === 'default') {
|
99
|
+
this.validate(value);
|
100
|
+
this.updateDatavalue(value, null);
|
101
|
+
}
|
102
|
+
});
|
103
|
+
}
|
79
104
|
}
|
80
105
|
invokeChange(e) {
|
81
106
|
if (Platform.OS === 'web') {
|
@@ -99,6 +124,11 @@ export class BaseInputComponent extends BaseComponent {
|
|
99
124
|
new Promise(resolve => {
|
100
125
|
if (props.hastwowaybinding) {
|
101
126
|
this.setProp("datavalue", value);
|
127
|
+
this.updateState({
|
128
|
+
props: {
|
129
|
+
"datavalue": value
|
130
|
+
}
|
131
|
+
});
|
102
132
|
resolve(true);
|
103
133
|
} else {
|
104
134
|
this.updateState({
|
@@ -117,7 +147,7 @@ export class BaseInputComponent extends BaseComponent {
|
|
117
147
|
onBlur(event) {
|
118
148
|
Injector.FOCUSED_ELEMENT.remove();
|
119
149
|
this.isTouched = true;
|
120
|
-
let newVal = this.state.textValue;
|
150
|
+
let newVal = this.state.textValue || '';
|
121
151
|
let oldVal = this.state.props.datavalue || '';
|
122
152
|
this.validate(newVal);
|
123
153
|
if (newVal === '' || newVal == undefined) {
|
@@ -125,12 +155,15 @@ export class BaseInputComponent extends BaseComponent {
|
|
125
155
|
this.props.triggerValidation && this.props.triggerValidation();
|
126
156
|
}, 10);
|
127
157
|
}
|
128
|
-
if (this.state.props.updateon === 'blur') {
|
129
|
-
if (oldVal !== newVal) {
|
158
|
+
if (this.state.props.updateon === 'blur' || this.state.props.updateon === 'default') {
|
159
|
+
if (oldVal !== newVal && this.state.props.updateon === 'blur') {
|
130
160
|
this.updateDatavalue(newVal, event, 'blur');
|
131
161
|
} else {
|
132
162
|
this.invokeEventCallback('onBlur', [event, this.proxy]);
|
133
163
|
}
|
164
|
+
this.setState({
|
165
|
+
isInputFocused: false
|
166
|
+
});
|
134
167
|
}
|
135
168
|
}
|
136
169
|
validate(value) {
|
@@ -149,6 +182,9 @@ export class BaseInputComponent extends BaseComponent {
|
|
149
182
|
this.invokeEventCallback('onFocus', [event, this.proxy]);
|
150
183
|
(_this$closestTappable = this.closestTappable) === null || _this$closestTappable === void 0 || _this$closestTappable.triggerTap();
|
151
184
|
}, 250);
|
185
|
+
this.setState({
|
186
|
+
isInputFocused: true
|
187
|
+
});
|
152
188
|
}
|
153
189
|
onKeyPress(event) {
|
154
190
|
this.invokeEventCallback('onKeypress', [event, this.proxy]);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["DEFAULT_CLASS","BaseComponent","BaseComponentState","isString","Platform","validateField","Injector","BaseInputState","constructor","args","_defineProperty","BaseInputComponent","props","defaultClass","defaultProps","defaultState","focus","_this$widgetRef","widgetRef","blur","_this$widgetRef2","_this$widgetRef3","onPropertyChange","name","$new","$old","keyboardType","type","updateState","textValue","isDefault","state","onFieldChange","bind","onChange","event","updateon","updateDatavalue","target","value","onChangeText","validate","invokeChange","e","OS","cursor","selectionStart","setState","source","oldValue","datavalue","autotrim","trim","Promise","resolve","hastwowaybinding","setProp","then","invokeEventCallback","proxy","onBlur","FOCUSED_ELEMENT","remove","isTouched","newVal","oldVal","undefined","setTimeout","triggerValidation","validationObj","isValid","errorType","onFocus","_this$closestTappable","set","closestTappable","triggerTap","onKeyPress"],"sources":["baseinput.component.ts"],"sourcesContent":["import { DEFAULT_CLASS } from '@wavemaker/app-rn-runtime/components/navigation/basenav/basenav.styles';\nimport { BaseComponent, BaseComponentState } from '@wavemaker/app-rn-runtime/core/base.component';\nimport BaseInputProps from './baseinput.props';\nimport { isString } from 'lodash';\nimport { BaseInputStyles } from './baseinput.styles';\nimport { Platform, TextInput } from 'react-native';\nimport { validateField } from '@wavemaker/app-rn-runtime/core/utils';\nimport Injector from '@wavemaker/app-rn-runtime/core/injector';\n\nexport class BaseInputState <T extends BaseInputProps> extends BaseComponentState<T> {\n keyboardType: any = 'default';\n isValid: boolean = true;\n textValue: string = '';\n isDefault = false;\n errorType: string = '';\n}\nexport abstract class BaseInputComponent< T extends BaseInputProps, S extends BaseInputState<T>, L extends BaseInputStyles> extends BaseComponent<T, S, L> {\n public widgetRef: TextInput | null = null;\n isTouched: boolean = false;\n private cursor: any = 0;\n constructor(props: T, public defaultClass: string = DEFAULT_CLASS, defaultProps?: T, defaultState?: S) {\n super(props, defaultClass, defaultProps, defaultState);\n }\n\n focus() {\n this?.widgetRef?.focus();\n }\n\n blur() {\n this?.widgetRef?.blur && this?.widgetRef?.blur();\n }\n\n onPropertyChange(name: string, $new: any, $old: any) {\n switch (name) {\n case 'type':\n let keyboardType;\n if (this.props.type === 'number') {\n keyboardType = 'numeric';\n } else if (this.props.type === 'tel') {\n keyboardType = 'phone-pad';\n } else if (this.props.type === 'email') {\n keyboardType = 'email-address';\n }\n this.updateState({\n keyboardType: keyboardType,\n } as S);\n break;\n case 'datavalue':\n this.updateState({\n textValue: $new\n } as S\n );\n const isDefault = this.state.isDefault;\n if (isDefault) {\n this.updateState({ isDefault: false } as S, this.props.onFieldChange && this.props.onFieldChange.bind(this, 'datavalue', $new, $old, isDefault));\n } else {\n this.props.onFieldChange && this.props.onFieldChange('datavalue', $new, $old, isDefault);\n }\n }\n }\n\n onChange(event: any) {\n if (this.state.props.updateon === 'default') {\n this.updateDatavalue(event.target.value, event);\n }\n }\n\n onChangeText(value: any) {\n this.updateState({\n textValue: value\n } as S, () => {\n if (this.state.props.updateon === 'default') {\n this.validate(value);\n this.updateDatavalue(value, null);\n }\n }\n );\n }\n\n invokeChange(e: any) {\n if (Platform.OS === 'web') {\n this.cursor = e.target.selectionStart;\n this.setState({ textValue: e.target.value });\n }\n }\n\n updateDatavalue(value: any, event?: any, source?: any) {\n const props = this.state.props;\n const oldValue = props.datavalue;\n if (value === oldValue) {\n return;\n }\n\n // autotrim\n if (props.autotrim && props.datavalue && isString(props.datavalue)) {\n value = value.trim();\n }\n new Promise((resolve) => {\n if (props.hastwowaybinding) {\n this.setProp(\"datavalue\", value);\n resolve(true);\n } else {\n this.updateState({\n props: {\n datavalue: value\n }\n } as S, () => resolve(true));\n }\n }).then(() => {\n !this.props.onFieldChange && value !== oldValue && this.invokeEventCallback('onChange', [event, this.proxy, value, oldValue]);\n if (source === 'blur') {\n this.invokeEventCallback('onBlur', [ event, this.proxy]);\n }\n })\n }\n\n onBlur(event: any) {\n Injector.FOCUSED_ELEMENT.remove();\n this.isTouched = true;\n let newVal = this.state.textValue;\n let oldVal = this.state.props.datavalue || '';\n this.validate(newVal);\n if (newVal === '' || newVal == undefined) {\n setTimeout(() => {\n this.props.triggerValidation && this.props.triggerValidation();\n },10)\n }\n if (this.state.props.updateon === 'blur') {\n if (oldVal !== newVal) {\n this.updateDatavalue(newVal, event, 'blur');\n } else {\n this.invokeEventCallback('onBlur', [event, this.proxy]);\n }\n }\n }\n\n validate(value: any) {\n const validationObj = validateField(this.state.props, value);\n this.setState({\n isValid: validationObj.isValid,\n errorType: validationObj.errorType\n } as S);\n }\n\n onFocus(event: any) {\n // When input widgets are inside list widget and try to focus the field, list is selecting but unable to enter values in input fields\n // because on tap event of list is triggering after 200ms timeout So added 250ms timeout here\n setTimeout(() => {\n Injector.FOCUSED_ELEMENT.set(this);\n this.invokeEventCallback('onFocus', [ event, this.proxy]);\n this.closestTappable?.triggerTap();\n }, 250);\n\n }\n\n onKeyPress(event: any) {\n this.invokeEventCallback('onKeypress', [ event, this.proxy]);\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M;QACL,IAAI,CAACuB,mBAAmB,CAAC,QAAQ,EAAE,CAACvB,KAAK,EAAE,IAAI,CAACwB,KAAK,CAAC,CAAC;MACzD;IACF;EACF;EAEAlB,QAAQA,CAACF,KAAU,EAAE;IACnB,MAAM8B,aAAa,GAAGhE,aAAa,CAAC,IAAI,CAAC0B,KAAK,CAACnB,KAAK,EAAE2B,KAAK,CAAC;IAC5D,IAAI,CAACQ,QAAQ,CAAC;MACZuB,OAAO,EAAED,aAAa,CAACC,OAAO;MAC9BC,SAAS,EAAEF,aAAa,CAACE;IAC3B,CAAM,CAAC;EACT;EAEAC,OAAOA,CAACrC,KAAU,EAAE;IAClB;IACA;IACAgC,UAAU,CAAC,MAAM;MAAA,IAAAM,qBAAA;MACfnE,QAAQ,CAACuD,eAAe,CAACa,GAAG,CAAC,IAAI,CAAC;MAClC,IAAI,CAAChB,mBAAmB,CAAC,SAAS,EAAE,CAAEvB,KAAK,EAAE,IAAI,CAACwB,KAAK,CAAC,CAAC;MACzD,CAAAc,qBAAA,OAAI,CAACE,eAAe,cAAAF,qBAAA,eAApBA,qBAAA,CAAsBG,UAAU,CAAC,CAAC;IACpC,CAAC,EAAE,GAAG,CAAC;EAET;EAEAC,UAAUA,CAAC1C,KAAU,EAAE;IACrB,IAAI,CAACuB,mBAAmB,CAAC,YAAY,EAAE,CAAEvB,KAAK,EAAE,IAAI,CAACwB,KAAK,CAAC,CAAC;EAC9D;AACF","ignoreList":[]}
|
1
|
+
{"version":3,"names":["DEFAULT_CLASS","BaseComponent","BaseComponentState","isString","Platform","validateField","Injector","BaseInputState","constructor","args","_defineProperty","BaseInputComponent","props","defaultClass","defaultProps","defaultState","focus","_this$widgetRef","widgetRef","blur","_this$widgetRef2","_this$widgetRef3","onPropertyChange","name","$new","$old","keyboardType","type","updateState","textValue","isDefault","state","onFieldChange","bind","onChange","event","updateon","updateDatavalue","target","value","timer","clearTimeout","setTimeout","onChangeText","validate","invokeChange","e","OS","cursor","selectionStart","setState","source","oldValue","datavalue","autotrim","trim","Promise","resolve","hastwowaybinding","setProp","then","invokeEventCallback","proxy","onBlur","FOCUSED_ELEMENT","remove","isTouched","newVal","oldVal","undefined","triggerValidation","isInputFocused","validationObj","isValid","errorType","onFocus","_this$closestTappable","set","closestTappable","triggerTap","onKeyPress"],"sources":["baseinput.component.ts"],"sourcesContent":["import { DEFAULT_CLASS } from '@wavemaker/app-rn-runtime/components/navigation/basenav/basenav.styles';\nimport { BaseComponent, BaseComponentState } from '@wavemaker/app-rn-runtime/core/base.component';\nimport BaseInputProps from './baseinput.props';\nimport { isString } from 'lodash';\nimport { BaseInputStyles } from './baseinput.styles';\nimport { Platform, TextInput } from 'react-native';\nimport { validateField } from '@wavemaker/app-rn-runtime/core/utils';\nimport Injector from '@wavemaker/app-rn-runtime/core/injector';\n\nexport class BaseInputState <T extends BaseInputProps> extends BaseComponentState<T> {\n keyboardType: any = 'default';\n isValid: boolean = true;\n isInputFocused: boolean = false;\n textValue: string = '';\n isDefault = false;\n errorType: string = '';\n}\nexport abstract class BaseInputComponent< T extends BaseInputProps, S extends BaseInputState<T>, L extends BaseInputStyles> extends BaseComponent<T, S, L> {\n public widgetRef: TextInput | null = null;\n isTouched: boolean = false;\n private cursor: any = 0;\n private timer: ReturnType<typeof setTimeout> | null = null;\n constructor(props: T, public defaultClass: string = DEFAULT_CLASS, defaultProps?: T, defaultState?: S) {\n super(props, defaultClass, defaultProps, defaultState);\n }\n\n focus() {\n this?.widgetRef?.focus();\n }\n\n blur() {\n this?.widgetRef?.blur && this?.widgetRef?.blur();\n }\n\n onPropertyChange(name: string, $new: any, $old: any) {\n switch (name) {\n case 'type':\n let keyboardType;\n if (this.props.type === 'number') {\n keyboardType = 'numeric';\n } else if (this.props.type === 'tel') {\n keyboardType = 'phone-pad';\n } else if (this.props.type === 'email') {\n keyboardType = 'email-address';\n }\n this.updateState({\n keyboardType: keyboardType,\n } as S);\n break;\n case 'datavalue':\n this.updateState({\n textValue: $new\n } as S\n );\n const isDefault = this.state.isDefault;\n if (isDefault) {\n this.updateState({ isDefault: false } as S, this.props.onFieldChange && this.props.onFieldChange.bind(this, 'datavalue', $new, $old, isDefault));\n } else {\n this.props.onFieldChange && this.props.onFieldChange('datavalue', $new, $old, isDefault);\n }\n }\n }\n\n onChange(event: any) {\n if (this.state.props.updateon === 'default') {\n this.updateDatavalue(event.target.value, event);\n }else if(this.state.props.updateon === 'lazy') {\n if(this.timer !== null) {\n clearTimeout(this.timer);\n this.timer = null;\n }\n\n this.timer = setTimeout(() => {\n this.updateDatavalue(event.target.value, event);\n }, 300)\n }\n }\n\n onChangeText(value: any) {\n if(this.state.props.updateon === 'lazy') {\n if(this.timer !== null) {\n clearTimeout(this.timer);\n this.timer = null;\n }\n\n this.timer = setTimeout(() => {\n this.updateState({\n textValue: value\n } as S, () => {\n this.validate(value);\n this.updateDatavalue(value, null);\n }\n );\n }, 300)\n }\n else {\n this.updateState({\n textValue: value\n } as S, () => {\n if (this.state.props.updateon === 'default') {\n this.validate(value);\n this.updateDatavalue(value, null);\n }\n }\n );\n }\n }\n\n invokeChange(e: any) {\n if (Platform.OS === 'web') {\n this.cursor = e.target.selectionStart;\n this.setState({ textValue: e.target.value });\n }\n }\n\n updateDatavalue(value: any, event?: any, source?: any) {\n const props = this.state.props;\n const oldValue = props.datavalue;\n if (value === oldValue) {\n return;\n }\n\n // autotrim\n if (props.autotrim && props.datavalue && isString(props.datavalue)) {\n value = value.trim();\n }\n new Promise((resolve) => {\n if (props.hastwowaybinding) {\n this.setProp(\"datavalue\", value);\n this.updateState({props: { \"datavalue\": value }} as S);\n resolve(true);\n } else {\n this.updateState({\n props: {\n datavalue: value\n }\n } as S, () => resolve(true));\n }\n }).then(() => {\n !this.props.onFieldChange && value !== oldValue && this.invokeEventCallback('onChange', [event, this.proxy, value, oldValue]);\n if (source === 'blur') {\n this.invokeEventCallback('onBlur', [ event, this.proxy]);\n }\n })\n }\n\n onBlur(event: any) {\n Injector.FOCUSED_ELEMENT.remove();\n this.isTouched = true;\n let newVal = this.state.textValue || '';\n let oldVal = this.state.props.datavalue || '';\n this.validate(newVal);\n if (newVal === '' || newVal == undefined) {\n setTimeout(() => {\n this.props.triggerValidation && this.props.triggerValidation();\n },10)\n }\n if (this.state.props.updateon === 'blur' || this.state.props.updateon === 'default') {\n if (oldVal !== newVal && this.state.props.updateon === 'blur') {\n this.updateDatavalue(newVal, event, 'blur');\n } else {\n this.invokeEventCallback('onBlur', [event, this.proxy]);\n }\n this.setState({ isInputFocused: false })\n }\n }\n\n validate(value: any) {\n const validationObj = validateField(this.state.props, value);\n this.setState({\n isValid: validationObj.isValid,\n errorType: validationObj.errorType\n } as S);\n }\n\n onFocus(event: any) {\n // When input widgets are inside list widget and try to focus the field, list is selecting but unable to enter values in input fields\n // because on tap event of list is triggering after 200ms timeout So added 250ms timeout here\n setTimeout(() => {\n Injector.FOCUSED_ELEMENT.set(this);\n this.invokeEventCallback('onFocus', [ event, this.proxy]);\n this.closestTappable?.triggerTap();\n }, 250);\n this.setState({ isInputFocused: true })\n }\n\n onKeyPress(event: any) {\n this.invokeEventCallback('onKeypress', [ event, this.proxy]);\n }\n}\n"],"mappings":";;;AAAA,SAASA,aAAa,QAAQ,wEAAwE;AACtG,SAASC,aAAa,EAAEC,kBAAkB,QAAQ,+CAA+C;AAEjG,SAASC,QAAQ,QAAQ,QAAQ;AAEjC,SAASC,QAAQ,QAAmB,cAAc;AAClD,SAASC,aAAa,QAAQ,sCAAsC;AACpE,OAAOC,QAAQ,MAAM,yCAAyC;AAE9D,OAAO,MAAMC,cAAc,SAAoCL,kBAAkB,CAAI;EAAAM,YAAA,GAAAC,IAAA;IAAA,SAAAA,IAAA;IAAAC,eAAA,uBAC/D,SAAS;IAAAA,eAAA,kBACV,IAAI;IAAAA,eAAA,yBACG,KAAK;IAAAA,eAAA,oBACX,EAAE;IAAAA,eAAA,oBACV,KAAK;IAAAA,eAAA,oBACG,EAAE;EAAA;AACxB;AACA,OAAO,MAAeC,kBAAkB,SAA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AC,IAAI,CAAC;MAClC,IAAI,CAAChB,mBAAmB,CAAC,SAAS,EAAE,CAAE1B,KAAK,EAAE,IAAI,CAAC2B,KAAK,CAAC,CAAC;MACzD,CAAAc,qBAAA,OAAI,CAACE,eAAe,cAAAF,qBAAA,eAApBA,qBAAA,CAAsBG,UAAU,CAAC,CAAC;IACpC,CAAC,EAAE,GAAG,CAAC;IACP,IAAI,CAAC7B,QAAQ,CAAC;MAAEqB,cAAc,EAAE;IAAK,CAAC,CAAC;EACzC;EAEAS,UAAUA,CAAC7C,KAAU,EAAE;IACrB,IAAI,CAAC0B,mBAAmB,CAAC,YAAY,EAAE,CAAE1B,KAAK,EAAE,IAAI,CAAC2B,KAAK,CAAC,CAAC;EAC9D;AACF","ignoreList":[]}
|
@@ -10,6 +10,7 @@ export class BaseNumberState extends BaseComponentState {
|
|
10
10
|
constructor(...args) {
|
11
11
|
super(...args);
|
12
12
|
_defineProperty(this, "isValid", true);
|
13
|
+
_defineProperty(this, "isInputFocused", false);
|
13
14
|
_defineProperty(this, "textValue", '');
|
14
15
|
_defineProperty(this, "isDefault", false);
|
15
16
|
_defineProperty(this, "errorType", '');
|
@@ -151,7 +152,7 @@ export class BaseNumberComponent extends BaseComponent {
|
|
151
152
|
if (value === oldValue) {
|
152
153
|
return;
|
153
154
|
}
|
154
|
-
const validNumber = this.isValidNumber(model) || value
|
155
|
+
const validNumber = this.isValidNumber(model) || value === oldValue + '.';
|
155
156
|
if (!validNumber) {
|
156
157
|
this.invokeEventCallback('onError', [event, this.proxy, value, oldValue]);
|
157
158
|
return;
|
@@ -159,6 +160,11 @@ export class BaseNumberComponent extends BaseComponent {
|
|
159
160
|
new Promise(resolve => {
|
160
161
|
if (props.hastwowaybinding) {
|
161
162
|
this.setProp("datavalue", value);
|
163
|
+
setTimeout(() => this.updateState({
|
164
|
+
props: {
|
165
|
+
"datavalue": value
|
166
|
+
}
|
167
|
+
}), 0);
|
162
168
|
resolve(true);
|
163
169
|
} else {
|
164
170
|
this.updateState({
|
@@ -175,24 +181,31 @@ export class BaseNumberComponent extends BaseComponent {
|
|
175
181
|
});
|
176
182
|
}
|
177
183
|
onBlur(event, isDisplayValuePresent) {
|
178
|
-
|
184
|
+
const textVal = this.state.textValue || '';
|
185
|
+
let newVal = isDisplayValuePresent ? textVal : event.target.value || textVal;
|
179
186
|
this.validate(newVal);
|
180
187
|
if (newVal === '' || newVal == undefined) {
|
181
188
|
setTimeout(() => {
|
182
189
|
this.props.triggerValidation && this.props.triggerValidation();
|
183
190
|
}, 10);
|
184
191
|
}
|
185
|
-
if (this.state.props.updateon === 'blur') {
|
192
|
+
if (this.state.props.updateon === 'blur' || this.state.props.updateon === 'default') {
|
186
193
|
let oldVal = this.state.props.datavalue || '';
|
187
|
-
if (oldVal !== newVal) {
|
194
|
+
if (oldVal !== newVal && this.state.props.updateon === 'blur') {
|
188
195
|
this.updateDatavalue(newVal, event, 'blur');
|
189
196
|
} else {
|
190
197
|
this.invokeEventCallback('onBlur', [event, this.proxy]);
|
191
198
|
}
|
199
|
+
this.setState({
|
200
|
+
isInputFocused: false
|
201
|
+
});
|
192
202
|
}
|
193
203
|
}
|
194
204
|
onFocus(event) {
|
195
205
|
this.invokeEventCallback('onFocus', [event, this.proxy]);
|
206
|
+
this.setState({
|
207
|
+
isInputFocused: true
|
208
|
+
});
|
196
209
|
}
|
197
210
|
|
198
211
|
/**
|
@@ -245,13 +258,13 @@ export class BaseNumberComponent extends BaseComponent {
|
|
245
258
|
*/
|
246
259
|
getValueInRange(value) {
|
247
260
|
const props = this.state.props;
|
248
|
-
if (!isNil(value) && !isNaN(props.minvalue) && value < props.minvalue) {
|
261
|
+
if (props.minvalue && !isNil(value) && !isNaN(props.minvalue) && value < props.minvalue) {
|
249
262
|
this.updateState({
|
250
263
|
errorType: 'minvalue'
|
251
264
|
});
|
252
265
|
return props.minvalue;
|
253
266
|
}
|
254
|
-
if (!isNil(value) && !isNaN(props.maxvalue) && value > props.maxvalue) {
|
267
|
+
if (props.maxvalue && !isNil(value) && !isNaN(props.maxvalue) && value > props.maxvalue) {
|
255
268
|
this.updateState({
|
256
269
|
errorType: 'maxvalue'
|
257
270
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["includes","intersection","isNaN","isFinite","toArray","isNil","BaseComponent","BaseComponentState","DEFAULT_CLASS","Platform","countDecimalDigits","validateField","BaseNumberState","constructor","args","_defineProperty","BaseNumberComponent","props","defaultClass","defaultProps","defaultState","DECIMAL","GROUP","onChange","event","state","updateon","updateDatavalue","target","value","focus","_this$widgetRef","widgetRef","validateOnDevice","type","_value$match","isCurrencyField","isValidText","test","Number","match","length","onChangeText","shouldFormateToNumber","newValue","parseNumber","replace","isValidTextOnDevice","decimalPlacesInNumber","decimalPlaces","updateState","textValue","validate","invokeChange","e","OS","cursor","selectionStart","setState","validationObj","isValid","errorType","handleValidation","regexp","condition","RegExp","val","parts","split","NaN","number","join","decimal","sum","parseFloat","toFixed","Object","is","source","model","toString","oldValue","datavalue","validNumber","isValidNumber","invokeEventCallback","proxy","Promise","resolve","hastwowaybinding","setProp","then","onFieldChange","onBlur","isDisplayValuePresent","newVal","undefined","setTimeout","triggerValidation","oldVal","onFocus","countDecimals","decimalValue","validateInputEntry","$event","ctrlKey","key","validity","inputValue","step","preventDefault","getValueInRange","minvalue","maxvalue","required","isInteger","resetValidations","onPropertyChange","name","$new","$old","isDefault","bind","displayValue"],"sources":["basenumber.component.ts"],"sourcesContent":["import { includes, intersection, isNaN, isFinite, toArray, isNil } from 'lodash';\nimport BaseNumberProps from '@wavemaker/app-rn-runtime/components/input/basenumber/basenumber.props';\nimport { BaseComponent, BaseComponentState } from \"@wavemaker/app-rn-runtime/core/base.component\";\nimport { BaseNumberStyles } from '@wavemaker/app-rn-runtime/components/input/basenumber/basenumber.styles';\nimport { DEFAULT_CLASS } from \"@wavemaker/app-rn-runtime/components/navigation/basenav/basenav.styles\";\nimport { Platform, TextInput } from 'react-native';\nimport { countDecimalDigits, validateField } from '@wavemaker/app-rn-runtime/core/utils';\n\nexport class BaseNumberState <T extends BaseNumberProps> extends BaseComponentState<T> {\n isValid: boolean = true;\n textValue: string = '';\n isDefault = false;\n errorType = '';\n}\n\nexport abstract class BaseNumberComponent< T extends BaseNumberProps, S extends BaseNumberState<T>, L extends BaseNumberStyles> extends BaseComponent<T, S, L> {\n private DECIMAL;\n private GROUP;\n public widgetRef: TextInput | null = null;\n private cursor: any = 0;\n constructor(props: T, public defaultClass: string = DEFAULT_CLASS, defaultProps?: T, defaultState?: S) {\n super(props, defaultClass, defaultProps, defaultState);\n this.DECIMAL = '.';\n this.GROUP = ',';\n }\n\n onChange(event: any) {\n if (this.state.props.updateon === 'default') {\n this.updateDatavalue(event.target.value, event);\n }\n }\n\n focus() {\n this?.widgetRef?.focus();\n }\n\n validateOnDevice(value: string, type: 'number' | 'currency') {\n const isCurrencyField = type === 'currency';\n let isValidText = true;\n\n // * no alphabets except E, may contain E only once\n if (/[a-df-zA-DF-Z]/.test(value) || !/^[^eE]*[eE]?[^eE]*$/.test(value)) {\n isValidText = false;\n }\n\n // * currency only: check for negative number\n if (isCurrencyField && (Number(value) < 0 || /-/g.test(value))) {\n isValidText = false;\n }\n\n // * number only: not more than one minus and doesn't end with minus (-)\n if (!isCurrencyField && (Number(value.match(/-/g)?.length) > 1) || /\\w-/.test(value)) {\n isValidText = false;\n }\n\n // * check for more than one decimal point\n if (/^\\d*\\.\\d*\\..*$/.test(value)) {\n isValidText = false;\n }\n\n // * check for spaces and comma\n if (/[\\s,]/.test(value)) {\n isValidText = false;\n }\n\n return isValidText;\n }\n\n onChangeText(value: string, type: 'number' | 'currency', shouldFormateToNumber?: boolean) {\n const newValue = shouldFormateToNumber ? `${this.parseNumber(value.replace(/[^0-9.]/g, ''))}` : value;\n const isValidTextOnDevice = this.validateOnDevice(newValue, type);\n if (!isValidTextOnDevice) {\n return;\n }\n\n const decimalPlacesInNumber = countDecimalDigits(newValue);\n\n if (this.props.decimalPlaces < decimalPlacesInNumber) {\n return;\n }\n\n this.updateState({\n textValue: newValue\n } as S, () => {\n if (this.state.props.updateon === 'default') {\n this.validate(newValue);\n this.updateDatavalue(newValue, null);\n }\n }\n );\n }\n\n invokeChange(e: any) {\n if (Platform.OS === 'web') {\n this.cursor = e.target.selectionStart;\n this.setState({ textValue: e.target.value });\n }\n }\n\n validate(value: any) {\n const validationObj = validateField(this.state.props, value);\n this.updateState({\n isValid: validationObj.isValid,\n errorType: validationObj.errorType\n } as S);\n\n }\n\n handleValidation(value: any) {\n const props = this.state.props;\n if (props.regexp) {\n const condition = new RegExp(props.regexp, 'g');\n return condition.test(value);\n }\n return true;\n }\n\n /**\n * Method parses the Localized number(string) to a valid number.\n * if the string dose not result to a valid number then returns NaN.\n * @param {string} val Localized number.\n * @returns {number}\n */\n private parseNumber(val: string): any {\n // splits string into two parts. decimal and number.\n const parts = val.split(this.DECIMAL);\n if (!parts.length) {\n return;\n }\n if (parts.length > 2) {\n return NaN;\n }\n // If number have decimal point and not have a decimal value then return.\n if (parts[1] === '') {\n return NaN;\n }\n // replaces all group separators form the number.\n const number = Number(parts[0].split(this.GROUP).join(''));\n const decimal = Number(`0.${parts[1] || 0}`);\n if (Number.isNaN(number) || Number.isNaN(decimal)) {\n return NaN;\n }\n const sum = parts.length > 1 ? parseFloat((number + decimal).toFixed(parts[1].length)) : number + decimal;\n // if the number is negative then calculate the number as number - decimal\n // Ex: number = -123 and decimal = 0.45 then number - decimal = -123-045 = -123.45\n // If entered number is -0.1 to -0.9 then the number is -0 and decimal is 0.1 to 0.9. Now calaculate the number as number-decimal\n // Ex: number = -0 and decimal = 0.1 then number-decimal = -0-0.1 = -0.1\n if (number === 0) {\n return Object.is(0, number) ? sum : number - decimal;\n }\n return number > 0 ? sum : number - decimal;\n }\n\n updateDatavalue(value: any, event?: any, source?: any) {\n const model = value && this.parseNumber(value.toString());\n const props = this.state.props;\n const oldValue = props.datavalue;\n if (value === oldValue) {\n return;\n }\n const validNumber = this.isValidNumber(model) || value == oldValue + '.';\n if (!validNumber) {\n this.invokeEventCallback('onError', [ event, this.proxy, value, oldValue ]);\n return;\n }\n\n new Promise((resolve) => {\n if (props.hastwowaybinding) {\n this.setProp(\"datavalue\", value);\n resolve(true);\n } else {\n this.updateState({\n props: {\n datavalue: model || Number(value)\n }\n } as S, () => resolve(true));\n }\n }).then(() => {\n !this.props.onFieldChange && value !== oldValue && this.invokeEventCallback('onChange', [event, this.proxy, model, oldValue]);\n if (source === 'blur') {\n this.invokeEventCallback('onBlur', [event, this.proxy]);\n }\n });\n }\n\n onBlur(event: any, isDisplayValuePresent?: boolean) {\n let newVal = isDisplayValuePresent ? this.state.textValue : event.target.value || this.state.textValue;\n this.validate(newVal);\n if (newVal === '' || newVal == undefined) {\n setTimeout(() => {\n this.props.triggerValidation && this.props.triggerValidation();\n },10)\n }\n if (this.state.props.updateon === 'blur') {\n let oldVal = this.state.props.datavalue || '';\n if (oldVal !== newVal) {\n this.updateDatavalue(newVal, event, 'blur');\n } else {\n this.invokeEventCallback('onBlur', [event, this.proxy]);\n }\n }\n }\n\n onFocus(event: any) {\n this.invokeEventCallback('onFocus', [ event, this.proxy]);\n }\n\n /**\n * returns the number of decimal places a number have.\n * @param value: number\n * @returns {number}\n */\n private countDecimals(value: any) {\n if (value && ((value % 1) !== 0)) {\n const decimalValue = value.toString().split('.')[1];\n return decimalValue && decimalValue.length;\n }\n return 0;\n }\n\n public validateInputEntry($event: any) {\n const props = this.state.props;\n\n // allow actions if control key is pressed or if backspace is pressed. (for Mozilla).\n if ($event.ctrlKey || includes(['Backspace', 'ArrowRight', 'ArrowLeft', 'Tab', 'Enter', 'Delete'], $event.key)) {\n return;\n }\n\n const validity = new RegExp(`^[\\\\d\\\\s-,.e+${this.GROUP}${this.DECIMAL}]$`, 'i');\n const inputValue = $event.target.value;\n // validates entering of decimal values only when user provides decimal limit(i.e step contains decimal values).\n if (inputValue && this.countDecimals(props.step) && (this.countDecimals(inputValue) >= this.countDecimals(props.step))) {\n $event.preventDefault();\n }\n // validates if user entered an invalid character.\n if (!validity.test($event.key)) {\n $event.preventDefault();\n }\n // a decimal value can be entered only once in the input.\n if (includes(inputValue, this.DECIMAL) && $event.key === this.DECIMAL) {\n $event.preventDefault();\n }\n // 'e' can be entered only once in the input.\n if (intersection(toArray(inputValue), ['e', 'E']).length && includes('eE', $event.key)) {\n $event.preventDefault();\n }\n if ((includes(inputValue, '+') || includes(inputValue, '-')) && ($event.key === '+' || $event.key === '-')) {\n $event.preventDefault();\n }\n this.invokeEventCallback('onKeypress', [ $event, this.proxy]);\n }\n\n /**\n * returns a valid number by validating the minimum and maximum values.\n * @param {number} value\n * @returns {number}\n */\n private getValueInRange(value: number): number {\n const props = this.state.props;\n if (!isNil(value) && !isNaN(props.minvalue) && value < props.minvalue) {\n this.updateState({ errorType: 'minvalue'} as S);\n return props.minvalue;\n }\n if (!isNil(value) && !isNaN(props.maxvalue) && value > props.maxvalue) {\n this.updateState({ errorType: 'maxvalue'} as S);\n return props.maxvalue;\n }\n return value;\n }\n\n /**\n * Adds validations for the number before updating the widget model. like validating min and max value for the widget.\n * @param {number} val number to be validated\n * @returns {number}\n */\n private isValidNumber(val: number): boolean {\n const props = this.state.props;\n\n //empty number widget should not show validation error when required is false\n // @ts-ignore\n if (this.state.props.required === false && val === '') {\n return true;\n }\n // id number is infinite then consider it as invalid value\n if (isNaN(val) || !isFinite(val) || (!Number.isInteger(props.step) &&\n this.countDecimals(val) > this.countDecimals(props.step))) {\n this.updateState({\n isValid: false,\n } as S);\n return false;\n }\n if (val !== this.getValueInRange(val)) {\n this.updateState({\n isValid: false,\n } as S);\n return true;\n }\n this.resetValidations();\n return true;\n }\n\n // resets all the flags related to the widget's validation.\n protected resetValidations() {\n this.updateState({\n isValid: true,\n } as S);\n }\n\n onPropertyChange(name: string, $new: any, $old: any) {\n switch (name) {\n case 'minvalue':\n case 'maxvalue':\n if ($new|| $old) {\n this.isValidNumber($new);\n }\n break;\n case 'datavalue':\n this.updateState({\n textValue: $new,\n } as S);\n const isDefault = this.state.isDefault;\n if (isDefault) {\n this.updateState({ isDefault: false } as S, this.props.onFieldChange && this.props.onFieldChange.bind(this, 'datavalue', $new, $old, isDefault));\n } else {\n this.props.onFieldChange && this.props.onFieldChange('datavalue', $new, $old, isDefault);\n }\n break;\n case 'displayValue': \n this.updateState({\n displayValue: $new,\n } as any)\n }\n }\n}\n"],"mappings":";;;AAAA,SAASA,QAAQ,EAAEC,YAAY,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,KAAK,QAAQ,QAAQ;AAEhF,SAASC,aAAa,EAAEC,kBAAkB,QAAQ,+CAA+C;AAEjG,SAASC,aAAa,QAAQ,wEAAwE;AACtG,SAASC,QAAQ,QAAmB,cAAc;AAClD,SAASC,kBAAkB,EAAEC,aAAa,QAAQ,sCAAsC;AAExF,OAAO,MAAMC,eAAe,SAAqCL,kBAAkB,CAAI;EAAAM,YAAA,GAAAC,IAAA;IAAA,SAAAA,IAAA;IAAAC,eAAA,kBAClE,IAAI;IAAAA,eAAA,oBACH,EAAE;IAAAA,eAAA,oBACV,KAAK;IAAAA,eAAA,oBACL,EAAE;EAAA;AAChB;AAEA,OAAO,MAAeC,mBAAmB,SAA+FV,aAAa,CAAU;EAK7JO,WAAWA,CAACI,KAAQ,EAASC,YAAoB,GAAGV,aAAa,EAAEW,YAAgB,EAAEC,YAAgB,EAAE;IACrG,KAAK,CAACH,KAAK,EAAEC,YAAY,EAAEC,YAAY,EAAEC,YAAY,CAAC;IAAC,KAD5BF,YAAoB,GAApBA,YAAoB;IAAAH,eAAA;IAAAA,eAAA;IAAAA,eAAA,oBAFZ,IAAI;IAAAA,eAAA,iBACnB,CAAC;IAGrB,IAAI,CAACM,OAAO,GAAG,GAAG;IAClB,IAAI,CAACC,KAAK,GAAG,GAAG;EAClB;EAEAC,QAAQA,CAACC,KAAU,EAAE;IACnB,IAAI,IAAI,CAACC,KAAK,CAACR,KAAK,CAACS,QAAQ,KAAK,SAAS,EAAE;MAC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MACV,KAAK,UAAU;MACf,KAAK,UAAU;QACb,IAAIC,IAAI,IAAGC,IAAI,EAAE;UACf,IAAI,CAACpC,aAAa,CAACmC,IAAI,CAAC;QAC1B;QACA;MACF,KAAK,WAAW;QACd,IAAI,CAACrE,WAAW,CAAC;UACfC,SAAS,EAAEoE;QACb,CAAM,CAAC;QACP,MAAME,SAAS,GAAG,IAAI,CAAChG,KAAK,CAACgG,SAAS;QACtC,IAAIA,SAAS,EAAE;UACb,IAAI,CAACvE,WAAW,CAAC;YAAEuE,SAAS,EAAE;UAAM,CAAC,EAAO,IAAI,CAACxG,KAAK,CAAC2E,aAAa,IAAI,IAAI,CAAC3E,KAAK,CAAC2E,aAAa,CAAC8B,IAAI,CAAC,IAAI,EAAE,WAAW,EAAEH,IAAI,EAAEC,IAAI,EAAEC,SAAS,CAAC,CAAC;QAClJ,CAAC,MAAM;UACL,IAAI,CAACxG,KAAK,CAAC2E,aAAa,IAAI,IAAI,CAAC3E,KAAK,CAAC2E,aAAa,CAAC,WAAW,EAAE2B,IAAI,EAAEC,IAAI,EAAEC,SAAS,CAAC;QAC1F;QACA;MACF,KAAK,cAAc;QACjB,IAAI,CAACvE,WAAW,CAAC;UACfyE,YAAY,EAAEJ;QAChB,CAAQ,CAAC;IACb;EACF;AACF","ignoreList":[]}
|
1
|
+
{"version":3,"names":["includes","intersection","isNaN","isFinite","toArray","isNil","BaseComponent","BaseComponentState","DEFAULT_CLASS","Platform","countDecimalDigits","validateField","BaseNumberState","constructor","args","_defineProperty","BaseNumberComponent","props","defaultClass","defaultProps","defaultState","DECIMAL","GROUP","onChange","event","state","updateon","updateDatavalue","target","value","focus","_this$widgetRef","widgetRef","validateOnDevice","type","_value$match","isCurrencyField","isValidText","test","Number","match","length","onChangeText","shouldFormateToNumber","newValue","parseNumber","replace","isValidTextOnDevice","decimalPlacesInNumber","decimalPlaces","updateState","textValue","validate","invokeChange","e","OS","cursor","selectionStart","setState","validationObj","isValid","errorType","handleValidation","regexp","condition","RegExp","val","parts","split","NaN","number","join","decimal","sum","parseFloat","toFixed","Object","is","source","model","toString","oldValue","datavalue","validNumber","isValidNumber","invokeEventCallback","proxy","Promise","resolve","hastwowaybinding","setProp","setTimeout","then","onFieldChange","onBlur","isDisplayValuePresent","textVal","newVal","undefined","triggerValidation","oldVal","isInputFocused","onFocus","countDecimals","decimalValue","validateInputEntry","$event","ctrlKey","key","validity","inputValue","step","preventDefault","getValueInRange","minvalue","maxvalue","required","isInteger","resetValidations","onPropertyChange","name","$new","$old","isDefault","bind","displayValue"],"sources":["basenumber.component.ts"],"sourcesContent":["import { includes, intersection, isNaN, isFinite, toArray, isNil } from 'lodash';\nimport BaseNumberProps from '@wavemaker/app-rn-runtime/components/input/basenumber/basenumber.props';\nimport { BaseComponent, BaseComponentState } from \"@wavemaker/app-rn-runtime/core/base.component\";\nimport { BaseNumberStyles } from '@wavemaker/app-rn-runtime/components/input/basenumber/basenumber.styles';\nimport { DEFAULT_CLASS } from \"@wavemaker/app-rn-runtime/components/navigation/basenav/basenav.styles\";\nimport { Platform, TextInput } from 'react-native';\nimport { countDecimalDigits, validateField } from '@wavemaker/app-rn-runtime/core/utils';\n\nexport class BaseNumberState <T extends BaseNumberProps> extends BaseComponentState<T> {\n isValid: boolean = true;\n isInputFocused: boolean = false;\n textValue: string = '';\n isDefault = false;\n errorType = '';\n}\n\nexport abstract class BaseNumberComponent< T extends BaseNumberProps, S extends BaseNumberState<T>, L extends BaseNumberStyles> extends BaseComponent<T, S, L> {\n private DECIMAL;\n private GROUP;\n public widgetRef: TextInput | null = null;\n private cursor: any = 0;\n constructor(props: T, public defaultClass: string = DEFAULT_CLASS, defaultProps?: T, defaultState?: S) {\n super(props, defaultClass, defaultProps, defaultState);\n this.DECIMAL = '.';\n this.GROUP = ',';\n }\n\n onChange(event: any) {\n if (this.state.props.updateon === 'default') {\n this.updateDatavalue(event.target.value, event);\n }\n }\n\n focus() {\n this?.widgetRef?.focus();\n }\n\n validateOnDevice(value: string, type: 'number' | 'currency') {\n const isCurrencyField = type === 'currency';\n let isValidText = true;\n\n // * no alphabets except E, may contain E only once\n if (/[a-df-zA-DF-Z]/.test(value) || !/^[^eE]*[eE]?[^eE]*$/.test(value)) {\n isValidText = false;\n }\n\n // * currency only: check for negative number\n if (isCurrencyField && (Number(value) < 0 || /-/g.test(value))) {\n isValidText = false;\n }\n\n // * number only: not more than one minus and doesn't end with minus (-)\n if (!isCurrencyField && (Number(value.match(/-/g)?.length) > 1) || /\\w-/.test(value)) {\n isValidText = false;\n }\n\n // * check for more than one decimal point\n if (/^\\d*\\.\\d*\\..*$/.test(value)) {\n isValidText = false;\n }\n\n // * check for spaces and comma\n if (/[\\s,]/.test(value)) {\n isValidText = false;\n }\n\n return isValidText;\n }\n\n onChangeText(value: string, type: 'number' | 'currency', shouldFormateToNumber?: boolean) {\n const newValue = shouldFormateToNumber ? `${this.parseNumber(value.replace(/[^0-9.]/g, ''))}` : value;\n const isValidTextOnDevice = this.validateOnDevice(newValue, type);\n if (!isValidTextOnDevice) {\n return;\n }\n\n const decimalPlacesInNumber = countDecimalDigits(newValue);\n\n if (this.props.decimalPlaces < decimalPlacesInNumber) {\n return;\n }\n\n this.updateState({\n textValue: newValue\n } as S, () => {\n if (this.state.props.updateon === 'default') {\n this.validate(newValue);\n this.updateDatavalue(newValue, null);\n }\n }\n );\n }\n\n invokeChange(e: any) {\n if (Platform.OS === 'web') {\n this.cursor = e.target.selectionStart;\n this.setState({ textValue: e.target.value });\n }\n }\n\n validate(value: any) {\n const validationObj = validateField(this.state.props, value);\n this.updateState({\n isValid: validationObj.isValid,\n errorType: validationObj.errorType\n } as S);\n\n }\n\n handleValidation(value: any) {\n const props = this.state.props;\n if (props.regexp) {\n const condition = new RegExp(props.regexp, 'g');\n return condition.test(value);\n }\n return true;\n }\n\n /**\n * Method parses the Localized number(string) to a valid number.\n * if the string dose not result to a valid number then returns NaN.\n * @param {string} val Localized number.\n * @returns {number}\n */\n private parseNumber(val: string): any {\n // splits string into two parts. decimal and number.\n const parts = val.split(this.DECIMAL);\n if (!parts.length) {\n return;\n }\n if (parts.length > 2) {\n return NaN;\n }\n // If number have decimal point and not have a decimal value then return.\n if (parts[1] === '') {\n return NaN;\n }\n // replaces all group separators form the number.\n const number = Number(parts[0].split(this.GROUP).join(''));\n const decimal = Number(`0.${parts[1] || 0}`);\n if (Number.isNaN(number) || Number.isNaN(decimal)) {\n return NaN;\n }\n const sum = parts.length > 1 ? parseFloat((number + decimal).toFixed(parts[1].length)) : number + decimal;\n // if the number is negative then calculate the number as number - decimal\n // Ex: number = -123 and decimal = 0.45 then number - decimal = -123-045 = -123.45\n // If entered number is -0.1 to -0.9 then the number is -0 and decimal is 0.1 to 0.9. Now calaculate the number as number-decimal\n // Ex: number = -0 and decimal = 0.1 then number-decimal = -0-0.1 = -0.1\n if (number === 0) {\n return Object.is(0, number) ? sum : number - decimal;\n }\n return number > 0 ? sum : number - decimal;\n }\n\n updateDatavalue(value: any, event?: any, source?: any) {\n const model = value && this.parseNumber(value.toString());\n const props = this.state.props;\n const oldValue = props.datavalue;\n if (value === oldValue) {\n return;\n }\n const validNumber = this.isValidNumber(model) || value === oldValue + '.';\n if (!validNumber) {\n this.invokeEventCallback('onError', [ event, this.proxy, value, oldValue ]);\n return;\n }\n\n new Promise((resolve) => {\n if (props.hastwowaybinding) {\n this.setProp(\"datavalue\", value);\n setTimeout(()=>this.updateState({props: { \"datavalue\": value }} as S), 0);\n resolve(true);\n } else {\n this.updateState({\n props: {\n datavalue: model || Number(value)\n }\n } as S, () => resolve(true));\n }\n }).then(() => {\n !this.props.onFieldChange && value !== oldValue && this.invokeEventCallback('onChange', [event, this.proxy, model, oldValue]);\n if (source === 'blur') {\n this.invokeEventCallback('onBlur', [event, this.proxy]);\n }\n });\n }\n\n onBlur(event: any, isDisplayValuePresent?: boolean) {\n const textVal = this.state.textValue || '';\n let newVal = isDisplayValuePresent ? textVal : event.target.value || textVal;\n this.validate(newVal);\n if (newVal === '' || newVal == undefined) {\n setTimeout(() => {\n this.props.triggerValidation && this.props.triggerValidation();\n },10)\n }\n if (this.state.props.updateon === 'blur' || this.state.props.updateon === 'default') {\n let oldVal = this.state.props.datavalue || '';\n if (oldVal !== newVal && this.state.props.updateon === 'blur') {\n this.updateDatavalue(newVal, event, 'blur');\n } else {\n this.invokeEventCallback('onBlur', [event, this.proxy]);\n }\n this.setState({ isInputFocused: false});\n }\n }\n\n onFocus(event: any) {\n this.invokeEventCallback('onFocus', [ event, this.proxy]);\n this.setState({ isInputFocused: true});\n }\n\n /**\n * returns the number of decimal places a number have.\n * @param value: number\n * @returns {number}\n */\n private countDecimals(value: any) {\n if (value && ((value % 1) !== 0)) {\n const decimalValue = value.toString().split('.')[1];\n return decimalValue && decimalValue.length;\n }\n return 0;\n }\n\n public validateInputEntry($event: any) {\n const props = this.state.props;\n\n // allow actions if control key is pressed or if backspace is pressed. (for Mozilla).\n if ($event.ctrlKey || includes(['Backspace', 'ArrowRight', 'ArrowLeft', 'Tab', 'Enter', 'Delete'], $event.key)) {\n return;\n }\n\n const validity = new RegExp(`^[\\\\d\\\\s-,.e+${this.GROUP}${this.DECIMAL}]$`, 'i');\n const inputValue = $event.target.value;\n // validates entering of decimal values only when user provides decimal limit(i.e step contains decimal values).\n if (inputValue && this.countDecimals(props.step) && (this.countDecimals(inputValue) >= this.countDecimals(props.step))) {\n $event.preventDefault();\n }\n // validates if user entered an invalid character.\n if (!validity.test($event.key)) {\n $event.preventDefault();\n }\n // a decimal value can be entered only once in the input.\n if (includes(inputValue, this.DECIMAL) && $event.key === this.DECIMAL) {\n $event.preventDefault();\n }\n // 'e' can be entered only once in the input.\n if (intersection(toArray(inputValue), ['e', 'E']).length && includes('eE', $event.key)) {\n $event.preventDefault();\n }\n if ((includes(inputValue, '+') || includes(inputValue, '-')) && ($event.key === '+' || $event.key === '-')) {\n $event.preventDefault();\n }\n this.invokeEventCallback('onKeypress', [ $event, this.proxy]);\n }\n\n /**\n * returns a valid number by validating the minimum and maximum values.\n * @param {number} value\n * @returns {number}\n */\n private getValueInRange(value: number): number {\n const props = this.state.props;\n if (props.minvalue && !isNil(value) && !isNaN(props.minvalue) && value < props.minvalue) {\n this.updateState({ errorType: 'minvalue'} as S);\n return props.minvalue;\n }\n if (props.maxvalue && !isNil(value) && !isNaN(props.maxvalue) && value > props.maxvalue) {\n this.updateState({ errorType: 'maxvalue'} as S);\n return props.maxvalue;\n }\n return value;\n }\n\n /**\n * Adds validations for the number before updating the widget model. like validating min and max value for the widget.\n * @param {number} val number to be validated\n * @returns {number}\n */\n private isValidNumber(val: number): boolean {\n const props = this.state.props;\n\n //empty number widget should not show validation error when required is false\n // @ts-ignore\n if (this.state.props.required === false && val === '') {\n return true;\n }\n // id number is infinite then consider it as invalid value\n if (isNaN(val) || !isFinite(val) || (!Number.isInteger(props.step) &&\n this.countDecimals(val) > this.countDecimals(props.step))) {\n this.updateState({\n isValid: false,\n } as S);\n return false;\n }\n if (val !== this.getValueInRange(val)) {\n this.updateState({\n isValid: false,\n } as S);\n return true;\n }\n this.resetValidations();\n return true;\n }\n\n // resets all the flags related to the widget's validation.\n protected resetValidations() {\n this.updateState({\n isValid: true,\n } as S);\n }\n\n onPropertyChange(name: string, $new: any, $old: any) {\n switch (name) {\n case 'minvalue':\n case 'maxvalue':\n if ($new|| $old) {\n this.isValidNumber($new);\n }\n break;\n case 'datavalue':\n this.updateState({\n textValue: $new,\n } as S);\n const isDefault = this.state.isDefault;\n if (isDefault) {\n this.updateState({ isDefault: false } as S, this.props.onFieldChange && this.props.onFieldChange.bind(this, 'datavalue', $new, $old, isDefault));\n } else {\n this.props.onFieldChange && this.props.onFieldChange('datavalue', $new, $old, isDefault);\n }\n break;\n case 'displayValue': \n this.updateState({\n displayValue: $new,\n } as any)\n }\n }\n}\n"],"mappings":";;;AAAA,SAASA,QAAQ,EAAEC,YAAY,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,KAAK,QAAQ,QAAQ;AAEhF,SAASC,aAAa,E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AI,CAACpE,WAAW,CAAC;MACfU,OAAO,EAAE;IACX,CAAM,CAAC;EACT;EAEA2D,gBAAgBA,CAACC,IAAY,EAAEC,IAAS,EAAEC,IAAS,EAAE;IACnD,QAAQF,IAAI;MACV,KAAK,UAAU;MACf,KAAK,UAAU;QACb,IAAIC,IAAI,IAAGC,IAAI,EAAE;UACf,IAAI,CAACtC,aAAa,CAACqC,IAAI,CAAC;QAC1B;QACA;MACF,KAAK,WAAW;QACd,IAAI,CAACvE,WAAW,CAAC;UACfC,SAAS,EAAEsE;QACb,CAAM,CAAC;QACP,MAAME,SAAS,GAAG,IAAI,CAAClG,KAAK,CAACkG,SAAS;QACtC,IAAIA,SAAS,EAAE;UACb,IAAI,CAACzE,WAAW,CAAC;YAAEyE,SAAS,EAAE;UAAM,CAAC,EAAO,IAAI,CAAC1G,KAAK,CAAC4E,aAAa,IAAI,IAAI,CAAC5E,KAAK,CAAC4E,aAAa,CAAC+B,IAAI,CAAC,IAAI,EAAE,WAAW,EAAEH,IAAI,EAAEC,IAAI,EAAEC,SAAS,CAAC,CAAC;QAClJ,CAAC,MAAM;UACL,IAAI,CAAC1G,KAAK,CAAC4E,aAAa,IAAI,IAAI,CAAC5E,KAAK,CAAC4E,aAAa,CAAC,WAAW,EAAE4B,IAAI,EAAEC,IAAI,EAAEC,SAAS,CAAC;QAC1F;QACA;MACF,KAAK,cAAc;QACjB,IAAI,CAACzE,WAAW,CAAC;UACf2E,YAAY,EAAEJ;QAChB,CAAQ,CAAC;IACb;EACF;AACF","ignoreList":[]}
|
@@ -10,6 +10,7 @@ import { MonthView } from './views/month-view';
|
|
10
10
|
import WmCalendarProps from './calendar.props';
|
11
11
|
import { DEFAULT_CLASS } from './calendar.styles';
|
12
12
|
import WmIcon from '../../basic/icon/icon.component';
|
13
|
+
import { createSkeleton } from '@wavemaker/app-rn-runtime/components/basic/skeleton/skeleton.component';
|
13
14
|
export class WmCalendarState extends BaseComponentState {
|
14
15
|
constructor(...args) {
|
15
16
|
super(...args);
|
@@ -91,6 +92,30 @@ export default class WmCalendar extends BaseComponent {
|
|
91
92
|
super.componentDidUpdate && super.componentDidUpdate(prevProps, prevState, snapshot);
|
92
93
|
this.invokeEventCallback('onViewrender', [this, null]);
|
93
94
|
}
|
95
|
+
renderSkeleton(props) {
|
96
|
+
return /*#__PURE__*/React.createElement(View, {
|
97
|
+
style: [this.styles.root, this.styles.skeleton.root]
|
98
|
+
}, /*#__PURE__*/React.createElement(View, {
|
99
|
+
style: this.styles.headerSkeleton.root
|
100
|
+
}, createSkeleton(this.theme, {}, {
|
101
|
+
width: '10%',
|
102
|
+
height: 28,
|
103
|
+
borderRadius: 4
|
104
|
+
}), createSkeleton(this.theme, {}, {
|
105
|
+
width: '68%',
|
106
|
+
height: 16,
|
107
|
+
borderRadius: 4
|
108
|
+
}), createSkeleton(this.theme, {}, {
|
109
|
+
width: '10%',
|
110
|
+
height: 28,
|
111
|
+
borderRadius: 4
|
112
|
+
})), createSkeleton(this.theme, {}, {
|
113
|
+
width: '96%',
|
114
|
+
margin: 8,
|
115
|
+
height: 320,
|
116
|
+
borderRadius: 4
|
117
|
+
}));
|
118
|
+
}
|
94
119
|
renderWidget(props) {
|
95
120
|
this.invokeEventCallback('onBeforerender', [null, this]);
|
96
121
|
return /*#__PURE__*/React.createElement(View, {
|