@variantjs/core
Version:
VariantJS common functions and utilities
1,176 lines • 51.1 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __objRest = (source, exclude) => {
var target = {};
for (var prop in source)
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
target[prop] = source[prop];
if (source != null && __getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(source)) {
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
target[prop] = source[prop];
}
return target;
};
const selectClasses = (classesObject) => Object.keys(classesObject).filter((className) => !!classesObject[className]);
const mergeClasses = (...classes) => classes.map((className) => {
if (typeof className === "string" || className === void 0) {
return className || "";
}
if (Array.isArray(className)) {
return mergeClasses(...className);
}
return mergeClasses(...selectClasses(className));
}).join(" ").replace(/ +/g, " ").trim();
const getCustomPropsFromVariant$1 = (variants, variant) => {
if (variant !== void 0 && variants) {
return variants[variant];
}
return void 0;
};
const parseVariant = (props, globalConfiguration, defaultConfiguration) => {
const _a = __spreadValues(__spreadValues(__spreadValues({}, defaultConfiguration), globalConfiguration), props), { variants, variant } = _a, mainProps = __objRest(_a, ["variants", "variant"]);
const customProps = getCustomPropsFromVariant$1(variants, variant);
const mergedProps = __spreadValues(__spreadValues({}, mainProps), customProps);
const _b = mergedProps, { classes, fixedClasses, class: className } = _b, componentProps = __objRest(_b, ["classes", "fixedClasses", "class"]);
const mergedClasses = mergeClasses(className, classes, fixedClasses);
if (mergedClasses) {
componentProps.class = mergedClasses;
}
return componentProps;
};
const pick = (object, condition = (value) => !!value) => {
const newObject = __spreadValues({}, object);
Object.keys(object).filter((key) => !condition(newObject[key], key)).forEach((key) => delete newObject[key]);
return newObject;
};
const hasProperty = (obj, prop) => obj !== null && typeof obj === "object" && Object.prototype.hasOwnProperty.call(obj, prop);
const getCustomPropsFromVariant = (variants, variant) => {
if (variant !== void 0 && variants) {
return variants[variant];
}
return void 0;
};
const getShouldClearClasses = (props, key, variant) => {
if (variant === void 0) {
return hasProperty(props, key) && (props[key] === void 0 || props[key] === null);
}
if (props.variants !== void 0 && props.variants[variant] !== void 0) {
const propsVariant = props.variants[variant];
return hasProperty(propsVariant, key) && (propsVariant[key] === void 0 || propsVariant[key] === null);
}
return false;
};
const parseVariantWithClassesList = (props, classesListKeys, globalConfiguration, defaultConfiguration) => {
const _a = __spreadValues(__spreadValues(__spreadValues({}, defaultConfiguration), globalConfiguration), props), { variants, variant } = _a, mainProps = __objRest(_a, ["variants", "variant"]);
const classes = {};
const fixedClasses = {};
const clearClasses = getShouldClearClasses(props, "classes", variant);
const clearFixedClasses = getShouldClearClasses(props, "fixedClasses", variant);
if (clearClasses) {
classesListKeys.forEach((classItemKey) => {
classes[classItemKey] = void 0;
});
} else {
classesListKeys.forEach((classItemKey) => {
if (props.classes !== void 0 && hasProperty(props.classes, classItemKey)) {
classes[classItemKey] = props.classes[classItemKey];
} else if (globalConfiguration !== void 0 && globalConfiguration.classes !== void 0 && hasProperty(globalConfiguration.classes, classItemKey)) {
classes[classItemKey] = globalConfiguration.classes[classItemKey];
} else if (defaultConfiguration !== void 0 && defaultConfiguration.classes !== void 0 && hasProperty(defaultConfiguration.classes, classItemKey)) {
classes[classItemKey] = defaultConfiguration.classes[classItemKey];
}
if (variant) {
if (props.variants !== void 0 && props.variants[variant] !== void 0) {
const propsVariant = props.variants[variant];
if (propsVariant.classes && hasProperty(propsVariant.classes, classItemKey)) {
classes[classItemKey] = propsVariant.classes[classItemKey];
}
} else if (globalConfiguration !== void 0 && globalConfiguration.variants !== void 0 && globalConfiguration.variants[variant] !== void 0) {
const globalConfigurationVariant = globalConfiguration.variants[variant];
if (globalConfigurationVariant.classes && hasProperty(globalConfigurationVariant.classes, classItemKey)) {
classes[classItemKey] = globalConfigurationVariant.classes[classItemKey];
}
} else if (defaultConfiguration !== void 0 && defaultConfiguration.variants !== void 0 && defaultConfiguration.variants[variant] !== void 0) {
const defaultConfigurationVariant = defaultConfiguration.variants[variant];
if (defaultConfigurationVariant.classes && hasProperty(defaultConfigurationVariant.classes, classItemKey)) {
classes[classItemKey] = defaultConfigurationVariant.classes[classItemKey];
}
}
}
});
}
if (clearFixedClasses) {
classesListKeys.forEach((classItemKey) => {
fixedClasses[classItemKey] = void 0;
});
} else {
classesListKeys.forEach((classItemKey) => {
if (props.fixedClasses !== void 0 && hasProperty(props.fixedClasses, classItemKey)) {
fixedClasses[classItemKey] = props.fixedClasses[classItemKey];
} else if (globalConfiguration !== void 0 && globalConfiguration.fixedClasses !== void 0 && hasProperty(globalConfiguration.fixedClasses, classItemKey)) {
fixedClasses[classItemKey] = globalConfiguration.fixedClasses[classItemKey];
} else if (defaultConfiguration !== void 0 && defaultConfiguration.fixedClasses !== void 0 && hasProperty(defaultConfiguration.fixedClasses, classItemKey)) {
fixedClasses[classItemKey] = defaultConfiguration.fixedClasses[classItemKey];
}
if (variant) {
if (props.variants !== void 0 && props.variants[variant] !== void 0) {
const propsVariant = props.variants[variant];
if (propsVariant.fixedClasses && hasProperty(propsVariant.fixedClasses, classItemKey)) {
fixedClasses[classItemKey] = propsVariant.fixedClasses[classItemKey];
}
} else if (globalConfiguration !== void 0 && globalConfiguration.variants !== void 0 && globalConfiguration.variants[variant] !== void 0) {
const globalConfigurationVariant = globalConfiguration.variants[variant];
if (globalConfigurationVariant.fixedClasses && hasProperty(globalConfigurationVariant.fixedClasses, classItemKey)) {
fixedClasses[classItemKey] = globalConfigurationVariant.fixedClasses[classItemKey];
}
} else if (defaultConfiguration !== void 0 && defaultConfiguration.variants !== void 0 && defaultConfiguration.variants[variant] !== void 0) {
const defaultConfigurationVariant = defaultConfiguration.variants[variant];
if (defaultConfigurationVariant.fixedClasses && hasProperty(defaultConfigurationVariant.fixedClasses, classItemKey)) {
fixedClasses[classItemKey] = defaultConfigurationVariant.fixedClasses[classItemKey];
}
}
}
});
}
const customProps = getCustomPropsFromVariant(variants, variant);
const mergedProps = __spreadValues(__spreadValues({}, mainProps), customProps);
delete mergedProps.fixedClasses;
delete mergedProps.classes;
const mergedClasses = {};
classesListKeys.forEach((classItemKey) => {
const classesForTheCurrentKey = classes[classItemKey];
const fixedClassesForTheCurrentKey = fixedClasses[classItemKey];
mergedClasses[classItemKey] = mergeClasses(classesForTheCurrentKey, fixedClassesForTheCurrentKey);
});
const result = pick(mergedClasses);
if (Object.keys(result).length > 0) {
mergedProps.classesList = result;
}
return mergedProps;
};
const get = (object, path, defaultValue) => {
const result = String(path).replace(/\[/g, ".").replace(/\]/g, "").split(".").reduce((objectSoFar, step) => {
if (typeof objectSoFar === "object" || Array.isArray(objectSoFar)) {
return objectSoFar[step];
}
return void 0;
}, object);
return result === void 0 ? defaultValue : result;
};
const guessOptionValue = (option, valueAttribute) => {
if (valueAttribute) {
const value = get(option, valueAttribute);
if (value === null) {
return null;
}
if (typeof value === "undefined") {
return void 0;
}
if (typeof value === "number" || typeof value === "string") {
return value;
}
return String(value);
}
return option.value;
};
const guessOptionText = (option, textAttribute) => {
if (textAttribute) {
const text = get(option, textAttribute);
if (typeof text === "undefined" || text === null) {
return "";
}
if (typeof text === "number" || typeof text === "string") {
return text;
}
return String(text);
}
return option.text;
};
const normalizeOption = (option, textAttribute, valueAttribute) => {
if (typeof option === "string" || typeof option === "number") {
return {
value: option,
text: option,
raw: option
};
}
const normalizedOption = {
value: guessOptionValue(option, valueAttribute),
text: guessOptionText(option, textAttribute),
raw: option
};
if (option.disabled) {
normalizedOption.disabled = true;
}
if (option.children) {
normalizedOption.children = normalizeOptions(option.children, textAttribute, valueAttribute);
}
return normalizedOption;
};
const normalizeOptions = (options, textAttribute, valueAttribute) => {
if (Array.isArray(options)) {
return options.map((option) => normalizeOption(option, textAttribute, valueAttribute));
}
if (typeof options === "object") {
return Object.keys(options).map((optionKey) => ({
value: optionKey,
text: options[optionKey]
}));
}
return [];
};
const flattenOptions = (options) => options.flatMap((option) => {
if (option.children) {
return flattenOptions(option.children);
}
return option;
});
const filterOptions = (options, query) => {
if (query === "") {
return options;
}
return options.map((option) => {
if (option.children) {
const newOption = __spreadValues(__spreadValues({}, option), {
children: filterOptions(option.children, query)
});
return newOption;
}
return option;
}).filter((option) => {
const foundText = String(option.text).toUpperCase().trim().includes(query.toUpperCase().trim());
const hasChildren = option.children && option.children.length > 0;
return hasChildren || foundText;
});
};
const TInputConfig = {
classes: "block w-full px-3 py-2 text-black placeholder-gray-400 transition duration-100 ease-in-out bg-white border border-gray-300 rounded shadow-sm focus:border-blue-500 focus:ring-2 focus:ring-blue-500 focus:outline-none focus:ring-opacity-50 disabled:opacity-50 disabled:cursor-not-allowed"
};
const TTextareaConfig = {
classes: "block w-full px-3 py-2 text-black placeholder-gray-400 transition duration-100 ease-in-out bg-white border border-gray-300 rounded shadow-sm focus:border-blue-500 focus:ring-2 focus:ring-blue-500 focus:outline-none focus:ring-opacity-50 disabled:opacity-50 disabled:cursor-not-allowed"
};
const TButtonConfig = {
classes: "block px-4 py-2 text-white transition duration-100 ease-in-out bg-blue-500 border border-transparent rounded shadow-sm hover:bg-blue-600 focus:border-blue-500 focus:ring-2 focus:ring-blue-500 focus:outline-none focus:ring-opacity-50 disabled:opacity-50 disabled:cursor-not-allowed"
};
const TSelectConfig = {
classes: "block w-full pl-3 pr-10 py-2 text-black placeholder-gray-400 transition duration-100 ease-in-out bg-white border border-gray-300 rounded shadow-sm focus:border-blue-500 focus:ring-2 focus:ring-blue-500 focus:outline-none focus:ring-opacity-50 disabled:opacity-50 disabled:cursor-not-allowed"
};
const TCheckboxConfig = {
classes: "text-blue-500 transition duration-100 ease-in-out border-gray-300 rounded shadow-sm focus:border-blue-500 focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50 focus:ring-offset-0 disabled:opacity-50 disabled:cursor-not-allowed"
};
const TRadioConfig = {
classes: "text-blue-500 transition duration-100 ease-in-out border-gray-300 shadow-sm focus:border-blue-500 focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50 focus:ring-offset-0 disabled:opacity-50 disabled:cursor-not-allowed"
};
const TTagConfig = {
classes: ""
};
const TCardConfig = {
classes: {
wrapper: "bg-white border border-gray-100 rounded shadow-sm",
body: "p-3",
header: "p-3 border-b border-gray-100 rounded-t",
footer: "p-3 border-t border-gray-100 rounded-b"
}
};
const TCardClassesKeys = Object.keys(TCardConfig.classes);
const TModalConfig = {
fixedClasses: {
overlay: "fixed top-0 bottom-0 left-0 right-0 w-full h-full overflow-auto scrolling-touch",
wrapper: "relative mx-auto",
modal: "relative overflow-visible"
},
classes: {
overlay: "z-40 bg-black bg-opacity-50",
wrapper: "z-50 max-w-lg px-3 py-12",
close: "absolute top-0 right-0 z-10 flex items-center justify-center w-8 h-8 -m-3 text-gray-700 transition ease-in-out bg-gray-100 rounded-full shadow duration-400 focus:ring-2 focus:ring-blue-500 focus:outline-none focus:ring-opacity-50 hover:bg-gray-200",
closeIcon: "w-4 h-4",
modal: "bg-white rounded shadow",
header: "p-3 border-b border-gray-100 rounded-t",
body: "p-3",
footer: "p-3 bg-gray-100 rounded-b",
overlayEnterActiveClass: "transition duration-300 ease-out",
overlayEnterFromClass: "transform opacity-0",
overlayEnterToClass: "transform opacity-100",
overlayLeaveActiveClass: "transition duration-300 ease-in",
overlayLeaveFromClass: "transform opacity-100",
overlayLeaveToClass: "transform opacity-0",
enterActiveClass: "transition duration-100 ease-out",
enterFromClass: "transform scale-95 opacity-0",
enterToClass: "transform scale-100 opacity-100",
leaveActiveClass: "transition duration-100 ease-in",
leaveFromClass: "transform scale-100 opacity-100",
leaveToClass: "transform scale-95 opacity-0"
}
};
var ModalHideReason;
(function(ModalHideReason2) {
ModalHideReason2["Outside"] = "outside";
ModalHideReason2["Close"] = "close";
ModalHideReason2["Esc"] = "esc";
ModalHideReason2["Method"] = "method";
ModalHideReason2["Value"] = "value";
ModalHideReason2["Other"] = "other";
})(ModalHideReason || (ModalHideReason = {}));
const TModalClassesKeys = Object.keys(TModalConfig.classes);
const { overlay: fixedOverlay, wrapper: fixedWrapper, modal: fixedDialog } = TModalConfig.fixedClasses;
const { overlay, wrapper, close, closeIcon, modal: dialog, overlayEnterActiveClass, overlayEnterFromClass, overlayEnterToClass, overlayLeaveActiveClass, overlayLeaveFromClass, overlayLeaveToClass, enterActiveClass, enterFromClass, enterToClass, leaveActiveClass, leaveFromClass, leaveToClass } = TModalConfig.classes;
const TDialogConfig = {
fixedClasses: {
overlay: fixedOverlay,
wrapper: fixedWrapper,
dialog: fixedDialog
},
classes: {
overlay,
wrapper,
close: `${close} disabled:text-opacity-50 disabled:cursor-not-allowed`,
closeIcon,
dialog,
body: "relative p-3",
content: "flex flex-col justify-center w-full",
iconWrapper: "flex items-center justify-center flex-shrink-0 w-12 h-12 mx-auto mb-2 bg-gray-100 rounded-full",
icon: "w-6 h-6 text-gray-700",
titleWrapper: "",
title: "text-lg font-medium leading-6 text-center text-gray-900",
textWrapper: "w-full text-center",
text: "text-sm text-gray-500",
buttons: "flex justify-center p-3 space-x-4 bg-gray-100 rounded-b",
cancelButton: "block w-full max-w-xs px-4 py-2 transition duration-100 ease-in-out bg-white border border-gray-300 rounded shadow-sm hover:bg-gray-100 focus:border-gray-100 focus:ring-2 focus:ring-blue-500 focus:outline-none focus:ring-opacity-50 disabled:opacity-50 disabled:cursor-not-allowed",
okButton: "block w-full max-w-xs px-4 py-2 text-white transition duration-100 ease-in-out bg-blue-500 border border-transparent rounded shadow-sm hover:bg-blue-600 focus:border-blue-500 focus:ring-2 focus:ring-blue-500 focus:outline-none focus:ring-opacity-50 disabled:opacity-50 disabled:cursor-not-allowed",
inputWrapper: "mt-3",
inputValidationError: "mt-1 text-sm font-semibold text-red-600",
input: TInputConfig.classes,
errorMessage: "block p-3 mb-3 -mx-3 -mt-3 text-sm text-center text-red-500 rounded-t bg-red-50",
busyWrapper: "absolute top-0 left-0 flex items-center justify-center w-full h-full bg-white bg-opacity-75",
busyIcon: "w-6 h-6 text-gray-500",
enterActiveClass,
enterFromClass,
enterToClass,
leaveActiveClass,
leaveFromClass,
leaveToClass,
overlayEnterActiveClass,
overlayEnterFromClass,
overlayEnterToClass,
overlayLeaveActiveClass,
overlayLeaveFromClass,
overlayLeaveToClass
}
};
var DialogType;
(function(DialogType2) {
DialogType2["Alert"] = "alert";
DialogType2["Confirm"] = "confirm";
DialogType2["Prompt"] = "prompt";
})(DialogType || (DialogType = {}));
var DialogIcon;
(function(DialogIcon2) {
DialogIcon2["Success"] = "success";
DialogIcon2["Error"] = "error";
DialogIcon2["Warning"] = "warning";
DialogIcon2["Info"] = "info";
DialogIcon2["Question"] = "question";
})(DialogIcon || (DialogIcon = {}));
var DialogHideReason;
(function(DialogHideReason2) {
DialogHideReason2["Outside"] = "outside";
DialogHideReason2["Close"] = "close";
DialogHideReason2["Esc"] = "esc";
DialogHideReason2["Method"] = "method";
DialogHideReason2["Value"] = "value";
DialogHideReason2["Other"] = "other";
DialogHideReason2["Cancel"] = "cancel";
DialogHideReason2["Ok"] = "ok";
})(DialogHideReason || (DialogHideReason = {}));
const TDialogClassesKeys = Object.keys(TDialogConfig.classes);
const enterAndLeave = {
enterActiveClass: "transition-opacity duration-100 ease-out",
enterFromClass: "transform scale-95 opacity-0",
enterToClass: "transform scale-100 opacity-100",
leaveActiveClass: "transition-opacity duration-75 ease-in",
leaveFromClass: "transform scale-100 opacity-100",
leaveToClass: "transform scale-95 opacity-0"
};
const TAlertConfig = {
classes: __spreadValues({
wrapper: "relative flex items-center p-4 border-l-4 border-blue-500 rounded shadow-sm bg-blue-50",
body: "flex-grow",
close: "relative flex items-center justify-center flex-shrink-0 w-6 h-6 ml-4 text-blue-500 transition duration-100 ease-in-out rounded hover:bg-blue-200 focus:ring-2 focus:ring-blue-500 focus:outline-none focus:ring-opacity-50",
closeIcon: "w-4 h-4"
}, enterAndLeave)
};
const TAlertClassesKeys = Object.keys(TAlertConfig.classes);
const TInputGroupConfig = {
classes: {
wrapper: "",
label: "block",
body: "",
feedback: "text-sm text-gray-400",
description: "text-sm text-gray-400"
}
};
const TInputGroupClassesKeys = Object.keys(TInputGroupConfig.classes);
const TDropdownConfig = {
classes: __spreadValues({
trigger: TButtonConfig.classes,
dropdown: "w-56 bg-white rounded shadow z-10"
}, enterAndLeave)
};
const TDropdownClassesKeys = Object.keys(TDropdownConfig.classes);
const TDropdownPopperDefaultOptions = {
placement: "bottom",
modifiers: [
{
name: "offset",
options: {
offset: [0, 10]
}
}
],
strategy: "absolute",
onFirstUpdate: void 0
};
const TRichSelectConfig = {
classes: __spreadValues({
wrapper: "relative",
trigger: "flex items-center justify-between w-full px-3 py-2 text-left text-black transition duration-100 ease-in-out bg-white border border-gray-300 rounded shadow-sm focus:border-blue-500 focus:ring-2 focus:ring-blue-500 focus:outline-none focus:ring-opacity-50 disabled:opacity-50 disabled:cursor-not-allowed",
dropdown: "z-10 bg-white rounded shadow-lg",
dropdownContent: "p-2 space-y-2",
clearButton: "absolute flex items-center justify-center w-6 h-6 text-gray-600 transition duration-100 ease-in-out rounded mt-2.5 mr-2 top-0 right-0 hover:bg-gray-100 focus:ring-2 focus:ring-blue-500 focus:outline-none focus:ring-opacity-50",
optionsList: "space-y-1",
optionsListLoadingMore: "flex items-center justify-between px-3 py-2 text-sm text-gray-400",
optionWrapper: "",
option: "w-full rounded cursor-pointer disabled:cursor-not-allowed disabled:opacity-50",
selectedOption: "font-semibold text-white bg-blue-500",
highlightedOption: "bg-blue-100",
selectedHighlightedOption: "font-semibold text-white bg-blue-600",
optionContent: "flex items-center justify-between px-3 py-2",
optionLabel: "block truncate",
optionSelectedIcon: "w-5 h-5",
optgroup: "space-y-2",
optgroupContent: "",
optgroupLabel: "block px-3 py-2 text-xs text-gray-400 uppercase truncate",
optgroupOptionsList: "px-2 pb-2",
searchWrapper: "inline-block w-full placeholder-gray-400",
searchInput: "inline-block w-full px-3 py-2 text-sm border border-gray-300 rounded shadow-inner bg-gray-50 focus:border-blue-500 focus:ring-2 focus:ring-blue-500 focus:outline-none focus:ring-opacity-50",
searchingText: "text-sm text-gray-400",
needsMoreCharsText: "text-sm text-gray-400",
noResultsText: "text-sm text-gray-400",
selectButtonLabel: "block pr-4 truncate",
selectButtonPlaceholder: "block text-gray-400 truncate",
selectButtonSearchingPlaceholder: "block text-gray-400 truncate",
selectButtonLoadingIcon: "flex-shrink-0 w-4 h-4 ml-1 text-gray-600",
selectButtonSelectorIcon: "flex-shrink-0 w-4 h-4 ml-1 text-gray-600",
tagsWrapper: "flex flex-wrap overflow-hidden -mx-2 -my-2.5 py-1 pr-8",
tag: "bg-blue-500 disabled:cursor-not-allowed disabled:opacity-50 duration-100 ease-in-out focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50 rounded shadow-sm text-sm text-white transition white-space-no m-0.5 max-w-full h-8 flex items-center cursor-pointer",
tagLabel: "px-3",
tagDeleteButton: "-ml-1.5 h-full hover:bg-blue-600 hover:shadow-sm inline-flex items-center px-2 transition focus:border-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-600 focus:ring-opacity-50 rounded-r",
tagDeleteButtonIcon: "w-3 h-3"
}, enterAndLeave)
};
const TRichSelectClassesKeys = Object.keys(TRichSelectConfig.classes);
const TDatepickerConfig = {
classes: {
dropdownWrapper: "relative z-10",
dropdown: "absolute mt-1 overflow-hidden origin-top-left bg-white rounded shadow",
inlineWrapper: "",
inlineViews: "inline-flex flex-col mt-1 bg-white border rounded",
inputWrapper: "",
input: "block w-full px-3 py-2 text-black placeholder-gray-400 transition duration-100 ease-in-out bg-white border border-gray-300 rounded shadow-sm focus:border-blue-500 focus:ring-2 focus:ring-blue-500 focus:outline-none focus:ring-opacity-50 disabled:opacity-50 disabled:cursor-not-allowed",
clearButton: "text-gray-600 transition duration-100 ease-in-out rounded hover:bg-gray-100",
clearButtonIcon: "",
viewGroup: "",
view: "",
navigator: "px-3 pt-2",
navigatorViewButton: "inline-flex px-2 py-1 -ml-1 transition duration-100 ease-in-out rounded-full cursor-pointer hover:bg-gray-100",
navigatorViewButtonIcon: "text-gray-400 fill-current",
navigatorViewButtonBackIcon: "text-gray-400 fill-current",
navigatorViewButtonMonth: "font-semibold text-gray-700",
navigatorViewButtonYear: "ml-1 text-gray-500",
navigatorViewButtonYearRange: "ml-1 text-gray-500",
navigatorLabel: "py-1",
navigatorLabelMonth: "font-semibold text-gray-700",
navigatorLabelYear: "ml-1 text-gray-500",
navigatorPrevButton: "inline-flex p-1 ml-2 ml-auto transition duration-100 ease-in-out rounded-full cursor-pointer hover:bg-gray-100 disabled:opacity-50 disabled:cursor-not-allowed",
navigatorNextButton: "inline-flex p-1 -mr-1 transition duration-100 ease-in-out rounded-full cursor-pointer hover:bg-gray-100 disabled:opacity-50 disabled:cursor-not-allowed",
navigatorPrevButtonIcon: "text-gray-400",
navigatorNextButtonIcon: "text-gray-400",
calendarWrapper: "px-3 py-2",
calendarHeaderWrapper: "",
calendarHeaderWeekDay: "flex items-center justify-center w-8 h-8 text-xs text-gray-500 uppercase",
calendarDaysWrapper: "",
calendarDaysDayWrapper: "flex items-center flex-shrink-0 w-full h-8",
otherMonthDay: "w-8 h-8 mx-auto text-sm text-gray-400 rounded-full hover:bg-blue-100 disabled:opacity-50 disabled:cursor-not-allowed",
emptyDay: "",
inRangeFirstDay: "w-full h-8 text-sm text-white bg-blue-500 rounded-l-full",
inRangeLastDay: "w-full h-8 text-sm text-white bg-blue-500 rounded-r-full",
inRangeDay: "w-full h-8 text-sm bg-blue-200 disabled:opacity-50 disabled:cursor-not-allowed",
selectedDay: "w-8 h-8 mx-auto text-sm text-white bg-blue-500 rounded-full disabled:opacity-50 disabled:cursor-not-allowed",
activeDay: "w-8 h-8 mx-auto text-sm bg-blue-100 rounded-full disabled:opacity-50 disabled:cursor-not-allowed",
highlightedDay: "w-8 h-8 mx-auto text-sm bg-blue-200 rounded-full disabled:opacity-50 disabled:cursor-not-allowed",
day: "w-8 h-8 mx-auto text-sm rounded-full hover:bg-blue-100 disabled:opacity-50 disabled:cursor-not-allowed",
today: "w-8 h-8 mx-auto text-sm border border-blue-500 rounded-full hover:bg-blue-100 disabled:opacity-50 disabled:cursor-not-allowed",
monthWrapper: "px-3 py-2",
selectedMonth: "w-full h-12 mx-auto text-sm text-white bg-blue-500 rounded",
activeMonth: "w-full h-12 mx-auto text-sm bg-blue-100 rounded",
month: "w-full h-12 mx-auto text-sm rounded hover:bg-blue-100",
yearWrapper: "px-3 py-2",
year: "w-full h-12 mx-auto text-sm rounded hover:bg-blue-100",
selectedYear: "w-full h-12 mx-auto text-sm text-white bg-blue-500 rounded",
activeYear: "w-full h-12 mx-auto text-sm bg-blue-100 rounded",
timepickerWrapper: "flex items-center px-4 py-2 space-x-2",
timepickerTimeWrapper: "flex items-center space-x-2",
timepickerTimeFieldsWrapper: "flex items-center w-full text-right bg-gray-100 border border-gray-100 rounded-md focus:border-blue-500 focus:ring-2 focus:ring-blue-500 focus:outline-none focus:ring-opacity-50",
timepickerOkButton: "text-sm font-semibold text-blue-600 uppercase transition duration-100 ease-in-out border border-transparent rounded cursor-pointer focus:border-blue-500 focus:ring-2 focus:ring-blue-500 focus:outline-none focus:ring-opacity-50",
timepickerInput: "w-8 h-6 p-0 text-sm text-center transition duration-100 ease-in-out bg-transparent border border-transparent rounded focus:border-blue-500 focus:ring-2 focus:ring-blue-500 focus:outline-none focus:ring-opacity-50",
timepickerTimeLabel: "flex-grow text-sm text-gray-500",
timepickerAmPmWrapper: "relative inline-flex flex-shrink-0 transition duration-200 ease-in-out bg-gray-100 border border-transparent rounded cursor-pointer focus:border-blue-500 focus:ring-2 focus:ring-blue-500 focus:outline-none focus:ring-opacity-50",
timepickerAmPmWrapperChecked: "relative inline-flex flex-shrink-0 transition duration-200 ease-in-out bg-gray-100 border border-transparent rounded cursor-pointer focus:border-blue-500 focus:ring-2 focus:ring-blue-500 focus:outline-none focus:ring-opacity-50",
timepickerAmPmWrapperDisabled: "relative inline-flex flex-shrink-0 transition duration-200 ease-in-out opacity-50 cursor-not-allowed",
timepickerAmPmWrapperCheckedDisabled: "relative inline-flex flex-shrink-0 transition duration-200 ease-in-out opacity-50 cursor-not-allowed",
timepickerAmPmButton: "absolute flex items-center justify-center w-6 h-6 text-xs text-gray-800 transition duration-200 ease-in-out transform translate-x-0 bg-white rounded shadow",
timepickerAmPmButtonChecked: "absolute flex items-center justify-center w-6 h-6 text-xs text-gray-800 transition duration-200 ease-in-out transform translate-x-full bg-white rounded shadow",
timepickerAmPmCheckedPlaceholder: "flex items-center justify-center w-6 h-6 text-xs text-gray-500 rounded-sm",
timepickerAmPmUncheckedPlaceholder: "flex items-center justify-center w-6 h-6 text-xs text-gray-500 rounded-sm"
}
};
const TDatepickerClassesKeys = Object.keys(TDatepickerConfig.classes);
const TToggleConfig = {
classes: {
wrapper: "bg-gray-100 border-2 border-transparent rounded-full focus:ring-2 focus:ring-blue-500 focus:outline-none focus:ring-opacity-50",
wrapperChecked: "bg-blue-500 border-2 border-transparent rounded-full focus:ring-2 focus:ring-blue-500 focus:outline-none focus:ring-opacity-50",
wrapperDisabled: "bg-gray-100 border-2 border-transparent rounded-full focus:ring-2 focus:ring-blue-500 focus:outline-none focus:ring-opacity-50",
wrapperCheckedDisabled: "bg-blue-500 border-2 border-transparent rounded-full focus:ring-2 focus:ring-blue-500 focus:outline-none focus:ring-opacity-50",
button: "flex items-center justify-center w-5 h-5 text-xs text-gray-400 bg-white rounded-full shadow",
buttonChecked: "flex items-center justify-center w-5 h-5 text-xs text-blue-500 bg-white rounded-full shadow",
checkedPlaceholder: "flex items-center justify-center w-5 h-5 text-xs text-gray-400 rounded-full",
uncheckedPlaceholder: "flex items-center justify-center w-5 h-5 text-xs text-gray-400 rounded-full"
},
fixedClasses: {
wrapper: "relative inline-flex flex-shrink-0 items-center transition-colors duration-200 ease-in-out cursor-pointer",
wrapperChecked: "relative inline-flex flex-shrink-0 items-center transition-colors duration-200 ease-in-out cursor-pointer",
wrapperDisabled: "relative inline-flex flex-shrink-0 items-center transition-colors duration-200 ease-in-out opacity-50 cursor-pointer cursor-not-allowed",
wrapperCheckedDisabled: "relative inline-flex flex-shrink-0 items-center transition-colors duration-200 ease-in-out opacity-50 cursor-pointer cursor-not-allowed",
button: "absolute transition duration-200 ease-in-out transform translate-x-0",
buttonChecked: "absolute transition duration-200 ease-in-out transform translate-x-full",
checkedPlaceholder: "",
uncheckedPlaceholder: ""
}
};
const TToggleClassesKeys = Object.keys(TToggleConfig.classes);
const TWrappedRadioClassesKeys = ["wrapper", "wrapperChecked", "inputWrapper", "inputWrapperChecked", "input", "label", "labelChecked"];
const TWrappedRadioConfig = {
classes: {
wrapper: "flex items-center space-x-2",
inputWrapper: "inline-flex",
label: "",
input: TRadioConfig.classes
}
};
const TWrappedCheckboxClassesKeys = ["wrapper", "wrapperChecked", "inputWrapper", "inputWrapperChecked", "input", "label", "labelChecked"];
const TWrappedCheckboxConfig = {
classes: {
wrapper: "flex items-center space-x-2",
inputWrapper: "inline-flex",
label: "",
input: TCheckboxConfig.classes
}
};
const addToArray = (arr, value) => {
if (!Array.isArray(arr)) {
return [value];
}
return [...arr, value];
};
const clone = (obj) => {
if (obj instanceof Date) {
return new Date(obj.valueOf());
}
return JSON.parse(JSON.stringify(obj));
};
const debounce = (func, wait = 200) => {
let timeout;
const cancel = () => {
if (timeout) {
clearTimeout(timeout);
}
};
const debounceFn = (...args) => {
cancel();
timeout = setTimeout(() => {
timeout = void 0;
func(args);
}, wait);
if (!wait) {
func(args);
}
};
return Object.assign(debounceFn, { cancel });
};
const elementIsTargetOrTargetChild = (target, wrapper2) => {
if (!(target instanceof Element)) {
return false;
}
return wrapper2.contains(target);
};
const getFocusableElements = (element) => Array.from(element.querySelectorAll('a, button, input, textarea, select, details, [contenteditable], [tabindex]:not([tabindex="-1"])')).filter((el) => !el.hasAttribute("disabled"));
const isEqual = (a, b) => JSON.stringify(a) === JSON.stringify(b);
const isPrimitive = (value) => {
if (value === null) {
return true;
}
return !["array", "function", "object"].includes(typeof value);
};
const isTouchOnlyDevice = (w) => {
if (w === void 0) {
if (window === void 0) {
return false;
}
w = window;
}
return !!(w.matchMedia && w.matchMedia("(any-hover: none)").matches);
};
const normalizedOptionIsDisabled = (option) => option.disabled === true || option.disabled === "disabled";
const normalizeMeasure = (measure) => {
if (measure === null || measure === void 0) {
return void 0;
}
if (typeof measure === "number") {
return `${measure}px`;
}
if (String(Number(measure)) === measure) {
return `${Number(measure)}px`;
}
return measure;
};
const promisify = (value) => {
if (value instanceof Promise) {
return value;
}
return Promise.resolve(value);
};
const promisifyFunctionResult = (fn, ...args) => {
const result = fn(...args);
return promisify(result);
};
const range = (start, end) => {
const length = end - start + 1;
return Array.from({ length }, (_, i) => start + i);
};
const substractFromArray = (arr, value) => {
if (!Array.isArray(arr)) {
return [];
}
const index = arr.findIndex((valueInOriginal) => isEqual(valueInOriginal, value));
if (index === -1) {
return arr;
}
const newArray = [...arr];
newArray.splice(index, 1);
return newArray;
};
const throttle = (func, wait = 200) => {
let isCalled = false;
return (...args) => {
if (!isCalled) {
func(...args);
isCalled = true;
setTimeout(() => {
isCalled = false;
}, wait);
}
};
};
const pad$1 = (number, length = 2) => String(number).padStart(length, "0");
const English = {
weekdays: {
shorthand: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
longhand: [
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
]
},
months: {
shorthand: [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
],
longhand: [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
]
},
daysInMonth: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
firstDayOfWeek: 0,
ordinal: (nth) => {
const s = nth % 100;
switch (s % 10) {
case 1:
return "st";
case 2:
return "nd";
case 3:
return "rd";
default:
return "th";
}
},
rangeSeparator: " to ",
weekAbbreviation: "Wk",
amPM: ["AM", "PM"],
yearAriaLabel: "Year",
monthAriaLabel: "Month",
hourAriaLabel: "Hour",
minuteAriaLabel: "Minute",
time24hr: false,
timeLabel: "Time",
okLabel: "Ok"
};
var WeekDay;
(function(WeekDay2) {
WeekDay2[WeekDay2["Sunday"] = 0] = "Sunday";
WeekDay2[WeekDay2["Monday"] = 1] = "Monday";
WeekDay2[WeekDay2["Tuesday"] = 2] = "Tuesday";
WeekDay2[WeekDay2["Wednesday"] = 3] = "Wednesday";
WeekDay2[WeekDay2["Thursday"] = 4] = "Thursday";
WeekDay2[WeekDay2["Friday"] = 5] = "Friday";
WeekDay2[WeekDay2["Saturday"] = 6] = "Saturday";
})(WeekDay || (WeekDay = {}));
const getDateInDayNumber = (fromDate, dayNumber) => {
const newDate = clone(fromDate);
newDate.setUTCDate(dayNumber);
return newDate;
};
const getFirstDayOfMonth = (fromDate) => {
const newDate = clone(fromDate);
newDate.setUTCDate(1);
return newDate;
};
const getFirstDayOfNextMonth = (fromDate) => {
const newDate = clone(fromDate);
newDate.setMonth(fromDate.getMonth() + 1);
if (newDate.getMonth() > fromDate.getMonth() + 1) {
newDate.setUTCDate(0);
}
newDate.setUTCDate(1);
return newDate;
};
const getFirstDayOfPrevMonth = (fromDate) => {
const newDate = clone(fromDate);
newDate.setUTCDate(0);
newDate.setUTCDate(1);
return newDate;
};
const getLastDayOfMonth = (fromDate) => {
const newDate = clone(fromDate);
newDate.setMonth(fromDate.getMonth() + 1);
if (newDate.getMonth() > fromDate.getMonth() + 1) {
newDate.setUTCDate(0);
}
newDate.setUTCDate(0);
return newDate;
};
const getLastDayOfPrevMonth = (fromDate) => {
const newDate = clone(fromDate);
newDate.setUTCDate(0);
return newDate;
};
const getNextMonthDays = (firstDayOfNextMonth, monthDays, prevMonthDays) => {
const nextMonthTotalDays = 7 - (monthDays.length + prevMonthDays.length) % 7;
if (nextMonthTotalDays === 7) {
return [];
}
return Array.from({ length: nextMonthTotalDays }, (_x, i) => i + 1).map((day) => getDateInDayNumber(firstDayOfNextMonth, day));
};
const getMonthDays = (month, lastDayOfMonth) => Array.from({ length: lastDayOfMonth.getDate() }, (_x, i) => i + 1).map((day) => getDateInDayNumber(month, day));
const getPreviousMonthDays = (month, firstDayOfPrevMonth, lastDayOfPrevMonth, weekstart) => {
let prevMonthTotalDays = getFirstDayOfMonth(month).getDay() - weekstart;
if (prevMonthTotalDays < 0) {
prevMonthTotalDays = 7 + prevMonthTotalDays;
}
return Array.from({ length: prevMonthTotalDays }, (_x, i) => lastDayOfPrevMonth.getDate() - i).reverse().map((day) => getDateInDayNumber(firstDayOfPrevMonth, day));
};
const visibleDaysInMonthView = (month, weekstart = WeekDay.Sunday) => {
const firstDayOfPrevMonth = getFirstDayOfPrevMonth(month);
const lastDayOfPrevMonth = getLastDayOfPrevMonth(month);
const lastDayOfMonth = getLastDayOfMonth(month);
const firstDayOfNextMonth = getFirstDayOfNextMonth(month);
const prevMonthDays = getPreviousMonthDays(month, firstDayOfPrevMonth, lastDayOfPrevMonth, weekstart);
const monthDays = getMonthDays(month, lastDayOfMonth);
const nextMonthDays = getNextMonthDays(firstDayOfNextMonth, monthDays, prevMonthDays);
return prevMonthDays.concat(monthDays, nextMonthDays);
};
const isSameYear = (date1, date2) => {
if (!date1 || !date2) {
return false;
}
return date1.getFullYear() === date2.getFullYear();
};
const isSameMonth = (date1, date2) => {
if (!date1 || !date2) {
return false;
}
return date1.getFullYear() === date2.getFullYear() && date1.getMonth() === date2.getMonth();
};
const isSameDay = (date1, date2) => {
if (!date1 || !date2) {
return false;
}
return date1.getDate() === date2.getDate() && date1.getMonth() === date2.getMonth() && date1.getFullYear() === date2.getFullYear();
};
const isToday = (date) => isSameDay(date, new Date());
const diffInDays = (date1, date2, absolute = false) => {
const MS_PER_DAY = 1e3 * 60 * 60 * 24;
if (!date1 || !date2) {
return false;
}
const utc1 = Date.UTC(date1.getFullYear(), date1.getMonth(), date1.getDate());
const utc2 = Date.UTC(date2.getFullYear(), date2.getMonth(), date2.getDate());
const diff = Math.floor((utc2 - utc1) / MS_PER_DAY);
if (absolute) {
return Math.abs(diff);
}
return diff;
};
const addDays = (date, amount = 1) => {
const result = clone(date);
result.setDate(result.getDate() + amount);
return result;
};
const addMonths = (date, amount = 1) => {
let newDate = clone(date);
newDate.setMonth(date.getMonth() + amount);
if (newDate.getDate() !== date.getDate()) {
newDate = getLastDayOfPrevMonth(newDate);
}
return newDate;
};
const addYears = (date, amount = 1) => {
let newDate = clone(date);
newDate.setFullYear(date.getFullYear() + amount);
if (newDate.getDate() !== date.getDate()) {
newDate = getLastDayOfPrevMonth(newDate);
}
return newDate;
};
const YEAR_ZERO_TIMESTAMP = -621672192e5;
const YEAR_9999_TIMESTAMP = 253402300799999;
const dateIsValid = (date) => {
if (date === void 0) {
return true;
}
return date instanceof Date && date.getTime() >= YEAR_ZERO_TIMESTAMP && date.getTime() <= YEAR_9999_TIMESTAMP && date.getTime() === date.getTime() && isFinite(date.getTime());
};
const boolToInt$1 = (bool) => bool === true ? 1 : 0;
const doNothing = () => void 0;
const tokenParsingFunctions = {
D: doNothing,
F(dateObj, monthName, locale) {
dateObj.setMonth(locale.months.longhand.indexOf(monthName));
},
G: (dateObj, hour) => {
dateObj.setHours(parseFloat(hour));
},
H: (dateObj, hour) => {
dateObj.setHours(parseFloat(hour));
},
J: (dateObj, day) => {
dateObj.setDate(parseFloat(day));
},
K: (dateObj, amPM, locale) => {
dateObj.setHours(dateObj.getHours() % 12 + 12 * boolToInt$1(new RegExp(locale.amPM[1], "i").test(amPM)));
},
M(dateObj, shortMonth, locale) {
dateObj.setMonth(locale.months.shorthand.indexOf(shortMonth));
},
S: (dateObj, seconds) => {
dateObj.setSeconds(parseFloat(seconds));
},
U: (_, unixSeconds) => new Date(parseFloat(unixSeconds) * 1e3),
W(dateObj, weekNum, locale) {
const weekNumber = parseInt(weekNum, 10);
const date = new Date(dateObj.getFullYear(), 0, 2 + (weekNumber - 1) * 7, 0, 0, 0, 0);
date.setDate(date.getDate() - date.getDay() + locale.firstDayOfWeek);
return date;
},
Y: (dateObj, year) => {
dateObj.setFullYear(parseFloat(year));
},
Z: (_, ISODate) => new Date(ISODate),
d: (dateObj, day) => {
dateObj.setDate(parseFloat(day));
},
h: (dateObj, hour) => {
dateObj.setHours(parseFloat(hour));
},
i: (dateObj, minutes) => {
dateObj.setMinutes(parseFloat(minutes));
},
j: (dateObj, day) => {
dateObj.setDate(parseFloat(day));
},
l: doNothing,
m: (dateObj, month) => {
dateObj.setMonth(parseFloat(month) - 1);
},
n: (dateObj, month) => {
dateObj.setMonth(parseFloat(month) - 1);
},
s: (dateObj, seconds) => {
dateObj.setSeconds(parseFloat(seconds));
},
w: doNothing,
y: (dateObj, year) => {
dateObj.setFullYear(2e3 + parseFloat(year));
}
};
const tokenRegex = {
D: "(\\w+)",
F: "(\\w+)",
G: "(\\d\\d|\\d)",
H: "(\\d\\d|\\d)",
J: "(\\d\\d|\\d)\\w+",
K: "",
M: "(\\w+)",
S: "(\\d\\d|\\d)",
U: "(.+)",
W: "(\\d\\d|\\d)",
Y: "(\\d{4})",
Z: "(.+)",
d: "(\\d\\d|\\d)",
h: "(\\d\\d|\\d)",
i: "(\\d\\d|\\d)",
j: "(\\d\\d|\\d)",
l: "(\\w+)",
m: "(\\d\\d|\\d)",
n: "(\\d\\d|\\d)",
s: "(\\d\\d|\\d)",
w: "(\\d\\d|\\d)",
y: "(\\d{2})"
};
const isTimestamp = (date) => typeof date === "number";
const isGMTString = (date) => date.toLowerCase().endsWith("gmt");
const isIsoString = (date) => date.toLowerCase().endsWith("z");
const getIsBackSlash = (char) => char === "\\";
const getTokenParsingOperationsFromFormat = (date, format, locale) => {
const localeTokenRegex = __spreadValues({}, tokenRegex);
localeTokenRegex.K = `(${locale.amPM[0]}|${locale.amPM[1]}|${locale.amPM[0].toLowerCase()}|${locale.amPM[1].toLowerCase()})`;
const operations = [];
let regexString = "";
let matchIndex = 0;
format.split("").forEach((token, tokenIndex) => {
const isBackSlash = getIsBackSlash(token);
const isEscaped = getIsBackSlash(format[tokenIndex - 1]) || isBackSlash;
const regex = localeTokenRegex[token];
if (!isEscaped && regex) {
regexString += regex;
const match = new RegExp(regexString).exec(date);
if (match !== null) {
matchIndex += 1;
if (token === "Y") {
operations.unshift({
fn: tokenParsingFunctions[token],
match: match[matchIndex]
});
} else {
operations.push({
fn: tokenParsingFunctions[token],
match: match[matchIndex]
});
}
}
} else if (!isBackSlash) {
regexString += ".";
}
});
return operations;
};
const getToday = () => {
const today = new Date();
today.setHours(0, 0, 0, 0);
return today;
};
const parseDate = (date, fromFormat = "Y-m-d H:i:S", timeless, customLocale) => {
if (date !== 0 && !date) {
return void 0;
}
if (date === "today") {
return getToday();
}
const locale = customLocale || English;
let parsedDate;
const originalDate = date;
if (date instanceof Date) {
parsedDate = clone(date);
} else if (isTimestamp(date)) {
parsedDate = new Date(date);
} else if (typeof date === "string") {
if (isGMTString(date) || isIsoString(date)) {
parsedDate = new Date(date);
} else {
const operations = getTokenParsingOperationsFromFormat(date, fromFormat, locale);
if (operations.length === 0) {
parsedDate = void 0;
} else {
parsedDate = new Date(new Date().getFullYear(), 0, 1, 0, 0, 0, 0);
operations.forEach((operation) => {
const { fn, match } = operation;
parsedDate = fn(parsedDate, String(match), locale) || parsedDate;
});
}
}
} else {
throw new Error(`Invalid date provided: ${originalDate}`);
}
if (!dateIsValid(parsedDate) || parsedDate === void 0) {
throw new Error(`Invalid date provided: ${originalDate}`);
}
if (timeless === true) {
parsedDate.setHours(0, 0, 0, 0);
}
return parsedDate;
};
const dateIsPartOfTheRange = (date, min, max, dateParser = parseDate, dateFormat = "Y-m-d H:i:S") => {
const minDate = min === void 0 ? void 0 : dateParser(min, dateFormat);
const maxDate = max === void 0 ? void 0 : dateParser(max, dateFormat);
const time = date.getTime();
if (minDate && maxDate) {
return time >= minDate.getTime() && time <= maxDate.getTime();
}
if (minDate) {
return time >= minDate.getTime();
}
if (maxDate) {
return time <= maxDate.getTime();
}
return true;
};
const dayIsPartOfTheConditions = (date, condition, dateParser, dateFormat) => {
if (!date || condition === void 0) {
return false;
}
if (typeof condition === "function") {
return condition(date);
}
if (Array.isArray(condition)) {
return condition.some((c) => dayIsPartOfTheConditions(date, c, dateParser, dateFormat));
}
if (typeof condition === "string" || typeof condition === "number" || condition instanceof String) {
const disabledDate = dateParser(condition, dateFormat);
return isSameDay(disabledDate, date);
}
return isSameDay(condition, date);
};
const boolToInt = (bool) => bool === true ? 1 : 0;
const pad = (number, length = 2) => `000${number}`.slice(length * -1);
const monthToString = (monthNumber, shorthand, locale) => locale.months[shorthand ? "shorthand" : "longhand"][monthNumber];
const tokenFormatingFunctions = {
Z: (date) => date.toISOString(),
D(date, locale) {
return locale.weekdays.shorthand[tokenFormatingFunctions.w(date, locale)];
},
F(date, locale) {
return monthToString(tokenFormatingFunctions.n(date, locale) - 1, false, locale);
},
G(date, locale) {
return pad(tokenFormatingFunctions.h(date, locale));
},
H: (date) => pad(date.getHours()),
J(date, locale) {
return date.getDate() + locale.ordinal(date.getDate());
},
K: (date, locale) => locale.amPM[boolToInt(date.getHours() > 11)],
M(date, locale) {
return monthToString(date.getMonth(), true, locale);
},
S: (date) => pad(date.getSeconds()),
U: (date) => date.getTime() / 1e3,
W(givenDate) {
const date = new Date(givenDate.getTime());
date.setHours(0, 0, 0, 0);
date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7);
const week1 = new Date(date.getFullYear(), 0, 4);
return 1 + Math.round(((date.getTime() - week1.getTime()) / 864e5 - 3 + (week1.getDay() + 6) % 7) / 7);
},
Y: (date) => pad(date.getFullYear(), 4),
d: (date) => pad(date.getDate()),
h: (date) => date.getHours() % 12 ? date.getHours() % 12 : 12,
i: (date) => pad(date.getMinutes()),
j: (date) => date.getDate(),
l(date, locale) {
return locale.weekdays.longhand[date.getDay()];
},
m: (date) => pad(date.getMonth() + 1),
n: (date) => date.getMonth() + 1,
s: (date) => date.getSeconds(),
w: (date) => date.getDay(),
y: (date) => String(date.getFullYear()).substring(2)
};
const formatDate = (date, format, customLocale) => {
if (!date) {
return "";
}
const locale = customLocale || English;
return format.split("").map((char, i, arr) => {
if (tokenFormatingFunctions[char] && arr[i - 1] !== "\\") {
return tokenFormatingFunctions[char](date, locale);
}
if (char !== "\\") {
return char;
}
return "";
}).join("");
};
const buildDateParser = (locale, customDateParser) => (date, format = "Y-m-d H:i:S", timeless) => {
if (customDateParser) {
return customDateParser(date, format, timeless, locale);
}
return parseDate(date, format, timeless, locale);
};
const buildDateFormatter = (locale, customDateFormatter) => (date, format = "Y-m-d H:i:S") => {
if (customDateFormatter) {
return customDateFormatter(date, format, locale);
}
return formatDate(date, format, locale);
};
export { DialogHideReason, DialogIcon, DialogType, ModalHideReason, TAlertClassesKeys, TAlertConfig, TButtonConfig, TCardClassesKeys, TCardConfig, TCheckboxConfig, TDatepickerClassesKeys, TDatepickerConfig, TDialo