form-driver 0.4.25 → 0.4.27
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/dist/m3.js +1 -1
- package/es/m3.js +158 -74
- package/lib/m3.js +158 -75
- package/package.json +1 -1
- package/src/ui/editor/basic/ARangePicker.tsx +323 -124
- package/types/ui/editor/basic/ARangePicker.d.ts +4 -3
package/es/m3.js
CHANGED
|
@@ -20,7 +20,6 @@ import clsx from 'clsx';
|
|
|
20
20
|
import Button$1 from 'antd/lib/button';
|
|
21
21
|
import _objectWithoutPropertiesLoose from '@babel/runtime/helpers/esm/objectWithoutPropertiesLoose';
|
|
22
22
|
import zhCN$1 from 'antd/lib/date-picker/locale/zh_CN';
|
|
23
|
-
import ReactDOM from 'react-dom';
|
|
24
23
|
import debounce from 'lodash/debounce';
|
|
25
24
|
import 'moment/locale/zh-cn';
|
|
26
25
|
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
@@ -22945,7 +22944,7 @@ var ARangePicker = /*#__PURE__*/function (_Viewer) {
|
|
|
22945
22944
|
ctrlVersion: 1,
|
|
22946
22945
|
noValidate: false,
|
|
22947
22946
|
mobileDlg: false,
|
|
22948
|
-
mobileStep:
|
|
22947
|
+
mobileStep: "start"
|
|
22949
22948
|
};
|
|
22950
22949
|
return _this;
|
|
22951
22950
|
}
|
|
@@ -22965,12 +22964,14 @@ var ARangePicker = /*#__PURE__*/function (_Viewer) {
|
|
|
22965
22964
|
|
|
22966
22965
|
if (_.get(v, "[2]")) {
|
|
22967
22966
|
// tillnow
|
|
22968
|
-
var dom =
|
|
22967
|
+
var dom = this._pickerRef.current;
|
|
22969
22968
|
|
|
22970
22969
|
if (dom) {
|
|
22971
|
-
// @ts-ignore
|
|
22972
22970
|
var r = dom.querySelector(":nth-child(3)");
|
|
22973
|
-
|
|
22971
|
+
|
|
22972
|
+
if (r) {
|
|
22973
|
+
r.innerHTML = "<input readonly disabled size='12' autocomplete='off' value='至今' style='color: black'>";
|
|
22974
|
+
}
|
|
22974
22975
|
}
|
|
22975
22976
|
}
|
|
22976
22977
|
}
|
|
@@ -23015,23 +23016,23 @@ var ARangePicker = /*#__PURE__*/function (_Viewer) {
|
|
|
23015
23016
|
var rangePickerData = this._data2rangePicker((_this$getValue = this.getValue()) != null ? _this$getValue : []);
|
|
23016
23017
|
|
|
23017
23018
|
if (MUtil.phoneLike()) {
|
|
23018
|
-
var _this$props$schema$da3
|
|
23019
|
+
var _this$props$schema$da3;
|
|
23019
23020
|
|
|
23020
23021
|
var show = MDateRangeType.toReadableN(assembly, this.props.schema, _Viewer.prototype.getValue.call(this)); // 根据 precision 配置确定移动端 DatePicker 精度(使用扁平化属性 dateRangePrecision)
|
|
23021
23022
|
|
|
23022
|
-
var mobilePrecision = this.props.schema.dateRangePrecision ||
|
|
23023
|
+
var mobilePrecision = this.props.schema.dateRangePrecision || "day";
|
|
23023
23024
|
return jsxs(Fragment, {
|
|
23024
23025
|
children: [jsxs("div", {
|
|
23025
23026
|
className: "backfill",
|
|
23026
23027
|
onClick: function onClick() {
|
|
23027
23028
|
return _this2.setState({
|
|
23028
23029
|
mobileDlg: true,
|
|
23029
|
-
mobileStep:
|
|
23030
|
+
mobileStep: "start"
|
|
23030
23031
|
});
|
|
23031
23032
|
},
|
|
23032
|
-
children: [" ", show != null ? show :
|
|
23033
|
+
children: [" ", show != null ? show : "请点击选择", " "]
|
|
23033
23034
|
}), jsx(DatePicker, {
|
|
23034
|
-
visible: this.state.mobileDlg && this.state.mobileStep ===
|
|
23035
|
+
visible: this.state.mobileDlg && this.state.mobileStep === "start",
|
|
23035
23036
|
precision: mobilePrecision,
|
|
23036
23037
|
title: "\u9009\u62E9\u5F00\u59CB\u65E5\u671F",
|
|
23037
23038
|
min: this.props.schema.min ? new Date(this.props.schema.min) : undefined,
|
|
@@ -23041,7 +23042,7 @@ var ARangePicker = /*#__PURE__*/function (_Viewer) {
|
|
|
23041
23042
|
|
|
23042
23043
|
_this2.setState({
|
|
23043
23044
|
mobileStartDate: val,
|
|
23044
|
-
mobileStep:
|
|
23045
|
+
mobileStep: "end"
|
|
23045
23046
|
});
|
|
23046
23047
|
},
|
|
23047
23048
|
onClose: function onClose() {
|
|
@@ -23057,14 +23058,14 @@ var ARangePicker = /*#__PURE__*/function (_Viewer) {
|
|
|
23057
23058
|
});
|
|
23058
23059
|
}
|
|
23059
23060
|
}, "start_" + mobilePrecision), jsx(DatePicker, {
|
|
23060
|
-
visible: this.state.mobileDlg && this.state.mobileStep ===
|
|
23061
|
+
visible: this.state.mobileDlg && this.state.mobileStep === "end",
|
|
23061
23062
|
precision: mobilePrecision,
|
|
23062
23063
|
title: // 如果允许"至今"且开始时间不在未来,在标题区域展示"至今"按钮
|
|
23063
|
-
!((_this$props$schema$da3 = this.props.schema.dateRange) != null && _this$props$schema$da3.hideTillNow) && !(
|
|
23064
|
+
!((_this$props$schema$da3 = this.props.schema.dateRange) != null && _this$props$schema$da3.hideTillNow) && !(this.state.mobileStartDate && this.state.mobileStartDate > new Date()) ? jsxs("div", {
|
|
23064
23065
|
style: {
|
|
23065
|
-
display:
|
|
23066
|
-
alignItems:
|
|
23067
|
-
justifyContent:
|
|
23066
|
+
display: "flex",
|
|
23067
|
+
alignItems: "center",
|
|
23068
|
+
justifyContent: "center",
|
|
23068
23069
|
gap: 12
|
|
23069
23070
|
},
|
|
23070
23071
|
children: [jsx("span", {
|
|
@@ -23105,93 +23106,176 @@ var ARangePicker = /*#__PURE__*/function (_Viewer) {
|
|
|
23105
23106
|
onClose: function onClose() {
|
|
23106
23107
|
// 回退到第一步,让用户可以重新选择开始日期
|
|
23107
23108
|
_this2.setState({
|
|
23108
|
-
mobileStep:
|
|
23109
|
+
mobileStep: "start"
|
|
23109
23110
|
});
|
|
23110
23111
|
}
|
|
23111
23112
|
}, "end_" + mobilePrecision)]
|
|
23112
23113
|
});
|
|
23113
23114
|
} else {
|
|
23114
|
-
var _this$props$schema$
|
|
23115
|
+
var _this$props$schema$da4, _this$props$schema$da5, _this$props$schema$da6;
|
|
23115
23116
|
|
|
23116
23117
|
// 根据 precision 配置确定 PC 端 picker 模式和 showTime(使用扁平化属性 dateRangePrecision)
|
|
23117
23118
|
var precision = this.props.schema.dateRangePrecision;
|
|
23118
|
-
var pcShowTime = precision ===
|
|
23119
|
-
var hideFooter = (
|
|
23119
|
+
var pcShowTime = precision === "minute" || ((_this$props$schema$da4 = this.props.schema.dateRange) == null ? void 0 : _this$props$schema$da4.showTime);
|
|
23120
|
+
var hideFooter = (_this$props$schema$da5 = this.props.schema.dateRange) == null ? void 0 : _this$props$schema$da5.hideTillNow; // 动态构建额外属性,避免 showTime 和 picker 同时传入导致类型冲突
|
|
23120
23121
|
|
|
23121
23122
|
var extraProps = {};
|
|
23122
23123
|
|
|
23123
|
-
if (precision ===
|
|
23124
|
-
extraProps.picker =
|
|
23125
|
-
} else if (precision ===
|
|
23126
|
-
extraProps.picker =
|
|
23124
|
+
if (precision === "year") {
|
|
23125
|
+
extraProps.picker = "year";
|
|
23126
|
+
} else if (precision === "month") {
|
|
23127
|
+
extraProps.picker = "month";
|
|
23127
23128
|
} else if (pcShowTime) {
|
|
23128
23129
|
// precision 为 minute 时只展示时分,不展示秒
|
|
23129
|
-
extraProps.showTime = precision ===
|
|
23130
|
-
format:
|
|
23130
|
+
extraProps.showTime = precision === "minute" ? {
|
|
23131
|
+
format: "HH:mm"
|
|
23131
23132
|
} : true; // 同步设置输入框的显示格式,避免 showTime.format 只影响面板列而输入框仍显示秒
|
|
23132
23133
|
|
|
23133
|
-
if (precision ===
|
|
23134
|
-
extraProps.format =
|
|
23134
|
+
if (precision === "minute") {
|
|
23135
|
+
extraProps.format = "YYYY-MM-DD HH:mm";
|
|
23136
|
+
}
|
|
23137
|
+
} // "至今"按钮的点击处理函数
|
|
23138
|
+
|
|
23139
|
+
|
|
23140
|
+
var handleTillNow = function handleTillNow() {
|
|
23141
|
+
var _this2$_onCalendarCha, _ref, _ref2;
|
|
23142
|
+
|
|
23143
|
+
// 优先级:onCalendarChange 记录的值 > 面板点击捕获的日期 > 已有默认值 > 当前时间
|
|
23144
|
+
var fromCalendarChange = (_this2$_onCalendarCha = _this2._onCalendarChangeValue) == null ? void 0 : _this2$_onCalendarCha[0];
|
|
23145
|
+
var fromPanelClick = _this2._panelClickedDate;
|
|
23146
|
+
var startMoment = (_ref = (_ref2 = fromCalendarChange != null ? fromCalendarChange : fromPanelClick) != null ? _ref2 : rangePickerData == null ? void 0 : rangePickerData[0]) != null ? _ref : moment(); // 如果开始时间来自面板点击(只有日期没有时间),将当前时刻的时分附加上去
|
|
23147
|
+
|
|
23148
|
+
if (!fromCalendarChange && fromPanelClick) {
|
|
23149
|
+
var now = moment();
|
|
23150
|
+
startMoment = startMoment.clone().hour(now.hour()).minute(now.minute()).second(0);
|
|
23135
23151
|
}
|
|
23136
|
-
} // 构造元素
|
|
23137
23152
|
|
|
23153
|
+
_Viewer.prototype.changeValueEx.call(_this2, _this2._rangePicker2Data([startMoment, moment()], true), true, true);
|
|
23154
|
+
}; // 判断是否应展示"至今"按钮
|
|
23138
23155
|
|
|
23139
|
-
|
|
23156
|
+
|
|
23157
|
+
var showTillNow = !hideFooter; // 构造元素
|
|
23158
|
+
|
|
23159
|
+
return jsx("div", {
|
|
23140
23160
|
ref: this._pickerRef,
|
|
23141
|
-
|
|
23142
|
-
|
|
23161
|
+
children: jsx(DatePicker$1.RangePicker, _objectSpread$8({
|
|
23162
|
+
panelRender: pcShowTime && showTillNow ? function (panelNode) {
|
|
23163
|
+
// showTime 模式下:通过事件委托捕获面板上日期单元格的点击
|
|
23164
|
+
// 同时在 footer 的"确定"按钮同一行注入"至今"按钮
|
|
23165
|
+
return jsx("div", {
|
|
23166
|
+
onClick: function onClick(e) {
|
|
23167
|
+
var target = e.target;
|
|
23168
|
+
var cell = target.closest == null ? void 0 : target.closest(".ant-picker-cell");
|
|
23143
23169
|
|
|
23144
|
-
|
|
23145
|
-
|
|
23170
|
+
if (cell) {
|
|
23171
|
+
// 排除 disabled 状态的日期单元格
|
|
23172
|
+
if (cell.classList.contains("ant-picker-cell-disabled")) return;
|
|
23173
|
+
var title = cell.getAttribute("title");
|
|
23146
23174
|
|
|
23147
|
-
|
|
23148
|
-
|
|
23149
|
-
}
|
|
23175
|
+
if (title) {
|
|
23176
|
+
var parsed = moment(title, "YYYY-MM-DD"); // 校验 moment 解析有效性,无效日期不记录
|
|
23150
23177
|
|
|
23151
|
-
|
|
23152
|
-
|
|
23153
|
-
|
|
23154
|
-
|
|
23155
|
-
|
|
23156
|
-
size: "small",
|
|
23157
|
-
style: {
|
|
23158
|
-
width: "100px",
|
|
23159
|
-
display: "inline-block",
|
|
23160
|
-
marginTop: "5px"
|
|
23178
|
+
if (parsed.isValid()) {
|
|
23179
|
+
_this2._panelClickedDate = parsed;
|
|
23180
|
+
}
|
|
23181
|
+
}
|
|
23182
|
+
}
|
|
23161
23183
|
},
|
|
23162
|
-
|
|
23163
|
-
|
|
23184
|
+
ref: function ref(el) {
|
|
23185
|
+
var _ref3, _this2$_onCalendarCha2, _this2$_onCalendarCha3;
|
|
23186
|
+
|
|
23187
|
+
// 面板渲染后,将"至今"按钮注入到 .ant-picker-ok 内部,确定按钮之后
|
|
23188
|
+
// 这样两者在同一个 flex item 中,确定在左、至今在右
|
|
23189
|
+
if (!el) return;
|
|
23190
|
+
var okLi = el.querySelector(".ant-picker-ok");
|
|
23191
|
+
if (!okLi) return; // 开始时间在未来时,移除已有的至今按钮并不再注入
|
|
23192
|
+
|
|
23193
|
+
var previewStart = (_ref3 = (_this2$_onCalendarCha2 = (_this2$_onCalendarCha3 = _this2._onCalendarChangeValue) == null ? void 0 : _this2$_onCalendarCha3[0]) != null ? _this2$_onCalendarCha2 : _this2._panelClickedDate) != null ? _ref3 : rangePickerData == null ? void 0 : rangePickerData[0];
|
|
23194
|
+
|
|
23195
|
+
if (previewStart && previewStart.isAfter(moment())) {
|
|
23196
|
+
var existingBtn = okLi.querySelector(".till-now-btn");
|
|
23197
|
+
if (existingBtn) existingBtn.remove();
|
|
23198
|
+
return;
|
|
23199
|
+
}
|
|
23200
|
+
|
|
23201
|
+
if (!okLi.querySelector(".till-now-btn")) {
|
|
23202
|
+
var tillNowBtn = document.createElement("button");
|
|
23203
|
+
tillNowBtn.className = "ant-btn ant-btn-sm till-now-btn";
|
|
23204
|
+
tillNowBtn.textContent = "至今";
|
|
23205
|
+
tillNowBtn.style.cssText = "margin-left: 8px;"; // 使用具名函数以便于清理;先移除可能的旧监听再添加,防止重复绑定
|
|
23206
|
+
|
|
23207
|
+
var onTillNowClick = function onTillNowClick(e) {
|
|
23208
|
+
e.stopPropagation();
|
|
23209
|
+
handleTillNow();
|
|
23210
|
+
};
|
|
23211
|
+
|
|
23212
|
+
tillNowBtn.addEventListener("click", onTillNowClick);
|
|
23213
|
+
okLi.appendChild(tillNowBtn);
|
|
23214
|
+
}
|
|
23164
23215
|
},
|
|
23165
|
-
children:
|
|
23166
|
-
})
|
|
23167
|
-
}
|
|
23168
|
-
|
|
23169
|
-
|
|
23170
|
-
style: {
|
|
23171
|
-
width: "300px"
|
|
23172
|
-
},
|
|
23173
|
-
locale: zhCN$1,
|
|
23174
|
-
defaultValue: rangePickerData,
|
|
23175
|
-
onCalendarChange: function onCalendarChange(d) {
|
|
23176
|
-
_this2._onCalendarChangeValue = d;
|
|
23177
|
-
},
|
|
23178
|
-
onChange: function onChange(vv) {
|
|
23179
|
-
// 用户清空日期范围时,直接置空
|
|
23180
|
-
if (!vv) {
|
|
23181
|
-
_Viewer.prototype.changeValueEx.call(_this2, undefined, true, true);
|
|
23216
|
+
children: panelNode
|
|
23217
|
+
});
|
|
23218
|
+
} : undefined,
|
|
23219
|
+
renderExtraFooter: !pcShowTime && showTillNow ? function (mode) {
|
|
23220
|
+
var _this2$_onCalendarCha4, _this2$_onCalendarCha5;
|
|
23182
23221
|
|
|
23183
|
-
|
|
23184
|
-
|
|
23222
|
+
// 非 showTime 模式:使用 renderExtraFooter 展示"至今"按钮
|
|
23223
|
+
var previewStart = (_this2$_onCalendarCha4 = (_this2$_onCalendarCha5 = _this2._onCalendarChangeValue) == null ? void 0 : _this2$_onCalendarCha5[0]) != null ? _this2$_onCalendarCha4 : rangePickerData == null ? void 0 : rangePickerData[0];
|
|
23185
23224
|
|
|
23186
|
-
|
|
23225
|
+
if (previewStart && previewStart.isAfter(moment())) {
|
|
23226
|
+
return null;
|
|
23227
|
+
}
|
|
23187
23228
|
|
|
23188
|
-
|
|
23229
|
+
return jsx("div", {
|
|
23230
|
+
style: {
|
|
23231
|
+
textAlign: "right"
|
|
23232
|
+
},
|
|
23233
|
+
children: jsx(Button, {
|
|
23234
|
+
size: "small",
|
|
23235
|
+
style: {
|
|
23236
|
+
width: "100px",
|
|
23237
|
+
display: "inline-block",
|
|
23238
|
+
marginTop: "5px"
|
|
23239
|
+
},
|
|
23240
|
+
onClick: handleTillNow,
|
|
23241
|
+
children: "\u81F3\u4ECA"
|
|
23242
|
+
})
|
|
23243
|
+
});
|
|
23244
|
+
} : undefined,
|
|
23245
|
+
bordered: this.props.hideBorder ? false : true,
|
|
23246
|
+
style: {
|
|
23247
|
+
width: "360px"
|
|
23248
|
+
},
|
|
23249
|
+
locale: zhCN$1,
|
|
23250
|
+
defaultValue: rangePickerData,
|
|
23251
|
+
onCalendarChange: function onCalendarChange(d) {
|
|
23252
|
+
_this2._onCalendarChangeValue = d; // 用户开始新一轮选择时清理面板点击缓存,避免上一轮过时数据污染
|
|
23189
23253
|
|
|
23190
|
-
|
|
23254
|
+
_this2._panelClickedDate = null;
|
|
23255
|
+
},
|
|
23256
|
+
onOpenChange: function onOpenChange(open) {
|
|
23257
|
+
if (!open) {
|
|
23258
|
+
_this2._panelClickedDate = null;
|
|
23259
|
+
}
|
|
23260
|
+
},
|
|
23261
|
+
onChange: function onChange(vv) {
|
|
23262
|
+
// 用户清空日期范围时,直接置空
|
|
23263
|
+
if (!vv) {
|
|
23264
|
+
_Viewer.prototype.changeValueEx.call(_this2, undefined, true, true);
|
|
23191
23265
|
|
|
23192
|
-
|
|
23193
|
-
|
|
23194
|
-
|
|
23266
|
+
return;
|
|
23267
|
+
}
|
|
23268
|
+
|
|
23269
|
+
var currentData = _Viewer.prototype.getValue.call(_this2);
|
|
23270
|
+
|
|
23271
|
+
var isTillNow = _.get(currentData, "[2]") === true; // 若当前是"至今"且用户只改了开始时间(结束时间仍为 null),保留 tillNow
|
|
23272
|
+
|
|
23273
|
+
var newTillNow = isTillNow && vv[1] == null;
|
|
23274
|
+
|
|
23275
|
+
_Viewer.prototype.changeValueEx.call(_this2, _this2._rangePicker2Data(vv, newTillNow), true, true);
|
|
23276
|
+
}
|
|
23277
|
+
}, extraProps), this.state.ctrlVersion + "_" + ((_this$props$schema$da6 = this.props.schema.dateRangePrecision) != null ? _this$props$schema$da6 : "day"))
|
|
23278
|
+
});
|
|
23195
23279
|
}
|
|
23196
23280
|
};
|
|
23197
23281
|
|