@djangocfg/ui-tools 2.1.390 → 2.1.394

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.
Files changed (184) hide show
  1. package/README.md +7 -10
  2. package/dist/chunk-PAWJFY3S.mjs +6 -0
  3. package/dist/{chunk-N2XQF2OL.mjs.map → chunk-PAWJFY3S.mjs.map} +1 -1
  4. package/dist/chunk-PK6SKIKE.cjs +8 -0
  5. package/dist/{chunk-OLISEQHS.cjs.map → chunk-PK6SKIKE.cjs.map} +1 -1
  6. package/dist/file-icon/index.cjs +6 -6
  7. package/dist/file-icon/index.d.cts +1 -1
  8. package/dist/file-icon/index.d.ts +1 -1
  9. package/dist/file-icon/index.mjs +1 -1
  10. package/dist/tree/index.cjs +1372 -143
  11. package/dist/tree/index.cjs.map +1 -1
  12. package/dist/tree/index.d.cts +2 -2
  13. package/dist/tree/index.d.ts +2 -2
  14. package/dist/tree/index.mjs +1322 -3
  15. package/dist/tree/index.mjs.map +1 -1
  16. package/dist/{types-CevSbyfD.d.cts → types-B_zhyAqR.d.cts} +1 -1
  17. package/dist/{types-CevSbyfD.d.ts → types-B_zhyAqR.d.ts} +1 -1
  18. package/package.json +6 -14
  19. package/src/tools/AudioPlayer/README.md +4 -4
  20. package/src/tools/Chat/README.md +6 -6
  21. package/src/tools/CronScheduler/index.tsx +1 -1
  22. package/src/tools/CronScheduler/lazy.tsx +1 -1
  23. package/src/tools/ImageViewer/README.md +1 -1
  24. package/src/tools/JsonForm/README.md +2 -2
  25. package/src/tools/MarkdownEditor/README.md +3 -3
  26. package/src/tools/MarkdownMessage/README.md +2 -2
  27. package/src/tools/OpenapiViewer/components/DocsLayout/grouping.ts +5 -1
  28. package/src/tools/PrettyCode/lazy.tsx +6 -0
  29. package/src/tools/SpeechRecognition/README.md +1 -1
  30. package/dist/ChatRoot-EFNXQXXN.cjs +0 -15
  31. package/dist/ChatRoot-EFNXQXXN.cjs.map +0 -1
  32. package/dist/ChatRoot-FITF5RVP.mjs +0 -6
  33. package/dist/ChatRoot-FITF5RVP.mjs.map +0 -1
  34. package/dist/ChatRoot-PNNGQCYF.css +0 -7
  35. package/dist/ChatRoot-PNNGQCYF.css.map +0 -1
  36. package/dist/CronScheduler.client-DLMXCPAJ.mjs +0 -67
  37. package/dist/CronScheduler.client-DLMXCPAJ.mjs.map +0 -1
  38. package/dist/CronScheduler.client-WEJF4PWQ.cjs +0 -72
  39. package/dist/CronScheduler.client-WEJF4PWQ.cjs.map +0 -1
  40. package/dist/DictationField-AS2F33WI.cjs +0 -13
  41. package/dist/DictationField-AS2F33WI.cjs.map +0 -1
  42. package/dist/DictationField-WPONUCYE.mjs +0 -4
  43. package/dist/DictationField-WPONUCYE.mjs.map +0 -1
  44. package/dist/DocsLayout-EKASBSP7.mjs +0 -3448
  45. package/dist/DocsLayout-EKASBSP7.mjs.map +0 -1
  46. package/dist/DocsLayout-MBFIB4NO.css +0 -7
  47. package/dist/DocsLayout-MBFIB4NO.css.map +0 -1
  48. package/dist/DocsLayout-OURFYWQE.cjs +0 -3455
  49. package/dist/DocsLayout-OURFYWQE.cjs.map +0 -1
  50. package/dist/JsonSchemaForm-DD7CLRIG.cjs +0 -13
  51. package/dist/JsonSchemaForm-DD7CLRIG.cjs.map +0 -1
  52. package/dist/JsonSchemaForm-XKUIVELK.mjs +0 -4
  53. package/dist/JsonSchemaForm-XKUIVELK.mjs.map +0 -1
  54. package/dist/JsonTree-43PQAJKY.mjs +0 -5
  55. package/dist/JsonTree-43PQAJKY.mjs.map +0 -1
  56. package/dist/JsonTree-MLET23ZA.css +0 -7
  57. package/dist/JsonTree-MLET23ZA.css.map +0 -1
  58. package/dist/JsonTree-X6W5YEVY.cjs +0 -11
  59. package/dist/JsonTree-X6W5YEVY.cjs.map +0 -1
  60. package/dist/LottiePlayer.client-2S7ISJ2S.cjs +0 -168
  61. package/dist/LottiePlayer.client-2S7ISJ2S.cjs.map +0 -1
  62. package/dist/LottiePlayer.client-5LDSSJWS.mjs +0 -161
  63. package/dist/LottiePlayer.client-5LDSSJWS.mjs.map +0 -1
  64. package/dist/MapContainer-AKIPABJK.mjs +0 -4
  65. package/dist/MapContainer-AKIPABJK.mjs.map +0 -1
  66. package/dist/MapContainer-STVDMC36.cjs +0 -17
  67. package/dist/MapContainer-STVDMC36.cjs.map +0 -1
  68. package/dist/Mermaid.client-DDXWXZXY.css +0 -7
  69. package/dist/Mermaid.client-DDXWXZXY.css.map +0 -1
  70. package/dist/Mermaid.client-NL4SVR7F.mjs +0 -481
  71. package/dist/Mermaid.client-NL4SVR7F.mjs.map +0 -1
  72. package/dist/Mermaid.client-NNTI6DFX.cjs +0 -487
  73. package/dist/Mermaid.client-NNTI6DFX.cjs.map +0 -1
  74. package/dist/Player-BRV7XTWR.mjs +0 -4
  75. package/dist/Player-BRV7XTWR.mjs.map +0 -1
  76. package/dist/Player-PM7F7DD7.cjs +0 -13
  77. package/dist/Player-PM7F7DD7.cjs.map +0 -1
  78. package/dist/Player-ZGQKKOWI.css +0 -66
  79. package/dist/Player-ZGQKKOWI.css.map +0 -1
  80. package/dist/PrettyCode.client-GWFAIVFN.css +0 -7
  81. package/dist/PrettyCode.client-GWFAIVFN.css.map +0 -1
  82. package/dist/PrettyCode.client-KOHDVPPN.cjs +0 -285
  83. package/dist/PrettyCode.client-KOHDVPPN.cjs.map +0 -1
  84. package/dist/PrettyCode.client-ZGYGKE7G.mjs +0 -283
  85. package/dist/PrettyCode.client-ZGYGKE7G.mjs.map +0 -1
  86. package/dist/TreeRoot-5COOOSWG.mjs +0 -4
  87. package/dist/TreeRoot-5COOOSWG.mjs.map +0 -1
  88. package/dist/TreeRoot-AABP2J6Y.cjs +0 -19
  89. package/dist/TreeRoot-AABP2J6Y.cjs.map +0 -1
  90. package/dist/chunk-2NG4SXEP.mjs +0 -743
  91. package/dist/chunk-2NG4SXEP.mjs.map +0 -1
  92. package/dist/chunk-4LFB7I5K.cjs +0 -1387
  93. package/dist/chunk-4LFB7I5K.cjs.map +0 -1
  94. package/dist/chunk-5D2OCOPQ.cjs +0 -222
  95. package/dist/chunk-5D2OCOPQ.cjs.map +0 -1
  96. package/dist/chunk-5I5QNGUG.cjs +0 -611
  97. package/dist/chunk-5I5QNGUG.cjs.map +0 -1
  98. package/dist/chunk-6ZX2G25W.mjs +0 -1361
  99. package/dist/chunk-6ZX2G25W.mjs.map +0 -1
  100. package/dist/chunk-76NNDZH6.cjs +0 -1061
  101. package/dist/chunk-76NNDZH6.cjs.map +0 -1
  102. package/dist/chunk-7CWGZPO3.mjs +0 -214
  103. package/dist/chunk-7CWGZPO3.mjs.map +0 -1
  104. package/dist/chunk-7EYHNP3E.cjs +0 -965
  105. package/dist/chunk-7EYHNP3E.cjs.map +0 -1
  106. package/dist/chunk-7IYXZUJO.cjs +0 -769
  107. package/dist/chunk-7IYXZUJO.cjs.map +0 -1
  108. package/dist/chunk-ADEN3UA4.cjs +0 -892
  109. package/dist/chunk-ADEN3UA4.cjs.map +0 -1
  110. package/dist/chunk-B6IR5KSC.mjs +0 -59
  111. package/dist/chunk-B6IR5KSC.mjs.map +0 -1
  112. package/dist/chunk-C6GXVH5J.mjs +0 -338
  113. package/dist/chunk-C6GXVH5J.mjs.map +0 -1
  114. package/dist/chunk-DMX7W4XZ.mjs +0 -1113
  115. package/dist/chunk-DMX7W4XZ.mjs.map +0 -1
  116. package/dist/chunk-ECONRHIG.mjs +0 -212
  117. package/dist/chunk-ECONRHIG.mjs.map +0 -1
  118. package/dist/chunk-FEN5S772.cjs +0 -1227
  119. package/dist/chunk-FEN5S772.cjs.map +0 -1
  120. package/dist/chunk-FP2RLYQZ.cjs +0 -187
  121. package/dist/chunk-FP2RLYQZ.cjs.map +0 -1
  122. package/dist/chunk-FVVF7VCD.cjs +0 -1325
  123. package/dist/chunk-FVVF7VCD.cjs.map +0 -1
  124. package/dist/chunk-GYIO7W7M.mjs +0 -1197
  125. package/dist/chunk-GYIO7W7M.mjs.map +0 -1
  126. package/dist/chunk-KNDLV4PI.cjs +0 -1356
  127. package/dist/chunk-KNDLV4PI.cjs.map +0 -1
  128. package/dist/chunk-KNEQRUBA.mjs +0 -181
  129. package/dist/chunk-KNEQRUBA.mjs.map +0 -1
  130. package/dist/chunk-N2XQF2OL.mjs +0 -14
  131. package/dist/chunk-N4MZYNR4.mjs +0 -1342
  132. package/dist/chunk-N4MZYNR4.mjs.map +0 -1
  133. package/dist/chunk-NTVBIIUD.mjs +0 -1439
  134. package/dist/chunk-NTVBIIUD.mjs.map +0 -1
  135. package/dist/chunk-OBRSGM64.mjs +0 -607
  136. package/dist/chunk-OBRSGM64.mjs.map +0 -1
  137. package/dist/chunk-ODO4GMW7.mjs +0 -79
  138. package/dist/chunk-ODO4GMW7.mjs.map +0 -1
  139. package/dist/chunk-OLISEQHS.cjs +0 -18
  140. package/dist/chunk-PVAX67JG.mjs +0 -1041
  141. package/dist/chunk-PVAX67JG.mjs.map +0 -1
  142. package/dist/chunk-QJ6GTUCO.cjs +0 -81
  143. package/dist/chunk-QJ6GTUCO.cjs.map +0 -1
  144. package/dist/chunk-T3MWM23F.cjs +0 -214
  145. package/dist/chunk-T3MWM23F.cjs.map +0 -1
  146. package/dist/chunk-TBSHZO5R.cjs +0 -1134
  147. package/dist/chunk-TBSHZO5R.cjs.map +0 -1
  148. package/dist/chunk-UNCS5V5F.mjs +0 -887
  149. package/dist/chunk-UNCS5V5F.mjs.map +0 -1
  150. package/dist/chunk-VWQ5WOIL.mjs +0 -2059
  151. package/dist/chunk-VWQ5WOIL.mjs.map +0 -1
  152. package/dist/chunk-W75B7Y6C.cjs +0 -1478
  153. package/dist/chunk-W75B7Y6C.cjs.map +0 -1
  154. package/dist/chunk-Y6UTOBF6.mjs +0 -938
  155. package/dist/chunk-Y6UTOBF6.mjs.map +0 -1
  156. package/dist/chunk-YDPDTOSP.cjs +0 -2061
  157. package/dist/chunk-YDPDTOSP.cjs.map +0 -1
  158. package/dist/chunk-YW5IVWHQ.cjs +0 -346
  159. package/dist/chunk-YW5IVWHQ.cjs.map +0 -1
  160. package/dist/chunk-YXZ6GU7H.cjs +0 -63
  161. package/dist/chunk-YXZ6GU7H.cjs.map +0 -1
  162. package/dist/chunk-ZL7FH4NW.mjs +0 -1274
  163. package/dist/chunk-ZL7FH4NW.mjs.map +0 -1
  164. package/dist/components-EHOGXATG.cjs +0 -22
  165. package/dist/components-EHOGXATG.cjs.map +0 -1
  166. package/dist/components-MQ6DR7TX.cjs +0 -26
  167. package/dist/components-MQ6DR7TX.cjs.map +0 -1
  168. package/dist/components-XRX7QGLB.mjs +0 -5
  169. package/dist/components-XRX7QGLB.mjs.map +0 -1
  170. package/dist/components-YATKRWLH.mjs +0 -5
  171. package/dist/components-YATKRWLH.mjs.map +0 -1
  172. package/dist/index.cjs +0 -3674
  173. package/dist/index.cjs.map +0 -1
  174. package/dist/index.css +0 -234
  175. package/dist/index.css.map +0 -1
  176. package/dist/index.d.cts +0 -4929
  177. package/dist/index.d.ts +0 -4929
  178. package/dist/index.mjs +0 -2912
  179. package/dist/index.mjs.map +0 -1
  180. package/dist/launcher-5Y42OBSN.mjs +0 -6
  181. package/dist/launcher-5Y42OBSN.mjs.map +0 -1
  182. package/dist/launcher-PMW2YB24.cjs +0 -59
  183. package/dist/launcher-PMW2YB24.cjs.map +0 -1
  184. package/src/index.ts +0 -157
@@ -1,1061 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkOLISEQHS_cjs = require('./chunk-OLISEQHS.cjs');
4
- var react = require('react');
5
- var jsxRuntime = require('react/jsx-runtime');
6
- var components = require('@djangocfg/ui-core/components');
7
- var lib = require('@djangocfg/ui-core/lib');
8
- var lucideReact = require('lucide-react');
9
-
10
- // src/tools/CronScheduler/utils/cron-builder.ts
11
- function buildCron(state) {
12
- if (!state || typeof state !== "object") {
13
- return "0 0 * * *";
14
- }
15
- const { type, hour = 0, minute = 0, weekDays = [], monthDays = [], customCron = "" } = state;
16
- const h = Math.max(0, Math.min(23, Number(hour) || 0));
17
- const m = Math.max(0, Math.min(59, Number(minute) || 0));
18
- const safeWeekDays = Array.isArray(weekDays) ? weekDays : [];
19
- const safeMonthDays = Array.isArray(monthDays) ? monthDays : [];
20
- switch (type) {
21
- case "daily":
22
- return `${m} ${h} * * *`;
23
- case "weekly": {
24
- const sortedDays = [...safeWeekDays].sort((a, b) => a - b);
25
- const daysStr = sortedDays.length > 0 ? formatNumberList(sortedDays) : "*";
26
- return `${m} ${h} * * ${daysStr}`;
27
- }
28
- case "monthly": {
29
- const sortedDays = [...safeMonthDays].sort((a, b) => a - b);
30
- const daysStr = sortedDays.length > 0 ? formatNumberList(sortedDays) : "1";
31
- return `${m} ${h} ${daysStr} * *`;
32
- }
33
- case "custom":
34
- return (customCron || "").trim() || "* * * * *";
35
- default:
36
- return "0 0 * * *";
37
- }
38
- }
39
- chunkOLISEQHS_cjs.__name(buildCron, "buildCron");
40
- function formatNumberList(nums) {
41
- if (nums.length === 0) return "";
42
- if (nums.length === 1) return nums[0].toString();
43
- const sorted = [...nums].sort((a, b) => a - b);
44
- const ranges = [];
45
- let start = sorted[0];
46
- let end = sorted[0];
47
- for (let i = 1; i < sorted.length; i++) {
48
- if (sorted[i] === end + 1) {
49
- end = sorted[i];
50
- } else {
51
- ranges.push(start === end ? `${start}` : `${start}-${end}`);
52
- start = sorted[i];
53
- end = sorted[i];
54
- }
55
- }
56
- ranges.push(start === end ? `${start}` : `${start}-${end}`);
57
- return ranges.join(",");
58
- }
59
- chunkOLISEQHS_cjs.__name(formatNumberList, "formatNumberList");
60
-
61
- // src/tools/CronScheduler/utils/cron-parser.ts
62
- function parseCron(cron) {
63
- if (!cron || typeof cron !== "string") return null;
64
- const parts = cron.trim().split(/\s+/);
65
- if (parts.length !== 5) return null;
66
- const [minutePart, hourPart, dayOfMonthPart, monthPart, dayOfWeekPart] = parts;
67
- if (!isValidCronField(minutePart, 0, 59)) return null;
68
- if (!isValidCronField(hourPart, 0, 23)) return null;
69
- if (!isValidCronField(dayOfMonthPart, 1, 31)) return null;
70
- if (!isValidCronField(monthPart, 1, 12)) return null;
71
- if (!isValidCronField(dayOfWeekPart, 0, 6)) return null;
72
- const minute = parseField(minutePart);
73
- const hour = parseField(hourPart);
74
- const result = detectScheduleType(
75
- minutePart,
76
- hourPart,
77
- dayOfMonthPart,
78
- monthPart,
79
- dayOfWeekPart
80
- );
81
- return {
82
- type: result.type,
83
- hour: hour ?? 0,
84
- minute: minute ?? 0,
85
- weekDays: result.weekDays,
86
- monthDays: result.monthDays,
87
- customCron: cron,
88
- isValid: true
89
- };
90
- }
91
- chunkOLISEQHS_cjs.__name(parseCron, "parseCron");
92
- function isSimpleField(part) {
93
- return part === "*" || /^\d+$/.test(part);
94
- }
95
- chunkOLISEQHS_cjs.__name(isSimpleField, "isSimpleField");
96
- function detectScheduleType(minutePart, hourPart, dayOfMonthPart, monthPart, dayOfWeekPart) {
97
- let type = "custom";
98
- let weekDays = [1, 2, 3, 4, 5];
99
- let monthDays = [1];
100
- if (!isSimpleField(minutePart) || !isSimpleField(hourPart)) {
101
- return { type: "custom", weekDays, monthDays };
102
- }
103
- if (dayOfMonthPart === "*" && monthPart === "*" && dayOfWeekPart === "*") {
104
- type = "daily";
105
- } else if (dayOfMonthPart === "*" && monthPart === "*" && dayOfWeekPart !== "*") {
106
- type = "weekly";
107
- weekDays = parseWeekDays(dayOfWeekPart);
108
- } else if (dayOfMonthPart !== "*" && monthPart === "*" && dayOfWeekPart === "*") {
109
- type = "monthly";
110
- monthDays = parseMonthDays(dayOfMonthPart);
111
- }
112
- return { type, weekDays, monthDays };
113
- }
114
- chunkOLISEQHS_cjs.__name(detectScheduleType, "detectScheduleType");
115
- function isValidCronField(part, min, max) {
116
- if (part === "*") return true;
117
- if (part.includes("/")) {
118
- const [base, step] = part.split("/");
119
- if (!step || !/^\d+$/.test(step)) return false;
120
- if (base === "*") return true;
121
- return isValidCronField(base, min, max);
122
- }
123
- if (part.includes("-") && !part.includes(",")) {
124
- const [start, end] = part.split("-").map((s) => parseInt(s, 10));
125
- return !isNaN(start) && !isNaN(end) && start >= min && end <= max && start <= end;
126
- }
127
- if (part.includes(",")) {
128
- return part.split(",").every((p) => isValidCronField(p.trim(), min, max));
129
- }
130
- if (/^\d+$/.test(part)) {
131
- const num = parseInt(part, 10);
132
- return num >= min && num <= max;
133
- }
134
- return false;
135
- }
136
- chunkOLISEQHS_cjs.__name(isValidCronField, "isValidCronField");
137
- function parseField(part, _min, _max) {
138
- if (/^\d+$/.test(part)) {
139
- return parseInt(part, 10);
140
- }
141
- return null;
142
- }
143
- chunkOLISEQHS_cjs.__name(parseField, "parseField");
144
- function parseWeekDays(part) {
145
- const result = [];
146
- if (part.includes("-")) {
147
- const [start, end] = part.split("-").map((s) => parseInt(s, 10));
148
- if (!isNaN(start) && !isNaN(end)) {
149
- for (let i = start; i <= end && i <= 6; i++) {
150
- if (i >= 0) result.push(i);
151
- }
152
- }
153
- return result.length > 0 ? result : [1, 2, 3, 4, 5];
154
- }
155
- for (const segment of part.split(",")) {
156
- const num = parseInt(segment.trim(), 10);
157
- if (!isNaN(num) && num >= 0 && num <= 6) {
158
- result.push(num);
159
- }
160
- }
161
- return result.length > 0 ? result : [1, 2, 3, 4, 5];
162
- }
163
- chunkOLISEQHS_cjs.__name(parseWeekDays, "parseWeekDays");
164
- function parseMonthDays(part) {
165
- const result = [];
166
- if (part.includes("-")) {
167
- const [start, end] = part.split("-").map((s) => parseInt(s, 10));
168
- if (!isNaN(start) && !isNaN(end)) {
169
- for (let i = start; i <= end && i <= 31; i++) {
170
- if (i >= 1) result.push(i);
171
- }
172
- }
173
- return result.length > 0 ? result : [1];
174
- }
175
- for (const segment of part.split(",")) {
176
- const num = parseInt(segment.trim(), 10);
177
- if (!isNaN(num) && num >= 1 && num <= 31) {
178
- result.push(num);
179
- }
180
- }
181
- return result.length > 0 ? result : [1];
182
- }
183
- chunkOLISEQHS_cjs.__name(parseMonthDays, "parseMonthDays");
184
- function isValidCron(cron) {
185
- if (!cron || typeof cron !== "string") return false;
186
- const parts = cron.trim().split(/\s+/);
187
- if (parts.length !== 5) return false;
188
- const [minutePart, hourPart, dayOfMonthPart, monthPart, dayOfWeekPart] = parts;
189
- return isValidCronField(minutePart, 0, 59) && isValidCronField(hourPart, 0, 23) && isValidCronField(dayOfMonthPart, 1, 31) && isValidCronField(monthPart, 1, 12) && isValidCronField(dayOfWeekPart, 0, 6);
190
- }
191
- chunkOLISEQHS_cjs.__name(isValidCron, "isValidCron");
192
-
193
- // src/tools/CronScheduler/utils/cron-humanize.ts
194
- var WEEKDAY_SHORT = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
195
- function humanizeCron(cron) {
196
- if (!cron || typeof cron !== "string") return "Invalid schedule";
197
- const parts = cron.trim().split(/\s+/);
198
- if (parts.length !== 5) return "Invalid schedule";
199
- const [minutePart, hourPart, dayOfMonthPart, monthPart, dayOfWeekPart] = parts;
200
- const minute = parseInt(minutePart, 10);
201
- const hour = parseInt(hourPart, 10);
202
- const timeStr = formatTime(hour, minute);
203
- if (minutePart === "*" && hourPart === "*" && dayOfMonthPart === "*" && monthPart === "*" && dayOfWeekPart === "*") {
204
- return "Every minute";
205
- }
206
- if (minutePart.startsWith("*/")) {
207
- const interval = parseInt(minutePart.slice(2), 10);
208
- if (hourPart === "*") {
209
- return `Every ${interval} minute${interval > 1 ? "s" : ""}`;
210
- }
211
- return `Every ${interval} minute${interval > 1 ? "s" : ""} at hour ${hour}`;
212
- }
213
- if (!isNaN(minute) && hourPart === "*" && dayOfMonthPart === "*" && monthPart === "*" && dayOfWeekPart === "*") {
214
- return `Every hour at minute ${minute}`;
215
- }
216
- if (dayOfMonthPart === "*" && monthPart === "*" && dayOfWeekPart === "*") {
217
- return `Every day at ${timeStr}`;
218
- }
219
- if (dayOfMonthPart === "*" && monthPart === "*" && dayOfWeekPart !== "*") {
220
- const days = parseWeekDays2(dayOfWeekPart);
221
- if (days.length === 7) {
222
- return `Every day at ${timeStr}`;
223
- }
224
- if (days.length === 5 && isWeekdays(days)) {
225
- return `Weekdays at ${timeStr}`;
226
- }
227
- if (days.length === 2 && isWeekend(days)) {
228
- return `Weekends at ${timeStr}`;
229
- }
230
- const dayNames = days.map((d) => WEEKDAY_SHORT[d]).join(", ");
231
- return `${dayNames} at ${timeStr}`;
232
- }
233
- if (dayOfMonthPart !== "*" && monthPart === "*" && dayOfWeekPart === "*") {
234
- const days = parseMonthDays2(dayOfMonthPart);
235
- if (days.length === 1) {
236
- return `${ordinal(days[0])} of every month at ${timeStr}`;
237
- }
238
- if (days.length <= 3) {
239
- const dayStr = days.map((d) => ordinal(d)).join(", ");
240
- return `${dayStr} of every month at ${timeStr}`;
241
- }
242
- return `${days.length} days per month at ${timeStr}`;
243
- }
244
- return `Custom schedule`;
245
- }
246
- chunkOLISEQHS_cjs.__name(humanizeCron, "humanizeCron");
247
- function formatTime(hour, minute) {
248
- const h = isNaN(hour) ? 0 : Math.max(0, Math.min(23, hour));
249
- const m = isNaN(minute) ? 0 : Math.max(0, Math.min(59, minute));
250
- return `${h.toString().padStart(2, "0")}:${m.toString().padStart(2, "0")}`;
251
- }
252
- chunkOLISEQHS_cjs.__name(formatTime, "formatTime");
253
- function parseWeekDays2(part) {
254
- const result = [];
255
- if (part.includes("-") && !part.includes(",")) {
256
- const [start, end] = part.split("-").map((s) => parseInt(s, 10));
257
- if (!isNaN(start) && !isNaN(end)) {
258
- for (let i = start; i <= end && i <= 6; i++) {
259
- if (i >= 0) result.push(i);
260
- }
261
- }
262
- return result;
263
- }
264
- for (const segment of part.split(",")) {
265
- if (segment.includes("-")) {
266
- const [start, end] = segment.split("-").map((s) => parseInt(s, 10));
267
- if (!isNaN(start) && !isNaN(end)) {
268
- for (let i = start; i <= end && i <= 6; i++) {
269
- if (i >= 0) result.push(i);
270
- }
271
- }
272
- } else {
273
- const num = parseInt(segment.trim(), 10);
274
- if (!isNaN(num) && num >= 0 && num <= 6) {
275
- result.push(num);
276
- }
277
- }
278
- }
279
- return result.sort((a, b) => a - b);
280
- }
281
- chunkOLISEQHS_cjs.__name(parseWeekDays2, "parseWeekDays");
282
- function parseMonthDays2(part) {
283
- const result = [];
284
- if (part.includes("-") && !part.includes(",")) {
285
- const [start, end] = part.split("-").map((s) => parseInt(s, 10));
286
- if (!isNaN(start) && !isNaN(end)) {
287
- for (let i = start; i <= end && i <= 31; i++) {
288
- if (i >= 1) result.push(i);
289
- }
290
- }
291
- return result;
292
- }
293
- for (const segment of part.split(",")) {
294
- const num = parseInt(segment.trim(), 10);
295
- if (!isNaN(num) && num >= 1 && num <= 31) {
296
- result.push(num);
297
- }
298
- }
299
- return result.sort((a, b) => a - b);
300
- }
301
- chunkOLISEQHS_cjs.__name(parseMonthDays2, "parseMonthDays");
302
- function isWeekdays(days) {
303
- const sorted = [...days].sort((a, b) => a - b);
304
- return sorted.join(",") === "1,2,3,4,5";
305
- }
306
- chunkOLISEQHS_cjs.__name(isWeekdays, "isWeekdays");
307
- function isWeekend(days) {
308
- const sorted = [...days].sort((a, b) => a - b);
309
- return sorted.join(",") === "0,6";
310
- }
311
- chunkOLISEQHS_cjs.__name(isWeekend, "isWeekend");
312
- function ordinal(n) {
313
- const s = ["th", "st", "nd", "rd"];
314
- const v = n % 100;
315
- return n + (s[(v - 20) % 10] || s[v] || s[0]);
316
- }
317
- chunkOLISEQHS_cjs.__name(ordinal, "ordinal");
318
- var CronSchedulerContext = react.createContext(null);
319
- var DEFAULT_STATE = {
320
- type: "daily",
321
- hour: 9,
322
- minute: 0,
323
- weekDays: [1, 2, 3, 4, 5],
324
- // Mon-Fri
325
- monthDays: [1],
326
- customCron: "* * * * *",
327
- isValid: true
328
- };
329
- function CronSchedulerProvider({
330
- children,
331
- value,
332
- onChange,
333
- defaultType = "daily"
334
- }) {
335
- const isInitialMount = react.useRef(true);
336
- const onChangeRef = react.useRef(onChange);
337
- onChangeRef.current = onChange;
338
- const [initialValue] = react.useState(() => value || null);
339
- const [state, setState] = react.useState(() => {
340
- try {
341
- if (value) {
342
- const parsed = parseCron(value);
343
- if (parsed) return parsed;
344
- }
345
- } catch {
346
- }
347
- return { ...DEFAULT_STATE, type: defaultType };
348
- });
349
- react.useEffect(() => {
350
- try {
351
- if (value) {
352
- const parsed = parseCron(value);
353
- if (parsed) {
354
- const currentCron = buildCron(state);
355
- if (value !== currentCron) {
356
- setState(parsed);
357
- }
358
- }
359
- }
360
- } catch {
361
- }
362
- }, [value]);
363
- const cronExpression = react.useMemo(() => buildCron(state), [state]);
364
- const humanDescription = react.useMemo(() => humanizeCron(cronExpression), [cronExpression]);
365
- react.useEffect(() => {
366
- if (isInitialMount.current) {
367
- isInitialMount.current = false;
368
- return;
369
- }
370
- onChangeRef.current?.(cronExpression);
371
- }, [cronExpression]);
372
- const setType = react.useCallback((type) => {
373
- setState((s) => ({ ...s, type }));
374
- }, []);
375
- const setTime = react.useCallback((hour, minute) => {
376
- setState((s) => ({
377
- ...s,
378
- hour: Math.max(0, Math.min(23, hour)),
379
- minute: Math.max(0, Math.min(59, minute))
380
- }));
381
- }, []);
382
- const toggleWeekDay = react.useCallback((day) => {
383
- setState((s) => {
384
- const hasDay = s.weekDays.includes(day);
385
- if (hasDay && s.weekDays.length === 1) return s;
386
- const newDays = hasDay ? s.weekDays.filter((d) => d !== day) : [...s.weekDays, day];
387
- return {
388
- ...s,
389
- weekDays: newDays.sort((a, b) => a - b)
390
- };
391
- });
392
- }, []);
393
- const setWeekDays = react.useCallback((days) => {
394
- setState((s) => ({
395
- ...s,
396
- weekDays: days.length > 0 ? [...days].sort((a, b) => a - b) : [1]
397
- // Default to Monday if empty
398
- }));
399
- }, []);
400
- const toggleMonthDay = react.useCallback((day) => {
401
- setState((s) => {
402
- const hasDay = s.monthDays.includes(day);
403
- if (hasDay && s.monthDays.length === 1) return s;
404
- const newDays = hasDay ? s.monthDays.filter((d) => d !== day) : [...s.monthDays, day];
405
- return {
406
- ...s,
407
- monthDays: newDays.sort((a, b) => a - b)
408
- };
409
- });
410
- }, []);
411
- const setMonthDays = react.useCallback((days) => {
412
- setState((s) => ({
413
- ...s,
414
- monthDays: days.length > 0 ? [...days].sort((a, b) => a - b) : [1]
415
- // Default to 1st if empty
416
- }));
417
- }, []);
418
- const setCustomCron = react.useCallback((customCron) => {
419
- const parsed = parseCron(customCron);
420
- setState((s) => ({
421
- ...s,
422
- customCron,
423
- isValid: parsed !== null
424
- }));
425
- }, []);
426
- const reset = react.useCallback(() => {
427
- setState({ ...DEFAULT_STATE, type: defaultType });
428
- }, [defaultType]);
429
- const contextValue = react.useMemo(
430
- () => ({
431
- // State
432
- ...state,
433
- // Computed
434
- cronExpression,
435
- humanDescription,
436
- initialValue,
437
- // Actions
438
- setType,
439
- setTime,
440
- toggleWeekDay,
441
- setWeekDays,
442
- toggleMonthDay,
443
- setMonthDays,
444
- setCustomCron,
445
- reset
446
- }),
447
- [
448
- state,
449
- cronExpression,
450
- humanDescription,
451
- initialValue,
452
- setType,
453
- setTime,
454
- toggleWeekDay,
455
- setWeekDays,
456
- toggleMonthDay,
457
- setMonthDays,
458
- setCustomCron,
459
- reset
460
- ]
461
- );
462
- return /* @__PURE__ */ jsxRuntime.jsx(CronSchedulerContext.Provider, { value: contextValue, children });
463
- }
464
- chunkOLISEQHS_cjs.__name(CronSchedulerProvider, "CronSchedulerProvider");
465
- function useCronSchedulerContext() {
466
- const context = react.useContext(CronSchedulerContext);
467
- if (!context) {
468
- throw new Error(
469
- "useCronSchedulerContext must be used within CronSchedulerProvider"
470
- );
471
- }
472
- return context;
473
- }
474
- chunkOLISEQHS_cjs.__name(useCronSchedulerContext, "useCronSchedulerContext");
475
- function useCronType() {
476
- const { type, setType } = useCronSchedulerContext();
477
- return react.useMemo(() => ({ type, setType }), [type, setType]);
478
- }
479
- chunkOLISEQHS_cjs.__name(useCronType, "useCronType");
480
- function useCronTime() {
481
- const { hour, minute, setTime } = useCronSchedulerContext();
482
- return react.useMemo(() => ({ hour, minute, setTime }), [hour, minute, setTime]);
483
- }
484
- chunkOLISEQHS_cjs.__name(useCronTime, "useCronTime");
485
- function useCronWeekDays() {
486
- const { weekDays, toggleWeekDay, setWeekDays } = useCronSchedulerContext();
487
- return react.useMemo(
488
- () => ({ weekDays, toggleWeekDay, setWeekDays }),
489
- [weekDays, toggleWeekDay, setWeekDays]
490
- );
491
- }
492
- chunkOLISEQHS_cjs.__name(useCronWeekDays, "useCronWeekDays");
493
- function useCronMonthDays() {
494
- const { monthDays, toggleMonthDay, setMonthDays } = useCronSchedulerContext();
495
- return react.useMemo(
496
- () => ({ monthDays, toggleMonthDay, setMonthDays }),
497
- [monthDays, toggleMonthDay, setMonthDays]
498
- );
499
- }
500
- chunkOLISEQHS_cjs.__name(useCronMonthDays, "useCronMonthDays");
501
- function useCronCustom() {
502
- const { customCron, isValid, setCustomCron } = useCronSchedulerContext();
503
- return react.useMemo(
504
- () => ({ customCron, isValid, setCustomCron }),
505
- [customCron, isValid, setCustomCron]
506
- );
507
- }
508
- chunkOLISEQHS_cjs.__name(useCronCustom, "useCronCustom");
509
- function useCronPreview() {
510
- const { cronExpression, humanDescription, isValid, initialValue } = useCronSchedulerContext();
511
- return react.useMemo(
512
- () => ({ cronExpression, humanDescription, isValid, initialValue }),
513
- [cronExpression, humanDescription, isValid, initialValue]
514
- );
515
- }
516
- chunkOLISEQHS_cjs.__name(useCronPreview, "useCronPreview");
517
- function useCronScheduler() {
518
- return useCronSchedulerContext();
519
- }
520
- chunkOLISEQHS_cjs.__name(useCronScheduler, "useCronScheduler");
521
- var SCHEDULE_TYPES = [
522
- { value: "daily", label: "Daily" },
523
- { value: "weekly", label: "Weekly" },
524
- { value: "monthly", label: "Monthly" },
525
- { value: "custom", label: "Custom" }
526
- ];
527
- function ScheduleTypeSelector({
528
- disabled,
529
- className
530
- }) {
531
- const { type, setType } = useCronType();
532
- const triggerClassName = lib.cn(
533
- "text-xs font-medium px-2 py-1.5",
534
- "data-[state=active]:shadow-sm",
535
- "transition-all duration-150"
536
- );
537
- const triggers = SCHEDULE_TYPES.map(({ value, label }) => ({
538
- value,
539
- label,
540
- disabled,
541
- className: triggerClassName
542
- }));
543
- return /* @__PURE__ */ jsxRuntime.jsx(
544
- components.Tabs,
545
- {
546
- value: type,
547
- onValueChange: (v) => setType(v),
548
- className: lib.cn("w-full", className),
549
- children: /* @__PURE__ */ jsxRuntime.jsx(components.TabsList, { className: "grid w-full grid-cols-4 h-9 p-0.5", children: triggers.map((trigger) => /* @__PURE__ */ jsxRuntime.jsx(
550
- components.TabsTrigger,
551
- {
552
- value: trigger.value,
553
- disabled: trigger.disabled,
554
- className: trigger.className,
555
- children: trigger.label
556
- },
557
- trigger.value
558
- )) })
559
- }
560
- );
561
- }
562
- chunkOLISEQHS_cjs.__name(ScheduleTypeSelector, "ScheduleTypeSelector");
563
- var HOURS = Array.from({ length: 24 }, (_, i) => i);
564
- var MINUTES = [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55];
565
- function TimeSelector({
566
- format = "24h",
567
- disabled,
568
- className
569
- }) {
570
- const { hour, minute, setTime } = useCronTime();
571
- const is24h = format === "24h";
572
- const displayHour = is24h ? hour : hour % 12 || 12;
573
- const isPM = hour >= 12;
574
- const handleHourChange = /* @__PURE__ */ chunkOLISEQHS_cjs.__name((value) => {
575
- let newHour = parseInt(value, 10);
576
- if (!is24h) {
577
- if (isPM && newHour !== 12) newHour += 12;
578
- else if (!isPM && newHour === 12) newHour = 0;
579
- }
580
- setTime(newHour, minute);
581
- }, "handleHourChange");
582
- const handleMinuteChange = /* @__PURE__ */ chunkOLISEQHS_cjs.__name((value) => {
583
- setTime(hour, parseInt(value, 10));
584
- }, "handleMinuteChange");
585
- const handlePeriodChange = /* @__PURE__ */ chunkOLISEQHS_cjs.__name((value) => {
586
- const newIsPM = value === "PM";
587
- let newHour = hour;
588
- if (newIsPM && hour < 12) newHour = hour + 12;
589
- else if (!newIsPM && hour >= 12) newHour = hour - 12;
590
- setTime(newHour, minute);
591
- }, "handlePeriodChange");
592
- const hours = is24h ? HOURS : Array.from({ length: 12 }, (_, i) => i + 1);
593
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: lib.cn("flex items-center gap-3", className), children: [
594
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 text-muted-foreground", children: [
595
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Clock, { className: "h-4 w-4" }),
596
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm", children: "Run at" })
597
- ] }),
598
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5 flex-1", children: [
599
- /* @__PURE__ */ jsxRuntime.jsxs(
600
- components.Select,
601
- {
602
- value: displayHour.toString(),
603
- onValueChange: handleHourChange,
604
- disabled,
605
- children: [
606
- /* @__PURE__ */ jsxRuntime.jsx(components.SelectTrigger, { className: "w-[70px] h-9", children: /* @__PURE__ */ jsxRuntime.jsx(components.SelectValue, { children: displayHour.toString().padStart(2, "0") }) }),
607
- /* @__PURE__ */ jsxRuntime.jsx(components.SelectContent, { className: "max-h-48", children: hours.map((h) => /* @__PURE__ */ jsxRuntime.jsx(components.SelectItem, { value: h.toString(), children: h.toString().padStart(2, "0") }, h)) })
608
- ]
609
- }
610
- ),
611
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground font-medium", children: ":" }),
612
- /* @__PURE__ */ jsxRuntime.jsxs(
613
- components.Select,
614
- {
615
- value: minute.toString(),
616
- onValueChange: handleMinuteChange,
617
- disabled,
618
- children: [
619
- /* @__PURE__ */ jsxRuntime.jsx(components.SelectTrigger, { className: "w-[70px] h-9", children: /* @__PURE__ */ jsxRuntime.jsx(components.SelectValue, { children: minute.toString().padStart(2, "0") }) }),
620
- /* @__PURE__ */ jsxRuntime.jsx(components.SelectContent, { className: "max-h-48", children: MINUTES.map((m) => /* @__PURE__ */ jsxRuntime.jsx(components.SelectItem, { value: m.toString(), children: m.toString().padStart(2, "0") }, m)) })
621
- ]
622
- }
623
- ),
624
- !is24h && /* @__PURE__ */ jsxRuntime.jsxs(
625
- components.Select,
626
- {
627
- value: isPM ? "PM" : "AM",
628
- onValueChange: handlePeriodChange,
629
- disabled,
630
- children: [
631
- /* @__PURE__ */ jsxRuntime.jsx(components.SelectTrigger, { className: "w-[70px] h-9", children: /* @__PURE__ */ jsxRuntime.jsx(components.SelectValue, {}) }),
632
- /* @__PURE__ */ jsxRuntime.jsxs(components.SelectContent, { children: [
633
- /* @__PURE__ */ jsxRuntime.jsx(components.SelectItem, { value: "AM", children: "AM" }),
634
- /* @__PURE__ */ jsxRuntime.jsx(components.SelectItem, { value: "PM", children: "PM" })
635
- ] })
636
- ]
637
- }
638
- )
639
- ] })
640
- ] });
641
- }
642
- chunkOLISEQHS_cjs.__name(TimeSelector, "TimeSelector");
643
- var DAYS = [
644
- { value: 1, label: "Mon" },
645
- { value: 2, label: "Tue" },
646
- { value: 3, label: "Wed" },
647
- { value: 4, label: "Thu" },
648
- { value: 5, label: "Fri" },
649
- { value: 6, label: "Sat" },
650
- { value: 0, label: "Sun" }
651
- ];
652
- function DayChips({
653
- disabled,
654
- showPresets = true,
655
- className
656
- }) {
657
- const { weekDays, toggleWeekDay, setWeekDays } = useCronWeekDays();
658
- const safeWeekDays = Array.isArray(weekDays) ? weekDays : [];
659
- const isWeekdays2 = safeWeekDays.length === 5 && [1, 2, 3, 4, 5].every((d) => safeWeekDays.includes(d));
660
- const isWeekendPreset = safeWeekDays.length === 2 && [0, 6].every((d) => safeWeekDays.includes(d));
661
- const isEveryday = safeWeekDays.length === 7;
662
- const dayButtons = DAYS.map(({ value, label }) => {
663
- const isSelected = safeWeekDays.includes(value);
664
- const isWeekendDay = value === 0 || value === 6;
665
- return {
666
- value,
667
- label,
668
- isSelected,
669
- isWeekendDay,
670
- className: lib.cn(
671
- "flex flex-col items-center justify-center",
672
- "py-2.5 rounded-lg text-xs font-medium",
673
- "transition-all duration-150",
674
- "focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",
675
- "active:scale-[0.97]",
676
- isSelected ? "bg-primary text-primary-foreground shadow-sm" : lib.cn(
677
- "bg-muted/50 hover:bg-muted",
678
- isWeekendDay ? "text-muted-foreground/70" : "text-muted-foreground"
679
- ),
680
- disabled && "opacity-50 cursor-not-allowed pointer-events-none"
681
- )
682
- };
683
- });
684
- const presets = [
685
- { label: "Weekdays", isActive: isWeekdays2, days: [1, 2, 3, 4, 5] },
686
- { label: "Weekends", isActive: isWeekendPreset, days: [0, 6] },
687
- { label: "Every day", isActive: isEveryday, days: [0, 1, 2, 3, 4, 5, 6] }
688
- ];
689
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: lib.cn("space-y-3", className), children: [
690
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-7 gap-1", children: dayButtons.map((day) => /* @__PURE__ */ jsxRuntime.jsx(
691
- "button",
692
- {
693
- type: "button",
694
- disabled,
695
- onClick: () => toggleWeekDay(day.value),
696
- "aria-pressed": day.isSelected,
697
- className: day.className,
698
- children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: day.label })
699
- },
700
- day.value
701
- )) }),
702
- showPresets && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-2", children: presets.map((preset) => /* @__PURE__ */ jsxRuntime.jsx(
703
- PresetButton,
704
- {
705
- label: preset.label,
706
- isActive: preset.isActive,
707
- onClick: () => setWeekDays(preset.days),
708
- disabled
709
- },
710
- preset.label
711
- )) })
712
- ] });
713
- }
714
- chunkOLISEQHS_cjs.__name(DayChips, "DayChips");
715
- function PresetButton({ label, isActive, onClick, disabled }) {
716
- return /* @__PURE__ */ jsxRuntime.jsx(
717
- "button",
718
- {
719
- type: "button",
720
- disabled,
721
- onClick,
722
- className: lib.cn(
723
- "flex-1 px-3 py-1.5 rounded-md text-xs font-medium",
724
- "transition-colors duration-150",
725
- "focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",
726
- isActive ? "bg-primary/15 text-primary border border-primary/30" : "bg-muted/30 text-muted-foreground hover:bg-muted/50 border border-transparent",
727
- disabled && "opacity-50 cursor-not-allowed"
728
- ),
729
- children: label
730
- }
731
- );
732
- }
733
- chunkOLISEQHS_cjs.__name(PresetButton, "PresetButton");
734
- Array.from({ length: 31 }, (_, i) => i + 1);
735
- var GRID_SIZE = 35;
736
- function MonthDayGrid({
737
- disabled,
738
- showPresets = true,
739
- className
740
- }) {
741
- const { monthDays, toggleMonthDay, setMonthDays } = useCronMonthDays();
742
- const safeMonthDays = Array.isArray(monthDays) ? monthDays : [];
743
- const is1st = safeMonthDays.length === 1 && safeMonthDays[0] === 1;
744
- const is15th = safeMonthDays.length === 1 && safeMonthDays[0] === 15;
745
- const is1stAnd15th = safeMonthDays.length === 2 && safeMonthDays.includes(1) && safeMonthDays.includes(15);
746
- const presets = [
747
- { label: "1st", isActive: is1st, days: [1] },
748
- { label: "15th", isActive: is15th, days: [15] },
749
- { label: "1st & 15th", isActive: is1stAnd15th, days: [1, 15] }
750
- ];
751
- const gridCells = Array.from({ length: GRID_SIZE }, (_, i) => {
752
- const day = i + 1;
753
- const isValidDay = day <= 31;
754
- const isSelected = isValidDay && safeMonthDays.includes(day);
755
- const isPartialMonth = day > 28;
756
- if (!isValidDay) {
757
- return { type: "empty", key: i };
758
- }
759
- return {
760
- type: "day",
761
- key: day,
762
- day,
763
- isSelected,
764
- className: lib.cn(
765
- "aspect-square flex items-center justify-center",
766
- "rounded-lg text-sm font-medium",
767
- "transition-all duration-150",
768
- "focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",
769
- "active:scale-[0.95]",
770
- isSelected ? "bg-primary text-primary-foreground shadow-sm" : lib.cn(
771
- "bg-muted/30 hover:bg-muted/60",
772
- isPartialMonth ? "text-muted-foreground/50" : "text-muted-foreground"
773
- ),
774
- disabled && "opacity-50 cursor-not-allowed pointer-events-none"
775
- )
776
- };
777
- });
778
- const selectionCount = safeMonthDays.length;
779
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: lib.cn("space-y-3", className), children: [
780
- showPresets && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-2", children: presets.map((preset) => /* @__PURE__ */ jsxRuntime.jsx(
781
- PresetButton2,
782
- {
783
- label: preset.label,
784
- isActive: preset.isActive,
785
- onClick: () => setMonthDays(preset.days),
786
- disabled
787
- },
788
- preset.label
789
- )) }),
790
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-7 gap-1", children: gridCells.map((cell) => {
791
- if (cell.type === "empty") {
792
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "aspect-square" }, cell.key);
793
- }
794
- return /* @__PURE__ */ jsxRuntime.jsx(
795
- "button",
796
- {
797
- type: "button",
798
- disabled,
799
- onClick: () => toggleMonthDay(cell.day),
800
- "aria-pressed": cell.isSelected,
801
- "aria-label": `Day ${cell.day}`,
802
- className: cell.className,
803
- children: cell.day
804
- },
805
- cell.key
806
- );
807
- }) }),
808
- selectionCount > 1 && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs text-muted-foreground text-center", children: [
809
- selectionCount,
810
- " days selected"
811
- ] })
812
- ] });
813
- }
814
- chunkOLISEQHS_cjs.__name(MonthDayGrid, "MonthDayGrid");
815
- function PresetButton2({ label, isActive, onClick, disabled }) {
816
- return /* @__PURE__ */ jsxRuntime.jsx(
817
- "button",
818
- {
819
- type: "button",
820
- disabled,
821
- onClick,
822
- className: lib.cn(
823
- "flex-1 px-3 py-1.5 rounded-md text-xs font-medium",
824
- "transition-colors duration-150",
825
- "focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",
826
- isActive ? "bg-primary/15 text-primary border border-primary/30" : "bg-muted/30 text-muted-foreground hover:bg-muted/50 border border-transparent",
827
- disabled && "opacity-50 cursor-not-allowed"
828
- ),
829
- children: label
830
- }
831
- );
832
- }
833
- chunkOLISEQHS_cjs.__name(PresetButton2, "PresetButton");
834
- function CustomInput({ disabled, className }) {
835
- const { customCron, isValid, setCustomCron } = useCronCustom();
836
- const [localValue, setLocalValue] = react.useState(customCron);
837
- const [localValid, setLocalValid] = react.useState(isValid);
838
- react.useEffect(() => {
839
- setLocalValue(customCron);
840
- setLocalValid(isValid);
841
- }, [customCron, isValid]);
842
- const handleChange = /* @__PURE__ */ chunkOLISEQHS_cjs.__name((e) => {
843
- const value = e.target.value;
844
- setLocalValue(value);
845
- const valid = isValidCron(value);
846
- setLocalValid(valid);
847
- setCustomCron(value);
848
- }, "handleChange");
849
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: lib.cn("space-y-2", className), children: [
850
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-muted-foreground", children: "Cron expression" }),
851
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
852
- /* @__PURE__ */ jsxRuntime.jsx(
853
- components.Input,
854
- {
855
- type: "text",
856
- value: localValue,
857
- onChange: handleChange,
858
- disabled,
859
- placeholder: "* * * * *",
860
- className: lib.cn(
861
- "font-mono text-base pr-10 h-11",
862
- !localValid && localValue.trim() && "border-destructive focus-visible:ring-destructive/50"
863
- )
864
- }
865
- ),
866
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute right-3 top-1/2 -translate-y-1/2", children: localValue.trim() && (localValid ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CheckCircle2, { className: "h-5 w-5 text-green-500" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertCircle, { className: "h-5 w-5 text-destructive" })) })
867
- ] })
868
- ] });
869
- }
870
- chunkOLISEQHS_cjs.__name(CustomInput, "CustomInput");
871
- function CronCheatsheet({ className }) {
872
- return /* @__PURE__ */ jsxRuntime.jsxs(components.Popover, { children: [
873
- /* @__PURE__ */ jsxRuntime.jsx(components.PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
874
- "button",
875
- {
876
- type: "button",
877
- className: lib.cn(
878
- "p-1 rounded hover:bg-muted/50 transition-colors",
879
- className
880
- ),
881
- "aria-label": "Cron syntax help",
882
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.HelpCircle, { className: "h-4 w-4 text-muted-foreground" })
883
- }
884
- ) }),
885
- /* @__PURE__ */ jsxRuntime.jsx(components.PopoverContent, { className: "w-72 p-3", align: "end", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
886
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-medium text-sm", children: "Cron Format" }),
887
- /* @__PURE__ */ jsxRuntime.jsx("code", { className: "block text-xs bg-muted px-2 py-1.5 rounded font-mono text-center", children: "min hour day month weekday" }),
888
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-4 gap-y-1 text-xs", children: [
889
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between", children: [
890
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "minute" }),
891
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: "0-59" })
892
- ] }),
893
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between", children: [
894
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "hour" }),
895
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: "0-23" })
896
- ] }),
897
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between", children: [
898
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "day" }),
899
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: "1-31" })
900
- ] }),
901
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between", children: [
902
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "month" }),
903
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: "1-12" })
904
- ] }),
905
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between col-span-2", children: [
906
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "weekday" }),
907
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: "0-6 (Sun-Sat)" })
908
- ] })
909
- ] }),
910
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pt-2 border-t border-border space-y-1.5", children: [
911
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs font-medium", children: "Special characters" }),
912
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-1.5 text-xs", children: [
913
- /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
914
- /* @__PURE__ */ jsxRuntime.jsx("code", { className: "bg-muted px-1 rounded", children: "*" }),
915
- " any value"
916
- ] }),
917
- /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
918
- /* @__PURE__ */ jsxRuntime.jsx("code", { className: "bg-muted px-1 rounded", children: "," }),
919
- " list (1,3,5)"
920
- ] }),
921
- /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
922
- /* @__PURE__ */ jsxRuntime.jsx("code", { className: "bg-muted px-1 rounded", children: "-" }),
923
- " range (1-5)"
924
- ] }),
925
- /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
926
- /* @__PURE__ */ jsxRuntime.jsx("code", { className: "bg-muted px-1 rounded", children: "/" }),
927
- " step (*/15)"
928
- ] })
929
- ] })
930
- ] }),
931
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pt-2 border-t border-border space-y-1.5", children: [
932
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs font-medium", children: "Examples" }),
933
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1 text-xs", children: [
934
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between font-mono", children: [
935
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "0 9 * * *" }),
936
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: "daily at 9am" })
937
- ] }),
938
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between font-mono", children: [
939
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "0 9 * * 1-5" }),
940
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: "weekdays 9am" })
941
- ] }),
942
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between font-mono", children: [
943
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "*/15 * * * *" }),
944
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: "every 15 min" })
945
- ] }),
946
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between font-mono", children: [
947
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "0 0 1 * *" }),
948
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: "1st of month" })
949
- ] })
950
- ] })
951
- ] })
952
- ] }) })
953
- ] });
954
- }
955
- chunkOLISEQHS_cjs.__name(CronCheatsheet, "CronCheatsheet");
956
- function SchedulePreview({
957
- showCronExpression = true,
958
- allowCopy = false,
959
- showInitialValue = true,
960
- className
961
- }) {
962
- const { cronExpression, humanDescription, isValid, initialValue } = useCronPreview();
963
- const hasChanged = react.useMemo(
964
- () => showInitialValue && initialValue && initialValue !== cronExpression,
965
- [showInitialValue, initialValue, cronExpression]
966
- );
967
- const [copied, setCopied] = react.useState(false);
968
- const handleCopy = react.useCallback(async () => {
969
- try {
970
- await navigator.clipboard.writeText(cronExpression);
971
- setCopied(true);
972
- setTimeout(() => setCopied(false), 2e3);
973
- } catch (err) {
974
- console.error("Failed to copy:", err);
975
- }
976
- }, [cronExpression]);
977
- return /* @__PURE__ */ jsxRuntime.jsxs(
978
- "div",
979
- {
980
- className: lib.cn(
981
- "px-3 py-2.5 rounded-lg border",
982
- "bg-muted/30 border-border/50",
983
- !isValid && "border-destructive/30 bg-destructive/5",
984
- className
985
- ),
986
- children: [
987
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-2", children: [
988
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 min-w-0", children: [
989
- /* @__PURE__ */ jsxRuntime.jsx(
990
- lucideReact.Calendar,
991
- {
992
- className: lib.cn(
993
- "h-4 w-4 shrink-0",
994
- isValid ? "text-primary" : "text-destructive"
995
- )
996
- }
997
- ),
998
- /* @__PURE__ */ jsxRuntime.jsx(
999
- "span",
1000
- {
1001
- className: lib.cn(
1002
- "text-sm",
1003
- isValid ? "text-foreground" : "text-destructive"
1004
- ),
1005
- children: humanDescription
1006
- }
1007
- )
1008
- ] }),
1009
- allowCopy && /* @__PURE__ */ jsxRuntime.jsx(
1010
- "button",
1011
- {
1012
- type: "button",
1013
- onClick: handleCopy,
1014
- disabled: !isValid,
1015
- className: lib.cn(
1016
- "p-1 rounded transition-colors duration-150",
1017
- "hover:bg-muted focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",
1018
- "disabled:opacity-50 disabled:cursor-not-allowed"
1019
- ),
1020
- title: copied ? "Copied!" : "Copy cron expression",
1021
- children: copied ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-3.5 w-3.5 text-green-500" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Copy, { className: "h-3.5 w-3.5 text-muted-foreground" })
1022
- }
1023
- )
1024
- ] }),
1025
- showCronExpression && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-1.5 pt-1.5 border-t border-border/30 flex items-center justify-between", children: [
1026
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5 min-w-0", children: [
1027
- hasChanged && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1028
- /* @__PURE__ */ jsxRuntime.jsx("code", { className: "text-xs font-mono text-muted-foreground/60 line-through", children: initialValue }),
1029
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowRight, { className: "h-3 w-3 text-muted-foreground/40 shrink-0" })
1030
- ] }),
1031
- /* @__PURE__ */ jsxRuntime.jsx("code", { className: "text-xs font-mono text-muted-foreground", children: cronExpression })
1032
- ] }),
1033
- /* @__PURE__ */ jsxRuntime.jsx(CronCheatsheet, {})
1034
- ] })
1035
- ]
1036
- }
1037
- );
1038
- }
1039
- chunkOLISEQHS_cjs.__name(SchedulePreview, "SchedulePreview");
1040
-
1041
- exports.CronSchedulerProvider = CronSchedulerProvider;
1042
- exports.CustomInput = CustomInput;
1043
- exports.DayChips = DayChips;
1044
- exports.MonthDayGrid = MonthDayGrid;
1045
- exports.SchedulePreview = SchedulePreview;
1046
- exports.ScheduleTypeSelector = ScheduleTypeSelector;
1047
- exports.TimeSelector = TimeSelector;
1048
- exports.buildCron = buildCron;
1049
- exports.humanizeCron = humanizeCron;
1050
- exports.isValidCron = isValidCron;
1051
- exports.parseCron = parseCron;
1052
- exports.useCronCustom = useCronCustom;
1053
- exports.useCronMonthDays = useCronMonthDays;
1054
- exports.useCronPreview = useCronPreview;
1055
- exports.useCronScheduler = useCronScheduler;
1056
- exports.useCronSchedulerContext = useCronSchedulerContext;
1057
- exports.useCronTime = useCronTime;
1058
- exports.useCronType = useCronType;
1059
- exports.useCronWeekDays = useCronWeekDays;
1060
- //# sourceMappingURL=chunk-76NNDZH6.cjs.map
1061
- //# sourceMappingURL=chunk-76NNDZH6.cjs.map