rc-picker
Advanced tools
Comparing version 0.0.1-alpha.45 to 0.0.1-alpha.46
@@ -87,2 +87,4 @@ "use strict"; | ||
var useRangeViewDates_1 = __importDefault(require("./hooks/useRangeViewDates")); | ||
function reorderValues(values, generateConfig) { | ||
@@ -192,45 +194,17 @@ if (values && values[0] && values[1] && generateConfig.isAfter(values[0], values[1])) { | ||
setInnerValue = _useMergeState_1$defa2[1]; // =========================== View Date =========================== | ||
// Config view panel | ||
/** | ||
* End view date is use right panel by default. | ||
* But when they in same month (date picker) or year (month picker), will both use left panel. | ||
*/ | ||
var _useRangeViewDates_1$ = useRangeViewDates_1.default({ | ||
values: mergedValue, | ||
picker: picker, | ||
defaultDates: defaultPickerValue, | ||
generateConfig: generateConfig | ||
}), | ||
_useRangeViewDates_1$2 = _slicedToArray(_useRangeViewDates_1$, 2), | ||
getViewDate = _useRangeViewDates_1$2[0], | ||
setViewDate = _useRangeViewDates_1$2[1]; // ========================= Select Values ========================= | ||
function getEndViewDate(viewDate, values) { | ||
var compareFunc = dateUtil_1.isSameMonth; | ||
if (picker === 'month') { | ||
compareFunc = dateUtil_1.isSameYear; | ||
} | ||
if (compareFunc(generateConfig, miscUtil_1.getValue(values, 0), miscUtil_1.getValue(values, 1))) { | ||
return viewDate; | ||
} | ||
return dateUtil_1.getClosingViewDate(viewDate, picker, generateConfig, -1); | ||
} // Config view panel | ||
var _useMergeState_1$defa3 = useMergeState_1.default({ | ||
defaultValue: function defaultValue() { | ||
return defaultPickerValue || miscUtil_1.updateValues(mergedValue, function (viewDate) { | ||
return getEndViewDate(viewDate, mergedValue); | ||
}, 1); | ||
}, | ||
defaultStateValue: null, | ||
postState: function postState(postViewDates) { | ||
var startViewDate = miscUtil_1.getValue(postViewDates, 0) || miscUtil_1.getValue(mergedValue, 0); | ||
var endViewDate = miscUtil_1.getValue(postViewDates, 1) || miscUtil_1.getValue(mergedValue, 1); | ||
startViewDate = startViewDate || endViewDate || generateConfig.getNow(); | ||
endViewDate = endViewDate || startViewDate || generateConfig.getNow(); | ||
return [startViewDate, endViewDate]; | ||
} | ||
}), | ||
_useMergeState_1$defa4 = _slicedToArray(_useMergeState_1$defa3, 2), | ||
viewDates = _useMergeState_1$defa4[0], | ||
setViewDates = _useMergeState_1$defa4[1]; // ========================= Select Values ========================= | ||
var _useMergeState_1$defa5 = useMergeState_1.default({ | ||
defaultStateValue: mergedValue, | ||
@@ -249,5 +223,5 @@ postState: function postState(values) { | ||
}), | ||
_useMergeState_1$defa6 = _slicedToArray(_useMergeState_1$defa5, 2), | ||
selectedValue = _useMergeState_1$defa6[0], | ||
setSelectedValue = _useMergeState_1$defa6[1]; | ||
_useMergeState_1$defa4 = _slicedToArray(_useMergeState_1$defa3, 2), | ||
selectedValue = _useMergeState_1$defa4[0], | ||
setSelectedValue = _useMergeState_1$defa4[1]; | ||
@@ -274,9 +248,9 @@ var _React$useState3 = React.useState(null), | ||
var _useMergeState_1$defa7 = useMergeState_1.default({ | ||
var _useMergeState_1$defa5 = useMergeState_1.default({ | ||
value: mode, | ||
defaultStateValue: [picker, picker] | ||
}), | ||
_useMergeState_1$defa8 = _slicedToArray(_useMergeState_1$defa7, 2), | ||
mergedModes = _useMergeState_1$defa8[0], | ||
setInnerModes = _useMergeState_1$defa8[1]; | ||
_useMergeState_1$defa6 = _slicedToArray(_useMergeState_1$defa5, 2), | ||
mergedModes = _useMergeState_1$defa6[0], | ||
setInnerModes = _useMergeState_1$defa6[1]; | ||
@@ -303,3 +277,3 @@ var triggerModesChange = function triggerModesChange(modes, values) { | ||
var _useMergeState_1$defa9 = useMergeState_1.default({ | ||
var _useMergeState_1$defa7 = useMergeState_1.default({ | ||
value: open, | ||
@@ -321,5 +295,5 @@ defaultValue: defaultOpen, | ||
}), | ||
_useMergeState_1$defa10 = _slicedToArray(_useMergeState_1$defa9, 2), | ||
mergedOpen = _useMergeState_1$defa10[0], | ||
triggerInnerOpen = _useMergeState_1$defa10[1]; | ||
_useMergeState_1$defa8 = _slicedToArray(_useMergeState_1$defa7, 2), | ||
mergedOpen = _useMergeState_1$defa8[0], | ||
triggerInnerOpen = _useMergeState_1$defa8[1]; | ||
@@ -354,4 +328,3 @@ var startOpen = mergedOpen && activePickerIndex === 0; | ||
values = [startValue, null]; | ||
endValue = null; | ||
setViewDates(miscUtil_1.updateValues(viewDates, startValue, 1)); | ||
endValue = null; // TODO: setViewDates1(updateValues(viewDates1, startValue, 1)); | ||
} | ||
@@ -419,2 +392,4 @@ | ||
} | ||
setViewDate(null, index); | ||
} | ||
@@ -454,3 +429,3 @@ }; | ||
setSelectedValue(miscUtil_1.updateValues(selectedValue, inputDate, index)); | ||
setViewDates(miscUtil_1.updateValues(viewDates, inputDate, index)); | ||
setViewDate(inputDate, index); | ||
} | ||
@@ -636,3 +611,3 @@ }; | ||
triggerModesChange(miscUtil_1.updateValues(mergedModes, newMode, activePickerIndex), miscUtil_1.updateValues(selectedValue, date, activePickerIndex)); | ||
setViewDates(miscUtil_1.updateValues(viewDates, date, activePickerIndex)); | ||
setViewDate(date, activePickerIndex); | ||
}, | ||
@@ -663,3 +638,3 @@ onSelect: undefined, | ||
if (picker !== 'time' && !showTime) { | ||
var viewDate = viewDates[activePickerIndex]; | ||
var viewDate = getViewDate(activePickerIndex); | ||
var nextViewDate = dateUtil_1.getClosingViewDate(viewDate, picker, generateConfig); | ||
@@ -671,3 +646,3 @@ var currentMode = mergedModes[activePickerIndex]; | ||
onPickerValueChange: function onPickerValueChange(newViewDate) { | ||
setViewDates(miscUtil_1.updateValues(viewDates, newViewDate, activePickerIndex)); | ||
setViewDate(newViewDate, activePickerIndex); | ||
} | ||
@@ -677,3 +652,3 @@ }), showDoublePanel && renderPanel('right', { | ||
onPickerValueChange: function onPickerValueChange(newViewDate) { | ||
setViewDates(miscUtil_1.updateValues(viewDates, dateUtil_1.getClosingViewDate(newViewDate, picker, generateConfig, -1), activePickerIndex)); | ||
setViewDate(dateUtil_1.getClosingViewDate(newViewDate, picker, generateConfig, -1), activePickerIndex); | ||
} | ||
@@ -680,0 +655,0 @@ })); |
@@ -5,2 +5,3 @@ import { GenerateConfig } from '../generate'; | ||
export declare function isNullEqual<T>(value1: T, value2: T): boolean | undefined; | ||
export declare function isSameDecade<DateType>(generateConfig: GenerateConfig<DateType>, decade1: NullableDateType<DateType>, decade2: NullableDateType<DateType>): boolean; | ||
export declare function isSameYear<DateType>(generateConfig: GenerateConfig<DateType>, year1: NullableDateType<DateType>, year2: NullableDateType<DateType>): boolean; | ||
@@ -7,0 +8,0 @@ export declare function isSameMonth<DateType>(generateConfig: GenerateConfig<DateType>, month1: NullableDateType<DateType>, month2: NullableDateType<DateType>): boolean; |
@@ -25,2 +25,16 @@ "use strict"; | ||
function isSameDecade(generateConfig, decade1, decade2) { | ||
var equal = isNullEqual(decade1, decade2); | ||
if (typeof equal === 'boolean') { | ||
return equal; | ||
} | ||
var num1 = Math.floor(generateConfig.getYear(decade1) / 10); | ||
var num2 = Math.floor(generateConfig.getYear(decade2) / 10); | ||
return num1 === num2; | ||
} | ||
exports.isSameDecade = isSameDecade; | ||
function isSameYear(generateConfig, year1, year2) { | ||
@@ -27,0 +41,0 @@ var equal = isNullEqual(year1, year2); |
@@ -87,2 +87,4 @@ "use strict"; | ||
var useRangeViewDates_1 = __importDefault(require("./hooks/useRangeViewDates")); | ||
function reorderValues(values, generateConfig) { | ||
@@ -192,45 +194,17 @@ if (values && values[0] && values[1] && generateConfig.isAfter(values[0], values[1])) { | ||
setInnerValue = _useMergeState_1$defa2[1]; // =========================== View Date =========================== | ||
// Config view panel | ||
/** | ||
* End view date is use right panel by default. | ||
* But when they in same month (date picker) or year (month picker), will both use left panel. | ||
*/ | ||
var _useRangeViewDates_1$ = useRangeViewDates_1.default({ | ||
values: mergedValue, | ||
picker: picker, | ||
defaultDates: defaultPickerValue, | ||
generateConfig: generateConfig | ||
}), | ||
_useRangeViewDates_1$2 = _slicedToArray(_useRangeViewDates_1$, 2), | ||
getViewDate = _useRangeViewDates_1$2[0], | ||
setViewDate = _useRangeViewDates_1$2[1]; // ========================= Select Values ========================= | ||
function getEndViewDate(viewDate, values) { | ||
var compareFunc = dateUtil_1.isSameMonth; | ||
if (picker === 'month') { | ||
compareFunc = dateUtil_1.isSameYear; | ||
} | ||
if (compareFunc(generateConfig, miscUtil_1.getValue(values, 0), miscUtil_1.getValue(values, 1))) { | ||
return viewDate; | ||
} | ||
return dateUtil_1.getClosingViewDate(viewDate, picker, generateConfig, -1); | ||
} // Config view panel | ||
var _useMergeState_1$defa3 = useMergeState_1.default({ | ||
defaultValue: function defaultValue() { | ||
return defaultPickerValue || miscUtil_1.updateValues(mergedValue, function (viewDate) { | ||
return getEndViewDate(viewDate, mergedValue); | ||
}, 1); | ||
}, | ||
defaultStateValue: null, | ||
postState: function postState(postViewDates) { | ||
var startViewDate = miscUtil_1.getValue(postViewDates, 0) || miscUtil_1.getValue(mergedValue, 0); | ||
var endViewDate = miscUtil_1.getValue(postViewDates, 1) || miscUtil_1.getValue(mergedValue, 1); | ||
startViewDate = startViewDate || endViewDate || generateConfig.getNow(); | ||
endViewDate = endViewDate || startViewDate || generateConfig.getNow(); | ||
return [startViewDate, endViewDate]; | ||
} | ||
}), | ||
_useMergeState_1$defa4 = _slicedToArray(_useMergeState_1$defa3, 2), | ||
viewDates = _useMergeState_1$defa4[0], | ||
setViewDates = _useMergeState_1$defa4[1]; // ========================= Select Values ========================= | ||
var _useMergeState_1$defa5 = useMergeState_1.default({ | ||
defaultStateValue: mergedValue, | ||
@@ -249,5 +223,5 @@ postState: function postState(values) { | ||
}), | ||
_useMergeState_1$defa6 = _slicedToArray(_useMergeState_1$defa5, 2), | ||
selectedValue = _useMergeState_1$defa6[0], | ||
setSelectedValue = _useMergeState_1$defa6[1]; | ||
_useMergeState_1$defa4 = _slicedToArray(_useMergeState_1$defa3, 2), | ||
selectedValue = _useMergeState_1$defa4[0], | ||
setSelectedValue = _useMergeState_1$defa4[1]; | ||
@@ -274,9 +248,9 @@ var _React$useState3 = React.useState(null), | ||
var _useMergeState_1$defa7 = useMergeState_1.default({ | ||
var _useMergeState_1$defa5 = useMergeState_1.default({ | ||
value: mode, | ||
defaultStateValue: [picker, picker] | ||
}), | ||
_useMergeState_1$defa8 = _slicedToArray(_useMergeState_1$defa7, 2), | ||
mergedModes = _useMergeState_1$defa8[0], | ||
setInnerModes = _useMergeState_1$defa8[1]; | ||
_useMergeState_1$defa6 = _slicedToArray(_useMergeState_1$defa5, 2), | ||
mergedModes = _useMergeState_1$defa6[0], | ||
setInnerModes = _useMergeState_1$defa6[1]; | ||
@@ -303,3 +277,3 @@ var triggerModesChange = function triggerModesChange(modes, values) { | ||
var _useMergeState_1$defa9 = useMergeState_1.default({ | ||
var _useMergeState_1$defa7 = useMergeState_1.default({ | ||
value: open, | ||
@@ -321,5 +295,5 @@ defaultValue: defaultOpen, | ||
}), | ||
_useMergeState_1$defa10 = _slicedToArray(_useMergeState_1$defa9, 2), | ||
mergedOpen = _useMergeState_1$defa10[0], | ||
triggerInnerOpen = _useMergeState_1$defa10[1]; | ||
_useMergeState_1$defa8 = _slicedToArray(_useMergeState_1$defa7, 2), | ||
mergedOpen = _useMergeState_1$defa8[0], | ||
triggerInnerOpen = _useMergeState_1$defa8[1]; | ||
@@ -354,4 +328,3 @@ var startOpen = mergedOpen && activePickerIndex === 0; | ||
values = [startValue, null]; | ||
endValue = null; | ||
setViewDates(miscUtil_1.updateValues(viewDates, startValue, 1)); | ||
endValue = null; // TODO: setViewDates1(updateValues(viewDates1, startValue, 1)); | ||
} | ||
@@ -419,2 +392,4 @@ | ||
} | ||
setViewDate(null, index); | ||
} | ||
@@ -454,3 +429,3 @@ }; | ||
setSelectedValue(miscUtil_1.updateValues(selectedValue, inputDate, index)); | ||
setViewDates(miscUtil_1.updateValues(viewDates, inputDate, index)); | ||
setViewDate(inputDate, index); | ||
} | ||
@@ -636,3 +611,3 @@ }; | ||
triggerModesChange(miscUtil_1.updateValues(mergedModes, newMode, activePickerIndex), miscUtil_1.updateValues(selectedValue, date, activePickerIndex)); | ||
setViewDates(miscUtil_1.updateValues(viewDates, date, activePickerIndex)); | ||
setViewDate(date, activePickerIndex); | ||
}, | ||
@@ -663,3 +638,3 @@ onSelect: undefined, | ||
if (picker !== 'time' && !showTime) { | ||
var viewDate = viewDates[activePickerIndex]; | ||
var viewDate = getViewDate(activePickerIndex); | ||
var nextViewDate = dateUtil_1.getClosingViewDate(viewDate, picker, generateConfig); | ||
@@ -671,3 +646,3 @@ var currentMode = mergedModes[activePickerIndex]; | ||
onPickerValueChange: function onPickerValueChange(newViewDate) { | ||
setViewDates(miscUtil_1.updateValues(viewDates, newViewDate, activePickerIndex)); | ||
setViewDate(newViewDate, activePickerIndex); | ||
} | ||
@@ -677,3 +652,3 @@ }), showDoublePanel && renderPanel('right', { | ||
onPickerValueChange: function onPickerValueChange(newViewDate) { | ||
setViewDates(miscUtil_1.updateValues(viewDates, dateUtil_1.getClosingViewDate(newViewDate, picker, generateConfig, -1), activePickerIndex)); | ||
setViewDate(dateUtil_1.getClosingViewDate(newViewDate, picker, generateConfig, -1), activePickerIndex); | ||
} | ||
@@ -680,0 +655,0 @@ })); |
@@ -5,2 +5,3 @@ import { GenerateConfig } from '../generate'; | ||
export declare function isNullEqual<T>(value1: T, value2: T): boolean | undefined; | ||
export declare function isSameDecade<DateType>(generateConfig: GenerateConfig<DateType>, decade1: NullableDateType<DateType>, decade2: NullableDateType<DateType>): boolean; | ||
export declare function isSameYear<DateType>(generateConfig: GenerateConfig<DateType>, year1: NullableDateType<DateType>, year2: NullableDateType<DateType>): boolean; | ||
@@ -7,0 +8,0 @@ export declare function isSameMonth<DateType>(generateConfig: GenerateConfig<DateType>, month1: NullableDateType<DateType>, month2: NullableDateType<DateType>): boolean; |
@@ -25,2 +25,16 @@ "use strict"; | ||
function isSameDecade(generateConfig, decade1, decade2) { | ||
var equal = isNullEqual(decade1, decade2); | ||
if (typeof equal === 'boolean') { | ||
return equal; | ||
} | ||
var num1 = Math.floor(generateConfig.getYear(decade1) / 10); | ||
var num2 = Math.floor(generateConfig.getYear(decade2) / 10); | ||
return num1 === num2; | ||
} | ||
exports.isSameDecade = isSameDecade; | ||
function isSameYear(generateConfig, year1, year2) { | ||
@@ -27,0 +41,0 @@ var equal = isNullEqual(year1, year2); |
{ | ||
"name": "rc-picker", | ||
"version": "0.0.1-alpha.45", | ||
"version": "0.0.1-alpha.46", | ||
"description": "React date & time picker", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
555511
370
13259