@gravitee/ui-particles-angular 16.4.0 → 16.4.1

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.
@@ -4753,10 +4753,41 @@ const toCronExpression = (cronDisplay) => {
4753
4753
  const toCronDescription = (cronExpression) => {
4754
4754
  throwIfInvalid(cronExpression);
4755
4755
  if (!isEmpty(cronExpression)) {
4756
- return Cronstrue.toString(cronExpression);
4756
+ return Cronstrue.toString(expandMisleadingSteps(cronExpression));
4757
4757
  }
4758
4758
  return '';
4759
4759
  };
4760
+ /**
4761
+ * Expand step values (like *\/50) that don't evenly divide the field range
4762
+ * into explicit value lists (like 0,50) so that cronstrue generates an accurate description.
4763
+ *
4764
+ * For example, *\/50 in the minutes field means "at every minute divisible by 50" (i.e. 0 and 50),
4765
+ * NOT "every 50 minutes". Without this fix, cronstrue would display "Every 50 minutes" which is misleading.
4766
+ *
4767
+ * See: https://github.com/bradymholt/cRonstrue/issues/360
4768
+ */
4769
+ const expandMisleadingSteps = (cronExpression) => {
4770
+ const parts = cronExpression.trim().split(/\s+/);
4771
+ // Field ranges: [seconds, minutes, hours, day-of-month, month, day-of-week]
4772
+ const fieldRanges = [60, 60, 24, undefined, undefined, undefined];
4773
+ const expandedParts = parts.map((part, index) => {
4774
+ const range = fieldRanges[index];
4775
+ if (range === undefined)
4776
+ return part;
4777
+ const match = part.match(/^\*\/(\d+)$/);
4778
+ if (!match)
4779
+ return part;
4780
+ const step = parseInt(match[1], 10);
4781
+ if (step <= 0 || range % step === 0)
4782
+ return part;
4783
+ const values = [];
4784
+ for (let v = 0; v < range; v += step) {
4785
+ values.push(v);
4786
+ }
4787
+ return values.join(',');
4788
+ });
4789
+ return expandedParts.join(' ');
4790
+ };
4760
4791
  /**
4761
4792
  * Simple validation to ensure that the cron expression has 6 parts.
4762
4793
  * Note : The full cron expression validation is done by the backend.