@dnanpm/ui-components 0.8.0 → 0.10.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/README.md +13 -0
- package/dist/components/Accordion/Accordion.css +9 -2
- package/dist/components/AccordionItem/AccordionItem.cjs +4 -4
- package/dist/components/AccordionItem/AccordionItem.cjs.map +1 -1
- package/dist/components/AccordionItem/AccordionItem.css +8 -2
- package/dist/components/AccordionItem/AccordionItem.d.ts.map +1 -1
- package/dist/components/AccordionItem/AccordionItem.js +2 -2
- package/dist/components/AccordionItem/AccordionItem.js.map +1 -1
- package/dist/components/Avatar/Avatar.cjs +83 -0
- package/dist/components/Avatar/Avatar.cjs.map +1 -0
- package/dist/components/Avatar/Avatar.css +188 -0
- package/dist/components/Avatar/Avatar.d.ts +3 -0
- package/dist/components/Avatar/Avatar.d.ts.map +1 -0
- package/dist/components/Avatar/Avatar.js +83 -0
- package/dist/components/Avatar/Avatar.js.map +1 -0
- package/dist/components/Avatar/Avatar.module.css.cjs +40 -0
- package/dist/components/Avatar/Avatar.module.css.cjs.map +1 -0
- package/dist/components/Avatar/Avatar.module.css.js +40 -0
- package/dist/components/Avatar/Avatar.module.css.js.map +1 -0
- package/dist/components/Avatar/Avatar.types.d.ts +66 -0
- package/dist/components/Avatar/Avatar.types.d.ts.map +1 -0
- package/dist/components/Avatar/Avatar.utils.cjs +17 -0
- package/dist/components/Avatar/Avatar.utils.cjs.map +1 -0
- package/dist/components/Avatar/Avatar.utils.d.ts +6 -0
- package/dist/components/Avatar/Avatar.utils.d.ts.map +1 -0
- package/dist/components/Avatar/Avatar.utils.js +17 -0
- package/dist/components/Avatar/Avatar.utils.js.map +1 -0
- package/dist/components/Avatar/index.d.ts +3 -0
- package/dist/components/Avatar/index.d.ts.map +1 -0
- package/dist/components/Breadcrumb/Breadcrumb.cjs +9 -12
- package/dist/components/Breadcrumb/Breadcrumb.cjs.map +1 -1
- package/dist/components/Breadcrumb/Breadcrumb.css +20 -17
- package/dist/components/Breadcrumb/Breadcrumb.d.ts.map +1 -1
- package/dist/components/Breadcrumb/Breadcrumb.js +2 -5
- package/dist/components/Breadcrumb/Breadcrumb.js.map +1 -1
- package/dist/components/Breadcrumb/Breadcrumb.module.css.cjs +5 -8
- package/dist/components/Breadcrumb/Breadcrumb.module.css.cjs.map +1 -1
- package/dist/components/Breadcrumb/Breadcrumb.module.css.js +5 -8
- package/dist/components/Breadcrumb/Breadcrumb.module.css.js.map +1 -1
- package/dist/components/Button/Button.cjs +29 -3
- package/dist/components/Button/Button.cjs.map +1 -1
- package/dist/components/Button/Button.css +76 -30
- package/dist/components/Button/Button.d.ts +1 -1
- package/dist/components/Button/Button.d.ts.map +1 -1
- package/dist/components/Button/Button.js +28 -2
- package/dist/components/Button/Button.js.map +1 -1
- package/dist/components/Button/Button.module.css.cjs +19 -11
- package/dist/components/Button/Button.module.css.cjs.map +1 -1
- package/dist/components/Button/Button.module.css.js +19 -11
- package/dist/components/Button/Button.module.css.js.map +1 -1
- package/dist/components/Button/Button.types.d.ts +20 -3
- package/dist/components/Button/Button.types.d.ts.map +1 -1
- package/dist/components/Button/index.d.ts +1 -1
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/ButtonCard/ButtonCard.cjs +19 -14
- package/dist/components/ButtonCard/ButtonCard.cjs.map +1 -1
- package/dist/components/ButtonCard/ButtonCard.css +62 -20
- package/dist/components/ButtonCard/ButtonCard.d.ts +2 -1
- package/dist/components/ButtonCard/ButtonCard.d.ts.map +1 -1
- package/dist/components/ButtonCard/ButtonCard.js +17 -12
- package/dist/components/ButtonCard/ButtonCard.js.map +1 -1
- package/dist/components/ButtonCard/ButtonCard.module.css.cjs +14 -12
- package/dist/components/ButtonCard/ButtonCard.module.css.cjs.map +1 -1
- package/dist/components/ButtonCard/ButtonCard.module.css.js +14 -12
- package/dist/components/ButtonCard/ButtonCard.module.css.js.map +1 -1
- package/dist/components/ButtonCard/ButtonCard.types.d.ts +3 -2
- package/dist/components/ButtonCard/ButtonCard.types.d.ts.map +1 -1
- package/dist/components/Checkbox/Checkbox.cjs +105 -0
- package/dist/components/Checkbox/Checkbox.cjs.map +1 -0
- package/dist/components/Checkbox/Checkbox.css +323 -0
- package/dist/components/Checkbox/Checkbox.d.ts +3 -0
- package/dist/components/Checkbox/Checkbox.d.ts.map +1 -0
- package/dist/components/Checkbox/Checkbox.js +105 -0
- package/dist/components/Checkbox/Checkbox.js.map +1 -0
- package/dist/components/Checkbox/Checkbox.module.css.cjs +35 -0
- package/dist/components/Checkbox/Checkbox.module.css.cjs.map +1 -0
- package/dist/components/Checkbox/Checkbox.module.css.js +35 -0
- package/dist/components/Checkbox/Checkbox.module.css.js.map +1 -0
- package/dist/components/Checkbox/Checkbox.types.d.ts +47 -0
- package/dist/components/Checkbox/Checkbox.types.d.ts.map +1 -0
- package/dist/components/Checkbox/index.d.ts +3 -0
- package/dist/components/Checkbox/index.d.ts.map +1 -0
- package/dist/components/ContentCard/ContentCard.cjs +97 -0
- package/dist/components/ContentCard/ContentCard.cjs.map +1 -0
- package/dist/components/ContentCard/ContentCard.css +254 -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 +97 -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 +100 -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 +15 -7
- package/dist/components/Drawer/Drawer.cjs.map +1 -1
- package/dist/components/Drawer/Drawer.css +47 -45
- package/dist/components/Drawer/Drawer.d.ts.map +1 -1
- package/dist/components/Drawer/Drawer.js +12 -4
- package/dist/components/Drawer/Drawer.js.map +1 -1
- package/dist/components/Drawer/Drawer.module.css.cjs +16 -16
- package/dist/components/Drawer/Drawer.module.css.js +16 -16
- package/dist/components/Footer/Footer.cjs +8 -9
- package/dist/components/Footer/Footer.cjs.map +1 -1
- package/dist/components/Footer/Footer.css +91 -84
- package/dist/components/Footer/Footer.d.ts.map +1 -1
- package/dist/components/Footer/Footer.js +1 -2
- package/dist/components/Footer/Footer.js.map +1 -1
- 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 +2 -2
- package/dist/components/FunctionButton/FunctionButton.cjs.map +1 -1
- package/dist/components/FunctionButton/FunctionButton.css +5 -2
- package/dist/components/FunctionButton/FunctionButton.js +1 -1
- package/dist/components/FunctionButton/FunctionButton.js.map +1 -1
- package/dist/components/Hero/Hero.cjs +30 -29
- package/dist/components/Hero/Hero.cjs.map +1 -1
- package/dist/components/Hero/Hero.css +86 -74
- package/dist/components/Hero/Hero.d.ts +1 -1
- package/dist/components/Hero/Hero.d.ts.map +1 -1
- package/dist/components/Hero/Hero.js +30 -29
- 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/Hero/Hero.types.d.ts +2 -6
- package/dist/components/Hero/Hero.types.d.ts.map +1 -1
- package/dist/components/IconButton/IconButton.cjs +3 -4
- package/dist/components/IconButton/IconButton.cjs.map +1 -1
- package/dist/components/IconButton/IconButton.css +5 -2
- package/dist/components/IconButton/IconButton.d.ts.map +1 -1
- package/dist/components/IconButton/IconButton.js +1 -2
- package/dist/components/IconButton/IconButton.js.map +1 -1
- package/dist/components/Label/Label.css +5 -2
- package/dist/components/MainNavigation/MainNavigation.cjs +556 -191
- package/dist/components/MainNavigation/MainNavigation.cjs.map +1 -1
- package/dist/components/MainNavigation/MainNavigation.css +297 -170
- 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 +526 -161
- package/dist/components/MainNavigation/MainNavigation.js.map +1 -1
- package/dist/components/MainNavigation/MainNavigation.module.css.cjs +80 -68
- package/dist/components/MainNavigation/MainNavigation.module.css.cjs.map +1 -1
- package/dist/components/MainNavigation/MainNavigation.module.css.js +80 -68
- package/dist/components/MainNavigation/MainNavigation.module.css.js.map +1 -1
- package/dist/components/MainNavigation/MainNavigation.types.d.ts +55 -21
- package/dist/components/MainNavigation/MainNavigation.types.d.ts.map +1 -1
- package/dist/components/MainNavigation/MainNavigation.utils.cjs +28 -4
- package/dist/components/MainNavigation/MainNavigation.utils.cjs.map +1 -1
- package/dist/components/MainNavigation/MainNavigation.utils.d.ts +11 -1
- package/dist/components/MainNavigation/MainNavigation.utils.d.ts.map +1 -1
- package/dist/components/MainNavigation/MainNavigation.utils.js +28 -4
- 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 +14 -6
- package/dist/components/Modal/Modal.cjs.map +1 -1
- package/dist/components/Modal/Modal.css +43 -40
- package/dist/components/Modal/Modal.d.ts.map +1 -1
- package/dist/components/Modal/Modal.js +12 -4
- package/dist/components/Modal/Modal.js.map +1 -1
- package/dist/components/Modal/Modal.module.css.cjs +18 -18
- package/dist/components/Modal/Modal.module.css.js +18 -18
- package/dist/components/Notification/Notification.cjs +3 -2
- package/dist/components/Notification/Notification.cjs.map +1 -1
- package/dist/components/Notification/Notification.css +20 -12
- package/dist/components/Notification/Notification.d.ts.map +1 -1
- package/dist/components/Notification/Notification.js +2 -1
- package/dist/components/Notification/Notification.js.map +1 -1
- package/dist/components/Notification/Notification.module.css.cjs +9 -9
- package/dist/components/Notification/Notification.module.css.js +9 -9
- package/dist/components/Pagination/Pagination.cjs +142 -0
- package/dist/components/Pagination/Pagination.cjs.map +1 -0
- package/dist/components/Pagination/Pagination.css +256 -0
- package/dist/components/Pagination/Pagination.d.ts +3 -0
- package/dist/components/Pagination/Pagination.d.ts.map +1 -0
- package/dist/components/Pagination/Pagination.js +142 -0
- package/dist/components/Pagination/Pagination.js.map +1 -0
- package/dist/components/Pagination/Pagination.module.css.cjs +34 -0
- package/dist/components/Pagination/Pagination.module.css.cjs.map +1 -0
- package/dist/components/Pagination/Pagination.module.css.js +34 -0
- package/dist/components/Pagination/Pagination.module.css.js.map +1 -0
- package/dist/components/Pagination/Pagination.types.d.ts +20 -0
- package/dist/components/Pagination/Pagination.types.d.ts.map +1 -0
- package/dist/components/Pagination/Pagination.utils.cjs +76 -0
- package/dist/components/Pagination/Pagination.utils.cjs.map +1 -0
- package/dist/components/Pagination/Pagination.utils.d.ts +21 -0
- package/dist/components/Pagination/Pagination.utils.d.ts.map +1 -0
- package/dist/components/Pagination/Pagination.utils.js +76 -0
- package/dist/components/Pagination/Pagination.utils.js.map +1 -0
- package/dist/components/Pagination/index.d.ts +3 -0
- package/dist/components/Pagination/index.d.ts.map +1 -0
- package/dist/components/Pictograph/Pictograph.css +9 -2
- package/dist/components/Pictograph/PictographItem.css +9 -2
- package/dist/components/Quote/Quote.css +5 -2
- package/dist/components/Spinner/Spinner.css +9 -2
- package/dist/design-tokens/dist/tokens.cjs +5 -0
- package/dist/design-tokens/dist/tokens.cjs.map +1 -0
- package/dist/design-tokens/dist/tokens.js +5 -0
- package/dist/design-tokens/dist/tokens.js.map +1 -0
- package/dist/index.cjs +8 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +10 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/styles/utilities.css +6 -0
- package/dist/styles/utils/elevation.css +34 -26
- package/dist/styles/utils/focus.css +63 -65
- package/dist/styles/utils/index.cjs +33 -0
- package/dist/styles/utils/index.cjs.map +1 -0
- package/dist/styles/utils/index.d.ts +20 -0
- package/dist/styles/utils/index.d.ts.map +1 -0
- package/dist/styles/utils/index.js +33 -0
- package/dist/styles/utils/index.js.map +1 -0
- package/dist/styles/utils/overlay.css +35 -28
- package/dist/styles/utils/text-decoration.css +19 -12
- package/dist/styles.css +46 -12
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/isRenderable/index.d.ts +2 -0
- package/dist/utils/isRenderable/index.d.ts.map +1 -0
- package/dist/utils/isRenderable/isRenderable.cjs +5 -0
- package/dist/utils/isRenderable/isRenderable.cjs.map +1 -0
- package/dist/utils/isRenderable/isRenderable.d.ts +4 -0
- package/dist/utils/isRenderable/isRenderable.d.ts.map +1 -0
- package/dist/utils/isRenderable/isRenderable.js +5 -0
- package/dist/utils/isRenderable/isRenderable.js.map +1 -0
- package/package.json +12 -4
- package/dist/styles/utils/elevation.module.css.cjs +0 -16
- package/dist/styles/utils/elevation.module.css.cjs.map +0 -1
- package/dist/styles/utils/elevation.module.css.js +0 -16
- package/dist/styles/utils/elevation.module.css.js.map +0 -1
- package/dist/styles/utils/focus.module.css.cjs +0 -16
- package/dist/styles/utils/focus.module.css.cjs.map +0 -1
- package/dist/styles/utils/focus.module.css.js +0 -16
- package/dist/styles/utils/focus.module.css.js.map +0 -1
- package/dist/styles/utils/overlay.module.css.cjs +0 -13
- package/dist/styles/utils/overlay.module.css.cjs.map +0 -1
- package/dist/styles/utils/overlay.module.css.js +0 -13
- package/dist/styles/utils/overlay.module.css.js.map +0 -1
- package/dist/styles/utils/text-decoration.module.css.cjs +0 -13
- package/dist/styles/utils/text-decoration.module.css.cjs.map +0 -1
- package/dist/styles/utils/text-decoration.module.css.js +0 -13
- package/dist/styles/utils/text-decoration.module.css.js.map +0 -1
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
import './Modal.css';
|
|
2
|
-
const modal = "
|
|
3
|
-
const modal__container = "
|
|
4
|
-
const modal__title = "
|
|
5
|
-
const modal__heading = "
|
|
6
|
-
const modal__description = "
|
|
7
|
-
const modal__content = "
|
|
8
|
-
const modal__close = "
|
|
2
|
+
const modal = "_modal_9bjhv_1";
|
|
3
|
+
const modal__container = "_modal__container_9bjhv_64";
|
|
4
|
+
const modal__title = "_modal__title_9bjhv_76";
|
|
5
|
+
const modal__heading = "_modal__heading_9bjhv_86";
|
|
6
|
+
const modal__description = "_modal__description_9bjhv_94";
|
|
7
|
+
const modal__content = "_modal__content_9bjhv_98";
|
|
8
|
+
const modal__close = "_modal__close_9bjhv_111";
|
|
9
9
|
const styles = {
|
|
10
10
|
modal,
|
|
11
|
-
"modal--align-top": "_modal--align-
|
|
12
|
-
"modal--small": "_modal--
|
|
13
|
-
"modal--medium": "_modal--
|
|
14
|
-
"modal--large": "_modal--
|
|
15
|
-
"modal--opening": "_modal--
|
|
16
|
-
"modal-open": "_modal-
|
|
17
|
-
"modal--closing": "_modal--
|
|
18
|
-
"modal-close": "_modal-
|
|
11
|
+
"modal--align-top": "_modal--align-top_9bjhv_21",
|
|
12
|
+
"modal--small": "_modal--small_9bjhv_38",
|
|
13
|
+
"modal--medium": "_modal--medium_9bjhv_42",
|
|
14
|
+
"modal--large": "_modal--large_9bjhv_45",
|
|
15
|
+
"modal--opening": "_modal--opening_9bjhv_49",
|
|
16
|
+
"modal-open": "_modal-open_9bjhv_1",
|
|
17
|
+
"modal--closing": "_modal--closing_9bjhv_52",
|
|
18
|
+
"modal-close": "_modal-close_9bjhv_1",
|
|
19
19
|
modal__container,
|
|
20
|
-
"modal--fixed-title": "_modal--fixed-
|
|
20
|
+
"modal--fixed-title": "_modal--fixed-title_9bjhv_72",
|
|
21
21
|
modal__title,
|
|
22
22
|
modal__heading,
|
|
23
23
|
modal__description,
|
|
24
24
|
modal__content,
|
|
25
25
|
modal__close,
|
|
26
|
-
"modal__bottom-bar": "_modal__bottom-
|
|
27
|
-
"modal--dark": "_modal--
|
|
26
|
+
"modal__bottom-bar": "_modal__bottom-bar_9bjhv_132",
|
|
27
|
+
"modal--dark": "_modal--dark_9bjhv_137"
|
|
28
28
|
};
|
|
29
29
|
export {
|
|
30
30
|
styles as default,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
4
|
const icons = require("@dnanpm/icons");
|
|
5
|
-
const
|
|
5
|
+
const index = require("../../styles/utils/index.cjs");
|
|
6
6
|
const Notification_module = require("./Notification.module.css.cjs");
|
|
7
7
|
const cn = require("../../utils/cn/cn.cjs");
|
|
8
8
|
const variantIcons = {
|
|
@@ -33,6 +33,7 @@ const Notification = ({
|
|
|
33
33
|
"div",
|
|
34
34
|
{
|
|
35
35
|
...props,
|
|
36
|
+
"data-color-scheme": "light",
|
|
36
37
|
ref,
|
|
37
38
|
role,
|
|
38
39
|
className: cn.cn(Notification_module.default.notification, Notification_module.default[`notification--${variant}`], className),
|
|
@@ -43,7 +44,7 @@ const Notification = ({
|
|
|
43
44
|
"button",
|
|
44
45
|
{
|
|
45
46
|
type: "button",
|
|
46
|
-
className: cn.cn(Notification_module.default.notification__close,
|
|
47
|
+
className: cn.cn(Notification_module.default.notification__close, index.focusStyles.focusable),
|
|
47
48
|
onClick: onClose,
|
|
48
49
|
"aria-label": closeLabel,
|
|
49
50
|
children: /* @__PURE__ */ jsxRuntime.jsx(icons.Close, { "aria-hidden": "true" })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Notification.cjs","sources":["../../../src/components/Notification/Notification.tsx"],"sourcesContent":["import type { ComponentType, SVGProps } from 'react';\nimport { Check, Close, Error as ErrorIcon, Info, Warning } from '@dnanpm/icons';\nimport { cn } from '../../utils/cn';\nimport focusStyles from '../../styles/utils
|
|
1
|
+
{"version":3,"file":"Notification.cjs","sources":["../../../src/components/Notification/Notification.tsx"],"sourcesContent":["import type { ComponentType, SVGProps } from 'react';\nimport { Check, Close, Error as ErrorIcon, Info, Warning } from '@dnanpm/icons';\nimport { cn } from '../../utils/cn';\nimport { focusStyles } from '../../styles/utils';\nimport styles from './Notification.module.css';\nimport type { NotificationProps, NotificationVariant } from './Notification.types';\n\nconst variantIcons: Record<NotificationVariant, ComponentType<SVGProps<SVGSVGElement>>> = {\n info: Info,\n success: Check,\n warning: Warning,\n error: ErrorIcon,\n};\n\nconst variantRoles: Record<NotificationVariant, 'status' | 'alert'> = {\n info: 'status',\n success: 'status',\n warning: 'alert',\n error: 'alert',\n};\n\nexport const Notification = ({\n variant,\n children,\n closable = false,\n onClose,\n closeLabel = 'Sulje ilmoitus',\n className,\n ref,\n ...props\n}: NotificationProps) => {\n const Icon = variantIcons[variant];\n const role = variantRoles[variant];\n\n return (\n <div\n {...props}\n data-color-scheme=\"light\"\n ref={ref}\n role={role}\n className={cn(styles.notification, styles[`notification--${variant}`], className)}\n >\n <div className={styles['notification__icon-container']}>\n <Icon className={styles.notification__icon} aria-hidden=\"true\" />\n </div>\n <div className={styles.notification__content}>{children}</div>\n {closable && (\n <button\n type=\"button\"\n className={cn(styles.notification__close, focusStyles.focusable)}\n onClick={onClose}\n aria-label={closeLabel}\n >\n <Close aria-hidden=\"true\" />\n </button>\n )}\n </div>\n );\n};\n"],"names":["Info","Check","Warning","ErrorIcon","jsxs","cn","styles","jsx","focusStyles","Close"],"mappings":";;;;;;;AAOA,MAAM,eAAoF;AAAA,EACtF,MAAMA,MAAAA;AAAAA,EACN,SAASC,MAAAA;AAAAA,EACT,SAASC,MAAAA;AAAAA,EACT,OAAOC,MAAAA;AACX;AAEA,MAAM,eAAgE;AAAA,EAClE,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AAAA,EACT,OAAO;AACX;AAEO,MAAM,eAAe,CAAC;AAAA,EACzB;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX;AAAA,EACA,aAAa;AAAA,EACb;AAAA,EACA;AAAA,EACA,GAAG;AACP,MAAyB;AACrB,QAAM,OAAO,aAAa,OAAO;AACjC,QAAM,OAAO,aAAa,OAAO;AAEjC,SACIC,2BAAAA;AAAAA,IAAC;AAAA,IAAA;AAAA,MACI,GAAG;AAAA,MACJ,qBAAkB;AAAA,MAClB;AAAA,MACA;AAAA,MACA,WAAWC,GAAAA,GAAGC,oBAAAA,QAAO,cAAcA,oBAAAA,QAAO,iBAAiB,OAAO,EAAE,GAAG,SAAS;AAAA,MAEhF,UAAA;AAAA,QAAAC,2BAAAA,IAAC,OAAA,EAAI,WAAWD,oBAAAA,QAAO,8BAA8B,GACjD,UAAAC,2BAAAA,IAAC,MAAA,EAAK,WAAWD,4BAAO,oBAAoB,eAAY,OAAA,CAAO,GACnE;AAAA,QACAC,2BAAAA,IAAC,OAAA,EAAI,WAAWD,oBAAAA,QAAO,uBAAwB,UAAS;AAAA,QACvD,YACGC,2BAAAA;AAAAA,UAAC;AAAA,UAAA;AAAA,YACG,MAAK;AAAA,YACL,WAAWF,GAAAA,GAAGC,oBAAAA,QAAO,qBAAqBE,MAAAA,YAAY,SAAS;AAAA,YAC/D,SAAS;AAAA,YACT,cAAY;AAAA,YAEZ,UAAAD,2BAAAA,IAACE,MAAAA,OAAA,EAAM,eAAY,OAAA,CAAO;AAAA,UAAA;AAAA,QAAA;AAAA,MAC9B;AAAA,IAAA;AAAA,EAAA;AAIhB;;"}
|
|
@@ -1,39 +1,44 @@
|
|
|
1
|
-
@layer dds-components
|
|
1
|
+
@layer dds-base, dds-components;
|
|
2
|
+
|
|
3
|
+
@layer dds-components { @layer fallback, components; }
|
|
4
|
+
|
|
5
|
+
@layer dds-components.components{/**
|
|
2
6
|
* Notification Component Styles
|
|
3
7
|
*
|
|
4
8
|
* Design tokens are consumed via CSS custom properties (variables).
|
|
5
9
|
* These variables come from @dnanpm/design-tokens package.
|
|
6
10
|
*/
|
|
7
11
|
|
|
8
|
-
.
|
|
12
|
+
._notification_1m544_8 {
|
|
9
13
|
display: flex;
|
|
10
14
|
align-items: center;
|
|
11
15
|
gap: var(--spacing-space-16);
|
|
12
16
|
padding-right: var(--spacing-space-20);
|
|
13
17
|
border: 2px solid var(--notification-color);
|
|
14
18
|
border-radius: var(--radius-semantic-sm);
|
|
19
|
+
background-color: var(--color-semantic-surface-base);
|
|
15
20
|
overflow: clip;
|
|
16
21
|
}
|
|
17
22
|
|
|
18
23
|
/* Variant colors */
|
|
19
|
-
._notification--
|
|
24
|
+
._notification--info_1m544_20 {
|
|
20
25
|
--notification-color: var(--color-semantic-status-info);
|
|
21
26
|
}
|
|
22
27
|
|
|
23
|
-
._notification--
|
|
28
|
+
._notification--success_1m544_24 {
|
|
24
29
|
--notification-color: var(--color-semantic-status-success);
|
|
25
30
|
}
|
|
26
31
|
|
|
27
|
-
._notification--
|
|
32
|
+
._notification--warning_1m544_28 {
|
|
28
33
|
--notification-color: var(--color-semantic-status-warning);
|
|
29
34
|
}
|
|
30
35
|
|
|
31
|
-
._notification--
|
|
36
|
+
._notification--error_1m544_32 {
|
|
32
37
|
--notification-color: var(--color-semantic-status-error);
|
|
33
38
|
}
|
|
34
39
|
|
|
35
40
|
/* Icon container */
|
|
36
|
-
._notification__icon-
|
|
41
|
+
._notification__icon-container_1m544_37 {
|
|
37
42
|
/* 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
43
|
--_icon-padding-with-border: 10px;
|
|
39
44
|
--_icon-padding-without-border: 12px;
|
|
@@ -49,14 +54,14 @@
|
|
|
49
54
|
color: var(--color-semantic-foreground-inverse);
|
|
50
55
|
}
|
|
51
56
|
|
|
52
|
-
.
|
|
57
|
+
._notification__icon_1m544_37 {
|
|
53
58
|
width: 24px;
|
|
54
59
|
height: 24px;
|
|
55
60
|
flex: 0 0 auto;
|
|
56
61
|
}
|
|
57
62
|
|
|
58
63
|
/* Content */
|
|
59
|
-
.
|
|
64
|
+
._notification__content_1m544_60 {
|
|
60
65
|
flex: 1 1 auto;
|
|
61
66
|
min-width: 0;
|
|
62
67
|
padding: var(--spacing-space-8) 0;
|
|
@@ -66,7 +71,7 @@
|
|
|
66
71
|
}
|
|
67
72
|
|
|
68
73
|
/* Close button */
|
|
69
|
-
.
|
|
74
|
+
._notification__close_1m544_70 {
|
|
70
75
|
flex: 0 0 auto;
|
|
71
76
|
display: flex;
|
|
72
77
|
align-items: center;
|
|
@@ -83,8 +88,11 @@
|
|
|
83
88
|
cursor: pointer;
|
|
84
89
|
}
|
|
85
90
|
|
|
86
|
-
.
|
|
91
|
+
._notification__close_1m544_70 svg {
|
|
87
92
|
width: 24px;
|
|
88
93
|
height: 24px;
|
|
89
94
|
}
|
|
90
|
-
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Do not edit directly, this file was auto-generated.
|
|
98
|
+
*/ }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Notification.d.ts","sourceRoot":"","sources":["../../../src/components/Notification/Notification.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAuB,MAAM,sBAAsB,CAAC;AAgBnF,eAAO,MAAM,YAAY,GAAI,gFAS1B,iBAAiB,
|
|
1
|
+
{"version":3,"file":"Notification.d.ts","sourceRoot":"","sources":["../../../src/components/Notification/Notification.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAuB,MAAM,sBAAsB,CAAC;AAgBnF,eAAO,MAAM,YAAY,GAAI,gFAS1B,iBAAiB,4CA4BnB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Error, Warning, Check, Info, Close } from "@dnanpm/icons";
|
|
3
|
-
import focusStyles from "../../styles/utils/
|
|
3
|
+
import { focusStyles } from "../../styles/utils/index.js";
|
|
4
4
|
import styles from "./Notification.module.css.js";
|
|
5
5
|
import { cn } from "../../utils/cn/cn.js";
|
|
6
6
|
const variantIcons = {
|
|
@@ -31,6 +31,7 @@ const Notification = ({
|
|
|
31
31
|
"div",
|
|
32
32
|
{
|
|
33
33
|
...props,
|
|
34
|
+
"data-color-scheme": "light",
|
|
34
35
|
ref,
|
|
35
36
|
role,
|
|
36
37
|
className: cn(styles.notification, styles[`notification--${variant}`], className),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Notification.js","sources":["../../../src/components/Notification/Notification.tsx"],"sourcesContent":["import type { ComponentType, SVGProps } from 'react';\nimport { Check, Close, Error as ErrorIcon, Info, Warning } from '@dnanpm/icons';\nimport { cn } from '../../utils/cn';\nimport focusStyles from '../../styles/utils
|
|
1
|
+
{"version":3,"file":"Notification.js","sources":["../../../src/components/Notification/Notification.tsx"],"sourcesContent":["import type { ComponentType, SVGProps } from 'react';\nimport { Check, Close, Error as ErrorIcon, Info, Warning } from '@dnanpm/icons';\nimport { cn } from '../../utils/cn';\nimport { focusStyles } from '../../styles/utils';\nimport styles from './Notification.module.css';\nimport type { NotificationProps, NotificationVariant } from './Notification.types';\n\nconst variantIcons: Record<NotificationVariant, ComponentType<SVGProps<SVGSVGElement>>> = {\n info: Info,\n success: Check,\n warning: Warning,\n error: ErrorIcon,\n};\n\nconst variantRoles: Record<NotificationVariant, 'status' | 'alert'> = {\n info: 'status',\n success: 'status',\n warning: 'alert',\n error: 'alert',\n};\n\nexport const Notification = ({\n variant,\n children,\n closable = false,\n onClose,\n closeLabel = 'Sulje ilmoitus',\n className,\n ref,\n ...props\n}: NotificationProps) => {\n const Icon = variantIcons[variant];\n const role = variantRoles[variant];\n\n return (\n <div\n {...props}\n data-color-scheme=\"light\"\n ref={ref}\n role={role}\n className={cn(styles.notification, styles[`notification--${variant}`], className)}\n >\n <div className={styles['notification__icon-container']}>\n <Icon className={styles.notification__icon} aria-hidden=\"true\" />\n </div>\n <div className={styles.notification__content}>{children}</div>\n {closable && (\n <button\n type=\"button\"\n className={cn(styles.notification__close, focusStyles.focusable)}\n onClick={onClose}\n aria-label={closeLabel}\n >\n <Close aria-hidden=\"true\" />\n </button>\n )}\n </div>\n );\n};\n"],"names":["ErrorIcon"],"mappings":";;;;;AAOA,MAAM,eAAoF;AAAA,EACtF,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AAAA,EACT,OAAOA;AACX;AAEA,MAAM,eAAgE;AAAA,EAClE,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AAAA,EACT,OAAO;AACX;AAEO,MAAM,eAAe,CAAC;AAAA,EACzB;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX;AAAA,EACA,aAAa;AAAA,EACb;AAAA,EACA;AAAA,EACA,GAAG;AACP,MAAyB;AACrB,QAAM,OAAO,aAAa,OAAO;AACjC,QAAM,OAAO,aAAa,OAAO;AAEjC,SACI;AAAA,IAAC;AAAA,IAAA;AAAA,MACI,GAAG;AAAA,MACJ,qBAAkB;AAAA,MAClB;AAAA,MACA;AAAA,MACA,WAAW,GAAG,OAAO,cAAc,OAAO,iBAAiB,OAAO,EAAE,GAAG,SAAS;AAAA,MAEhF,UAAA;AAAA,QAAA,oBAAC,OAAA,EAAI,WAAW,OAAO,8BAA8B,GACjD,UAAA,oBAAC,MAAA,EAAK,WAAW,OAAO,oBAAoB,eAAY,OAAA,CAAO,GACnE;AAAA,QACA,oBAAC,OAAA,EAAI,WAAW,OAAO,uBAAwB,UAAS;AAAA,QACvD,YACG;AAAA,UAAC;AAAA,UAAA;AAAA,YACG,MAAK;AAAA,YACL,WAAW,GAAG,OAAO,qBAAqB,YAAY,SAAS;AAAA,YAC/D,SAAS;AAAA,YACT,cAAY;AAAA,YAEZ,UAAA,oBAAC,OAAA,EAAM,eAAY,OAAA,CAAO;AAAA,UAAA;AAAA,QAAA;AAAA,MAC9B;AAAA,IAAA;AAAA,EAAA;AAIhB;"}
|
|
@@ -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 = "
|
|
5
|
-
const notification__icon = "
|
|
6
|
-
const notification__content = "
|
|
7
|
-
const notification__close = "
|
|
4
|
+
const notification = "_notification_1m544_8";
|
|
5
|
+
const notification__icon = "_notification__icon_1m544_37";
|
|
6
|
+
const notification__content = "_notification__content_1m544_60";
|
|
7
|
+
const notification__close = "_notification__close_1m544_70";
|
|
8
8
|
const styles = {
|
|
9
9
|
notification,
|
|
10
|
-
"notification--info": "_notification--
|
|
11
|
-
"notification--success": "_notification--
|
|
12
|
-
"notification--warning": "_notification--
|
|
13
|
-
"notification--error": "_notification--
|
|
14
|
-
"notification__icon-container": "_notification__icon-
|
|
10
|
+
"notification--info": "_notification--info_1m544_20",
|
|
11
|
+
"notification--success": "_notification--success_1m544_24",
|
|
12
|
+
"notification--warning": "_notification--warning_1m544_28",
|
|
13
|
+
"notification--error": "_notification--error_1m544_32",
|
|
14
|
+
"notification__icon-container": "_notification__icon-container_1m544_37",
|
|
15
15
|
notification__icon,
|
|
16
16
|
notification__content,
|
|
17
17
|
notification__close
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import './Notification.css';
|
|
2
|
-
const notification = "
|
|
3
|
-
const notification__icon = "
|
|
4
|
-
const notification__content = "
|
|
5
|
-
const notification__close = "
|
|
2
|
+
const notification = "_notification_1m544_8";
|
|
3
|
+
const notification__icon = "_notification__icon_1m544_37";
|
|
4
|
+
const notification__content = "_notification__content_1m544_60";
|
|
5
|
+
const notification__close = "_notification__close_1m544_70";
|
|
6
6
|
const styles = {
|
|
7
7
|
notification,
|
|
8
|
-
"notification--info": "_notification--
|
|
9
|
-
"notification--success": "_notification--
|
|
10
|
-
"notification--warning": "_notification--
|
|
11
|
-
"notification--error": "_notification--
|
|
12
|
-
"notification__icon-container": "_notification__icon-
|
|
8
|
+
"notification--info": "_notification--info_1m544_20",
|
|
9
|
+
"notification--success": "_notification--success_1m544_24",
|
|
10
|
+
"notification--warning": "_notification--warning_1m544_28",
|
|
11
|
+
"notification--error": "_notification--error_1m544_32",
|
|
12
|
+
"notification__icon-container": "_notification__icon-container_1m544_37",
|
|
13
13
|
notification__icon,
|
|
14
14
|
notification__content,
|
|
15
15
|
notification__close
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const icons = require("@dnanpm/icons");
|
|
5
|
+
const react = require("react");
|
|
6
|
+
const index = require("../../styles/utils/index.cjs");
|
|
7
|
+
const Pagination_utils = require("./Pagination.utils.cjs");
|
|
8
|
+
const Pagination_module = require("./Pagination.module.css.cjs");
|
|
9
|
+
const cn = require("../../utils/cn/cn.cjs");
|
|
10
|
+
const defaultPageLabel = (page) => `Sivu ${page}`;
|
|
11
|
+
const defaultAnnouncement = (page, total) => `Sivu ${page} / ${total}`;
|
|
12
|
+
const Pagination = ({
|
|
13
|
+
currentPage,
|
|
14
|
+
totalPages,
|
|
15
|
+
onPageChange,
|
|
16
|
+
showPreviousNext = true,
|
|
17
|
+
previousPageLabel = "Edellinen sivu",
|
|
18
|
+
nextPageLabel = "Seuraava sivu",
|
|
19
|
+
formatPageLabel = defaultPageLabel,
|
|
20
|
+
formatPageAnnouncement = defaultAnnouncement,
|
|
21
|
+
className,
|
|
22
|
+
"aria-label": ariaLabel,
|
|
23
|
+
"aria-labelledby": ariaLabelledBy,
|
|
24
|
+
onFocusCapture,
|
|
25
|
+
onBlurCapture,
|
|
26
|
+
ref,
|
|
27
|
+
...props
|
|
28
|
+
}) => {
|
|
29
|
+
Pagination_utils.validatePages(currentPage, totalPages);
|
|
30
|
+
const currentButton = react.useRef(null);
|
|
31
|
+
const focusedButton = react.useRef(null);
|
|
32
|
+
const [announcement, setAnnouncement] = react.useState({
|
|
33
|
+
page: currentPage,
|
|
34
|
+
empty: totalPages === 0,
|
|
35
|
+
text: ""
|
|
36
|
+
});
|
|
37
|
+
if (announcement.page !== currentPage || announcement.empty !== (totalPages === 0)) {
|
|
38
|
+
setAnnouncement({
|
|
39
|
+
page: currentPage,
|
|
40
|
+
empty: totalPages === 0,
|
|
41
|
+
text: totalPages > 0 && !announcement.empty && announcement.page !== currentPage ? formatPageAnnouncement(currentPage, totalPages) : ""
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
react.useLayoutEffect(() => {
|
|
45
|
+
const focused = focusedButton.current;
|
|
46
|
+
if (focused && (!focused.isConnected || focused.disabled) && (document.activeElement === document.body || document.activeElement === focused)) {
|
|
47
|
+
currentButton.current?.focus();
|
|
48
|
+
}
|
|
49
|
+
}, [currentPage, totalPages, showPreviousNext]);
|
|
50
|
+
if (totalPages === 0) return null;
|
|
51
|
+
const requestPage = (page) => {
|
|
52
|
+
if (page !== currentPage) onPageChange(page);
|
|
53
|
+
};
|
|
54
|
+
const buttonClass = cn.cn(Pagination_module.default.pagination__button, index.focusStyles.focusable);
|
|
55
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
56
|
+
"nav",
|
|
57
|
+
{
|
|
58
|
+
ref,
|
|
59
|
+
className: cn.cn(Pagination_module.default.pagination, className),
|
|
60
|
+
"aria-label": ariaLabel ?? (ariaLabelledBy ? void 0 : "Sivutus"),
|
|
61
|
+
"aria-labelledby": ariaLabelledBy,
|
|
62
|
+
onFocusCapture: (event) => {
|
|
63
|
+
if (event.target instanceof HTMLButtonElement) focusedButton.current = event.target;
|
|
64
|
+
onFocusCapture?.(event);
|
|
65
|
+
},
|
|
66
|
+
onBlurCapture: (event) => {
|
|
67
|
+
const button = focusedButton.current;
|
|
68
|
+
const focusLeftPagination = event.relatedTarget ? !event.currentTarget.contains(event.relatedTarget) : button?.isConnected && !button.disabled;
|
|
69
|
+
if (focusLeftPagination) {
|
|
70
|
+
focusedButton.current = null;
|
|
71
|
+
}
|
|
72
|
+
onBlurCapture?.(event);
|
|
73
|
+
},
|
|
74
|
+
...props,
|
|
75
|
+
children: [
|
|
76
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
77
|
+
"ul",
|
|
78
|
+
{
|
|
79
|
+
className: cn.cn(
|
|
80
|
+
Pagination_module.default.pagination__list,
|
|
81
|
+
Pagination_module.default[`pagination__list--${Pagination_utils.getPageWidth(totalPages)}`],
|
|
82
|
+
{ [Pagination_module.default["pagination__list--arrows"]]: showPreviousNext }
|
|
83
|
+
),
|
|
84
|
+
children: [
|
|
85
|
+
showPreviousNext && /* @__PURE__ */ jsxRuntime.jsx("li", { className: Pagination_module.default.pagination__arrow, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
86
|
+
"button",
|
|
87
|
+
{
|
|
88
|
+
type: "button",
|
|
89
|
+
className: buttonClass,
|
|
90
|
+
"aria-label": previousPageLabel,
|
|
91
|
+
disabled: currentPage === 1,
|
|
92
|
+
onClick: () => requestPage(currentPage - 1),
|
|
93
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.ChevronLeftFilled, { "aria-hidden": "true", size: "16" })
|
|
94
|
+
}
|
|
95
|
+
) }),
|
|
96
|
+
Pagination_utils.getPageCandidates(currentPage, totalPages).map(({ item, budgets }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
97
|
+
"li",
|
|
98
|
+
{
|
|
99
|
+
className: cn.cn(
|
|
100
|
+
Pagination_module.default.pagination__item,
|
|
101
|
+
{
|
|
102
|
+
[Pagination_module.default["pagination__item--current"]]: item.kind === "page" && item.page === currentPage
|
|
103
|
+
},
|
|
104
|
+
budgets.map((budget) => Pagination_module.default[`pagination__item--${budget}`])
|
|
105
|
+
),
|
|
106
|
+
"aria-hidden": item.kind === "gap" ? true : void 0,
|
|
107
|
+
children: item.kind === "page" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
108
|
+
"button",
|
|
109
|
+
{
|
|
110
|
+
type: "button",
|
|
111
|
+
ref: item.page === currentPage ? currentButton : void 0,
|
|
112
|
+
className: buttonClass,
|
|
113
|
+
"aria-label": formatPageLabel(item.page),
|
|
114
|
+
"aria-current": item.page === currentPage ? "page" : void 0,
|
|
115
|
+
onClick: () => requestPage(item.page),
|
|
116
|
+
children: item.page
|
|
117
|
+
}
|
|
118
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: Pagination_module.default.pagination__gap, children: /* @__PURE__ */ jsxRuntime.jsx(icons.MoreFilled, { "aria-hidden": "true", size: "16" }) })
|
|
119
|
+
},
|
|
120
|
+
item.key
|
|
121
|
+
)),
|
|
122
|
+
showPreviousNext && /* @__PURE__ */ jsxRuntime.jsx("li", { className: Pagination_module.default.pagination__arrow, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
123
|
+
"button",
|
|
124
|
+
{
|
|
125
|
+
type: "button",
|
|
126
|
+
className: buttonClass,
|
|
127
|
+
"aria-label": nextPageLabel,
|
|
128
|
+
disabled: currentPage === totalPages,
|
|
129
|
+
onClick: () => requestPage(currentPage + 1),
|
|
130
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.ChevronRightFilled, { "aria-hidden": "true", size: "16" })
|
|
131
|
+
}
|
|
132
|
+
) })
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
),
|
|
136
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: Pagination_module.default["pagination__sr-only"], "aria-live": "polite", "aria-atomic": "true", children: announcement.text })
|
|
137
|
+
]
|
|
138
|
+
}
|
|
139
|
+
);
|
|
140
|
+
};
|
|
141
|
+
exports.Pagination = Pagination;
|
|
142
|
+
//# sourceMappingURL=Pagination.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Pagination.cjs","sources":["../../../src/components/Pagination/Pagination.tsx"],"sourcesContent":["import { ChevronLeftFilled, ChevronRightFilled, MoreFilled } from '@dnanpm/icons';\nimport { useLayoutEffect, useRef, useState } from 'react';\nimport { cn } from '../../utils/cn';\nimport { focusStyles } from '../../styles/utils';\nimport type { PaginationProps } from './Pagination.types';\nimport { getPageCandidates, getPageWidth, validatePages } from './Pagination.utils';\nimport styles from './Pagination.module.css';\n\nconst defaultPageLabel = (page: number) => `Sivu ${page}`;\nconst defaultAnnouncement = (page: number, total: number) => `Sivu ${page} / ${total}`;\n\nexport const Pagination = ({\n currentPage,\n totalPages,\n onPageChange,\n showPreviousNext = true,\n previousPageLabel = 'Edellinen sivu',\n nextPageLabel = 'Seuraava sivu',\n formatPageLabel = defaultPageLabel,\n formatPageAnnouncement = defaultAnnouncement,\n className,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n onFocusCapture,\n onBlurCapture,\n ref,\n ...props\n}: PaginationProps) => {\n validatePages(currentPage, totalPages);\n const currentButton = useRef<HTMLButtonElement>(null);\n const focusedButton = useRef<HTMLButtonElement | null>(null);\n const [announcement, setAnnouncement] = useState({\n page: currentPage,\n empty: totalPages === 0,\n text: '',\n });\n\n if (announcement.page !== currentPage || announcement.empty !== (totalPages === 0)) {\n setAnnouncement({\n page: currentPage,\n empty: totalPages === 0,\n text:\n totalPages > 0 && !announcement.empty && announcement.page !== currentPage\n ? formatPageAnnouncement(currentPage, totalPages)\n : '',\n });\n }\n\n useLayoutEffect(() => {\n const focused = focusedButton.current;\n if (\n focused &&\n (!focused.isConnected || focused.disabled) &&\n (document.activeElement === document.body || document.activeElement === focused)\n ) {\n currentButton.current?.focus();\n }\n }, [currentPage, totalPages, showPreviousNext]);\n\n if (totalPages === 0) return null;\n\n const requestPage = (page: number) => {\n if (page !== currentPage) onPageChange(page);\n };\n const buttonClass = cn(styles.pagination__button, focusStyles.focusable);\n\n return (\n <nav\n ref={ref}\n className={cn(styles.pagination, className)}\n aria-label={ariaLabel ?? (ariaLabelledBy ? undefined : 'Sivutus')}\n aria-labelledby={ariaLabelledBy}\n onFocusCapture={(event) => {\n if (event.target instanceof HTMLButtonElement) focusedButton.current = event.target;\n onFocusCapture?.(event);\n }}\n onBlurCapture={(event) => {\n const button = focusedButton.current;\n const focusLeftPagination = event.relatedTarget\n ? !event.currentTarget.contains(event.relatedTarget)\n : button?.isConnected && !button.disabled;\n\n if (focusLeftPagination) {\n focusedButton.current = null;\n }\n onBlurCapture?.(event);\n }}\n {...props}\n >\n <ul\n className={cn(\n styles.pagination__list,\n styles[`pagination__list--${getPageWidth(totalPages)}`],\n { [styles['pagination__list--arrows']]: showPreviousNext },\n )}\n >\n {showPreviousNext && (\n <li className={styles.pagination__arrow}>\n <button\n type=\"button\"\n className={buttonClass}\n aria-label={previousPageLabel}\n disabled={currentPage === 1}\n onClick={() => requestPage(currentPage - 1)}\n >\n <ChevronLeftFilled aria-hidden=\"true\" size=\"16\" />\n </button>\n </li>\n )}\n {getPageCandidates(currentPage, totalPages).map(({ item, budgets }) => (\n <li\n key={item.key}\n className={cn(\n styles.pagination__item,\n {\n [styles['pagination__item--current']]:\n item.kind === 'page' && item.page === currentPage,\n },\n budgets.map((budget) => styles[`pagination__item--${budget}`]),\n )}\n aria-hidden={item.kind === 'gap' ? true : undefined}\n >\n {item.kind === 'page' ? (\n <button\n type=\"button\"\n ref={item.page === currentPage ? currentButton : undefined}\n className={buttonClass}\n aria-label={formatPageLabel(item.page)}\n aria-current={item.page === currentPage ? 'page' : undefined}\n onClick={() => requestPage(item.page)}\n >\n {item.page}\n </button>\n ) : (\n <span className={styles.pagination__gap}>\n <MoreFilled aria-hidden=\"true\" size=\"16\" />\n </span>\n )}\n </li>\n ))}\n {showPreviousNext && (\n <li className={styles.pagination__arrow}>\n <button\n type=\"button\"\n className={buttonClass}\n aria-label={nextPageLabel}\n disabled={currentPage === totalPages}\n onClick={() => requestPage(currentPage + 1)}\n >\n <ChevronRightFilled aria-hidden=\"true\" size=\"16\" />\n </button>\n </li>\n )}\n </ul>\n <span className={styles['pagination__sr-only']} aria-live=\"polite\" aria-atomic=\"true\">\n {announcement.text}\n </span>\n </nav>\n );\n};\n"],"names":["validatePages","useRef","useState","useLayoutEffect","cn","styles","focusStyles","jsxs","getPageWidth","jsx","ChevronLeftFilled","getPageCandidates","MoreFilled","ChevronRightFilled"],"mappings":"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"}
|