ef7ecce4407f28a2f52e05ed5565c158.json
8.78 KB
{"ast":null,"code":"import * as React from 'react';\nimport { getValue } from '../utils/miscUtil';\nimport { isSameDate, getQuarter } from '../utils/dateUtil';\nexport default function useRangeDisabled(_ref, disabledStart, disabledEnd) {\n var picker = _ref.picker,\n locale = _ref.locale,\n selectedValue = _ref.selectedValue,\n disabledDate = _ref.disabledDate,\n disabled = _ref.disabled,\n generateConfig = _ref.generateConfig;\n var startDate = getValue(selectedValue, 0);\n var endDate = getValue(selectedValue, 1);\n\n function weekFirstDate(date) {\n return generateConfig.locale.getWeekFirstDate(locale.locale, date);\n }\n\n function monthNumber(date) {\n var year = generateConfig.getYear(date);\n var month = generateConfig.getMonth(date);\n return year * 100 + month;\n }\n\n function quarterNumber(date) {\n var year = generateConfig.getYear(date);\n var quarter = getQuarter(generateConfig, date);\n return year * 10 + quarter;\n }\n\n var disabledStartDate = React.useCallback(function (date) {\n if (disabledDate && disabledDate(date)) {\n return true;\n } // Disabled range\n\n\n if (disabled[1] && endDate) {\n return !isSameDate(generateConfig, date, endDate) && generateConfig.isAfter(date, endDate);\n } // Disabled part\n\n\n if (disabledStart && endDate) {\n switch (picker) {\n case 'quarter':\n return quarterNumber(date) > quarterNumber(endDate);\n\n case 'month':\n return monthNumber(date) > monthNumber(endDate);\n\n case 'week':\n return weekFirstDate(date) > weekFirstDate(endDate);\n\n default:\n return !isSameDate(generateConfig, date, endDate) && generateConfig.isAfter(date, endDate);\n }\n }\n\n return false;\n }, [disabledDate, disabled[1], endDate, disabledStart]);\n var disabledEndDate = React.useCallback(function (date) {\n if (disabledDate && disabledDate(date)) {\n return true;\n } // Disabled range\n\n\n if (disabled[0] && startDate) {\n return !isSameDate(generateConfig, date, endDate) && generateConfig.isAfter(startDate, date);\n } // Disabled part\n\n\n if (disabledEnd && startDate) {\n switch (picker) {\n case 'quarter':\n return quarterNumber(date) < quarterNumber(startDate);\n\n case 'month':\n return monthNumber(date) < monthNumber(startDate);\n\n case 'week':\n return weekFirstDate(date) < weekFirstDate(startDate);\n\n default:\n return !isSameDate(generateConfig, date, startDate) && generateConfig.isAfter(startDate, date);\n }\n }\n\n return false;\n }, [disabledDate, disabled[0], startDate, disabledEnd]);\n return [disabledStartDate, disabledEndDate];\n}","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-picker/es/hooks/useRangeDisabled.js"],"names":["React","getValue","isSameDate","getQuarter","useRangeDisabled","_ref","disabledStart","disabledEnd","picker","locale","selectedValue","disabledDate","disabled","generateConfig","startDate","endDate","weekFirstDate","date","getWeekFirstDate","monthNumber","year","getYear","month","getMonth","quarterNumber","quarter","disabledStartDate","useCallback","isAfter","disabledEndDate"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,QAAT,QAAyB,mBAAzB;AACA,SAASC,UAAT,EAAqBC,UAArB,QAAuC,mBAAvC;AACA,eAAe,SAASC,gBAAT,CAA0BC,IAA1B,EAAgCC,aAAhC,EAA+CC,WAA/C,EAA4D;AACzE,MAAIC,MAAM,GAAGH,IAAI,CAACG,MAAlB;AAAA,MACIC,MAAM,GAAGJ,IAAI,CAACI,MADlB;AAAA,MAEIC,aAAa,GAAGL,IAAI,CAACK,aAFzB;AAAA,MAGIC,YAAY,GAAGN,IAAI,CAACM,YAHxB;AAAA,MAIIC,QAAQ,GAAGP,IAAI,CAACO,QAJpB;AAAA,MAKIC,cAAc,GAAGR,IAAI,CAACQ,cAL1B;AAMA,MAAIC,SAAS,GAAGb,QAAQ,CAACS,aAAD,EAAgB,CAAhB,CAAxB;AACA,MAAIK,OAAO,GAAGd,QAAQ,CAACS,aAAD,EAAgB,CAAhB,CAAtB;;AAEA,WAASM,aAAT,CAAuBC,IAAvB,EAA6B;AAC3B,WAAOJ,cAAc,CAACJ,MAAf,CAAsBS,gBAAtB,CAAuCT,MAAM,CAACA,MAA9C,EAAsDQ,IAAtD,CAAP;AACD;;AAED,WAASE,WAAT,CAAqBF,IA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A,SAAO,CAACmB,iBAAD,EAAoBG,eAApB,CAAP;AACD","sourcesContent":["import * as React from 'react';\nimport { getValue } from '../utils/miscUtil';\nimport { isSameDate, getQuarter } from '../utils/dateUtil';\nexport default function useRangeDisabled(_ref, disabledStart, disabledEnd) {\n var picker = _ref.picker,\n locale = _ref.locale,\n selectedValue = _ref.selectedValue,\n disabledDate = _ref.disabledDate,\n disabled = _ref.disabled,\n generateConfig = _ref.generateConfig;\n var startDate = getValue(selectedValue, 0);\n var endDate = getValue(selectedValue, 1);\n\n function weekFirstDate(date) {\n return generateConfig.locale.getWeekFirstDate(locale.locale, date);\n }\n\n function monthNumber(date) {\n var year = generateConfig.getYear(date);\n var month = generateConfig.getMonth(date);\n return year * 100 + month;\n }\n\n function quarterNumber(date) {\n var year = generateConfig.getYear(date);\n var quarter = getQuarter(generateConfig, date);\n return year * 10 + quarter;\n }\n\n var disabledStartDate = React.useCallback(function (date) {\n if (disabledDate && disabledDate(date)) {\n return true;\n } // Disabled range\n\n\n if (disabled[1] && endDate) {\n return !isSameDate(generateConfig, date, endDate) && generateConfig.isAfter(date, endDate);\n } // Disabled part\n\n\n if (disabledStart && endDate) {\n switch (picker) {\n case 'quarter':\n return quarterNumber(date) > quarterNumber(endDate);\n\n case 'month':\n return monthNumber(date) > monthNumber(endDate);\n\n case 'week':\n return weekFirstDate(date) > weekFirstDate(endDate);\n\n default:\n return !isSameDate(generateConfig, date, endDate) && generateConfig.isAfter(date, endDate);\n }\n }\n\n return false;\n }, [disabledDate, disabled[1], endDate, disabledStart]);\n var disabledEndDate = React.useCallback(function (date) {\n if (disabledDate && disabledDate(date)) {\n return true;\n } // Disabled range\n\n\n if (disabled[0] && startDate) {\n return !isSameDate(generateConfig, date, endDate) && generateConfig.isAfter(startDate, date);\n } // Disabled part\n\n\n if (disabledEnd && startDate) {\n switch (picker) {\n case 'quarter':\n return quarterNumber(date) < quarterNumber(startDate);\n\n case 'month':\n return monthNumber(date) < monthNumber(startDate);\n\n case 'week':\n return weekFirstDate(date) < weekFirstDate(startDate);\n\n default:\n return !isSameDate(generateConfig, date, startDate) && generateConfig.isAfter(startDate, date);\n }\n }\n\n return false;\n }, [disabledDate, disabled[0], startDate, disabledEnd]);\n return [disabledStartDate, disabledEndDate];\n}"]},"metadata":{},"sourceType":"module"}