react-cron-generator
Advanced tools
Comparing version 1.2.2 to 1.2.3
@@ -33,29 +33,43 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; | ||
value: function componentWillMount() { | ||
if (!this.props.value || this.props.value.split(' ').length !== 7) { | ||
this.state.value = ['0', '0', '00', '1/1', '*', '?', '*']; | ||
this.state.selectedTab = this.state.headers[0]; | ||
this.parentChange(this.state.value); | ||
this.setValue(this.props.value); | ||
if (this.props.translateFn && !this.props.locale) { | ||
console.log('Warning !!! locale not set while using translateFn'); | ||
} | ||
if (this.props.onRef) { | ||
this.props.onRef(this); | ||
} | ||
} | ||
}, { | ||
key: "setValue", | ||
value: function setValue(value) { | ||
var prevState = this.state; | ||
if (!value || value.split(' ').length !== 7) { | ||
prevState.value = ['0', '0', '00', '1/1', '*', '?', '*']; | ||
prevState.selectedTab = prevState.headers[0]; | ||
this.parentChange(prevState.value); | ||
} else { | ||
this.state.value = this.props.value.replace(/,/g, '!').split(' '); | ||
prevState.value = value.replace(/,/g, '!').split(' '); | ||
} | ||
var val = this.state.value; | ||
var val = prevState.value; | ||
if (val[1].search('/') !== -1 && val[2] === '*' && val[3] === '1/1') { | ||
this.state.selectedTab = this.state.headers[0]; | ||
prevState.selectedTab = prevState.headers[0]; | ||
} else if (val[3] === '1/1') { | ||
this.state.selectedTab = this.state.headers[1]; | ||
prevState.selectedTab = prevState.headers[1]; | ||
} else if (val[3].search('/') !== -1 || val[5] === 'MON-FRI') { | ||
this.state.selectedTab = this.state.headers[2]; | ||
prevState.selectedTab = prevState.headers[2]; | ||
} else if (val[3] === '?') { | ||
this.state.selectedTab = this.state.headers[3]; | ||
prevState.selectedTab = prevState.headers[3]; | ||
} else if (val[3].startsWith('L') || val[4] === '1/1') { | ||
this.state.selectedTab = this.state.headers[4]; | ||
prevState.selectedTab = prevState.headers[4]; | ||
} else { | ||
this.state.selectedTab = this.state.headers[0]; | ||
prevState.selectedTab = prevState.headers[0]; | ||
} | ||
if (this.props.translateFn && !this.props.locale) { | ||
console.log('Warning !!! locale not set while using translateFn'); | ||
} | ||
this.parentChange(prevState.value); | ||
this.setState(prevState); | ||
} | ||
@@ -62,0 +76,0 @@ }, { |
{ | ||
"name": "react-cron-generator", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"description": "Simple react component to generate cron expression", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -87,2 +87,17 @@ # react-cron-generator | ||
Added `ref` to the component now you can access state and functions using ref. You can change cron value from outside the component even after cron generator loaded, | ||
add the new prop ` onRef={ref => (this.cronGen = ref)} ` | ||
``` | ||
<Cron | ||
onRef={ref => (this.cronGen = ref)} | ||
onChange={(e)=> {this.setState({value:e}); console.log(e)}} | ||
value={this.state.value} | ||
showResultText={true} | ||
showResultCron={true} | ||
/> | ||
``` | ||
Just call this.cronGen.setValue(/* Your new value */) to change the value when you need | ||
[Sojin Antony](https://github.com/sojinantony01) | ||
@@ -89,0 +104,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41385
980
109