@industry-theme/repository-composition-panels 0.2.18 → 0.2.20

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.
@@ -1 +1 @@
1
- {"version":3,"file":"GitChangesPanel.d.ts","sourceRoot":"","sources":["../../src/panels/GitChangesPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4D,MAAM,OAAO,CAAC;AAIjF,OAAO,EAAwB,KAAK,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAE3F,OAAO,KAAK,EAAE,SAAS,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACzF,OAAO,uBAAuB,CAAC;AAU/B,MAAM,MAAM,iBAAiB,GACzB;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACtC;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC1C;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzC,MAAM,WAAW,oBAAoB;IACnC,kDAAkD;IAClD,SAAS,EAAE,SAAS,CAAC;IACrB,mDAAmD;IACnD,QAAQ,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC3B,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8CAA8C;IAC9C,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,sCAAsC;IACtC,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,wBAAwB,KAAK,IAAI,CAAC;IAC5E,uDAAuD;IACvD,mBAAmB,CAAC,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC1D,mDAAmD;IACnD,YAAY,CAAC,E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;IACpB,sCAAsC;IACtC,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,wBAAwB,KAAK,IAAI,CAAC;IAC5E,uDAAuD;IACvD,mBAAmB,CAAC,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC1D,mDAAmD;IACnD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uCAAuC;IACvC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mCAAmC;IACnC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAwXjE,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAiD1C,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAmDzD,CAAC"}
@@ -8332,6 +8332,62 @@ class U {
8332
8332
  for (let [j, k] of this.files.entries()) if (!j.endsWith("/.dir")) console.log(` ${j}: ${k.length} bytes`);
8333
8333
  }
8334
8334
  }
8335
+ const EMPTY_GIT_STATUS = {
8336
+ staged: [],
8337
+ unstaged: [],
8338
+ untracked: [],
8339
+ deleted: []
8340
+ };
8341
+ const ToggleButtons = React2.memo(({ showFullTree, onShowFullTree, onShowChanges, theme }) => /* @__PURE__ */ jsxs(
8342
+ "div",
8343
+ {
8344
+ style: {
8345
+ display: "flex",
8346
+ alignItems: "stretch",
8347
+ backgroundColor: theme.colors.backgroundTertiary,
8348
+ width: "100%",
8349
+ height: "100%"
8350
+ },
8351
+ children: [
8352
+ /* @__PURE__ */ jsx(
8353
+ "button",
8354
+ {
8355
+ onClick: onShowFullTree,
8356
+ style: {
8357
+ flex: 1,
8358
+ padding: "6px 12px",
8359
+ fontSize: theme.fontSizes[1],
8360
+ backgroundColor: showFullTree ? theme.colors.backgroundSecondary : "transparent",
8361
+ color: showFullTree ? theme.colors.text : theme.colors.textSecondary,
8362
+ border: "none",
8363
+ cursor: "pointer",
8364
+ fontWeight: showFullTree ? 600 : 400,
8365
+ transition: "all 0.2s"
8366
+ },
8367
+ children: "Full Tree"
8368
+ }
8369
+ ),
8370
+ /* @__PURE__ */ jsx(
8371
+ "button",
8372
+ {
8373
+ onClick: onShowChanges,
8374
+ style: {
8375
+ flex: 1,
8376
+ padding: "6px 12px",
8377
+ fontSize: theme.fontSizes[1],
8378
+ backgroundColor: !showFullTree ? theme.colors.backgroundSecondary : "transparent",
8379
+ color: !showFullTree ? theme.colors.text : theme.colors.textSecondary,
8380
+ border: "none",
8381
+ cursor: "pointer",
8382
+ fontWeight: !showFullTree ? 600 : 400,
8383
+ transition: "all 0.2s"
8384
+ },
8385
+ children: "Changes"
8386
+ }
8387
+ )
8388
+ ]
8389
+ }
8390
+ ));
8335
8391
  const GitChangesPanelContent = ({
8336
8392
  gitStatus,
8337
8393
  fileTree,
@@ -8363,17 +8419,19 @@ const GitChangesPanelContent = ({
8363
8419
  return () => document.removeEventListener("mousedown", handleClickOutside);
8364
8420
  }
8365
8421
  }, [contextMenu.visible]);
8366
- const hasChanges = gitStatus.staged.length > 0 || gitStatus.unstaged.length > 0 || gitStatus.untracked.length > 0 || gitStatus.deleted.length > 0;
8422
+ const hasChanges = useMemo(
8423
+ () => gitStatus.staged.length > 0 || gitStatus.unstaged.length > 0 || gitStatus.untracked.length > 0 || gitStatus.deleted.length > 0,
8424
+ [gitStatus.staged.length, gitStatus.unstaged.length, gitStatus.untracked.length, gitStatus.deleted.length]
8425
+ );
8367
8426
  const [showFullTree, setShowFullTree] = useState(false);
8368
8427
  const userHasToggledView = useRef(false);
8428
+ const hasInitializedView = useRef(false);
8369
8429
  useEffect(() => {
8370
- if (!isLoading && !userHasToggledView.current) {
8371
- const rafId = requestAnimationFrame(() => {
8372
- setShowFullTree(!hasChanges);
8373
- });
8374
- return () => cancelAnimationFrame(rafId);
8430
+ if (!isLoading && !hasInitializedView.current && !userHasToggledView.current) {
8431
+ hasInitializedView.current = true;
8432
+ setShowFullTree(!hasChanges);
8375
8433
  }
8376
- }, [hasChanges, isLoading]);
8434
+ }, [isLoading]);
8377
8435
  const getFileStatus = useCallback(
8378
8436
  (filePath) => {
8379
8437
  if (gitStatus.staged.includes(filePath)) {
@@ -8508,63 +8566,15 @@ const GitChangesPanelContent = ({
8508
8566
  const tree = builder.build({ files: allChangedFiles, rootPath: rootPath ?? "" });
8509
8567
  return { tree, statusData };
8510
8568
  }, [isLoading, hasChanges, fileTree, gitStatus, rootPath, showFullTree]);
8511
- const ToggleButtons = () => /* @__PURE__ */ jsxs(
8512
- "div",
8513
- {
8514
- style: {
8515
- display: "flex",
8516
- alignItems: "stretch",
8517
- backgroundColor: theme.colors.backgroundTertiary,
8518
- width: "100%",
8519
- height: "100%"
8520
- },
8521
- children: [
8522
- /* @__PURE__ */ jsx(
8523
- "button",
8524
- {
8525
- onClick: () => {
8526
- userHasToggledView.current = true;
8527
- setShowFullTree(true);
8528
- },
8529
- style: {
8530
- flex: 1,
8531
- padding: "6px 12px",
8532
- fontSize: theme.fontSizes[1],
8533
- backgroundColor: showFullTree ? theme.colors.backgroundSecondary : "transparent",
8534
- color: showFullTree ? theme.colors.text : theme.colors.textSecondary,
8535
- border: "none",
8536
- cursor: "pointer",
8537
- fontWeight: showFullTree ? 600 : 400,
8538
- transition: "all 0.2s"
8539
- },
8540
- children: "Full Tree"
8541
- }
8542
- ),
8543
- /* @__PURE__ */ jsx(
8544
- "button",
8545
- {
8546
- onClick: () => {
8547
- userHasToggledView.current = true;
8548
- setShowFullTree(false);
8549
- },
8550
- style: {
8551
- flex: 1,
8552
- padding: "6px 12px",
8553
- fontSize: theme.fontSizes[1],
8554
- backgroundColor: !showFullTree ? theme.colors.backgroundSecondary : "transparent",
8555
- color: !showFullTree ? theme.colors.text : theme.colors.textSecondary,
8556
- border: "none",
8557
- cursor: "pointer",
8558
- fontWeight: !showFullTree ? 600 : 400,
8559
- transition: "all 0.2s"
8560
- },
8561
- children: "Changes"
8562
- }
8563
- )
8564
- ]
8565
- }
8566
- );
8567
- const Content = () => {
8569
+ const handleShowFullTree = useCallback(() => {
8570
+ userHasToggledView.current = true;
8571
+ setShowFullTree(true);
8572
+ }, []);
8573
+ const handleShowChanges = useCallback(() => {
8574
+ userHasToggledView.current = true;
8575
+ setShowFullTree(false);
8576
+ }, []);
8577
+ const renderContent = () => {
8568
8578
  if (isLoading) {
8569
8579
  return /* @__PURE__ */ jsx(
8570
8580
  "div",
@@ -8606,8 +8616,7 @@ const GitChangesPanelContent = ({
8606
8616
  transparentBackground: true,
8607
8617
  horizontalNodePadding: "16px",
8608
8618
  openByDefault: !showFullTree
8609
- },
8610
- showFullTree ? "full" : "changes"
8619
+ }
8611
8620
  );
8612
8621
  };
8613
8622
  const contextMenuButtonStyle = {
@@ -8624,8 +8633,16 @@ const GitChangesPanelContent = ({
8624
8633
  textAlign: "left"
8625
8634
  };
8626
8635
  return /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", height: "100%" }, children: [
8627
- /* @__PURE__ */ jsx("div", { style: { height: 40, borderBottom: `1px solid ${theme.colors.border}` }, children: /* @__PURE__ */ jsx(ToggleButtons, {}) }),
8628
- /* @__PURE__ */ jsx("div", { style: { flex: 1, overflow: "auto" }, children: /* @__PURE__ */ jsx(Content, {}) }),
8636
+ /* @__PURE__ */ jsx("div", { style: { height: 40, borderBottom: `1px solid ${theme.colors.border}` }, children: /* @__PURE__ */ jsx(
8637
+ ToggleButtons,
8638
+ {
8639
+ showFullTree,
8640
+ onShowFullTree: handleShowFullTree,
8641
+ onShowChanges: handleShowChanges,
8642
+ theme
8643
+ }
8644
+ ) }),
8645
+ /* @__PURE__ */ jsx("div", { style: { flex: 1, overflow: "auto" }, children: renderContent() }),
8629
8646
  contextMenu.visible && createPortal(
8630
8647
  /* @__PURE__ */ jsxs(
8631
8648
  "div",
@@ -8766,12 +8783,7 @@ const GitChangesPanel = ({ context, events }) => {
8766
8783
  var _a;
8767
8784
  const gitSlice = context.getSlice("git");
8768
8785
  const fileTreeSlice = context.getSlice("fileTree");
8769
- const gitStatus = (gitSlice == null ? void 0 : gitSlice.data) ?? {
8770
- staged: [],
8771
- unstaged: [],
8772
- untracked: [],
8773
- deleted: []
8774
- };
8786
+ const gitStatus = (gitSlice == null ? void 0 : gitSlice.data) ?? EMPTY_GIT_STATUS;
8775
8787
  const fileTree = (fileTreeSlice == null ? void 0 : fileTreeSlice.data) ?? null;
8776
8788
  const isLoading = (gitSlice == null ? void 0 : gitSlice.loading) || (fileTreeSlice == null ? void 0 : fileTreeSlice.loading) || false;
8777
8789
  const rootPath = context.currentScope.type === "repository" ? (_a = context.currentScope.repository) == null ? void 0 : _a.path : void 0;