adizen-tanstack-table
Version:
Enhanced DataTable with TanStack Table
1,056 lines (1,027 loc) • 219 kB
JavaScript
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var jsxRuntime = require('react/jsx-runtime');
var React = require('react');
var reactTable = require('@tanstack/react-table');
var clsx = require('clsx');
var tailwindMerge = require('tailwind-merge');
var reactSlot = require('@radix-ui/react-slot');
var classVarianceAuthority = require('class-variance-authority');
var DropdownMenuPrimitive = require('@radix-ui/react-dropdown-menu');
var reactIcons = require('@radix-ui/react-icons');
var TooltipPrimitive = require('@radix-ui/react-tooltip');
var SelectPrimitive = require('@radix-ui/react-select');
var lucideReact = require('lucide-react');
var dateFns = require('date-fns');
var format$1 = require('date-fns/format');
var DialogPrimitive = require('@radix-ui/react-dialog');
function _interopNamespaceDefault(e) {
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n.default = e;
return Object.freeze(n);
}
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
var DropdownMenuPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(DropdownMenuPrimitive);
var TooltipPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(TooltipPrimitive);
var SelectPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(SelectPrimitive);
var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(DialogPrimitive);
/******************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
}
function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
function __generator(thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
}
function __spreadArray(to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
}
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
var e = new Error(message);
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
};
function cn() {
var inputs = [];
for (var _i = 0; _i < arguments.length; _i++) {
inputs[_i] = arguments[_i];
}
return tailwindMerge.twMerge(clsx.clsx(inputs));
}
var Table = React__namespace.forwardRef(function (_a, ref) {
var className = _a.className, props = __rest(_a, ["className"]);
return (jsxRuntime.jsx("div", { className: "relative w-full overflow-auto", children: jsxRuntime.jsx("table", __assign({ ref: ref, className: cn("w-full caption-bottom text-sm", className) }, props)) }));
});
Table.displayName = "Table";
var TableHeader = React__namespace.forwardRef(function (_a, ref) {
var className = _a.className, props = __rest(_a, ["className"]);
return (jsxRuntime.jsx("thead", __assign({ ref: ref, className: cn("[&_tr]:border-b", className) }, props)));
});
TableHeader.displayName = "TableHeader";
var TableBody = React__namespace.forwardRef(function (_a, ref) {
var className = _a.className, props = __rest(_a, ["className"]);
return (jsxRuntime.jsx("tbody", __assign({ ref: ref, className: cn("[&_tr:last-child]:border-0", className) }, props)));
});
TableBody.displayName = "TableBody";
var TableFooter = React__namespace.forwardRef(function (_a, ref) {
var className = _a.className, props = __rest(_a, ["className"]);
return (jsxRuntime.jsx("tfoot", __assign({ ref: ref, className: cn("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0", className) }, props)));
});
TableFooter.displayName = "TableFooter";
var TableRow = React__namespace.forwardRef(function (_a, ref) {
var className = _a.className, props = __rest(_a, ["className"]);
return (jsxRuntime.jsx("tr", __assign({ ref: ref, className: cn("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted", className) }, props)));
});
TableRow.displayName = "TableRow";
var TableHead = React__namespace.forwardRef(function (_a, ref) {
var className = _a.className, props = __rest(_a, ["className"]);
return (jsxRuntime.jsx("th", __assign({ ref: ref, className: cn("h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]", className) }, props)));
});
TableHead.displayName = "TableHead";
var TableCell = React__namespace.forwardRef(function (_a, ref) {
var className = _a.className, props = __rest(_a, ["className"]);
return (jsxRuntime.jsx("td", __assign({ ref: ref, className: cn("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]", className) }, props)));
});
TableCell.displayName = "TableCell";
var TableCaption = React__namespace.forwardRef(function (_a, ref) {
var className = _a.className, props = __rest(_a, ["className"]);
return (jsxRuntime.jsx("caption", __assign({ ref: ref, className: cn("mt-4 text-sm text-muted-foreground", className) }, props)));
});
TableCaption.displayName = "TableCaption";
function Skeleton(_a) {
var className = _a.className, props = __rest(_a, ["className"]);
return (jsxRuntime.jsx("div", __assign({ className: cn("animate-pulse rounded-md bg-primary/10", className) }, props)));
}
var buttonVariants = classVarianceAuthority.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0", {
variants: {
variant: {
default: "bg-primary text-primary-foreground shadow hover:bg-primary/90",
destructive: "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
outline: "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
ghost: "hover:bg-accent hover:text-accent-foreground",
link: "text-primary underline-offset-4 hover:underline",
},
size: {
default: "h-9 px-4 py-2",
sm: "h-8 rounded-md px-3 text-xs",
lg: "h-10 rounded-md px-8",
icon: "h-9 w-9",
},
},
defaultVariants: {
variant: "default",
size: "default",
},
});
var Button = React__namespace.forwardRef(function (_a, ref) {
var className = _a.className, variant = _a.variant, size = _a.size, _b = _a.asChild, asChild = _b === void 0 ? false : _b, props = __rest(_a, ["className", "variant", "size", "asChild"]);
var Comp = asChild ? reactSlot.Slot : "button";
return (jsxRuntime.jsx(Comp, __assign({ className: cn(buttonVariants({ variant: variant, size: size, className: className })), ref: ref }, props)));
});
Button.displayName = "Button";
var DropdownMenu = DropdownMenuPrimitive__namespace.Root;
var DropdownMenuTrigger = DropdownMenuPrimitive__namespace.Trigger;
var DropdownMenuSubTrigger = React__namespace.forwardRef(function (_a, ref) {
var className = _a.className, inset = _a.inset, children = _a.children, props = __rest(_a, ["className", "inset", "children"]);
return (jsxRuntime.jsxs(DropdownMenuPrimitive__namespace.SubTrigger, __assign({ ref: ref, className: cn("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent", inset && "pl-8", className) }, props, { children: [children, jsxRuntime.jsx(reactIcons.ChevronRightIcon, { className: "ml-auto h-4 w-4" })] })));
});
DropdownMenuSubTrigger.displayName =
DropdownMenuPrimitive__namespace.SubTrigger.displayName;
var DropdownMenuSubContent = React__namespace.forwardRef(function (_a, ref) {
var className = _a.className, props = __rest(_a, ["className"]);
return (jsxRuntime.jsx(DropdownMenuPrimitive__namespace.SubContent, __assign({ ref: ref, className: cn("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", className) }, props)));
});
DropdownMenuSubContent.displayName =
DropdownMenuPrimitive__namespace.SubContent.displayName;
var DropdownMenuContent = React__namespace.forwardRef(function (_a, ref) {
var className = _a.className, _b = _a.sideOffset, sideOffset = _b === void 0 ? 4 : _b, props = __rest(_a, ["className", "sideOffset"]);
return (jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Portal, { children: jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Content, __assign({ ref: ref, sideOffset: sideOffset, className: cn("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md", "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", className) }, props)) }));
});
DropdownMenuContent.displayName = DropdownMenuPrimitive__namespace.Content.displayName;
var DropdownMenuItem = React__namespace.forwardRef(function (_a, ref) {
var className = _a.className, inset = _a.inset, props = __rest(_a, ["className", "inset"]);
return (jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Item, __assign({ ref: ref, className: cn("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0", inset && "pl-8", className) }, props)));
});
DropdownMenuItem.displayName = DropdownMenuPrimitive__namespace.Item.displayName;
var DropdownMenuCheckboxItem = React__namespace.forwardRef(function (_a, ref) {
var className = _a.className, children = _a.children, checked = _a.checked, props = __rest(_a, ["className", "children", "checked"]);
return (jsxRuntime.jsxs(DropdownMenuPrimitive__namespace.CheckboxItem, __assign({ ref: ref, className: cn("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", className), checked: checked }, props, { children: [jsxRuntime.jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: jsxRuntime.jsx(DropdownMenuPrimitive__namespace.ItemIndicator, { children: jsxRuntime.jsx(reactIcons.CheckIcon, { className: "h-4 w-4" }) }) }), children] })));
});
DropdownMenuCheckboxItem.displayName =
DropdownMenuPrimitive__namespace.CheckboxItem.displayName;
var DropdownMenuRadioItem = React__namespace.forwardRef(function (_a, ref) {
var className = _a.className, children = _a.children, props = __rest(_a, ["className", "children"]);
return (jsxRuntime.jsxs(DropdownMenuPrimitive__namespace.RadioItem, __assign({ ref: ref, className: cn("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", className) }, props, { children: [jsxRuntime.jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: jsxRuntime.jsx(DropdownMenuPrimitive__namespace.ItemIndicator, { children: jsxRuntime.jsx(reactIcons.DotFilledIcon, { className: "h-4 w-4 fill-current" }) }) }), children] })));
});
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive__namespace.RadioItem.displayName;
var DropdownMenuLabel = React__namespace.forwardRef(function (_a, ref) {
var className = _a.className, inset = _a.inset, props = __rest(_a, ["className", "inset"]);
return (jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Label, __assign({ ref: ref, className: cn("px-2 py-1.5 text-sm font-semibold", inset && "pl-8", className) }, props)));
});
DropdownMenuLabel.displayName = DropdownMenuPrimitive__namespace.Label.displayName;
var DropdownMenuSeparator = React__namespace.forwardRef(function (_a, ref) {
var className = _a.className, props = __rest(_a, ["className"]);
return (jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Separator, __assign({ ref: ref, className: cn("-mx-1 my-1 h-px bg-muted", className) }, props)));
});
DropdownMenuSeparator.displayName = DropdownMenuPrimitive__namespace.Separator.displayName;
var TooltipProvider = TooltipPrimitive__namespace.Provider;
var Tooltip = TooltipPrimitive__namespace.Root;
var TooltipTrigger = TooltipPrimitive__namespace.Trigger;
var TooltipContent = React__namespace.forwardRef(function (_a, ref) {
var className = _a.className, _b = _a.sideOffset, sideOffset = _b === void 0 ? 4 : _b, props = __rest(_a, ["className", "sideOffset"]);
return (jsxRuntime.jsx(TooltipPrimitive__namespace.Portal, { children: jsxRuntime.jsx(TooltipPrimitive__namespace.Content, __assign({ ref: ref, sideOffset: sideOffset, className: cn("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", className) }, props)) }));
});
TooltipContent.displayName = TooltipPrimitive__namespace.Content.displayName;
var Select = SelectPrimitive__namespace.Root;
var SelectValue = SelectPrimitive__namespace.Value;
var SelectTrigger = React__namespace.forwardRef(function (_a, ref) {
var className = _a.className, children = _a.children, props = __rest(_a, ["className", "children"]);
return (jsxRuntime.jsxs(SelectPrimitive__namespace.Trigger, __assign({ ref: ref, className: cn("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1", className) }, props, { children: [children, jsxRuntime.jsx(SelectPrimitive__namespace.Icon, { asChild: true, children: jsxRuntime.jsx(reactIcons.CaretSortIcon, { className: "h-4 w-4 opacity-50" }) })] })));
});
SelectTrigger.displayName = SelectPrimitive__namespace.Trigger.displayName;
var SelectScrollUpButton = React__namespace.forwardRef(function (_a, ref) {
var className = _a.className, props = __rest(_a, ["className"]);
return (jsxRuntime.jsx(SelectPrimitive__namespace.ScrollUpButton, __assign({ ref: ref, className: cn("flex cursor-default items-center justify-center py-1", className) }, props, { children: jsxRuntime.jsx(reactIcons.ChevronUpIcon, {}) })));
});
SelectScrollUpButton.displayName = SelectPrimitive__namespace.ScrollUpButton.displayName;
var SelectScrollDownButton = React__namespace.forwardRef(function (_a, ref) {
var className = _a.className, props = __rest(_a, ["className"]);
return (jsxRuntime.jsx(SelectPrimitive__namespace.ScrollDownButton, __assign({ ref: ref, className: cn("flex cursor-default items-center justify-center py-1", className) }, props, { children: jsxRuntime.jsx(reactIcons.ChevronDownIcon, {}) })));
});
SelectScrollDownButton.displayName =
SelectPrimitive__namespace.ScrollDownButton.displayName;
var SelectContent = React__namespace.forwardRef(function (_a, ref) {
var className = _a.className, children = _a.children, _b = _a.position, position = _b === void 0 ? "popper" : _b, props = __rest(_a, ["className", "children", "position"]);
return (jsxRuntime.jsx(SelectPrimitive__namespace.Portal, { children: jsxRuntime.jsxs(SelectPrimitive__namespace.Content, __assign({ ref: ref, className: cn("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", position === "popper" &&
"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1", className), position: position }, props, { children: [jsxRuntime.jsx(SelectScrollUpButton, {}), jsxRuntime.jsx(SelectPrimitive__namespace.Viewport, { className: cn("p-1", position === "popper" &&
"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"), children: children }), jsxRuntime.jsx(SelectScrollDownButton, {})] })) }));
});
SelectContent.displayName = SelectPrimitive__namespace.Content.displayName;
var SelectLabel = React__namespace.forwardRef(function (_a, ref) {
var className = _a.className, props = __rest(_a, ["className"]);
return (jsxRuntime.jsx(SelectPrimitive__namespace.Label, __assign({ ref: ref, className: cn("px-2 py-1.5 text-sm font-semibold", className) }, props)));
});
SelectLabel.displayName = SelectPrimitive__namespace.Label.displayName;
var SelectItem = React__namespace.forwardRef(function (_a, ref) {
var className = _a.className, children = _a.children, props = __rest(_a, ["className", "children"]);
return (jsxRuntime.jsxs(SelectPrimitive__namespace.Item, __assign({ ref: ref, className: cn("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", className) }, props, { children: [jsxRuntime.jsx("span", { className: "absolute right-2 flex h-3.5 w-3.5 items-center justify-center", children: jsxRuntime.jsx(SelectPrimitive__namespace.ItemIndicator, { children: jsxRuntime.jsx(reactIcons.CheckIcon, { className: "h-4 w-4" }) }) }), jsxRuntime.jsx(SelectPrimitive__namespace.ItemText, { children: children })] })));
});
SelectItem.displayName = SelectPrimitive__namespace.Item.displayName;
var SelectSeparator = React__namespace.forwardRef(function (_a, ref) {
var className = _a.className, props = __rest(_a, ["className"]);
return (jsxRuntime.jsx(SelectPrimitive__namespace.Separator, __assign({ ref: ref, className: cn("-mx-1 my-1 h-px bg-muted", className) }, props)));
});
SelectSeparator.displayName = SelectPrimitive__namespace.Separator.displayName;
/**
* Returns the formatted time zone name of the provided `timeZone` or the current
* system time zone if omitted, accounting for DST according to the UTC value of
* the date.
*/
function tzIntlTimeZoneName(length, date, options) {
const defaultOptions = dateFns.getDefaultOptions();
const dtf = getDTF(length, options.timeZone, options.locale ?? defaultOptions.locale);
return 'formatToParts' in dtf ? partsTimeZone(dtf, date) : hackyTimeZone(dtf, date);
}
function partsTimeZone(dtf, date) {
const formatted = dtf.formatToParts(date);
for (let i = formatted.length - 1; i >= 0; --i) {
if (formatted[i].type === 'timeZoneName') {
return formatted[i].value;
}
}
return undefined;
}
function hackyTimeZone(dtf, date) {
const formatted = dtf.format(date).replace(/\u200E/g, '');
const tzNameMatch = / [\w-+ ]+$/.exec(formatted);
return tzNameMatch ? tzNameMatch[0].substr(1) : '';
}
// If a locale has been provided `en-US` is used as a fallback in case it is an
// invalid locale, otherwise the locale is left undefined to use the system locale.
function getDTF(length, timeZone, locale) {
return new Intl.DateTimeFormat(locale ? [locale.code, 'en-US'] : undefined, {
timeZone: timeZone,
timeZoneName: length,
});
}
/**
* Returns the [year, month, day, hour, minute, seconds] tokens of the provided
* `date` as it will be rendered in the `timeZone`.
*/
function tzTokenizeDate(date, timeZone) {
const dtf = getDateTimeFormat(timeZone);
return 'formatToParts' in dtf ? partsOffset(dtf, date) : hackyOffset(dtf, date);
}
const typeToPos = {
year: 0,
month: 1,
day: 2,
hour: 3,
minute: 4,
second: 5,
};
function partsOffset(dtf, date) {
try {
const formatted = dtf.formatToParts(date);
const filled = [];
for (let i = 0; i < formatted.length; i++) {
const pos = typeToPos[formatted[i].type];
if (pos !== undefined) {
filled[pos] = parseInt(formatted[i].value, 10);
}
}
return filled;
}
catch (error) {
if (error instanceof RangeError) {
return [NaN];
}
throw error;
}
}
function hackyOffset(dtf, date) {
const formatted = dtf.format(date);
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const parsed = /(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(formatted);
// const [, fMonth, fDay, fYear, fHour, fMinute, fSecond] = parsed
// return [fYear, fMonth, fDay, fHour, fMinute, fSecond]
return [
parseInt(parsed[3], 10),
parseInt(parsed[1], 10),
parseInt(parsed[2], 10),
parseInt(parsed[4], 10),
parseInt(parsed[5], 10),
parseInt(parsed[6], 10),
];
}
// Get a cached Intl.DateTimeFormat instance for the IANA `timeZone`. This can be used
// to get deterministic local date/time output according to the `en-US` locale which
// can be used to extract local time parts as necessary.
const dtfCache = {};
// New browsers use `hourCycle`, IE and Chrome <73 does not support it and uses `hour12`
const testDateFormatted = new Intl.DateTimeFormat('en-US', {
hourCycle: 'h23',
timeZone: 'America/New_York',
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
}).format(new Date('2014-06-25T04:00:00.123Z'));
const hourCycleSupported = testDateFormatted === '06/25/2014, 00:00:00' ||
testDateFormatted === '06/25/2014 00:00:00';
function getDateTimeFormat(timeZone) {
if (!dtfCache[timeZone]) {
dtfCache[timeZone] = hourCycleSupported
? new Intl.DateTimeFormat('en-US', {
hourCycle: 'h23',
timeZone: timeZone,
year: 'numeric',
month: 'numeric',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
})
: new Intl.DateTimeFormat('en-US', {
hour12: false,
timeZone: timeZone,
year: 'numeric',
month: 'numeric',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
});
}
return dtfCache[timeZone];
}
/**
* Use instead of `new Date(Date.UTC(...))` to support years below 100 which doesn't work
* otherwise due to the nature of the
* [`Date` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#interpretation_of_two-digit_years.
*
* For `Date.UTC(...)`, use `newDateUTC(...).getTime()`.
*/
function newDateUTC(fullYear, month, day, hour, minute, second, millisecond) {
const utcDate = new Date(0);
utcDate.setUTCFullYear(fullYear, month, day);
utcDate.setUTCHours(hour, minute, second, millisecond);
return utcDate;
}
const MILLISECONDS_IN_HOUR$1 = 3600000;
const MILLISECONDS_IN_MINUTE$2 = 60000;
const patterns$1 = {
timezoneZ: /^(Z)$/,
timezoneHH: /^([+-]\d{2})$/,
timezoneHHMM: /^([+-])(\d{2}):?(\d{2})$/,
};
// Parse constious time zone offset formats to an offset in milliseconds
function tzParseTimezone(timezoneString, date, isUtcDate) {
// Empty string
if (!timezoneString) {
return 0;
}
// Z
let token = patterns$1.timezoneZ.exec(timezoneString);
if (token) {
return 0;
}
let hours;
let absoluteOffset;
// ±hh
token = patterns$1.timezoneHH.exec(timezoneString);
if (token) {
hours = parseInt(token[1], 10);
if (!validateTimezone(hours)) {
return NaN;
}
return -(hours * MILLISECONDS_IN_HOUR$1);
}
// ±hh:mm or ±hhmm
token = patterns$1.timezoneHHMM.exec(timezoneString);
if (token) {
hours = parseInt(token[2], 10);
const minutes = parseInt(token[3], 10);
if (!validateTimezone(hours, minutes)) {
return NaN;
}
absoluteOffset = Math.abs(hours) * MILLISECONDS_IN_HOUR$1 + minutes * MILLISECONDS_IN_MINUTE$2;
return token[1] === '+' ? -absoluteOffset : absoluteOffset;
}
// IANA time zone
if (isValidTimezoneIANAString(timezoneString)) {
date = new Date(date || Date.now());
const utcDate = isUtcDate ? date : toUtcDate(date);
const offset = calcOffset(utcDate, timezoneString);
const fixedOffset = isUtcDate ? offset : fixOffset(date, offset, timezoneString);
return -fixedOffset;
}
return NaN;
}
function toUtcDate(date) {
return newDateUTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
}
function calcOffset(date, timezoneString) {
const tokens = tzTokenizeDate(date, timezoneString);
// ms dropped because it's not provided by tzTokenizeDate
const asUTC = newDateUTC(tokens[0], tokens[1] - 1, tokens[2], tokens[3] % 24, tokens[4], tokens[5], 0).getTime();
let asTS = date.getTime();
const over = asTS % 1000;
asTS -= over >= 0 ? over : 1000 + over;
return asUTC - asTS;
}
function fixOffset(date, offset, timezoneString) {
const localTS = date.getTime();
// Our UTC time is just a guess because our offset is just a guess
let utcGuess = localTS - offset;
// Test whether the zone matches the offset for this ts
const o2 = calcOffset(new Date(utcGuess), timezoneString);
// If so, offset didn't change, and we're done
if (offset === o2) {
return offset;
}
// If not, change the ts by the difference in the offset
utcGuess -= o2 - offset;
// If that gives us the local time we want, we're done
const o3 = calcOffset(new Date(utcGuess), timezoneString);
if (o2 === o3) {
return o2;
}
// If it's different, we're in a hole time. The offset has changed, but we don't adjust the time
return Math.max(o2, o3);
}
function validateTimezone(hours, minutes) {
return -23 <= hours && hours <= 23 && (minutes == null || (0 <= minutes && minutes <= 59));
}
const validIANATimezoneCache = {};
function isValidTimezoneIANAString(timeZoneString) {
if (validIANATimezoneCache[timeZoneString])
return true;
try {
new Intl.DateTimeFormat(undefined, { timeZone: timeZoneString });
validIANATimezoneCache[timeZoneString] = true;
return true;
}
catch (error) {
return false;
}
}
const MILLISECONDS_IN_MINUTE$1 = 60 * 1000;
const formatters = {
// Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
X: function (date, token, options) {
const timezoneOffset = getTimeZoneOffset(options.timeZone, date);
if (timezoneOffset === 0) {
return 'Z';
}
switch (token) {
// Hours and optional minutes
case 'X':
return formatTimezoneWithOptionalMinutes(timezoneOffset);
// Hours, minutes and optional seconds without `:` delimeter
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
// so this token always has the same output as `XX`
case 'XXXX':
case 'XX': // Hours and minutes without `:` delimeter
return formatTimezone(timezoneOffset);
// Hours, minutes and optional seconds with `:` delimeter
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
// so this token always has the same output as `XXX`
case 'XXXXX':
case 'XXX': // Hours and minutes with `:` delimeter
default:
return formatTimezone(timezoneOffset, ':');
}
},
// Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
x: function (date, token, options) {
const timezoneOffset = getTimeZoneOffset(options.timeZone, date);
switch (token) {
// Hours and optional minutes
case 'x':
return formatTimezoneWithOptionalMinutes(timezoneOffset);
// Hours, minutes and optional seconds without `:` delimeter
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
// so this token always has the same output as `xx`
case 'xxxx':
case 'xx': // Hours and minutes without `:` delimeter
return formatTimezone(timezoneOffset);
// Hours, minutes and optional seconds with `:` delimeter
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
// so this token always has the same output as `xxx`
case 'xxxxx':
case 'xxx': // Hours and minutes with `:` delimeter
default:
return formatTimezone(timezoneOffset, ':');
}
},
// Timezone (GMT)
O: function (date, token, options) {
const timezoneOffset = getTimeZoneOffset(options.timeZone, date);
switch (token) {
// Short
case 'O':
case 'OO':
case 'OOO':
return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
// Long
case 'OOOO':
default:
return 'GMT' + formatTimezone(timezoneOffset, ':');
}
},
// Timezone (specific non-location)
z: function (date, token, options) {
switch (token) {
// Short
case 'z':
case 'zz':
case 'zzz':
return tzIntlTimeZoneName('short', date, options);
// Long
case 'zzzz':
default:
return tzIntlTimeZoneName('long', date, options);
}
},
};
function getTimeZoneOffset(timeZone, originalDate) {
const timeZoneOffset = timeZone
? tzParseTimezone(timeZone, originalDate, true) / MILLISECONDS_IN_MINUTE$1
: originalDate?.getTimezoneOffset() ?? 0;
if (Number.isNaN(timeZoneOffset)) {
throw new RangeError('Invalid time zone specified: ' + timeZone);
}
return timeZoneOffset;
}
function addLeadingZeros(number, targetLength) {
const sign = number < 0 ? '-' : '';
let output = Math.abs(number).toString();
while (output.length < targetLength) {
output = '0' + output;
}
return sign + output;
}
function formatTimezone(offset, delimiter = '') {
const sign = offset > 0 ? '-' : '+';
const absOffset = Math.abs(offset);
const hours = addLeadingZeros(Math.floor(absOffset / 60), 2);
const minutes = addLeadingZeros(Math.floor(absOffset % 60), 2);
return sign + hours + delimiter + minutes;
}
function formatTimezoneWithOptionalMinutes(offset, delimiter) {
if (offset % 60 === 0) {
const sign = offset > 0 ? '-' : '+';
return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
}
return formatTimezone(offset, delimiter);
}
function formatTimezoneShort(offset, delimiter = '') {
const sign = offset > 0 ? '-' : '+';
const absOffset = Math.abs(offset);
const hours = Math.floor(absOffset / 60);
const minutes = absOffset % 60;
if (minutes === 0) {
return sign + String(hours);
}
return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
}
/**
* Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.
* They usually appear for dates that denote time before the timezones were introduced
* (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891
* and GMT+01:00:00 after that date)
*
* Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,
* which would lead to incorrect calculations.
*
* This function returns the timezone offset in milliseconds that takes seconds in account.
*/
function getTimezoneOffsetInMilliseconds(date) {
const utcDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
utcDate.setUTCFullYear(date.getFullYear());
return +date - +utcDate;
}
/** Regex to identify the presence of a time zone specifier in a date string */
const tzPattern = /(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/;
const MILLISECONDS_IN_HOUR = 3600000;
const MILLISECONDS_IN_MINUTE = 60000;
const DEFAULT_ADDITIONAL_DIGITS = 2;
const patterns = {
dateTimePattern: /^([0-9W+-]+)(T| )(.*)/,
datePattern: /^([0-9W+-]+)(.*)/,
// year tokens
YY: /^(\d{2})$/,
YYY: [
/^([+-]\d{2})$/, // 0 additional digits
/^([+-]\d{3})$/, // 1 additional digit
/^([+-]\d{4})$/, // 2 additional digits
],
YYYY: /^(\d{4})/,
YYYYY: [
/^([+-]\d{4})/, // 0 additional digits
/^([+-]\d{5})/, // 1 additional digit
/^([+-]\d{6})/, // 2 additional digits
],
// date tokens
MM: /^-(\d{2})$/,
DDD: /^-?(\d{3})$/,
MMDD: /^-?(\d{2})-?(\d{2})$/,
Www: /^-?W(\d{2})$/,
WwwD: /^-?W(\d{2})-?(\d{1})$/,
HH: /^(\d{2}([.,]\d*)?)$/,
HHMM: /^(\d{2}):?(\d{2}([.,]\d*)?)$/,
HHMMSS: /^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/,
// time zone tokens (to identify the presence of a tz)
timeZone: tzPattern,
};
/**
* @name toDate
* @category Common Helpers
* @summary Convert the given argument to an instance of Date.
*
* @description
* Convert the given argument to an instance of Date.
*
* If the argument is an instance of Date, the function returns its clone.
*
* If the argument is a number, it is treated as a timestamp.
*
* If an argument is a string, the function tries to parse it.
* Function accepts complete ISO 8601 formats as well as partial implementations.
* ISO 8601: http://en.wikipedia.org/wiki/ISO_8601
* If the function cannot parse the string or the values are invalid, it returns Invalid Date.
*
* If the argument is none of the above, the function returns Invalid Date.
*
* **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
* All *date-fns* functions will throw `RangeError` if `options.additionalDigits` is not 0, 1, 2 or undefined.
*
* @param argument the value to convert
* @param options the object with options. See [Options]{@link https://date-fns.org/docs/Options}
* @param {0|1|2} [options.additionalDigits=2] - the additional number of digits in the extended year format
* @param {string} [options.timeZone=''] - used to specify the IANA time zone offset of a date String.
*
* @returns the parsed date in the local time zone
* @throws {TypeError} 1 argument required
* @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2
*
* @example
* // Convert string '2014-02-11T11:30:30' to date:
* const result = toDate('2014-02-11T11:30:30')
* //=> Tue Feb 11 2014 11:30:30
*
* @example
* // Convert string '+02014101' to date,
* // if the additional number of digits in the extended year format is 1:
* const result = toDate('+02014101', {additionalDigits: 1})
* //=> Fri Apr 11 2014 00:00:00
*/
function toDate(argument, options = {}) {
if (arguments.length < 1) {
throw new TypeError('1 argument required, but only ' + arguments.length + ' present');
}
if (argument === null) {
return new Date(NaN);
}
const additionalDigits = options.additionalDigits == null ? DEFAULT_ADDITIONAL_DIGITS : Number(options.additionalDigits);
if (additionalDigits !== 2 && additionalDigits !== 1 && additionalDigits !== 0) {
throw new RangeError('additionalDigits must be 0, 1 or 2');
}
// Clone the date
if (argument instanceof Date ||
(typeof argument === 'object' && Object.prototype.toString.call(argument) === '[object Date]')) {
// Prevent the date to lose the milliseconds when passed to new Date() in IE10
return new Date(argument.getTime());
}
else if (typeof argument === 'number' ||
Object.prototype.toString.call(argument) === '[object Number]') {
return new Date(argument);
}
else if (!(Object.prototype.toString.call(argument) === '[object String]')) {
return new Date(NaN);
}
const dateStrings = splitDateString(argument);
const { year, restDateString } = parseYear(dateStrings.date, additionalDigits);
const date = parseDate(restDateString, year);
if (date === null || isNaN(date.getTime())) {
return new Date(NaN);
}
if (date) {
const timestamp = date.getTime();
let time = 0;
let offset;
if (dateStrings.time) {
time = parseTime(dateStrings.time);
if (time === null || isNaN(time)) {
return new Date(NaN);
}
}
if (dateStrings.timeZone || options.timeZone) {
offset = tzParseTimezone(dateStrings.timeZone || options.timeZone, new Date(timestamp + time));
if (isNaN(offset)) {
return new Date(NaN);
}
}
else {
// get offset accurate to hour in time zones that change offset
offset = getTimezoneOffsetInMilliseconds(new Date(timestamp + time));
offset = getTimezoneOffsetInMilliseconds(new Date(timestamp + time + offset));
}
return new Date(timestamp + time + offset);
}
else {
return new Date(NaN);
}
}
function splitDateString(dateString) {
const dateStrings = {};
let parts = patterns.dateTimePattern.exec(dateString);
let timeString;
if (!parts) {
parts = patterns.datePattern.exec(dateString);
if (parts) {
dateStrings.date = parts[1];
timeString = parts[2];
}
else {
dateStrings.date = null;
timeString = dateString;
}
}
else {
dateStrings.date = parts[1];
timeString = parts[3];
}
if (timeString) {
const token = patterns.timeZone.exec(timeString);
if (token) {
dateStrings.time = timeString.replace(token[1], '');
dateStrings.timeZone = token[1].trim();
}
else {
dateStrings.time = timeString;
}
}
return dateStrings;
}
function parseYear(dateString, additionalDigits) {
if (dateString) {
const patternYYY = patterns.YYY[additionalDigits];
const patternYYYYY = patterns.YYYYY[additionalDigits];
// YYYY or ±YYYYY
let token = patterns.YYYY.exec(dateString) || patternYYYYY.exec(dateString);
if (token) {
const yearString = token[1];
return {
year: parseInt(yearString, 10),
restDateString: dateString.slice(yearString.length),
};
}
// YY or ±YYY
token = patterns.YY.exec(dateString) || patternYYY.exec(dateString);
if (token) {
const centuryString = token[1];
return {
year: parseInt(centuryString, 10) * 100,
restDateString: dateString.slice(centuryString.length),
};
}
}
// Invalid ISO-formatted year
return {
year: null,
};
}
function parseDate(dateString, year) {
// Invalid ISO-formatted year
if (year === null) {
return null;
}
let date;
let month;
let week;
// YYYY
if (!dateString || !dateString.length) {
date = new Date(0);
date.setUTCFullYear(year);
return date;
}
// YYYY-MM
let token = patterns.MM.exec(dateString);
if (token) {
date = new Date(0);
month = parseInt(token[1], 10) - 1;
if (!validateDate(year, month)) {
return new Date(NaN);
}
date.setUTCFullYear(year, month);
return date;
}
// YYYY-DDD or YYYYDDD
token = patterns.DDD.exec(dateString);
if (token) {
date = new Date(0);
const dayOfYear = parseInt(token[1], 10);
if (!validateDayOfYearDate(year, dayOfYear)) {
return new Date(NaN);
}
date.setUTCFullYear(year, 0, dayOfYear);
return date;
}
// yyyy-MM-dd or YYYYMMDD
token = patterns.MMDD.exec(dateString);
if (token) {
date = new Date(0);
month = parseInt(token[1], 10) - 1;
const day = parseInt(token[2], 10);
if (!validateDate(year, month, day)) {
return new Date(NaN);
}
date.setUTCFullYear(year, month, day);
return date;
}
// YYYY-Www or YYYYWww
token = patterns.Www.exec(dateString);
if (token) {
week = parseInt(token[1], 10) - 1;
if (!validateWeekDate(week)) {
return new Date(NaN);
}
return dayOfISOWeekYear(year, week);
}
// YYYY-Www-D or YYYYWwwD
token = patterns.WwwD.exec(dateString);
if (token) {
week = parseInt(token[1], 10) - 1;
const dayOfWeek = parseInt(token[2], 10) - 1;
if (!validateWeekDate(week, dayOfWeek)) {
return new Date(NaN);
}
return dayOfISOWeekYear(year, week, dayOfWeek);
}
// Invalid ISO-formatted date
return null;
}
function parseTime(timeString) {
let hours;
let minutes;
// hh
let token = patterns.HH.exec(timeString);
if (token) {
hours = parseFloat(token[1].replace(',', '.'));
if (!validateTime(hours)) {
return NaN;
}
return (hours % 24) * MILLISECONDS_IN_HOUR;
}
// hh:mm or hhmm
token = patterns.HHMM.exec(timeString);
if (token) {
hours = parseInt(token[1], 10);
minutes = parseFloat(token[2].replace(',', '.'));
if (!validateTime(hours, minutes)) {
return NaN;
}
return (hours % 24) * MILLISECONDS_IN_HOUR + minutes * MILLISECONDS_IN_MINUTE;
}
// hh:mm:ss or hhmmss
token = patterns.HHMMSS.exec(timeString);
if (token) {
hours = parseInt(token[1], 10);
minutes = parseInt(token[2], 10);
const seconds = parseFloat(token[3].replace(',', '.'));
if (!validateTime(hours, minutes, seconds)) {
return NaN;
}
return (hours % 24) * MILLISECONDS_IN_HOUR + minutes * MILLISECONDS_IN_MINUTE + seconds * 1000;
}
// Invalid ISO-formatted time
return null;
}
function dayOfISOWeekYear(isoWeekYear, week, day) {
week = week || 0;
day = day || 0;
const date = new Date(0);
date.setUTCFullYear(isoWeekYear, 0, 4);
const fourthOfJanuaryDay = date.getUTCDay() || 7;
const diff = week * 7 + day + 1 - fourthOfJanuaryDay;
date.setUTCDate(date.getUTCDate() + diff);
return date;
}
// Validation functions
const DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
const DAYS_IN_MONTH_LEAP_YEAR = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
function isLeapYearIndex(year) {
return year % 400 === 0 || (year % 4 === 0 && year % 100 !== 0);
}
function validateDate(year, month, date) {
if (month < 0 || month > 11) {
return false;
}
if (date != null) {
if (date < 1) {
return false;
}
const isLeapYear = isLeapYearIndex(year);
if (isLeapYear && date > DAYS_IN_MONTH_LEAP_YEAR[month]) {
return false;
}
if (!isLeapYear && date > DAYS_IN_MONTH[month]) {
return false;
}
}
return true;
}
function validateDayOfYearDate(year, dayOfYear) {
if (dayOfYear < 1) {
return false;
}
const isLeapYear = isLeapYearIndex(year);
if (isLeapYear && dayOfYear > 366) {
return false;
}
if (!isLeapYear && dayOfYear > 365) {
return false;
}
return true;
}
function validateWeekDate(week, day) {
if (week < 0 || week > 52) {
return false;
}
if (day != null && (day < 0 || day > 6)) {
return false;
}
return true;
}
function validateTime(hours, minutes, seconds) {
if (hours < 0 || hours >= 25) {
return false;
}
if (minutes != null && (minutes < 0 || minutes >= 60)) {
return false;
}
if (seconds != null && (seconds < 0 || seconds >= 60)) {
return fals