@canyonjs/report-component 1.0.20 → 1.0.22

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/dist/index.css CHANGED
@@ -1,9 +1,7 @@
1
1
  .canyonjs-report-html .canyon-coverage-detail-spin-wrapper {
2
2
  height: 100%;
3
3
  }
4
- .canyonjs-report-html
5
- .canyon-coverage-detail-spin-wrapper
6
- > .ant-spin-container {
4
+ .canyonjs-report-html .canyon-coverage-detail-spin-wrapper > .ant-spin-container {
7
5
  height: 100%;
8
6
  }
9
7
  .canyonjs-report-html {
@@ -118,8 +116,7 @@
118
116
  border-bottom: 1px solid #e0e0e0;
119
117
  color: #333333;
120
118
  font-size: 13px;
121
- font-family:
122
- -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
119
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
123
120
  cursor: pointer;
124
121
  text-align: left;
125
122
  display: flex;
@@ -158,36 +155,29 @@
158
155
  opacity: 0;
159
156
  }
160
157
 
161
- .canyonjs-report-html
162
- .canyon-changed-code-coverage-content[style*="max-height: auto"] {
158
+ .canyonjs-report-html .canyon-changed-code-coverage-content[style*="max-height: auto"] {
163
159
  opacity: 1;
164
160
  }
165
161
 
166
162
  .canyonjs-report-html .canyon-changed-code-coverage-select-wrapper {
167
163
  padding: 12px 16px;
168
164
  background: #ffffff;
169
- font-family:
170
- -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
165
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
171
166
  display: flex;
172
167
  justify-content: flex-start;
173
168
  }
174
169
 
175
170
  /* 下拉选项样式优化 */
176
- .canyonjs-report-html .canyon-changed-code-coverage-select-wrapper
177
- .ant-select-item {
171
+ .canyonjs-report-html .canyon-changed-code-coverage-select-wrapper .ant-select-item {
178
172
  padding: 6px 12px !important;
179
173
  line-height: 20px !important;
180
174
  }
181
175
 
182
- .canyonjs-report-html
183
- .canyon-changed-code-coverage-select-wrapper
184
- .ant-select-item-option-active {
176
+ .canyonjs-report-html .canyon-changed-code-coverage-select-wrapper .ant-select-item-option-active {
185
177
  background-color: #f5f5f5;
186
178
  }
187
179
 
188
- .canyonjs-report-html
189
- .canyon-changed-code-coverage-select-wrapper
190
- .ant-select-item-option-content {
180
+ .canyonjs-report-html .canyon-changed-code-coverage-select-wrapper .ant-select-item-option-content {
191
181
  display: flex;
192
182
  align-items: center;
193
183
  }
package/dist/index.d.ts CHANGED
@@ -15,6 +15,8 @@ interface FileDataResponse {
15
15
  }
16
16
  interface DataSourceItem {
17
17
  path: string;
18
+ /** 该文件相对基准是否有变更(用于 Only Changed 筛选) */
19
+ change?: boolean;
18
20
  [key: string]: unknown;
19
21
  }
20
22
  interface CanyonReportProps {
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { ConfigProvider, Divider, Input, Progress, Segmented, Select, Space, Spin, Switch, Table, Tag, Typography, theme } from "antd";
1
+ import { ConfigProvider, Divider, Input, Progress, Segmented, Select, Space, Spin, Switch, Table, Tag, Typography } from "antd";
2
2
  import { Suspense, useEffect, useMemo, useRef, useState } from "react";
3
3
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
4
  import { genSummaryTreeItem } from "canyon-data";
@@ -395,8 +395,7 @@ const ChangedCodeCoverageTable = ({ coverage, addLines, onJumpToRange }) => {
395
395
  coverageStats.coveredCount,
396
396
  "/",
397
397
  coverageStats.totalCount,
398
- ") -",
399
- " ",
398
+ ") - ",
400
399
  coverageStats.notCoveredCount,
401
400
  " Not Covered"
402
401
  ] }),
@@ -761,9 +760,14 @@ const getColor = (pct) => {
761
760
  //#endregion
762
761
  //#region src/widgets/SummaryHeader.tsx
763
762
  const { Text } = Typography;
764
- const { useToken } = theme;
763
+ const SUMMARY_LABELS = {
764
+ statements: "Statements",
765
+ branches: "Branches",
766
+ functions: "Functions",
767
+ lines: "Lines",
768
+ changestatements: "Change Statements"
769
+ };
765
770
  const SummaryNav = ({ value, onClick, reportName }) => {
766
- const { token } = useToken();
767
771
  return /* @__PURE__ */ jsx("div", {
768
772
  style: {
769
773
  display: "flex",
@@ -833,7 +837,7 @@ const SummaryMetric = ({ data, onlyChange }) => {
833
837
  /* @__PURE__ */ jsxs(Text, {
834
838
  style: { fontSize: "14px" },
835
839
  type: "secondary",
836
- children: [t$1(`${key}`), ":"]
840
+ children: [t$1(SUMMARY_LABELS[key] || key), ":"]
837
841
  }),
838
842
  /* @__PURE__ */ jsxs(Tag, {
839
843
  bordered: false,
@@ -1127,7 +1131,7 @@ function PhTreeViewIcon(props) {
1127
1131
 
1128
1132
  //#endregion
1129
1133
  //#region src/widgets/TopControl.tsx
1130
- const TopControl = ({ total, showMode, onChangeShowMode, onChangeKeywords, filenameKeywords, onChangeOnlyChange, onlyChange }) => {
1134
+ const TopControl = ({ total, showMode, onChangeShowMode, onChangeKeywords, filenameKeywords, onChangeOnlyChange, onlyChange, showOnlyChangeSwitch = true }) => {
1131
1135
  return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsxs("div", {
1132
1136
  style: {
1133
1137
  display: "flex",
@@ -1173,38 +1177,34 @@ const TopControl = ({ total, showMode, onChangeShowMode, onChangeKeywords, filen
1173
1177
  display: "flex",
1174
1178
  alignItems: "center"
1175
1179
  },
1176
- children: [
1177
- /* @__PURE__ */ jsxs("div", {
1178
- style: {
1179
- display: "flex",
1180
- alignItems: "center",
1181
- gap: "6px"
1182
- },
1183
- children: [/* @__PURE__ */ jsxs(Typography.Text, {
1184
- type: "secondary",
1185
- style: { fontSize: "12px" },
1186
- children: [
1187
- "Only Changed",
1188
- ":",
1189
- " "
1190
- ]
1191
- }), /* @__PURE__ */ jsx(Switch, {
1192
- checked: onlyChange,
1193
- size: "small",
1194
- onChange: onChangeOnlyChange
1195
- })]
1196
- }),
1197
- /* @__PURE__ */ jsx(Divider, { type: "vertical" }),
1198
- /* @__PURE__ */ jsx(Input, {
1199
- placeholder: "Enter the file path to search",
1200
- value: filenameKeywords,
1201
- style: { width: "240px" },
1180
+ children: [showOnlyChangeSwitch && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
1181
+ style: {
1182
+ display: "flex",
1183
+ alignItems: "center",
1184
+ gap: "6px"
1185
+ },
1186
+ children: [/* @__PURE__ */ jsxs(Typography.Text, {
1187
+ type: "secondary",
1188
+ style: { fontSize: "12px" },
1189
+ children: [
1190
+ "Only Changed",
1191
+ ":",
1192
+ " "
1193
+ ]
1194
+ }), /* @__PURE__ */ jsx(Switch, {
1195
+ checked: onlyChange,
1202
1196
  size: "small",
1203
- onChange: (val) => {
1204
- onChangeKeywords(val.target.value);
1205
- }
1206
- })
1207
- ]
1197
+ onChange: onChangeOnlyChange
1198
+ })]
1199
+ }), /* @__PURE__ */ jsx(Divider, { type: "vertical" })] }), /* @__PURE__ */ jsx(Input, {
1200
+ placeholder: "Enter the file path to search",
1201
+ value: filenameKeywords,
1202
+ style: { width: "240px" },
1203
+ size: "small",
1204
+ onChange: (val) => {
1205
+ onChangeKeywords(val.target.value);
1206
+ }
1207
+ })]
1208
1208
  })]
1209
1209
  }), /* @__PURE__ */ jsx(Divider, { style: {
1210
1210
  margin: "0",
@@ -1236,6 +1236,17 @@ const CanyonReport = ({ value, name, dataSource, onSelect, defaultOnlyChange = f
1236
1236
  const isControlled = controlledOnlyChange !== void 0 && controlledOnChangeOnlyChange !== void 0;
1237
1237
  const [internalOnlyChange, setInternalOnlyChange] = useState(defaultOnlyChange);
1238
1238
  const onlyChange = isControlled ? controlledOnlyChange : internalOnlyChange;
1239
+ const hasAnyFileChange = useMemo(() => dataSource.some((item) => item["change"] === true), [dataSource]);
1240
+ useEffect(() => {
1241
+ if (!hasAnyFileChange) if (isControlled && controlledOnChangeOnlyChange) {
1242
+ if (controlledOnlyChange) controlledOnChangeOnlyChange(false);
1243
+ } else setInternalOnlyChange(false);
1244
+ }, [
1245
+ hasAnyFileChange,
1246
+ isControlled,
1247
+ controlledOnChangeOnlyChange,
1248
+ controlledOnlyChange
1249
+ ]);
1239
1250
  const rootClassName = useMemo(() => `report-scope-${Math.random().toString(36).slice(2, 9)} canyonjs-report-html`, []);
1240
1251
  function onChangeOnlyChange(v) {
1241
1252
  if (isControlled && controlledOnChangeOnlyChange) controlledOnChangeOnlyChange(v);
@@ -1295,6 +1306,7 @@ const CanyonReport = ({ value, name, dataSource, onSelect, defaultOnlyChange = f
1295
1306
  ` }),
1296
1307
  /* @__PURE__ */ jsx(TopControl_default, {
1297
1308
  onlyChange,
1309
+ showOnlyChangeSwitch: hasAnyFileChange,
1298
1310
  filenameKeywords,
1299
1311
  showMode,
1300
1312
  onChangeShowMode: (val) => {
package/package.json CHANGED
@@ -1,50 +1,50 @@
1
1
  {
2
2
  "name": "@canyonjs/report-component",
3
- "type": "module",
4
- "version": "1.0.20",
3
+ "version": "1.0.22",
4
+ "homepage": "https://github.com/canyon-project/canyon#readme",
5
+ "bugs": {
6
+ "url": "https://github.com/canyon-project/canyon/issues"
7
+ },
8
+ "license": "MIT",
5
9
  "author": "Travis Zhang<https://github.com/travzhang>",
6
10
  "repository": {
7
11
  "type": "git",
8
12
  "url": "https://github.com/canyon-project/canyon"
9
13
  },
10
- "bugs": {
11
- "url": "https://github.com/canyon-project/canyon/issues"
12
- },
13
- "homepage": "https://github.com/canyon-project/canyon#readme",
14
- "license": "MIT",
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "type": "module",
18
+ "main": "./dist/index.js",
19
+ "module": "./dist/index.js",
20
+ "types": "./dist/index.d.ts",
15
21
  "exports": {
16
22
  ".": "./dist/index.js",
17
23
  "./package.json": "./package.json",
18
24
  "./index.css": "./dist/index.css"
19
25
  },
20
- "main": "./dist/index.js",
21
- "module": "./dist/index.js",
22
- "types": "./dist/index.d.ts",
23
- "files": [
24
- "dist"
25
- ],
26
+ "dependencies": {
27
+ "@ant-design/icons": "6.1.0",
28
+ "@ibm/plex-mono": "1.1.0",
29
+ "antd": "6.1.0",
30
+ "canyon-data": "2.0.0-beta.36",
31
+ "monaco-editor": "0.55.1",
32
+ "react": "19.2.3",
33
+ "react-dom": "19.2.3",
34
+ "react-highlight-words": "0.21.0"
35
+ },
26
36
  "devDependencies": {
37
+ "@monaco-editor/react": "4.7.0",
27
38
  "@tsconfig/strictest": "^2.0.8",
28
39
  "@types/istanbul-lib-coverage": "^2.0.6",
29
40
  "@types/node": "^24.10.1",
30
41
  "@types/react": "19.2.3",
31
42
  "@types/react-dom": "19.2.3",
43
+ "@typescript/native-preview": "7.0.0-dev.20260408.1",
32
44
  "@vitejs/plugin-react": "^5.1.1",
33
45
  "istanbul-lib-coverage": "^3.2.2",
34
46
  "tsdown": "^0.17.0",
35
- "@typescript/native-preview": "7.0.0-dev.20260204.1",
36
- "vite": "8.0.0-beta.13",
37
- "@monaco-editor/react": "4.7.0"
38
- },
39
- "dependencies": {
40
- "react": "19.2.3",
41
- "react-dom": "19.2.3",
42
- "@ant-design/icons": "6.1.0",
43
- "@ibm/plex-mono": "1.1.0",
44
- "antd": "6.1.0",
45
- "canyon-data": "2.0.0-beta.36",
46
- "monaco-editor": "0.55.1",
47
- "react-highlight-words": "0.21.0"
47
+ "vite": "8.0.7"
48
48
  },
49
49
  "scripts": {
50
50
  "build": "tsdown",