@zat-design/sisyphus-react 4.1.2-beta.7 → 4.1.2-beta.9
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.
|
@@ -19,6 +19,22 @@ import { useDateRange } from "./useDateRange";
|
|
|
19
19
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
20
20
|
var AntRangePicker = DatePicker.RangePicker;
|
|
21
21
|
|
|
22
|
+
/** 与 DatePicker 一致:无 valueType 时按 picker 决定默认展示格式 */
|
|
23
|
+
var getDefaultFormat = picker => {
|
|
24
|
+
switch (picker) {
|
|
25
|
+
case 'week':
|
|
26
|
+
return 'YYYY-ww';
|
|
27
|
+
case 'month':
|
|
28
|
+
return 'YYYY-MM';
|
|
29
|
+
case 'quarter':
|
|
30
|
+
return 'YYYY-[Q]Q';
|
|
31
|
+
case 'year':
|
|
32
|
+
return 'YYYY';
|
|
33
|
+
default:
|
|
34
|
+
return 'YYYY-MM-DD';
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
22
38
|
// 获取默认快捷选项(presets 格式)
|
|
23
39
|
var getDefaultPresets = () => {
|
|
24
40
|
var _locale$RangePicker;
|
|
@@ -47,8 +63,7 @@ var getDefaultPresets = () => {
|
|
|
47
63
|
}];
|
|
48
64
|
};
|
|
49
65
|
var RangePicker = props => {
|
|
50
|
-
var
|
|
51
|
-
format = _props$format === void 0 ? 'YYYY-MM-DD' : _props$format,
|
|
66
|
+
var format = props.format,
|
|
52
67
|
otherProps = props.otherProps,
|
|
53
68
|
_props$separator = props.separator,
|
|
54
69
|
separator = _props$separator === void 0 ? '~' : _props$separator,
|
|
@@ -61,6 +76,22 @@ var RangePicker = props => {
|
|
|
61
76
|
viewEmpty = _ref.viewEmpty,
|
|
62
77
|
valueType = _ref.valueType;
|
|
63
78
|
|
|
79
|
+
// 优先级:valueType > format > picker 默认(与 DatePicker 一致)
|
|
80
|
+
var nextFormat;
|
|
81
|
+
if (valueType === 'dateTime') {
|
|
82
|
+
nextFormat = 'YYYY-MM-DD HH:mm:ss';
|
|
83
|
+
} else if (valueType === 'date' || valueType === 'dateStartEndTime') {
|
|
84
|
+
nextFormat = 'YYYY-MM-DD';
|
|
85
|
+
} else if (isFunction(format)) {
|
|
86
|
+
nextFormat = undefined;
|
|
87
|
+
} else if (Array.isArray(format) && format.length && !isFunction(format[0])) {
|
|
88
|
+
nextFormat = format[0];
|
|
89
|
+
} else if (typeof format === 'string') {
|
|
90
|
+
nextFormat = format;
|
|
91
|
+
} else {
|
|
92
|
+
nextFormat = getDefaultFormat(rest.picker);
|
|
93
|
+
}
|
|
94
|
+
|
|
64
95
|
// 返回函数管理起止时间可选范围
|
|
65
96
|
var rangeRegulator = useDateRange({
|
|
66
97
|
range,
|
|
@@ -89,16 +120,35 @@ var RangePicker = props => {
|
|
|
89
120
|
}
|
|
90
121
|
}
|
|
91
122
|
|
|
92
|
-
//
|
|
123
|
+
// 字符串时间格式兼容(与 DatePicker 一致:优先按 nextFormat 严格解析)
|
|
93
124
|
if (Array.isArray(_rest.value) && isString(_rest.value[0]) && isString(_rest.value[1])) {
|
|
94
|
-
|
|
125
|
+
var parseRangeString = s => {
|
|
126
|
+
if (nextFormat && !isFunction(format)) {
|
|
127
|
+
var parsed = dayjs(s, nextFormat, true);
|
|
128
|
+
if (parsed.isValid()) return parsed;
|
|
129
|
+
}
|
|
130
|
+
return dayjs(s);
|
|
131
|
+
};
|
|
132
|
+
_rest.value = [parseRangeString(_rest.value[0]), parseRangeString(_rest.value[1])];
|
|
95
133
|
}
|
|
96
|
-
var
|
|
97
|
-
var tempFormat = Array.isArray(format) ? format : [format];
|
|
134
|
+
var tempFormat;
|
|
98
135
|
if (isFunction(format)) {
|
|
99
136
|
tempFormat = [];
|
|
137
|
+
} else if (valueType === 'dateTime') {
|
|
138
|
+
tempFormat = ['YYYY-MM-DD HH:mm:ss'];
|
|
139
|
+
} else if (valueType === 'date' || valueType === 'dateStartEndTime') {
|
|
140
|
+
tempFormat = ['YYYY-MM-DD'];
|
|
141
|
+
} else if (Array.isArray(format)) {
|
|
142
|
+
tempFormat = format.filter(f => typeof f === 'string') || [];
|
|
143
|
+
if (!tempFormat.length) {
|
|
144
|
+
tempFormat = [getDefaultFormat(rest.picker)];
|
|
145
|
+
}
|
|
146
|
+
} else if (typeof format === 'string') {
|
|
147
|
+
tempFormat = [format];
|
|
148
|
+
} else {
|
|
149
|
+
tempFormat = [getDefaultFormat(rest.picker)];
|
|
100
150
|
}
|
|
101
|
-
var _format = uniq([...tempFormat, 'YYYY-MM-DD', 'YYYYMMDD', 'YYYY/MM/DD', 'YYYY_MM_DD', 'YYYY.MM.DD']).filter(formatKey => !!formatKey);
|
|
151
|
+
var _format = uniq([...tempFormat, 'YYYY-MM-DD HH:mm:ss', 'YYYY-MM-DD', 'YYYYMMDD', 'YYYY/MM/DD', 'YYYY_MM_DD', 'YYYY.MM.DD']).filter(formatKey => !!formatKey);
|
|
102
152
|
var _defaultShowTime = {
|
|
103
153
|
format: 'HH:mm:ss'
|
|
104
154
|
};
|
|
@@ -108,6 +158,9 @@ var RangePicker = props => {
|
|
|
108
158
|
var viewChildren = null;
|
|
109
159
|
if (!value || !value[0] || !value[1]) {
|
|
110
160
|
viewChildren = null;
|
|
161
|
+
} else if (valueType === 'dateTime' || valueType === 'date' || valueType === 'dateStartEndTime') {
|
|
162
|
+
var vf = nextFormat || 'YYYY-MM-DD';
|
|
163
|
+
viewChildren = `${value[0].format(vf)} ${separator} ${value[1].format(vf)}`;
|
|
111
164
|
} else if (Array.isArray(format)) {
|
|
112
165
|
var formattedList = format.map((formatItem, index) => {
|
|
113
166
|
var _format2, _ref2;
|
|
@@ -120,7 +173,8 @@ var RangePicker = props => {
|
|
|
120
173
|
} else if (isFunction(format)) {
|
|
121
174
|
viewChildren = `${format(value[0])} ${separator} ${format(value[1])}`;
|
|
122
175
|
} else {
|
|
123
|
-
|
|
176
|
+
var _vf = (typeof format === 'string' ? format : nextFormat) || 'YYYY-MM-DD';
|
|
177
|
+
viewChildren = `${value[0].format(_vf)} ${separator} ${value[1].format(_vf)}`;
|
|
124
178
|
}
|
|
125
179
|
return /*#__PURE__*/_jsx(Container, {
|
|
126
180
|
viewEmpty: viewEmpty,
|
|
@@ -75,40 +75,29 @@ export declare const useFormItemProps: (column: FlexibleGroupColumnType, context
|
|
|
75
75
|
confirm?: boolean | import("antd").ModalFuncProps | import("../../../render/propsType").FunctionArgs<any, boolean | import("antd").ModalFuncProps>;
|
|
76
76
|
show?: boolean | ReactiveFunction<any, boolean>;
|
|
77
77
|
component?: React.ReactNode | ReactiveFunction<any, React.ReactNode>;
|
|
78
|
-
toISOString?: boolean;
|
|
79
|
-
toCSTString?: boolean;
|
|
80
|
-
switchValue?: [any, any];
|
|
81
|
-
clearNotShow?: boolean;
|
|
82
|
-
style?: React.CSSProperties;
|
|
83
|
-
valueType?: import("../../../render/propsType").ProFormValueType;
|
|
84
|
-
viewRender?: (value: any, record: any, { form, index, namePath, }: {
|
|
85
|
-
[key: string]: any;
|
|
86
|
-
form: FormInstance<any>;
|
|
87
|
-
index?: number;
|
|
88
|
-
}) => string | React.ReactElement<any, any>;
|
|
89
|
-
className?: string;
|
|
90
|
-
trim?: boolean;
|
|
91
|
-
desensitization?: [number, number] | ReactiveFunction<any, [number, number]>;
|
|
92
|
-
validateTrigger?: string | false | string[];
|
|
93
78
|
id?: string;
|
|
79
|
+
className?: string;
|
|
94
80
|
hidden?: boolean;
|
|
81
|
+
style?: React.CSSProperties;
|
|
95
82
|
children?: React.ReactNode | ((form: FormInstance<any>) => React.ReactNode);
|
|
96
83
|
onReset?: () => void;
|
|
97
84
|
prefixCls?: string;
|
|
98
|
-
rootClassName?: string;
|
|
99
85
|
status?: "" | "warning" | "error" | "success" | "validating";
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
shouldUpdate?: import("@rc-component/form/lib/Field").ShouldUpdate<any>;
|
|
86
|
+
rootClassName?: string;
|
|
87
|
+
isView?: boolean;
|
|
103
88
|
colon?: boolean;
|
|
104
89
|
htmlFor?: string;
|
|
105
90
|
labelAlign?: import("antd/es/form/interface").FormLabelAlign;
|
|
106
91
|
labelCol?: import("antd").ColProps;
|
|
107
92
|
vertical?: boolean;
|
|
108
93
|
getValueFromEvent?: (...args: import("@rc-component/form/lib/interface").EventArgs) => any;
|
|
94
|
+
normalize?: (value: any, prevValue: any, allValues: import("@rc-component/form/lib/interface").Store) => any;
|
|
95
|
+
shouldUpdate?: import("@rc-component/form/lib/Field").ShouldUpdate<any>;
|
|
109
96
|
trigger?: string;
|
|
97
|
+
validateTrigger?: string | false | string[];
|
|
110
98
|
validateDebounce?: number;
|
|
111
99
|
valuePropName?: string;
|
|
100
|
+
getValueProps?: ((value: any) => Record<string, unknown>) & ((value: any) => Record<string, unknown>);
|
|
112
101
|
messageVariables?: Record<string, string>;
|
|
113
102
|
initialValue?: any;
|
|
114
103
|
onMetaChange?: (meta: import("@rc-component/form/lib/Field").MetaEvent) => void;
|
|
@@ -124,9 +113,20 @@ export declare const useFormItemProps: (column: FlexibleGroupColumnType, context
|
|
|
124
113
|
wrapperCol?: import("antd").ColProps;
|
|
125
114
|
help?: React.ReactNode;
|
|
126
115
|
fieldId?: string;
|
|
127
|
-
|
|
116
|
+
valueType?: import("../../../render/propsType").ProFormValueType;
|
|
117
|
+
switchValue?: [any, any];
|
|
118
|
+
viewRender?: (value: any, record: any, { form, index, namePath, }: {
|
|
119
|
+
[key: string]: any;
|
|
120
|
+
form: FormInstance<any>;
|
|
121
|
+
index?: number;
|
|
122
|
+
}) => string | React.ReactElement<any, any>;
|
|
128
123
|
viewType?: import("../../../render/propsType").ViewType;
|
|
124
|
+
trim?: boolean;
|
|
129
125
|
upperCase?: boolean;
|
|
126
|
+
toISOString?: boolean;
|
|
127
|
+
toCSTString?: boolean;
|
|
128
|
+
clearNotShow?: boolean;
|
|
129
|
+
desensitization?: [number, number] | ReactiveFunction<any, [number, number]>;
|
|
130
130
|
name: any;
|
|
131
131
|
dependencies: any[];
|
|
132
132
|
tooltip: string | {
|
|
@@ -141,7 +141,7 @@ export declare const useFormItemProps: (column: FlexibleGroupColumnType, context
|
|
|
141
141
|
* 创建组件属性
|
|
142
142
|
*/
|
|
143
143
|
export declare const createComponentProps: (column: FlexibleGroupColumnType, formItemProps: any) => {
|
|
144
|
-
componentProps: import("lodash").Omit<any, "format" | "
|
|
144
|
+
componentProps: import("lodash").Omit<any, "format" | "valueType" | "switchValue" | "dependNames" | "toISOString" | "toCSTString" | "clearNotShow" | "precision">;
|
|
145
145
|
formItemTransform: {
|
|
146
146
|
getValueProps: any;
|
|
147
147
|
normalize: any;
|
|
@@ -25,6 +25,22 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
25
25
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
26
26
|
var AntRangePicker = _antd.DatePicker.RangePicker;
|
|
27
27
|
|
|
28
|
+
/** 与 DatePicker 一致:无 valueType 时按 picker 决定默认展示格式 */
|
|
29
|
+
var getDefaultFormat = picker => {
|
|
30
|
+
switch (picker) {
|
|
31
|
+
case 'week':
|
|
32
|
+
return 'YYYY-ww';
|
|
33
|
+
case 'month':
|
|
34
|
+
return 'YYYY-MM';
|
|
35
|
+
case 'quarter':
|
|
36
|
+
return 'YYYY-[Q]Q';
|
|
37
|
+
case 'year':
|
|
38
|
+
return 'YYYY';
|
|
39
|
+
default:
|
|
40
|
+
return 'YYYY-MM-DD';
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
28
44
|
// 获取默认快捷选项(presets 格式)
|
|
29
45
|
var getDefaultPresets = () => {
|
|
30
46
|
var _locale$RangePicker;
|
|
@@ -53,8 +69,7 @@ var getDefaultPresets = () => {
|
|
|
53
69
|
}];
|
|
54
70
|
};
|
|
55
71
|
var RangePicker = props => {
|
|
56
|
-
var
|
|
57
|
-
format = _props$format === void 0 ? 'YYYY-MM-DD' : _props$format,
|
|
72
|
+
var format = props.format,
|
|
58
73
|
otherProps = props.otherProps,
|
|
59
74
|
_props$separator = props.separator,
|
|
60
75
|
separator = _props$separator === void 0 ? '~' : _props$separator,
|
|
@@ -67,6 +82,22 @@ var RangePicker = props => {
|
|
|
67
82
|
viewEmpty = _ref.viewEmpty,
|
|
68
83
|
valueType = _ref.valueType;
|
|
69
84
|
|
|
85
|
+
// 优先级:valueType > format > picker 默认(与 DatePicker 一致)
|
|
86
|
+
var nextFormat;
|
|
87
|
+
if (valueType === 'dateTime') {
|
|
88
|
+
nextFormat = 'YYYY-MM-DD HH:mm:ss';
|
|
89
|
+
} else if (valueType === 'date' || valueType === 'dateStartEndTime') {
|
|
90
|
+
nextFormat = 'YYYY-MM-DD';
|
|
91
|
+
} else if ((0, _lodash.isFunction)(format)) {
|
|
92
|
+
nextFormat = undefined;
|
|
93
|
+
} else if (Array.isArray(format) && format.length && !(0, _lodash.isFunction)(format[0])) {
|
|
94
|
+
nextFormat = format[0];
|
|
95
|
+
} else if (typeof format === 'string') {
|
|
96
|
+
nextFormat = format;
|
|
97
|
+
} else {
|
|
98
|
+
nextFormat = getDefaultFormat(rest.picker);
|
|
99
|
+
}
|
|
100
|
+
|
|
70
101
|
// 返回函数管理起止时间可选范围
|
|
71
102
|
var rangeRegulator = (0, _useDateRange.useDateRange)({
|
|
72
103
|
range,
|
|
@@ -95,16 +126,35 @@ var RangePicker = props => {
|
|
|
95
126
|
}
|
|
96
127
|
}
|
|
97
128
|
|
|
98
|
-
//
|
|
129
|
+
// 字符串时间格式兼容(与 DatePicker 一致:优先按 nextFormat 严格解析)
|
|
99
130
|
if (Array.isArray(_rest.value) && (0, _lodash.isString)(_rest.value[0]) && (0, _lodash.isString)(_rest.value[1])) {
|
|
100
|
-
|
|
131
|
+
var parseRangeString = s => {
|
|
132
|
+
if (nextFormat && !(0, _lodash.isFunction)(format)) {
|
|
133
|
+
var parsed = (0, _dayjs.default)(s, nextFormat, true);
|
|
134
|
+
if (parsed.isValid()) return parsed;
|
|
135
|
+
}
|
|
136
|
+
return (0, _dayjs.default)(s);
|
|
137
|
+
};
|
|
138
|
+
_rest.value = [parseRangeString(_rest.value[0]), parseRangeString(_rest.value[1])];
|
|
101
139
|
}
|
|
102
|
-
var
|
|
103
|
-
var tempFormat = Array.isArray(format) ? format : [format];
|
|
140
|
+
var tempFormat;
|
|
104
141
|
if ((0, _lodash.isFunction)(format)) {
|
|
105
142
|
tempFormat = [];
|
|
143
|
+
} else if (valueType === 'dateTime') {
|
|
144
|
+
tempFormat = ['YYYY-MM-DD HH:mm:ss'];
|
|
145
|
+
} else if (valueType === 'date' || valueType === 'dateStartEndTime') {
|
|
146
|
+
tempFormat = ['YYYY-MM-DD'];
|
|
147
|
+
} else if (Array.isArray(format)) {
|
|
148
|
+
tempFormat = format.filter(f => typeof f === 'string') || [];
|
|
149
|
+
if (!tempFormat.length) {
|
|
150
|
+
tempFormat = [getDefaultFormat(rest.picker)];
|
|
151
|
+
}
|
|
152
|
+
} else if (typeof format === 'string') {
|
|
153
|
+
tempFormat = [format];
|
|
154
|
+
} else {
|
|
155
|
+
tempFormat = [getDefaultFormat(rest.picker)];
|
|
106
156
|
}
|
|
107
|
-
var _format = (0, _lodash.uniq)([...tempFormat, 'YYYY-MM-DD', 'YYYYMMDD', 'YYYY/MM/DD', 'YYYY_MM_DD', 'YYYY.MM.DD']).filter(formatKey => !!formatKey);
|
|
157
|
+
var _format = (0, _lodash.uniq)([...tempFormat, 'YYYY-MM-DD HH:mm:ss', 'YYYY-MM-DD', 'YYYYMMDD', 'YYYY/MM/DD', 'YYYY_MM_DD', 'YYYY.MM.DD']).filter(formatKey => !!formatKey);
|
|
108
158
|
var _defaultShowTime = {
|
|
109
159
|
format: 'HH:mm:ss'
|
|
110
160
|
};
|
|
@@ -114,6 +164,9 @@ var RangePicker = props => {
|
|
|
114
164
|
var viewChildren = null;
|
|
115
165
|
if (!value || !value[0] || !value[1]) {
|
|
116
166
|
viewChildren = null;
|
|
167
|
+
} else if (valueType === 'dateTime' || valueType === 'date' || valueType === 'dateStartEndTime') {
|
|
168
|
+
var vf = nextFormat || 'YYYY-MM-DD';
|
|
169
|
+
viewChildren = `${value[0].format(vf)} ${separator} ${value[1].format(vf)}`;
|
|
117
170
|
} else if (Array.isArray(format)) {
|
|
118
171
|
var formattedList = format.map((formatItem, index) => {
|
|
119
172
|
var _format2, _ref2;
|
|
@@ -126,7 +179,8 @@ var RangePicker = props => {
|
|
|
126
179
|
} else if ((0, _lodash.isFunction)(format)) {
|
|
127
180
|
viewChildren = `${format(value[0])} ${separator} ${format(value[1])}`;
|
|
128
181
|
} else {
|
|
129
|
-
|
|
182
|
+
var _vf = (typeof format === 'string' ? format : nextFormat) || 'YYYY-MM-DD';
|
|
183
|
+
viewChildren = `${value[0].format(_vf)} ${separator} ${value[1].format(_vf)}`;
|
|
130
184
|
}
|
|
131
185
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Container.default, {
|
|
132
186
|
viewEmpty: viewEmpty,
|