form-driver 0.4.26 → 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/lib/m3.js CHANGED
@@ -24,7 +24,6 @@ var clsx = require('clsx');
24
24
  var Button = require('antd/lib/button');
25
25
  var _objectWithoutPropertiesLoose = require('@babel/runtime/helpers/objectWithoutPropertiesLoose');
26
26
  var zhCN$1 = require('antd/lib/date-picker/locale/zh_CN');
27
- var ReactDOM = require('react-dom');
28
27
  var debounce = require('lodash/debounce');
29
28
  require('moment/locale/zh-cn');
30
29
  var _extends = require('@babel/runtime/helpers/extends');
@@ -46,7 +45,6 @@ var clsx__default = /*#__PURE__*/_interopDefaultLegacy(clsx);
46
45
  var Button__default = /*#__PURE__*/_interopDefaultLegacy(Button);
47
46
  var _objectWithoutPropertiesLoose__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutPropertiesLoose);
48
47
  var zhCN__default$1 = /*#__PURE__*/_interopDefaultLegacy(zhCN$1);
49
- var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
50
48
  var debounce__default = /*#__PURE__*/_interopDefaultLegacy(debounce);
51
49
  var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
52
50
  var OSS__default = /*#__PURE__*/_interopDefaultLegacy(OSS);
@@ -22970,7 +22968,7 @@ var ARangePicker = /*#__PURE__*/function (_Viewer) {
22970
22968
  ctrlVersion: 1,
22971
22969
  noValidate: false,
22972
22970
  mobileDlg: false,
22973
- mobileStep: 'start'
22971
+ mobileStep: "start"
22974
22972
  };
22975
22973
  return _this;
22976
22974
  }
@@ -22990,10 +22988,9 @@ var ARangePicker = /*#__PURE__*/function (_Viewer) {
22990
22988
 
22991
22989
  if (___default["default"].get(v, "[2]")) {
22992
22990
  // tillnow
22993
- var dom = ReactDOM__default["default"].findDOMNode(this._pickerRef.current);
22991
+ var dom = this._pickerRef.current;
22994
22992
 
22995
22993
  if (dom) {
22996
- // @ts-ignore
22997
22994
  var r = dom.querySelector(":nth-child(3)");
22998
22995
 
22999
22996
  if (r) {
@@ -23047,19 +23044,19 @@ var ARangePicker = /*#__PURE__*/function (_Viewer) {
23047
23044
 
23048
23045
  var show = MDateRangeType.toReadableN(assembly, this.props.schema, _Viewer.prototype.getValue.call(this)); // 根据 precision 配置确定移动端 DatePicker 精度(使用扁平化属性 dateRangePrecision)
23049
23046
 
23050
- var mobilePrecision = this.props.schema.dateRangePrecision || 'day';
23047
+ var mobilePrecision = this.props.schema.dateRangePrecision || "day";
23051
23048
  return jsxRuntime.jsxs(jsxRuntime.Fragment, {
23052
23049
  children: [jsxRuntime.jsxs("div", {
23053
23050
  className: "backfill",
23054
23051
  onClick: function onClick() {
23055
23052
  return _this2.setState({
23056
23053
  mobileDlg: true,
23057
- mobileStep: 'start'
23054
+ mobileStep: "start"
23058
23055
  });
23059
23056
  },
23060
- children: [" ", show != null ? show : '请点击选择', " "]
23057
+ children: [" ", show != null ? show : "请点击选择", " "]
23061
23058
  }), jsxRuntime.jsx(antdMobile.DatePicker, {
23062
- visible: this.state.mobileDlg && this.state.mobileStep === 'start',
23059
+ visible: this.state.mobileDlg && this.state.mobileStep === "start",
23063
23060
  precision: mobilePrecision,
23064
23061
  title: "\u9009\u62E9\u5F00\u59CB\u65E5\u671F",
23065
23062
  min: this.props.schema.min ? new Date(this.props.schema.min) : undefined,
@@ -23069,7 +23066,7 @@ var ARangePicker = /*#__PURE__*/function (_Viewer) {
23069
23066
 
23070
23067
  _this2.setState({
23071
23068
  mobileStartDate: val,
23072
- mobileStep: 'end'
23069
+ mobileStep: "end"
23073
23070
  });
23074
23071
  },
23075
23072
  onClose: function onClose() {
@@ -23085,14 +23082,14 @@ var ARangePicker = /*#__PURE__*/function (_Viewer) {
23085
23082
  });
23086
23083
  }
23087
23084
  }, "start_" + mobilePrecision), jsxRuntime.jsx(antdMobile.DatePicker, {
23088
- visible: this.state.mobileDlg && this.state.mobileStep === 'end',
23085
+ visible: this.state.mobileDlg && this.state.mobileStep === "end",
23089
23086
  precision: mobilePrecision,
23090
23087
  title: // 如果允许"至今"且开始时间不在未来,在标题区域展示"至今"按钮
23091
23088
  !((_this$props$schema$da3 = this.props.schema.dateRange) != null && _this$props$schema$da3.hideTillNow) && !(this.state.mobileStartDate && this.state.mobileStartDate > new Date()) ? jsxRuntime.jsxs("div", {
23092
23089
  style: {
23093
- display: 'flex',
23094
- alignItems: 'center',
23095
- justifyContent: 'center',
23090
+ display: "flex",
23091
+ alignItems: "center",
23092
+ justifyContent: "center",
23096
23093
  gap: 12
23097
23094
  },
23098
23095
  children: [jsxRuntime.jsx("span", {
@@ -23133,7 +23130,7 @@ var ARangePicker = /*#__PURE__*/function (_Viewer) {
23133
23130
  onClose: function onClose() {
23134
23131
  // 回退到第一步,让用户可以重新选择开始日期
23135
23132
  _this2.setState({
23136
- mobileStep: 'start'
23133
+ mobileStep: "start"
23137
23134
  });
23138
23135
  }
23139
23136
  }, "end_" + mobilePrecision)]
@@ -23143,23 +23140,23 @@ var ARangePicker = /*#__PURE__*/function (_Viewer) {
23143
23140
 
23144
23141
  // 根据 precision 配置确定 PC 端 picker 模式和 showTime(使用扁平化属性 dateRangePrecision)
23145
23142
  var precision = this.props.schema.dateRangePrecision;
23146
- var pcShowTime = precision === 'minute' || ((_this$props$schema$da4 = this.props.schema.dateRange) == null ? void 0 : _this$props$schema$da4.showTime);
23143
+ var pcShowTime = precision === "minute" || ((_this$props$schema$da4 = this.props.schema.dateRange) == null ? void 0 : _this$props$schema$da4.showTime);
23147
23144
  var hideFooter = (_this$props$schema$da5 = this.props.schema.dateRange) == null ? void 0 : _this$props$schema$da5.hideTillNow; // 动态构建额外属性,避免 showTime 和 picker 同时传入导致类型冲突
23148
23145
 
23149
23146
  var extraProps = {};
23150
23147
 
23151
- if (precision === 'year') {
23152
- extraProps.picker = 'year';
23153
- } else if (precision === 'month') {
23154
- extraProps.picker = 'month';
23148
+ if (precision === "year") {
23149
+ extraProps.picker = "year";
23150
+ } else if (precision === "month") {
23151
+ extraProps.picker = "month";
23155
23152
  } else if (pcShowTime) {
23156
23153
  // precision 为 minute 时只展示时分,不展示秒
23157
- extraProps.showTime = precision === 'minute' ? {
23158
- format: 'HH:mm'
23154
+ extraProps.showTime = precision === "minute" ? {
23155
+ format: "HH:mm"
23159
23156
  } : true; // 同步设置输入框的显示格式,避免 showTime.format 只影响面板列而输入框仍显示秒
23160
23157
 
23161
- if (precision === 'minute') {
23162
- extraProps.format = 'YYYY-MM-DD HH:mm';
23158
+ if (precision === "minute") {
23159
+ extraProps.format = "YYYY-MM-DD HH:mm";
23163
23160
  }
23164
23161
  } // "至今"按钮的点击处理函数
23165
23162
 
@@ -23183,124 +23180,126 @@ var ARangePicker = /*#__PURE__*/function (_Viewer) {
23183
23180
 
23184
23181
  var showTillNow = !hideFooter; // 构造元素
23185
23182
 
23186
- return jsxRuntime.jsx(antd.DatePicker.RangePicker, _objectSpread$8({
23183
+ return jsxRuntime.jsx("div", {
23187
23184
  ref: this._pickerRef,
23188
- panelRender: pcShowTime && showTillNow ? function (panelNode) {
23189
- // showTime 模式下:通过事件委托捕获面板上日期单元格的点击
23190
- // 同时在 footer 的"确定"按钮同一行注入"至今"按钮
23191
- return jsxRuntime.jsx("div", {
23192
- onClick: function onClick(e) {
23193
- var target = e.target;
23194
- var cell = target.closest == null ? void 0 : target.closest('.ant-picker-cell');
23185
+ children: jsxRuntime.jsx(antd.DatePicker.RangePicker, _objectSpread$8({
23186
+ panelRender: pcShowTime && showTillNow ? function (panelNode) {
23187
+ // showTime 模式下:通过事件委托捕获面板上日期单元格的点击
23188
+ // 同时在 footer 的"确定"按钮同一行注入"至今"按钮
23189
+ return jsxRuntime.jsx("div", {
23190
+ onClick: function onClick(e) {
23191
+ var target = e.target;
23192
+ var cell = target.closest == null ? void 0 : target.closest(".ant-picker-cell");
23195
23193
 
23196
- if (cell) {
23197
- // 排除 disabled 状态的日期单元格
23198
- if (cell.classList.contains('ant-picker-cell-disabled')) return;
23199
- var title = cell.getAttribute('title');
23194
+ if (cell) {
23195
+ // 排除 disabled 状态的日期单元格
23196
+ if (cell.classList.contains("ant-picker-cell-disabled")) return;
23197
+ var title = cell.getAttribute("title");
23200
23198
 
23201
- if (title) {
23202
- var parsed = moment__default["default"](title, 'YYYY-MM-DD'); // 校验 moment 解析有效性,无效日期不记录
23199
+ if (title) {
23200
+ var parsed = moment__default["default"](title, "YYYY-MM-DD"); // 校验 moment 解析有效性,无效日期不记录
23203
23201
 
23204
- if (parsed.isValid()) {
23205
- _this2._panelClickedDate = parsed;
23202
+ if (parsed.isValid()) {
23203
+ _this2._panelClickedDate = parsed;
23204
+ }
23206
23205
  }
23207
23206
  }
23208
- }
23209
- },
23210
- ref: function ref(el) {
23211
- var _ref3, _this2$_onCalendarCha2, _this2$_onCalendarCha3;
23207
+ },
23208
+ ref: function ref(el) {
23209
+ var _ref3, _this2$_onCalendarCha2, _this2$_onCalendarCha3;
23212
23210
 
23213
- // 面板渲染后,将"至今"按钮注入到 .ant-picker-ok 内部,确定按钮之后
23214
- // 这样两者在同一个 flex item 中,确定在左、至今在右
23215
- if (!el) return;
23216
- var okLi = el.querySelector('.ant-picker-ok');
23217
- if (!okLi) return; // 开始时间在未来时,移除已有的至今按钮并不再注入
23211
+ // 面板渲染后,将"至今"按钮注入到 .ant-picker-ok 内部,确定按钮之后
23212
+ // 这样两者在同一个 flex item 中,确定在左、至今在右
23213
+ if (!el) return;
23214
+ var okLi = el.querySelector(".ant-picker-ok");
23215
+ if (!okLi) return; // 开始时间在未来时,移除已有的至今按钮并不再注入
23218
23216
 
23219
- 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];
23217
+ 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];
23220
23218
 
23221
- if (previewStart && previewStart.isAfter(moment__default["default"]())) {
23222
- var existingBtn = okLi.querySelector('.till-now-btn');
23223
- if (existingBtn) existingBtn.remove();
23224
- return;
23225
- }
23219
+ if (previewStart && previewStart.isAfter(moment__default["default"]())) {
23220
+ var existingBtn = okLi.querySelector(".till-now-btn");
23221
+ if (existingBtn) existingBtn.remove();
23222
+ return;
23223
+ }
23226
23224
 
23227
- if (!okLi.querySelector('.till-now-btn')) {
23228
- var tillNowBtn = document.createElement('button');
23229
- tillNowBtn.className = 'ant-btn ant-btn-sm till-now-btn';
23230
- tillNowBtn.textContent = '至今';
23231
- tillNowBtn.style.cssText = 'margin-left: 8px;'; // 使用具名函数以便于清理;先移除可能的旧监听再添加,防止重复绑定
23225
+ if (!okLi.querySelector(".till-now-btn")) {
23226
+ var tillNowBtn = document.createElement("button");
23227
+ tillNowBtn.className = "ant-btn ant-btn-sm till-now-btn";
23228
+ tillNowBtn.textContent = "至今";
23229
+ tillNowBtn.style.cssText = "margin-left: 8px;"; // 使用具名函数以便于清理;先移除可能的旧监听再添加,防止重复绑定
23232
23230
 
23233
- var onTillNowClick = function onTillNowClick(e) {
23234
- e.stopPropagation();
23235
- handleTillNow();
23236
- };
23231
+ var onTillNowClick = function onTillNowClick(e) {
23232
+ e.stopPropagation();
23233
+ handleTillNow();
23234
+ };
23237
23235
 
23238
- tillNowBtn.addEventListener('click', onTillNowClick);
23239
- okLi.appendChild(tillNowBtn);
23240
- }
23241
- },
23242
- children: panelNode
23243
- });
23244
- } : undefined,
23245
- renderExtraFooter: !pcShowTime && showTillNow ? function (mode) {
23246
- var _this2$_onCalendarCha4, _this2$_onCalendarCha5;
23236
+ tillNowBtn.addEventListener("click", onTillNowClick);
23237
+ okLi.appendChild(tillNowBtn);
23238
+ }
23239
+ },
23240
+ children: panelNode
23241
+ });
23242
+ } : undefined,
23243
+ renderExtraFooter: !pcShowTime && showTillNow ? function (mode) {
23244
+ var _this2$_onCalendarCha4, _this2$_onCalendarCha5;
23247
23245
 
23248
- // 非 showTime 模式:使用 renderExtraFooter 展示"至今"按钮
23249
- var previewStart = (_this2$_onCalendarCha4 = (_this2$_onCalendarCha5 = _this2._onCalendarChangeValue) == null ? void 0 : _this2$_onCalendarCha5[0]) != null ? _this2$_onCalendarCha4 : rangePickerData == null ? void 0 : rangePickerData[0];
23246
+ // 非 showTime 模式:使用 renderExtraFooter 展示"至今"按钮
23247
+ var previewStart = (_this2$_onCalendarCha4 = (_this2$_onCalendarCha5 = _this2._onCalendarChangeValue) == null ? void 0 : _this2$_onCalendarCha5[0]) != null ? _this2$_onCalendarCha4 : rangePickerData == null ? void 0 : rangePickerData[0];
23250
23248
 
23251
- if (previewStart && previewStart.isAfter(moment__default["default"]())) {
23252
- return null;
23253
- }
23249
+ if (previewStart && previewStart.isAfter(moment__default["default"]())) {
23250
+ return null;
23251
+ }
23254
23252
 
23255
- return jsxRuntime.jsx("div", {
23256
- style: {
23257
- textAlign: "right"
23258
- },
23259
- children: jsxRuntime.jsx(antd.Button, {
23260
- size: "small",
23253
+ return jsxRuntime.jsx("div", {
23261
23254
  style: {
23262
- width: "100px",
23263
- display: "inline-block",
23264
- marginTop: "5px"
23255
+ textAlign: "right"
23265
23256
  },
23266
- onClick: handleTillNow,
23267
- children: "\u81F3\u4ECA"
23268
- })
23269
- });
23270
- } : undefined,
23271
- bordered: this.props.hideBorder ? false : true,
23272
- style: {
23273
- width: "300px"
23274
- },
23275
- locale: zhCN__default$1["default"],
23276
- defaultValue: rangePickerData,
23277
- onCalendarChange: function onCalendarChange(d) {
23278
- _this2._onCalendarChangeValue = d; // 用户开始新一轮选择时清理面板点击缓存,避免上一轮过时数据污染
23257
+ children: jsxRuntime.jsx(antd.Button, {
23258
+ size: "small",
23259
+ style: {
23260
+ width: "100px",
23261
+ display: "inline-block",
23262
+ marginTop: "5px"
23263
+ },
23264
+ onClick: handleTillNow,
23265
+ children: "\u81F3\u4ECA"
23266
+ })
23267
+ });
23268
+ } : undefined,
23269
+ bordered: this.props.hideBorder ? false : true,
23270
+ style: {
23271
+ width: "360px"
23272
+ },
23273
+ locale: zhCN__default$1["default"],
23274
+ defaultValue: rangePickerData,
23275
+ onCalendarChange: function onCalendarChange(d) {
23276
+ _this2._onCalendarChangeValue = d; // 用户开始新一轮选择时清理面板点击缓存,避免上一轮过时数据污染
23279
23277
 
23280
- _this2._panelClickedDate = null;
23281
- },
23282
- onOpenChange: function onOpenChange(open) {
23283
- if (!open) {
23284
23278
  _this2._panelClickedDate = null;
23285
- }
23286
- },
23287
- onChange: function onChange(vv) {
23288
- // 用户清空日期范围时,直接置空
23289
- if (!vv) {
23290
- _Viewer.prototype.changeValueEx.call(_this2, undefined, true, true);
23279
+ },
23280
+ onOpenChange: function onOpenChange(open) {
23281
+ if (!open) {
23282
+ _this2._panelClickedDate = null;
23283
+ }
23284
+ },
23285
+ onChange: function onChange(vv) {
23286
+ // 用户清空日期范围时,直接置空
23287
+ if (!vv) {
23288
+ _Viewer.prototype.changeValueEx.call(_this2, undefined, true, true);
23291
23289
 
23292
- return;
23293
- }
23290
+ return;
23291
+ }
23294
23292
 
23295
- var currentData = _Viewer.prototype.getValue.call(_this2);
23293
+ var currentData = _Viewer.prototype.getValue.call(_this2);
23296
23294
 
23297
- var isTillNow = ___default["default"].get(currentData, '[2]') === true; // 若当前是"至今"且用户只改了开始时间(结束时间仍为 null),保留 tillNow
23295
+ var isTillNow = ___default["default"].get(currentData, "[2]") === true; // 若当前是"至今"且用户只改了开始时间(结束时间仍为 null),保留 tillNow
23298
23296
 
23299
- var newTillNow = isTillNow && vv[1] == null;
23297
+ var newTillNow = isTillNow && vv[1] == null;
23300
23298
 
23301
- _Viewer.prototype.changeValueEx.call(_this2, _this2._rangePicker2Data(vv, newTillNow), true, true);
23302
- }
23303
- }, extraProps), this.state.ctrlVersion + "_" + ((_this$props$schema$da6 = this.props.schema.dateRangePrecision) != null ? _this$props$schema$da6 : 'day'));
23299
+ _Viewer.prototype.changeValueEx.call(_this2, _this2._rangePicker2Data(vv, newTillNow), true, true);
23300
+ }
23301
+ }, extraProps), this.state.ctrlVersion + "_" + ((_this$props$schema$da6 = this.props.schema.dateRangePrecision) != null ? _this$props$schema$da6 : "day"))
23302
+ });
23304
23303
  }
23305
23304
  };
23306
23305
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "form-driver",
3
- "version": "0.4.26",
3
+ "version": "0.4.27",
4
4
  "description": "An efficient framework for creating forms.",
5
5
  "license": "MIT",
6
6
  "authors": [