react-cron-generator
Advanced tools
Comparing version 1.1.9 to 1.2.0
@@ -79,2 +79,3 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; | ||
var translateFn = this.props.translate; | ||
this.state.value = this.props.value; | ||
@@ -97,3 +98,3 @@ return /*#__PURE__*/React.createElement("div", { | ||
checked: this.state.every | ||
}), /*#__PURE__*/React.createElement("span", null, "Every"), /*#__PURE__*/React.createElement("input", { | ||
}), /*#__PURE__*/React.createElement("span", null, translateFn('Every')), /*#__PURE__*/React.createElement("input", { | ||
disabled: !this.state.every, | ||
@@ -104,3 +105,3 @@ type: "Number", | ||
value: this.state.value[3].split('/')[1] ? this.state.value[3].split('/')[1] : '' | ||
}), /*#__PURE__*/React.createElement("span", null, "day(s)")), /*#__PURE__*/React.createElement("div", { | ||
}), /*#__PURE__*/React.createElement("span", null, translateFn('day(s)'))), /*#__PURE__*/React.createElement("div", { | ||
className: "well well-small" | ||
@@ -119,3 +120,3 @@ }, /*#__PURE__*/React.createElement("input", { | ||
checked: !this.state.every | ||
}), /*#__PURE__*/React.createElement("span", null, "Every week day")), /*#__PURE__*/React.createElement("span", null, "Start time"), /*#__PURE__*/React.createElement(Hour, { | ||
}), /*#__PURE__*/React.createElement("span", null, translateFn('Every week day'))), /*#__PURE__*/React.createElement("span", null, translateFn('Start time')), /*#__PURE__*/React.createElement(Hour, { | ||
onChange: this.onAtHourChange, | ||
@@ -122,0 +123,0 @@ value: this.state.value[2] |
@@ -68,2 +68,3 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; | ||
var translateFn = this.props.translate; | ||
this.state.value = this.props.value; | ||
@@ -86,3 +87,3 @@ return /*#__PURE__*/React.createElement("div", { | ||
checked: this.state.every | ||
}), /*#__PURE__*/React.createElement("span", null, "Every "), /*#__PURE__*/React.createElement("input", { | ||
}), /*#__PURE__*/React.createElement("span", null, translateFn('Every'), " "), /*#__PURE__*/React.createElement("input", { | ||
disabled: !this.state.every, | ||
@@ -92,3 +93,3 @@ type: "Number", | ||
value: this.state.value[2].split('/')[1] ? this.state.value[2].split('/')[1] : '' | ||
}), /*#__PURE__*/React.createElement("span", null, "hour(s)")), /*#__PURE__*/React.createElement("div", { | ||
}), /*#__PURE__*/React.createElement("span", null, translateFn('hour(s)'))), /*#__PURE__*/React.createElement("div", { | ||
className: "well df well-small margin-right-0 margin-left-0" | ||
@@ -109,3 +110,3 @@ }, /*#__PURE__*/React.createElement("div", { | ||
className: "margin-right-10 " | ||
}, "At"), /*#__PURE__*/React.createElement(Hour, { | ||
}, translateFn('At')), /*#__PURE__*/React.createElement(Hour, { | ||
disabled: this.state.every, | ||
@@ -112,0 +113,0 @@ onChange: this.onAtHourChange, |
@@ -12,10 +12,6 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; | ||
function MinutesCron(props) { | ||
var _this; | ||
function MinutesCron() { | ||
_classCallCheck(this, MinutesCron); | ||
_this = _super.call(this, props); | ||
_this.state = {}; | ||
return _this; | ||
return _super.apply(this, arguments); | ||
} | ||
@@ -35,12 +31,18 @@ | ||
value: function render() { | ||
this.state.value = this.props.value; | ||
var translateFn = this.props.translate; | ||
var value = this.props.value; | ||
if (value && value.length > 1) { | ||
value = value[1].split('/')[1]; | ||
} | ||
return /*#__PURE__*/React.createElement("div", { | ||
className: "well" | ||
}, "Every ", /*#__PURE__*/React.createElement("input", { | ||
}, translateFn('Every'), " ", /*#__PURE__*/React.createElement("input", { | ||
type: "Number", | ||
onChange: this.onChange.bind(this), | ||
value: this.state.value[1].split('/')[1], | ||
value: value, | ||
min: 1, | ||
max: 60 | ||
}), " minute(s)"); | ||
}), " ", translateFn('minute(s)')); | ||
} | ||
@@ -47,0 +49,0 @@ }]); |
@@ -52,3 +52,3 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; | ||
value: function onDayChange(e) { | ||
if (parseInt(e.target.value) > 0 && parseInt(e.target.value) <= 31 || e.target.value == "") { | ||
if (parseInt(e.target.value) > 0 && parseInt(e.target.value) <= 31 || e.target.value === "") { | ||
var val = ['0', this.state.value[1] === '*' ? '0' : this.state.value[1], this.state.value[2] === '*' ? '0' : this.state.value[2], this.state.value[3], '1/1', '?', '*']; | ||
@@ -62,6 +62,6 @@ val[3] = "".concat(e.target.value); | ||
value: function onLastDayChange(e) { | ||
if (parseInt(e.target.value) >> 0 && parseInt(e.target.value) <= 31 || e.target.value == "") { | ||
if (parseInt(e.target.value) >> 0 && parseInt(e.target.value) <= 31 || e.target.value === "") { | ||
var val = ['0', this.state.value[1] === '*' ? '0' : this.state.value[1], this.state.value[2] === '*' ? '0' : this.state.value[2], this.state.value[3], '1/1', '?', '*']; | ||
if (e.target.value == '') { | ||
if (e.target.value === '') { | ||
val[3] = ''; | ||
@@ -94,2 +94,3 @@ } else { | ||
var translateFn = this.props.translate; | ||
this.state.value = this.props.value; | ||
@@ -112,3 +113,3 @@ return /*#__PURE__*/React.createElement("div", { | ||
checked: this.state.every === "1" ? true : false | ||
}), "Day", /*#__PURE__*/React.createElement("input", { | ||
}), translateFn('Day'), /*#__PURE__*/React.createElement("input", { | ||
readOnly: this.state.every !== "1", | ||
@@ -118,3 +119,3 @@ type: "number", | ||
onChange: this.onDayChange | ||
}), "of every month(s)"), /*#__PURE__*/React.createElement("div", { | ||
}), translateFn('of every month(s)')), /*#__PURE__*/React.createElement("div", { | ||
className: "well well-small" | ||
@@ -133,3 +134,3 @@ }, /*#__PURE__*/React.createElement("input", { | ||
checked: this.state.every === "2" ? true : false | ||
}), "Last day of every month"), /*#__PURE__*/React.createElement("div", { | ||
}), translateFn('Last day of every month')), /*#__PURE__*/React.createElement("div", { | ||
className: "well well-small" | ||
@@ -148,3 +149,3 @@ }, /*#__PURE__*/React.createElement("input", { | ||
checked: this.state.every === "3" ? true : false | ||
}), "On the last weekday of every month"), /*#__PURE__*/React.createElement("div", { | ||
}), translateFn('On the last weekday of every month')), /*#__PURE__*/React.createElement("div", { | ||
className: "well well-small" | ||
@@ -168,3 +169,3 @@ }, /*#__PURE__*/React.createElement("input", { | ||
onChange: this.onLastDayChange | ||
}), "day(s) before the end of the month"), "Start time", /*#__PURE__*/React.createElement(Hour, { | ||
}), translateFn('day(s) before the end of the month')), translateFn('Start time'), /*#__PURE__*/React.createElement(Hour, { | ||
onChange: this.onAtHourChange, | ||
@@ -171,0 +172,0 @@ value: this.state.value[2] |
@@ -86,2 +86,3 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; | ||
value: function render() { | ||
var translateFn = this.props.translate; | ||
this.state.value = this.props.value; | ||
@@ -101,3 +102,3 @@ return /*#__PURE__*/React.createElement("div", { | ||
checked: this.state.value[5].search('MON') !== -1 ? true : false | ||
}), "Monday", /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("input", { | ||
}), translateFn('Monday'), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("input", { | ||
type: "checkbox", | ||
@@ -107,3 +108,3 @@ value: "WED", | ||
checked: this.state.value[5].search('WED') !== -1 ? true : false | ||
}), "Wednesday", /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("input", { | ||
}), translateFn('Wednesday'), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("input", { | ||
type: "checkbox", | ||
@@ -113,3 +114,3 @@ value: "FRI", | ||
checked: this.state.value[5].search('FRI') !== -1 ? true : false | ||
}), "Friday", /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("input", { | ||
}), translateFn('Friday'), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("input", { | ||
type: "checkbox", | ||
@@ -119,3 +120,3 @@ value: "SUN", | ||
checked: this.state.value[5].search('SUN') !== -1 ? true : false | ||
}), "Sunday")), /*#__PURE__*/React.createElement("div", { | ||
}), translateFn('Sunday'))), /*#__PURE__*/React.createElement("div", { | ||
className: "span6 col-sm-6" | ||
@@ -129,3 +130,3 @@ }, /*#__PURE__*/React.createElement("div", { | ||
checked: this.state.value[5].search('TUE') !== -1 ? true : false | ||
}), "Tuesday", /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("input", { | ||
}), translateFn('Tuesday'), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("input", { | ||
type: "checkbox", | ||
@@ -135,3 +136,3 @@ value: "THU", | ||
checked: this.state.value[5].search('THU') !== -1 ? true : false | ||
}), "Thursday", /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("input", { | ||
}), translateFn('Thursday'), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("input", { | ||
type: "checkbox", | ||
@@ -141,3 +142,3 @@ value: "SAT", | ||
checked: this.state.value[5].search('SAT') !== -1 ? true : false | ||
}), "Saturday"), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("br", null))), "Start time", /*#__PURE__*/React.createElement(Hour, { | ||
}), translateFn('Saturday')), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("br", null))), translateFn('Start time'), /*#__PURE__*/React.createElement(Hour, { | ||
onChange: this.onAtHourChange, | ||
@@ -144,0 +145,0 @@ value: this.state.value[2] |
@@ -148,2 +148,3 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; | ||
return /*#__PURE__*/React.createElement(CronComponent, { | ||
translate: this.translate.bind(this), | ||
value: this.state.value, | ||
@@ -154,2 +155,17 @@ onChange: this.onValueChange.bind(this) | ||
}, { | ||
key: "translate", | ||
value: function translate(key) { | ||
var translatedText = key; | ||
if (this.props.translateFn) { | ||
translatedText = this.props.translateFn(key); | ||
if (typeof translatedText !== 'string') { | ||
throw new Error('translateFn expects a string translation'); | ||
} | ||
} | ||
return translatedText; | ||
} | ||
}, { | ||
key: "render", | ||
@@ -156,0 +172,0 @@ value: function render() { |
@@ -0,0 +0,0 @@ import Minutes from '../cron-tab/minutes'; |
@@ -0,0 +0,0 @@ MIT License |
{ | ||
"name": "react-cron-generator", | ||
"version": "1.1.9", | ||
"version": "1.2.0", | ||
"description": "Simple react component to generate cron expression", | ||
@@ -48,3 +48,3 @@ "keywords": [ | ||
"start": "react-scripts start", | ||
"build": " NODE_ENV=production babel src/lib --out-dir dist --copy-files --ignore __tests__,spec.js,test.js,__snapshots__", | ||
"build": "rm -rf dist && NODE_ENV=production babel src/lib --out-dir dist --copy-files --ignore __tests__,spec.js,test.js,__snapshots__", | ||
"test": "react-scripts test", | ||
@@ -51,0 +51,0 @@ "eject": "react-scripts eject", |
@@ -64,4 +64,9 @@ # react-cron-generator | ||
| showResultCron | show cron expression | false | No | ||
| translateFn | translate function callback | method | No | ||
| options | Options for Cron component, *Must pass a valid cron value for available headers | All available headers | No | ||
**translateFn** | ||
Expects a method. Use this prop for localization support. `react-cron-generator` will call this method for every key. List of keys are available here (https://github.com/sojinantony01/react-cron-generator/tree/master/src/lib/localization/translation.json) | ||
## Options | ||
@@ -86,2 +91,2 @@ | ||
[Viswanath Lekshmanan](https://github.com/ViswanathLekshmanan) | ||
[Viswanath Lekshmanan](https://viswanathl.in/) |
Sorry, the diff of this file is not supported yet
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
39993
16
958
91