@canyonjs/report-component 1.0.21 → 1.0.25

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.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
@@ -1131,7 +1131,7 @@ function PhTreeViewIcon(props) {
1131
1131
 
1132
1132
  //#endregion
1133
1133
  //#region src/widgets/TopControl.tsx
1134
- const TopControl = ({ total, showMode, onChangeShowMode, onChangeKeywords, filenameKeywords, onChangeOnlyChange, onlyChange }) => {
1134
+ const TopControl = ({ total, showMode, onChangeShowMode, onChangeKeywords, filenameKeywords, onChangeOnlyChange, onlyChange, showOnlyChangeSwitch = true }) => {
1135
1135
  return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsxs("div", {
1136
1136
  style: {
1137
1137
  display: "flex",
@@ -1177,38 +1177,34 @@ const TopControl = ({ total, showMode, onChangeShowMode, onChangeKeywords, filen
1177
1177
  display: "flex",
1178
1178
  alignItems: "center"
1179
1179
  },
1180
- children: [
1181
- /* @__PURE__ */ jsxs("div", {
1182
- style: {
1183
- display: "flex",
1184
- alignItems: "center",
1185
- gap: "6px"
1186
- },
1187
- children: [/* @__PURE__ */ jsxs(Typography.Text, {
1188
- type: "secondary",
1189
- style: { fontSize: "12px" },
1190
- children: [
1191
- "Only Changed",
1192
- ":",
1193
- " "
1194
- ]
1195
- }), /* @__PURE__ */ jsx(Switch, {
1196
- checked: onlyChange,
1197
- size: "small",
1198
- onChange: onChangeOnlyChange
1199
- })]
1200
- }),
1201
- /* @__PURE__ */ jsx(Divider, { type: "vertical" }),
1202
- /* @__PURE__ */ jsx(Input, {
1203
- placeholder: "Enter the file path to search",
1204
- value: filenameKeywords,
1205
- 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,
1206
1196
  size: "small",
1207
- onChange: (val) => {
1208
- onChangeKeywords(val.target.value);
1209
- }
1210
- })
1211
- ]
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
+ })]
1212
1208
  })]
1213
1209
  }), /* @__PURE__ */ jsx(Divider, { style: {
1214
1210
  margin: "0",
@@ -1240,6 +1236,17 @@ const CanyonReport = ({ value, name, dataSource, onSelect, defaultOnlyChange = f
1240
1236
  const isControlled = controlledOnlyChange !== void 0 && controlledOnChangeOnlyChange !== void 0;
1241
1237
  const [internalOnlyChange, setInternalOnlyChange] = useState(defaultOnlyChange);
1242
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
+ ]);
1243
1250
  const rootClassName = useMemo(() => `report-scope-${Math.random().toString(36).slice(2, 9)} canyonjs-report-html`, []);
1244
1251
  function onChangeOnlyChange(v) {
1245
1252
  if (isControlled && controlledOnChangeOnlyChange) controlledOnChangeOnlyChange(v);
@@ -1299,6 +1306,7 @@ const CanyonReport = ({ value, name, dataSource, onSelect, defaultOnlyChange = f
1299
1306
  ` }),
1300
1307
  /* @__PURE__ */ jsx(TopControl_default, {
1301
1308
  onlyChange,
1309
+ showOnlyChangeSwitch: hasAnyFileChange,
1302
1310
  filenameKeywords,
1303
1311
  showMode,
1304
1312
  onChangeShowMode: (val) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canyonjs/report-component",
3
- "version": "1.0.21",
3
+ "version": "1.0.25",
4
4
  "homepage": "https://github.com/canyon-project/canyon#readme",
5
5
  "bugs": {
6
6
  "url": "https://github.com/canyon-project/canyon/issues"
@@ -40,11 +40,11 @@
40
40
  "@types/node": "^24.10.1",
41
41
  "@types/react": "19.2.3",
42
42
  "@types/react-dom": "19.2.3",
43
- "@typescript/native-preview": "7.0.0-dev.20260223.1",
43
+ "@typescript/native-preview": "7.0.0-dev.20260408.1",
44
44
  "@vitejs/plugin-react": "^5.1.1",
45
45
  "istanbul-lib-coverage": "^3.2.2",
46
46
  "tsdown": "^0.17.0",
47
- "vite": "8.0.0"
47
+ "vite": "8.0.7"
48
48
  },
49
49
  "scripts": {
50
50
  "build": "tsdown",