@nokecy/qc-ui 1.1.73 → 1.1.75

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.
Files changed (81) hide show
  1. package/dist/cjs/adapters/pagedApiAdapter.d.ts +2 -0
  2. package/dist/cjs/ag-grid-plus/ag-gridPlus.js +5 -3
  3. package/dist/cjs/ag-grid-plus/interface.d.ts +6 -0
  4. package/dist/cjs/ag-grid-plus/utils/aggregation.js +8 -14
  5. package/dist/cjs/ag-grid-plus/utils/columnProcessors.d.ts +2 -1
  6. package/dist/cjs/ag-grid-plus/utils/columnProcessors.js +5 -2
  7. package/dist/cjs/ag-grid-plus/utils/valueEnumColor.d.ts +17 -0
  8. package/dist/cjs/ag-grid-plus/utils/valueEnumColor.js +99 -0
  9. package/dist/cjs/dialogSelect/index.d.ts +31 -2
  10. package/dist/cjs/dialogSelect/index.js +209 -105
  11. package/dist/cjs/dialogSelect/index.less +39 -0
  12. package/dist/cjs/draggableModal/index.js +12 -8
  13. package/dist/cjs/entitySelect/index.d.ts +57 -0
  14. package/dist/cjs/entitySelect/index.js +172 -0
  15. package/dist/cjs/index.d.ts +8 -0
  16. package/dist/cjs/index.js +143 -1
  17. package/dist/cjs/readPretty/arrayTable.d.ts +6 -0
  18. package/dist/cjs/readPretty/arrayTable.js +156 -0
  19. package/dist/cjs/readPretty/controls.d.ts +11 -0
  20. package/dist/cjs/readPretty/controls.js +68 -0
  21. package/dist/cjs/readPretty/decimal.d.ts +4 -0
  22. package/dist/cjs/readPretty/decimal.js +28 -0
  23. package/dist/cjs/readPretty/formily.d.ts +2 -0
  24. package/dist/cjs/readPretty/formily.js +71 -0
  25. package/dist/cjs/readPretty/hoistStatics.d.ts +1 -0
  26. package/dist/cjs/readPretty/hoistStatics.js +37 -0
  27. package/dist/cjs/readPretty/index.d.ts +11 -0
  28. package/dist/cjs/readPretty/index.js +70 -0
  29. package/dist/cjs/readPretty/selectValue.d.ts +7 -0
  30. package/dist/cjs/readPretty/selectValue.js +60 -0
  31. package/dist/cjs/readPretty/values.d.ts +4 -0
  32. package/dist/cjs/readPretty/values.js +49 -0
  33. package/dist/cjs/toolBar/index.d.ts +1 -0
  34. package/dist/cjs/toolBar/index.js +44 -10
  35. package/dist/cjs/toolBar/index.less +25 -7
  36. package/dist/cjs/utils/businessDecimal.d.ts +11 -0
  37. package/dist/cjs/utils/businessDecimal.js +53 -0
  38. package/dist/cjs/utils/contrast.d.ts +40 -0
  39. package/dist/cjs/utils/contrast.js +153 -0
  40. package/dist/esm/adapters/pagedApiAdapter.d.ts +2 -0
  41. package/dist/esm/ag-grid-plus/ag-gridPlus.js +5 -3
  42. package/dist/esm/ag-grid-plus/interface.d.ts +6 -0
  43. package/dist/esm/ag-grid-plus/utils/aggregation.js +1 -5
  44. package/dist/esm/ag-grid-plus/utils/columnProcessors.d.ts +2 -1
  45. package/dist/esm/ag-grid-plus/utils/columnProcessors.js +5 -2
  46. package/dist/esm/ag-grid-plus/utils/valueEnumColor.d.ts +17 -0
  47. package/dist/esm/ag-grid-plus/utils/valueEnumColor.js +95 -0
  48. package/dist/esm/dialogSelect/index.d.ts +31 -2
  49. package/dist/esm/dialogSelect/index.js +211 -106
  50. package/dist/esm/dialogSelect/index.less +39 -0
  51. package/dist/esm/draggableModal/index.js +12 -8
  52. package/dist/esm/entitySelect/index.d.ts +57 -0
  53. package/dist/esm/entitySelect/index.js +164 -0
  54. package/dist/esm/index.d.ts +8 -0
  55. package/dist/esm/index.js +5 -0
  56. package/dist/esm/readPretty/arrayTable.d.ts +6 -0
  57. package/dist/esm/readPretty/arrayTable.js +147 -0
  58. package/dist/esm/readPretty/controls.d.ts +11 -0
  59. package/dist/esm/readPretty/controls.js +62 -0
  60. package/dist/esm/readPretty/decimal.d.ts +4 -0
  61. package/dist/esm/readPretty/decimal.js +22 -0
  62. package/dist/esm/readPretty/formily.d.ts +2 -0
  63. package/dist/esm/readPretty/formily.js +63 -0
  64. package/dist/esm/readPretty/hoistStatics.d.ts +1 -0
  65. package/dist/esm/readPretty/hoistStatics.js +31 -0
  66. package/dist/esm/readPretty/index.d.ts +11 -0
  67. package/dist/esm/readPretty/index.js +12 -0
  68. package/dist/esm/readPretty/selectValue.d.ts +7 -0
  69. package/dist/esm/readPretty/selectValue.js +53 -0
  70. package/dist/esm/readPretty/values.d.ts +4 -0
  71. package/dist/esm/readPretty/values.js +43 -0
  72. package/dist/esm/toolBar/index.d.ts +1 -0
  73. package/dist/esm/toolBar/index.js +43 -10
  74. package/dist/esm/toolBar/index.less +25 -7
  75. package/dist/esm/utils/businessDecimal.d.ts +11 -0
  76. package/dist/esm/utils/businessDecimal.js +47 -0
  77. package/dist/esm/utils/contrast.d.ts +40 -0
  78. package/dist/esm/utils/contrast.js +141 -0
  79. package/dist/umd/qc-ui.min.css +1 -1
  80. package/dist/umd/qc-ui.min.js +1 -1
  81. package/package.json +1 -1
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.withReadingFields = withReadingFields;
7
+ var _react = require("@formily/react");
8
+ var _react2 = _interopRequireDefault(require("react"));
9
+ var _hoistStatics = require("./hoistStatics");
10
+ var Reading = _interopRequireWildcard(require("./controls"));
11
+ var _arrayTable = require("./arrayTable");
12
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
13
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
16
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
17
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
18
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
19
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
20
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
21
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
22
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
23
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
24
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
25
+ /** 动态表单统一入口:禁用/只读的数据控件使用阅读展示,保持字段值和校验模型。@author nokecy */
26
+ function withReadingFields(components) {
27
+ var result = _objectSpread({}, components);
28
+ var previews = _objectSpread(_objectSpread({}, Reading), {}, {
29
+ NumberPicker: Reading.InputNumber,
30
+ Password: Reading.Input.Password
31
+ });
32
+ var wrap = function wrap(Control, Preview) {
33
+ var Component = (0, _react.observer)(function (props) {
34
+ var field = (0, _react.useField)();
35
+ if (props.disabled || props.readOnly || field !== null && field !== void 0 && field.disabled || field !== null && field !== void 0 && field.readOnly) {
36
+ var _field$value, _field$value2, _field$dataSource;
37
+ return /*#__PURE__*/_react2.default.createElement(Preview, _extends({}, props, {
38
+ value: (_field$value = field === null || field === void 0 ? void 0 : field.value) !== null && _field$value !== void 0 ? _field$value : props.value,
39
+ checked: (_field$value2 = field === null || field === void 0 ? void 0 : field.value) !== null && _field$value2 !== void 0 ? _field$value2 : props.checked,
40
+ options: field !== null && field !== void 0 && (_field$dataSource = field.dataSource) !== null && _field$dataSource !== void 0 && _field$dataSource.length ? field.dataSource : props.options,
41
+ disabled: true
42
+ }));
43
+ }
44
+ return /*#__PURE__*/_react2.default.createElement(Control, props);
45
+ });
46
+ var Wrapped = (0, _hoistStatics.hoistStatics)(Component, Control);
47
+ // 嵌套控件同样按字段状态展示,例如Input.TextArea、DatePicker.RangePicker。
48
+ for (var _i = 0, _arr = ['TextArea', 'Password', 'Search', 'Group', 'RangePicker']; _i < _arr.length; _i++) {
49
+ var key = _arr[_i];
50
+ if (Control[key] && Preview[key]) Wrapped[key] = wrap(Control[key], Preview[key]);
51
+ }
52
+ return Wrapped;
53
+ };
54
+ var _iterator = _createForOfIteratorHelper(Object.keys(previews).filter(function (name) {
55
+ return components[name];
56
+ })),
57
+ _step;
58
+ try {
59
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
60
+ var name = _step.value;
61
+ result[name] = wrap(components[name], previews[name]);
62
+ }
63
+ // ArrayTable 阅读态保留动态列的标题和显隐状态。@author nokecy
64
+ } catch (err) {
65
+ _iterator.e(err);
66
+ } finally {
67
+ _iterator.f();
68
+ }
69
+ if (components.ArrayTable) result.ArrayTable = (0, _arrayTable.withReadingArrayTable)(components.ArrayTable);
70
+ return result;
71
+ }
@@ -0,0 +1 @@
1
+ export declare function hoistStatics<T, S>(target: T, source: S): T & S;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.hoistStatics = hoistStatics;
7
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
8
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
9
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
10
+ /**
11
+ * 把被包装组件的静态成员(如 Input.TextArea、Select.Option)带到包装后的组件上,
12
+ * 等价于 hoist-non-react-statics,但不新增依赖。React 自有的静态属性不拷贝。
13
+ * @author nokecy
14
+ */
15
+ var REACT_STATICS = new Set(['$$typeof', 'render', 'defaultProps', 'displayName', 'propTypes', 'contextType', 'contextTypes', 'childContextTypes', 'getDefaultProps', 'getDerivedStateFromProps', 'getDerivedStateFromError', 'mixins', 'type', 'compare', 'length', 'name', 'prototype', 'caller', 'callee', 'arguments', 'arity']);
16
+ function hoistStatics(target, source) {
17
+ var _iterator = _createForOfIteratorHelper(Reflect.ownKeys(source)),
18
+ _step;
19
+ try {
20
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
21
+ var key = _step.value;
22
+ if (REACT_STATICS.has(key)) continue;
23
+ var descriptor = Object.getOwnPropertyDescriptor(source, key);
24
+ if (!descriptor) continue;
25
+ try {
26
+ Object.defineProperty(target, key, descriptor);
27
+ } catch (_unused) {
28
+ // 个别只读属性无法重定义,跳过即可。
29
+ }
30
+ }
31
+ } catch (err) {
32
+ _iterator.e(err);
33
+ } finally {
34
+ _iterator.f();
35
+ }
36
+ return target;
37
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * 阅读态控件:不可编辑时展示名称/文本而不是禁用的输入框,继承整张表单的禁用状态。
3
+ * 动态表单入口 `withReadingFields` 按字段的 disabled/readOnly 状态切换阅读展示,并保留 ArrayTable 动态列。
4
+ * @author nokecy
5
+ */
6
+ export * as ReadPrettyControls from './controls';
7
+ export { withReadingFields } from './formily';
8
+ export { withReadingArrayTable } from './arrayTable';
9
+ export { DecimalInput, DecimalPicker } from './decimal';
10
+ export { flattenOptions, selectedLabels } from './values';
11
+ export { normalizeSelectValue, selectCode, selectLabel } from './selectValue';
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ Object.defineProperty(exports, "DecimalInput", {
8
+ enumerable: true,
9
+ get: function get() {
10
+ return _decimal.DecimalInput;
11
+ }
12
+ });
13
+ Object.defineProperty(exports, "DecimalPicker", {
14
+ enumerable: true,
15
+ get: function get() {
16
+ return _decimal.DecimalPicker;
17
+ }
18
+ });
19
+ exports.ReadPrettyControls = void 0;
20
+ Object.defineProperty(exports, "flattenOptions", {
21
+ enumerable: true,
22
+ get: function get() {
23
+ return _values.flattenOptions;
24
+ }
25
+ });
26
+ Object.defineProperty(exports, "normalizeSelectValue", {
27
+ enumerable: true,
28
+ get: function get() {
29
+ return _selectValue.normalizeSelectValue;
30
+ }
31
+ });
32
+ Object.defineProperty(exports, "selectCode", {
33
+ enumerable: true,
34
+ get: function get() {
35
+ return _selectValue.selectCode;
36
+ }
37
+ });
38
+ Object.defineProperty(exports, "selectLabel", {
39
+ enumerable: true,
40
+ get: function get() {
41
+ return _selectValue.selectLabel;
42
+ }
43
+ });
44
+ Object.defineProperty(exports, "selectedLabels", {
45
+ enumerable: true,
46
+ get: function get() {
47
+ return _values.selectedLabels;
48
+ }
49
+ });
50
+ Object.defineProperty(exports, "withReadingArrayTable", {
51
+ enumerable: true,
52
+ get: function get() {
53
+ return _arrayTable.withReadingArrayTable;
54
+ }
55
+ });
56
+ Object.defineProperty(exports, "withReadingFields", {
57
+ enumerable: true,
58
+ get: function get() {
59
+ return _formily.withReadingFields;
60
+ }
61
+ });
62
+ var _ReadPrettyControls = _interopRequireWildcard(require("./controls"));
63
+ exports.ReadPrettyControls = _ReadPrettyControls;
64
+ var _formily = require("./formily");
65
+ var _arrayTable = require("./arrayTable");
66
+ var _decimal = require("./decimal");
67
+ var _values = require("./values");
68
+ var _selectValue = require("./selectValue");
69
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
70
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -0,0 +1,7 @@
1
+ import { type ReactNode } from 'react';
2
+ /** 提取选择项的标量编码,兼容嵌套 labelInValue;保留编码 0 和显式空字符串选项。@author nokecy */
3
+ export declare function selectCode(value: unknown, depth?: number): string | number | undefined;
4
+ /** 标签只输出可渲染内容;选择项对象取名称后再回落编码,避免 React 对象子节点异常。@author nokecy */
5
+ export declare function selectLabel(value: unknown, depth?: number): ReactNode;
6
+ /** 单选、多选与阅读态共用同一值形状;名称缺省时保留组件按选项查名称的行为。@author nokecy */
7
+ export declare function normalizeSelectValue(value: unknown, labelInValue?: boolean): any;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.normalizeSelectValue = normalizeSelectValue;
7
+ exports.selectCode = selectCode;
8
+ exports.selectLabel = selectLabel;
9
+ var _react = require("react");
10
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
11
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
12
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
14
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
15
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
16
+ /** 提取选择项的标量编码,兼容嵌套 labelInValue;保留编码 0 和显式空字符串选项。@author nokecy */
17
+ function selectCode(value) {
18
+ var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
19
+ if (typeof value === 'string') return value;
20
+ if (typeof value === 'number') return Number.isFinite(value) ? value : undefined;
21
+ if (!value || _typeof(value) !== 'object' || depth >= 8 || /*#__PURE__*/(0, _react.isValidElement)(value)) return undefined;
22
+ return selectCode(value.value, depth + 1);
23
+ }
24
+
25
+ /** 标签只输出可渲染内容;选择项对象取名称后再回落编码,避免 React 对象子节点异常。@author nokecy */
26
+ function selectLabel(value) {
27
+ var _selectLabel;
28
+ var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
29
+ if (value == null || typeof value === 'boolean' || depth >= 8) return undefined;
30
+ if (typeof value === 'string' || typeof value === 'number' || /*#__PURE__*/(0, _react.isValidElement)(value)) return value;
31
+ if (Array.isArray(value)) return value.map(function (item) {
32
+ return selectLabel(item, depth + 1);
33
+ });
34
+ if (_typeof(value) !== 'object') return undefined;
35
+ var item = value;
36
+ return (_selectLabel = selectLabel(item.label, depth + 1)) !== null && _selectLabel !== void 0 ? _selectLabel : selectLabel(item.value, depth + 1);
37
+ }
38
+
39
+ /** 单选、多选与阅读态共用同一值形状;名称缺省时保留组件按选项查名称的行为。@author nokecy */
40
+ function normalizeSelectValue(value, labelInValue) {
41
+ var _selectLabel2;
42
+ if (Array.isArray(value)) return value.map(function (item) {
43
+ return normalizeSelectValue(item, labelInValue);
44
+ }).filter(function (item) {
45
+ return item !== undefined;
46
+ });
47
+ var code = selectCode(value);
48
+ if (code === undefined) return undefined;
49
+ if (!labelInValue) return code;
50
+ if (!value || _typeof(value) !== 'object') return {
51
+ value: code
52
+ };
53
+ var item = value;
54
+ var label = (_selectLabel2 = selectLabel(item.label)) !== null && _selectLabel2 !== void 0 ? _selectLabel2 : _typeof(item.value) === 'object' ? selectLabel(item.value) : undefined;
55
+ return _objectSpread({
56
+ value: code
57
+ }, label !== undefined ? {
58
+ label: label
59
+ } : {});
60
+ }
@@ -0,0 +1,4 @@
1
+ /** 阅读态选择项展开,保留分组内选项及自定义字段名。@author nokecy */
2
+ export declare function flattenOptions(options?: any[], fieldNames?: any): any[];
3
+ /** 保留0和空选项标签;有 labelInValue 时优先使用已加载的名称。@author nokecy */
4
+ export declare function selectedLabels(value: any, options: any[], labelInValue?: boolean): any;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.flattenOptions = flattenOptions;
7
+ exports.selectedLabels = selectedLabels;
8
+ var _selectValue = require("./selectValue");
9
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
10
+ /** 阅读态选择项展开,保留分组内选项及自定义字段名。@author nokecy */
11
+ function flattenOptions() {
12
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
13
+ var fieldNames = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
14
+ var _ref = fieldNames || {},
15
+ _ref$label = _ref.label,
16
+ label = _ref$label === void 0 ? 'label' : _ref$label,
17
+ _ref$value = _ref.value,
18
+ value = _ref$value === void 0 ? 'value' : _ref$value,
19
+ _ref$options = _ref.options,
20
+ children = _ref$options === void 0 ? 'options' : _ref$options;
21
+ return options.flatMap(function (option) {
22
+ return _typeof(option) === 'object' && option !== null ? option[children] ? flattenOptions(option[children], fieldNames) : [{
23
+ value: option[value],
24
+ label: option[label]
25
+ }] : [{
26
+ value: option,
27
+ label: option
28
+ }];
29
+ });
30
+ }
31
+
32
+ /** 保留0和空选项标签;有 labelInValue 时优先使用已加载的名称。@author nokecy */
33
+ function selectedLabels(value, options, labelInValue) {
34
+ if (value == null || value === '' || Array.isArray(value) && !value.length) return '—';
35
+ var normalized = labelInValue ? (0, _selectValue.normalizeSelectValue)(value, true) : value;
36
+ var values = Array.isArray(normalized) ? normalized : normalized == null ? [] : [normalized];
37
+ if (!values.length) return '—';
38
+ var labels = values.map(function (item) {
39
+ var _ref2, _selectLabel, _options$find, _item$label;
40
+ var raw = labelInValue ? item.value : item;
41
+ return (_ref2 = (_selectLabel = (0, _selectValue.selectLabel)((_options$find = options.find(function (option) {
42
+ return option.value === raw;
43
+ })) === null || _options$find === void 0 ? void 0 : _options$find.label)) !== null && _selectLabel !== void 0 ? _selectLabel : (0, _selectValue.selectLabel)(labelInValue ? (_item$label = item.label) !== null && _item$label !== void 0 ? _item$label : raw : raw)) !== null && _ref2 !== void 0 ? _ref2 : '—';
44
+ });
45
+ // 选项标签可以是React节点,交由调用组件按顺序渲染。
46
+ return labels.flatMap(function (label, index) {
47
+ return index ? ['、', label] : [label];
48
+ });
49
+ }
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
2
  import './index.less';
3
+ /** 详情、表单共用工具栏:按实际操作元素统一留出间距,宽度不足时换行。@author nokecy */
3
4
  declare const ToolBar: (props: any) => React.JSX.Element;
4
5
  export default ToolBar;
@@ -1,35 +1,69 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.default = void 0;
7
- var _react = _interopRequireDefault(require("react"));
8
+ var _react = _interopRequireWildcard(require("react"));
8
9
  var _antd = require("antd");
9
10
  require("./index.less");
10
- var _excluded = ["children", "className", "extra", "style", "renderContent", "getTargetContainer"];
11
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ var _excluded = ["children", "className", "extra", "identity", "banner", "style", "renderContent", "getTargetContainer"];
12
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
13
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
12
14
  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; }
13
15
  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; }
16
+ /** 详情、表单共用工具栏:按实际操作元素统一留出间距,宽度不足时换行。@author nokecy */
14
17
  var ToolBar = function ToolBar(props) {
15
18
  var children = props.children,
16
19
  className = props.className,
17
20
  extra = props.extra,
21
+ identity = props.identity,
22
+ banner = props.banner,
18
23
  style = props.style,
19
24
  renderContent = props.renderContent,
20
25
  getTargetContainer = props.getTargetContainer,
21
26
  restProps = _objectWithoutProperties(props, _excluded);
27
+ var _theme$useToken = _antd.theme.useToken(),
28
+ token = _theme$useToken.token; // 单据操作栏跟随宿主主题。@author nokecy
29
+ var barRef = (0, _react.useRef)(null);
30
+ // @author nokecy:KeepAlive 内容区独立滚动,吸顶应相对其视口,避免定位到应用顶栏下面。
31
+ var defaultTarget = (0, _react.useCallback)(function () {
32
+ var _barRef$current$paren, _barRef$current;
33
+ var parent = (_barRef$current$paren = (_barRef$current = barRef.current) === null || _barRef$current === void 0 ? void 0 : _barRef$current.parentElement) !== null && _barRef$current$paren !== void 0 ? _barRef$current$paren : null;
34
+ while (parent) {
35
+ if (/auto|scroll/.test(getComputedStyle(parent).overflowY)) return parent;
36
+ parent = parent.parentElement;
37
+ }
38
+ return window;
39
+ }, []);
22
40
  return /*#__PURE__*/_react.default.createElement(_antd.Affix, {
23
41
  offsetTop: 2,
24
42
  style: style,
25
43
  offsetBottom: 2,
26
- target: getTargetContainer
44
+ target: getTargetContainer || defaultTarget
27
45
  }, /*#__PURE__*/_react.default.createElement("div", {
28
- className: "antd-tool-bar"
29
- }, /*#__PURE__*/_react.default.createElement("div", {
30
- className: "antd-tool-bar-left".trim()
31
- }, /*#__PURE__*/_react.default.createElement(_antd.Space, null, extra)), /*#__PURE__*/_react.default.createElement("div", {
32
- className: "antd-tool-bar-right".trim()
33
- }, /*#__PURE__*/_react.default.createElement(_antd.Space, null, children))));
46
+ ref: barRef,
47
+ className: "antd-tool-bar",
48
+ style: {
49
+ backgroundColor: token.colorBgContainer,
50
+ color: token.colorText,
51
+ borderBlockStartColor: token.colorBorderSecondary,
52
+ gap: token.marginXS,
53
+ paddingBlock: token.paddingXXS
54
+ }
55
+ }, banner && /*#__PURE__*/_react.default.createElement("div", {
56
+ className: "antd-tool-bar-banner"
57
+ }, banner), /*#__PURE__*/_react.default.createElement("div", {
58
+ className: "antd-tool-bar-left",
59
+ style: {
60
+ gap: token.marginXS
61
+ }
62
+ }, extra, identity), /*#__PURE__*/_react.default.createElement("div", {
63
+ className: "antd-tool-bar-right",
64
+ style: {
65
+ gap: token.marginXS
66
+ }
67
+ }, children)));
34
68
  };
35
69
  var _default = exports.default = ToolBar;
@@ -1,25 +1,43 @@
1
1
  .antd-tool-bar {
2
2
  display: flex;
3
+ flex-wrap: wrap;
3
4
  align-items: center;
4
5
  box-sizing: border-box;
5
6
  width: 100%;
6
- color: rgba(0, 0, 0, 0.88);
7
7
  line-height: 40px;
8
- background-color: rgba(255, 255, 255);
9
- -webkit-backdrop-filter: blur(8px);
8
+ backdrop-filter: blur(8px);
10
9
  backdrop-filter: blur(8px);
11
10
  transition: all 0.2s ease 0s;
12
11
  inset-inline-end: 0;
13
12
  padding-inline: 16px;
14
13
  padding-block: 0;
15
- border-block-start: 1px solid rgba(5, 5, 5, 0.06);
14
+ // 颜色由组件读取主题 token;子区域继承正文色。
15
+ border-block-start: 1px solid;
16
+ }
17
+
18
+ .antd-tool-bar-banner {
19
+ flex: 1 0 100%;
20
+ min-width: 0;
21
+ line-height: normal;
16
22
  }
17
23
 
18
24
  .antd-tool-bar-left {
19
- flex: 1;
20
- color: rgba(0, 0, 0, 0.88);
25
+ flex: 1 0 auto;
26
+ color: inherit;
27
+ }
28
+
29
+ .antd-tool-bar-right {
30
+ margin-inline-start: auto;
31
+ justify-content: flex-end;
32
+ color: inherit;
21
33
  }
22
34
 
35
+ /* 直接排列组件输出的按钮,React Fragment 内的按钮也获得相同间距。@author nokecy */
36
+ .antd-tool-bar-left,
23
37
  .antd-tool-bar-right {
24
- color: rgba(0, 0, 0, 0.88);
38
+ display: flex;
39
+ flex-wrap: wrap;
40
+ align-items: center;
41
+ min-width: 0;
42
+ max-width: 100%;
25
43
  }
@@ -0,0 +1,11 @@
1
+ import Decimal from 'decimal.js';
2
+ /** 业务值保留十进制文本,运算使用十进制库;整型标识和时间不经过此入口。@author nokecy */
3
+ export declare const BusinessDecimal: typeof Decimal;
4
+ export type DecimalValue = string | number | Decimal | null | undefined;
5
+ export declare const decimal: (value: DecimalValue) => Decimal;
6
+ export declare const decimalText: (value: DecimalValue) => string;
7
+ export declare const nonNegativeDecimal: (value: DecimalValue) => string;
8
+ export declare const roundDecimal: (value: DecimalValue, places: number) => string;
9
+ export declare const sumDecimals: (values: DecimalValue[]) => string;
10
+ /** 指定取位规则显示,千分位直接处理文本,不转换为 JavaScript number。@author nokecy */
11
+ export declare const formatDecimal: (value: DecimalValue, places?: number, minimumPlaces?: number) => string;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.sumDecimals = exports.roundDecimal = exports.nonNegativeDecimal = exports.formatDecimal = exports.decimalText = exports.decimal = exports.BusinessDecimal = void 0;
7
+ var _decimal = _interopRequireDefault(require("decimal.js"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
10
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
11
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
12
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
13
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
14
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
15
+ /** 业务值保留十进制文本,运算使用十进制库;整型标识和时间不经过此入口。@author nokecy */
16
+ var BusinessDecimal = exports.BusinessDecimal = _decimal.default.clone({
17
+ precision: 64,
18
+ rounding: _decimal.default.ROUND_HALF_UP,
19
+ toExpNeg: -64,
20
+ toExpPos: 64
21
+ });
22
+ var decimal = exports.decimal = function decimal(value) {
23
+ return new BusinessDecimal(value == null || value === '' ? '0' : value);
24
+ };
25
+ var decimalText = exports.decimalText = function decimalText(value) {
26
+ return decimal(value).toFixed();
27
+ };
28
+ var nonNegativeDecimal = exports.nonNegativeDecimal = function nonNegativeDecimal(value) {
29
+ return BusinessDecimal.max(0, decimal(value)).toFixed();
30
+ };
31
+ var roundDecimal = exports.roundDecimal = function roundDecimal(value, places) {
32
+ return decimal(value).toDecimalPlaces(places).toFixed();
33
+ };
34
+ var sumDecimals = exports.sumDecimals = function sumDecimals(values) {
35
+ return values.reduce(function (sum, value) {
36
+ return sum.plus(decimal(value));
37
+ }, decimal('0')).toFixed();
38
+ };
39
+
40
+ /** 指定取位规则显示,千分位直接处理文本,不转换为 JavaScript number。@author nokecy */
41
+ var formatDecimal = exports.formatDecimal = function formatDecimal(value) {
42
+ var places = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 6;
43
+ var minimumPlaces = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
44
+ if (value == null || value === '') return '';
45
+ var _decimal$toFixed$spli = decimal(value).toFixed(places).split('.'),
46
+ _decimal$toFixed$spli2 = _slicedToArray(_decimal$toFixed$spli, 2),
47
+ integer = _decimal$toFixed$spli2[0],
48
+ _decimal$toFixed$spli3 = _decimal$toFixed$spli2[1],
49
+ fraction = _decimal$toFixed$spli3 === void 0 ? '' : _decimal$toFixed$spli3;
50
+ while (fraction.length > minimumPlaces && fraction.endsWith('0')) fraction = fraction.slice(0, -1);
51
+ integer = integer.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
52
+ return fraction ? "".concat(integer, ".").concat(fraction) : integer;
53
+ };
@@ -0,0 +1,40 @@
1
+ /**
2
+ * 对比度计算与「够读的主色」派生。
3
+ *
4
+ * 背景:品牌绿 #00b96b 落在白底上只有 2.58:1,而正文文字要 4.5:1、非文本要 3:1(WCAG 2.1)。
5
+ * antd 从它派生的最深一档 colorPrimaryActive 也只有 3.90:1——够非文本,够不到文字。
6
+ * 所以菜单选中态、行内操作按钮这些「用主色写字」的地方,靠 antd 自带档位解决不了。
7
+ *
8
+ * 这里按色相不变、只压明度的方式派生出刚好达标的一档:绿还是那个绿,但读得清。
9
+ * 写成纯函数而不是写死一个色值,是因为四个客户各有各的主色,写死就只对信诚成立。
10
+ *
11
+ * 验收方法沿用登录页复核那套:实测计算,不看源码想当然。
12
+ *
13
+ * @author nokecy
14
+ */
15
+ /** hex -> [r, g, b],每项 0~255。 */
16
+ export declare function toRgb(hex: string): [number, number, number];
17
+ /** WCAG 相对亮度。 */
18
+ export declare function relativeLuminance(hex: string): number;
19
+ /** WCAG 对比度,1 ~ 21。 */
20
+ export declare function contrastRatio(a: string, b: string): number;
21
+ /** hex -> [h(0~360), s(0~1), l(0~1)]。 */
22
+ export declare function toHsl(hex: string): [number, number, number];
23
+ /** [h, s, l] -> hex。 */
24
+ export declare function fromHsl(h: number, s: number, l: number): string;
25
+ /**
26
+ * 压暗到刚好满足对比度要求的一档,色相与饱和度保持不变。
27
+ *
28
+ * @param hex 起始色(通常是品牌主色)
29
+ * @param against 要压在什么底色上,默认白底
30
+ * @param min 目标对比度,正文 4.5、非文本 3
31
+ */
32
+ export declare function darkenUntilContrast(hex: string, { against, min }?: {
33
+ against?: string | undefined;
34
+ min?: number | undefined;
35
+ }): string;
36
+ /** 深色表面上的文字保持色相,提亮至正文对比度。@author nokecy */
37
+ export declare function lightenUntilContrast(hex: string, { against, min }?: {
38
+ against?: string | undefined;
39
+ min?: number | undefined;
40
+ }): string;