@dnanpm/ui-components 0.5.0 → 0.7.0

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.
Files changed (161) hide show
  1. package/README.md +3 -1
  2. package/dist/components/Accordion/Accordion.css +4 -4
  3. package/dist/components/Accordion/Accordion.module.css.cjs +3 -3
  4. package/dist/components/Accordion/Accordion.module.css.js +3 -3
  5. package/dist/components/AccordionItem/AccordionItem.css +19 -19
  6. package/dist/components/AccordionItem/AccordionItem.module.css.cjs +11 -11
  7. package/dist/components/AccordionItem/AccordionItem.module.css.js +11 -11
  8. package/dist/components/Breadcrumb/Breadcrumb.css +11 -12
  9. package/dist/components/Breadcrumb/Breadcrumb.module.css.cjs +6 -6
  10. package/dist/components/Breadcrumb/Breadcrumb.module.css.js +6 -6
  11. package/dist/components/Button/Button.cjs +3 -1
  12. package/dist/components/Button/Button.cjs.map +1 -1
  13. package/dist/components/Button/Button.css +33 -33
  14. package/dist/components/Button/Button.d.ts.map +1 -1
  15. package/dist/components/Button/Button.js +3 -1
  16. package/dist/components/Button/Button.js.map +1 -1
  17. package/dist/components/Button/Button.module.css.cjs +11 -11
  18. package/dist/components/Button/Button.module.css.js +11 -11
  19. package/dist/components/Footer/Footer.cjs +272 -0
  20. package/dist/components/Footer/Footer.cjs.map +1 -0
  21. package/dist/components/Footer/Footer.css +466 -0
  22. package/dist/components/Footer/Footer.d.ts +3 -0
  23. package/dist/components/Footer/Footer.d.ts.map +1 -0
  24. package/dist/components/Footer/Footer.js +272 -0
  25. package/dist/components/Footer/Footer.js.map +1 -0
  26. package/dist/components/Footer/Footer.module.css.cjs +80 -0
  27. package/dist/components/Footer/Footer.module.css.cjs.map +1 -0
  28. package/dist/components/Footer/Footer.module.css.js +80 -0
  29. package/dist/components/Footer/Footer.module.css.js.map +1 -0
  30. package/dist/components/Footer/Footer.types.d.ts +128 -0
  31. package/dist/components/Footer/Footer.types.d.ts.map +1 -0
  32. package/dist/components/Footer/Footer.utils.cjs +41 -0
  33. package/dist/components/Footer/Footer.utils.cjs.map +1 -0
  34. package/dist/components/Footer/Footer.utils.d.ts +13 -0
  35. package/dist/components/Footer/Footer.utils.d.ts.map +1 -0
  36. package/dist/components/Footer/Footer.utils.js +41 -0
  37. package/dist/components/Footer/Footer.utils.js.map +1 -0
  38. package/dist/components/Footer/assets/app-store-badge.svg.cjs +4 -0
  39. package/dist/components/Footer/assets/app-store-badge.svg.cjs.map +1 -0
  40. package/dist/components/Footer/assets/app-store-badge.svg.js +5 -0
  41. package/dist/components/Footer/assets/app-store-badge.svg.js.map +1 -0
  42. package/dist/components/Footer/assets/google-play-badge.svg.cjs +4 -0
  43. package/dist/components/Footer/assets/google-play-badge.svg.cjs.map +1 -0
  44. package/dist/components/Footer/assets/google-play-badge.svg.js +5 -0
  45. package/dist/components/Footer/assets/google-play-badge.svg.js.map +1 -0
  46. package/dist/components/Footer/index.d.ts +3 -0
  47. package/dist/components/Footer/index.d.ts.map +1 -0
  48. package/dist/components/Hero/Hero.cjs +31 -26
  49. package/dist/components/Hero/Hero.cjs.map +1 -1
  50. package/dist/components/Hero/Hero.css +96 -103
  51. package/dist/components/Hero/Hero.d.ts +1 -1
  52. package/dist/components/Hero/Hero.d.ts.map +1 -1
  53. package/dist/components/Hero/Hero.js +32 -27
  54. package/dist/components/Hero/Hero.js.map +1 -1
  55. package/dist/components/Hero/Hero.module.css.cjs +17 -19
  56. package/dist/components/Hero/Hero.module.css.cjs.map +1 -1
  57. package/dist/components/Hero/Hero.module.css.js +17 -19
  58. package/dist/components/Hero/Hero.module.css.js.map +1 -1
  59. package/dist/components/Hero/Hero.types.d.ts +9 -8
  60. package/dist/components/Hero/Hero.types.d.ts.map +1 -1
  61. package/dist/components/Hero/Hero.utils.cjs +5 -7
  62. package/dist/components/Hero/Hero.utils.cjs.map +1 -1
  63. package/dist/components/Hero/Hero.utils.d.ts +2 -2
  64. package/dist/components/Hero/Hero.utils.d.ts.map +1 -1
  65. package/dist/components/Hero/Hero.utils.js +5 -7
  66. package/dist/components/Hero/Hero.utils.js.map +1 -1
  67. package/dist/components/IconButton/IconButton.cjs +21 -5
  68. package/dist/components/IconButton/IconButton.cjs.map +1 -1
  69. package/dist/components/IconButton/IconButton.css +87 -83
  70. package/dist/components/IconButton/IconButton.d.ts +1 -1
  71. package/dist/components/IconButton/IconButton.d.ts.map +1 -1
  72. package/dist/components/IconButton/IconButton.js +22 -6
  73. package/dist/components/IconButton/IconButton.js.map +1 -1
  74. package/dist/components/IconButton/IconButton.module.css.cjs +9 -10
  75. package/dist/components/IconButton/IconButton.module.css.cjs.map +1 -1
  76. package/dist/components/IconButton/IconButton.module.css.js +9 -10
  77. package/dist/components/IconButton/IconButton.module.css.js.map +1 -1
  78. package/dist/components/IconButton/IconButton.types.d.ts +15 -10
  79. package/dist/components/IconButton/IconButton.types.d.ts.map +1 -1
  80. package/dist/components/IconButton/index.d.ts +1 -1
  81. package/dist/components/IconButton/index.d.ts.map +1 -1
  82. package/dist/components/Label/Label.css +13 -8
  83. package/dist/components/Label/Label.module.css.cjs +7 -7
  84. package/dist/components/Label/Label.module.css.js +7 -7
  85. package/dist/components/MainNavigation/MainNavigation.cjs +1110 -0
  86. package/dist/components/MainNavigation/MainNavigation.cjs.map +1 -0
  87. package/dist/components/MainNavigation/MainNavigation.css +946 -0
  88. package/dist/components/MainNavigation/MainNavigation.d.ts +3 -0
  89. package/dist/components/MainNavigation/MainNavigation.d.ts.map +1 -0
  90. package/dist/components/MainNavigation/MainNavigation.js +1110 -0
  91. package/dist/components/MainNavigation/MainNavigation.js.map +1 -0
  92. package/dist/components/MainNavigation/MainNavigation.module.css.cjs +74 -0
  93. package/dist/components/MainNavigation/MainNavigation.module.css.cjs.map +1 -0
  94. package/dist/components/MainNavigation/MainNavigation.module.css.js +75 -0
  95. package/dist/components/MainNavigation/MainNavigation.module.css.js.map +1 -0
  96. package/dist/components/MainNavigation/MainNavigation.types.d.ts +149 -0
  97. package/dist/components/MainNavigation/MainNavigation.types.d.ts.map +1 -0
  98. package/dist/components/MainNavigation/MainNavigation.utils.cjs +168 -0
  99. package/dist/components/MainNavigation/MainNavigation.utils.cjs.map +1 -0
  100. package/dist/components/MainNavigation/MainNavigation.utils.d.ts +29 -0
  101. package/dist/components/MainNavigation/MainNavigation.utils.d.ts.map +1 -0
  102. package/dist/components/MainNavigation/MainNavigation.utils.js +168 -0
  103. package/dist/components/MainNavigation/MainNavigation.utils.js.map +1 -0
  104. package/dist/components/MainNavigation/index.d.ts +3 -0
  105. package/dist/components/MainNavigation/index.d.ts.map +1 -0
  106. package/dist/components/Notification/Notification.css +14 -14
  107. package/dist/components/Notification/Notification.module.css.cjs +9 -9
  108. package/dist/components/Notification/Notification.module.css.js +9 -9
  109. package/dist/components/Pictograph/Pictograph.css +69 -57
  110. package/dist/components/Pictograph/Pictograph.module.css.cjs +11 -11
  111. package/dist/components/Pictograph/Pictograph.module.css.js +11 -11
  112. package/dist/components/Pictograph/Pictograph.types.d.ts +2 -2
  113. package/dist/components/Pictograph/PictographItem.cjs +15 -4
  114. package/dist/components/Pictograph/PictographItem.cjs.map +1 -1
  115. package/dist/components/Pictograph/PictographItem.css +26 -23
  116. package/dist/components/Pictograph/PictographItem.d.ts.map +1 -1
  117. package/dist/components/Pictograph/PictographItem.js +15 -4
  118. package/dist/components/Pictograph/PictographItem.js.map +1 -1
  119. package/dist/components/Pictograph/PictographItem.module.css.cjs +3 -3
  120. package/dist/components/Pictograph/PictographItem.module.css.js +3 -3
  121. package/dist/components/Quote/Quote.cjs +32 -0
  122. package/dist/components/Quote/Quote.cjs.map +1 -0
  123. package/dist/components/Quote/Quote.css +95 -0
  124. package/dist/components/Quote/Quote.d.ts +3 -0
  125. package/dist/components/Quote/Quote.d.ts.map +1 -0
  126. package/dist/components/Quote/Quote.js +32 -0
  127. package/dist/components/Quote/Quote.js.map +1 -0
  128. package/dist/components/Quote/Quote.module.css.cjs +22 -0
  129. package/dist/components/Quote/Quote.module.css.cjs.map +1 -0
  130. package/dist/components/Quote/Quote.module.css.js +22 -0
  131. package/dist/components/Quote/Quote.module.css.js.map +1 -0
  132. package/dist/components/Quote/Quote.types.d.ts +12 -0
  133. package/dist/components/Quote/Quote.types.d.ts.map +1 -0
  134. package/dist/components/Quote/index.d.ts +3 -0
  135. package/dist/components/Quote/index.d.ts.map +1 -0
  136. package/dist/index.cjs +6 -0
  137. package/dist/index.cjs.map +1 -1
  138. package/dist/index.d.ts +7 -1
  139. package/dist/index.d.ts.map +1 -1
  140. package/dist/index.js +6 -0
  141. package/dist/index.js.map +1 -1
  142. package/dist/styles/utils/elevation.css +20 -17
  143. package/dist/styles/utils/elevation.module.css.cjs +4 -4
  144. package/dist/styles/utils/elevation.module.css.js +4 -4
  145. package/dist/styles/utils/focus.css +23 -14
  146. package/dist/styles/utils/focus.module.css.cjs +6 -3
  147. package/dist/styles/utils/focus.module.css.cjs.map +1 -1
  148. package/dist/styles/utils/focus.module.css.js +7 -4
  149. package/dist/styles/utils/focus.module.css.js.map +1 -1
  150. package/dist/styles/utils/overlay.css +37 -0
  151. package/dist/styles/utils/overlay.module.css.cjs +13 -0
  152. package/dist/styles/utils/overlay.module.css.cjs.map +1 -0
  153. package/dist/styles/utils/overlay.module.css.js +13 -0
  154. package/dist/styles/utils/overlay.module.css.js.map +1 -0
  155. package/dist/styles/utils/text-decoration.css +8 -1
  156. package/dist/styles/utils/text-decoration.module.css.cjs +5 -2
  157. package/dist/styles/utils/text-decoration.module.css.cjs.map +1 -1
  158. package/dist/styles/utils/text-decoration.module.css.js +6 -3
  159. package/dist/styles/utils/text-decoration.module.css.js.map +1 -1
  160. package/dist/styles.css +141 -92
  161. package/package.json +2 -1
@@ -0,0 +1,168 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const relativeNavigationBaseUrl = "https://navigation.local";
4
+ const safeLinkProtocols = /* @__PURE__ */ new Set(["http:", "https:", "mailto:", "tel:"]);
5
+ const isDesktopViewportByEnvironment = (windowObject) => {
6
+ if (windowObject == null) {
7
+ return false;
8
+ }
9
+ if (typeof windowObject.matchMedia === "function") {
10
+ return windowObject.matchMedia("(min-width: 1024px)").matches;
11
+ }
12
+ return windowObject.innerWidth >= 1024;
13
+ };
14
+ const isMobileViewportByEnvironment = (windowObject) => {
15
+ if (windowObject == null) {
16
+ return false;
17
+ }
18
+ if (typeof windowObject.matchMedia === "function") {
19
+ return windowObject.matchMedia("(max-width: 1023px)").matches;
20
+ }
21
+ return windowObject.innerWidth < 1024;
22
+ };
23
+ const isMobileIosDeviceByEnvironment = (windowObject, navigatorObject) => {
24
+ if (windowObject == null || navigatorObject == null) {
25
+ return false;
26
+ }
27
+ const isIOS = /iPad|iPhone|iPod/.test(navigatorObject.userAgent) && !("MSStream" in windowObject);
28
+ return isIOS && windowObject.innerWidth < 768;
29
+ };
30
+ const isExternalTarget = (target) => target === "_blank";
31
+ const isExternalLink = (link) => {
32
+ if (link.external != null) {
33
+ return link.external;
34
+ }
35
+ return isExternalTarget(link.target);
36
+ };
37
+ const getLinkRel = (target) => isExternalTarget(target) ? "noopener noreferrer" : void 0;
38
+ const getLinkTarget = (target) => isExternalTarget(target) ? "_blank" : void 0;
39
+ const normalizePathname = (value) => {
40
+ const path = value.split("?")[0].split("#")[0] || "/";
41
+ const withLeadingSlash = path.startsWith("/") ? path : `/${path}`;
42
+ if (withLeadingSlash === "/") {
43
+ return "/";
44
+ }
45
+ return withLeadingSlash.replace(/\/+$/, "");
46
+ };
47
+ const toNavigableHref = (href) => {
48
+ const normalizedHref = href.trim();
49
+ if (normalizedHref === "") {
50
+ return "#";
51
+ }
52
+ const hrefWithProtocol = normalizedHref.toLowerCase().startsWith("www.") ? `https://${normalizedHref}` : normalizedHref;
53
+ if (hrefWithProtocol.startsWith("./") || hrefWithProtocol.startsWith("../")) {
54
+ return hrefWithProtocol;
55
+ }
56
+ if (hrefWithProtocol.startsWith("/") || hrefWithProtocol.startsWith("#") || hrefWithProtocol.startsWith("?")) {
57
+ return hrefWithProtocol;
58
+ }
59
+ const hasScheme = /^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(hrefWithProtocol);
60
+ if (!hasScheme) {
61
+ return hrefWithProtocol;
62
+ }
63
+ try {
64
+ const protocol = new URL(
65
+ hrefWithProtocol,
66
+ relativeNavigationBaseUrl
67
+ ).protocol.toLowerCase();
68
+ if (safeLinkProtocols.has(protocol)) {
69
+ return hrefWithProtocol;
70
+ }
71
+ } catch {
72
+ return "#";
73
+ }
74
+ return "#";
75
+ };
76
+ const toPathname = (href) => {
77
+ if (href == null || href.trim() === "" || href === "#") {
78
+ return null;
79
+ }
80
+ if (href.startsWith("/")) {
81
+ return normalizePathname(href);
82
+ }
83
+ try {
84
+ return normalizePathname(new URL(href).pathname);
85
+ } catch {
86
+ return normalizePathname(href);
87
+ }
88
+ };
89
+ const matchesPath = (currentPathname, linkPathname) => {
90
+ if (linkPathname === "/") {
91
+ return currentPathname === "/";
92
+ }
93
+ return currentPathname === linkPathname || currentPathname.startsWith(`${linkPathname}/`);
94
+ };
95
+ const isLinkInCurrentPath = (link, currentPathname) => {
96
+ if (link.current) {
97
+ return true;
98
+ }
99
+ if (isExternalLink(link)) {
100
+ return false;
101
+ }
102
+ if (currentPathname == null) {
103
+ return false;
104
+ }
105
+ const linkPathname = toPathname(toNavigableHref(link.href));
106
+ if (linkPathname == null) {
107
+ return false;
108
+ }
109
+ return matchesPath(normalizePathname(currentPathname), linkPathname);
110
+ };
111
+ const hasHref = (item) => typeof item.href === "string" && item.href.trim().length > 0;
112
+ const isItemInCurrentPath = (item, currentPathname) => {
113
+ if (hasHref(item) && isLinkInCurrentPath(item, currentPathname)) {
114
+ return true;
115
+ }
116
+ if (item.panel?.columns?.some(
117
+ (column) => column.links.some((link) => isLinkInCurrentPath(link, currentPathname))
118
+ )) {
119
+ return true;
120
+ }
121
+ return item.panel?.featureLinks?.some((link) => isLinkInCurrentPath(link, currentPathname)) ?? false;
122
+ };
123
+ const isLinkInCurrentPage = (link, currentPathname) => {
124
+ if (link.current) {
125
+ return true;
126
+ }
127
+ if (isExternalLink(link)) {
128
+ return false;
129
+ }
130
+ if (currentPathname == null) {
131
+ return false;
132
+ }
133
+ const linkPathname = toPathname(toNavigableHref(link.href));
134
+ if (linkPathname == null) {
135
+ return false;
136
+ }
137
+ return normalizePathname(currentPathname) === linkPathname;
138
+ };
139
+ const isRefObject = (target) => typeof target === "object" && target !== null && "current" in target;
140
+ const assignRef = (target, value) => {
141
+ if (target == null) {
142
+ return;
143
+ }
144
+ if (typeof target === "function") {
145
+ target(value);
146
+ return;
147
+ }
148
+ if (isRefObject(target)) {
149
+ target.current = value;
150
+ }
151
+ };
152
+ exports.assignRef = assignRef;
153
+ exports.getLinkRel = getLinkRel;
154
+ exports.getLinkTarget = getLinkTarget;
155
+ exports.hasHref = hasHref;
156
+ exports.isDesktopViewportByEnvironment = isDesktopViewportByEnvironment;
157
+ exports.isExternalLink = isExternalLink;
158
+ exports.isExternalTarget = isExternalTarget;
159
+ exports.isItemInCurrentPath = isItemInCurrentPath;
160
+ exports.isLinkInCurrentPage = isLinkInCurrentPage;
161
+ exports.isLinkInCurrentPath = isLinkInCurrentPath;
162
+ exports.isMobileIosDeviceByEnvironment = isMobileIosDeviceByEnvironment;
163
+ exports.isMobileViewportByEnvironment = isMobileViewportByEnvironment;
164
+ exports.matchesPath = matchesPath;
165
+ exports.normalizePathname = normalizePathname;
166
+ exports.toNavigableHref = toNavigableHref;
167
+ exports.toPathname = toPathname;
168
+ //# sourceMappingURL=MainNavigation.utils.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MainNavigation.utils.cjs","sources":["../../../src/components/MainNavigation/MainNavigation.utils.ts"],"sourcesContent":["import type { Ref } from 'react';\nimport type { MainNavigationItem, MainNavigationLink } from './MainNavigation.types';\n\nconst relativeNavigationBaseUrl = 'https://navigation.local';\nconst safeLinkProtocols = new Set(['http:', 'https:', 'mailto:', 'tel:']);\n\nexport type MainNavigationWindowLike = {\n innerWidth: number;\n matchMedia?: (query: string) => Pick<MediaQueryList, 'matches'>;\n MSStream?: unknown;\n};\n\nexport type MainNavigationNavigatorLike = {\n userAgent: string;\n};\n\nexport const isDesktopViewportByEnvironment = (\n windowObject: MainNavigationWindowLike | undefined,\n) => {\n if (windowObject == null) {\n return false;\n }\n\n if (typeof windowObject.matchMedia === 'function') {\n return windowObject.matchMedia('(min-width: 1024px)').matches;\n }\n\n return windowObject.innerWidth >= 1024;\n};\n\nexport const isMobileViewportByEnvironment = (\n windowObject: MainNavigationWindowLike | undefined,\n) => {\n if (windowObject == null) {\n return false;\n }\n\n if (typeof windowObject.matchMedia === 'function') {\n return windowObject.matchMedia('(max-width: 1023px)').matches;\n }\n\n return windowObject.innerWidth < 1024;\n};\n\nexport const isMobileIosDeviceByEnvironment = (\n windowObject: MainNavigationWindowLike | undefined,\n navigatorObject: MainNavigationNavigatorLike | undefined,\n) => {\n if (windowObject == null || navigatorObject == null) {\n return false;\n }\n\n const isIOS =\n /iPad|iPhone|iPod/.test(navigatorObject.userAgent) && !('MSStream' in windowObject);\n return isIOS && windowObject.innerWidth < 768;\n};\n\nexport const isExternalTarget = (target?: string) => target === '_blank';\n\nexport const isExternalLink = (link: Pick<MainNavigationLink, 'target' | 'external'>) => {\n if (link.external != null) {\n return link.external;\n }\n\n return isExternalTarget(link.target);\n};\n\nexport const getLinkRel = (target?: string) =>\n isExternalTarget(target) ? 'noopener noreferrer' : undefined;\n\nexport const getLinkTarget = (target?: string) => (isExternalTarget(target) ? '_blank' : undefined);\n\nexport const normalizePathname = (value: string) => {\n const path = value.split('?')[0].split('#')[0] || '/';\n const withLeadingSlash = path.startsWith('/') ? path : `/${path}`;\n\n if (withLeadingSlash === '/') {\n return '/';\n }\n\n return withLeadingSlash.replace(/\\/+$/, '');\n};\n\nexport const toNavigableHref = (href: string) => {\n const normalizedHref = href.trim();\n\n if (normalizedHref === '') {\n return '#';\n }\n\n const hrefWithProtocol = normalizedHref.toLowerCase().startsWith('www.')\n ? `https://${normalizedHref}`\n : normalizedHref;\n\n if (hrefWithProtocol.startsWith('./') || hrefWithProtocol.startsWith('../')) {\n return hrefWithProtocol;\n }\n\n if (\n hrefWithProtocol.startsWith('/') ||\n hrefWithProtocol.startsWith('#') ||\n hrefWithProtocol.startsWith('?')\n ) {\n return hrefWithProtocol;\n }\n\n const hasScheme = /^[a-zA-Z][a-zA-Z\\d+\\-.]*:/.test(hrefWithProtocol);\n\n if (!hasScheme) {\n return hrefWithProtocol;\n }\n\n try {\n const protocol = new URL(\n hrefWithProtocol,\n relativeNavigationBaseUrl,\n ).protocol.toLowerCase();\n if (safeLinkProtocols.has(protocol)) {\n return hrefWithProtocol;\n }\n } catch {\n return '#';\n }\n\n return '#';\n};\n\nexport const toPathname = (href?: string) => {\n if (href == null || href.trim() === '' || href === '#') {\n return null;\n }\n\n if (href.startsWith('/')) {\n return normalizePathname(href);\n }\n\n try {\n return normalizePathname(new URL(href).pathname);\n } catch {\n return normalizePathname(href);\n }\n};\n\nexport const matchesPath = (currentPathname: string, linkPathname: string) => {\n if (linkPathname === '/') {\n return currentPathname === '/';\n }\n\n return currentPathname === linkPathname || currentPathname.startsWith(`${linkPathname}/`);\n};\n\nexport const isLinkInCurrentPath = (link: MainNavigationLink, currentPathname?: string) => {\n if (link.current) {\n return true;\n }\n\n if (isExternalLink(link)) {\n return false;\n }\n\n if (currentPathname == null) {\n return false;\n }\n\n const linkPathname = toPathname(toNavigableHref(link.href));\n\n if (linkPathname == null) {\n return false;\n }\n\n return matchesPath(normalizePathname(currentPathname), linkPathname);\n};\n\nexport const hasHref = (item: MainNavigationItem): item is MainNavigationItem & { href: string } =>\n typeof item.href === 'string' && item.href.trim().length > 0;\n\nexport const isItemInCurrentPath = (item: MainNavigationItem, currentPathname?: string) => {\n if (hasHref(item) && isLinkInCurrentPath(item, currentPathname)) {\n return true;\n }\n\n if (\n item.panel?.columns?.some((column) =>\n column.links.some((link) => isLinkInCurrentPath(link, currentPathname)),\n )\n ) {\n return true;\n }\n\n return (\n item.panel?.featureLinks?.some((link) => isLinkInCurrentPath(link, currentPathname)) ??\n false\n );\n};\n\nexport const isLinkInCurrentPage = (link: MainNavigationLink, currentPathname?: string) => {\n if (link.current) {\n return true;\n }\n\n if (isExternalLink(link)) {\n return false;\n }\n\n if (currentPathname == null) {\n return false;\n }\n\n const linkPathname = toPathname(toNavigableHref(link.href));\n\n if (linkPathname == null) {\n return false;\n }\n\n return normalizePathname(currentPathname) === linkPathname;\n};\n\nconst isRefObject = <T>(target: Ref<T>): target is { current: T | null } =>\n typeof target === 'object' && target !== null && 'current' in target;\n\nexport const assignRef = <T>(target: Ref<T> | undefined, value: T | null) => {\n if (target == null) {\n return;\n }\n\n if (typeof target === 'function') {\n target(value);\n return;\n }\n\n if (isRefObject(target)) {\n target.current = value;\n }\n};\n"],"names":[],"mappings":";;AAGA,MAAM,4BAA4B;AAClC,MAAM,wCAAwB,IAAI,CAAC,SAAS,UAAU,WAAW,MAAM,CAAC;AAYjE,MAAM,iCAAiC,CAC1C,iBACC;AACD,MAAI,gBAAgB,MAAM;AACtB,WAAO;AAAA,EACX;AAEA,MAAI,OAAO,aAAa,eAAe,YAAY;AAC/C,WAAO,aAAa,WAAW,qBAAqB,EAAE;AAAA,EAC1D;AAEA,SAAO,aAAa,cAAc;AACtC;AAEO,MAAM,gCAAgC,CACzC,iBACC;AACD,MAAI,gBAAgB,MAAM;AACtB,WAAO;AAAA,EACX;AAEA,MAAI,OAAO,aAAa,eAAe,YAAY;AAC/C,WAAO,aAAa,WAAW,qBAAqB,EAAE;AAAA,EAC1D;AAEA,SAAO,aAAa,aAAa;AACrC;AAEO,MAAM,iCAAiC,CAC1C,cACA,oBACC;AACD,MAAI,gBAAgB,QAAQ,mBAAmB,MAAM;AACjD,WAAO;AAAA,EACX;AAEA,QAAM,QACF,mBAAmB,KAAK,gBAAgB,SAAS,KAAK,EAAE,cAAc;AAC1E,SAAO,SAAS,aAAa,aAAa;AAC9C;AAEO,MAAM,mB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AK,CAAC,SAAS,oBAAoB,MAAM,eAAe,CAAC,KACnF;AAER;AAEO,MAAM,sBAAsB,CAAC,MAA0B,oBAA6B;AACvF,MAAI,KAAK,SAAS;AACd,WAAO;AAAA,EACX;AAEA,MAAI,eAAe,IAAI,GAAG;AACtB,WAAO;AAAA,EACX;AAEA,MAAI,mBAAmB,MAAM;AACzB,WAAO;AAAA,EACX;AAEA,QAAM,eAAe,WAAW,gBAAgB,KAAK,IAAI,CAAC;AAE1D,MAAI,gBAAgB,MAAM;AACtB,WAAO;AAAA,EACX;AAEA,SAAO,kBAAkB,eAAe,MAAM;AAClD;AAEA,MAAM,cAAc,CAAI,WACpB,OAAO,WAAW,YAAY,WAAW,QAAQ,aAAa;AAE3D,MAAM,YAAY,CAAI,QAA4B,UAAoB;AACzE,MAAI,UAAU,MAAM;AAChB;AAAA,EACJ;AAEA,MAAI,OAAO,WAAW,YAAY;AAC9B,WAAO,KAAK;AACZ;AAAA,EACJ;AAEA,MAAI,YAAY,MAAM,GAAG;AACrB,WAAO,UAAU;AAAA,EACrB;AACJ;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,29 @@
1
+ import { Ref } from 'react';
2
+ import { MainNavigationItem, MainNavigationLink } from './MainNavigation.types';
3
+ export type MainNavigationWindowLike = {
4
+ innerWidth: number;
5
+ matchMedia?: (query: string) => Pick<MediaQueryList, 'matches'>;
6
+ MSStream?: unknown;
7
+ };
8
+ export type MainNavigationNavigatorLike = {
9
+ userAgent: string;
10
+ };
11
+ export declare const isDesktopViewportByEnvironment: (windowObject: MainNavigationWindowLike | undefined) => boolean;
12
+ export declare const isMobileViewportByEnvironment: (windowObject: MainNavigationWindowLike | undefined) => boolean;
13
+ export declare const isMobileIosDeviceByEnvironment: (windowObject: MainNavigationWindowLike | undefined, navigatorObject: MainNavigationNavigatorLike | undefined) => boolean;
14
+ export declare const isExternalTarget: (target?: string) => target is "_blank";
15
+ export declare const isExternalLink: (link: Pick<MainNavigationLink, "target" | "external">) => boolean;
16
+ export declare const getLinkRel: (target?: string) => "noopener noreferrer" | undefined;
17
+ export declare const getLinkTarget: (target?: string) => "_blank" | undefined;
18
+ export declare const normalizePathname: (value: string) => string;
19
+ export declare const toNavigableHref: (href: string) => string;
20
+ export declare const toPathname: (href?: string) => string | null;
21
+ export declare const matchesPath: (currentPathname: string, linkPathname: string) => boolean;
22
+ export declare const isLinkInCurrentPath: (link: MainNavigationLink, currentPathname?: string) => boolean;
23
+ export declare const hasHref: (item: MainNavigationItem) => item is MainNavigationItem & {
24
+ href: string;
25
+ };
26
+ export declare const isItemInCurrentPath: (item: MainNavigationItem, currentPathname?: string) => boolean;
27
+ export declare const isLinkInCurrentPage: (link: MainNavigationLink, currentPathname?: string) => boolean;
28
+ export declare const assignRef: <T>(target: Ref<T> | undefined, value: T | null) => void;
29
+ //# sourceMappingURL=MainNavigation.utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MainNavigation.utils.d.ts","sourceRoot":"","sources":["../../../src/components/MainNavigation/MainNavigation.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAKrF,MAAM,MAAM,wBAAwB,GAAG;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;IAChE,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACtC,SAAS,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,8BAA8B,GACvC,cAAc,wBAAwB,GAAG,SAAS,YAWrD,CAAC;AAEF,eAAO,MAAM,6BAA6B,GACtC,cAAc,wBAAwB,GAAG,SAAS,YAWrD,CAAC;AAEF,eAAO,MAAM,8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esktopViewportByEnvironment = (windowObject) => {
4
+ if (windowObject == null) {
5
+ return false;
6
+ }
7
+ if (typeof windowObject.matchMedia === "function") {
8
+ return windowObject.matchMedia("(min-width: 1024px)").matches;
9
+ }
10
+ return windowObject.innerWidth >= 1024;
11
+ };
12
+ const isMobileViewportByEnvironment = (windowObject) => {
13
+ if (windowObject == null) {
14
+ return false;
15
+ }
16
+ if (typeof windowObject.matchMedia === "function") {
17
+ return windowObject.matchMedia("(max-width: 1023px)").matches;
18
+ }
19
+ return windowObject.innerWidth < 1024;
20
+ };
21
+ const isMobileIosDeviceByEnvironment = (windowObject, navigatorObject) => {
22
+ if (windowObject == null || navigatorObject == null) {
23
+ return false;
24
+ }
25
+ const isIOS = /iPad|iPhone|iPod/.test(navigatorObject.userAgent) && !("MSStream" in windowObject);
26
+ return isIOS && windowObject.innerWidth < 768;
27
+ };
28
+ const isExternalTarget = (target) => target === "_blank";
29
+ const isExternalLink = (link) => {
30
+ if (link.external != null) {
31
+ return link.external;
32
+ }
33
+ return isExternalTarget(link.target);
34
+ };
35
+ const getLinkRel = (target) => isExternalTarget(target) ? "noopener noreferrer" : void 0;
36
+ const getLinkTarget = (target) => isExternalTarget(target) ? "_blank" : void 0;
37
+ const normalizePathname = (value) => {
38
+ const path = value.split("?")[0].split("#")[0] || "/";
39
+ const withLeadingSlash = path.startsWith("/") ? path : `/${path}`;
40
+ if (withLeadingSlash === "/") {
41
+ return "/";
42
+ }
43
+ return withLeadingSlash.replace(/\/+$/, "");
44
+ };
45
+ const toNavigableHref = (href) => {
46
+ const normalizedHref = href.trim();
47
+ if (normalizedHref === "") {
48
+ return "#";
49
+ }
50
+ const hrefWithProtocol = normalizedHref.toLowerCase().startsWith("www.") ? `https://${normalizedHref}` : normalizedHref;
51
+ if (hrefWithProtocol.startsWith("./") || hrefWithProtocol.startsWith("../")) {
52
+ return hrefWithProtocol;
53
+ }
54
+ if (hrefWithProtocol.startsWith("/") || hrefWithProtocol.startsWith("#") || hrefWithProtocol.startsWith("?")) {
55
+ return hrefWithProtocol;
56
+ }
57
+ const hasScheme = /^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(hrefWithProtocol);
58
+ if (!hasScheme) {
59
+ return hrefWithProtocol;
60
+ }
61
+ try {
62
+ const protocol = new URL(
63
+ hrefWithProtocol,
64
+ relativeNavigationBaseUrl
65
+ ).protocol.toLowerCase();
66
+ if (safeLinkProtocols.has(protocol)) {
67
+ return hrefWithProtocol;
68
+ }
69
+ } catch {
70
+ return "#";
71
+ }
72
+ return "#";
73
+ };
74
+ const toPathname = (href) => {
75
+ if (href == null || href.trim() === "" || href === "#") {
76
+ return null;
77
+ }
78
+ if (href.startsWith("/")) {
79
+ return normalizePathname(href);
80
+ }
81
+ try {
82
+ return normalizePathname(new URL(href).pathname);
83
+ } catch {
84
+ return normalizePathname(href);
85
+ }
86
+ };
87
+ const matchesPath = (currentPathname, linkPathname) => {
88
+ if (linkPathname === "/") {
89
+ return currentPathname === "/";
90
+ }
91
+ return currentPathname === linkPathname || currentPathname.startsWith(`${linkPathname}/`);
92
+ };
93
+ const isLinkInCurrentPath = (link, currentPathname) => {
94
+ if (link.current) {
95
+ return true;
96
+ }
97
+ if (isExternalLink(link)) {
98
+ return false;
99
+ }
100
+ if (currentPathname == null) {
101
+ return false;
102
+ }
103
+ const linkPathname = toPathname(toNavigableHref(link.href));
104
+ if (linkPathname == null) {
105
+ return false;
106
+ }
107
+ return matchesPath(normalizePathname(currentPathname), linkPathname);
108
+ };
109
+ const hasHref = (item) => typeof item.href === "string" && item.href.trim().length > 0;
110
+ const isItemInCurrentPath = (item, currentPathname) => {
111
+ if (hasHref(item) && isLinkInCurrentPath(item, currentPathname)) {
112
+ return true;
113
+ }
114
+ if (item.panel?.columns?.some(
115
+ (column) => column.links.some((link) => isLinkInCurrentPath(link, currentPathname))
116
+ )) {
117
+ return true;
118
+ }
119
+ return item.panel?.featureLinks?.some((link) => isLinkInCurrentPath(link, currentPathname)) ?? false;
120
+ };
121
+ const isLinkInCurrentPage = (link, currentPathname) => {
122
+ if (link.current) {
123
+ return true;
124
+ }
125
+ if (isExternalLink(link)) {
126
+ return false;
127
+ }
128
+ if (currentPathname == null) {
129
+ return false;
130
+ }
131
+ const linkPathname = toPathname(toNavigableHref(link.href));
132
+ if (linkPathname == null) {
133
+ return false;
134
+ }
135
+ return normalizePathname(currentPathname) === linkPathname;
136
+ };
137
+ const isRefObject = (target) => typeof target === "object" && target !== null && "current" in target;
138
+ const assignRef = (target, value) => {
139
+ if (target == null) {
140
+ return;
141
+ }
142
+ if (typeof target === "function") {
143
+ target(value);
144
+ return;
145
+ }
146
+ if (isRefObject(target)) {
147
+ target.current = value;
148
+ }
149
+ };
150
+ export {
151
+ assignRef,
152
+ getLinkRel,
153
+ getLinkTarget,
154
+ hasHref,
155
+ isDesktopViewportByEnvironment,
156
+ isExternalLink,
157
+ isExternalTarget,
158
+ isItemInCurrentPath,
159
+ isLinkInCurrentPage,
160
+ isLinkInCurrentPath,
161
+ isMobileIosDeviceByEnvironment,
162
+ isMobileViewportByEnvironment,
163
+ matchesPath,
164
+ normalizePathname,
165
+ toNavigableHref,
166
+ toPathname
167
+ };
168
+ //# sourceMappingURL=MainNavigation.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MainNavigation.utils.js","sources":["../../../src/components/MainNavigation/MainNavigation.utils.ts"],"sourcesContent":["import type { Ref } from 'react';\nimport type { MainNavigationItem, MainNavigationLink } from './MainNavigation.types';\n\nconst relativeNavigationBaseUrl = 'https://navigation.local';\nconst safeLinkProtocols = new Set(['http:', 'https:', 'mailto:', 'tel:']);\n\nexport type MainNavigationWindowLike = {\n innerWidth: number;\n matchMedia?: (query: string) => Pick<MediaQueryList, 'matches'>;\n MSStream?: unknown;\n};\n\nexport type MainNavigationNavigatorLike = {\n userAgent: string;\n};\n\nexport const isDesktopViewportByEnvironment = (\n windowObject: MainNavigationWindowLike | undefined,\n) => {\n if (windowObject == null) {\n return false;\n }\n\n if (typeof windowObject.matchMedia === 'function') {\n return windowObject.matchMedia('(min-width: 1024px)').matches;\n }\n\n return windowObject.innerWidth >= 1024;\n};\n\nexport const isMobileViewportByEnvironment = (\n windowObject: MainNavigationWindowLike | undefined,\n) => {\n if (windowObject == null) {\n return false;\n }\n\n if (typeof windowObject.matchMedia === 'function') {\n return windowObject.matchMedia('(max-width: 1023px)').matches;\n }\n\n return windowObject.innerWidth < 1024;\n};\n\nexport const isMobileIosDeviceByEnvironment = (\n windowObject: MainNavigationWindowLike | undefined,\n navigatorObject: MainNavigationNavigatorLike | undefined,\n) => {\n if (windowObject == null || navigatorObject == null) {\n return false;\n }\n\n const isIOS =\n /iPad|iPhone|iPod/.test(navigatorObject.userAgent) && !('MSStream' in windowObject);\n return isIOS && windowObject.innerWidth < 768;\n};\n\nexport const isExternalTarget = (target?: string) => target === '_blank';\n\nexport const isExternalLink = (link: Pick<MainNavigationLink, 'target' | 'external'>) => {\n if (link.external != null) {\n return link.external;\n }\n\n return isExternalTarget(link.target);\n};\n\nexport const getLinkRel = (target?: string) =>\n isExternalTarget(target) ? 'noopener noreferrer' : undefined;\n\nexport const getLinkTarget = (target?: string) => (isExternalTarget(target) ? '_blank' : undefined);\n\nexport const normalizePathname = (value: string) => {\n const path = value.split('?')[0].split('#')[0] || '/';\n const withLeadingSlash = path.startsWith('/') ? path : `/${path}`;\n\n if (withLeadingSlash === '/') {\n return '/';\n }\n\n return withLeadingSlash.replace(/\\/+$/, '');\n};\n\nexport const toNavigableHref = (href: string) => {\n const normalizedHref = href.trim();\n\n if (normalizedHref === '') {\n return '#';\n }\n\n const hrefWithProtocol = normalizedHref.toLowerCase().startsWith('www.')\n ? `https://${normalizedHref}`\n : normalizedHref;\n\n if (hrefWithProtocol.startsWith('./') || hrefWithProtocol.startsWith('../')) {\n return hrefWithProtocol;\n }\n\n if (\n hrefWithProtocol.startsWith('/') ||\n hrefWithProtocol.startsWith('#') ||\n hrefWithProtocol.startsWith('?')\n ) {\n return hrefWithProtocol;\n }\n\n const hasScheme = /^[a-zA-Z][a-zA-Z\\d+\\-.]*:/.test(hrefWithProtocol);\n\n if (!hasScheme) {\n return hrefWithProtocol;\n }\n\n try {\n const protocol = new URL(\n hrefWithProtocol,\n relativeNavigationBaseUrl,\n ).protocol.toLowerCase();\n if (safeLinkProtocols.has(protocol)) {\n return hrefWithProtocol;\n }\n } catch {\n return '#';\n }\n\n return '#';\n};\n\nexport const toPathname = (href?: string) => {\n if (href == null || href.trim() === '' || href === '#') {\n return null;\n }\n\n if (href.startsWith('/')) {\n return normalizePathname(href);\n }\n\n try {\n return normalizePathname(new URL(href).pathname);\n } catch {\n return normalizePathname(href);\n }\n};\n\nexport const matchesPath = (currentPathname: string, linkPathname: string) => {\n if (linkPathname === '/') {\n return currentPathname === '/';\n }\n\n return currentPathname === linkPathname || currentPathname.startsWith(`${linkPathname}/`);\n};\n\nexport const isLinkInCurrentPath = (link: MainNavigationLink, currentPathname?: string) => {\n if (link.current) {\n return true;\n }\n\n if (isExternalLink(link)) {\n return false;\n }\n\n if (currentPathname == null) {\n return false;\n }\n\n const linkPathname = toPathname(toNavigableHref(link.href));\n\n if (linkPathname == null) {\n return false;\n }\n\n return matchesPath(normalizePathname(currentPathname), linkPathname);\n};\n\nexport const hasHref = (item: MainNavigationItem): item is MainNavigationItem & { href: string } =>\n typeof item.href === 'string' && item.href.trim().length > 0;\n\nexport const isItemInCurrentPath = (item: MainNavigationItem, currentPathname?: string) => {\n if (hasHref(item) && isLinkInCurrentPath(item, currentPathname)) {\n return true;\n }\n\n if (\n item.panel?.columns?.some((column) =>\n column.links.some((link) => isLinkInCurrentPath(link, currentPathname)),\n )\n ) {\n return true;\n }\n\n return (\n item.panel?.featureLinks?.some((link) => isLinkInCurrentPath(link, currentPathname)) ??\n false\n );\n};\n\nexport const isLinkInCurrentPage = (link: MainNavigationLink, currentPathname?: string) => {\n if (link.current) {\n return true;\n }\n\n if (isExternalLink(link)) {\n return false;\n }\n\n if (currentPathname == null) {\n return false;\n }\n\n const linkPathname = toPathname(toNavigableHref(link.href));\n\n if (linkPathname == null) {\n return false;\n }\n\n return normalizePathname(currentPathname) === linkPathname;\n};\n\nconst isRefObject = <T>(target: Ref<T>): target is { current: T | null } =>\n typeof target === 'object' && target !== null && 'current' in target;\n\nexport const assignRef = <T>(target: Ref<T> | undefined, value: T | null) => {\n if (target == null) {\n return;\n }\n\n if (typeof target === 'function') {\n target(value);\n return;\n }\n\n if (isRefObject(target)) {\n target.current = value;\n }\n};\n"],"names":[],"mappings":"AAGA,MAAM,4BAA4B;AAClC,MAAM,wCAAwB,IAAI,CAAC,SAAS,UAAU,WAAW,MAAM,CAAC;AAYjE,MAAM,iCAAiC,CAC1C,iBACC;AACD,MAAI,gBAAgB,MAAM;AACtB,WAAO;AAAA,EACX;AAEA,MAAI,OAAO,aAAa,eAAe,YAAY;AAC/C,WAAO,aAAa,WAAW,qBAAqB,EAAE;AAAA,EAC1D;AAEA,SAAO,aAAa,cAAc;AACtC;AAEO,MAAM,gCAAgC,CACzC,iBACC;AACD,MAAI,gBAAgB,MAAM;AACtB,WAAO;AAAA,EACX;AAEA,MAAI,OAAO,aAAa,eAAe,YAAY;AAC/C,WAAO,aAAa,WAAW,qBAAqB,EAAE;AAAA,EAC1D;AAEA,SAAO,aAAa,aAAa;AACrC;AAEO,MAAM,iCAAiC,CAC1C,cACA,oBACC;AACD,MAAI,gBAAgB,QAAQ,mBAAmB,MAAM;AACjD,WAAO;AAAA,EACX;AAEA,QAAM,QACF,mBAAmB,KAAK,gBAAgB,SAAS,KAAK,EAAE,cAAc;AAC1E,SAAO,SAAS,aAAa,aAAa;AAC9C;AAEO,MAAM,mBAAmB,CAAC,WAAoB,WAAW;AAEzD,MAAM,iBAAiB,CAAC,SAA0D;AACrF,MAAI,KAAK,YAAY,MAAM;AACvB,WAAO,KAAK;AAAA,EAChB;AAEA,SAAO,iBAAiB,KAAK,MAAM;AACvC;AAEO,MAAM,aAAa,CAAC,WACvB,iBAAiB,MAAM,IAAI,wB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B,MAAM;AACzB,WAAO;AAAA,EACX;AAEA,QAAM,eAAe,WAAW,gBAAgB,KAAK,IAAI,CAAC;AAE1D,MAAI,gBAAgB,MAAM;AACtB,WAAO;AAAA,EACX;AAEA,SAAO,kBAAkB,eAAe,MAAM;AAClD;AAEA,MAAM,cAAc,CAAI,WACpB,OAAO,WAAW,YAAY,WAAW,QAAQ,aAAa;AAE3D,MAAM,YAAY,CAAI,QAA4B,UAAoB;AACzE,MAAI,UAAU,MAAM;AAChB;AAAA,EACJ;AAEA,MAAI,OAAO,WAAW,YAAY;AAC9B,WAAO,KAAK;AACZ;AAAA,EACJ;AAEA,MAAI,YAAY,MAAM,GAAG;AACrB,WAAO,UAAU;AAAA,EACrB;AACJ;"}
@@ -0,0 +1,3 @@
1
+ export { MainNavigation } from './MainNavigation';
2
+ export type { MainNavigationItem, MainNavigationLink, MainNavigationOrganizationLink, MainNavigationPanel, MainNavigationProps, MainNavigationSubmenuColumn, } from './MainNavigation.types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/MainNavigation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,YAAY,EACR,kBAAkB,EAClB,kBAAkB,EAClB,8BAA8B,EAC9B,mBAAmB,EACnB,mBAAmB,EACnB,2BAA2B,GAC9B,MAAM,wBAAwB,CAAC"}
@@ -5,35 +5,35 @@
5
5
  * These variables come from @dnanpm/design-tokens package.
6
6
  */
7
7
 
8
- ._notification_5h3rs_8 {
8
+ ._notification_m746g_8 {
9
9
  display: flex;
10
10
  align-items: center;
11
- gap: var(--spacing-ui-md);
12
- padding-right: var(--spacing-ui-lg);
11
+ gap: var(--spacing-space-16);
12
+ padding-right: var(--spacing-space-20);
13
13
  border: 2px solid var(--notification-color);
14
14
  border-radius: var(--radius-semantic-sm);
15
15
  overflow: clip;
16
16
  }
17
17
 
18
18
  /* Variant colors */
19
- ._notification--info_5h3rs_19 {
19
+ ._notification--info_m746g_19 {
20
20
  --notification-color: var(--color-semantic-status-info);
21
21
  }
22
22
 
23
- ._notification--success_5h3rs_23 {
23
+ ._notification--success_m746g_23 {
24
24
  --notification-color: var(--color-semantic-status-success);
25
25
  }
26
26
 
27
- ._notification--warning_5h3rs_27 {
27
+ ._notification--warning_m746g_27 {
28
28
  --notification-color: var(--color-semantic-status-warning);
29
29
  }
30
30
 
31
- ._notification--error_5h3rs_31 {
31
+ ._notification--error_m746g_31 {
32
32
  --notification-color: var(--color-semantic-status-error);
33
33
  }
34
34
 
35
35
  /* Icon container */
36
- ._notification__icon-container_5h3rs_36 {
36
+ ._notification__icon-container_m746g_36 {
37
37
  /* The colored area size should be 48x48px on one line content, so we adjust padding based on whether the border is present or not */
38
38
  --_icon-padding-with-border: 10px;
39
39
  --_icon-padding-without-border: 12px;
@@ -49,24 +49,24 @@
49
49
  color: var(--color-semantic-foreground-inverse);
50
50
  }
51
51
 
52
- ._notification__icon_5h3rs_36 {
52
+ ._notification__icon_m746g_36 {
53
53
  width: 24px;
54
54
  height: 24px;
55
55
  flex: 0 0 auto;
56
56
  }
57
57
 
58
58
  /* Content */
59
- ._notification__content_5h3rs_59 {
59
+ ._notification__content_m746g_59 {
60
60
  flex: 1 1 auto;
61
61
  min-width: 0;
62
- padding: var(--spacing-ui-xs) 0;
62
+ padding: var(--spacing-space-8) 0;
63
63
  font: var(--typography-body-md);
64
64
  color: var(--color-semantic-foreground-default);
65
65
  text-wrap: pretty;
66
66
  }
67
67
 
68
68
  /* Close button */
69
- ._notification__close_5h3rs_69 {
69
+ ._notification__close_m746g_69 {
70
70
  flex: 0 0 auto;
71
71
  display: flex;
72
72
  align-items: center;
@@ -75,7 +75,7 @@
75
75
  height: 32px;
76
76
  padding: 0;
77
77
  /* Negative margin to offset the button's size and maintain consistent spacing with the content */
78
- margin: 0 calc(var(--spacing-ui-xxs) * -1);
78
+ margin: 0 calc(var(--spacing-space-4) * -1);
79
79
  border: none;
80
80
  border-radius: var(--radius-semantic-sm);
81
81
  background: none;
@@ -83,7 +83,7 @@
83
83
  cursor: pointer;
84
84
  }
85
85
 
86
- ._notification__close_5h3rs_69 svg {
86
+ ._notification__close_m746g_69 svg {
87
87
  width: 24px;
88
88
  height: 24px;
89
89
  }
@@ -1,17 +1,17 @@
1
1
  require('./Notification.css');
2
2
  "use strict";
3
3
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
4
- const notification = "_notification_5h3rs_8";
5
- const notification__icon = "_notification__icon_5h3rs_36";
6
- const notification__content = "_notification__content_5h3rs_59";
7
- const notification__close = "_notification__close_5h3rs_69";
4
+ const notification = "_notification_m746g_8";
5
+ const notification__icon = "_notification__icon_m746g_36";
6
+ const notification__content = "_notification__content_m746g_59";
7
+ const notification__close = "_notification__close_m746g_69";
8
8
  const styles = {
9
9
  notification,
10
- "notification--info": "_notification--info_5h3rs_19",
11
- "notification--success": "_notification--success_5h3rs_23",
12
- "notification--warning": "_notification--warning_5h3rs_27",
13
- "notification--error": "_notification--error_5h3rs_31",
14
- "notification__icon-container": "_notification__icon-container_5h3rs_36",
10
+ "notification--info": "_notification--info_m746g_19",
11
+ "notification--success": "_notification--success_m746g_23",
12
+ "notification--warning": "_notification--warning_m746g_27",
13
+ "notification--error": "_notification--error_m746g_31",
14
+ "notification__icon-container": "_notification__icon-container_m746g_36",
15
15
  notification__icon,
16
16
  notification__content,
17
17
  notification__close
@@ -1,15 +1,15 @@
1
1
  import './Notification.css';
2
- const notification = "_notification_5h3rs_8";
3
- const notification__icon = "_notification__icon_5h3rs_36";
4
- const notification__content = "_notification__content_5h3rs_59";
5
- const notification__close = "_notification__close_5h3rs_69";
2
+ const notification = "_notification_m746g_8";
3
+ const notification__icon = "_notification__icon_m746g_36";
4
+ const notification__content = "_notification__content_m746g_59";
5
+ const notification__close = "_notification__close_m746g_69";
6
6
  const styles = {
7
7
  notification,
8
- "notification--info": "_notification--info_5h3rs_19",
9
- "notification--success": "_notification--success_5h3rs_23",
10
- "notification--warning": "_notification--warning_5h3rs_27",
11
- "notification--error": "_notification--error_5h3rs_31",
12
- "notification__icon-container": "_notification__icon-container_5h3rs_36",
8
+ "notification--info": "_notification--info_m746g_19",
9
+ "notification--success": "_notification--success_m746g_23",
10
+ "notification--warning": "_notification--warning_m746g_27",
11
+ "notification--error": "_notification--error_m746g_31",
12
+ "notification__icon-container": "_notification__icon-container_m746g_36",
13
13
  notification__icon,
14
14
  notification__content,
15
15
  notification__close