@dnanpm/ui-components 0.7.0 → 0.9.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.
- package/dist/components/Accordion/Accordion.css +6 -3
- package/dist/components/AccordionItem/AccordionItem.css +6 -3
- package/dist/components/Breadcrumb/Breadcrumb.css +15 -12
- package/dist/components/Breadcrumb/Breadcrumb.module.css.cjs +6 -6
- package/dist/components/Breadcrumb/Breadcrumb.module.css.js +6 -6
- package/dist/components/Button/Button.css +33 -32
- package/dist/components/Button/Button.module.css.cjs +11 -11
- package/dist/components/Button/Button.module.css.js +11 -11
- package/dist/components/ButtonCard/ButtonCard.cjs +105 -0
- package/dist/components/ButtonCard/ButtonCard.cjs.map +1 -0
- package/dist/components/ButtonCard/ButtonCard.css +166 -0
- package/dist/components/ButtonCard/ButtonCard.d.ts +3 -0
- package/dist/components/ButtonCard/ButtonCard.d.ts.map +1 -0
- package/dist/components/ButtonCard/ButtonCard.js +105 -0
- package/dist/components/ButtonCard/ButtonCard.js.map +1 -0
- package/dist/components/ButtonCard/ButtonCard.module.css.cjs +18 -0
- package/dist/components/ButtonCard/ButtonCard.module.css.cjs.map +1 -0
- package/dist/components/ButtonCard/ButtonCard.module.css.js +19 -0
- package/dist/components/ButtonCard/ButtonCard.module.css.js.map +1 -0
- package/dist/components/ButtonCard/ButtonCard.types.d.ts +103 -0
- package/dist/components/ButtonCard/ButtonCard.types.d.ts.map +1 -0
- package/dist/components/ButtonCard/index.d.ts +3 -0
- package/dist/components/ButtonCard/index.d.ts.map +1 -0
- package/dist/components/ContentCard/ContentCard.cjs +96 -0
- package/dist/components/ContentCard/ContentCard.cjs.map +1 -0
- package/dist/components/ContentCard/ContentCard.css +249 -0
- package/dist/components/ContentCard/ContentCard.d.ts +3 -0
- package/dist/components/ContentCard/ContentCard.d.ts.map +1 -0
- package/dist/components/ContentCard/ContentCard.js +96 -0
- package/dist/components/ContentCard/ContentCard.js.map +1 -0
- package/dist/components/ContentCard/ContentCard.module.css.cjs +24 -0
- package/dist/components/ContentCard/ContentCard.module.css.cjs.map +1 -0
- package/dist/components/ContentCard/ContentCard.module.css.js +25 -0
- package/dist/components/ContentCard/ContentCard.module.css.js.map +1 -0
- package/dist/components/ContentCard/ContentCard.types.d.ts +99 -0
- package/dist/components/ContentCard/ContentCard.types.d.ts.map +1 -0
- package/dist/components/ContentCard/index.d.ts +3 -0
- package/dist/components/ContentCard/index.d.ts.map +1 -0
- package/dist/components/Drawer/Drawer.cjs +101 -0
- package/dist/components/Drawer/Drawer.cjs.map +1 -0
- package/dist/components/Drawer/Drawer.css +218 -0
- package/dist/components/Drawer/Drawer.d.ts +3 -0
- package/dist/components/Drawer/Drawer.d.ts.map +1 -0
- package/dist/components/Drawer/Drawer.js +101 -0
- package/dist/components/Drawer/Drawer.js.map +1 -0
- package/dist/components/Drawer/Drawer.module.css.cjs +37 -0
- package/dist/components/Drawer/Drawer.module.css.cjs.map +1 -0
- package/dist/components/Drawer/Drawer.module.css.js +37 -0
- package/dist/components/Drawer/Drawer.module.css.js.map +1 -0
- package/dist/components/Drawer/Drawer.types.d.ts +63 -0
- package/dist/components/Drawer/Drawer.types.d.ts.map +1 -0
- package/dist/components/Drawer/index.d.ts +3 -0
- package/dist/components/Drawer/index.d.ts.map +1 -0
- package/dist/components/Footer/Footer.css +87 -77
- package/dist/components/Footer/Footer.module.css.cjs +39 -39
- package/dist/components/Footer/Footer.module.css.js +39 -39
- package/dist/components/FunctionButton/FunctionButton.cjs +34 -0
- package/dist/components/FunctionButton/FunctionButton.cjs.map +1 -0
- package/dist/components/FunctionButton/FunctionButton.css +124 -0
- package/dist/components/FunctionButton/FunctionButton.d.ts +3 -0
- package/dist/components/FunctionButton/FunctionButton.d.ts.map +1 -0
- package/dist/components/FunctionButton/FunctionButton.js +34 -0
- package/dist/components/FunctionButton/FunctionButton.js.map +1 -0
- package/dist/components/FunctionButton/FunctionButton.module.css.cjs +11 -0
- package/dist/components/FunctionButton/FunctionButton.module.css.cjs.map +1 -0
- package/dist/components/FunctionButton/FunctionButton.module.css.js +12 -0
- package/dist/components/FunctionButton/FunctionButton.module.css.js.map +1 -0
- package/dist/components/FunctionButton/FunctionButton.types.d.ts +21 -0
- package/dist/components/FunctionButton/FunctionButton.types.d.ts.map +1 -0
- package/dist/components/FunctionButton/index.d.ts +3 -0
- package/dist/components/FunctionButton/index.d.ts.map +1 -0
- package/dist/components/Hero/Hero.cjs +24 -26
- package/dist/components/Hero/Hero.cjs.map +1 -1
- package/dist/components/Hero/Hero.css +81 -74
- package/dist/components/Hero/Hero.js +24 -26
- package/dist/components/Hero/Hero.js.map +1 -1
- package/dist/components/Hero/Hero.module.css.cjs +20 -17
- package/dist/components/Hero/Hero.module.css.cjs.map +1 -1
- package/dist/components/Hero/Hero.module.css.js +20 -17
- package/dist/components/Hero/Hero.module.css.js.map +1 -1
- package/dist/components/IconButton/IconButton.css +32 -34
- package/dist/components/IconButton/IconButton.module.css.cjs +9 -9
- package/dist/components/IconButton/IconButton.module.css.js +9 -9
- package/dist/components/Label/Label.css +2 -3
- package/dist/components/MainNavigation/MainNavigation.cjs +415 -120
- package/dist/components/MainNavigation/MainNavigation.cjs.map +1 -1
- package/dist/components/MainNavigation/MainNavigation.css +265 -159
- package/dist/components/MainNavigation/MainNavigation.d.ts +1 -1
- package/dist/components/MainNavigation/MainNavigation.d.ts.map +1 -1
- package/dist/components/MainNavigation/MainNavigation.js +417 -122
- package/dist/components/MainNavigation/MainNavigation.js.map +1 -1
- package/dist/components/MainNavigation/MainNavigation.module.css.cjs +78 -68
- package/dist/components/MainNavigation/MainNavigation.module.css.cjs.map +1 -1
- package/dist/components/MainNavigation/MainNavigation.module.css.js +78 -68
- package/dist/components/MainNavigation/MainNavigation.module.css.js.map +1 -1
- package/dist/components/MainNavigation/MainNavigation.types.d.ts +64 -17
- package/dist/components/MainNavigation/MainNavigation.types.d.ts.map +1 -1
- package/dist/components/MainNavigation/MainNavigation.utils.cjs +20 -0
- package/dist/components/MainNavigation/MainNavigation.utils.cjs.map +1 -1
- package/dist/components/MainNavigation/MainNavigation.utils.d.ts +10 -1
- package/dist/components/MainNavigation/MainNavigation.utils.d.ts.map +1 -1
- package/dist/components/MainNavigation/MainNavigation.utils.js +20 -0
- package/dist/components/MainNavigation/MainNavigation.utils.js.map +1 -1
- package/dist/components/MainNavigation/index.d.ts +1 -1
- package/dist/components/MainNavigation/index.d.ts.map +1 -1
- package/dist/components/Modal/Modal.cjs +101 -0
- package/dist/components/Modal/Modal.cjs.map +1 -0
- package/dist/components/Modal/Modal.css +204 -0
- package/dist/components/Modal/Modal.d.ts +3 -0
- package/dist/components/Modal/Modal.d.ts.map +1 -0
- package/dist/components/Modal/Modal.js +101 -0
- package/dist/components/Modal/Modal.js.map +1 -0
- package/dist/components/Modal/Modal.module.css.cjs +39 -0
- package/dist/components/Modal/Modal.module.css.cjs.map +1 -0
- package/dist/components/Modal/Modal.module.css.js +39 -0
- package/dist/components/Modal/Modal.module.css.js.map +1 -0
- package/dist/components/Modal/Modal.types.d.ts +62 -0
- package/dist/components/Modal/Modal.types.d.ts.map +1 -0
- package/dist/components/Modal/index.d.ts +3 -0
- package/dist/components/Modal/index.d.ts.map +1 -0
- package/dist/components/Modal/useDialogDismissal.cjs +41 -0
- package/dist/components/Modal/useDialogDismissal.cjs.map +1 -0
- package/dist/components/Modal/useDialogDismissal.d.ts +17 -0
- package/dist/components/Modal/useDialogDismissal.d.ts.map +1 -0
- package/dist/components/Modal/useDialogDismissal.js +41 -0
- package/dist/components/Modal/useDialogDismissal.js.map +1 -0
- package/dist/components/Modal/useNativeDialog.cjs +126 -0
- package/dist/components/Modal/useNativeDialog.cjs.map +1 -0
- package/dist/components/Modal/useNativeDialog.d.ts +14 -0
- package/dist/components/Modal/useNativeDialog.d.ts.map +1 -0
- package/dist/components/Modal/useNativeDialog.js +126 -0
- package/dist/components/Modal/useNativeDialog.js.map +1 -0
- package/dist/components/Notification/Notification.css +6 -3
- package/dist/components/Pictograph/Pictograph.css +6 -3
- package/dist/components/Pictograph/PictographItem.css +6 -3
- package/dist/components/Quote/Quote.css +2 -3
- package/dist/components/Spinner/Spinner.css +6 -3
- package/dist/index.cjs +10 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -1
- package/dist/styles/utils/elevation.css +2 -3
- package/dist/styles/utils/elevation.module.css.cjs +3 -0
- package/dist/styles/utils/elevation.module.css.cjs.map +1 -1
- package/dist/styles/utils/elevation.module.css.js +4 -1
- package/dist/styles/utils/elevation.module.css.js.map +1 -1
- package/dist/styles/utils/focus.css +26 -24
- package/dist/styles/utils/focus.module.css.cjs +3 -6
- package/dist/styles/utils/focus.module.css.cjs.map +1 -1
- package/dist/styles/utils/focus.module.css.js +4 -7
- package/dist/styles/utils/focus.module.css.js.map +1 -1
- package/dist/styles/utils/overlay.css +2 -3
- package/dist/styles/utils/text-decoration.css +4 -4
- package/dist/styles/utils/text-decoration.module.css.cjs +2 -2
- package/dist/styles/utils/text-decoration.module.css.js +2 -2
- package/dist/styles.css +17 -7
- package/package.json +3 -3
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
const relativeNavigationBaseUrl = "https://navigation.local";
|
|
2
2
|
const safeLinkProtocols = /* @__PURE__ */ new Set(["http:", "https:", "mailto:", "tel:"]);
|
|
3
|
+
const languageLinkAriaLabels = {
|
|
4
|
+
fi: "FI, siirry suomenkieliselle sivustolle",
|
|
5
|
+
en: "EN, customer support in English",
|
|
6
|
+
sv: "SV, kundsupport på svenska"
|
|
7
|
+
};
|
|
8
|
+
const languageToggleAnnouncementBuilders = {
|
|
9
|
+
en: (currentCode) => `Change language. Current language ${currentCode}.`,
|
|
10
|
+
fi: (currentCode) => `Vaihda kieli. Nykyinen kieli ${currentCode}.`,
|
|
11
|
+
sv: (currentCode) => `Ändra språk. Aktuellt språk ${currentCode}.`
|
|
12
|
+
};
|
|
13
|
+
const languageAnnouncementOrder = ["en", "fi", "sv"];
|
|
14
|
+
const getLanguageToggleAnnouncements = (presentCodes, currentCode) => {
|
|
15
|
+
const upperCurrentCode = currentCode.toUpperCase();
|
|
16
|
+
return languageAnnouncementOrder.filter((code) => presentCodes.includes(code)).map((code) => ({
|
|
17
|
+
lang: code,
|
|
18
|
+
text: languageToggleAnnouncementBuilders[code](upperCurrentCode)
|
|
19
|
+
}));
|
|
20
|
+
};
|
|
3
21
|
const isDesktopViewportByEnvironment = (windowObject) => {
|
|
4
22
|
if (windowObject == null) {
|
|
5
23
|
return false;
|
|
@@ -149,6 +167,7 @@ const assignRef = (target, value) => {
|
|
|
149
167
|
};
|
|
150
168
|
export {
|
|
151
169
|
assignRef,
|
|
170
|
+
getLanguageToggleAnnouncements,
|
|
152
171
|
getLinkRel,
|
|
153
172
|
getLinkTarget,
|
|
154
173
|
hasHref,
|
|
@@ -160,6 +179,7 @@ export {
|
|
|
160
179
|
isLinkInCurrentPath,
|
|
161
180
|
isMobileIosDeviceByEnvironment,
|
|
162
181
|
isMobileViewportByEnvironment,
|
|
182
|
+
languageLinkAriaLabels,
|
|
163
183
|
matchesPath,
|
|
164
184
|
normalizePathname,
|
|
165
185
|
toNavigableHref,
|
|
@@ -1 +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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,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;"}
|
|
1
|
+
{"version":3,"file":"MainNavigation.utils.js","sources":["../../../src/components/MainNavigation/MainNavigation.utils.ts"],"sourcesContent":["import type { Ref } from 'react';\nimport type {\n MainNavigationItem,\n MainNavigationLanguageCode,\n MainNavigationLink,\n} from './MainNavigation.types';\n\nconst relativeNavigationBaseUrl = 'https://navigation.local';\nconst safeLinkProtocols = new Set(['http:', 'https:', 'mailto:', 'tel:']);\n\nexport const languageLinkAriaLabels: Record<MainNavigationLanguageCode, string> = {\n fi: 'FI, siirry suomenkieliselle sivustolle',\n en: 'EN, customer support in English',\n sv: 'SV, kundsupport på svenska',\n};\n\nconst languageToggleAnnouncementBuilders: Record<\n MainNavigationLanguageCode,\n (currentCode: string) => string\n> = {\n en: (currentCode) => `Change language. Current language ${currentCode}.`,\n fi: (currentCode) => `Vaihda kieli. Nykyinen kieli ${currentCode}.`,\n sv: (currentCode) => `Ändra språk. Aktuellt språk ${currentCode}.`,\n};\n\nconst languageAnnouncementOrder: readonly MainNavigationLanguageCode[] = ['en', 'fi', 'sv'];\n\n/**\n * Builds the toggle's screen-reader announcements: one per language present in the data, each in its\n * own language, with the current language code as the final token.\n */\nexport const getLanguageToggleAnnouncements = (\n presentCodes: readonly MainNavigationLanguageCode[],\n currentCode: MainNavigationLanguageCode,\n): ReadonlyArray<{ readonly lang: MainNavigationLanguageCode; readonly text: string }> => {\n const upperCurrentCode = currentCode.toUpperCase();\n\n return languageAnnouncementOrder\n .filter((code) => presentCodes.includes(code))\n .map((code) => ({\n lang: code,\n text: languageToggleAnnouncementBuilders[code](upperCurrentCode),\n }));\n};\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":"AAOA,MAAM,4BAA4B;AAClC,MAAM,wCAAwB,IAAI,CAAC,SAAS,UAAU,WAAW,MAAM,CAAC;AAEjE,MAAM,yBAAqE;AAAA,EAC9E,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACR;AAEA,MAAM,qCAGF;AAAA,EACA,IAAI,CAAC,gBAAgB,qCAAqC,WAAW;AAAA,EACrE,IAAI,CAAC,gBAAgB,gCAAgC,WAAW;AAAA,EAChE,IAAI,CAAC,gBAAgB,+BAA+B,WAAW;AACnE;AAEA,MAAM,4BAAmE,CAAC,MAAM,MAAM,IAAI;AAMnF,MAAM,iCAAiC,CAC1C,cACA,gBACsF;AACtF,QAAM,mBAAmB,YAAY,YAAA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AQ,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;"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { MainNavigation } from './MainNavigation';
|
|
2
|
-
export type { MainNavigationItem, MainNavigationLink, MainNavigationOrganizationLink, MainNavigationPanel, MainNavigationProps, MainNavigationSubmenuColumn, } from './MainNavigation.types';
|
|
2
|
+
export type { MainNavigationItem, MainNavigationLanguageCode, MainNavigationLanguageLinkProps, MainNavigationLanguageOption, MainNavigationLink, MainNavigationOrganizationLink, MainNavigationPanel, MainNavigationProps, MainNavigationRenderLanguageLink, MainNavigationSubmenuColumn, } from './MainNavigation.types';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +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"}
|
|
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,0BAA0B,EAC1B,+BAA+B,EAC/B,4BAA4B,EAC5B,kBAAkB,EAClB,8BAA8B,EAC9B,mBAAmB,EACnB,mBAAmB,EACnB,gCAAgC,EAChC,2BAA2B,GAC9B,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const react = require("react");
|
|
5
|
+
const icons = require("@dnanpm/icons");
|
|
6
|
+
const elevation_module = require("../../styles/utils/elevation.module.css.cjs");
|
|
7
|
+
const focus_module = require("../../styles/utils/focus.module.css.cjs");
|
|
8
|
+
const Modal_module = require("./Modal.module.css.cjs");
|
|
9
|
+
const useDialogDismissal = require("./useDialogDismissal.cjs");
|
|
10
|
+
const useNativeDialog = require("./useNativeDialog.cjs");
|
|
11
|
+
const cn = require("../../utils/cn/cn.cjs");
|
|
12
|
+
const Modal = ({
|
|
13
|
+
open,
|
|
14
|
+
onOpenChange,
|
|
15
|
+
title,
|
|
16
|
+
description,
|
|
17
|
+
children,
|
|
18
|
+
footer,
|
|
19
|
+
size = "medium",
|
|
20
|
+
headerStyle = "light",
|
|
21
|
+
fixedTitle = false,
|
|
22
|
+
alignToTop = false,
|
|
23
|
+
disableCloseOptions = false,
|
|
24
|
+
closeLabel = "Sulje dialogi",
|
|
25
|
+
keepMounted = false,
|
|
26
|
+
className,
|
|
27
|
+
ref,
|
|
28
|
+
onKeyDown,
|
|
29
|
+
onClick,
|
|
30
|
+
onPointerDown,
|
|
31
|
+
"aria-label": ariaLabel,
|
|
32
|
+
"aria-labelledby": ariaLabelledBy,
|
|
33
|
+
"aria-describedby": ariaDescribedBy,
|
|
34
|
+
...props
|
|
35
|
+
}) => {
|
|
36
|
+
const titleId = react.useId();
|
|
37
|
+
const descriptionId = react.useId();
|
|
38
|
+
const { dialogRef, close, phase, isPresent } = useNativeDialog.useNativeDialog({
|
|
39
|
+
open: open ?? false,
|
|
40
|
+
keepMounted,
|
|
41
|
+
onOpenChange
|
|
42
|
+
});
|
|
43
|
+
const describedBy = [description ? descriptionId : void 0, ariaDescribedBy].filter(Boolean).join(" ") || void 0;
|
|
44
|
+
const dialogDismissalProps = useDialogDismissal.useDialogDismissal({
|
|
45
|
+
close,
|
|
46
|
+
disableCloseOptions,
|
|
47
|
+
onClick,
|
|
48
|
+
onKeyDown,
|
|
49
|
+
onPointerDown
|
|
50
|
+
});
|
|
51
|
+
if (!isPresent) return null;
|
|
52
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
53
|
+
"dialog",
|
|
54
|
+
{
|
|
55
|
+
...props,
|
|
56
|
+
ref: (node) => {
|
|
57
|
+
dialogRef.current = node;
|
|
58
|
+
if (typeof ref === "function") ref(node);
|
|
59
|
+
else if (ref) ref.current = node;
|
|
60
|
+
},
|
|
61
|
+
className: cn.cn(
|
|
62
|
+
Modal_module.default.modal,
|
|
63
|
+
elevation_module.default.elevationHigh,
|
|
64
|
+
Modal_module.default[`modal--${size}`],
|
|
65
|
+
Modal_module.default[`modal--${headerStyle}`],
|
|
66
|
+
{ [Modal_module.default["modal--fixed-title"]]: fixedTitle },
|
|
67
|
+
{ [Modal_module.default["modal--align-top"]]: alignToTop },
|
|
68
|
+
{ [Modal_module.default["modal--opening"]]: phase !== "closing" },
|
|
69
|
+
{ [Modal_module.default["modal--closing"]]: phase === "closing" },
|
|
70
|
+
className
|
|
71
|
+
),
|
|
72
|
+
"aria-label": ariaLabel,
|
|
73
|
+
"aria-labelledby": ariaLabelledBy ?? (!ariaLabel && title ? titleId : void 0),
|
|
74
|
+
"aria-describedby": describedBy,
|
|
75
|
+
...dialogDismissalProps,
|
|
76
|
+
children: [
|
|
77
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: Modal_module.default.modal__container, children: [
|
|
78
|
+
!disableCloseOptions && /* @__PURE__ */ jsxRuntime.jsx(
|
|
79
|
+
"button",
|
|
80
|
+
{
|
|
81
|
+
type: "button",
|
|
82
|
+
className: cn.cn(Modal_module.default.modal__close, focus_module.default.focusable),
|
|
83
|
+
"aria-label": closeLabel,
|
|
84
|
+
"data-dialog-autofocus": "true",
|
|
85
|
+
onClick: close,
|
|
86
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.Close, { "aria-hidden": "true" })
|
|
87
|
+
}
|
|
88
|
+
),
|
|
89
|
+
(title || description) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: Modal_module.default.modal__title, children: [
|
|
90
|
+
title && /* @__PURE__ */ jsxRuntime.jsx("h2", { id: titleId, className: Modal_module.default.modal__heading, children: title }),
|
|
91
|
+
description && /* @__PURE__ */ jsxRuntime.jsx("div", { id: descriptionId, className: Modal_module.default.modal__description, children: description })
|
|
92
|
+
] }),
|
|
93
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: Modal_module.default.modal__content, children })
|
|
94
|
+
] }),
|
|
95
|
+
footer && /* @__PURE__ */ jsxRuntime.jsx("div", { className: Modal_module.default["modal__bottom-bar"], children: footer })
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
);
|
|
99
|
+
};
|
|
100
|
+
exports.Modal = Modal;
|
|
101
|
+
//# sourceMappingURL=Modal.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Modal.cjs","sources":["../../../src/components/Modal/Modal.tsx"],"sourcesContent":["import { useId } from 'react';\nimport { Close } from '@dnanpm/icons';\nimport { cn } from '../../utils/cn';\nimport elevationStyles from '../../styles/utils/elevation.module.css';\nimport focusStyles from '../../styles/utils/focus.module.css';\nimport styles from './Modal.module.css';\nimport { useDialogDismissal } from './useDialogDismissal';\nimport { useNativeDialog } from './useNativeDialog';\nimport type { ModalProps } from './Modal.types';\n\nexport const Modal = ({\n open,\n onOpenChange,\n title,\n description,\n children,\n footer,\n size = 'medium',\n headerStyle = 'light',\n fixedTitle = false,\n alignToTop = false,\n disableCloseOptions = false,\n closeLabel = 'Sulje dialogi',\n keepMounted = false,\n className,\n ref,\n onKeyDown,\n onClick,\n onPointerDown,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n ...props\n}: ModalProps) => {\n const titleId = useId();\n const descriptionId = useId();\n const { dialogRef, close, phase, isPresent } = useNativeDialog({\n open: open ?? false,\n keepMounted,\n onOpenChange,\n });\n const describedBy =\n [description ? descriptionId : undefined, ariaDescribedBy].filter(Boolean).join(' ') ||\n undefined;\n const dialogDismissalProps = useDialogDismissal({\n close,\n disableCloseOptions,\n onClick,\n onKeyDown,\n onPointerDown,\n });\n\n if (!isPresent) return null;\n\n return (\n <dialog\n {...props}\n ref={(node) => {\n dialogRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) ref.current = node;\n }}\n className={cn(\n styles.modal,\n elevationStyles.elevationHigh,\n styles[`modal--${size}`],\n styles[`modal--${headerStyle}`],\n { [styles['modal--fixed-title']]: fixedTitle },\n { [styles['modal--align-top']]: alignToTop },\n { [styles['modal--opening']]: phase !== 'closing' },\n { [styles['modal--closing']]: phase === 'closing' },\n className,\n )}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy ?? (!ariaLabel && title ? titleId : undefined)}\n aria-describedby={describedBy}\n {...dialogDismissalProps}\n >\n <div className={styles.modal__container}>\n {!disableCloseOptions && (\n <button\n type=\"button\"\n className={cn(styles.modal__close, focusStyles.focusable)}\n aria-label={closeLabel}\n data-dialog-autofocus=\"true\"\n onClick={close}\n >\n <Close aria-hidden=\"true\" />\n </button>\n )}\n {(title || description) && (\n <div className={styles.modal__title}>\n {title && (\n <h2 id={titleId} className={styles.modal__heading}>\n {title}\n </h2>\n )}\n {description && (\n <div id={descriptionId} className={styles.modal__description}>\n {description}\n </div>\n )}\n </div>\n )}\n <div className={styles.modal__content}>{children}</div>\n </div>\n {footer && <div className={styles['modal__bottom-bar']}>{footer}</div>}\n </dialog>\n );\n};\n"],"names":["useId","useNativeDialog","useDialogDismissal","jsxs","cn","styles","elevationStyles","jsx","focusStyles","Close"],"mappings":";;;;;;;;;;;AAUO,MAAM,QAAQ,CAAC;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAA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AAO,gBAAgB,CAAC,GAAG,UAAU,UAAA;AAAA,QACxC,EAAE,CAACA,aAAAA,QAAO,gBAAgB,CAAC,GAAG,UAAU,UAAA;AAAA,QACxC;AAAA,MAAA;AAAA,MAEJ,cAAY;AAAA,MACZ,mBAAiB,mBAAmB,CAAC,aAAa,QAAQ,UAAU;AAAA,MACpE,oBAAkB;AAAA,MACjB,GAAG;AAAA,MAEJ,UAAA;AAAA,QAAAF,2BAAAA,KAAC,OAAA,EAAI,WAAWE,aAAAA,QAAO,kBAClB,UAAA;AAAA,UAAA,CAAC,uBACEE,2BAAAA;AAAAA,YAAC;AAAA,YAAA;AAAA,cACG,MAAK;AAAA,cACL,WAAWH,GAAAA,GAAGC,aAAAA,QAAO,cAAcG,aAAAA,QAAY,SAAS;AAAA,cACxD,cAAY;AAAA,cACZ,yBAAsB;AAAA,cACtB,SAAS;AAAA,cAET,UAAAD,2BAAAA,IAACE,MAAAA,OAAA,EAAM,eAAY,OAAA,CAAO;AAAA,YAAA;AAAA,UAAA;AAAA,WAGhC,SAAS,gBACPN,gCAAC,OAAA,EAAI,WAAWE,aAAAA,QAAO,cAClB,UAAA;AAAA,YAAA,wCACI,MAAA,EAAG,IAAI,SAAS,WAAWA,qBAAO,gBAC9B,UAAA,MAAA,CACL;AAAA,YAEH,8CACI,OAAA,EAAI,IAAI,eAAe,WAAWA,qBAAO,oBACrC,UAAA,YAAA,CACL;AAAA,UAAA,GAER;AAAA,UAEJE,2BAAAA,IAAC,OAAA,EAAI,WAAWF,aAAAA,QAAO,gBAAiB,SAAA,CAAS;AAAA,QAAA,GACrD;AAAA,QACC,UAAUE,2BAAAA,IAAC,OAAA,EAAI,WAAWF,aAAAA,QAAO,mBAAmB,GAAI,UAAA,OAAA,CAAO;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAG5E;;"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
@layer dds-base, dds-components;@layer dds-components { @layer fallback, components; }@layer dds-components.components{._modal_ewl1e_1 {
|
|
2
|
+
--_modal-transition-duration-open: 400ms;
|
|
3
|
+
--_modal-transition-duration-close: 200ms;
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
width: min(90vw, 768px);
|
|
7
|
+
max-width: calc(100vw - var(--spacing-space-40));
|
|
8
|
+
min-height: 33.333dvh;
|
|
9
|
+
max-height: 90dvh;
|
|
10
|
+
margin: auto;
|
|
11
|
+
padding: 0;
|
|
12
|
+
border: none;
|
|
13
|
+
border-radius: var(--radius-semantic-md);
|
|
14
|
+
background: var(--color-semantic-surface-base);
|
|
15
|
+
color: var(--color-semantic-foreground-default);
|
|
16
|
+
font: var(--typography-body-md);
|
|
17
|
+
opacity: 1;
|
|
18
|
+
transition: opacity var(--_modal-transition-duration-close) ease;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
._modal--align-top_ewl1e_21 {
|
|
22
|
+
margin-block: 5dvh auto;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
._modal_ewl1e_1:not([open]) {
|
|
26
|
+
display: none;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
._modal_ewl1e_1::backdrop {
|
|
30
|
+
background: var(--color-semantic-utility-overlay-strong);
|
|
31
|
+
opacity: 0;
|
|
32
|
+
transition-property: opacity, overlay;
|
|
33
|
+
transition-duration: var(--_modal-transition-duration-close);
|
|
34
|
+
transition-timing-function: ease;
|
|
35
|
+
transition-behavior: allow-discrete;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
._modal--small_ewl1e_38 {
|
|
39
|
+
width: 480px;
|
|
40
|
+
min-height: auto;
|
|
41
|
+
}
|
|
42
|
+
._modal--medium_ewl1e_42 {
|
|
43
|
+
width: 768px;
|
|
44
|
+
}
|
|
45
|
+
._modal--large_ewl1e_45 {
|
|
46
|
+
width: 960px;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
._modal--opening_ewl1e_49 {
|
|
50
|
+
animation: _modal-open_ewl1e_1 var(--_modal-transition-duration-open) ease both;
|
|
51
|
+
}
|
|
52
|
+
._modal--closing_ewl1e_52 {
|
|
53
|
+
animation: _modal-close_ewl1e_1 var(--_modal-transition-duration-close) ease both;
|
|
54
|
+
}
|
|
55
|
+
._modal--opening_ewl1e_49::backdrop {
|
|
56
|
+
opacity: 1;
|
|
57
|
+
transition-duration: var(--_modal-transition-duration-open);
|
|
58
|
+
}
|
|
59
|
+
._modal--closing_ewl1e_52::backdrop {
|
|
60
|
+
opacity: 0;
|
|
61
|
+
transition-duration: var(--_modal-transition-duration-close);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
._modal__container_ewl1e_64 {
|
|
65
|
+
display: flex;
|
|
66
|
+
min-height: 0;
|
|
67
|
+
flex: 1 1 auto;
|
|
68
|
+
flex-direction: column;
|
|
69
|
+
overflow: auto;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
._modal--fixed-title_ewl1e_72 ._modal__container_ewl1e_64 {
|
|
73
|
+
overflow: hidden;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
._modal__title_ewl1e_76 {
|
|
77
|
+
display: flex;
|
|
78
|
+
flex: 0 0 auto;
|
|
79
|
+
flex-direction: column;
|
|
80
|
+
gap: var(--spacing-space-4);
|
|
81
|
+
padding: var(--spacing-space-20) var(--spacing-space-40) var(--spacing-space-20)
|
|
82
|
+
var(--spacing-space-20);
|
|
83
|
+
background: var(--color-semantic-surface-base);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
._modal__heading_ewl1e_86 {
|
|
87
|
+
margin: 0;
|
|
88
|
+
font: var(--typography-heading-md);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
._modal--small_ewl1e_38 ._modal__heading_ewl1e_86 {
|
|
92
|
+
font: var(--typography-heading-sm);
|
|
93
|
+
}
|
|
94
|
+
._modal__description_ewl1e_94 {
|
|
95
|
+
margin: 0;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
._modal__content_ewl1e_98 {
|
|
99
|
+
flex: 1 1 auto;
|
|
100
|
+
padding: var(--spacing-space-20);
|
|
101
|
+
overflow-wrap: anywhere;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
._modal--fixed-title_ewl1e_72 ._modal__content_ewl1e_98 {
|
|
105
|
+
overflow: auto;
|
|
106
|
+
}
|
|
107
|
+
._modal__container_ewl1e_64:not(:has(._modal__title_ewl1e_76)) ._modal__content_ewl1e_98 {
|
|
108
|
+
padding-top: var(--spacing-space-40);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
._modal__close_ewl1e_111 {
|
|
112
|
+
position: absolute;
|
|
113
|
+
z-index: 1;
|
|
114
|
+
top: 0;
|
|
115
|
+
right: 0;
|
|
116
|
+
display: grid;
|
|
117
|
+
width: 40px;
|
|
118
|
+
height: 40px;
|
|
119
|
+
place-items: center;
|
|
120
|
+
padding: 0;
|
|
121
|
+
border: none;
|
|
122
|
+
border-bottom-left-radius: var(--radius-semantic-md);
|
|
123
|
+
background: var(--color-semantic-surface-neutral-mid);
|
|
124
|
+
color: var(--color-semantic-foreground-secondary-strong);
|
|
125
|
+
cursor: pointer;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
._modal__close_ewl1e_111 svg {
|
|
129
|
+
width: 24px;
|
|
130
|
+
height: 24px;
|
|
131
|
+
}
|
|
132
|
+
._modal__bottom-bar_ewl1e_132 {
|
|
133
|
+
flex: 0 0 auto;
|
|
134
|
+
padding: var(--spacing-space-8) var(--spacing-space-20) var(--spacing-space-20);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
._modal--dark_ewl1e_137 ._modal__title_ewl1e_76 {
|
|
138
|
+
background: var(--color-semantic-surface-secondary-strong);
|
|
139
|
+
color: var(--color-semantic-foreground-inverse);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
._modal--dark_ewl1e_137 ._modal__close_ewl1e_111 {
|
|
143
|
+
background: var(--color-semantic-surface-secondary-mid);
|
|
144
|
+
color: var(--color-semantic-foreground-inverse);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
@keyframes _modal-open_ewl1e_1 {
|
|
148
|
+
from {
|
|
149
|
+
opacity: 0;
|
|
150
|
+
}
|
|
151
|
+
to {
|
|
152
|
+
opacity: 1;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
@keyframes _modal-close_ewl1e_1 {
|
|
156
|
+
from {
|
|
157
|
+
opacity: 1;
|
|
158
|
+
}
|
|
159
|
+
to {
|
|
160
|
+
opacity: 0;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
._modal--opening_ewl1e_49::backdrop {
|
|
165
|
+
@starting-style {
|
|
166
|
+
opacity: 0;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
@media (max-width: 359px) {
|
|
171
|
+
._modal_ewl1e_1 {
|
|
172
|
+
width: 100vw;
|
|
173
|
+
max-width: 100vw;
|
|
174
|
+
height: 100dvh;
|
|
175
|
+
max-height: 100dvh;
|
|
176
|
+
border-radius: 0;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
@media (prefers-reduced-motion: reduce) {
|
|
181
|
+
._modal_ewl1e_1,
|
|
182
|
+
._modal--opening_ewl1e_49,
|
|
183
|
+
._modal--closing_ewl1e_52,
|
|
184
|
+
._modal_ewl1e_1::backdrop {
|
|
185
|
+
animation: none;
|
|
186
|
+
transition: none;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
@media (forced-colors: active) {
|
|
191
|
+
._modal_ewl1e_1 {
|
|
192
|
+
border: 2px solid CanvasText;
|
|
193
|
+
box-shadow: none;
|
|
194
|
+
}
|
|
195
|
+
._modal_ewl1e_1::backdrop {
|
|
196
|
+
background: Canvas;
|
|
197
|
+
opacity: 0.7;
|
|
198
|
+
}
|
|
199
|
+
._modal__close_ewl1e_111 {
|
|
200
|
+
border: 1px solid ButtonBorder;
|
|
201
|
+
background: ButtonFace;
|
|
202
|
+
color: ButtonText;
|
|
203
|
+
}
|
|
204
|
+
} }
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ModalProps } from './Modal.types';
|
|
2
|
+
export declare const Modal: ({ open, onOpenChange, title, description, children, footer, size, headerStyle, fixedTitle, alignToTop, disableCloseOptions, closeLabel, keepMounted, className, ref, onKeyDown, onClick, onPointerDown, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, ...props }: ModalProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
3
|
+
//# sourceMappingURL=Modal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../../src/components/Modal/Modal.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,eAAO,MAAM,KAAK,GAAI,qTAuBnB,UAAU,mDA4EZ,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from "react";
|
|
3
|
+
import { Close } from "@dnanpm/icons";
|
|
4
|
+
import elevationStyles from "../../styles/utils/elevation.module.css.js";
|
|
5
|
+
import focusStyles from "../../styles/utils/focus.module.css.js";
|
|
6
|
+
import styles from "./Modal.module.css.js";
|
|
7
|
+
import { useDialogDismissal } from "./useDialogDismissal.js";
|
|
8
|
+
import { useNativeDialog } from "./useNativeDialog.js";
|
|
9
|
+
import { cn } from "../../utils/cn/cn.js";
|
|
10
|
+
const Modal = ({
|
|
11
|
+
open,
|
|
12
|
+
onOpenChange,
|
|
13
|
+
title,
|
|
14
|
+
description,
|
|
15
|
+
children,
|
|
16
|
+
footer,
|
|
17
|
+
size = "medium",
|
|
18
|
+
headerStyle = "light",
|
|
19
|
+
fixedTitle = false,
|
|
20
|
+
alignToTop = false,
|
|
21
|
+
disableCloseOptions = false,
|
|
22
|
+
closeLabel = "Sulje dialogi",
|
|
23
|
+
keepMounted = false,
|
|
24
|
+
className,
|
|
25
|
+
ref,
|
|
26
|
+
onKeyDown,
|
|
27
|
+
onClick,
|
|
28
|
+
onPointerDown,
|
|
29
|
+
"aria-label": ariaLabel,
|
|
30
|
+
"aria-labelledby": ariaLabelledBy,
|
|
31
|
+
"aria-describedby": ariaDescribedBy,
|
|
32
|
+
...props
|
|
33
|
+
}) => {
|
|
34
|
+
const titleId = useId();
|
|
35
|
+
const descriptionId = useId();
|
|
36
|
+
const { dialogRef, close, phase, isPresent } = useNativeDialog({
|
|
37
|
+
open: open ?? false,
|
|
38
|
+
keepMounted,
|
|
39
|
+
onOpenChange
|
|
40
|
+
});
|
|
41
|
+
const describedBy = [description ? descriptionId : void 0, ariaDescribedBy].filter(Boolean).join(" ") || void 0;
|
|
42
|
+
const dialogDismissalProps = useDialogDismissal({
|
|
43
|
+
close,
|
|
44
|
+
disableCloseOptions,
|
|
45
|
+
onClick,
|
|
46
|
+
onKeyDown,
|
|
47
|
+
onPointerDown
|
|
48
|
+
});
|
|
49
|
+
if (!isPresent) return null;
|
|
50
|
+
return /* @__PURE__ */ jsxs(
|
|
51
|
+
"dialog",
|
|
52
|
+
{
|
|
53
|
+
...props,
|
|
54
|
+
ref: (node) => {
|
|
55
|
+
dialogRef.current = node;
|
|
56
|
+
if (typeof ref === "function") ref(node);
|
|
57
|
+
else if (ref) ref.current = node;
|
|
58
|
+
},
|
|
59
|
+
className: cn(
|
|
60
|
+
styles.modal,
|
|
61
|
+
elevationStyles.elevationHigh,
|
|
62
|
+
styles[`modal--${size}`],
|
|
63
|
+
styles[`modal--${headerStyle}`],
|
|
64
|
+
{ [styles["modal--fixed-title"]]: fixedTitle },
|
|
65
|
+
{ [styles["modal--align-top"]]: alignToTop },
|
|
66
|
+
{ [styles["modal--opening"]]: phase !== "closing" },
|
|
67
|
+
{ [styles["modal--closing"]]: phase === "closing" },
|
|
68
|
+
className
|
|
69
|
+
),
|
|
70
|
+
"aria-label": ariaLabel,
|
|
71
|
+
"aria-labelledby": ariaLabelledBy ?? (!ariaLabel && title ? titleId : void 0),
|
|
72
|
+
"aria-describedby": describedBy,
|
|
73
|
+
...dialogDismissalProps,
|
|
74
|
+
children: [
|
|
75
|
+
/* @__PURE__ */ jsxs("div", { className: styles.modal__container, children: [
|
|
76
|
+
!disableCloseOptions && /* @__PURE__ */ jsx(
|
|
77
|
+
"button",
|
|
78
|
+
{
|
|
79
|
+
type: "button",
|
|
80
|
+
className: cn(styles.modal__close, focusStyles.focusable),
|
|
81
|
+
"aria-label": closeLabel,
|
|
82
|
+
"data-dialog-autofocus": "true",
|
|
83
|
+
onClick: close,
|
|
84
|
+
children: /* @__PURE__ */ jsx(Close, { "aria-hidden": "true" })
|
|
85
|
+
}
|
|
86
|
+
),
|
|
87
|
+
(title || description) && /* @__PURE__ */ jsxs("div", { className: styles.modal__title, children: [
|
|
88
|
+
title && /* @__PURE__ */ jsx("h2", { id: titleId, className: styles.modal__heading, children: title }),
|
|
89
|
+
description && /* @__PURE__ */ jsx("div", { id: descriptionId, className: styles.modal__description, children: description })
|
|
90
|
+
] }),
|
|
91
|
+
/* @__PURE__ */ jsx("div", { className: styles.modal__content, children })
|
|
92
|
+
] }),
|
|
93
|
+
footer && /* @__PURE__ */ jsx("div", { className: styles["modal__bottom-bar"], children: footer })
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
};
|
|
98
|
+
export {
|
|
99
|
+
Modal
|
|
100
|
+
};
|
|
101
|
+
//# sourceMappingURL=Modal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Modal.js","sources":["../../../src/components/Modal/Modal.tsx"],"sourcesContent":["import { useId } from 'react';\nimport { Close } from '@dnanpm/icons';\nimport { cn } from '../../utils/cn';\nimport elevationStyles from '../../styles/utils/elevation.module.css';\nimport focusStyles from '../../styles/utils/focus.module.css';\nimport styles from './Modal.module.css';\nimport { useDialogDismissal } from './useDialogDismissal';\nimport { useNativeDialog } from './useNativeDialog';\nimport type { ModalProps } from './Modal.types';\n\nexport const Modal = ({\n open,\n onOpenChange,\n title,\n description,\n children,\n footer,\n size = 'medium',\n headerStyle = 'light',\n fixedTitle = false,\n alignToTop = false,\n disableCloseOptions = false,\n closeLabel = 'Sulje dialogi',\n keepMounted = false,\n className,\n ref,\n onKeyDown,\n onClick,\n onPointerDown,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n ...props\n}: ModalProps) => {\n const titleId = useId();\n const descriptionId = useId();\n const { dialogRef, close, phase, isPresent } = useNativeDialog({\n open: open ?? false,\n keepMounted,\n onOpenChange,\n });\n const describedBy =\n [description ? descriptionId : undefined, ariaDescribedBy].filter(Boolean).join(' ') ||\n undefined;\n const dialogDismissalProps = useDialogDismissal({\n close,\n disableCloseOptions,\n onClick,\n onKeyDown,\n onPointerDown,\n });\n\n if (!isPresent) return null;\n\n return (\n <dialog\n {...props}\n ref={(node) => {\n dialogRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) ref.current = node;\n }}\n className={cn(\n styles.modal,\n elevationStyles.elevationHigh,\n styles[`modal--${size}`],\n styles[`modal--${headerStyle}`],\n { [styles['modal--fixed-title']]: fixedTitle },\n { [styles['modal--align-top']]: alignToTop },\n { [styles['modal--opening']]: phase !== 'closing' },\n { [styles['modal--closing']]: phase === 'closing' },\n className,\n )}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy ?? (!ariaLabel && title ? titleId : undefined)}\n aria-describedby={describedBy}\n {...dialogDismissalProps}\n >\n <div className={styles.modal__container}>\n {!disableCloseOptions && (\n <button\n type=\"button\"\n className={cn(styles.modal__close, focusStyles.focusable)}\n aria-label={closeLabel}\n data-dialog-autofocus=\"true\"\n onClick={close}\n >\n <Close aria-hidden=\"true\" />\n </button>\n )}\n {(title || description) && (\n <div className={styles.modal__title}>\n {title && (\n <h2 id={titleId} className={styles.modal__heading}>\n {title}\n </h2>\n )}\n {description && (\n <div id={descriptionId} className={styles.modal__description}>\n {description}\n </div>\n )}\n </div>\n )}\n <div className={styles.modal__content}>{children}</div>\n </div>\n {footer && <div className={styles['modal__bottom-bar']}>{footer}</div>}\n </dialog>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AAUO,MAAM,QAAQ,CAAC;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP,cAAc;AAAA,EACd,aAAa;AAAA,EACb,aAAa;AAAA,EACb,sBAAsB;AAAA,EACtB,aAAa;AAAA,EACb,cAAc;AAAA,EACd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,cAAc;AAAA,EACd,mBAAmB;AAAA,EACnB,oBAAoB;AAAA,EACpB,GAAG;AACP,MAAkB;AACd,QAAM,UAAU,MAAA;AAChB,QAAM,gBAAgB,MAAA;AACtB,QAAM,EAAE,WAAW,OAAO,OAAO,UAAA,IAAc,gBAAgB;AAAA,IAC3D,MAAM,QAAQ;AAAA,IACd;AAAA,IACA;AAAA,EAAA,CACH;AACD,QAAM,cACF,CAAC,cAAc,gBAAgB,QAAW,eAAe,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG,KACnF;AACJ,QAAM,uBAAuB,mBAAmB;AAAA,IAC5C;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACH;AAED,MAAI,CAAC,UAAW,QAAO;AAEvB,SACI;AAAA,IAAC;AAAA,IAAA;AAAA,MACI,GAAG;AAAA,MACJ,KAAK,CAAC,SAAS;AACX,kBAAU,UAAU;AACpB,YAAI,OAAO,QAAQ,WAAY,KAAI,IAAI;AAAA,iBAC9B,SAAS,UAAU;AAAA,MAChC;AAAA,MACA,WAAW;AAAA,QACP,OAAO;AAAA,QACP,gBAAgB;AAAA,QAChB,OAAO,UAAU,IAAI,EAAE;AAAA,Q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
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
4
|
+
const modal = "_modal_ewl1e_1";
|
|
5
|
+
const modal__container = "_modal__container_ewl1e_64";
|
|
6
|
+
const modal__title = "_modal__title_ewl1e_76";
|
|
7
|
+
const modal__heading = "_modal__heading_ewl1e_86";
|
|
8
|
+
const modal__description = "_modal__description_ewl1e_94";
|
|
9
|
+
const modal__content = "_modal__content_ewl1e_98";
|
|
10
|
+
const modal__close = "_modal__close_ewl1e_111";
|
|
11
|
+
const styles = {
|
|
12
|
+
modal,
|
|
13
|
+
"modal--align-top": "_modal--align-top_ewl1e_21",
|
|
14
|
+
"modal--small": "_modal--small_ewl1e_38",
|
|
15
|
+
"modal--medium": "_modal--medium_ewl1e_42",
|
|
16
|
+
"modal--large": "_modal--large_ewl1e_45",
|
|
17
|
+
"modal--opening": "_modal--opening_ewl1e_49",
|
|
18
|
+
"modal-open": "_modal-open_ewl1e_1",
|
|
19
|
+
"modal--closing": "_modal--closing_ewl1e_52",
|
|
20
|
+
"modal-close": "_modal-close_ewl1e_1",
|
|
21
|
+
modal__container,
|
|
22
|
+
"modal--fixed-title": "_modal--fixed-title_ewl1e_72",
|
|
23
|
+
modal__title,
|
|
24
|
+
modal__heading,
|
|
25
|
+
modal__description,
|
|
26
|
+
modal__content,
|
|
27
|
+
modal__close,
|
|
28
|
+
"modal__bottom-bar": "_modal__bottom-bar_ewl1e_132",
|
|
29
|
+
"modal--dark": "_modal--dark_ewl1e_137"
|
|
30
|
+
};
|
|
31
|
+
exports.default = styles;
|
|
32
|
+
exports.modal = modal;
|
|
33
|
+
exports.modal__close = modal__close;
|
|
34
|
+
exports.modal__container = modal__container;
|
|
35
|
+
exports.modal__content = modal__content;
|
|
36
|
+
exports.modal__description = modal__description;
|
|
37
|
+
exports.modal__heading = modal__heading;
|
|
38
|
+
exports.modal__title = modal__title;
|
|
39
|
+
//# sourceMappingURL=Modal.module.css.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Modal.module.css.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import './Modal.css';
|
|
2
|
+
const modal = "_modal_ewl1e_1";
|
|
3
|
+
const modal__container = "_modal__container_ewl1e_64";
|
|
4
|
+
const modal__title = "_modal__title_ewl1e_76";
|
|
5
|
+
const modal__heading = "_modal__heading_ewl1e_86";
|
|
6
|
+
const modal__description = "_modal__description_ewl1e_94";
|
|
7
|
+
const modal__content = "_modal__content_ewl1e_98";
|
|
8
|
+
const modal__close = "_modal__close_ewl1e_111";
|
|
9
|
+
const styles = {
|
|
10
|
+
modal,
|
|
11
|
+
"modal--align-top": "_modal--align-top_ewl1e_21",
|
|
12
|
+
"modal--small": "_modal--small_ewl1e_38",
|
|
13
|
+
"modal--medium": "_modal--medium_ewl1e_42",
|
|
14
|
+
"modal--large": "_modal--large_ewl1e_45",
|
|
15
|
+
"modal--opening": "_modal--opening_ewl1e_49",
|
|
16
|
+
"modal-open": "_modal-open_ewl1e_1",
|
|
17
|
+
"modal--closing": "_modal--closing_ewl1e_52",
|
|
18
|
+
"modal-close": "_modal-close_ewl1e_1",
|
|
19
|
+
modal__container,
|
|
20
|
+
"modal--fixed-title": "_modal--fixed-title_ewl1e_72",
|
|
21
|
+
modal__title,
|
|
22
|
+
modal__heading,
|
|
23
|
+
modal__description,
|
|
24
|
+
modal__content,
|
|
25
|
+
modal__close,
|
|
26
|
+
"modal__bottom-bar": "_modal__bottom-bar_ewl1e_132",
|
|
27
|
+
"modal--dark": "_modal--dark_ewl1e_137"
|
|
28
|
+
};
|
|
29
|
+
export {
|
|
30
|
+
styles as default,
|
|
31
|
+
modal,
|
|
32
|
+
modal__close,
|
|
33
|
+
modal__container,
|
|
34
|
+
modal__content,
|
|
35
|
+
modal__description,
|
|
36
|
+
modal__heading,
|
|
37
|
+
modal__title
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=Modal.module.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Modal.module.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|