design-system-next 2.11.0 → 2.11.2

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.
Binary file
@@ -1,9 +1,9 @@
1
1
  declare const _default: {
2
2
  "name": "design-system-next",
3
3
  "private": false,
4
- "version": "2.11.0",
5
- "main": "./dist/design-system-next.js",
6
- "module": "./dist/design-system-next.js",
4
+ "version": "2.11.2",
5
+ "main": "./dist/design-system-next.umd.js",
6
+ "module": "./dist/design-system-next.es.js",
7
7
  "repository": {
8
8
  "type": "git",
9
9
  "url": "https://dev.azure.com/sproutphil/Sprout%20Design%20System/_git/Sprout%20Design%20System%20Next"
@@ -18,8 +18,8 @@ declare const _default: {
18
18
  ],
19
19
  "exports": {
20
20
  ".": {
21
- "import": "./dist/design-system-next.js",
22
- "require": "./dist/design-system-next.js"
21
+ "import": "./dist/design-system-next.es.js",
22
+ "require": "./dist/design-system-next.umd.js"
23
23
  },
24
24
  "./style.css": "./dist/main.css"
25
25
  },
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "design-system-next",
3
3
  "private": false,
4
- "version": "2.11.0",
5
- "main": "./dist/design-system-next.js",
6
- "module": "./dist/design-system-next.js",
4
+ "version": "2.11.2",
5
+ "main": "./dist/design-system-next.umd.js",
6
+ "module": "./dist/design-system-next.es.js",
7
7
  "repository": {
8
8
  "type": "git",
9
9
  "url": "https://dev.azure.com/sproutphil/Sprout%20Design%20System/_git/Sprout%20Design%20System%20Next"
@@ -18,8 +18,8 @@
18
18
  ],
19
19
  "exports": {
20
20
  ".": {
21
- "import": "./dist/design-system-next.js",
22
- "require": "./dist/design-system-next.js"
21
+ "import": "./dist/design-system-next.es.js",
22
+ "require": "./dist/design-system-next.umd.js"
23
23
  },
24
24
  "./style.css": "./dist/main.css"
25
25
  },
@@ -1,7 +1,7 @@
1
1
  import { ref, onMounted } from 'vue';
2
2
  import type { SetupContext } from 'vue';
3
3
 
4
- import type { SidenavPropTypes, SidenavEmitTypes, ParentLinkItem, NavLinks, NavItem } from './sidenav';
4
+ import type { SidenavPropTypes, SidenavEmitTypes, ParentLinkItem, NavLinks, NavItem, MenuLinkItem } from './sidenav';
5
5
 
6
6
  interface ObjectItem {
7
7
  redirect: {
@@ -68,6 +68,7 @@ export const useSidenav = (props: SidenavPropTypes, emit: SetupContext<SidenavEm
68
68
  const generateId = (...titles: string[]): string => {
69
69
  return titles.map(transformToCamelCaseId).join('_');
70
70
  }
71
+
71
72
  const confirmIfOwnDomain = (url: string) => {
72
73
  const domain = window.location.href;
73
74
  const urlHostname = new URL(url).hostname;
@@ -100,31 +101,47 @@ export const useSidenav = (props: SidenavPropTypes, emit: SetupContext<SidenavEm
100
101
  return Object.values(groups).map(group => ({ parentLinks: group.map(mapItemToNav) }));
101
102
  }
102
103
 
103
- const mapItemToNav = (item: NavItem): ParentLinkItem => {
104
- return {
105
- title: item.label,
106
- icon: item.icon || "",
107
- redirect: item.url
108
- ? {
109
- openInNewTab: item.isNewTab || false,
110
- isAbsoluteURL: !confirmIfOwnDomain(item.url),
111
- link: navLinkCondition(item) || "",
112
- }
113
- : undefined,
114
- menuLinks: item.children && item.children.length > 0
115
- ? [{
116
- menuHeading: '',
117
- items: item.children.map(child => mapItemToNav(child))
118
- }]
119
- : [],
120
- submenuLinks: item.children && item.children.length > 0 && !item.children.some(c => c.children)
121
- ? [{
122
- subMenuHeading: '',
123
- items: item.children.map(child => mapItemToNav(child)),
124
- }]
125
- : [],
126
- }
127
- }
104
+
105
+ const mapItemToNav = (item: NavItem): ParentLinkItem | MenuLinkItem => {
106
+ const groupChildrenByProperty = (
107
+ children: NavItem[] | undefined,
108
+ property: keyof NavItem
109
+ ): { [key: string]: NavItem[] } => {
110
+ if (!children || children.length === 0) return {};
111
+ return children.reduce((acc: Record<string, NavItem[]>, child) => {
112
+ const key = String(child[property] || '');
113
+ acc[key] = acc[key] || [];
114
+ acc[key].push(child);
115
+ return acc;
116
+ }, {});
117
+ };
118
+
119
+ const mapGroupedChildren = (
120
+ groupedChildren: { [key: string]: NavItem[] },
121
+ headingKey: 'menuHeading' | 'subMenuHeading'
122
+ ) => {
123
+ return Object.entries(groupedChildren).map(([groupName, groupItems]) => ({
124
+ [headingKey]: groupName,
125
+ items: groupItems.map(mapItemToNav),
126
+ }));
127
+ };
128
+
129
+ const groupedChildren = groupChildrenByProperty(item.children ?? undefined, 'groupName');
130
+
131
+ return {
132
+ title: item.label,
133
+ icon: item.icon || undefined,
134
+ redirect: item.url
135
+ ? {
136
+ openInNewTab: item.isNewTab || false,
137
+ isAbsoluteURL: !confirmIfOwnDomain(item.url as string),
138
+ link: navLinkCondition(item),
139
+ }
140
+ : undefined,
141
+ menuLinks: mapGroupedChildren(groupedChildren, 'menuHeading') as { menuHeading: string; items: ParentLinkItem[]; }[],
142
+ submenuLinks: mapGroupedChildren(groupedChildren, 'subMenuHeading') as { subMenuHeading: string; items: ParentLinkItem[]; }[],
143
+ };
144
+ };
128
145
 
129
146
  // Helper function to extract valid NavItems from an array of objects
130
147
  const extractValidNavItems = <T extends Record<string, unknown>>(items: T[]): NavItem[] => {
package/src/vite-env.d.ts DELETED
@@ -1,6 +0,0 @@
1
- interface ImportMeta { readonly glob: ImportMetaGlob }
2
-
3
- interface ImportMetaGlob {
4
- (pattern: string, options?: { eager?: boolean }): Record<string, () => Promise<unknown>>
5
- (pattern: string, options?: { eager: true }): Record<string, unknown>
6
- }