cm-reporting 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,75 @@
1
+ # PolyForm Noncommercial License 1.0.0
2
+
3
+ <https://polyformproject.org/licenses/noncommercial/1.0.0>
4
+
5
+ Required Notice: Copyright (c) 2026 CM contributors
6
+
7
+ ## Acceptance
8
+
9
+ In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses.
10
+
11
+ ## Copyright License
12
+
13
+ The licensor grants you a copyright license for the software to do everything you might do with the software that would otherwise infringe the licensor's copyright in it for any permitted purpose. However, you may only distribute the software according to [Distribution License](#distribution-license) and make changes or new works based on the software according to [Changes and New Works License](#changes-and-new-works-license).
14
+
15
+ ## Distribution License
16
+
17
+ The licensor grants you an additional copyright license to distribute copies of the software. Your license to distribute covers distributing the software with changes and new works permitted by [Changes and New Works License](#changes-and-new-works-license).
18
+
19
+ ## Notices
20
+
21
+ You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms or the URL for them above, as well as copies of any plain-text lines beginning with `Required Notice:` that the licensor provided with the software. For example:
22
+
23
+ > Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
24
+
25
+ ## Changes and New Works License
26
+
27
+ The licensor grants you an additional copyright license to make changes and new works based on the software for any permitted purpose.
28
+
29
+ ## Patent License
30
+
31
+ The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software.
32
+
33
+ ## Noncommercial Purposes
34
+
35
+ Any noncommercial purpose is a permitted purpose.
36
+
37
+ ## Personal Uses
38
+
39
+ Personal use for research, experiment, and testing for the benefit of public knowledge, personal study, private entertainment, hobby projects, amateur pursuits, or religious observance, without any anticipated commercial application, is use for a permitted purpose.
40
+
41
+ ## Noncommercial Organizations
42
+
43
+ Use by any charitable organization, educational institution, public research organization, public safety or health organization, environmental protection organization, or government institution is use for a permitted purpose regardless of the source of funding or obligations resulting from the funding.
44
+
45
+ ## Fair Use
46
+
47
+ You may have "fair use" rights for the software under the law. These terms do not limit them.
48
+
49
+ ## No Other Rights
50
+
51
+ These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else. These terms do not imply any other licenses.
52
+
53
+ ## Patent Defense
54
+
55
+ If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
56
+
57
+ ## Violations
58
+
59
+ The first time you are notified in writing that you have violated any of these terms, or done anything with the software not covered by your licenses, your licenses can nonetheless continue if you come into full compliance with these terms, and take practical steps to correct past violations, within 32 days of receiving notice. Otherwise, all your licenses end immediately.
60
+
61
+ ## No Liability
62
+
63
+ ***As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.***
64
+
65
+ ## Definitions
66
+
67
+ The **licensor** is the individual or entity offering these terms, and the **software** is the software the licensor makes available under these terms.
68
+
69
+ **You** refers to the individual or entity agreeing to these terms.
70
+
71
+ **Your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. **Control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
72
+
73
+ **Your licenses** are all the licenses granted to you for the software under these terms.
74
+
75
+ **Use** means anything you do with the software requiring one of your licenses.
package/README.md ADDED
@@ -0,0 +1,110 @@
1
+ # cm-reporting
2
+
3
+ 基于 React + Ant Design 的冲突矿产报告(RMI 模板)开箱即用嵌入式应用组件库,支持 CMRT / EMRT / CRT / AMRT 的全版本覆盖。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ npm install cm-reporting
9
+ # 或
10
+ pnpm add cm-reporting
11
+ ```
12
+
13
+ ## 使用(开箱即用)
14
+
15
+ ```tsx
16
+ import { CMReporting } from 'cm-reporting'
17
+ import 'cm-reporting/styles.css'
18
+
19
+ export function App() {
20
+ return (
21
+ <CMReporting
22
+ templateType="cmrt"
23
+ versionId="6.5"
24
+ locale="zh-CN"
25
+ onSnapshotChange={(snapshot) => {
26
+ // 全量 JSON:建议宿主自行节流 + 落库/上报
27
+ console.log(snapshot)
28
+ }}
29
+ />
30
+ )
31
+ }
32
+ ```
33
+
34
+ ## JSON(全量快照)
35
+
36
+ - 数据契约:`ReportSnapshotV1`(含 `schemaVersion/templateType/versionId/data`)
37
+ - 工具:`parseSnapshot()` / `stringifySnapshot()`
38
+
39
+ 组件 ref 方式(推荐用于“导出/保存/回填”):
40
+
41
+ ```tsx
42
+ import { CMReporting, type CMReportingRef } from 'cm-reporting'
43
+ import { useRef } from 'react'
44
+
45
+ export function App() {
46
+ const ref = useRef<CMReportingRef>(null)
47
+
48
+ return (
49
+ <>
50
+ <button onClick={() => console.log(ref.current?.getSnapshot())}>Export JSON</button>
51
+ <CMReporting ref={ref} templateType="cmrt" versionId="6.5" locale="en-US" />
52
+ </>
53
+ )
54
+ }
55
+ ```
56
+
57
+ ## Excel(基于模板赋值导出)
58
+
59
+ 严格要求:打开 Excel 后视觉/校验(DV)/公式行为一致,因此导出采用“基于原始 RMI 模板最小差异赋值后导出”的策略。
60
+
61
+ 对外 API:
62
+
63
+ - `exportToExcel({ templateXlsx, snapshot })`
64
+ - `ref.exportExcel({ templateXlsx })`
65
+
66
+ 示例(浏览器下载):
67
+
68
+ ```tsx
69
+ import { CMReporting, type CMReportingRef } from 'cm-reporting'
70
+ import { useRef } from 'react'
71
+
72
+ async function downloadBlob(blob: Blob, filename: string) {
73
+ const url = URL.createObjectURL(blob)
74
+ const a = document.createElement('a')
75
+ a.href = url
76
+ a.download = filename
77
+ a.click()
78
+ URL.revokeObjectURL(url)
79
+ }
80
+
81
+ export function App() {
82
+ const ref = useRef<CMReportingRef>(null)
83
+
84
+ const onExportExcel = async () => {
85
+ // 模板来源由宿主决定:可从你们的静态资源/CDN,或从包导出的 templates 复制到你的 public。
86
+ const res = await fetch('/templates/RMI_CMRT_6.5.xlsx')
87
+ const templateXlsx = await res.arrayBuffer()
88
+ const blob = await ref.current!.exportExcel({ templateXlsx })
89
+ await downloadBlob(blob, 'cmrt-6.5.xlsx')
90
+ }
91
+
92
+ return (
93
+ <>
94
+ <button onClick={onExportExcel}>Export Excel</button>
95
+ <CMReporting ref={ref} templateType="cmrt" versionId="6.5" locale="en-US" />
96
+ </>
97
+ )
98
+ }
99
+ ```
100
+
101
+ ## 模板文件
102
+
103
+ 包内导出静态模板文件:`cm-reporting/templates/*`(用于宿主自持有/下载/二次分发)。
104
+
105
+ ## License
106
+
107
+ PolyForm-Noncommercial-1.0.0
108
+
109
+ - 禁止商业用途(Noncommercial only)。
110
+ - 如需商业使用,请联系版权所有者获取单独商业授权。