ai-design-system 0.1.65 → 0.1.66

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.
@@ -20,6 +20,7 @@ export const AppSidebar = React.memo<AppSidebarProps>(
20
20
  ({
21
21
  logo,
22
22
  mainNavigation,
23
+ navigationGroups,
23
24
  secondaryNavigation,
24
25
  documents,
25
26
  user,
@@ -46,11 +47,22 @@ export const AppSidebar = React.memo<AppSidebarProps>(
46
47
  </SidebarHeader>
47
48
 
48
49
  <SidebarContent>
49
- <SidebarGroup>
50
- <SidebarGroupContent>
51
- <NavigationList items={mainNavigation} />
52
- </SidebarGroupContent>
53
- </SidebarGroup>
50
+ {mainNavigation && mainNavigation.length > 0 && (
51
+ <SidebarGroup>
52
+ <SidebarGroupContent>
53
+ <NavigationList items={mainNavigation} />
54
+ </SidebarGroupContent>
55
+ </SidebarGroup>
56
+ )}
57
+
58
+ {navigationGroups?.map((group) => (
59
+ <SidebarGroup key={group.label}>
60
+ <SidebarGroupLabel>{group.label}</SidebarGroupLabel>
61
+ <SidebarGroupContent>
62
+ <NavigationList items={group.items} />
63
+ </SidebarGroupContent>
64
+ </SidebarGroup>
65
+ ))}
54
66
 
55
67
  {documents && documents.length > 0 && (
56
68
  <SidebarGroup>
@@ -1,13 +1,19 @@
1
1
  import type { NavigationItem } from "@/components/composites/NavigationList/interfaces";
2
2
  import type { SidebarProps } from "@/components/primitives/Sidebar";
3
3
 
4
+ export interface NavigationGroup {
5
+ label: string;
6
+ items: NavigationItem[];
7
+ }
8
+
4
9
  export interface AppSidebarProps {
5
10
  logo?: {
6
11
  icon: string;
7
12
  text: string;
8
13
  href: string;
9
14
  };
10
- mainNavigation: NavigationItem[];
15
+ mainNavigation?: NavigationItem[];
16
+ navigationGroups?: NavigationGroup[];
11
17
  secondaryNavigation?: NavigationItem[];
12
18
  documents?: NavigationItem[];
13
19
  user: {
@@ -25,7 +25,7 @@ export const NavigationList = React.memo<NavigationListProps>(
25
25
  ({ items, onItemClick, className }) => {
26
26
  return (
27
27
  <SidebarMenu className={className}>
28
- {items.map((item) => (
28
+ {items?.map((item) => (
29
29
  <SidebarMenuItem key={item.title}>
30
30
  <SidebarMenuButton
31
31
  tooltip={item.title}
@@ -269,9 +269,44 @@ export const TextEditor = React.memo<TextEditorProps>(
269
269
  if (!isExternal && !isAnchor && href) {
270
270
  e.preventDefault()
271
271
  let targetId = href
272
- if (targetId.startsWith('./')) {
272
+
273
+ if (targetId.startsWith('file://')) {
274
+ let path = targetId.replace('file://', '')
275
+ // On Windows, file:///C:/path becomes /C:/path, we want C:/path
276
+ if (path.match(/^\/[a-zA-Z]:\//)) {
277
+ path = path.slice(1)
278
+ }
279
+ if (isMultiTab && props.documents) {
280
+ const matchedDoc = props.documents.find(doc => path.endsWith(doc.file.id) || path.endsWith('/' + doc.file.id))
281
+ if (matchedDoc) {
282
+ targetId = matchedDoc.file.id
283
+ } else {
284
+ targetId = path
285
+ }
286
+ } else {
287
+ targetId = path
288
+ }
289
+ } else if (props.activeDocumentId) {
290
+ if (targetId.startsWith('/')) {
291
+ targetId = targetId.slice(1)
292
+ } else {
293
+ const baseParts = props.activeDocumentId.split('/')
294
+ baseParts.pop() // remove current filename
295
+ const targetParts = targetId.split('/')
296
+ for (const part of targetParts) {
297
+ if (part === '.' || part === '') continue
298
+ if (part === '..') {
299
+ if (baseParts.length > 0) baseParts.pop()
300
+ } else {
301
+ baseParts.push(part)
302
+ }
303
+ }
304
+ targetId = baseParts.join('/')
305
+ }
306
+ } else if (targetId.startsWith('./')) {
273
307
  targetId = targetId.slice(2)
274
308
  }
309
+
275
310
  if (handleTabSelect) {
276
311
  handleTabSelect(targetId)
277
312
  }
@@ -282,7 +317,7 @@ export const TextEditor = React.memo<TextEditorProps>(
282
317
  return <a href={href} target="_blank" rel="noopener noreferrer" {...rest} />
283
318
  }
284
319
  return <a href={href} onClick={handleClick} className="text-primary hover:underline cursor-pointer" {...rest} />
285
- }, [handleTabSelect])
320
+ }, [handleTabSelect, props.activeDocumentId])
286
321
 
287
322
  /**
288
323
  * Single-document mode
package/dist/index.cjs CHANGED
@@ -1399,7 +1399,7 @@ var Icon = React3__namespace.memo(
1399
1399
  Icon.displayName = "Icon";
1400
1400
  var NavigationList = React3__namespace.memo(
1401
1401
  ({ items, onItemClick, className }) => {
1402
- return /* @__PURE__ */ jsxRuntime.jsx(SidebarMenu2, { className, children: items.map((item) => /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuItem2, { children: /* @__PURE__ */ jsxRuntime.jsx(
1402
+ return /* @__PURE__ */ jsxRuntime.jsx(SidebarMenu2, { className, children: items == null ? void 0 : items.map((item) => /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuItem2, { children: /* @__PURE__ */ jsxRuntime.jsx(
1403
1403
  SidebarMenuButton2,
1404
1404
  {
1405
1405
  tooltip: item.title,
@@ -1642,6 +1642,7 @@ var AppSidebar = React3__namespace.memo(
1642
1642
  var _b = _a, {
1643
1643
  logo,
1644
1644
  mainNavigation,
1645
+ navigationGroups,
1645
1646
  secondaryNavigation,
1646
1647
  documents,
1647
1648
  user,
@@ -1651,6 +1652,7 @@ var AppSidebar = React3__namespace.memo(
1651
1652
  } = _b, props = __objRest(_b, [
1652
1653
  "logo",
1653
1654
  "mainNavigation",
1655
+ "navigationGroups",
1654
1656
  "secondaryNavigation",
1655
1657
  "documents",
1656
1658
  "user",
@@ -1664,7 +1666,11 @@ var AppSidebar = React3__namespace.memo(
1664
1666
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-base font-semibold", children: logo.text })
1665
1667
  ] }) }) }) }) }),
1666
1668
  /* @__PURE__ */ jsxRuntime.jsxs(SidebarContent2, { children: [
1667
- /* @__PURE__ */ jsxRuntime.jsx(SidebarGroup2, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarGroupContent2, { children: /* @__PURE__ */ jsxRuntime.jsx(NavigationList, { items: mainNavigation }) }) }),
1669
+ mainNavigation && mainNavigation.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(SidebarGroup2, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarGroupContent2, { children: /* @__PURE__ */ jsxRuntime.jsx(NavigationList, { items: mainNavigation }) }) }),
1670
+ navigationGroups == null ? void 0 : navigationGroups.map((group) => /* @__PURE__ */ jsxRuntime.jsxs(SidebarGroup2, { children: [
1671
+ /* @__PURE__ */ jsxRuntime.jsx(SidebarGroupLabel2, { children: group.label }),
1672
+ /* @__PURE__ */ jsxRuntime.jsx(SidebarGroupContent2, { children: /* @__PURE__ */ jsxRuntime.jsx(NavigationList, { items: group.items }) })
1673
+ ] }, group.label)),
1668
1674
  documents && documents.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(SidebarGroup2, { children: [
1669
1675
  /* @__PURE__ */ jsxRuntime.jsx(SidebarGroupLabel2, { children: "Documents" }),
1670
1676
  /* @__PURE__ */ jsxRuntime.jsx(SidebarGroupContent2, { children: /* @__PURE__ */ jsxRuntime.jsx(NavigationList, { items: documents }) })
@@ -11694,7 +11700,39 @@ var TextEditor = React3__namespace.default.memo(
11694
11700
  if (!isExternal && !isAnchor && href) {
11695
11701
  e.preventDefault();
11696
11702
  let targetId = href;
11697
- if (targetId.startsWith("./")) {
11703
+ if (targetId.startsWith("file://")) {
11704
+ let path = targetId.replace("file://", "");
11705
+ if (path.match(/^\/[a-zA-Z]:\//)) {
11706
+ path = path.slice(1);
11707
+ }
11708
+ if (isMultiTab && props.documents) {
11709
+ const matchedDoc = props.documents.find((doc) => path.endsWith(doc.file.id) || path.endsWith("/" + doc.file.id));
11710
+ if (matchedDoc) {
11711
+ targetId = matchedDoc.file.id;
11712
+ } else {
11713
+ targetId = path;
11714
+ }
11715
+ } else {
11716
+ targetId = path;
11717
+ }
11718
+ } else if (props.activeDocumentId) {
11719
+ if (targetId.startsWith("/")) {
11720
+ targetId = targetId.slice(1);
11721
+ } else {
11722
+ const baseParts = props.activeDocumentId.split("/");
11723
+ baseParts.pop();
11724
+ const targetParts = targetId.split("/");
11725
+ for (const part of targetParts) {
11726
+ if (part === "." || part === "") continue;
11727
+ if (part === "..") {
11728
+ if (baseParts.length > 0) baseParts.pop();
11729
+ } else {
11730
+ baseParts.push(part);
11731
+ }
11732
+ }
11733
+ targetId = baseParts.join("/");
11734
+ }
11735
+ } else if (targetId.startsWith("./")) {
11698
11736
  targetId = targetId.slice(2);
11699
11737
  }
11700
11738
  if (handleTabSelect) {
@@ -11706,7 +11744,7 @@ var TextEditor = React3__namespace.default.memo(
11706
11744
  return /* @__PURE__ */ jsxRuntime.jsx("a", __spreadValues({ href, target: "_blank", rel: "noopener noreferrer" }, rest));
11707
11745
  }
11708
11746
  return /* @__PURE__ */ jsxRuntime.jsx("a", __spreadValues({ href, onClick: handleClick, className: "text-primary hover:underline cursor-pointer" }, rest));
11709
- }, [handleTabSelect]);
11747
+ }, [handleTabSelect, props.activeDocumentId]);
11710
11748
  if (!isMultiTab) {
11711
11749
  const format = props.format || "markdown";
11712
11750
  const isMarkdown = format === "markdown" || format === "md" || format === "mdx";