UNPKG

crontab-react

Version:
1,053 lines (1,049 loc) 34.1 kB
import Je, { useState as L, useEffect as Te } from "react"; import z from "react-select"; import re from "prop-types"; var _e = { exports: {} }, te = {}; /** * @license React * react-jsx-runtime.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var Ie; function Rr() { if (Ie) return te; Ie = 1; var g = Je, y = Symbol.for("react.element"), C = Symbol.for("react.fragment"), O = Object.prototype.hasOwnProperty, _ = g.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, P = { key: !0, ref: !0, __self: !0, __source: !0 }; function W(N, l, j) { var k, F = {}, w = null, B = null; j !== void 0 && (w = "" + j), l.key !== void 0 && (w = "" + l.key), l.ref !== void 0 && (B = l.ref); for (k in l) O.call(l, k) && !P.hasOwnProperty(k) && (F[k] = l[k]); if (N && N.defaultProps) for (k in l = N.defaultProps, l) F[k] === void 0 && (F[k] = l[k]); return { $$typeof: y, type: N, key: w, ref: B, props: F, _owner: _.current }; } return te.Fragment = C, te.jsx = W, te.jsxs = W, te; } var ne = {}; /** * @license React * react-jsx-runtime.development.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var Ne; function Sr() { return Ne || (Ne = 1, process.env.NODE_ENV !== "production" && function() { var g = Je, y = Symbol.for("react.element"), C = Symbol.for("react.portal"), O = Symbol.for("react.fragment"), _ = Symbol.for("react.strict_mode"), P = Symbol.for("react.profiler"), W = Symbol.for("react.provider"), N = Symbol.for("react.context"), l = Symbol.for("react.forward_ref"), j = Symbol.for("react.suspense"), k = Symbol.for("react.suspense_list"), F = Symbol.for("react.memo"), w = Symbol.for("react.lazy"), B = Symbol.for("react.offscreen"), U = Symbol.iterator, V = "@@iterator"; function K(e) { if (e === null || typeof e != "object") return null; var r = U && e[U] || e[V]; return typeof r == "function" ? r : null; } var A = g.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; function E(e) { { for (var r = arguments.length, t = new Array(r > 1 ? r - 1 : 0), s = 1; s < r; s++) t[s - 1] = arguments[s]; H("error", e, t); } } function H(e, r, t) { { var s = A.ReactDebugCurrentFrame, f = s.getStackAddendum(); f !== "" && (r += "%s", t = t.concat([f])); var h = t.map(function(u) { return String(u); }); h.unshift("Warning: " + r), Function.prototype.apply.call(console[e], console, h); } } var X = !1, ae = !1, de = !1, oe = !1, se = !1, Z; Z = Symbol.for("react.module.reference"); function ve(e) { return !!(typeof e == "string" || typeof e == "function" || e === O || e === P || se || e === _ || e === j || e === k || oe || e === B || X || ae || de || typeof e == "object" && e !== null && (e.$$typeof === w || e.$$typeof === F || e.$$typeof === W || e.$$typeof === N || e.$$typeof === l || // This needs to include all possible module reference object // types supported by any Flight configuration anywhere since // we don't know which Flight build this will end up being used // with. e.$$typeof === Z || e.getModuleId !== void 0)); } function n(e, r, t) { var s = e.displayName; if (s) return s; var f = r.displayName || r.name || ""; return f !== "" ? t + "(" + f + ")" : t; } function a(e) { return e.displayName || "Context"; } function o(e) { if (e == null) return null; if (typeof e.tag == "number" && E("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function") return e.displayName || e.name || null; if (typeof e == "string") return e; switch (e) { case O: return "Fragment"; case C: return "Portal"; case P: return "Profiler"; case _: return "StrictMode"; case j: return "Suspense"; case k: return "SuspenseList"; } if (typeof e == "object") switch (e.$$typeof) { case N: var r = e; return a(r) + ".Consumer"; case W: var t = e; return a(t._context) + ".Provider"; case l: return n(e, e.render, "ForwardRef"); case F: var s = e.displayName || null; return s !== null ? s : o(e.type) || "Memo"; case w: { var f = e, h = f._payload, u = f._init; try { return o(u(h)); } catch { return null; } } } return null; } var c = Object.assign, v = 0, p, R, T, S, I, M, J; function Q() { } Q.__reactDisabledLog = !0; function Qe() { { if (v === 0) { p = console.log, R = console.info, T = console.warn, S = console.error, I = console.group, M = console.groupCollapsed, J = console.groupEnd; var e = { configurable: !0, enumerable: !0, value: Q, writable: !0 }; Object.defineProperties(console, { info: e, log: e, warn: e, error: e, group: e, groupCollapsed: e, groupEnd: e }); } v++; } } function er() { { if (v--, v === 0) { var e = { configurable: !0, enumerable: !0, writable: !0 }; Object.defineProperties(console, { log: c({}, e, { value: p }), info: c({}, e, { value: R }), warn: c({}, e, { value: T }), error: c({}, e, { value: S }), group: c({}, e, { value: I }), groupCollapsed: c({}, e, { value: M }), groupEnd: c({}, e, { value: J }) }); } v < 0 && E("disabledDepth fell below zero. This is a bug in React. Please file an issue."); } } var he = A.ReactCurrentDispatcher, pe; function le(e, r, t) { { if (pe === void 0) try { throw Error(); } catch (f) { var s = f.stack.trim().match(/\n( *(at )?)/); pe = s && s[1] || ""; } return ` ` + pe + e; } } var ye = !1, ie; { var rr = typeof WeakMap == "function" ? WeakMap : Map; ie = new rr(); } function Re(e, r) { if (!e || ye) return ""; { var t = ie.get(e); if (t !== void 0) return t; } var s; ye = !0; var f = Error.prepareStackTrace; Error.prepareStackTrace = void 0; var h; h = he.current, he.current = null, Qe(); try { if (r) { var u = function() { throw Error(); }; if (Object.defineProperty(u.prototype, "props", { set: function() { throw Error(); } }), typeof Reflect == "object" && Reflect.construct) { try { Reflect.construct(u, []); } catch (Y) { s = Y; } Reflect.construct(e, [], u); } else { try { u.call(); } catch (Y) { s = Y; } e.call(u.prototype); } } else { try { throw Error(); } catch (Y) { s = Y; } e(); } } catch (Y) { if (Y && s && typeof Y.stack == "string") { for (var i = Y.stack.split(` `), x = s.stack.split(` `), m = i.length - 1, b = x.length - 1; m >= 1 && b >= 0 && i[m] !== x[b]; ) b--; for (; m >= 1 && b >= 0; m--, b--) if (i[m] !== x[b]) { if (m !== 1 || b !== 1) do if (m--, b--, b < 0 || i[m] !== x[b]) { var $ = ` ` + i[m].replace(" at new ", " at "); return e.displayName && $.includes("<anonymous>") && ($ = $.replace("<anonymous>", e.displayName)), typeof e == "function" && ie.set(e, $), $; } while (m >= 1 && b >= 0); break; } } } finally { ye = !1, he.current = h, er(), Error.prepareStackTrace = f; } var G = e ? e.displayName || e.name : "", De = G ? le(G) : ""; return typeof e == "function" && ie.set(e, De), De; } function tr(e, r, t) { return Re(e, !1); } function nr(e) { var r = e.prototype; return !!(r && r.isReactComponent); } function ue(e, r, t) { if (e == null) return ""; if (typeof e == "function") return Re(e, nr(e)); if (typeof e == "string") return le(e); switch (e) { case j: return le("Suspense"); case k: return le("SuspenseList"); } if (typeof e == "object") switch (e.$$typeof) { case l: return tr(e.render); case F: return ue(e.type, r, t); case w: { var s = e, f = s._payload, h = s._init; try { return ue(h(f), r, t); } catch { } } } return ""; } var ce = Object.prototype.hasOwnProperty, Se = {}, Ce = A.ReactDebugCurrentFrame; function fe(e) { if (e) { var r = e._owner, t = ue(e.type, e._source, r ? r.type : null); Ce.setExtraStackFrame(t); } else Ce.setExtraStackFrame(null); } function ar(e, r, t, s, f) { { var h = Function.call.bind(ce); for (var u in e) if (h(e, u)) { var i = void 0; try { if (typeof e[u] != "function") { var x = Error((s || "React class") + ": " + t + " type `" + u + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[u] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`."); throw x.name = "Invariant Violation", x; } i = e[u](r, u, s, t, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"); } catch (m) { i = m; } i && !(i instanceof Error) && (fe(f), E("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", s || "React class", t, u, typeof i), fe(null)), i instanceof Error && !(i.message in Se) && (Se[i.message] = !0, fe(f), E("Failed %s type: %s", t, i.message), fe(null)); } } } var or = Array.isArray; function me(e) { return or(e); } function sr(e) { { var r = typeof Symbol == "function" && Symbol.toStringTag, t = r && e[Symbol.toStringTag] || e.constructor.name || "Object"; return t; } } function lr(e) { try { return je(e), !1; } catch { return !0; } } function je(e) { return "" + e; } function ke(e) { if (lr(e)) return E("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", sr(e)), je(e); } var ee = A.ReactCurrentOwner, ir = { key: !0, ref: !0, __self: !0, __source: !0 }, we, xe, ge; ge = {}; function ur(e) { if (ce.call(e, "ref")) { var r = Object.getOwnPropertyDescriptor(e, "ref").get; if (r && r.isReactWarning) return !1; } return e.ref !== void 0; } function cr(e) { if (ce.call(e, "key")) { var r = Object.getOwnPropertyDescriptor(e, "key").get; if (r && r.isReactWarning) return !1; } return e.key !== void 0; } function fr(e, r) { if (typeof e.ref == "string" && ee.current && r && ee.current.stateNode !== r) { var t = o(ee.current.type); ge[t] || (E('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', o(ee.current.type), e.ref), ge[t] = !0); } } function dr(e, r) { { var t = function() { we || (we = !0, E("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r)); }; t.isReactWarning = !0, Object.defineProperty(e, "key", { get: t, configurable: !0 }); } } function vr(e, r) { { var t = function() { xe || (xe = !0, E("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r)); }; t.isReactWarning = !0, Object.defineProperty(e, "ref", { get: t, configurable: !0 }); } } var hr = function(e, r, t, s, f, h, u) { var i = { // This tag allows us to uniquely identify this as a React Element $$typeof: y, // Built-in properties that belong on the element type: e, key: r, ref: t, props: u, // Record the component responsible for creating this element. _owner: h }; return i._store = {}, Object.defineProperty(i._store, "validated", { configurable: !1, enumerable: !1, writable: !0, value: !1 }), Object.defineProperty(i, "_self", { configurable: !1, enumerable: !1, writable: !1, value: s }), Object.defineProperty(i, "_source", { configurable: !1, enumerable: !1, writable: !1, value: f }), Object.freeze && (Object.freeze(i.props), Object.freeze(i)), i; }; function pr(e, r, t, s, f) { { var h, u = {}, i = null, x = null; t !== void 0 && (ke(t), i = "" + t), cr(r) && (ke(r.key), i = "" + r.key), ur(r) && (x = r.ref, fr(r, f)); for (h in r) ce.call(r, h) && !ir.hasOwnProperty(h) && (u[h] = r[h]); if (e && e.defaultProps) { var m = e.defaultProps; for (h in m) u[h] === void 0 && (u[h] = m[h]); } if (i || x) { var b = typeof e == "function" ? e.displayName || e.name || "Unknown" : e; i && dr(u, b), x && vr(u, b); } return hr(e, i, x, f, s, ee.current, u); } } var be = A.ReactCurrentOwner, Pe = A.ReactDebugCurrentFrame; function q(e) { if (e) { var r = e._owner, t = ue(e.type, e._source, r ? r.type : null); Pe.setExtraStackFrame(t); } else Pe.setExtraStackFrame(null); } var Oe; Oe = !1; function Ee(e) { return typeof e == "object" && e !== null && e.$$typeof === y; } function Me() { { if (be.current) { var e = o(be.current.type); if (e) return ` Check the render method of \`` + e + "`."; } return ""; } } function yr(e) { { if (e !== void 0) { var r = e.fileName.replace(/^.*[\\\/]/, ""), t = e.lineNumber; return ` Check your code at ` + r + ":" + t + "."; } return ""; } } var Fe = {}; function mr(e) { { var r = Me(); if (!r) { var t = typeof e == "string" ? e : e.displayName || e.name; t && (r = ` Check the top-level render call using <` + t + ">."); } return r; } } function Ae(e, r) { { if (!e._store || e._store.validated || e.key != null) return; e._store.validated = !0; var t = mr(r); if (Fe[t]) return; Fe[t] = !0; var s = ""; e && e._owner && e._owner !== be.current && (s = " It was passed a child from " + o(e._owner.type) + "."), q(e), E('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', t, s), q(null); } } function We(e, r) { { if (typeof e != "object") return; if (me(e)) for (var t = 0; t < e.length; t++) { var s = e[t]; Ee(s) && Ae(s, r); } else if (Ee(e)) e._store && (e._store.validated = !0); else if (e) { var f = K(e); if (typeof f == "function" && f !== e.entries) for (var h = f.call(e), u; !(u = h.next()).done; ) Ee(u.value) && Ae(u.value, r); } } } function gr(e) { { var r = e.type; if (r == null || typeof r == "string") return; var t; if (typeof r == "function") t = r.propTypes; else if (typeof r == "object" && (r.$$typeof === l || // Note: Memo only checks outer props here. // Inner props are checked in the reconciler. r.$$typeof === F)) t = r.propTypes; else return; if (t) { var s = o(r); ar(t, e.props, "prop", s, e); } else if (r.PropTypes !== void 0 && !Oe) { Oe = !0; var f = o(r); E("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", f || "Unknown"); } typeof r.getDefaultProps == "function" && !r.getDefaultProps.isReactClassApproved && E("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead."); } } function br(e) { { for (var r = Object.keys(e.props), t = 0; t < r.length; t++) { var s = r[t]; if (s !== "children" && s !== "key") { q(e), E("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", s), q(null); break; } } e.ref !== null && (q(e), E("Invalid attribute `ref` supplied to `React.Fragment`."), q(null)); } } function $e(e, r, t, s, f, h) { { var u = ve(e); if (!u) { var i = ""; (e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (i += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."); var x = yr(f); x ? i += x : i += Me(); var m; e === null ? m = "null" : me(e) ? m = "array" : e !== void 0 && e.$$typeof === y ? (m = "<" + (o(e.type) || "Unknown") + " />", i = " Did you accidentally export a JSX literal instead of a component?") : m = typeof e, E("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", m, i); } var b = pr(e, r, t, f, h); if (b == null) return b; if (u) { var $ = r.children; if ($ !== void 0) if (s) if (me($)) { for (var G = 0; G < $.length; G++) We($[G], e); Object.freeze && Object.freeze($); } else E("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."); else We($, e); } return e === O ? br(b) : gr(b), b; } } function Or(e, r, t) { return $e(e, r, t, !0); } function Er(e, r, t) { return $e(e, r, t, !1); } var Tr = Er, _r = Or; ne.Fragment = O, ne.jsx = Tr, ne.jsxs = _r; }()), ne; } process.env.NODE_ENV === "production" ? _e.exports = Rr() : _e.exports = Sr(); var d = _e.exports; function Ve(g) { let y = [], C = g[0], O = g[0]; for (let _ = 1; _ < g.length; _++) g[_] - g[_ - 1] === 1 || (y.push(C !== O ? `${C}-${O}` : `${C}`), C = g[_]), O = g[_]; return y.push(C !== O ? `${C}-${O}` : `${C}`), y.join(","); } const Le = (g, y, C) => Array.from({ length: (y - g) / C + 1 }, (O, _) => g + _ * C), Cr = [ { value: "year", label: "Year" }, { value: "month", label: "Month" }, { value: "week", label: "Week" }, { value: "day", label: "Day" }, { value: "hour", label: "Hour" }, { value: "minute", label: "Minute" } ], qe = [ { value: 1, label: "January" }, { value: 2, label: "February" }, { value: 3, label: "March" }, { value: 4, label: "April" }, { value: 5, label: "May" }, { value: 6, label: "June" }, { value: 7, label: "July" }, { value: 8, label: "August" }, { value: 9, label: "September" }, { value: 10, label: "October" }, { value: 11, label: "November" }, { value: 12, label: "December" } ], Ge = new Array(32).fill(1, 1).map((g, y) => ({ value: y, label: y.toString() })), ze = [ { value: 1, label: "Monday" }, { value: 2, label: "Tuesday" }, { value: 3, label: "Wednesday" }, { value: 4, label: "Thursday" }, { value: 5, label: "Friday" }, { value: 6, label: "Saturday" }, { value: 7, label: "Sunday" } ], Ke = new Array(24).fill(1).map((g, y) => ({ value: y, label: y.toString() })), Xe = new Array(60).fill(1).map((g, y) => ({ value: y, label: y.toString() })), Ye = { minutes: "*", hours: "*", months: "*", daysOfTheMonth: "*", daysOfTheWeek: "*" }, jr = /[a-z]/i, D = { minutes: [], hours: [], months: [], daysOfTheMonth: [], daysOfTheWeek: [] }, Ue = { 0: "minutes", 1: "hours", 2: "daysOfTheMonth", 3: "months", 4: "daysOfTheWeek" }, Be = { 0: Xe, 1: Ke, 2: Ge, 3: qe, 4: ze }, He = "* * * * *"; function Ze(g) { const { shortSelectedOptions: y = !0, invalidCronStringErrorMessage: C = "", value: O = "", onChange: _ = () => { }, disabled: P = !1 } = g, [W, N] = L({ value: "minute", label: "Minute" }), [l, j] = L(Ye), [k, F] = L(O || He); L(""), L(""), L(""), L(""), L(""); const [w, B] = L({}), [U, V] = L(D); Te(() => { F( `${l.minutes} ${l.hours} ${l.daysOfTheMonth} ${l.months} ${l.daysOfTheWeek}` ); }, [l]), Te(() => { _ && _({ value: `${l.minutes} ${l.hours} ${l.daysOfTheMonth} ${l.months} ${l.daysOfTheWeek}`, error: !!w.cronString, minutes: l.minutes, hours: l.hours, daysOfTheMonth: l.daysOfTheMonth, months: l.months, daysOfTheWeek: l.daysOfTheWeek }); }, [ w, l.months, l.minutes, l.hours, l.daysOfTheWeek, l.daysOfTheMonth ]), Te(() => { O && (F(O), Z(O)); }, []); const K = (n = "transparent") => ({ alignItems: "center", display: "flex", ":before": { backgroundColor: n, borderRadius: 10, content: '" "', display: "block", marginRight: 8, height: 10, width: 10 } }), A = { control: (n) => ({ ...n, backgroundColor: "white" }), option: (n, { data: a, isDisabled: o, isFocused: c, isSelected: v }) => ({ ...n, backgroundColor: o ? void 0 : v ? "#E9F5FF " : c ? "#f2f2f2" : void 0, color: o ? "#ccc" : "black", cursor: o ? "not-allowed" : "default", ":active": { ...n[":active"], backgroundColor: o ? void 0 : v ? "#1e99fa" : "grey" } }), input: (n) => ({ ...n, ...K() }), placeholder: (n) => ({ ...n, ...K("#ccc") }), singleValue: (n, { data: a }) => ({ ...n, ...K("grey") }), multiValueRemove: (n, { data: a }) => ({ ...n, color: "#666" }) }, E = ({ value: n, label: a }, { context: o }) => o === "menu" ? /* @__PURE__ */ d.jsx("div", { style: { display: "flex" }, children: /* @__PURE__ */ d.jsx("div", { style: { marginLeft: "4px" }, children: a }) }) : /* @__PURE__ */ d.jsx("div", { style: { display: "flex" }, children: /* @__PURE__ */ d.jsx("div", { style: { marginLeft: "4px" }, children: a.substring(0, 3) }) }), H = (n, a) => { if (n.length > 0) { const c = [...n].sort( (p, R) => p.value - R.value ).map( (p) => p.value ), v = Ve(c); V((p) => ({ ...p, [a]: n })), j((p) => ({ ...p, [a]: v })); } else V((o) => ({ ...o, [a]: "*" })), j((o) => ({ ...o, [a]: "*" })); }, X = (n, a) => a === 0 ? n.every((o) => o >= 0 && o <= 59) : a === 1 ? n.every((o) => o >= 0 && o <= 23) : a === 2 ? n.every((o) => o >= 1 && o <= 31) : a === 3 ? n.every((o) => o >= 1 && o <= 12) : a === 4 ? n.every((o) => o >= 1 && o <= 7) : !1, ae = (n, a) => { const o = n.split("-"), c = Number(o[0]), v = Number(o[1]); if (o.length !== 2) return !1; if (c === "" || v === "") return !1; if (c >= v) return !1; const p = Le(c, v, 1); return X(p, a); }, de = (n) => { if (n === He) return !0; if (jr.test(n)) return !1; const a = n.split(" "); return a.length !== 5 ? !1 : a.every((c, v) => c.includes(",") ? c.split(",").every((R) => R.includes("-") ? ae(R, v) : X([R], v)) : c.includes("-") ? ae(c, v) : c === "*" ? !0 : X([c], v)); }, oe = (n, a) => { const o = n.split("-"), c = Le( Number(o[0]), Number(o[1]), 1 ), v = Be[a].filter( (T) => c.includes(T.value) ), p = v.map((T) => T.value), R = Ve(p); return { selectedOptions: v, cronStringForField: R }; }, se = (n, a) => Be[a].filter( (c) => c.value === Number(n) ), Z = (n) => { const a = n.trim(); if (!de(a)) { B({ ...w, cronString: C || "Crontab String is Invalid" }); return; } B({ ...w, cronString: void 0 }); const c = a.split(" "); let v = { value: "minute", label: "Minute" }; c.forEach((p, R) => { let T = [], S = ""; if (p.includes(",")) p.split(",").forEach((M) => { if (M.includes("-")) { const { selectedOptions: J, cronStringForField: Q } = oe(M, R); T = [ ...T, ...J ], S = S ? `${S},${Q}` : Q; } else { if (M === "*" || M !== "0" && !Number(M)) return; const J = se(M, R); T = [ ...T, ...J ], S = S ? `${S},${M}` : M; } }); else if (p.includes("-")) { const { selectedOptions: I, cronStringForField: M } = oe(p, R); T = [ ...T, ...I ], S = S ? `${S},${M}` : M; } else if (p === "*") T = [...T], S = "*"; else if (Number(p) || Number(p) === 0) { const I = se(p, R); T = [ ...T, ...I ], S = S ? `${S},${p}` : p; } else return; V((I) => ({ ...I, [Ue[R]]: T })), j((I) => ({ ...I, [Ue[R]]: S })); }), c[3] !== "*" ? v = { value: "year", label: "Year" } : c[2] !== "*" ? v = { value: "month", label: "Month" } : c[4] !== "*" ? v = { value: "week", label: "Week" } : c[1] !== "*" ? v = { value: "day", label: "Day" } : c[0] !== "*" && (v = { value: "hour", label: "Hour" }), N(v); }, ve = (n) => { N(n), n.value === "minute" ? (j(Ye), V(D)) : n.value === "month" ? (j((a) => ({ ...a, months: "*" })), V((a) => ({ ...a, months: D.months }))) : n.value === "week" ? (j((a) => ({ ...a, months: "*", daysOfTheWeek: "*" })), V((a) => ({ ...a, months: D.months, daysOfTheWeek: D.daysOfTheWeek }))) : n.value === "day" ? (j((a) => ({ ...a, months: "*", daysOfTheWeek: "*", daysOfTheMonth: "*" })), V((a) => ({ ...a, months: D.months, daysOfTheWeek: D.daysOfTheWeek, daysOfTheMonth: D.daysOfTheMonth }))) : n.value === "hour" && (j((a) => ({ ...a, months: "*", daysOfTheWeek: "*", daysOfTheMonth: "*", hours: "*" })), V((a) => ({ ...a, months: D.months, daysOfTheWeek: D.daysOfTheWeek, daysOfTheMonth: D.daysOfTheMonth, hours: D.hours }))); }; return /* @__PURE__ */ d.jsxs("div", { className: "cr cr-container", children: [ /* @__PURE__ */ d.jsx( "input", { type: "text", value: k, className: `cr-container-cron-input ${w.cronString && "cr-has-error"}`, onChange: (n) => { P || F(n.target.value); }, onBlur: (n) => { P || Z(n.target.value); }, style: { width: "400px" }, disabled: P } ), w.cronString && /* @__PURE__ */ d.jsx("span", { className: "cr-error-text", children: w.cronString }), /* @__PURE__ */ d.jsxs("div", { className: "cr-container-field", children: [ /* @__PURE__ */ d.jsx("span", { children: "Period" }), /* @__PURE__ */ d.jsx( z, { options: Cr, onChange: ve, name: "period", value: W, styles: A, menuShouldScrollIntoView: !1, className: "cr-container-field-period", isDisabled: P } ) ] }), ["year"].includes(W.value) && /* @__PURE__ */ d.jsxs("div", { className: "cr-container-field cr-container-field-month", children: [ /* @__PURE__ */ d.jsx("span", { children: "Month" }), /* @__PURE__ */ d.jsx( z, { options: qe, onChange: (n) => H(n, "months"), name: "months", styles: A, isMulti: !0, delimiter: ",", menuShouldScrollIntoView: !1, placeholder: /* @__PURE__ */ d.jsx("div", { children: "Every month" }), cropWithEllipsis: !0, closeMenuOnSelect: !1, value: U.months, ...y ? { formatOptionLabel: E } : {}, isDisabled: P } ) ] }), ["year", "month"].includes(W.value) && /* @__PURE__ */ d.jsxs("div", { className: "cr-container-field", children: [ /* @__PURE__ */ d.jsx("span", { children: "Days of the Month" }), /* @__PURE__ */ d.jsx( z, { options: Ge, onChange: (n) => H(n, "daysOfTheMonth"), styles: A, menuShouldScrollIntoView: !1, isMulti: !0, name: "daysOfTheMonth", placeholder: /* @__PURE__ */ d.jsx("div", { children: "Every day of the month" }), value: U.daysOfTheMonth, closeMenuOnSelect: !1, isDisabled: P } ) ] }), ["year", "month", "week"].includes(W.value) && /* @__PURE__ */ d.jsxs("div", { className: "cr-container-field", children: [ /* @__PURE__ */ d.jsx("span", { children: "Days of the Week" }), /* @__PURE__ */ d.jsx( z, { options: ze, onChange: (n) => H(n, "daysOfTheWeek"), name: "daysOfTheWeek", styles: A, menuShouldScrollIntoView: !1, isMulti: !0, placeholder: /* @__PURE__ */ d.jsx("div", { children: "Every day of the week" }), value: U.daysOfTheWeek, closeMenuOnSelect: !1, ...y ? { formatOptionLabel: E } : {}, isDisabled: P } ) ] }), ["year", "month", "week", "day"].includes(W.value) && /* @__PURE__ */ d.jsxs("div", { className: "cr-container-field", children: [ /* @__PURE__ */ d.jsx("span", { children: "Hour" }), /* @__PURE__ */ d.jsx( z, { options: Ke, onChange: (n) => H(n, "hours"), name: "hours", styles: A, menuShouldScrollIntoView: !1, isMulti: !0, placeholder: /* @__PURE__ */ d.jsx("div", { children: "Every Hour" }), value: U.hours, closeMenuOnSelect: !1, isDisabled: P } ) ] }), ["year", "month", "week", "day", "hour"].includes(W.value) && /* @__PURE__ */ d.jsxs("div", { className: "cr-container-field", children: [ /* @__PURE__ */ d.jsx("span", { children: "Minutes" }), /* @__PURE__ */ d.jsx( z, { options: Xe, onChange: (n) => H(n, "minutes"), name: "minutes", styles: A, menuShouldScrollIntoView: !1, isMulti: !0, placeholder: /* @__PURE__ */ d.jsx("div", { children: "Every Minute" }), value: U.minutes, closeMenuOnSelect: !1, isDisabled: P } ) ] }) ] }); } Ze.propTypes = { value: re.string, invalidCronStringErrorMessage: re.string, shortSelectedOptions: re.bool, onChange: re.func, disabled: re.bool }; Ze.defaultProps = { value: "", invalidCronStringErrorMessage: "", shortSelectedOptions: !0, onChange: () => { }, disabled: !1 }; export { Ze as Crontab, Ze as default };