@cere/cere-design-system 0.0.30 → 0.0.32

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.mts CHANGED
@@ -2688,6 +2688,8 @@ interface CodeEditorStatusBarProps {
2688
2688
  * When provided, default rendering is skipped entirely.
2689
2689
  */
2690
2690
  renderStatusBar?: (props: CodeEditorStatusBarRenderProps) => React__default.ReactNode;
2691
+ /** Called when the user clicks the branch name in the status bar */
2692
+ onBranchClick?: () => void;
2691
2693
  /** Props for the outer container */
2692
2694
  containerProps?: BoxProps;
2693
2695
  }
@@ -2747,6 +2749,10 @@ interface CodeEditorWorkspaceProps extends Pick<UseCodeEditorWorkspaceOptions, '
2747
2749
  statusBarItems?: CodeEditorStatusBarItem[];
2748
2750
  /** Expose the workspace instance to the parent via ref-like callback */
2749
2751
  onWorkspaceReady?: (workspace: UseCodeEditorWorkspaceReturn) => void;
2752
+ /** Called when the user presses Ctrl+S / Cmd+S. Receives all dirty files. */
2753
+ onSave?: (dirtyFiles: CodeEditorFile[]) => void;
2754
+ /** Called when the user clicks the branch name in the status bar */
2755
+ onBranchClick?: () => void;
2750
2756
  }
2751
2757
  /**
2752
2758
  * Convenience composed workspace that combines `CodeEditorFileTree`,
package/dist/index.d.ts CHANGED
@@ -2688,6 +2688,8 @@ interface CodeEditorStatusBarProps {
2688
2688
  * When provided, default rendering is skipped entirely.
2689
2689
  */
2690
2690
  renderStatusBar?: (props: CodeEditorStatusBarRenderProps) => React__default.ReactNode;
2691
+ /** Called when the user clicks the branch name in the status bar */
2692
+ onBranchClick?: () => void;
2691
2693
  /** Props for the outer container */
2692
2694
  containerProps?: BoxProps;
2693
2695
  }
@@ -2747,6 +2749,10 @@ interface CodeEditorWorkspaceProps extends Pick<UseCodeEditorWorkspaceOptions, '
2747
2749
  statusBarItems?: CodeEditorStatusBarItem[];
2748
2750
  /** Expose the workspace instance to the parent via ref-like callback */
2749
2751
  onWorkspaceReady?: (workspace: UseCodeEditorWorkspaceReturn) => void;
2752
+ /** Called when the user presses Ctrl+S / Cmd+S. Receives all dirty files. */
2753
+ onSave?: (dirtyFiles: CodeEditorFile[]) => void;
2754
+ /** Called when the user clicks the branch name in the status bar */
2755
+ onBranchClick?: () => void;
2750
2756
  }
2751
2757
  /**
2752
2758
  * Convenience composed workspace that combines `CodeEditorFileTree`,
package/dist/index.js CHANGED
@@ -9672,6 +9672,7 @@ var CodeEditorStatusBar = ({
9672
9672
  cursorPosition,
9673
9673
  items,
9674
9674
  renderStatusBar,
9675
+ onBranchClick,
9675
9676
  containerProps
9676
9677
  }) => {
9677
9678
  if (renderStatusBar) {
@@ -9714,12 +9715,14 @@ var CodeEditorStatusBar = ({
9714
9715
  children: /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)(
9715
9716
  import_material76.Box,
9716
9717
  {
9718
+ onClick: onBranchClick,
9717
9719
  sx: {
9718
9720
  display: "flex",
9719
9721
  alignItems: "center",
9720
9722
  gap: 0.5,
9721
- cursor: "default",
9722
- overflow: "hidden"
9723
+ cursor: onBranchClick ? "pointer" : "default",
9724
+ overflow: "hidden",
9725
+ "&:hover": onBranchClick ? { opacity: 0.8 } : void 0
9723
9726
  },
9724
9727
  children: [
9725
9728
  /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
@@ -9865,7 +9868,9 @@ var CodeEditorWorkspace = ({
9865
9868
  gitInfo,
9866
9869
  showStatusBar = true,
9867
9870
  statusBarItems,
9868
- onWorkspaceReady
9871
+ onWorkspaceReady,
9872
+ onSave,
9873
+ onBranchClick
9869
9874
  }) => {
9870
9875
  const workspace = useCodeEditorWorkspace({
9871
9876
  files,
@@ -9876,6 +9881,27 @@ var CodeEditorWorkspace = ({
9876
9881
  import_react40.default.useEffect(() => {
9877
9882
  onWorkspaceReady?.(workspace);
9878
9883
  }, []);
9884
+ import_react40.default.useEffect(() => {
9885
+ if (!onSave) return;
9886
+ const handleKeyDown = (e) => {
9887
+ if ((e.ctrlKey || e.metaKey) && e.key === "s") {
9888
+ e.preventDefault();
9889
+ const dirtyFiles = workspace.openTabs.filter((t) => t.isDirty).map((t) => {
9890
+ const file = files.find((f) => f.path === t.path);
9891
+ if (!file) return null;
9892
+ return {
9893
+ ...file,
9894
+ value: workspace.getFileContent(file.path) ?? file.value
9895
+ };
9896
+ }).filter((f) => f !== null);
9897
+ if (dirtyFiles.length > 0) {
9898
+ onSave(dirtyFiles);
9899
+ }
9900
+ }
9901
+ };
9902
+ window.addEventListener("keydown", handleKeyDown);
9903
+ return () => window.removeEventListener("keydown", handleKeyDown);
9904
+ }, [onSave, workspace, files]);
9879
9905
  const hasFileTree = showFileTree && fileTree && fileTree.length > 0;
9880
9906
  const tabsProps = {
9881
9907
  tabs: workspace.openTabs,
@@ -9896,7 +9922,8 @@ var CodeEditorWorkspace = ({
9896
9922
  gitInfo,
9897
9923
  language: workspace.activeFile?.language,
9898
9924
  cursorPosition: workspace.cursorPosition ?? void 0,
9899
- items: statusBarItems
9925
+ items: statusBarItems,
9926
+ onBranchClick
9900
9927
  };
9901
9928
  const statusBarElement = showStatusBar ? renderStatusBar ? renderStatusBar({ ...statusBarProps, workspace }) : /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(CodeEditorStatusBar, { ...statusBarProps }) : null;
9902
9929
  const editorElement = renderEditor ? renderEditor(workspace) : workspace.activeFile ? /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(