likec4 1.36.0 → 1.36.1

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.
@@ -30794,6 +30794,9 @@ function useIsPanning() {
30794
30794
  return useStore(usePanningAtom());
30795
30795
  }
30796
30796
  const LikeC4ModelContext$1 = createContext(null), CurrentViewModelContext = createContext(null);
30797
+ function EnsureCurrentViewModel({ children: children2 }) {
30798
+ return useContext(CurrentViewModelContext) ? /* @__PURE__ */ jsx(Fragment$1, { children: children2 }) : null;
30799
+ }
30797
30800
  function useLikeC4Model$1() {
30798
30801
  const model = useContext(LikeC4ModelContext$1);
30799
30802
  if (!model)
@@ -37939,6 +37942,9 @@ const isSelected = ".react-flow__edge.selected", controlPointsContainer = css({
37939
37942
  );
37940
37943
  }
37941
37944
  );
37945
+ function useOptionalCurrentViewModel() {
37946
+ return useContext(CurrentViewModelContext);
37947
+ }
37942
37948
  function useCurrentViewModel() {
37943
37949
  const vm = useContext(CurrentViewModelContext);
37944
37950
  if (!vm)
@@ -39897,7 +39903,7 @@ const OpenSource = () => {
39897
39903
  onClick: (e2) => {
39898
39904
  e2.stopPropagation(), onOpenSource?.({ view: viewId });
39899
39905
  },
39900
- children: /* @__PURE__ */ jsx(IconFileSymlink, { stroke: 1.5, style: { width: "65%" } })
39906
+ children: /* @__PURE__ */ jsx(IconFileSymlink, { style: { width: "60%", height: "60%" } })
39901
39907
  }
39902
39908
  ) }) : null;
39903
39909
  };
@@ -48673,11 +48679,11 @@ function selector$1(context2) {
48673
48679
  };
48674
48680
  }
48675
48681
  function DiagramTitlePanel() {
48676
- const view = useCurrentViewModel(), { isNotActiveWalkthrough } = useDiagramContext(selector$1), [isCollapsed, setCollapsed] = useLocalStorage({
48682
+ const view = useOptionalCurrentViewModel(), { isNotActiveWalkthrough } = useDiagramContext(selector$1), [isCollapsed, setCollapsed] = useLocalStorage({
48677
48683
  key: "diagram-title-webview-collapsed",
48678
48684
  defaultValue: !1
48679
- }), title$12 = view.title ?? "untitled", toggle = () => setCollapsed((v) => !v);
48680
- return /* @__PURE__ */ jsx(AnimatePresence, { mode: "wait", children: isNotActiveWalkthrough && /* @__PURE__ */ jsx(
48685
+ }), title$12 = view?.title ?? "untitled", toggle = () => setCollapsed((v) => !v);
48686
+ return /* @__PURE__ */ jsx(AnimatePresence, { mode: "wait", children: view && isNotActiveWalkthrough && /* @__PURE__ */ jsx(
48681
48687
  m$4.div,
48682
48688
  {
48683
48689
  initial: { opacity: 0.05, scale: 0.7 },
@@ -49268,7 +49274,7 @@ const DiagramUI = memo$2(() => {
49268
49274
  enableSearch
49269
49275
  } = useEnabledFeatures(), overlaysActorRef = useOverlaysActorRef(), searchActorRef = useSearchActorRef();
49270
49276
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [
49271
- enableControls === "next" ? /* @__PURE__ */ jsx(NavigationPanel, {}) : /* @__PURE__ */ jsx(Controls, {}),
49277
+ enableControls === "next" ? /* @__PURE__ */ jsx(EnsureCurrentViewModel, { children: /* @__PURE__ */ jsx(NavigationPanel, {}) }) : /* @__PURE__ */ jsx(Controls, {}),
49272
49278
  overlaysActorRef && /* @__PURE__ */ jsx(Overlays, { overlaysActorRef }),
49273
49279
  enableNotations && /* @__PURE__ */ jsx(NotationPanel, {}),
49274
49280
  enableControls !== "next" && /* @__PURE__ */ jsxs(Fragment$1, { children: [
@@ -53164,22 +53170,23 @@ function DiagramActorProvider({
53164
53170
  actorRef.send({ type: "update.view", view, xyedges, xynodes });
53165
53171
  }, [view, xyedges, xynodes]);
53166
53172
  const toggledFeatures = xstateReact_cjsExports.useSelector(actorRef, selectToggledFeatures, shallowEqual);
53167
- return /* @__PURE__ */ jsx(DiagramActorContextProvider, { value: actorRef, children: /* @__PURE__ */ jsx(DiagramFeatures, { overrides: toggledFeatures, children: /* @__PURE__ */ jsx(ErrorBoundary2, { children: /* @__PURE__ */ jsx(CurrentViewModelProvider, { children: children2 }) }) }) });
53173
+ return /* @__PURE__ */ jsx(DiagramActorContextProvider, { value: actorRef, children: /* @__PURE__ */ jsx(DiagramFeatures, { overrides: toggledFeatures, children: /* @__PURE__ */ jsx(ErrorBoundary2, { children: /* @__PURE__ */ jsx(CurrentViewModelProvider, { viewId: view.id, children: children2 }) }) }) });
53168
53174
  }
53169
53175
  function CurrentViewModelProvider({
53170
- children: children2
53176
+ children: children2,
53177
+ viewId
53171
53178
  }) {
53172
- const viewId = useCurrentViewId$1(), likec4model = useLikeC4Model$1(), [viewmodel, setViewmodel] = useState(() => likec4model.view(viewId));
53179
+ const likec4model = useLikeC4Model$1(), [viewmodel, setViewmodel] = useState(() => likec4model.findView(viewId));
53173
53180
  return useEffect(() => {
53174
53181
  setViewmodel((current) => {
53175
53182
  const nextviewmodel = likec4model.findView(viewId);
53176
- return nextviewmodel || (console.error(`View "${viewId}" not found in likec4model, current viewmodel: ${current.id}`, {
53183
+ return nextviewmodel ? (nextviewmodel.isDiagram() || console.warn(`View "${viewId}" is not diagram.
53184
+ Make sure you have LikeC4ModelProvider with layouted model.`), nextviewmodel) : (console.error(`View "${viewId}" not found in likec4model, current viewmodel: ${current?.id}`, {
53177
53185
  currentViewModel: current,
53178
53186
  likec4model
53179
53187
  }), current);
53180
53188
  });
53181
- }, [likec4model, viewId]), viewmodel.isDiagram() || console.warn(`View "${viewId}" is not diagram.
53182
- Make sure you have LikeC4ModelProvider with layouted model.`), /* @__PURE__ */ jsx(CurrentViewModelContext.Provider, { value: viewmodel, children: children2 });
53189
+ }, [likec4model, viewId]), /* @__PURE__ */ jsx(CurrentViewModelContext.Provider, { value: viewmodel, children: children2 });
53183
53190
  }
53184
53191
  function useActorEventHandlers(actorRef) {
53185
53192
  const {