react-cron-generator 2.1.0 → 2.1.2

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 +1 @@
1
- {"version":3,"file":"cron.d.ts","sourceRoot":"","sources":["../src/lib/cron.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4D,MAAM,OAAO,CAAC;AAEjF,OAAO,EAAyB,aAAa,EAAiB,MAAM,QAAQ,CAAC;AAI7E,OAAO,oBAAoB,CAAC;AAE5B,MAAM,WAAW,QAAQ;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1C,cAAc,EAAE,OAAO,CAAC;IACxB,cAAc,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE;QAAE,OAAO,EAAE,aAAa,EAAE,CAAA;KAAE,CAAC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAeD,QAAA,MAAM,IAAI,EAAE,KAAK,CAAC,iBAAiB,CAAC,QAAQ,CAoX3C,CAAC;AAEF,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"cron.d.ts","sourceRoot":"","sources":["../src/lib/cron.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4D,MAAM,OAAO,CAAC;AAEjF,OAAO,EAAyB,aAAa,EAAiB,MAAM,QAAQ,CAAC;AAI7E,OAAO,oBAAoB,CAAC;AAE5B,MAAM,WAAW,QAAQ;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1C,cAAc,EAAE,OAAO,CAAC;IACxB,cAAc,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE;QAAE,OAAO,EAAE,aAAa,EAAE,CAAA;KAAE,CAAC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAeD,QAAA,MAAM,IAAI,EAAE,KAAK,CAAC,iBAAiB,CAAC,QAAQ,CA8X3C,CAAC;AAEF,eAAe,IAAI,CAAC"}
package/build/index.js CHANGED
@@ -9173,17 +9173,26 @@ const Cron = (props) => {
9173
9173
  let processedValue = value;
9174
9174
  // Convert Unix to Quartz if needed for internal representation
9175
9175
  if (props.isUnix && value) {
9176
- const parts = value.split(' ');
9177
- if (parts.length === 5) {
9176
+ if (value.split(' ').length === 5) {
9178
9177
  try {
9179
9178
  processedValue = unixToQuartz(value);
9180
9179
  }
9181
9180
  catch (e) {
9182
- console.error('Error converting Unix to Quartz:', e);
9181
+ console.error('Error: converting Unix to Quartz:', e);
9183
9182
  processedValue = defaultCron;
9184
9183
  }
9185
9184
  }
9186
9185
  }
9186
+ if (!props.isUnix && value && value.split(' ').length === 5) {
9187
+ try {
9188
+ console.error('Warning: Unix value found,Converting to Quartz');
9189
+ processedValue = unixToQuartz(value);
9190
+ }
9191
+ catch (e) {
9192
+ console.error('Error: converting Unix to Quartz:', e);
9193
+ processedValue = defaultCron;
9194
+ }
9195
+ }
9187
9196
  let valueArray = processedValue.replace(/,/g, '!').split(' ');
9188
9197
  // Handle 6-field cron (add year field for internal processing)
9189
9198
  if (processedValue && processedValue.split(' ').length === 6) {
@@ -9257,7 +9266,8 @@ const Cron = (props) => {
9257
9266
  * Sync with external value prop
9258
9267
  */
9259
9268
  useEffect(() => {
9260
- const compareVal = convertToOutputFormat(stateRef.current.value);
9269
+ const hasValidState = stateRef.current.value && stateRef.current.value.length > 0;
9270
+ const compareVal = hasValidState ? convertToOutputFormat(stateRef.current.value) : '';
9261
9271
  if (props.value !== compareVal) {
9262
9272
  setValue(props.value ? props.value : '');
9263
9273
  }
@@ -9265,9 +9275,6 @@ const Cron = (props) => {
9265
9275
  console.warn('Warning !!! locale not set while using translateFn');
9266
9276
  }
9267
9277
  }, [props.value, props.translateFn, props.locale, setValue, convertToOutputFormat]);
9268
- /**
9269
- * Handle isUnix prop changes - notify parent with converted format
9270
- */
9271
9278
  /**
9272
9279
  * Handle isUnix prop changes - notify parent with converted format
9273
9280
  */
@@ -9316,6 +9323,10 @@ const Cron = (props) => {
9316
9323
  * Get display value for result cron (uses single source of truth)
9317
9324
  */
9318
9325
  const displayCron = useMemo(() => {
9326
+ // Only convert if we have a valid state with actual values
9327
+ if (!state.value || state.value.length === 0) {
9328
+ return '';
9329
+ }
9319
9330
  return convertToOutputFormat(state.value, props.isUnix);
9320
9331
  }, [state.value, props.isUnix, convertToOutputFormat]);
9321
9332
  return (jsxs("div", Object.assign({ className: "cron_builder" }, { children: [jsx("ul", Object.assign({ className: "nav nav-tabs", role: "tablist" }, { children: headers })), jsx("div", Object.assign({ className: "cron_builder_bordering", role: "tabpanel" }, { children: state.selectedTab ? getComponent(state.selectedTab) : 'Select a header' })), props.showResultText && (jsx("div", Object.assign({ className: "cron-builder-bg", "aria-label": "Cron description" }, { children: getVal(displayCron) }))), props.showResultCron && (jsx("div", Object.assign({ className: "cron-builder-bg", "aria-label": "Cron expression" }, { children: displayCron })))] })));