@djangocfg/ui-tools 2.1.130 → 2.1.132

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