@pisell/date-picker 1.0.77 → 1.0.78
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/utils/index.d.ts +10 -3
- package/es/utils/index.js +14 -2
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -0
- package/lib/utils/index.d.ts +10 -3
- package/lib/utils/index.js +9 -1
- package/package.json +1 -1
package/es/index.d.ts
CHANGED
|
@@ -19,5 +19,5 @@ export type { DateRange, RangePosition } from "./internals/models/range";
|
|
|
19
19
|
export type { UseDateRangeFieldProps } from "./internals/models/dateRange";
|
|
20
20
|
export { PisellDateRangePicker as RangePicker };
|
|
21
21
|
export { LocaleContext, LocaleProvider };
|
|
22
|
-
export { getDatePickerValueByShortcut, formatPresets, getShortcutValue, getPresetLabel, } from "./utils/index";
|
|
22
|
+
export { getDatePickerValueByShortcut, formatPresets, getShortcutValue, getPresetLabel, getDatePickerValue, } from "./utils/index";
|
|
23
23
|
export * from "./models";
|
package/es/index.js
CHANGED
|
@@ -24,5 +24,5 @@ export * from "./StaticDateRangePicker";
|
|
|
24
24
|
export * from "./dateRangeViewRenderers";
|
|
25
25
|
export { PisellDateRangePicker as RangePicker };
|
|
26
26
|
export { LocaleContext, LocaleProvider };
|
|
27
|
-
export { getDatePickerValueByShortcut, formatPresets, getShortcutValue, getPresetLabel } from "./utils/index";
|
|
27
|
+
export { getDatePickerValueByShortcut, formatPresets, getShortcutValue, getPresetLabel, getDatePickerValue } from "./utils/index";
|
|
28
28
|
export * from "./models";
|
package/es/utils/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PresetType } from "../Shortcuts";
|
|
2
|
+
import { Dayjs } from "dayjs";
|
|
2
3
|
export declare const getCurrentLocale: () => string;
|
|
3
4
|
export declare const isBrowser: boolean;
|
|
4
5
|
export declare const isMobile: () => boolean;
|
|
@@ -8,12 +9,12 @@ export declare const isMobile: () => boolean;
|
|
|
8
9
|
*/
|
|
9
10
|
export declare const formatPresets: (presets: PresetType[]) => ({
|
|
10
11
|
label: any;
|
|
11
|
-
getValue: (() =>
|
|
12
|
-
value: [
|
|
12
|
+
getValue: (() => Dayjs[]) | (() => [Dayjs, Dayjs] | "today" | "yesterday" | "last_3_days" | "last_7_days" | "last_30_days" | "last_90_days" | "last_180_days" | "tomorrow" | "next_3_days" | "next_7_days" | "next_30_days" | "next_90_days" | "next_180_days");
|
|
13
|
+
value: [Dayjs, Dayjs] | "today" | "yesterday" | "last_3_days" | "last_7_days" | "last_30_days" | "last_90_days" | "last_180_days" | "tomorrow" | "next_3_days" | "next_7_days" | "next_30_days" | "next_90_days" | "next_180_days";
|
|
13
14
|
key?: string | undefined;
|
|
14
15
|
} | {
|
|
15
16
|
label: string | undefined;
|
|
16
|
-
getValue: () => [
|
|
17
|
+
getValue: () => [Dayjs, Dayjs] | "today" | "yesterday" | "last_3_days" | "last_7_days" | "last_30_days" | "last_90_days" | "last_180_days" | "tomorrow" | "next_3_days" | "next_7_days" | "next_30_days" | "next_90_days" | "next_180_days";
|
|
17
18
|
})[];
|
|
18
19
|
/**
|
|
19
20
|
* 获取预设的label
|
|
@@ -33,3 +34,9 @@ export declare const getShortcutValue: (value: string, preset: any[]) => any;
|
|
|
33
34
|
* @param preset
|
|
34
35
|
*/
|
|
35
36
|
export declare const getDatePickerValueByShortcut: (value: string, preset: any[]) => any;
|
|
37
|
+
/**
|
|
38
|
+
* 获取datePicker 时间值 [dayjs,dayjs]
|
|
39
|
+
* @param value
|
|
40
|
+
* @param preset
|
|
41
|
+
*/
|
|
42
|
+
export declare const getDatePickerValue: (value: string | Dayjs[], preset: any[]) => any;
|
package/es/utils/index.js
CHANGED
|
@@ -80,9 +80,9 @@ export var getPresetLabel = function getPresetLabel(currentShortcut, presets) {
|
|
|
80
80
|
*/
|
|
81
81
|
export var getShortcutValue = function getShortcutValue(value, preset) {
|
|
82
82
|
var _preset$find;
|
|
83
|
-
return (_preset$find = preset.find(function (item) {
|
|
83
|
+
return ((_preset$find = preset.find(function (item) {
|
|
84
84
|
return item.value === value || item.label === value;
|
|
85
|
-
})) === null || _preset$find === void 0 ? void 0 : _preset$find.getValue();
|
|
85
|
+
})) === null || _preset$find === void 0 ? void 0 : _preset$find.getValue()) || [];
|
|
86
86
|
};
|
|
87
87
|
|
|
88
88
|
/**
|
|
@@ -93,4 +93,16 @@ export var getShortcutValue = function getShortcutValue(value, preset) {
|
|
|
93
93
|
export var getDatePickerValueByShortcut = function getDatePickerValueByShortcut(value, preset) {
|
|
94
94
|
var p = formatPresets(preset);
|
|
95
95
|
return getShortcutValue(value, p);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* 获取datePicker 时间值 [dayjs,dayjs]
|
|
100
|
+
* @param value
|
|
101
|
+
* @param preset
|
|
102
|
+
*/
|
|
103
|
+
export var getDatePickerValue = function getDatePickerValue(value, preset) {
|
|
104
|
+
if (isString(value)) {
|
|
105
|
+
return getDatePickerValueByShortcut(value, preset);
|
|
106
|
+
}
|
|
107
|
+
return value;
|
|
96
108
|
};
|
package/lib/index.d.ts
CHANGED
|
@@ -19,5 +19,5 @@ export type { DateRange, RangePosition } from "./internals/models/range";
|
|
|
19
19
|
export type { UseDateRangeFieldProps } from "./internals/models/dateRange";
|
|
20
20
|
export { PisellDateRangePicker as RangePicker };
|
|
21
21
|
export { LocaleContext, LocaleProvider };
|
|
22
|
-
export { getDatePickerValueByShortcut, formatPresets, getShortcutValue, getPresetLabel, } from "./utils/index";
|
|
22
|
+
export { getDatePickerValueByShortcut, formatPresets, getShortcutValue, getPresetLabel, getDatePickerValue, } from "./utils/index";
|
|
23
23
|
export * from "./models";
|
package/lib/index.js
CHANGED
|
@@ -34,6 +34,7 @@ __export(src_exports, {
|
|
|
34
34
|
LocaleProvider: () => import_LocaleContext.LocaleProvider,
|
|
35
35
|
RangePicker: () => import_PisellDateRangePicker.default,
|
|
36
36
|
formatPresets: () => import_utils.formatPresets,
|
|
37
|
+
getDatePickerValue: () => import_utils.getDatePickerValue,
|
|
37
38
|
getDatePickerValueByShortcut: () => import_utils.getDatePickerValueByShortcut,
|
|
38
39
|
getPresetLabel: () => import_utils.getPresetLabel,
|
|
39
40
|
getShortcutValue: () => import_utils.getShortcutValue
|
|
@@ -63,6 +64,7 @@ __reExport(src_exports, require("./models"), module.exports);
|
|
|
63
64
|
LocaleProvider,
|
|
64
65
|
RangePicker,
|
|
65
66
|
formatPresets,
|
|
67
|
+
getDatePickerValue,
|
|
66
68
|
getDatePickerValueByShortcut,
|
|
67
69
|
getPresetLabel,
|
|
68
70
|
getShortcutValue,
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PresetType } from "../Shortcuts";
|
|
2
|
+
import { Dayjs } from "dayjs";
|
|
2
3
|
export declare const getCurrentLocale: () => string;
|
|
3
4
|
export declare const isBrowser: boolean;
|
|
4
5
|
export declare const isMobile: () => boolean;
|
|
@@ -8,12 +9,12 @@ export declare const isMobile: () => boolean;
|
|
|
8
9
|
*/
|
|
9
10
|
export declare const formatPresets: (presets: PresetType[]) => ({
|
|
10
11
|
label: any;
|
|
11
|
-
getValue: (() =>
|
|
12
|
-
value: [
|
|
12
|
+
getValue: (() => Dayjs[]) | (() => [Dayjs, Dayjs] | "today" | "yesterday" | "last_3_days" | "last_7_days" | "last_30_days" | "last_90_days" | "last_180_days" | "tomorrow" | "next_3_days" | "next_7_days" | "next_30_days" | "next_90_days" | "next_180_days");
|
|
13
|
+
value: [Dayjs, Dayjs] | "today" | "yesterday" | "last_3_days" | "last_7_days" | "last_30_days" | "last_90_days" | "last_180_days" | "tomorrow" | "next_3_days" | "next_7_days" | "next_30_days" | "next_90_days" | "next_180_days";
|
|
13
14
|
key?: string | undefined;
|
|
14
15
|
} | {
|
|
15
16
|
label: string | undefined;
|
|
16
|
-
getValue: () => [
|
|
17
|
+
getValue: () => [Dayjs, Dayjs] | "today" | "yesterday" | "last_3_days" | "last_7_days" | "last_30_days" | "last_90_days" | "last_180_days" | "tomorrow" | "next_3_days" | "next_7_days" | "next_30_days" | "next_90_days" | "next_180_days";
|
|
17
18
|
})[];
|
|
18
19
|
/**
|
|
19
20
|
* 获取预设的label
|
|
@@ -33,3 +34,9 @@ export declare const getShortcutValue: (value: string, preset: any[]) => any;
|
|
|
33
34
|
* @param preset
|
|
34
35
|
*/
|
|
35
36
|
export declare const getDatePickerValueByShortcut: (value: string, preset: any[]) => any;
|
|
37
|
+
/**
|
|
38
|
+
* 获取datePicker 时间值 [dayjs,dayjs]
|
|
39
|
+
* @param value
|
|
40
|
+
* @param preset
|
|
41
|
+
*/
|
|
42
|
+
export declare const getDatePickerValue: (value: string | Dayjs[], preset: any[]) => any;
|
package/lib/utils/index.js
CHANGED
|
@@ -21,6 +21,7 @@ var utils_exports = {};
|
|
|
21
21
|
__export(utils_exports, {
|
|
22
22
|
formatPresets: () => formatPresets,
|
|
23
23
|
getCurrentLocale: () => getCurrentLocale,
|
|
24
|
+
getDatePickerValue: () => getDatePickerValue,
|
|
24
25
|
getDatePickerValueByShortcut: () => getDatePickerValueByShortcut,
|
|
25
26
|
getPresetLabel: () => getPresetLabel,
|
|
26
27
|
getShortcutValue: () => getShortcutValue,
|
|
@@ -84,16 +85,23 @@ var getPresetLabel = (currentShortcut, presets) => {
|
|
|
84
85
|
};
|
|
85
86
|
var getShortcutValue = (value, preset) => {
|
|
86
87
|
var _a;
|
|
87
|
-
return (_a = preset.find((item) => item.value === value || item.label === value)) == null ? void 0 : _a.getValue();
|
|
88
|
+
return ((_a = preset.find((item) => item.value === value || item.label === value)) == null ? void 0 : _a.getValue()) || [];
|
|
88
89
|
};
|
|
89
90
|
var getDatePickerValueByShortcut = (value, preset) => {
|
|
90
91
|
const p = formatPresets(preset);
|
|
91
92
|
return getShortcutValue(value, p);
|
|
92
93
|
};
|
|
94
|
+
var getDatePickerValue = (value, preset) => {
|
|
95
|
+
if ((0, import_utils.isString)(value)) {
|
|
96
|
+
return getDatePickerValueByShortcut(value, preset);
|
|
97
|
+
}
|
|
98
|
+
return value;
|
|
99
|
+
};
|
|
93
100
|
// Annotate the CommonJS export names for ESM import in node:
|
|
94
101
|
0 && (module.exports = {
|
|
95
102
|
formatPresets,
|
|
96
103
|
getCurrentLocale,
|
|
104
|
+
getDatePickerValue,
|
|
97
105
|
getDatePickerValueByShortcut,
|
|
98
106
|
getPresetLabel,
|
|
99
107
|
getShortcutValue,
|