MCPcopy
hub / github.com/flatpickr/flatpickr / parseConfig

Function parseConfig

src/index.ts:1993–2134  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1991 }
1992
1993 function parseConfig() {
1994 const boolOpts: (keyof Options)[] = [
1995 "wrap",
1996 "weekNumbers",
1997 "allowInput",
1998 "allowInvalidPreload",
1999 "clickOpens",
2000 "time_24hr",
2001 "enableTime",
2002 "noCalendar",
2003 "altInput",
2004 "shorthandCurrentMonth",
2005 "inline",
2006 "static",
2007 "enableSeconds",
2008 "disableMobile",
2009 ];
2010
2011 const userConfig = {
2012 ...JSON.parse(JSON.stringify(element.dataset || {})),
2013 ...instanceConfig,
2014 } as Options;
2015
2016 const formats = {} as Record<"dateFormat" | "altFormat", string>;
2017
2018 self.config.parseDate = userConfig.parseDate;
2019 self.config.formatDate = userConfig.formatDate;
2020
2021 Object.defineProperty(self.config, "enable", {
2022 get: () => self.config._enable,
2023 set: (dates) => {
2024 self.config._enable = parseDateRules(dates);
2025 },
2026 });
2027
2028 Object.defineProperty(self.config, "disable", {
2029 get: () => self.config._disable,
2030 set: (dates) => {
2031 self.config._disable = parseDateRules(dates);
2032 },
2033 });
2034
2035 const timeMode = userConfig.mode === "time";
2036
2037 if (!userConfig.dateFormat && (userConfig.enableTime || timeMode)) {
2038 const defaultDateFormat =
2039 flatpickr.defaultConfig.dateFormat || defaultOptions.dateFormat;
2040 formats.dateFormat =
2041 userConfig.noCalendar || timeMode
2042 ? "H:i" + (userConfig.enableSeconds ? ":S" : "")
2043 : defaultDateFormat + " H:i" + (userConfig.enableSeconds ? ":S" : "");
2044 }
2045
2046 if (
2047 userConfig.altInput &&
2048 (userConfig.enableTime || timeMode) &&
2049 !userConfig.altFormat
2050 ) {

Callers 1

initFunction · 0.85

Calls 6

arrayifyFunction · 0.90
parseDateRulesFunction · 0.85
minMaxDateSetterFunction · 0.85
minMaxTimeSetterFunction · 0.85
getInputElemFunction · 0.85
triggerEventFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…