1 line
12 KiB
JSON
1 line
12 KiB
JSON
{"ast":null,"code":"export const getDisplayDate = (utils, rawValue, inputFormat) => {\n const date = utils.date(rawValue);\n const isEmpty = rawValue === null;\n if (isEmpty) {\n return '';\n }\n return utils.isValid(date) ? utils.formatByString(\n // TODO: should `isValid` narrow `TDate | null` to `NonNullable<TDate>`?\n // Either we allow `TDate | null` to be valid and guard against calling `formatByString` with `null`.\n // Or we ensure `formatByString` is callable with `null`.\n date, inputFormat) : '';\n};\nconst MASK_USER_INPUT_SYMBOL = '_';\nconst staticDateWith2DigitTokens = '2019-11-21T22:30:00.000';\nconst staticDateWith1DigitTokens = '2019-01-01T09:00:00.000';\nexport function getMaskFromCurrentFormat(mask, format, acceptRegex, utils) {\n if (mask) {\n return mask;\n }\n const formattedDateWith1Digit = utils.formatByString(utils.date(staticDateWith1DigitTokens), format);\n const inferredFormatPatternWith1Digits = formattedDateWith1Digit.replace(acceptRegex, MASK_USER_INPUT_SYMBOL);\n const inferredFormatPatternWith2Digits = utils.formatByString(utils.date(staticDateWith2DigitTokens), format).replace(acceptRegex, '_');\n if (inferredFormatPatternWith1Digits === inferredFormatPatternWith2Digits) {\n return inferredFormatPatternWith1Digits;\n }\n if (process.env.NODE_ENV !== 'production') {\n console.warn([`Mask does not support numbers with variable length such as 'M'.`, `Either use numbers with fix length or disable mask feature with 'disableMaskedInput' prop`, `Falling down to uncontrolled no-mask input.`].join('\\n'));\n }\n return '';\n}\nexport function checkMaskIsValidForCurrentFormat(mask, format, acceptRegex, utils) {\n if (!mask) {\n return false;\n }\n const formattedDateWith1Digit = utils.formatByString(utils.date(staticDateWith1DigitTokens), format);\n const inferredFormatPatternWith1Digits = formattedDateWith1Digit.replace(acceptRegex, MASK_USER_INPUT_SYMBOL);\n const inferredFormatPatternWith2Digits = utils.formatByString(utils.date(staticDateWith2DigitTokens), format).replace(acceptRegex, '_');\n const isMaskValid = inferredFormatPatternWith2Digits === inferredFormatPatternWith1Digits && mask === inferredFormatPatternWith2Digits;\n if (!isMaskValid && utils.lib !== 'luxon' && process.env.NODE_ENV !== 'production') {\n if (format.includes('MMM')) {\n console.warn([`Mask does not support literals such as 'MMM'.`, `Either use numbers with fix length or disable mask feature with 'disableMaskedInput' prop`, `Falling down to uncontrolled no-mask input.`].join('\\n'));\n } else if (inferredFormatPatternWith2Digits && inferredFormatPatternWith2Digits !== inferredFormatPatternWith1Digits) {\n console.warn([`Mask does not support numbers with variable length such as 'M'.`, `Either use numbers with fix length or disable mask feature with 'disableMaskedInput' prop`, `Falling down to uncontrolled no-mask input.`].join('\\n'));\n } else if (mask) {\n console.warn([`The mask \"${mask}\" you passed is not valid for the format used ${format}.`, `Falling down to uncontrolled no-mask input.`].join('\\n'));\n }\n }\n return isMaskValid;\n}\nexport const maskedDateFormatter = (mask, acceptRegexp) => value => {\n let outputCharIndex = 0;\n return value.split('').map((char, inputCharIndex) => {\n acceptRegexp.lastIndex = 0;\n if (outputCharIndex > mask.length - 1) {\n return '';\n }\n const maskChar = mask[outputCharIndex];\n const nextMaskChar = mask[outputCharIndex + 1];\n const acceptedChar = acceptRegexp.test(char) ? char : '';\n const formattedChar = maskChar === MASK_USER_INPUT_SYMBOL ? acceptedChar : maskChar + acceptedChar;\n outputCharIndex += formattedChar.length;\n const isLastCharacter = inputCharIndex === value.length - 1;\n if (isLastCharacter && nextMaskChar && nextMaskChar !== MASK_USER_INPUT_SYMBOL) {\n // when cursor at the end of mask part (e.g. month) prerender next symbol \"21\" -> \"21/\"\n return formattedChar ? formattedChar + nextMaskChar : '';\n }\n return formattedChar;\n }).join('');\n};","map":{"version":3,"names":["getDisplayDate","utils","rawValue","inputFormat","date","isEmpty","isValid","formatByString","MASK_USER_INPUT_SYMBOL","staticDateWith2DigitTokens","staticDateWith1DigitTokens","getMaskFromCurrentFormat","mask","format","acceptRegex","formattedDateWith1Digit","inferredFormatPatternWith1Digits","replace","inferredFormatPatternWith2Digits","process","env","NODE_ENV","console","warn","join","checkMaskIsValidForCurrentFormat","isMaskValid","lib","includes","maskedDateFormatter","acceptRegexp","value","outputCharIndex","split","map","char","inputCharIndex","lastIndex","length","maskChar","nextMaskChar","acceptedChar","test","formattedChar","isLastCharacter"],"sources":["/home/gnx/Desktop/ETB/ETB-FrontEnd/node_modules/@mui/x-date-pickers/internals/utils/text-field-helper.js"],"sourcesContent":["export const getDisplayDate = (utils, rawValue, inputFormat) => {\n const date = utils.date(rawValue);\n const isEmpty = rawValue === null;\n\n if (isEmpty) {\n return '';\n }\n\n return utils.isValid(date) ? utils.formatByString( // TODO: should `isValid` narrow `TDate | null` to `NonNullable<TDate>`?\n // Either we allow `TDate | null` to be valid and guard against calling `formatByString` with `null`.\n // Or we ensure `formatByString` is callable with `null`.\n date, inputFormat) : '';\n};\nconst MASK_USER_INPUT_SYMBOL = '_';\nconst staticDateWith2DigitTokens = '2019-11-21T22:30:00.000';\nconst staticDateWith1DigitTokens = '2019-01-01T09:00:00.000';\nexport function getMaskFromCurrentFormat(mask, format, acceptRegex, utils) {\n if (mask) {\n return mask;\n }\n\n const formattedDateWith1Digit = utils.formatByString(utils.date(staticDateWith1DigitTokens), format);\n const inferredFormatPatternWith1Digits = formattedDateWith1Digit.replace(acceptRegex, MASK_USER_INPUT_SYMBOL);\n const inferredFormatPatternWith2Digits = utils.formatByString(utils.date(staticDateWith2DigitTokens), format).replace(acceptRegex, '_');\n\n if (inferredFormatPatternWith1Digits === inferredFormatPatternWith2Digits) {\n return inferredFormatPatternWith1Digits;\n }\n\n if (process.env.NODE_ENV !== 'production') {\n console.warn([`Mask does not support numbers with variable length such as 'M'.`, `Either use numbers with fix length or disable mask feature with 'disableMaskedInput' prop`, `Falling down to uncontrolled no-mask input.`].join('\\n'));\n }\n\n return '';\n}\nexport function checkMaskIsValidForCurrentFormat(mask, format, acceptRegex, utils) {\n if (!mask) {\n return false;\n }\n\n const formattedDateWith1Digit = utils.formatByString(utils.date(staticDateWith1DigitTokens), format);\n const inferredFormatPatternWith1Digits = formattedDateWith1Digit.replace(acceptRegex, MASK_USER_INPUT_SYMBOL);\n const inferredFormatPatternWith2Digits = utils.formatByString(utils.date(staticDateWith2DigitTokens), format).replace(acceptRegex, '_');\n const isMaskValid = inferredFormatPatternWith2Digits === inferredFormatPatternWith1Digits && mask === inferredFormatPatternWith2Digits;\n\n if (!isMaskValid && utils.lib !== 'luxon' && process.env.NODE_ENV !== 'production') {\n if (format.includes('MMM')) {\n console.warn([`Mask does not support literals such as 'MMM'.`, `Either use numbers with fix length or disable mask feature with 'disableMaskedInput' prop`, `Falling down to uncontrolled no-mask input.`].join('\\n'));\n } else if (inferredFormatPatternWith2Digits && inferredFormatPatternWith2Digits !== inferredFormatPatternWith1Digits) {\n console.warn([`Mask does not support numbers with variable length such as 'M'.`, `Either use numbers with fix length or disable mask feature with 'disableMaskedInput' prop`, `Falling down to uncontrolled no-mask input.`].join('\\n'));\n } else if (mask) {\n console.warn([`The mask \"${mask}\" you passed is not valid for the format used ${format}.`, `Falling down to uncontrolled no-mask input.`].join('\\n'));\n }\n }\n\n return isMaskValid;\n}\nexport const maskedDateFormatter = (mask, acceptRegexp) => value => {\n let outputCharIndex = 0;\n return value.split('').map((char, inputCharIndex) => {\n acceptRegexp.lastIndex = 0;\n\n if (outputCharIndex > mask.length - 1) {\n return '';\n }\n\n const maskChar = mask[outputCharIndex];\n const nextMaskChar = mask[outputCharIndex + 1];\n const acceptedChar = acceptRegexp.test(char) ? char : '';\n const formattedChar = maskChar === MASK_USER_INPUT_SYMBOL ? acceptedChar : maskChar + acceptedChar;\n outputCharIndex += formattedChar.length;\n const isLastCharacter = inputCharIndex === value.length - 1;\n\n if (isLastCharacter && nextMaskChar && nextMaskChar !== MASK_USER_INPUT_SYMBOL) {\n // when cursor at the end of mask part (e.g. month) prerender next symbol \"21\" -> \"21/\"\n return formattedChar ? formattedChar + nextMaskChar : '';\n }\n\n return formattedChar;\n }).join('');\n};"],"mappings":"AAAA,OAAO,MAAMA,cAAc,GAAGA,CAACC,KAAK,EAAEC,QAAQ,E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