1
This commit is contained in:
+29
@@ -0,0 +1,29 @@
|
||||
import type { GenerateConfig } from '../generate';
|
||||
import type { CustomFormat, InternalMode, Locale, NullableDateType } from '../interface';
|
||||
export declare const WEEK_DAY_COUNT = 7;
|
||||
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;
|
||||
export declare function getQuarter<DateType>(generateConfig: GenerateConfig<DateType>, date: DateType): number;
|
||||
export declare function isSameQuarter<DateType>(generateConfig: GenerateConfig<DateType>, quarter1: NullableDateType<DateType>, quarter2: NullableDateType<DateType>): boolean;
|
||||
export declare function isSameMonth<DateType>(generateConfig: GenerateConfig<DateType>, month1: NullableDateType<DateType>, month2: NullableDateType<DateType>): boolean;
|
||||
export declare function isSameDate<DateType>(generateConfig: GenerateConfig<DateType>, date1: NullableDateType<DateType>, date2: NullableDateType<DateType>): boolean;
|
||||
export declare function isSameTime<DateType>(generateConfig: GenerateConfig<DateType>, time1: NullableDateType<DateType>, time2: NullableDateType<DateType>): boolean;
|
||||
/**
|
||||
* Check if the Date is all the same of timestamp
|
||||
*/
|
||||
export declare function isSameTimestamp<DateType>(generateConfig: GenerateConfig<DateType>, time1: NullableDateType<DateType>, time2: NullableDateType<DateType>): boolean;
|
||||
export declare function isSameWeek<DateType>(generateConfig: GenerateConfig<DateType>, locale: string, date1: NullableDateType<DateType>, date2: NullableDateType<DateType>): boolean;
|
||||
export declare function isSame<DateType = any>(generateConfig: GenerateConfig<DateType>, locale: Locale, source: NullableDateType<DateType>, target: NullableDateType<DateType>, type: InternalMode): boolean;
|
||||
/** Between in date but not equal of date */
|
||||
export declare function isInRange<DateType>(generateConfig: GenerateConfig<DateType>, startDate: NullableDateType<DateType>, endDate: NullableDateType<DateType>, current: NullableDateType<DateType>): boolean;
|
||||
export declare function isSameOrAfter<DateType>(generateConfig: GenerateConfig<DateType>, locale: Locale, date1: NullableDateType<DateType>, date2: NullableDateType<DateType>, type: InternalMode): boolean;
|
||||
export declare function getWeekStartDate<DateType>(locale: string, generateConfig: GenerateConfig<DateType>, value: DateType): DateType;
|
||||
export declare function formatValue<DateType>(value: DateType, { generateConfig, locale, format, }: {
|
||||
generateConfig: GenerateConfig<DateType>;
|
||||
locale: Locale;
|
||||
format: string | CustomFormat<DateType>;
|
||||
}): string;
|
||||
/**
|
||||
* Fill the time info into Date if provided.
|
||||
*/
|
||||
export declare function fillTime<DateType>(generateConfig: GenerateConfig<DateType>, date: DateType, time?: DateType): DateType;
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
export var WEEK_DAY_COUNT = 7;
|
||||
|
||||
/**
|
||||
* Wrap the compare logic.
|
||||
* This will compare the each of value is empty first.
|
||||
* 1. All is empty, return true.
|
||||
* 2. One is empty, return false.
|
||||
* 3. return customize compare logic.
|
||||
*/
|
||||
function nullableCompare(value1, value2, oriCompareFn) {
|
||||
if (!value1 && !value2 || value1 === value2) {
|
||||
return true;
|
||||
}
|
||||
if (!value1 || !value2) {
|
||||
return false;
|
||||
}
|
||||
return oriCompareFn();
|
||||
}
|
||||
export function isSameDecade(generateConfig, decade1, decade2) {
|
||||
return nullableCompare(decade1, decade2, function () {
|
||||
var num1 = Math.floor(generateConfig.getYear(decade1) / 10);
|
||||
var num2 = Math.floor(generateConfig.getYear(decade2) / 10);
|
||||
return num1 === num2;
|
||||
});
|
||||
}
|
||||
export function isSameYear(generateConfig, year1, year2) {
|
||||
return nullableCompare(year1, year2, function () {
|
||||
return generateConfig.getYear(year1) === generateConfig.getYear(year2);
|
||||
});
|
||||
}
|
||||
export function getQuarter(generateConfig, date) {
|
||||
var quota = Math.floor(generateConfig.getMonth(date) / 3);
|
||||
return quota + 1;
|
||||
}
|
||||
export function isSameQuarter(generateConfig, quarter1, quarter2) {
|
||||
return nullableCompare(quarter1, quarter2, function () {
|
||||
return isSameYear(generateConfig, quarter1, quarter2) && getQuarter(generateConfig, quarter1) === getQuarter(generateConfig, quarter2);
|
||||
});
|
||||
}
|
||||
export function isSameMonth(generateConfig, month1, month2) {
|
||||
return nullableCompare(month1, month2, function () {
|
||||
return isSameYear(generateConfig, month1, month2) && generateConfig.getMonth(month1) === generateConfig.getMonth(month2);
|
||||
});
|
||||
}
|
||||
export function isSameDate(generateConfig, date1, date2) {
|
||||
return nullableCompare(date1, date2, function () {
|
||||
return isSameYear(generateConfig, date1, date2) && isSameMonth(generateConfig, date1, date2) && generateConfig.getDate(date1) === generateConfig.getDate(date2);
|
||||
});
|
||||
}
|
||||
export function isSameTime(generateConfig, time1, time2) {
|
||||
return nullableCompare(time1, time2, function () {
|
||||
return generateConfig.getHour(time1) === generateConfig.getHour(time2) && generateConfig.getMinute(time1) === generateConfig.getMinute(time2) && generateConfig.getSecond(time1) === generateConfig.getSecond(time2);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the Date is all the same of timestamp
|
||||
*/
|
||||
export function isSameTimestamp(generateConfig, time1, time2) {
|
||||
return nullableCompare(time1, time2, function () {
|
||||
return isSameDate(generateConfig, time1, time2) && isSameTime(generateConfig, time1, time2) && generateConfig.getMillisecond(time1) === generateConfig.getMillisecond(time2);
|
||||
});
|
||||
}
|
||||
export function isSameWeek(generateConfig, locale, date1, date2) {
|
||||
return nullableCompare(date1, date2, function () {
|
||||
var weekStartDate1 = generateConfig.locale.getWeekFirstDate(locale, date1);
|
||||
var weekStartDate2 = generateConfig.locale.getWeekFirstDate(locale, date2);
|
||||
return isSameYear(generateConfig, weekStartDate1, weekStartDate2) && generateConfig.locale.getWeek(locale, date1) === generateConfig.locale.getWeek(locale, date2);
|
||||
});
|
||||
}
|
||||
export function isSame(generateConfig, locale, source, target, type) {
|
||||
switch (type) {
|
||||
case 'date':
|
||||
return isSameDate(generateConfig, source, target);
|
||||
case 'week':
|
||||
return isSameWeek(generateConfig, locale.locale, source, target);
|
||||
case 'month':
|
||||
return isSameMonth(generateConfig, source, target);
|
||||
case 'quarter':
|
||||
return isSameQuarter(generateConfig, source, target);
|
||||
case 'year':
|
||||
return isSameYear(generateConfig, source, target);
|
||||
case 'decade':
|
||||
return isSameDecade(generateConfig, source, target);
|
||||
case 'time':
|
||||
return isSameTime(generateConfig, source, target);
|
||||
default:
|
||||
return isSameTimestamp(generateConfig, source, target);
|
||||
}
|
||||
}
|
||||
|
||||
/** Between in date but not equal of date */
|
||||
export function isInRange(generateConfig, startDate, endDate, current) {
|
||||
if (!startDate || !endDate || !current) {
|
||||
return false;
|
||||
}
|
||||
return generateConfig.isAfter(current, startDate) && generateConfig.isAfter(endDate, current);
|
||||
}
|
||||
export function isSameOrAfter(generateConfig, locale, date1, date2, type) {
|
||||
if (isSame(generateConfig, locale, date1, date2, type)) {
|
||||
return true;
|
||||
}
|
||||
return generateConfig.isAfter(date1, date2);
|
||||
}
|
||||
export function getWeekStartDate(locale, generateConfig, value) {
|
||||
var weekFirstDay = generateConfig.locale.getWeekFirstDay(locale);
|
||||
var monthStartDate = generateConfig.setDate(value, 1);
|
||||
var startDateWeekDay = generateConfig.getWeekDay(monthStartDate);
|
||||
var alignStartDate = generateConfig.addDate(monthStartDate, weekFirstDay - startDateWeekDay);
|
||||
if (generateConfig.getMonth(alignStartDate) === generateConfig.getMonth(value) && generateConfig.getDate(alignStartDate) > 1) {
|
||||
alignStartDate = generateConfig.addDate(alignStartDate, -7);
|
||||
}
|
||||
return alignStartDate;
|
||||
}
|
||||
export function formatValue(value, _ref) {
|
||||
var generateConfig = _ref.generateConfig,
|
||||
locale = _ref.locale,
|
||||
format = _ref.format;
|
||||
if (!value) {
|
||||
return '';
|
||||
}
|
||||
return typeof format === 'function' ? format(value) : generateConfig.locale.format(locale.locale, value, format);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill the time info into Date if provided.
|
||||
*/
|
||||
export function fillTime(generateConfig, date, time) {
|
||||
var tmpDate = date;
|
||||
var getFn = ['getHour', 'getMinute', 'getSecond', 'getMillisecond'];
|
||||
var setFn = ['setHour', 'setMinute', 'setSecond', 'setMillisecond'];
|
||||
setFn.forEach(function (fn, index) {
|
||||
if (time) {
|
||||
tmpDate = generateConfig[fn](tmpDate, generateConfig[getFn[index]](time));
|
||||
} else {
|
||||
tmpDate = generateConfig[fn](tmpDate, 0);
|
||||
}
|
||||
});
|
||||
return tmpDate;
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import type { ReactNode } from "react";
|
||||
import React from "react";
|
||||
export declare function getClearIcon(prefixCls: string, allowClear?: boolean | {
|
||||
clearIcon?: ReactNode;
|
||||
}, clearIcon?: ReactNode): string | number | true | React.JSX.Element | Iterable<ReactNode>;
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
import React from "react";
|
||||
export function getClearIcon(prefixCls, allowClear, clearIcon) {
|
||||
var mergedClearIcon = _typeof(allowClear) === "object" ? allowClear.clearIcon : clearIcon;
|
||||
return mergedClearIcon || /*#__PURE__*/React.createElement("span", {
|
||||
className: "".concat(prefixCls, "-clear-btn")
|
||||
});
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import type { InternalMode, Locale, SharedPickerProps } from '../interface';
|
||||
export declare function leftPad(str: string | number, length: number, fill?: string): string;
|
||||
/**
|
||||
* Convert `value` to array. Will provide `[]` if is null or undefined.
|
||||
*/
|
||||
export declare function toArray<T>(val: T | T[]): T[];
|
||||
export declare function fillIndex<T extends any[]>(ori: T, index: number, value: T[number]): T;
|
||||
/** Pick props from the key list. Will filter empty value */
|
||||
export declare function pickProps<T extends object>(props: T, keys?: (keyof T)[] | readonly (keyof T)[]): T;
|
||||
export declare function getRowFormat(picker: InternalMode, locale: Locale, format?: SharedPickerProps['format']): {
|
||||
format: string;
|
||||
type?: "mask";
|
||||
} | import("../interface").FormatType<any> | import("../interface").FormatType<any>[];
|
||||
export declare function getFromDate<DateType>(calendarValues: DateType[], activeIndexList: number[], activeIndex?: number): DateType;
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
||||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
||||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
export function leftPad(str, length) {
|
||||
var fill = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '0';
|
||||
var current = String(str);
|
||||
while (current.length < length) {
|
||||
current = "".concat(fill).concat(current);
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert `value` to array. Will provide `[]` if is null or undefined.
|
||||
*/
|
||||
export function toArray(val) {
|
||||
if (val === null || val === undefined) {
|
||||
return [];
|
||||
}
|
||||
return Array.isArray(val) ? val : [val];
|
||||
}
|
||||
export function fillIndex(ori, index, value) {
|
||||
var clone = _toConsumableArray(ori);
|
||||
clone[index] = value;
|
||||
return clone;
|
||||
}
|
||||
|
||||
/** Pick props from the key list. Will filter empty value */
|
||||
export function pickProps(props, keys) {
|
||||
var clone = {};
|
||||
var mergedKeys = keys || Object.keys(props);
|
||||
mergedKeys.forEach(function (key) {
|
||||
if (props[key] !== undefined) {
|
||||
clone[key] = props[key];
|
||||
}
|
||||
});
|
||||
return clone;
|
||||
}
|
||||
export function getRowFormat(picker, locale, format) {
|
||||
if (format) {
|
||||
return format;
|
||||
}
|
||||
switch (picker) {
|
||||
// All from the `locale.fieldXXXFormat` first
|
||||
case 'time':
|
||||
return locale.fieldTimeFormat;
|
||||
case 'datetime':
|
||||
return locale.fieldDateTimeFormat;
|
||||
case 'month':
|
||||
return locale.fieldMonthFormat;
|
||||
case 'year':
|
||||
return locale.fieldYearFormat;
|
||||
case 'quarter':
|
||||
return locale.fieldQuarterFormat;
|
||||
case 'week':
|
||||
return locale.fieldWeekFormat;
|
||||
default:
|
||||
return locale.fieldDateFormat;
|
||||
}
|
||||
}
|
||||
export function getFromDate(calendarValues, activeIndexList, activeIndex) {
|
||||
var mergedActiveIndex = activeIndex !== undefined ? activeIndex : activeIndexList[activeIndexList.length - 1];
|
||||
var firstValuedIndex = activeIndexList.find(function (index) {
|
||||
return calendarValues[index];
|
||||
});
|
||||
return mergedActiveIndex !== firstValuedIndex ? calendarValues[firstValuedIndex] : undefined;
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
export declare function getRealPlacement(placement: string, rtl: boolean): string;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// ====================== Mode ======================
|
||||
export function getRealPlacement(placement, rtl) {
|
||||
if (placement !== undefined) {
|
||||
return placement;
|
||||
}
|
||||
return rtl ? 'bottomRight' : 'bottomLeft';
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import type { DisabledTimes, PickerMode } from '../interface';
|
||||
export interface WarningProps extends DisabledTimes {
|
||||
picker?: PickerMode;
|
||||
}
|
||||
export declare function legacyPropsWarning(props: WarningProps): void;
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import warning from "@rc-component/util/es/warning";
|
||||
export function legacyPropsWarning(props) {
|
||||
var picker = props.picker,
|
||||
disabledHours = props.disabledHours,
|
||||
disabledMinutes = props.disabledMinutes,
|
||||
disabledSeconds = props.disabledSeconds;
|
||||
if (picker === 'time' && (disabledHours || disabledMinutes || disabledSeconds)) {
|
||||
warning(false, "'disabledHours', 'disabledMinutes', 'disabledSeconds' will be removed in the next major version, please use 'disabledTime' instead.");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user