react-cron-generator 2.0.13 → 2.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { FunctionComponent } from 'react';
1
+ import { FunctionComponent } from "react";
2
2
  interface MonthlyCronProp {
3
3
  onChange(e?: string[]): void;
4
4
  value: string[];
package/build/index.js CHANGED
@@ -2044,7 +2044,7 @@ var cronstrueI18n = {exports: {}};
2044
2044
  return ", kun i %s";
2045
2045
  };
2046
2046
  da.prototype.commaOnlyOnX0 = function () {
2047
- return ", kun på %s";
2047
+ return ", på %se";
2048
2048
  };
2049
2049
  da.prototype.commaAndOnX0 = function () {
2050
2050
  return ", og på %s";
@@ -8126,15 +8126,18 @@ const MonthlyCron = (props) => {
8126
8126
  const [state, setState] = useState({ hour: 0, minute: 0, every: "" });
8127
8127
  useEffect(() => {
8128
8128
  let every;
8129
- if (props.value[3] === 'L') {
8129
+ if (props.value[3] === "L") {
8130
8130
  every = "2";
8131
8131
  }
8132
- else if (props.value[3] === 'LW') {
8132
+ else if (props.value[3] === "LW") {
8133
8133
  every = "3";
8134
8134
  }
8135
- else if (props.value[3].startsWith('L')) {
8135
+ else if (props.value[3].startsWith("L")) {
8136
8136
  every = "4";
8137
8137
  }
8138
+ else if (props.value[3].includes("!")) {
8139
+ every = "5";
8140
+ }
8138
8141
  else {
8139
8142
  every = "1";
8140
8143
  }
@@ -8144,20 +8147,58 @@ const MonthlyCron = (props) => {
8144
8147
  if (props.disabled) {
8145
8148
  return;
8146
8149
  }
8147
- if (((parseInt(e.target.value) > 0 && parseInt(e.target.value) <= 31)) || e.target.value === "") {
8148
- let val = ['0', props.value[1] === '*' ? '0' : props.value[1], props.value[2] === '*' ? '0' : props.value[2], props.value[3], '1/1', '?', '*'];
8150
+ if ((parseInt(e.target.value) > 0 && parseInt(e.target.value) <= 31) || e.target.value === "") {
8151
+ let val = [
8152
+ "0",
8153
+ props.value[1] === "*" ? "0" : props.value[1],
8154
+ props.value[2] === "*" ? "0" : props.value[2],
8155
+ props.value[3],
8156
+ "1/1",
8157
+ "?",
8158
+ "*",
8159
+ ];
8149
8160
  val[3] = `${e.target.value}`;
8150
8161
  props.onChange(val);
8151
8162
  }
8152
8163
  };
8164
+ const onMultiDayChange = (e) => {
8165
+ if (props.disabled) {
8166
+ return;
8167
+ }
8168
+ if (e.target.value === "" ||
8169
+ e.target.value
8170
+ .split(",")
8171
+ .map((day) => day.trim() ? parseInt(day.trim()) : day)
8172
+ .every((day) => typeof day !== "string" ? (day > 0 && day <= 31) : day === "")) {
8173
+ let val = [
8174
+ "0",
8175
+ props.value[1] === "*" ? "0" : props.value[1],
8176
+ props.value[2] === "*" ? "0" : props.value[2],
8177
+ props.value[3],
8178
+ "1/1",
8179
+ "?",
8180
+ "*",
8181
+ ];
8182
+ val[3] = `${e.target.value.replaceAll(",", "!")}`;
8183
+ props.onChange(val);
8184
+ }
8185
+ };
8153
8186
  const onLastDayChange = (e) => {
8154
8187
  if (props.disabled) {
8155
8188
  return;
8156
8189
  }
8157
- if (((parseInt(e.target.value) >> 0 && parseInt(e.target.value) <= 31)) || e.target.value === "") {
8158
- let val = ['0', props.value[1] === '*' ? '0' : props.value[1], props.value[2] === '*' ? '0' : props.value[2], props.value[3], '1/1', '?', '*'];
8159
- if (e.target.value === '') {
8160
- val[3] = '';
8190
+ if ((parseInt(e.target.value) >> 0 && parseInt(e.target.value) <= 31) || e.target.value === "") {
8191
+ let val = [
8192
+ "0",
8193
+ props.value[1] === "*" ? "0" : props.value[1],
8194
+ props.value[2] === "*" ? "0" : props.value[2],
8195
+ props.value[3],
8196
+ "1/1",
8197
+ "?",
8198
+ "*",
8199
+ ];
8200
+ if (e.target.value === "") {
8201
+ val[3] = "";
8161
8202
  }
8162
8203
  else {
8163
8204
  val[3] = `L-${e.target.value}`;
@@ -8182,15 +8223,77 @@ const MonthlyCron = (props) => {
8182
8223
  props.onChange(val);
8183
8224
  };
8184
8225
  const translateFn = props.translate;
8185
- return (jsxs("div", Object.assign({ className: "tab-pane" }, { children: [jsxs("div", Object.assign({ className: "well well-small" }, { children: [jsx("input", { type: "radio", onChange: (e) => { if (props.disabled) {
8186
- return;
8187
- } setState(Object.assign(Object.assign({}, state), { every: e.target.value })); props.onChange(['0', props.value[1] === '*' ? '0' : props.value[1], props.value[2] === '*' ? '0' : props.value[2], '1', '1/1', '?', '*']); }, value: "1", name: "MonthlyRadio", checked: state.every === "1" ? true : false, disabled: props.disabled }), translateFn('Day'), jsx("input", { readOnly: state.every !== "1", type: "number", value: props.value[3], onChange: onDayChange, disabled: props.disabled }), translateFn('of every month(s)')] })), jsxs("div", Object.assign({ className: "well well-small" }, { children: [jsx("input", { onChange: (e) => { if (props.disabled) {
8188
- return;
8189
- } setState(Object.assign(Object.assign({}, state), { every: e.target.value })); props.onChange(['0', props.value[1] === '*' ? '0' : props.value[1], props.value[2] === '*' ? '0' : props.value[2], 'L', '*', '?', '*']); }, type: "radio", value: "2", name: "DailyRadio", checked: state.every === "2" ? true : false, disabled: props.disabled }), translateFn('Last day of every month')] })), jsxs("div", Object.assign({ className: "well well-small" }, { children: [jsx("input", { onChange: (e) => { if (props.disabled) {
8190
- return;
8191
- } setState(Object.assign(Object.assign({}, state), { every: e.target.value })); props.onChange(['0', props.value[1] === '*' ? '0' : props.value[1], props.value[2] === '*' ? '0' : props.value[2], 'LW', '*', '?', '*']); }, type: "radio", value: "3", name: "DailyRadio", checked: state.every === "3" ? true : false, disabled: props.disabled }), translateFn('On the last weekday of every month')] })), jsxs("div", Object.assign({ className: "well well-small" }, { children: [jsx("input", { type: "radio", onChange: (e) => { if (props.disabled) {
8192
- return;
8193
- } setState(Object.assign(Object.assign({}, state), { every: e.target.value })); props.onChange(['0', props.value[1] === '*' ? '0' : props.value[1], props.value[2] === '*' ? '0' : props.value[2], `L-${1}`, '*', '?', '*']); }, value: "4", name: "MonthlyRadio", checked: state.every === "4" ? true : false, disabled: props.disabled }), jsx("input", { readOnly: state.every !== "4", type: "number", value: props.value[3].split('-').length && props.value[3].split('-')[1] ? props.value[3].split('-')[1] : '', onChange: onLastDayChange, disabled: props.disabled }), translateFn('day(s) before the end of the month')] })), translateFn('Start time'), jsx(HourSelect, { onChange: onAtHourChange, value: props.value[2], disabled: props.disabled }), jsx(MinutesSelect, { onChange: onAtMinuteChange, value: props.value[1], disabled: props.disabled })] })));
8226
+ return (jsxs("div", Object.assign({ className: "tab-pane" }, { children: [jsxs("div", Object.assign({ className: "well well-small" }, { children: [jsx("input", { type: "radio", onChange: (e) => {
8227
+ if (props.disabled) {
8228
+ return;
8229
+ }
8230
+ setState(Object.assign(Object.assign({}, state), { every: e.target.value }));
8231
+ props.onChange([
8232
+ "0",
8233
+ props.value[1] === "*" ? "0" : props.value[1],
8234
+ props.value[2] === "*" ? "0" : props.value[2],
8235
+ "1",
8236
+ "1/1",
8237
+ "?",
8238
+ "*",
8239
+ ]);
8240
+ }, value: "1", name: "MonthlyRadio", checked: state.every === "1" ? true : false, disabled: props.disabled }), translateFn("Day"), jsx("input", { readOnly: state.every !== "1", type: "number", value: props.value[3], onChange: onDayChange, disabled: props.disabled }), translateFn("of every month(s)")] })), jsxs("div", Object.assign({ className: "well well-small" }, { children: [jsx("input", { onChange: (e) => {
8241
+ if (props.disabled) {
8242
+ return;
8243
+ }
8244
+ setState(Object.assign(Object.assign({}, state), { every: e.target.value }));
8245
+ props.onChange([
8246
+ "0",
8247
+ props.value[1] === "*" ? "0" : props.value[1],
8248
+ props.value[2] === "*" ? "0" : props.value[2],
8249
+ "L",
8250
+ "*",
8251
+ "?",
8252
+ "*",
8253
+ ]);
8254
+ }, type: "radio", value: "2", name: "DailyRadio", checked: state.every === "2" ? true : false, disabled: props.disabled }), translateFn("Last day of every month")] })), jsxs("div", Object.assign({ className: "well well-small" }, { children: [jsx("input", { onChange: (e) => {
8255
+ if (props.disabled) {
8256
+ return;
8257
+ }
8258
+ setState(Object.assign(Object.assign({}, state), { every: e.target.value }));
8259
+ props.onChange([
8260
+ "0",
8261
+ props.value[1] === "*" ? "0" : props.value[1],
8262
+ props.value[2] === "*" ? "0" : props.value[2],
8263
+ "LW",
8264
+ "*",
8265
+ "?",
8266
+ "*",
8267
+ ]);
8268
+ }, type: "radio", value: "3", name: "DailyRadio", checked: state.every === "3" ? true : false, disabled: props.disabled }), translateFn("On the last weekday of every month")] })), jsxs("div", Object.assign({ className: "well well-small" }, { children: [jsx("input", { type: "radio", onChange: (e) => {
8269
+ if (props.disabled) {
8270
+ return;
8271
+ }
8272
+ setState(Object.assign(Object.assign({}, state), { every: e.target.value }));
8273
+ props.onChange([
8274
+ "0",
8275
+ props.value[1] === "*" ? "0" : props.value[1],
8276
+ props.value[2] === "*" ? "0" : props.value[2],
8277
+ `L-${1}`,
8278
+ "*",
8279
+ "?",
8280
+ "*",
8281
+ ]);
8282
+ }, value: "4", name: "MonthlyRadio", checked: state.every === "4" ? true : false, disabled: props.disabled }), jsx("input", { readOnly: state.every !== "4", type: "number", value: props.value[3].split("-").length && props.value[3].split("-")[1] ? props.value[3].split("-")[1] : "", onChange: onLastDayChange, disabled: props.disabled }), translateFn("day(s) before the end of the month")] })), jsxs("div", Object.assign({ className: "well well-small" }, { children: [jsx("input", { type: "radio", onChange: (e) => {
8283
+ if (props.disabled) {
8284
+ return;
8285
+ }
8286
+ setState(Object.assign(Object.assign({}, state), { every: e.target.value }));
8287
+ props.onChange([
8288
+ "0",
8289
+ props.value[1] === "*" ? "0" : props.value[1],
8290
+ props.value[2] === "*" ? "0" : props.value[2],
8291
+ "1",
8292
+ "1/1",
8293
+ "?",
8294
+ "*",
8295
+ ]);
8296
+ }, value: "5", name: "MonthlyMultipleRadio", checked: state.every === "5" ? true : false, disabled: props.disabled }), jsx("input", { readOnly: state.every !== "5", type: "text", value: state.every === "5" ? props.value[3].replaceAll("!", ",") : "", onChange: onMultiDayChange, disabled: props.disabled }), translateFn("Days of every month (coma separated dates)")] })), translateFn("Start time"), jsx(HourSelect, { onChange: onAtHourChange, value: props.value[2], disabled: props.disabled }), jsx(MinutesSelect, { onChange: onAtMinuteChange, value: props.value[1], disabled: props.disabled })] })));
8194
8297
  };
8195
8298
 
8196
8299
  const CustomCron = (props) => {
@@ -8282,6 +8385,54 @@ const loadHeaders = (options) => {
8282
8385
  return defaultTabs;
8283
8386
  };
8284
8387
 
8388
+ var Every = "Every";
8389
+ var hour = "hour";
8390
+ var At = "At";
8391
+ var Day = "Day";
8392
+ var Monday = "Monday";
8393
+ var Tuesday = "Tuesday";
8394
+ var Wednesday = "Wednesday";
8395
+ var Thursday = "Thursday";
8396
+ var Friday = "Friday";
8397
+ var Saturday = "Saturday";
8398
+ var Sunday = "Sunday";
8399
+ var Minutes = "Minutes";
8400
+ var Hourly = "Hourly";
8401
+ var Daily = "Daily";
8402
+ var Weekly = "Weekly";
8403
+ var Monthly = "Monthly";
8404
+ var Custom = "Custom";
8405
+ var Expression = "Expression";
8406
+ var translations = {
8407
+ Every: Every,
8408
+ "day(s)": "day(s)",
8409
+ "Every week day": "Every week day",
8410
+ "Start time": "Start time",
8411
+ hour: hour,
8412
+ At: At,
8413
+ "minute(s)": "minute(s)",
8414
+ Day: Day,
8415
+ "of every month(s)": "of every month(s)",
8416
+ "Last day of every month": "Last day of every month",
8417
+ "On the last weekday of every month": "On the last weekday of every month",
8418
+ "day(s) before the end of the month": "Day(s) before the end of the month",
8419
+ Monday: Monday,
8420
+ Tuesday: Tuesday,
8421
+ Wednesday: Wednesday,
8422
+ Thursday: Thursday,
8423
+ Friday: Friday,
8424
+ Saturday: Saturday,
8425
+ Sunday: Sunday,
8426
+ Minutes: Minutes,
8427
+ Hourly: Hourly,
8428
+ Daily: Daily,
8429
+ Weekly: Weekly,
8430
+ Monthly: Monthly,
8431
+ Custom: Custom,
8432
+ Expression: Expression,
8433
+ "Days of every month (coma separated dates)": "Days of every month (coma separated dates)"
8434
+ };
8435
+
8285
8436
  function styleInject(css, ref) {
8286
8437
  if ( ref === void 0 ) ref = {};
8287
8438
  var insertAt = ref.insertAt;
@@ -8428,6 +8579,9 @@ const Cron = (props) => {
8428
8579
  throw new Error('translateFn expects a string translation');
8429
8580
  }
8430
8581
  }
8582
+ else if (translations[translatedText]) {
8583
+ return translations[translatedText];
8584
+ }
8431
8585
  return translatedText;
8432
8586
  };
8433
8587
  return (jsxs("div", Object.assign({ className: 'cron_builder' }, { children: [jsx("ul", Object.assign({ className: "nav nav-tabs" }, { children: getHeaders() })), jsx("div", Object.assign({ className: "cron_builder_bordering" }, { children: state.selectedTab ? getComponent(state.selectedTab) : "Select a header" })), props.showResultText && jsx("div", Object.assign({ className: "cron-builder-bg" }, { children: getVal() })), props.showResultCron && jsx("div", Object.assign({ className: "cron-builder-bg" }, { children: state.value.toString().replace(/,/g, ' ').replace(/!/g, ',') }))] })));