simple-chakra-ui-datepicker
Version:
This is a package inspired on the necesity to use a datepicker for [Chakra UI](https://v1.chakra-ui.com/faq#is-there-a-datepicker-in-chakra-ui).
945 lines (941 loc) • 30.3 kB
JavaScript
import Ke, { useState as me, useEffect as br } from "react";
import { Box as Z, Text as yr, Select as Xe, Flex as Ze, IconButton as ze, useDisclosure as mr, Popover as _r, PopoverTrigger as Er, Input as Rr, PopoverContent as xr, PopoverArrow as Tr, PopoverCloseButton as Cr, PopoverBody as jr, PopoverFooter as wr, Button as Je } from "@chakra-ui/react";
import { ChevronRightIcon as Sr, ChevronLeftIcon as Pr, CalendarIcon as Or } from "@chakra-ui/icons";
var Ae = { exports: {} }, se = {};
/**
* @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 qe;
function kr() {
if (qe)
return se;
qe = 1;
var l = Ke, s = Symbol.for("react.element"), y = Symbol.for("react.fragment"), _ = Object.prototype.hasOwnProperty, E = l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, m = { key: !0, ref: !0, __self: !0, __source: !0 };
function j(T, d, b) {
var p, R = {}, F = null, U = null;
b !== void 0 && (F = "" + b), d.key !== void 0 && (F = "" + d.key), d.ref !== void 0 && (U = d.ref);
for (p in d)
_.call(d, p) && !m.hasOwnProperty(p) && (R[p] = d[p]);
if (T && T.defaultProps)
for (p in d = T.defaultProps, d)
R[p] === void 0 && (R[p] = d[p]);
return { $$typeof: s, type: T, key: F, ref: U, props: R, _owner: E.current };
}
return se.Fragment = y, se.jsx = j, se.jsxs = j, se;
}
var ue = {};
/**
* @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 Ge;
function Dr() {
return Ge || (Ge = 1, process.env.NODE_ENV !== "production" && function() {
var l = Ke, s = Symbol.for("react.element"), y = Symbol.for("react.portal"), _ = Symbol.for("react.fragment"), E = Symbol.for("react.strict_mode"), m = Symbol.for("react.profiler"), j = Symbol.for("react.provider"), T = Symbol.for("react.context"), d = Symbol.for("react.forward_ref"), b = Symbol.for("react.suspense"), p = Symbol.for("react.suspense_list"), R = Symbol.for("react.memo"), F = Symbol.for("react.lazy"), U = Symbol.for("react.offscreen"), le = Symbol.iterator, _e = "@@iterator";
function Ee(e) {
if (e === null || typeof e != "object")
return null;
var r = le && e[le] || e[_e];
return typeof r == "function" ? r : null;
}
var O = l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
function v(e) {
{
for (var r = arguments.length, t = new Array(r > 1 ? r - 1 : 0), n = 1; n < r; n++)
t[n - 1] = arguments[n];
Q("error", e, t);
}
}
function Q(e, r, t) {
{
var n = O.ReactDebugCurrentFrame, c = n.getStackAddendum();
c !== "" && (r += "%s", t = t.concat([c]));
var f = t.map(function(u) {
return String(u);
});
f.unshift("Warning: " + r), Function.prototype.apply.call(console[e], console, f);
}
}
var ce = !1, Re = !1, fe = !1, xe = !1, B = !1, V;
V = Symbol.for("react.module.reference");
function de(e) {
return !!(typeof e == "string" || typeof e == "function" || e === _ || e === m || B || e === E || e === b || e === p || xe || e === U || ce || Re || fe || typeof e == "object" && e !== null && (e.$$typeof === F || e.$$typeof === R || e.$$typeof === j || e.$$typeof === T || e.$$typeof === d || // 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 === V || e.getModuleId !== void 0));
}
function ee(e, r, t) {
var n = e.displayName;
if (n)
return n;
var c = r.displayName || r.name || "";
return c !== "" ? t + "(" + c + ")" : t;
}
function ve(e) {
return e.displayName || "Context";
}
function w(e) {
if (e == null)
return null;
if (typeof e.tag == "number" && v("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 _:
return "Fragment";
case y:
return "Portal";
case m:
return "Profiler";
case E:
return "StrictMode";
case b:
return "Suspense";
case p:
return "SuspenseList";
}
if (typeof e == "object")
switch (e.$$typeof) {
case T:
var r = e;
return ve(r) + ".Consumer";
case j:
var t = e;
return ve(t._context) + ".Provider";
case d:
return ee(e, e.render, "ForwardRef");
case R:
var n = e.displayName || null;
return n !== null ? n : w(e.type) || "Memo";
case F: {
var c = e, f = c._payload, u = c._init;
try {
return w(u(f));
} catch {
return null;
}
}
}
return null;
}
var k = Object.assign, $ = 0, L, A, pe, re, D, z, I;
function J() {
}
J.__reactDisabledLog = !0;
function Te() {
{
if ($ === 0) {
L = console.log, A = console.info, pe = console.warn, re = console.error, D = console.group, z = console.groupCollapsed, I = console.groupEnd;
var e = {
configurable: !0,
enumerable: !0,
value: J,
writable: !0
};
Object.defineProperties(console, {
info: e,
log: e,
warn: e,
error: e,
group: e,
groupCollapsed: e,
groupEnd: e
});
}
$++;
}
}
function Ce() {
{
if ($--, $ === 0) {
var e = {
configurable: !0,
enumerable: !0,
writable: !0
};
Object.defineProperties(console, {
log: k({}, e, {
value: L
}),
info: k({}, e, {
value: A
}),
warn: k({}, e, {
value: pe
}),
error: k({}, e, {
value: re
}),
group: k({}, e, {
value: D
}),
groupCollapsed: k({}, e, {
value: z
}),
groupEnd: k({}, e, {
value: I
})
});
}
$ < 0 && v("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
}
}
var te = O.ReactCurrentDispatcher, ne;
function q(e, r, t) {
{
if (ne === void 0)
try {
throw Error();
} catch (c) {
var n = c.stack.trim().match(/\n( *(at )?)/);
ne = n && n[1] || "";
}
return `
` + ne + e;
}
}
var ae = !1, M;
{
var je = typeof WeakMap == "function" ? WeakMap : Map;
M = new je();
}
function ge(e, r) {
if (!e || ae)
return "";
{
var t = M.get(e);
if (t !== void 0)
return t;
}
var n;
ae = !0;
var c = Error.prepareStackTrace;
Error.prepareStackTrace = void 0;
var f;
f = te.current, te.current = null, Te();
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) {
n = Y;
}
Reflect.construct(e, [], u);
} else {
try {
u.call();
} catch (Y) {
n = Y;
}
e.call(u.prototype);
}
} else {
try {
throw Error();
} catch (Y) {
n = Y;
}
e();
}
} catch (Y) {
if (Y && n && typeof Y.stack == "string") {
for (var o = Y.stack.split(`
`), x = n.stack.split(`
`), g = o.length - 1, h = x.length - 1; g >= 1 && h >= 0 && o[g] !== x[h]; )
h--;
for (; g >= 1 && h >= 0; g--, h--)
if (o[g] !== x[h]) {
if (g !== 1 || h !== 1)
do
if (g--, h--, h < 0 || o[g] !== x[h]) {
var C = `
` + o[g].replace(" at new ", " at ");
return e.displayName && C.includes("<anonymous>") && (C = C.replace("<anonymous>", e.displayName)), typeof e == "function" && M.set(e, C), C;
}
while (g >= 1 && h >= 0);
break;
}
}
} finally {
ae = !1, te.current = f, Ce(), Error.prepareStackTrace = c;
}
var X = e ? e.displayName || e.name : "", Be = X ? q(X) : "";
return typeof e == "function" && M.set(e, Be), Be;
}
function we(e, r, t) {
return ge(e, !1);
}
function Se(e) {
var r = e.prototype;
return !!(r && r.isReactComponent);
}
function G(e, r, t) {
if (e == null)
return "";
if (typeof e == "function")
return ge(e, Se(e));
if (typeof e == "string")
return q(e);
switch (e) {
case b:
return q("Suspense");
case p:
return q("SuspenseList");
}
if (typeof e == "object")
switch (e.$$typeof) {
case d:
return we(e.render);
case R:
return G(e.type, r, t);
case F: {
var n = e, c = n._payload, f = n._init;
try {
return G(f(c), r, t);
} catch {
}
}
}
return "";
}
var a = Object.prototype.hasOwnProperty, W = {}, S = O.ReactDebugCurrentFrame;
function N(e) {
if (e) {
var r = e._owner, t = G(e.type, e._source, r ? r.type : null);
S.setExtraStackFrame(t);
} else
S.setExtraStackFrame(null);
}
function he(e, r, t, n, c) {
{
var f = Function.call.bind(a);
for (var u in e)
if (f(e, u)) {
var o = void 0;
try {
if (typeof e[u] != "function") {
var x = Error((n || "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;
}
o = e[u](r, u, n, t, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
} catch (g) {
o = g;
}
o && !(o instanceof Error) && (N(c), v("%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).", n || "React class", t, u, typeof o), N(null)), o instanceof Error && !(o.message in W) && (W[o.message] = !0, N(c), v("Failed %s type: %s", t, o.message), N(null));
}
}
}
var be = Array.isArray;
function oe(e) {
return be(e);
}
function Pe(e) {
{
var r = typeof Symbol == "function" && Symbol.toStringTag, t = r && e[Symbol.toStringTag] || e.constructor.name || "Object";
return t;
}
}
function H(e) {
try {
return ye(e), !1;
} catch {
return !0;
}
}
function ye(e) {
return "" + e;
}
function Ie(e) {
if (H(e))
return v("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Pe(e)), ye(e);
}
var ie = O.ReactCurrentOwner, rr = {
key: !0,
ref: !0,
__self: !0,
__source: !0
}, Ye, Me, Oe;
Oe = {};
function tr(e) {
if (a.call(e, "ref")) {
var r = Object.getOwnPropertyDescriptor(e, "ref").get;
if (r && r.isReactWarning)
return !1;
}
return e.ref !== void 0;
}
function nr(e) {
if (a.call(e, "key")) {
var r = Object.getOwnPropertyDescriptor(e, "key").get;
if (r && r.isReactWarning)
return !1;
}
return e.key !== void 0;
}
function ar(e, r) {
if (typeof e.ref == "string" && ie.current && r && ie.current.stateNode !== r) {
var t = w(ie.current.type);
Oe[t] || (v('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', w(ie.current.type), e.ref), Oe[t] = !0);
}
}
function or(e, r) {
{
var t = function() {
Ye || (Ye = !0, v("%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 ir(e, r) {
{
var t = function() {
Me || (Me = !0, v("%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 sr = function(e, r, t, n, c, f, u) {
var o = {
// This tag allows us to uniquely identify this as a React Element
$$typeof: s,
// 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: f
};
return o._store = {}, Object.defineProperty(o._store, "validated", {
configurable: !1,
enumerable: !1,
writable: !0,
value: !1
}), Object.defineProperty(o, "_self", {
configurable: !1,
enumerable: !1,
writable: !1,
value: n
}), Object.defineProperty(o, "_source", {
configurable: !1,
enumerable: !1,
writable: !1,
value: c
}), Object.freeze && (Object.freeze(o.props), Object.freeze(o)), o;
};
function ur(e, r, t, n, c) {
{
var f, u = {}, o = null, x = null;
t !== void 0 && (Ie(t), o = "" + t), nr(r) && (Ie(r.key), o = "" + r.key), tr(r) && (x = r.ref, ar(r, c));
for (f in r)
a.call(r, f) && !rr.hasOwnProperty(f) && (u[f] = r[f]);
if (e && e.defaultProps) {
var g = e.defaultProps;
for (f in g)
u[f] === void 0 && (u[f] = g[f]);
}
if (o || x) {
var h = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
o && or(u, h), x && ir(u, h);
}
return sr(e, o, x, c, n, ie.current, u);
}
}
var ke = O.ReactCurrentOwner, We = O.ReactDebugCurrentFrame;
function K(e) {
if (e) {
var r = e._owner, t = G(e.type, e._source, r ? r.type : null);
We.setExtraStackFrame(t);
} else
We.setExtraStackFrame(null);
}
var De;
De = !1;
function Fe(e) {
return typeof e == "object" && e !== null && e.$$typeof === s;
}
function Ve() {
{
if (ke.current) {
var e = w(ke.current.type);
if (e)
return `
Check the render method of \`` + e + "`.";
}
return "";
}
}
function lr(e) {
{
if (e !== void 0) {
var r = e.fileName.replace(/^.*[\\\/]/, ""), t = e.lineNumber;
return `
Check your code at ` + r + ":" + t + ".";
}
return "";
}
}
var $e = {};
function cr(e) {
{
var r = Ve();
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 Le(e, r) {
{
if (!e._store || e._store.validated || e.key != null)
return;
e._store.validated = !0;
var t = cr(r);
if ($e[t])
return;
$e[t] = !0;
var n = "";
e && e._owner && e._owner !== ke.current && (n = " It was passed a child from " + w(e._owner.type) + "."), K(e), v('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', t, n), K(null);
}
}
function Ne(e, r) {
{
if (typeof e != "object")
return;
if (oe(e))
for (var t = 0; t < e.length; t++) {
var n = e[t];
Fe(n) && Le(n, r);
}
else if (Fe(e))
e._store && (e._store.validated = !0);
else if (e) {
var c = Ee(e);
if (typeof c == "function" && c !== e.entries)
for (var f = c.call(e), u; !(u = f.next()).done; )
Fe(u.value) && Le(u.value, r);
}
}
}
function fr(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 === d || // Note: Memo only checks outer props here.
// Inner props are checked in the reconciler.
r.$$typeof === R))
t = r.propTypes;
else
return;
if (t) {
var n = w(r);
he(t, e.props, "prop", n, e);
} else if (r.PropTypes !== void 0 && !De) {
De = !0;
var c = w(r);
v("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", c || "Unknown");
}
typeof r.getDefaultProps == "function" && !r.getDefaultProps.isReactClassApproved && v("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
}
}
function dr(e) {
{
for (var r = Object.keys(e.props), t = 0; t < r.length; t++) {
var n = r[t];
if (n !== "children" && n !== "key") {
K(e), v("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", n), K(null);
break;
}
}
e.ref !== null && (K(e), v("Invalid attribute `ref` supplied to `React.Fragment`."), K(null));
}
}
function Ue(e, r, t, n, c, f) {
{
var u = de(e);
if (!u) {
var o = "";
(e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (o += " 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 = lr(c);
x ? o += x : o += Ve();
var g;
e === null ? g = "null" : oe(e) ? g = "array" : e !== void 0 && e.$$typeof === s ? (g = "<" + (w(e.type) || "Unknown") + " />", o = " Did you accidentally export a JSX literal instead of a component?") : g = typeof e, v("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", g, o);
}
var h = ur(e, r, t, c, f);
if (h == null)
return h;
if (u) {
var C = r.children;
if (C !== void 0)
if (n)
if (oe(C)) {
for (var X = 0; X < C.length; X++)
Ne(C[X], e);
Object.freeze && Object.freeze(C);
} else
v("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
Ne(C, e);
}
return e === _ ? dr(h) : fr(h), h;
}
}
function vr(e, r, t) {
return Ue(e, r, t, !0);
}
function pr(e, r, t) {
return Ue(e, r, t, !1);
}
var gr = pr, hr = vr;
ue.Fragment = _, ue.jsx = gr, ue.jsxs = hr;
}()), ue;
}
process.env.NODE_ENV === "production" ? Ae.exports = kr() : Ae.exports = Dr();
var i = Ae.exports;
function P(l, s, y) {
return l ? s : y;
}
function He(l, s) {
return (l == null ? void 0 : l.getDate()) === (s == null ? void 0 : s.getDate()) && (l == null ? void 0 : l.getMonth()) === (s == null ? void 0 : s.getMonth()) && (l == null ? void 0 : l.getFullYear()) === (s == null ? void 0 : s.getFullYear());
}
function Qe(l, s) {
return !!l && !!s && l.getTime() > s.getTime();
}
function er(l, s) {
return !!l && !!s && l.getTime() < s.getTime();
}
function Fr({ labels: l, gap: s }) {
return /* @__PURE__ */ i.jsx(Z, { display: "grid", gridTemplateColumns: "repeat(7, 1fr)", gap: s, marginTop: 5, children: l.map((y) => /* @__PURE__ */ i.jsx(yr, { fontSize: "12px", children: y }, y)) });
}
function Ar({
months: l = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
],
defaultValue: s = 0,
onChange: y = () => {
},
currentYear: _,
maxDate: E,
minDate: m
}) {
const j = (d) => {
const { value: b } = d.target;
y && y(b);
}, T = (d) => {
if (_) {
const b = new Date(_, d, 1);
return Qe(b, E) || er(b, m);
}
return !1;
};
return /* @__PURE__ */ i.jsx(
Xe,
{
border: "none",
value: s,
onChange: j,
size: "sm",
maxW: "fit-content",
_focusVisible: {
borderColor: "transparent"
},
cursor: "pointer",
children: l.map((d, b) => /* @__PURE__ */ i.jsx("option", { value: b, disabled: T(b), children: d }, b))
}
);
}
function Ir({
defaultValue: l = (/* @__PURE__ */ new Date()).getFullYear(),
onChange: s,
endYear: y = (/* @__PURE__ */ new Date()).getFullYear() + 5,
initialYear: _ = (/* @__PURE__ */ new Date()).getFullYear() - 100,
maxDate: E,
minDate: m
}) {
const j = (p) => {
const { value: R } = p.target;
s && s(R);
}, T = Math.min(y, (E == null ? void 0 : E.getFullYear()) || 1 / 0), d = Math.max(_, (m == null ? void 0 : m.getFullYear()) || -1 / 0), b = Array.from(
Array(T - d + 1).keys(),
(p) => p + d
);
return /* @__PURE__ */ i.jsx(
Xe,
{
border: "none",
value: l,
onChange: j,
size: "sm",
maxW: "fit-content",
_focusVisible: {
borderColor: "transparent"
},
cursor: "pointer",
children: b.map((p, R) => /* @__PURE__ */ i.jsx("option", { value: p, children: p }, R))
}
);
}
function Yr({ onNext: l, onPrev: s, rightArrowIcon: y = /* @__PURE__ */ i.jsx(Sr, {}), leftArrowIcon: _ = /* @__PURE__ */ i.jsx(Pr, {}), bgColor: E, activeColor: m }) {
return /* @__PURE__ */ i.jsxs(Ze, { gap: "3px", justifyContent: "center", children: [
/* @__PURE__ */ i.jsx(
ze,
{
"aria-label": "Go back",
bg: E,
icon: _,
_hover: { borderColor: m },
onClick: s
}
),
/* @__PURE__ */ i.jsx(
ze,
{
"aria-label": "Go ahead",
bg: E,
icon: y,
_hover: { borderColor: m },
onClick: l
}
)
] });
}
function $r({
isDisabled: l = !1,
icon: s = /* @__PURE__ */ i.jsx(Or, {}),
rightArrowIcon: y,
leftArrowIcon: _,
withArrow: E = !0,
closable: m = !0,
closeOnClick: j = !0,
isInvalid: T,
containerProps: d,
popoverProps: b,
inputProps: p,
placeholder: R = "Pick a date",
clearLabel: F = "Clear",
todayLabel: U = "Today",
daysLabels: le = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
defaultValue: _e,
months: Ee,
colorSchema: O = "blue",
activeColor: v = "blue.400",
inactiveColor: Q = "gray.50",
monthGap: ce = "5px",
dateBorderRadius: Re = "md",
disabledDates: fe,
disabledWeekend: xe,
maxDate: B,
minDate: V,
onChange: de,
formatDate: ee
}) {
const { isOpen: ve, onToggle: w, onClose: k } = mr(), [$, L] = me(""), [A, pe] = me(_e), re = A || /* @__PURE__ */ new Date(), [D, z] = me(re.getMonth()), [I, J] = me(re.getFullYear()), Te = new Date(I, D), Ce = new Date(I, D + 1, 0), te = Te.getDay(), ne = new Array(te).fill(void 0), q = new Array(Ce.getDate()).fill(void 0).map((a, W) => W + 1), ae = [...ne, ...q], M = (a) => {
pe(a), de && de(a);
}, je = (a) => {
if (!a)
return;
const W = new Date(I, D, a);
M(W);
};
br(() => {
L(A ? ee ? ee(A) : A.toLocaleDateString() : "");
}, [L, A, ee]);
const ge = () => /* @__PURE__ */ i.jsx(i.Fragment, { children: ae.map((a, W) => {
const S = P(
a,
new Date(I, D, a),
a
), N = He(A, S);
let he = !1, be = !1;
S && B && (he = Qe(S, B)), S && V && (be = er(S, V));
const oe = Array.isArray(fe) && fe.some((ye) => He(S, ye)), Pe = S && xe && [0, 6].includes(S.getDay()), H = he || be || oe || Pe;
return /* @__PURE__ */ i.jsx(
Z,
{
as: P(a, "button", "span"),
bg: P(a, P(N, v, Q), "transparent"),
textColor: P(N, "white", "black"),
aspectRatio: 1,
borderRadius: Re,
display: "flex",
justifyContent: "center",
alignItems: "center",
disabled: H,
_disabled: {
opacity: 0.5,
cursor: "not-allowed"
},
cursor: P(a, "pointer", "default"),
_hover: P(
a,
{
bg: P(H, Q, v),
color: P(H, "initial", "white"),
borderColor: "transparent"
},
{}
),
onClick: () => {
H || (je(a), j && k());
},
children: a
},
W
);
}) }), we = () => {
z((a) => P(a !== 11, a + 1, 0)), D === 11 && J((a) => a + 1);
}, Se = () => {
z((a) => P(a !== 0, a - 1, 11)), D === 0 && J((a) => a - 1);
}, G = () => {
M(/* @__PURE__ */ new Date());
};
return /* @__PURE__ */ i.jsxs(_r, { isOpen: ve, onClose: k, ...b, children: [
/* @__PURE__ */ i.jsx(Er, { children: /* @__PURE__ */ i.jsxs(
Z,
{
position: "relative",
pointerEvents: l ? "none" : void 0,
backgroundColor: l ? "gray.100" : void 0,
opacity: l ? 0.8 : 1,
...d,
children: [
/* @__PURE__ */ i.jsx(
Rr,
{
isReadOnly: !0,
placeholder: R,
defaultValue: $,
colorScheme: O,
cursor: "pointer",
isInvalid: T,
onClick: w,
...p
}
),
/* @__PURE__ */ i.jsx(Z, { as: "span", position: "absolute", right: "0.5rem", top: "50%", transform: "translateY(-50%)", children: s })
]
}
) }),
/* @__PURE__ */ i.jsxs(xr, { children: [
E && /* @__PURE__ */ i.jsx(Tr, {}),
m && /* @__PURE__ */ i.jsx(Cr, {}),
/* @__PURE__ */ i.jsxs(jr, { children: [
/* @__PURE__ */ i.jsxs(Ze, { mt: m ? 6 : 2, alignItems: "center", justifyContent: "space-around", children: [
/* @__PURE__ */ i.jsx(
Ar,
{
defaultValue: D,
months: Ee,
currentYear: I,
maxDate: B,
minDate: V,
activeColor: v,
onChange: (a) => z(a)
}
),
/* @__PURE__ */ i.jsx(
Ir,
{
defaultValue: I,
maxDate: B,
minDate: V,
activeColor: v,
onChange: (a) => J(a)
}
),
/* @__PURE__ */ i.jsx(
Yr,
{
bgColor: Q,
activeColor: v,
rightArrowIcon: y,
leftArrowIcon: _,
onNext: we,
onPrev: Se
}
)
] }),
/* @__PURE__ */ i.jsx(Fr, { labels: le, gap: ce }),
/* @__PURE__ */ i.jsx(Z, { display: "grid", gridTemplateColumns: "repeat(7, 1fr)", gap: ce, marginTop: 2, children: /* @__PURE__ */ i.jsx(ge, {}) })
] }),
/* @__PURE__ */ i.jsx(wr, { children: /* @__PURE__ */ i.jsxs(Z, { display: "flex", justifyContent: "space-between", children: [
/* @__PURE__ */ i.jsx(
Je,
{
size: "sm",
colorScheme: O,
bg: v,
onClick: G,
_hover: { borderColor: "transparent" },
children: U
}
),
/* @__PURE__ */ i.jsx(
Je,
{
size: "sm",
variant: "ghost",
color: v,
colorScheme: O,
_hover: { borderColor: v },
onClick: () => {
M(void 0);
},
children: F
}
)
] }) })
] })
] });
}
export {
Yr as ControlButtons,
Fr as LabelDays,
Ar as MonthSelect,
$r as SimpleDatePicker,
Ir as YearSelect
};