@industry-theme/repository-composition-panels 0.2.19 → 0.2.21

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,15 +8419,16 @@ 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);
8369
8428
  useEffect(() => {
8370
8429
  if (!isLoading && !userHasToggledView.current) {
8371
- const rafId = requestAnimationFrame(() => {
8372
- setShowFullTree(!hasChanges);
8373
- });
8374
- return () => cancelAnimationFrame(rafId);
8430
+ const shouldShowFullTree = !hasChanges;
8431
+ setShowFullTree((prev) => prev === shouldShowFullTree ? prev : shouldShowFullTree);
8375
8432
  }
8376
8433
  }, [hasChanges, isLoading]);
8377
8434
  const getFileStatus = useCallback(
@@ -8508,62 +8565,14 @@ const GitChangesPanelContent = ({
8508
8565
  const tree = builder.build({ files: allChangedFiles, rootPath: rootPath ?? "" });
8509
8566
  return { tree, statusData };
8510
8567
  }, [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
- );
8568
+ const handleShowFullTree = useCallback(() => {
8569
+ userHasToggledView.current = true;
8570
+ setShowFullTree(true);
8571
+ }, []);
8572
+ const handleShowChanges = useCallback(() => {
8573
+ userHasToggledView.current = true;
8574
+ setShowFullTree(false);
8575
+ }, []);
8567
8576
  const renderContent = () => {
8568
8577
  if (isLoading) {
8569
8578
  return /* @__PURE__ */ jsx(
@@ -8606,8 +8615,7 @@ const GitChangesPanelContent = ({
8606
8615
  transparentBackground: true,
8607
8616
  horizontalNodePadding: "16px",
8608
8617
  openByDefault: !showFullTree
8609
- },
8610
- showFullTree ? "full" : "changes"
8618
+ }
8611
8619
  );
8612
8620
  };
8613
8621
  const contextMenuButtonStyle = {
@@ -8624,7 +8632,15 @@ const GitChangesPanelContent = ({
8624
8632
  textAlign: "left"
8625
8633
  };
8626
8634
  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, {}) }),
8635
+ /* @__PURE__ */ jsx("div", { style: { height: 40, borderBottom: `1px solid ${theme.colors.border}` }, children: /* @__PURE__ */ jsx(
8636
+ ToggleButtons,
8637
+ {
8638
+ showFullTree,
8639
+ onShowFullTree: handleShowFullTree,
8640
+ onShowChanges: handleShowChanges,
8641
+ theme
8642
+ }
8643
+ ) }),
8628
8644
  /* @__PURE__ */ jsx("div", { style: { flex: 1, overflow: "auto" }, children: renderContent() }),
8629
8645
  contextMenu.visible && createPortal(
8630
8646
  /* @__PURE__ */ jsxs(
@@ -8766,12 +8782,7 @@ const GitChangesPanel = ({ context, events }) => {
8766
8782
  var _a;
8767
8783
  const gitSlice = context.getSlice("git");
8768
8784
  const fileTreeSlice = context.getSlice("fileTree");
8769
- const gitStatus = (gitSlice == null ? void 0 : gitSlice.data) ?? {
8770
- staged: [],
8771
- unstaged: [],
8772
- untracked: [],
8773
- deleted: []
8774
- };
8785
+ const gitStatus = (gitSlice == null ? void 0 : gitSlice.data) ?? EMPTY_GIT_STATUS;
8775
8786
  const fileTree = (fileTreeSlice == null ? void 0 : fileTreeSlice.data) ?? null;
8776
8787
  const isLoading = (gitSlice == null ? void 0 : gitSlice.loading) || (fileTreeSlice == null ? void 0 : fileTreeSlice.loading) || false;
8777
8788
  const rootPath = context.currentScope.type === "repository" ? (_a = context.currentScope.repository) == null ? void 0 : _a.path : void 0;