likec4 1.32.0 → 1.32.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.
@@ -28903,7 +28903,7 @@ function useDebouncedCallback(callback, deps, delay2, maxWait = 0) {
28903
28903
  }, [delay2, maxWait, ...deps]);
28904
28904
  }
28905
28905
  const noop$1 = () => {
28906
- }, isBrowser$1 = typeof globalThis < "u" && typeof navigator < "u" && typeof document < "u", isStrictEqual = (previous, next) => previous === next, basicDepsComparator = (d1, d2) => {
28906
+ }, isBrowser$1 = typeof globalThis < "u" && typeof navigator < "u" && typeof document < "u", basicDepsComparator = (d1, d2) => {
28907
28907
  if (d1 === d2)
28908
28908
  return !0;
28909
28909
  if (d1.length !== d2.length)
@@ -29011,12 +29011,6 @@ const useCustomCompareMemo = (factory2, deps, comparator) => {
29011
29011
  function useDeepCompareMemo(factory2, deps) {
29012
29012
  return useCustomCompareMemo(factory2, deps, isEqual);
29013
29013
  }
29014
- function usePreviousDistinct(value, predicate = isStrictEqual) {
29015
- const [previousState, setPreviousState] = useState(), currentRef = useRef(value);
29016
- return useUpdateEffect$1(() => {
29017
- predicate(currentRef.current, value) || (setPreviousState(currentRef.current), currentRef.current = value);
29018
- }, [value]), previousState;
29019
- }
29020
29014
  function useAsync(asyncFn, initialValue) {
29021
29015
  const [state, setState] = useState({
29022
29016
  status: "not-executed",
@@ -30014,7 +30008,7 @@ const LikeC4ModelContext$1 = createContext(null);
30014
30008
  function useLikeC4Model$1(type) {
30015
30009
  const model = useContext(LikeC4ModelContext$1);
30016
30010
  if (!model)
30017
- throw new Error("No LikeC4Model found in context");
30011
+ throw new Error("LikeC4Model not found. Make sure you have LikeC4ModelProvider.");
30018
30012
  if (t$3(type) && model.stage !== type)
30019
30013
  throw new Error(`Invalid LikeC4ModelContext, expected "${type}" but got "${model.stage}" in context`);
30020
30014
  return model;
@@ -43115,7 +43109,7 @@ const backdropBlur = "--_blur", backdropOpacity = "--_opacity", level = "--_leve
43115
43109
  openDelay = 130,
43116
43110
  ...rest
43117
43111
  }, ref) => {
43118
- const [opened, setOpened] = useState(openDelay === 0), dialogRef = useRef(null), isClosingRef = useRef(!1), motionNotReduced = useReducedMotionConfig() !== !0, onCloseRef = useRef(onClose);
43112
+ const [opened, setOpened] = useState(openDelay === 0), focusTrapRef = useFocusTrap(opened), dialogRef = useRef(null), isClosingRef = useRef(!1), motionNotReduced = useReducedMotionConfig() !== !0, onCloseRef = useRef(onClose);
43119
43113
  onCloseRef.current = onClose;
43120
43114
  const close = useDebouncedCallback(
43121
43115
  () => {
@@ -43137,8 +43131,17 @@ const backdropBlur = "--_blur", backdropOpacity = "--_opacity", level = "--_leve
43137
43131
  return backdrop?.opacity !== void 0 && (targetBackdropOpacity = `${backdrop.opacity * 100}%`), /* @__PURE__ */ jsx(
43138
43132
  m$3.dialog,
43139
43133
  {
43140
- ref: useMergedRef(dialogRef, ref),
43141
- className: cx(RemoveScroll.classNames.fullWidth, classes2?.dialog, className, styles.dialog),
43134
+ ref: useMergedRef(
43135
+ dialogRef,
43136
+ focusTrapRef,
43137
+ ref
43138
+ ),
43139
+ className: cx(
43140
+ classes2?.dialog,
43141
+ className,
43142
+ styles.dialog,
43143
+ fullscreen && RemoveScroll.classNames.fullWidth
43144
+ ),
43142
43145
  layout: !0,
43143
43146
  style: {
43144
43147
  // @ts-ignore
@@ -43194,7 +43197,17 @@ const backdropBlur = "--_blur", backdropOpacity = "--_opacity", level = "--_leve
43194
43197
  e2.stopPropagation(), close();
43195
43198
  },
43196
43199
  ...rest,
43197
- children: /* @__PURE__ */ jsx(RemoveScroll, { forwardProps: !0, removeScrollBar: !1, children: /* @__PURE__ */ jsx("div", { className: cx(classes2?.body, styles.body, "overlay-body"), children: opened && /* @__PURE__ */ jsx(Fragment$1, { children: children2 }) }) })
43200
+ children: /* @__PURE__ */ jsx(RemoveScroll, { forwardProps: !0, children: /* @__PURE__ */ jsx(
43201
+ "div",
43202
+ {
43203
+ className: cx(
43204
+ classes2?.body,
43205
+ styles.body,
43206
+ "overlay-body"
43207
+ ),
43208
+ children: opened && /* @__PURE__ */ jsx(Fragment$1, { children: children2 })
43209
+ }
43210
+ ) })
43198
43211
  }
43199
43212
  );
43200
43213
  });
@@ -44134,7 +44147,7 @@ function Overlays({ overlaysActorRef }) {
44134
44147
  }
44135
44148
  const [SearchActorContext, useSearchActor] = createSafeContext("SearchActorContext"), selectSearchValue = (s2) => s2.context.searchValue;
44136
44149
  function useSearch() {
44137
- const { searchActorRef } = useSearchActor(), searchValue = xstateReact_cjsExports.useSelector(searchActorRef, selectSearchValue), updateSearch = useCallback((search) => {
44150
+ const searchActorRef = useSearchActor(), searchValue = xstateReact_cjsExports.useSelector(searchActorRef, selectSearchValue), updateSearch = useCallback((search) => {
44138
44151
  searchActorRef.send({ type: "change.search", search });
44139
44152
  }, [searchActorRef]);
44140
44153
  return [searchValue, updateSearch];
@@ -44144,18 +44157,18 @@ const selectNormalizedSearchValue = (s2) => {
44144
44157
  return v.length > 1 ? v : "";
44145
44158
  };
44146
44159
  function useNormalizedSearch() {
44147
- const { searchActorRef } = useSearchActor();
44160
+ const searchActorRef = useSearchActor();
44148
44161
  return useDeferredValue(xstateReact_cjsExports.useSelector(searchActorRef, selectNormalizedSearchValue));
44149
44162
  }
44150
44163
  function useUpdateSearch() {
44151
- const { searchActorRef } = useSearchActor();
44164
+ const searchActorRef = useSearchActor();
44152
44165
  return useCallback((search) => {
44153
44166
  searchActorRef.send({ type: "change.search", search });
44154
44167
  }, [searchActorRef]);
44155
44168
  }
44156
44169
  const selectPickViewFor = (s2) => s2.context.pickViewFor;
44157
44170
  function usePickViewFor() {
44158
- const { searchActorRef } = useSearchActor();
44171
+ const searchActorRef = useSearchActor();
44159
44172
  return xstateReact_cjsExports.useSelector(searchActorRef, selectPickViewFor);
44160
44173
  }
44161
44174
  const buttonFocused = css.raw({
@@ -44367,15 +44380,39 @@ function centerY(element) {
44367
44380
  const rect = element.getBoundingClientRect();
44368
44381
  return rect.y + Math.floor(rect.height / 2);
44369
44382
  }
44370
- function moveFocusToSearchInput() {
44371
- const input2 = document.getElementById("likec4searchinput");
44383
+ function moveFocusToSearchInput(from) {
44384
+ if (!from) {
44385
+ console.error("moveFocusToSearchInput: from is null or undefined");
44386
+ return;
44387
+ }
44388
+ const root2 = from.getRootNode();
44389
+ if (!t$2(root2.querySelector)) {
44390
+ console.error("moveFocusToSearchInput: root.querySelector is not a function");
44391
+ return;
44392
+ }
44393
+ let input2 = root2.querySelector("[data-likec4-search-input]");
44372
44394
  if (input2) {
44373
44395
  const length = input2.value.length;
44374
44396
  input2.focus(), input2.setSelectionRange(length, length);
44375
44397
  }
44376
44398
  }
44377
- function focusToFirstFoundElement() {
44378
- document.querySelector(`[data-likec4-search] .${focusable}`)?.focus();
44399
+ function focusToFirstFoundElement(from) {
44400
+ if (!from) {
44401
+ console.error("focusToFirstFoundElement: from is null or undefined");
44402
+ return;
44403
+ }
44404
+ const root2 = from.getRootNode();
44405
+ if (!t$2(root2.querySelector)) {
44406
+ console.error("focusToFirstFoundElement: root.querySelector is not a function");
44407
+ return;
44408
+ }
44409
+ root2.querySelector(`[data-likec4-search] .${focusable}`)?.focus();
44410
+ }
44411
+ function queryAllFocusable(from, where, selector3 = `.${focusable}`) {
44412
+ if (!from)
44413
+ return console.error("queryAllFocusable: from is null or undefined"), [];
44414
+ const root2 = from.getRootNode();
44415
+ return t$2(root2.querySelectorAll) ? [...root2.querySelectorAll(`[data-likec4-search-${where}] ${selector3}`)] : (console.error("queryAllFocusable: root.querySelectorAll is not a function"), []);
44379
44416
  }
44380
44417
  const _viewBtn = "likec4-view-btn", viewButton = cx(
44381
44418
  css({
@@ -44402,18 +44439,18 @@ css({
44402
44439
  }
44403
44440
  });
44404
44441
  const NothingFound = () => /* @__PURE__ */ jsx(Box, { className: emptyBoX, children: "Nothing found" }), ViewsColumn = memo$2(() => {
44442
+ const ref = useRef(null);
44405
44443
  let views = [...useLikeC4Model$1().views()], search = useNormalizedSearch();
44406
44444
  return search && (search.startsWith("kind:") ? views = [] : views = views.filter((view) => search.startsWith("#") ? view.tags.some((tag) => tag.toLocaleLowerCase().includes(search.slice(1))) : (view.title ?? "" + view.$view.description ?? "").toLocaleLowerCase().includes(search))), /* @__PURE__ */ jsxs(
44407
44445
  Stack,
44408
44446
  {
44447
+ ref,
44409
44448
  renderRoot: (props2) => /* @__PURE__ */ jsx(MotionDiv, { layout: !0, ...props2 }),
44410
44449
  gap: 8,
44411
44450
  "data-likec4-search-views": !0,
44412
44451
  onKeyDown: (e2) => {
44413
44452
  if (e2.key === "ArrowLeft" || e2.key === "ArrowRight") {
44414
- const maxY = e2.target.getBoundingClientRect().y, elementButtons = [...document.querySelectorAll(
44415
- "[data-likec4-search-elements] .likec4-focusable"
44416
- )];
44453
+ const maxY = e2.target.getBoundingClientRect().y, elementButtons = queryAllFocusable(ref.current, "elements", ".likec4-element-button");
44417
44454
  let elementButton = elementButtons.length > 1 ? elementButtons.find((el, i2, all) => centerY(el) > maxY || i2 === all.length - 1) : null;
44418
44455
  elementButton ??= d(elementButtons), elementButton && (e2.stopPropagation(), elementButton.focus());
44419
44456
  return;
@@ -44427,7 +44464,7 @@ const NothingFound = () => /* @__PURE__ */ jsx(Box, { className: emptyBoX, child
44427
44464
  "data-likec4-view": !0,
44428
44465
  tabIndex: -1,
44429
44466
  onFocus: (e2) => {
44430
- e2.stopPropagation(), moveFocusToSearchInput();
44467
+ e2.stopPropagation(), moveFocusToSearchInput(ref.current);
44431
44468
  }
44432
44469
  }
44433
44470
  ) }),
@@ -44444,7 +44481,11 @@ const NothingFound = () => /* @__PURE__ */ jsx(Box, { className: emptyBoX, child
44444
44481
  );
44445
44482
  }), btn$2 = buttonsva();
44446
44483
  function ViewButton({ className, view, loop = !1, search, ...props2 }) {
44447
- const diagram = useDiagram(), currentViewId = useCurrentViewId$1(), isCurrentView = view.id === currentViewId;
44484
+ const searchActorRef = useSearchActor(), diagram = useDiagram(), currentViewId = useCurrentViewId$1(), isCurrentView = view.id === currentViewId, navigate = () => {
44485
+ searchActorRef.send({ type: "close" }), setTimeout(() => {
44486
+ diagram.navigateTo(view.id);
44487
+ }, 100);
44488
+ };
44448
44489
  return /* @__PURE__ */ jsxs(
44449
44490
  UnstyledButton,
44450
44491
  {
@@ -44453,7 +44494,7 @@ function ViewButton({ className, view, loop = !1, search, ...props2 }) {
44453
44494
  "data-likec4-view": view.id,
44454
44495
  ...isCurrentView && { "data-disabled": !0 },
44455
44496
  onClick: (e2) => {
44456
- e2.stopPropagation(), diagram.navigateTo(view.id);
44497
+ e2.stopPropagation(), navigate();
44457
44498
  },
44458
44499
  onKeyDown: createScopedKeydownHandler({
44459
44500
  siblingSelector: "[data-likec4-view]",
@@ -44462,7 +44503,7 @@ function ViewButton({ className, view, loop = !1, search, ...props2 }) {
44462
44503
  loop,
44463
44504
  orientation: "vertical",
44464
44505
  onKeyDown: (e2) => {
44465
- e2.nativeEvent.code === "Space" && (e2.stopPropagation(), diagram.navigateTo(view.id));
44506
+ e2.nativeEvent.code === "Space" && (e2.stopPropagation(), navigate());
44466
44507
  }
44467
44508
  }),
44468
44509
  children: [
@@ -44540,15 +44581,13 @@ function ElementsTree({
44540
44581
  const target = e2.target, id2 = target.getAttribute("data-value"), node2 = !!id2 && byid[id2];
44541
44582
  if (node2) {
44542
44583
  if (e2.key === "ArrowUp") {
44543
- id2 === roots[0]?.value && (stopAndPrevent(e2), moveFocusToSearchInput());
44584
+ id2 === roots[0]?.value && (stopAndPrevent(e2), moveFocusToSearchInput(target));
44544
44585
  return;
44545
44586
  }
44546
44587
  if (e2.key === "ArrowRight") {
44547
44588
  if (node2.children.length > 0 && tree.expandedState[id2] === !1)
44548
44589
  return;
44549
- const maxY = (e2.target.querySelector(".mantine-Tree-label") ?? target).getBoundingClientRect().y, viewButtons = [...document.querySelectorAll(
44550
- `[data-likec4-search-views] .${focusable}`
44551
- )];
44590
+ const maxY = (e2.target.querySelector(".mantine-Tree-label") ?? target).getBoundingClientRect().y, viewButtons = queryAllFocusable(target, "views");
44552
44591
  let view = viewButtons.length > 1 ? viewButtons.find((el, i2, all2) => centerY(el) > maxY || i2 === all2.length - 1) : null;
44553
44592
  view ??= d(viewButtons), view && (stopAndPrevent(e2), view.focus());
44554
44593
  return;
@@ -44655,18 +44694,20 @@ function ElementTreeNode({ node: node2, elementProps, hasChildren, expanded }) {
44655
44694
  ] });
44656
44695
  }
44657
44696
  function useHandleElementSelection() {
44658
- const diagram = useDiagram(), { searchActorRef } = useSearchActor();
44659
- return useCallback((element) => {
44697
+ const diagram = useDiagram(), searchActorRef = useSearchActor();
44698
+ return useCallbackRef((element) => {
44660
44699
  const views = [...element.views()];
44661
44700
  if (views.length === 0)
44662
44701
  return;
44663
44702
  const singleView = t$6(views);
44664
44703
  if (singleView) {
44665
- singleView.id === diagram.currentView.id ? searchActorRef.send({ type: "close" }) : diagram.navigateTo(singleView.id);
44704
+ searchActorRef.send({ type: "close" }), singleView.id !== diagram.currentView.id && setTimeout(() => {
44705
+ diagram.navigateTo(singleView.id);
44706
+ }, 100);
44666
44707
  return;
44667
44708
  }
44668
44709
  searchActorRef.send({ type: "pickview.open", elementFqn: element.id });
44669
- }, []);
44710
+ });
44670
44711
  }
44671
44712
  const input = css({
44672
44713
  border: "transparent",
@@ -44722,7 +44763,7 @@ css({
44722
44763
  }
44723
44764
  });
44724
44765
  function PickView({ elementFqn }) {
44725
- const { searchActorRef } = useSearchActor(), element = useLikeC4Model$1().element(elementFqn), scoped = [], others = [];
44766
+ const searchActorRef = useSearchActor(), element = useLikeC4Model$1().element(elementFqn), scoped = [], others = [];
44726
44767
  for (const view of element.views())
44727
44768
  view.viewOf === element ? scoped.push(view) : others.push(view);
44728
44769
  const closePickView = () => {
@@ -44751,7 +44792,7 @@ function PickView({ elementFqn }) {
44751
44792
  },
44752
44793
  "pickview-backdrop"
44753
44794
  ),
44754
- /* @__PURE__ */ jsxs(
44795
+ /* @__PURE__ */ jsx(FocusTrap, { children: /* @__PURE__ */ jsxs(
44755
44796
  MotionDiv,
44756
44797
  {
44757
44798
  initial: {
@@ -44791,7 +44832,7 @@ function PickView({ elementFqn }) {
44791
44832
  }
44792
44833
  )
44793
44834
  ] }),
44794
- /* @__PURE__ */ jsx(FocusTrap, { children: /* @__PURE__ */ jsxs(ScrollAreaAutosize, { mah: "calc(100vh - 8rem - 50px)", type: "never", children: [
44835
+ /* @__PURE__ */ jsxs(ScrollAreaAutosize, { mah: "calc(100vh - 110px)", type: "never", children: [
44795
44836
  scoped.length > 0 && /* @__PURE__ */ jsxs(Stack, { gap: "sm", px: "sm", className: pickviewGroup, children: [
44796
44837
  /* @__PURE__ */ jsx(Title, { order: 6, c: "dimmed", children: "scoped views of the element" }),
44797
44838
  scoped.map((view, i2) => /* @__PURE__ */ jsx(
@@ -44822,14 +44863,15 @@ function PickView({ elementFqn }) {
44822
44863
  view.id
44823
44864
  ))
44824
44865
  ] })
44825
- ] }) })
44866
+ ] })
44826
44867
  ]
44827
44868
  },
44828
44869
  "pickview"
44829
- )
44870
+ ) })
44830
44871
  ] });
44831
44872
  }
44832
44873
  function SearchByTags() {
44874
+ const ref = useRef(null);
44833
44875
  let tags = useLikeC4Model$1().tagsSortedByUsage, setSearch = useUpdateSearch(), search = useNormalizedSearch(), countBefore = tags.length;
44834
44876
  if (search.startsWith("#")) {
44835
44877
  const searchTag = search.slice(1);
@@ -44841,6 +44883,7 @@ function SearchByTags() {
44841
44883
  return /* @__PURE__ */ jsxs(
44842
44884
  HStack,
44843
44885
  {
44886
+ ref,
44844
44887
  css: {
44845
44888
  gap: "md",
44846
44889
  paddingLeft: 48,
@@ -44900,7 +44943,7 @@ function SearchByTags() {
44900
44943
  }),
44901
44944
  onClick: (e2) => {
44902
44945
  e2.stopPropagation(), setSearch(`#${tag}`), setTimeout(() => {
44903
- focusToFirstFoundElement();
44946
+ focusToFirstFoundElement(ref.current);
44904
44947
  }, 350);
44905
44948
  }
44906
44949
  },
@@ -44915,7 +44958,7 @@ function SearchByTags() {
44915
44958
  size: "compact-xs",
44916
44959
  variant: "light",
44917
44960
  onClick: (e2) => {
44918
- e2.stopPropagation(), setSearch(""), moveFocusToSearchInput();
44961
+ e2.stopPropagation(), setSearch(""), moveFocusToSearchInput(ref.current);
44919
44962
  },
44920
44963
  rightSection: /* @__PURE__ */ jsx(IconX, { size: 14 }),
44921
44964
  children: "Clear"
@@ -44929,9 +44972,7 @@ function startingWithKind(search) {
44929
44972
  return search.match(/^(k|ki|kin|kind|kind:)$/) != null;
44930
44973
  }
44931
44974
  const SEARCH_PREFIXES = ["#", "kind:"], LikeC4SearchInput = memo$2(() => {
44932
- const { close, searchActorRef } = useSearchActor(), likec4model = useLikeC4Model$1(), { ref, focused } = useFocusWithin(), [search, setSearch] = useSearch();
44933
- usePreviousDistinct(search);
44934
- const combobox = useCombobox({
44975
+ const searchActorRef = useSearchActor(), likec4model = useLikeC4Model$1(), inputRef = useRef(null), { ref, focused } = useFocusWithin(), [search, setSearch] = useSearch(), combobox = useCombobox({
44935
44976
  scrollBehavior: "smooth",
44936
44977
  loop: !1
44937
44978
  });
@@ -44939,7 +44980,7 @@ const SEARCH_PREFIXES = ["#", "kind:"], LikeC4SearchInput = memo$2(() => {
44939
44980
  "keydown",
44940
44981
  (event) => {
44941
44982
  try {
44942
- !focused && (event.key === "Backspace" || event.key.startsWith("Arrow") || event.key.match(/^\p{L}$/u)) && moveFocusToSearchInput();
44983
+ !focused && (event.key === "Backspace" || event.key.startsWith("Arrow") || event.key.match(/^\p{L}$/u)) && moveFocusToSearchInput(inputRef.current);
44943
44984
  } catch (e2) {
44944
44985
  console.warn(e2);
44945
44986
  }
@@ -44958,24 +44999,24 @@ const SEARCH_PREFIXES = ["#", "kind:"], LikeC4SearchInput = memo$2(() => {
44958
44999
  // }
44959
45000
  case search.startsWith("#"): {
44960
45001
  const searchTag = search.toLocaleLowerCase().slice(1), alloptions = likec4model.tags.filter((tag) => tag.toLocaleLowerCase().includes(searchTag));
44961
- isExactMatch = t$6(alloptions)?.toLocaleLowerCase() === searchTag, alloptions.length === 0 ? options = [
45002
+ alloptions.length === 0 ? (isExactMatch = !1, options = [
44962
45003
  /* @__PURE__ */ jsx(ComboboxEmpty, { children: "No tags found" }, "empty-tags")
44963
- ] : options = alloptions.map((tag) => /* @__PURE__ */ jsxs(ComboboxOption, { value: `#${tag}`, children: [
45004
+ ]) : (isExactMatch = likec4model.tags.some((tag) => tag.toLocaleLowerCase() === searchTag), options = alloptions.map((tag) => /* @__PURE__ */ jsxs(ComboboxOption, { value: `#${tag}`, children: [
44964
45005
  /* @__PURE__ */ jsx(Text, { component: "span", opacity: 0.5, mr: 1, fz: "sm", children: "#" }),
44965
45006
  tag
44966
- ] }, tag));
45007
+ ] }, tag)));
44967
45008
  break;
44968
45009
  }
44969
45010
  case search.startsWith("kind:"):
44970
45011
  case startingWithKind(search): {
44971
45012
  const term = search.length > 5 ? search.slice(5).toLocaleLowerCase() : "";
44972
45013
  let alloptions = t$4(likec4model.specification.elements);
44973
- term && (alloptions = alloptions.filter((kind) => kind.toLocaleLowerCase().includes(term)), isExactMatch = t$6(alloptions)?.toLocaleLowerCase() === term), alloptions.length === 0 ? options = [
45014
+ term && (alloptions = alloptions.filter((kind) => kind.toLocaleLowerCase().includes(term))), alloptions.length === 0 ? (isExactMatch = !1, options = [
44974
45015
  /* @__PURE__ */ jsx(ComboboxEmpty, { children: "No kinds found" }, "empty-kinds")
44975
- ] : options = alloptions.map((kind) => /* @__PURE__ */ jsxs(ComboboxOption, { value: `kind:${kind}`, children: [
45016
+ ]) : (isExactMatch = alloptions.some((kind) => kind.toLocaleLowerCase() === term), options = alloptions.map((kind) => /* @__PURE__ */ jsxs(ComboboxOption, { value: `kind:${kind}`, children: [
44976
45017
  /* @__PURE__ */ jsx(Text, { component: "span", opacity: 0.5, mr: 1, fz: "sm", children: "kind:" }),
44977
45018
  kind
44978
- ] }, kind));
45019
+ ] }, kind)));
44979
45020
  break;
44980
45021
  }
44981
45022
  }
@@ -44984,7 +45025,7 @@ const SEARCH_PREFIXES = ["#", "kind:"], LikeC4SearchInput = memo$2(() => {
44984
45025
  {
44985
45026
  onOptionSubmit: (optionValue) => {
44986
45027
  setSearch(optionValue), combobox.resetSelectedOption(), SEARCH_PREFIXES.includes(optionValue) || (combobox.closeDropdown(), setTimeout(() => {
44987
- focusToFirstFoundElement();
45028
+ focusToFirstFoundElement(inputRef.current);
44988
45029
  }, 350));
44989
45030
  },
44990
45031
  width: "max-content",
@@ -45000,10 +45041,11 @@ const SEARCH_PREFIXES = ["#", "kind:"], LikeC4SearchInput = memo$2(() => {
45000
45041
  /* @__PURE__ */ jsx(ComboboxTarget, { children: /* @__PURE__ */ jsx(
45001
45042
  Input,
45002
45043
  {
45003
- ref,
45004
- id: "likec4searchinput",
45044
+ ref: useMergedRef(inputRef, ref),
45005
45045
  placeholder: "Search by title, description or start with # or kind:",
45006
45046
  autoFocus: !0,
45047
+ "data-autofocus": !0,
45048
+ "data-likec4-search-input": !0,
45007
45049
  tabIndex: 0,
45008
45050
  classNames: {
45009
45051
  input
@@ -45017,7 +45059,7 @@ const SEARCH_PREFIXES = ["#", "kind:"], LikeC4SearchInput = memo$2(() => {
45017
45059
  onClick: (e2) => {
45018
45060
  e2.stopPropagation();
45019
45061
  const openedWithSearch = searchActorRef.getSnapshot().context.openedWithSearch;
45020
- search === "" || search === openedWithSearch ? close() : setSearch("");
45062
+ search === "" || search === openedWithSearch ? searchActorRef.send({ type: "close" }) : setSearch("");
45021
45063
  }
45022
45064
  }
45023
45065
  ),
@@ -45058,7 +45100,7 @@ const SEARCH_PREFIXES = ["#", "kind:"], LikeC4SearchInput = memo$2(() => {
45058
45100
  }
45059
45101
  if (e2.key === "ArrowDown" && (!combobox.dropdownOpened || options.length === 0 || isExactMatch || // reached the last option and the search is empty
45060
45102
  search === "" && combobox.getSelectedOptionIndex() === options.length - 1)) {
45061
- combobox.closeDropdown(), stopAndPrevent(e2), focusToFirstFoundElement();
45103
+ combobox.closeDropdown(), stopAndPrevent(e2), focusToFirstFoundElement(inputRef.current);
45062
45104
  return;
45063
45105
  }
45064
45106
  }
@@ -45102,15 +45144,12 @@ const SEARCH_PREFIXES = ["#", "kind:"], LikeC4SearchInput = memo$2(() => {
45102
45144
  // _dark: `[rgb(34 34 34 / 0.95)]`,
45103
45145
  // _light: `[rgb(255 255 255/ 0.95)]`,
45104
45146
  // },
45105
- }), selectIsOpened = (s2) => !s2.matches("inactive"), Search = memo$2(({ searchActorRef }) => {
45147
+ }), selectIsOpened = (s2) => !s2.matches("inactive");
45148
+ function Search({ searchActorRef }) {
45106
45149
  const isOpened = xstateReact_cjsExports.useSelector(searchActorRef, selectIsOpened), openSearch = () => {
45107
45150
  searchActorRef.send({ type: "open" });
45108
- }, sendClose = () => {
45151
+ }, close = useCallbackRef(() => {
45109
45152
  searchActorRef.send({ type: "close" });
45110
- }, afterCloseCbRef = useRef(null), close = useCallbackRef((cb) => {
45111
- afterCloseCbRef.current = cb ?? null, sendClose();
45112
- }), onExitComplete = useCallbackRef(() => {
45113
- afterCloseCbRef.current && (afterCloseCbRef.current(), afterCloseCbRef.current = null);
45114
45153
  });
45115
45154
  return useHotkeys([
45116
45155
  ["mod+k", openSearch, {
@@ -45119,34 +45158,26 @@ const SEARCH_PREFIXES = ["#", "kind:"], LikeC4SearchInput = memo$2(() => {
45119
45158
  ["mod+f", openSearch, {
45120
45159
  preventDefault: !0
45121
45160
  }]
45122
- ]), /* @__PURE__ */ jsx(
45123
- SearchActorContext,
45161
+ ]), /* @__PURE__ */ jsx(SearchActorContext, { value: searchActorRef, children: /* @__PURE__ */ jsx(DiagramFeatures.Overlays, { children: /* @__PURE__ */ jsx(reactErrorBoundary_cjsExports.ErrorBoundary, { FallbackComponent: ErrorFallback, onReset: close, children: /* @__PURE__ */ jsx(AnimatePresence, { children: isOpened && /* @__PURE__ */ jsx(
45162
+ Overlay,
45124
45163
  {
45125
- value: {
45126
- searchActorRef,
45127
- close
45164
+ fullscreen: !0,
45165
+ withBackdrop: !1,
45166
+ backdrop: {
45167
+ opacity: 0.9
45128
45168
  },
45129
- children: /* @__PURE__ */ jsx(DiagramFeatures.Overlays, { children: /* @__PURE__ */ jsx(reactErrorBoundary_cjsExports.ErrorBoundary, { FallbackComponent: ErrorFallback, onReset: sendClose, children: /* @__PURE__ */ jsx(LayoutGroup, { children: /* @__PURE__ */ jsx(AnimatePresence, { onExitComplete, children: isOpened && /* @__PURE__ */ jsx(
45130
- Overlay,
45131
- {
45132
- fullscreen: !0,
45133
- withBackdrop: !1,
45134
- backdrop: {
45135
- opacity: 0.9
45136
- },
45137
- classes: {
45138
- dialog,
45139
- body
45140
- },
45141
- openDelay: 0,
45142
- onClose: close,
45143
- "data-likec4-search": "true",
45144
- children: /* @__PURE__ */ jsx(SearchOverlay, { close, searchActorRef })
45145
- }
45146
- ) }) }) }) })
45169
+ classes: {
45170
+ dialog,
45171
+ body
45172
+ },
45173
+ openDelay: 0,
45174
+ onClose: close,
45175
+ "data-likec4-search": "true",
45176
+ children: /* @__PURE__ */ jsx(SearchOverlay, { searchActorRef })
45147
45177
  }
45148
- );
45149
- }), scrollArea = css({
45178
+ ) }) }) }) });
45179
+ }
45180
+ const scrollArea = css({
45150
45181
  height: [
45151
45182
  "100%",
45152
45183
  "100cqh"
@@ -45158,18 +45189,18 @@ const SEARCH_PREFIXES = ["#", "kind:"], LikeC4SearchInput = memo$2(() => {
45158
45189
  height: "100%"
45159
45190
  }
45160
45191
  }
45161
- }), SearchOverlay = ({ close, searchActorRef }) => {
45162
- const pickViewFor = usePickViewFor();
45192
+ }), SearchOverlay = ({ searchActorRef }) => {
45193
+ const ref = useRef(null), pickViewFor = usePickViewFor();
45163
45194
  return useTimeoutEffect(() => {
45164
- n$5(searchActorRef.getSnapshot().context.openedWithSearch) && focusToFirstFoundElement();
45165
- }, 150), /* @__PURE__ */ jsxs(FocusTrap, { children: [
45195
+ n$5(searchActorRef.getSnapshot().context.openedWithSearch) && focusToFirstFoundElement(ref.current);
45196
+ }, 150), /* @__PURE__ */ jsxs(Box, { ref, display: "contents", children: [
45166
45197
  /* @__PURE__ */ jsx(
45167
45198
  Group,
45168
45199
  {
45169
45200
  className: "group",
45170
45201
  wrap: "nowrap",
45171
45202
  onClick: (e2) => {
45172
- e2.stopPropagation(), moveFocusToSearchInput();
45203
+ e2.stopPropagation(), moveFocusToSearchInput(ref.current);
45173
45204
  },
45174
45205
  children: /* @__PURE__ */ jsxs(VStack, { flex: 1, px: "sm", children: [
45175
45206
  /* @__PURE__ */ jsx(LikeC4SearchInput, {}),
@@ -46695,12 +46726,12 @@ function LikeC4DiagramXYFlow({
46695
46726
  onCanvasDblClick
46696
46727
  } = useDiagramEventHandlers(), notReadOnly = !enableReadOnly, isReducedGraphics = useIsReducedGraphics(), layoutConstraints = useLayoutConstraints(), $isPanning = usePanningAtom(), isPanning = useTimeout(() => {
46697
46728
  $isPanning.set(!0);
46698
- }, isReducedGraphics ? 100 : 200), notPanning = useDebouncedCallback$1(() => {
46729
+ }, isReducedGraphics ? 120 : 200), notPanning = useDebouncedCallback$1(() => {
46699
46730
  isPanning.clear(), $isPanning.get() && $isPanning.set(!1);
46700
- }, 200), onMove = useCallbackRef((event) => {
46731
+ }, isReducedGraphics ? 350 : 200), onMove = useCallbackRef((event) => {
46701
46732
  event && ($isPanning.get() || isPanning.start(), notPanning());
46702
46733
  }), onMoveEnd = useCallbackRef((event, viewport) => {
46703
- event && notPanning.flush(), diagram.send({ type: "xyflow.viewportMoved", viewport, manually: !!event });
46734
+ event && !isReducedGraphics && notPanning.flush(), diagram.send({ type: "xyflow.viewportMoved", viewport, manually: !!event });
46704
46735
  }), onViewportResize = useCallbackRef(() => {
46705
46736
  diagram.send({ type: "xyflow.resized" });
46706
46737
  }), nodeTypes2 = useCustomCompareMemo(
@@ -49625,12 +49656,14 @@ const _diagramMachine = xstate_cjsExports.setup({
49625
49656
  "closeAllOverlays",
49626
49657
  "closeSearch",
49627
49658
  "stopSyncLayout",
49628
- {
49629
- type: "trigger:NavigateTo",
49630
- params: ({ context: context2 }) => ({
49631
- viewId: nonNullable(context2.lastOnNavigate, "Invalid state, lastOnNavigate is null").toView
49632
- })
49633
- }
49659
+ xstate_cjsExports.enqueueActions(({ enqueue, context: context2 }) => {
49660
+ enqueue({
49661
+ type: "trigger:NavigateTo",
49662
+ params: {
49663
+ viewId: nonNullable(context2.lastOnNavigate, "Invalid state, lastOnNavigate is null").toView
49664
+ }
49665
+ });
49666
+ })
49634
49667
  ],
49635
49668
  on: {
49636
49669
  "update.view": {
@@ -49772,7 +49805,7 @@ function DiagramActorProvider({
49772
49805
  "trigger:NavigateTo": (_, { viewId }) => {
49773
49806
  setTimeout(() => {
49774
49807
  handlersRef.current.onNavigateTo?.(viewId);
49775
- }, 30);
49808
+ }, 40);
49776
49809
  },
49777
49810
  "trigger:OnChange": (_, params) => {
49778
49811
  handlersRef.current.onChange?.(params);
@@ -49843,7 +49876,7 @@ function LikeC4Diagram({
49843
49876
  pannable = !0,
49844
49877
  zoomable = !0,
49845
49878
  background = "dots",
49846
- enableElementTags = !0,
49879
+ enableElementTags = !1,
49847
49880
  enableFocusMode = !1,
49848
49881
  enableElementDetails = !1,
49849
49882
  enableRelationshipDetails = enableElementDetails,
@@ -50353,7 +50386,16 @@ function useDiagramsTreeData(groupBy = "by-files") {
50353
50386
  }
50354
50387
  const isFile = (node2) => isTreeNodeData(node2) && node2.type === "file", FolderIcon = ({ node: node2, expanded }) => isFile(node2) ? /* @__PURE__ */ jsx(ThemeIcon, { size: "sm", variant: "transparent", color: "indigo", children: /* @__PURE__ */ jsx(IconFileCode, { size: 16 }) }) : /* @__PURE__ */ jsx(ThemeIcon, { size: "sm", variant: "transparent", color: "violet", children: expanded ? /* @__PURE__ */ jsx(IconFolderOpen, { size: 16 }) : /* @__PURE__ */ jsx(IconFolderFilled, { size: 16 }) }), setHoveredNode = () => {
50355
50388
  }, DiagramsTree = /* @__PURE__ */ memo$2(({ groupBy }) => {
50356
- const data = useDiagramsTreeData(groupBy), router = useRouter(), diagram = useCurrentDiagram(), viewId = diagram?.id ?? null, tree = useTree({
50389
+ const views = useLikeC4Views(), data = useDiagramsTreeData(groupBy), navigate = useNavigate(), navigateTo = (viewId2) => {
50390
+ navigate({
50391
+ to: "./",
50392
+ viewTransition: !1,
50393
+ params: (p2) => ({
50394
+ ...p2,
50395
+ viewId: viewId2
50396
+ })
50397
+ });
50398
+ }, diagram = useCurrentDiagram(), viewId = diagram?.id ?? null, tree = useTree({
50357
50399
  multiple: !1
50358
50400
  });
50359
50401
  tree.setHoveredNode = setHoveredNode;
@@ -50371,7 +50413,7 @@ const isFile = (node2) => isTreeNodeData(node2) && node2.type === "file", Folder
50371
50413
  viewId && tree.select(viewId);
50372
50414
  }, [viewId]);
50373
50415
  const theme2 = useComputedColorScheme();
50374
- return /* @__PURE__ */ jsx(Box$1, { children: /* @__PURE__ */ jsx(
50416
+ return /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(
50375
50417
  Tree,
50376
50418
  {
50377
50419
  allowRangeSelection: !1,
@@ -50384,7 +50426,7 @@ const isFile = (node2) => isTreeNodeData(node2) && node2.type === "file", Folder
50384
50426
  }
50385
50427
  },
50386
50428
  levelOffset: "md",
50387
- renderNode: ({ node: node2, selected: selected2, expanded, elementProps, hasChildren }) => /* @__PURE__ */ jsx(DiagramPreviewHoverCard, { viewId: hasChildren ? null : node2.value, ...elementProps, children: /* @__PURE__ */ jsx(
50429
+ renderNode: ({ node: node2, selected: selected2, expanded, elementProps, hasChildren }) => /* @__PURE__ */ jsx(DiagramPreviewHoverCard, { diagram: hasChildren ? void 0 : views.find((v) => v.id === node2.value), children: /* @__PURE__ */ jsx(
50388
50430
  Button,
50389
50431
  {
50390
50432
  fullWidth: !0,
@@ -50407,16 +50449,10 @@ const isFile = (node2) => isTreeNodeData(node2) && node2.type === "file", Folder
50407
50449
  ] }),
50408
50450
  hasChildren && /* @__PURE__ */ jsx(FolderIcon, { node: node2, expanded })
50409
50451
  ] }),
50452
+ ...elementProps,
50410
50453
  ...!hasChildren && {
50411
50454
  onClick: (e2) => {
50412
- e2.stopPropagation(), router.buildAndCommitLocation({
50413
- to: ".",
50414
- viewTransition: !1,
50415
- params: (p2) => ({
50416
- ...p2,
50417
- viewId: node2.value
50418
- })
50419
- });
50455
+ e2.stopPropagation(), navigateTo(node2.value);
50420
50456
  }
50421
50457
  },
50422
50458
  children: node2.label
@@ -50424,20 +50460,15 @@ const isFile = (node2) => isTreeNodeData(node2) && node2.type === "file", Folder
50424
50460
  ) })
50425
50461
  }
50426
50462
  ) });
50427
- });
50428
- function DiagramPreviewHoverCard({
50429
- viewId,
50430
- children: children2,
50431
- onClick,
50432
- ...props2
50433
- }) {
50434
- const diagram = useLikeC4Views().find((v) => v.id === viewId), ratio = diagram ? Math.max(diagram.bounds.width / 400, diagram.bounds.height / 300) : 1, width = diagram ? Math.round(diagram.bounds.width / ratio) : 0, height = diagram ? Math.round(diagram.bounds.height / ratio) : 0;
50435
- return /* @__PURE__ */ jsxs(Box$1, { ...props2, children: [
50463
+ }, (prev, next) => prev.groupBy === next.groupBy);
50464
+ function DiagramPreviewHoverCard({ diagram, children: children2 }) {
50465
+ const ratio = diagram ? Math.max(diagram.bounds.width / 400, diagram.bounds.height / 300) : 1, width = diagram ? Math.round(diagram.bounds.width / ratio) : 0, height = diagram ? Math.round(diagram.bounds.height / ratio) : 0;
50466
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
50436
50467
  diagram && /* @__PURE__ */ jsxs(HoverCard, { position: "right-start", openDelay: 400, closeDelay: 100, keepMounted: !1, shadow: "lg", children: [
50437
50468
  /* @__PURE__ */ jsx(HoverCardTarget, { children: children2 }),
50438
- /* @__PURE__ */ jsx(HoverCardDropdown, { style: { width, height }, p: "xs", onClick, children: /* @__PURE__ */ jsx(DiagramPreview, { diagram }) })
50469
+ /* @__PURE__ */ jsx(HoverCardDropdown, { style: { width, height }, p: "xs", children: /* @__PURE__ */ jsx(DiagramPreview, { diagram }) })
50439
50470
  ] }),
50440
- !diagram && /* @__PURE__ */ jsx(Fragment$1, { children: children2 })
50471
+ !diagram && children2
50441
50472
  ] });
50442
50473
  }
50443
50474
  const DiagramPreview = memo$2(({ diagram }) => {
@@ -51484,6 +51515,7 @@ function ViewReact() {
51484
51515
  enableElementDetails: !0,
51485
51516
  enableRelationshipDetails: !0,
51486
51517
  enableRelationshipBrowser: !0,
51518
+ enableElementTags: !0,
51487
51519
  experimentalEdgeEditing: !1,
51488
51520
  showNotations: hasNotations,
51489
51521
  nodesDraggable: !1,
@@ -53231,6 +53263,7 @@ function ViewEditor() {
53231
53263
  enableElementDetails: !0,
53232
53264
  enableRelationshipDetails: !0,
53233
53265
  enableRelationshipBrowser: !0,
53266
+ enableElementTags: !0,
53234
53267
  onNavigateTo,
53235
53268
  onChange: (e2) => console.log(e2),
53236
53269
  onBurgerMenuClick: withOverviewGraph ? () => {
@@ -1 +1,2 @@
1
1
 
2
+ import '@likec4/core/builder';