@nokecy/qc-ui 1.1.47 → 1.1.48

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.
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.useArrayTableSources = exports.useArrayTableActions = exports.useAddition = exports.isColumnComponent = exports.buildArrayTableColumns = exports.LazyReadOnlyText = exports.LazyAgField = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
+ var _antd = require("antd");
9
10
  var _react2 = require("@formily/react");
10
11
  var _shared = require("@formily/shared");
11
12
  var _arrayBase = _interopRequireDefault(require("./arrayBase"));
@@ -169,6 +170,26 @@ var readByFieldPath = function readByFieldPath(record, path) {
169
170
  }, record);
170
171
  };
171
172
 
173
+ /** 「选一个」型组件:空值占位说「请选择」,其余说「请输入」 */
174
+ var SELECT_LIKE = new Set(['Select', 'TreeSelect', 'Cascader', 'DatePicker', 'TimePicker', 'Radio.Group', 'Checkbox.Group', 'Transfer']);
175
+
176
+ /**
177
+ * 懒挂载空值格显示什么。
178
+ *
179
+ * 懒挂载把未激活的可编辑格降成纯文本,值为空时整格一片空白——连输入框边框都没有,
180
+ * 用户看不出这里能填,以为功能坏了。故空值时按真控件的 placeholder 出淡灰占位,
181
+ * 点开前后看到同一句话,观感连续。
182
+ *
183
+ * 同样的理由 Switch/Checkbox 早就强制 eager 了(见 buildArrayTableColumns 的
184
+ * isInlineToggle),这里是把那条理由推广到其余可编辑列。@author nokecy
185
+ */
186
+ var resolveEmptyPlaceholder = function resolveEmptyPlaceholder(fieldSchema) {
187
+ var _fieldSchema$xCompon;
188
+ var configured = fieldSchema === null || fieldSchema === void 0 || (_fieldSchema$xCompon = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon === void 0 ? void 0 : _fieldSchema$xCompon.placeholder;
189
+ if (typeof configured === 'string' && configured) return configured;
190
+ return SELECT_LIKE.has(fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema['x-component']) ? '请选择' : '请输入';
191
+ };
192
+
172
193
  /**
173
194
  * 懒挂载单元格渲染器(可编辑列)。
174
195
  *
@@ -195,6 +216,9 @@ var LazyAgField = exports.LazyAgField = function LazyAgField(params) {
195
216
  formatter = params.formatter,
196
217
  columnProps = params.columnProps,
197
218
  fieldSchema = params.fieldSchema;
219
+ // hook 必须在下面的条件 return 之前调用
220
+ var _theme$useToken = _antd.theme.useToken(),
221
+ token = _theme$useToken.token;
198
222
  var key = "".concat(node === null || node === void 0 ? void 0 : node.id, ":").concat(colDef === null || colDef === void 0 ? void 0 : colDef.field);
199
223
  var activated = (record === null || record === void 0 ? void 0 : record._isNew) === true || (context === null || context === void 0 || (_context$activeCells = context.activeCells) === null || _context$activeCells === void 0 || (_context$activeCells$ = _context$activeCells.has) === null || _context$activeCells$ === void 0 ? void 0 : _context$activeCells$.call(_context$activeCells, key)) === true;
200
224
  if (activated) {
@@ -221,6 +245,18 @@ var LazyAgField = exports.LazyAgField = function LazyAgField(params) {
221
245
  fieldSchema: fieldSchema
222
246
  }) : liveValue == null ? '' : String(liveValue);
223
247
  // 纯文本占满单元格,点击交给 AG-Grid onCellClicked 激活;样式尽量贴近 Editable 只读态避免点开跳动
248
+ if (text === '') {
249
+ // 空值:出淡灰 placeholder,让用户看得出这格能填(颜色取 antd 输入框 placeholder 的 token,自动跟随暗色主题)
250
+ return /*#__PURE__*/_react.default.createElement("span", {
251
+ className: "ag-array-table-lazy-placeholder",
252
+ style: {
253
+ display: 'inline-block',
254
+ width: '100%',
255
+ cursor: 'text',
256
+ color: token.colorTextPlaceholder
257
+ }
258
+ }, resolveEmptyPlaceholder(fieldSchema));
259
+ }
224
260
  return /*#__PURE__*/_react.default.createElement("span", {
225
261
  className: "ag-array-table-lazy-text",
226
262
  style: {
@@ -8,6 +8,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
8
8
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
9
9
  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; }
10
10
  import React from 'react';
11
+ import { theme } from 'antd';
11
12
  import { useField, useFieldSchema, RecursionField, Observer } from '@formily/react';
12
13
  import { isArr } from '@formily/shared';
13
14
  import ArrayBase from "./arrayBase";
@@ -162,6 +163,26 @@ var readByFieldPath = function readByFieldPath(record, path) {
162
163
  }, record);
163
164
  };
164
165
 
166
+ /** 「选一个」型组件:空值占位说「请选择」,其余说「请输入」 */
167
+ var SELECT_LIKE = new Set(['Select', 'TreeSelect', 'Cascader', 'DatePicker', 'TimePicker', 'Radio.Group', 'Checkbox.Group', 'Transfer']);
168
+
169
+ /**
170
+ * 懒挂载空值格显示什么。
171
+ *
172
+ * 懒挂载把未激活的可编辑格降成纯文本,值为空时整格一片空白——连输入框边框都没有,
173
+ * 用户看不出这里能填,以为功能坏了。故空值时按真控件的 placeholder 出淡灰占位,
174
+ * 点开前后看到同一句话,观感连续。
175
+ *
176
+ * 同样的理由 Switch/Checkbox 早就强制 eager 了(见 buildArrayTableColumns 的
177
+ * isInlineToggle),这里是把那条理由推广到其余可编辑列。@author nokecy
178
+ */
179
+ var resolveEmptyPlaceholder = function resolveEmptyPlaceholder(fieldSchema) {
180
+ var _fieldSchema$xCompon;
181
+ var configured = fieldSchema === null || fieldSchema === void 0 || (_fieldSchema$xCompon = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon === void 0 ? void 0 : _fieldSchema$xCompon.placeholder;
182
+ if (typeof configured === 'string' && configured) return configured;
183
+ return SELECT_LIKE.has(fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema['x-component']) ? '请选择' : '请输入';
184
+ };
185
+
165
186
  /**
166
187
  * 懒挂载单元格渲染器(可编辑列)。
167
188
  *
@@ -188,6 +209,9 @@ var LazyAgField = function LazyAgField(params) {
188
209
  formatter = params.formatter,
189
210
  columnProps = params.columnProps,
190
211
  fieldSchema = params.fieldSchema;
212
+ // hook 必须在下面的条件 return 之前调用
213
+ var _theme$useToken = theme.useToken(),
214
+ token = _theme$useToken.token;
191
215
  var key = "".concat(node === null || node === void 0 ? void 0 : node.id, ":").concat(colDef === null || colDef === void 0 ? void 0 : colDef.field);
192
216
  var activated = (record === null || record === void 0 ? void 0 : record._isNew) === true || (context === null || context === void 0 || (_context$activeCells = context.activeCells) === null || _context$activeCells === void 0 || (_context$activeCells$ = _context$activeCells.has) === null || _context$activeCells$ === void 0 ? void 0 : _context$activeCells$.call(_context$activeCells, key)) === true;
193
217
  if (activated) {
@@ -214,6 +238,18 @@ var LazyAgField = function LazyAgField(params) {
214
238
  fieldSchema: fieldSchema
215
239
  }) : liveValue == null ? '' : String(liveValue);
216
240
  // 纯文本占满单元格,点击交给 AG-Grid onCellClicked 激活;样式尽量贴近 Editable 只读态避免点开跳动
241
+ if (text === '') {
242
+ // 空值:出淡灰 placeholder,让用户看得出这格能填(颜色取 antd 输入框 placeholder 的 token,自动跟随暗色主题)
243
+ return /*#__PURE__*/React.createElement("span", {
244
+ className: "ag-array-table-lazy-placeholder",
245
+ style: {
246
+ display: 'inline-block',
247
+ width: '100%',
248
+ cursor: 'text',
249
+ color: token.colorTextPlaceholder
250
+ }
251
+ }, resolveEmptyPlaceholder(fieldSchema));
252
+ }
217
253
  return /*#__PURE__*/React.createElement("span", {
218
254
  className: "ag-array-table-lazy-text",
219
255
  style: {