@nokecy/qc-ui-components 2.0.0-beta.1 → 2.0.0-beta.3

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.
@@ -9,6 +9,7 @@ var _agGridReact = require("ag-grid-react");
9
9
  var _antd = require("antd");
10
10
  var _react = _interopRequireWildcard(require("react"));
11
11
  var _agGridEnterprise = require("ag-grid-enterprise");
12
+ var _agGridLicenseNotice = require("./utils/agGridLicenseNotice");
12
13
  var _theme = require("./theme");
13
14
  var _density = require("./density");
14
15
  var _rowColors = require("./rowColors");
@@ -78,7 +79,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
78
79
  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); }
79
80
  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; }
80
81
  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; }
81
- // AG-Grid v33+ 需要显式注册模块
82
+ // AG-Grid v33+ 需要显式注册模块;组件库不内置 license key,未授权时的试用提示统一收敛
83
+ (0, _agGridLicenseNotice.installAgGridLicenseNotice)();
82
84
  _agGridCommunity.ModuleRegistry.registerModules([_agGridEnterprise.AllEnterpriseModule]);
83
85
 
84
86
  // 导入 AG-Grid v33 主题
@@ -16,3 +16,4 @@ export type { LocalStorageAdapterConfig } from "./shared/storage/localStorageAda
16
16
  export type { GlobalConfigPermissions } from "./shared/permissions/globalConfigPermissions";
17
17
  export type { EntityExtensionField, EntityExtensionConfig, HostEntityExtensions } from "./types";
18
18
  export { fieldToColumnDef, getEntityExtensionColumns } from "./utils/entityExtensionColumns";
19
+ export { setAgGridLicenseKey } from "./utils/agGridLicenseNotice";
@@ -81,6 +81,12 @@ Object.defineProperty(exports, "getEntityExtensionColumns", {
81
81
  return _entityExtensionColumns.getEntityExtensionColumns;
82
82
  }
83
83
  });
84
+ Object.defineProperty(exports, "setAgGridLicenseKey", {
85
+ enumerable: true,
86
+ get: function get() {
87
+ return _agGridLicenseNotice.setAgGridLicenseKey;
88
+ }
89
+ });
84
90
  Object.defineProperty(exports, "toTree", {
85
91
  enumerable: true,
86
92
  get: function get() {
@@ -114,4 +120,5 @@ var _useSchemeManager = require("./context/useSchemeManager");
114
120
  var _localStorageAdapter = require("./shared/storage/localStorageAdapter");
115
121
  var _backendApiAdapter = require("./shared/storage/backendApiAdapter");
116
122
  var _entityExtensionColumns = require("./utils/entityExtensionColumns");
123
+ var _agGridLicenseNotice = require("./utils/agGridLicenseNotice");
117
124
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -85,6 +85,14 @@
85
85
  text-align: right !important;
86
86
  }
87
87
 
88
+ // AG Grid Enterprise 试用水印:组件库不内置 license key(授权由宿主通过 setAgGridLicenseKey 注入),
89
+ // 未注入时 AG Grid 会在每个表格实例里叠一层 .ag-watermark。AgGridPlus 有 .qc-table-container 外壳,
90
+ // 但 ArrayTable / 只读预览直接渲染 AgGridReact、不带该外壳,按容器限定会漏掉它们。
91
+ // 组件库在模块顶层注册 AllEnterpriseModule,企业模块是全局生效的,因此这里统一关闭所有实例的水印。
92
+ .ag-watermark {
93
+ display: none !important;
94
+ }
95
+
88
96
  // 空态浮层里的「重试」「新建」「清空筛选」要能点:AG-Grid 给 .ag-overlay 设了 pointer-events: none,
89
97
  // 只给加载浮层放开,空态浮层里的按钮因此点不到。只放开可交互元素,空白处仍穿透到表格。@author nokecy
90
98
  .ag-overlay-no-rows-wrapper :is(button, a, input, [role='button']) {
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 安装一次 console.error 过滤:只吞 AG Grid 的 license 星号框,其余错误保持原参数、
3
+ * 原调用对象输出,不改变业务日志。多个组件库副本/重复 import 只包一层。
4
+ */
5
+ export declare function installAgGridLicenseNotice(): void;
6
+ /** 注入正式 AG Grid Enterprise license key;注入后不再静默任何控制台输出。 */
7
+ export declare function setAgGridLicenseKey(licenseKey: string): void;
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.installAgGridLicenseNotice = installAgGridLicenseNotice;
7
+ exports.setAgGridLicenseKey = setAgGridLicenseKey;
8
+ var _agGridEnterprise = require("ag-grid-enterprise");
9
+ /**
10
+ * AG Grid Enterprise 试用提示收敛(组件库内统一处理,宿主不必再各自 patch node_modules)。
11
+ *
12
+ * ag-gridPlus.tsx 在模块顶层注册 AllEnterpriseModule,但组件库不内置 license key——
13
+ * 授权由宿主决定。未注入 key 时,AG Grid 会在每个表格实例创建时打印一整块星号框
14
+ * ("AG Grid Enterprise License / License Key Not Found"),并在表格右下角渲染
15
+ * .ag-watermark(5 秒后淡出)。
16
+ *
17
+ * 这里只在没有正式 key 时静默这块提示,水印由同目录 index.less 关闭。宿主拿到正式
18
+ * 授权后调用 setAgGridLicenseKey(),静默立即停用,AG Grid 恢复常规行为。
19
+ */
20
+
21
+ var STATE_KEY = '__qcUiAgGridLicenseNotice__';
22
+ /** license 星号框同一批输出允许的最长间隔(毫秒):块内分隔行可能异步到达。 */
23
+ var BANNER_WINDOW_MS = 1000;
24
+
25
+ /** 星号框正文行:`**** AG Grid Enterprise License ****` / `* ... trial. *`。 */
26
+ function isLicenseLine(text) {
27
+ return /^\*+.*\*+$/.test(text) && /license|trial|watermark|ag-grid/i.test(text);
28
+ }
29
+
30
+ /** 星号框分隔行(整行都是星号)。 */
31
+ function isBannerLine(text) {
32
+ return /^\*+$/.test(text);
33
+ }
34
+
35
+ /**
36
+ * 安装一次 console.error 过滤:只吞 AG Grid 的 license 星号框,其余错误保持原参数、
37
+ * 原调用对象输出,不改变业务日志。多个组件库副本/重复 import 只包一层。
38
+ */
39
+ function installAgGridLicenseNotice() {
40
+ if (typeof console === 'undefined') return;
41
+ var host = globalThis;
42
+ if (host[STATE_KEY]) return;
43
+ var originalError = console.error;
44
+ var state = {
45
+ originalError: originalError,
46
+ licensed: false
47
+ };
48
+ host[STATE_KEY] = state;
49
+
50
+ // 星号框第一行是纯星号、出现在关键词行之前:先暂存,确认是 license 块后丢弃;
51
+ // 若是别的来源打印的星号行,则在当前同步任务结束前原样补输出。
52
+ var pending = [];
53
+ var flushScheduled = false;
54
+ var lastLicenseAt = 0;
55
+ var flush = function flush() {
56
+ var lines = pending;
57
+ pending = [];
58
+ for (var _i = 0, _lines = lines; _i < _lines.length; _i++) {
59
+ var args = _lines[_i];
60
+ originalError.apply(console, args);
61
+ }
62
+ };
63
+ var scheduleFlush = function scheduleFlush() {
64
+ if (flushScheduled) return;
65
+ flushScheduled = true;
66
+ queueMicrotask(function () {
67
+ flushScheduled = false;
68
+ flush();
69
+ });
70
+ };
71
+ console.error = function () {
72
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
73
+ args[_key] = arguments[_key];
74
+ }
75
+ if (state.licensed) {
76
+ flush();
77
+ originalError.apply(console, args);
78
+ return;
79
+ }
80
+ var text = args.length === 1 && typeof args[0] === 'string' ? args[0].trim() : '';
81
+ if (isLicenseLine(text)) {
82
+ lastLicenseAt = Date.now();
83
+ pending = [];
84
+ return;
85
+ }
86
+ if (isBannerLine(text)) {
87
+ if (Date.now() - lastLicenseAt < BANNER_WINDOW_MS) return;
88
+ pending.push(args);
89
+ scheduleFlush();
90
+ return;
91
+ }
92
+ flush();
93
+ originalError.apply(console, args);
94
+ };
95
+ }
96
+
97
+ /** 注入正式 AG Grid Enterprise license key;注入后不再静默任何控制台输出。 */
98
+ function setAgGridLicenseKey(licenseKey) {
99
+ var key = licenseKey === null || licenseKey === void 0 ? void 0 : licenseKey.trim();
100
+ if (!key) return;
101
+ _agGridEnterprise.LicenseManager.setLicenseKey(key);
102
+ var host = globalThis;
103
+ var state = host[STATE_KEY];
104
+ if (state) state.licensed = true;
105
+ }
@@ -40,6 +40,7 @@ export type { SemanticPreset } from "./ag-grid-plus/utils/valueEnumColor";
40
40
  export { StatusPill, STATUS_PILL } from "./ag-grid-plus/utils/statusPill";
41
41
  export type { StatusKey } from "./ag-grid-plus/utils/statusPill";
42
42
  export { getQcColDefProp } from "./ag-grid-plus/utils/agGridCompat";
43
+ export { setAgGridLicenseKey } from "./ag-grid-plus/index";
43
44
  export { contrastRatio, relativeLuminance, darkenUntilContrast, lightenUntilContrast, toRgb, toHsl, fromHsl } from "./shared/contrast";
44
45
  export { BusinessDecimal, decimal, decimalText, nonNegativeDecimal, roundDecimal, sumDecimals, formatDecimal } from "./shared/businessDecimal";
45
46
  export type { DecimalValue } from "./shared/businessDecimal";
package/dist/cjs/index.js CHANGED
@@ -14,6 +14,7 @@ var _exportNames = {
14
14
  useGridSchemes: true,
15
15
  LocalStorageSchemeAdapter: true,
16
16
  BackendApiSchemeAdapter: true,
17
+ setAgGridLicenseKey: true,
17
18
  ArrayTable: true,
18
19
  ArrayTableIndex: true,
19
20
  ColumnPresets: true,
@@ -429,6 +430,12 @@ Object.defineProperty(exports, "semanticTextColors", {
429
430
  return _valueEnumColor.semanticTextColors;
430
431
  }
431
432
  });
433
+ Object.defineProperty(exports, "setAgGridLicenseKey", {
434
+ enumerable: true,
435
+ get: function get() {
436
+ return _index.setAgGridLicenseKey;
437
+ }
438
+ });
432
439
  Object.defineProperty(exports, "sumDecimals", {
433
440
  enumerable: true,
434
441
  get: function get() {
@@ -23,8 +23,10 @@ import { AgGridReact } from 'ag-grid-react';
23
23
  import { Spin, Pagination, Card, Tag, Popover, Badge, Button, theme } from 'antd';
24
24
  import React, { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
25
25
  import { AllEnterpriseModule } from "ag-grid-enterprise";
26
+ import { installAgGridLicenseNotice } from "./utils/agGridLicenseNotice";
26
27
 
27
- // AG-Grid v33+ 需要显式注册模块
28
+ // AG-Grid v33+ 需要显式注册模块;组件库不内置 license key,未授权时的试用提示统一收敛
29
+ installAgGridLicenseNotice();
28
30
  ModuleRegistry.registerModules([AllEnterpriseModule]);
29
31
 
30
32
  // 导入 AG-Grid v33 主题
@@ -16,3 +16,4 @@ export type { LocalStorageAdapterConfig } from "./shared/storage/localStorageAda
16
16
  export type { GlobalConfigPermissions } from "./shared/permissions/globalConfigPermissions";
17
17
  export type { EntityExtensionField, EntityExtensionConfig, HostEntityExtensions } from "./types";
18
18
  export { fieldToColumnDef, getEntityExtensionColumns } from "./utils/entityExtensionColumns";
19
+ export { setAgGridLicenseKey } from "./utils/agGridLicenseNotice";
@@ -20,5 +20,8 @@ export { BackendApiSchemeAdapter } from "./shared/storage/backendApiAdapter";
20
20
  // 实体扩展列工具函数 @author nokecy
21
21
  export { fieldToColumnDef, getEntityExtensionColumns } from "./utils/entityExtensionColumns";
22
22
 
23
+ // 正式 AG Grid Enterprise 授权入口:宿主注入 key 后组件库不再静默试用提示。
24
+ export { setAgGridLicenseKey } from "./utils/agGridLicenseNotice";
25
+
23
26
  // 注意: 旧的查询方案管理功能已废弃
24
27
  // 相关导出已移除,请使用集中式方案管理 API (useSchemeManager/useGridSchemes)
@@ -85,6 +85,14 @@
85
85
  text-align: right !important;
86
86
  }
87
87
 
88
+ // AG Grid Enterprise 试用水印:组件库不内置 license key(授权由宿主通过 setAgGridLicenseKey 注入),
89
+ // 未注入时 AG Grid 会在每个表格实例里叠一层 .ag-watermark。AgGridPlus 有 .qc-table-container 外壳,
90
+ // 但 ArrayTable / 只读预览直接渲染 AgGridReact、不带该外壳,按容器限定会漏掉它们。
91
+ // 组件库在模块顶层注册 AllEnterpriseModule,企业模块是全局生效的,因此这里统一关闭所有实例的水印。
92
+ .ag-watermark {
93
+ display: none !important;
94
+ }
95
+
88
96
  // 空态浮层里的「重试」「新建」「清空筛选」要能点:AG-Grid 给 .ag-overlay 设了 pointer-events: none,
89
97
  // 只给加载浮层放开,空态浮层里的按钮因此点不到。只放开可交互元素,空白处仍穿透到表格。@author nokecy
90
98
  .ag-overlay-no-rows-wrapper :is(button, a, input, [role='button']) {
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 安装一次 console.error 过滤:只吞 AG Grid 的 license 星号框,其余错误保持原参数、
3
+ * 原调用对象输出,不改变业务日志。多个组件库副本/重复 import 只包一层。
4
+ */
5
+ export declare function installAgGridLicenseNotice(): void;
6
+ /** 注入正式 AG Grid Enterprise license key;注入后不再静默任何控制台输出。 */
7
+ export declare function setAgGridLicenseKey(licenseKey: string): void;
@@ -0,0 +1,97 @@
1
+ /**
2
+ * AG Grid Enterprise 试用提示收敛(组件库内统一处理,宿主不必再各自 patch node_modules)。
3
+ *
4
+ * ag-gridPlus.tsx 在模块顶层注册 AllEnterpriseModule,但组件库不内置 license key——
5
+ * 授权由宿主决定。未注入 key 时,AG Grid 会在每个表格实例创建时打印一整块星号框
6
+ * ("AG Grid Enterprise License / License Key Not Found"),并在表格右下角渲染
7
+ * .ag-watermark(5 秒后淡出)。
8
+ *
9
+ * 这里只在没有正式 key 时静默这块提示,水印由同目录 index.less 关闭。宿主拿到正式
10
+ * 授权后调用 setAgGridLicenseKey(),静默立即停用,AG Grid 恢复常规行为。
11
+ */
12
+ import { LicenseManager } from 'ag-grid-enterprise';
13
+ var STATE_KEY = '__qcUiAgGridLicenseNotice__';
14
+ /** license 星号框同一批输出允许的最长间隔(毫秒):块内分隔行可能异步到达。 */
15
+ var BANNER_WINDOW_MS = 1000;
16
+
17
+ /** 星号框正文行:`**** AG Grid Enterprise License ****` / `* ... trial. *`。 */
18
+ function isLicenseLine(text) {
19
+ return /^\*+.*\*+$/.test(text) && /license|trial|watermark|ag-grid/i.test(text);
20
+ }
21
+
22
+ /** 星号框分隔行(整行都是星号)。 */
23
+ function isBannerLine(text) {
24
+ return /^\*+$/.test(text);
25
+ }
26
+
27
+ /**
28
+ * 安装一次 console.error 过滤:只吞 AG Grid 的 license 星号框,其余错误保持原参数、
29
+ * 原调用对象输出,不改变业务日志。多个组件库副本/重复 import 只包一层。
30
+ */
31
+ export function installAgGridLicenseNotice() {
32
+ if (typeof console === 'undefined') return;
33
+ var host = globalThis;
34
+ if (host[STATE_KEY]) return;
35
+ var originalError = console.error;
36
+ var state = {
37
+ originalError: originalError,
38
+ licensed: false
39
+ };
40
+ host[STATE_KEY] = state;
41
+
42
+ // 星号框第一行是纯星号、出现在关键词行之前:先暂存,确认是 license 块后丢弃;
43
+ // 若是别的来源打印的星号行,则在当前同步任务结束前原样补输出。
44
+ var pending = [];
45
+ var flushScheduled = false;
46
+ var lastLicenseAt = 0;
47
+ var flush = function flush() {
48
+ var lines = pending;
49
+ pending = [];
50
+ for (var _i = 0, _lines = lines; _i < _lines.length; _i++) {
51
+ var args = _lines[_i];
52
+ originalError.apply(console, args);
53
+ }
54
+ };
55
+ var scheduleFlush = function scheduleFlush() {
56
+ if (flushScheduled) return;
57
+ flushScheduled = true;
58
+ queueMicrotask(function () {
59
+ flushScheduled = false;
60
+ flush();
61
+ });
62
+ };
63
+ console.error = function () {
64
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
65
+ args[_key] = arguments[_key];
66
+ }
67
+ if (state.licensed) {
68
+ flush();
69
+ originalError.apply(console, args);
70
+ return;
71
+ }
72
+ var text = args.length === 1 && typeof args[0] === 'string' ? args[0].trim() : '';
73
+ if (isLicenseLine(text)) {
74
+ lastLicenseAt = Date.now();
75
+ pending = [];
76
+ return;
77
+ }
78
+ if (isBannerLine(text)) {
79
+ if (Date.now() - lastLicenseAt < BANNER_WINDOW_MS) return;
80
+ pending.push(args);
81
+ scheduleFlush();
82
+ return;
83
+ }
84
+ flush();
85
+ originalError.apply(console, args);
86
+ };
87
+ }
88
+
89
+ /** 注入正式 AG Grid Enterprise license key;注入后不再静默任何控制台输出。 */
90
+ export function setAgGridLicenseKey(licenseKey) {
91
+ var key = licenseKey === null || licenseKey === void 0 ? void 0 : licenseKey.trim();
92
+ if (!key) return;
93
+ LicenseManager.setLicenseKey(key);
94
+ var host = globalThis;
95
+ var state = host[STATE_KEY];
96
+ if (state) state.licensed = true;
97
+ }
@@ -40,6 +40,7 @@ export type { SemanticPreset } from "./ag-grid-plus/utils/valueEnumColor";
40
40
  export { StatusPill, STATUS_PILL } from "./ag-grid-plus/utils/statusPill";
41
41
  export type { StatusKey } from "./ag-grid-plus/utils/statusPill";
42
42
  export { getQcColDefProp } from "./ag-grid-plus/utils/agGridCompat";
43
+ export { setAgGridLicenseKey } from "./ag-grid-plus/index";
43
44
  export { contrastRatio, relativeLuminance, darkenUntilContrast, lightenUntilContrast, toRgb, toHsl, fromHsl } from "./shared/contrast";
44
45
  export { BusinessDecimal, decimal, decimalText, nonNegativeDecimal, roundDecimal, sumDecimals, formatDecimal } from "./shared/businessDecimal";
45
46
  export type { DecimalValue } from "./shared/businessDecimal";
package/dist/esm/index.js CHANGED
@@ -36,6 +36,7 @@ export * from "./documentPage/index";
36
36
  export { semanticTextColors, toGridTextColor, gridValueEnum } from "./ag-grid-plus/utils/valueEnumColor";
37
37
  export { StatusPill, STATUS_PILL } from "./ag-grid-plus/utils/statusPill";
38
38
  export { getQcColDefProp } from "./ag-grid-plus/utils/agGridCompat";
39
+ export { setAgGridLicenseKey } from "./ag-grid-plus/index";
39
40
  export { contrastRatio, relativeLuminance, darkenUntilContrast, lightenUntilContrast, toRgb, toHsl, fromHsl } from "./shared/contrast";
40
41
  export { BusinessDecimal, decimal, decimalText, nonNegativeDecimal, roundDecimal, sumDecimals, formatDecimal } from "./shared/businessDecimal";
41
42
  export * from "./formily/index";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nokecy/qc-ui-components",
3
- "version": "2.0.0-beta.1",
3
+ "version": "2.0.0-beta.3",
4
4
  "description": "QC_UI backend-neutral React components",
5
5
  "license": "MIT",
6
6
  "private": false,