@navikt/ds-react 7.33.5 → 7.34.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/cjs/alert/Alert.js +2 -4
- package/cjs/alert/Alert.js.map +1 -1
- package/cjs/alert/base-alert/close-button/BaseAlertCloseButton.d.ts +17 -0
- package/cjs/alert/base-alert/close-button/BaseAlertCloseButton.js +72 -0
- package/cjs/alert/base-alert/close-button/BaseAlertCloseButton.js.map +1 -0
- package/cjs/alert/base-alert/content/BaseAlertContent.d.ts +20 -0
- package/cjs/alert/base-alert/content/BaseAlertContent.js +70 -0
- package/cjs/alert/base-alert/content/BaseAlertContent.js.map +1 -0
- package/cjs/alert/base-alert/header/BaseAlertHeader.d.ts +22 -0
- package/cjs/alert/base-alert/header/BaseAlertHeader.js +77 -0
- package/cjs/alert/base-alert/header/BaseAlertHeader.js.map +1 -0
- package/cjs/alert/base-alert/index.d.ts +1 -0
- package/cjs/alert/base-alert/index.js +39 -0
- package/cjs/alert/base-alert/index.js.map +1 -0
- package/cjs/alert/base-alert/namespace.d.ts +10 -0
- package/cjs/alert/base-alert/namespace.js +14 -0
- package/cjs/alert/base-alert/namespace.js.map +1 -0
- package/cjs/alert/base-alert/root/BaseAlertRoot.context.d.ts +12 -0
- package/cjs/alert/base-alert/root/BaseAlertRoot.context.js +11 -0
- package/cjs/alert/base-alert/root/BaseAlertRoot.context.js.map +1 -0
- package/cjs/alert/base-alert/root/BaseAlertRoot.d.ts +43 -0
- package/cjs/alert/base-alert/root/BaseAlertRoot.js +65 -0
- package/cjs/alert/base-alert/root/BaseAlertRoot.js.map +1 -0
- package/cjs/alert/base-alert/root/BaseAlertRoot.utils.d.ts +9 -0
- package/cjs/alert/base-alert/root/BaseAlertRoot.utils.js +48 -0
- package/cjs/alert/base-alert/root/BaseAlertRoot.utils.js.map +1 -0
- package/cjs/alert/base-alert/title/BaseAlertTitle.d.ts +24 -0
- package/cjs/alert/base-alert/title/BaseAlertTitle.js +77 -0
- package/cjs/alert/base-alert/title/BaseAlertTitle.js.map +1 -0
- package/cjs/alert/global-alert/close-button/GlobalAlertCloseButton.d.ts +17 -0
- package/cjs/alert/global-alert/close-button/GlobalAlertCloseButton.js +19 -0
- package/cjs/alert/global-alert/close-button/GlobalAlertCloseButton.js.map +1 -0
- package/cjs/alert/global-alert/content/GlobalAlertContent.d.ts +18 -0
- package/cjs/alert/global-alert/content/GlobalAlertContent.js +20 -0
- package/cjs/alert/global-alert/content/GlobalAlertContent.js.map +1 -0
- package/cjs/alert/global-alert/header/GlobalAlertHeader.d.ts +17 -0
- package/cjs/alert/global-alert/header/GlobalAlertHeader.js +54 -0
- package/cjs/alert/global-alert/header/GlobalAlertHeader.js.map +1 -0
- package/cjs/alert/global-alert/index.d.ts +2 -0
- package/cjs/alert/global-alert/index.js +11 -0
- package/cjs/alert/global-alert/index.js.map +1 -0
- package/cjs/alert/global-alert/root/GlobalAlertRoot.d.ts +81 -0
- package/cjs/alert/global-alert/root/GlobalAlertRoot.js +69 -0
- package/cjs/alert/global-alert/root/GlobalAlertRoot.js.map +1 -0
- package/cjs/alert/global-alert/title/GlobalAlertTitle.d.ts +17 -0
- package/cjs/alert/global-alert/title/GlobalAlertTitle.js +19 -0
- package/cjs/alert/global-alert/title/GlobalAlertTitle.js.map +1 -0
- package/cjs/alert/info-card/content/InfoCardContent.d.ts +18 -0
- package/cjs/alert/info-card/content/InfoCardContent.js +20 -0
- package/cjs/alert/info-card/content/InfoCardContent.js.map +1 -0
- package/cjs/alert/info-card/header/InfoCardHeader.d.ts +16 -0
- package/cjs/alert/info-card/header/InfoCardHeader.js +18 -0
- package/cjs/alert/info-card/header/InfoCardHeader.js.map +1 -0
- package/cjs/alert/info-card/index.d.ts +2 -0
- package/cjs/alert/info-card/index.js +10 -0
- package/cjs/alert/info-card/index.js.map +1 -0
- package/cjs/alert/info-card/root/InfoCardRoot.d.ts +76 -0
- package/cjs/alert/info-card/root/InfoCardRoot.js +78 -0
- package/cjs/alert/info-card/root/InfoCardRoot.js.map +1 -0
- package/cjs/alert/info-card/title/InfoCardTitle.d.ts +17 -0
- package/cjs/alert/info-card/title/InfoCardTitle.js +19 -0
- package/cjs/alert/info-card/title/InfoCardTitle.js.map +1 -0
- package/cjs/alert/local-alert/close-button/LocalAlertCloseButton.d.ts +17 -0
- package/cjs/alert/local-alert/close-button/LocalAlertCloseButton.js +19 -0
- package/cjs/alert/local-alert/close-button/LocalAlertCloseButton.js.map +1 -0
- package/cjs/alert/local-alert/content/LocalAlertContent.d.ts +18 -0
- package/cjs/alert/local-alert/content/LocalAlertContent.js +20 -0
- package/cjs/alert/local-alert/content/LocalAlertContent.js.map +1 -0
- package/cjs/alert/local-alert/header/LocalAlertHeader.d.ts +17 -0
- package/cjs/alert/local-alert/header/LocalAlertHeader.js +54 -0
- package/cjs/alert/local-alert/header/LocalAlertHeader.js.map +1 -0
- package/cjs/alert/local-alert/index.d.ts +2 -0
- package/cjs/alert/local-alert/index.js +11 -0
- package/cjs/alert/local-alert/index.js.map +1 -0
- package/cjs/alert/local-alert/root/LocalAlertRoot.d.ts +81 -0
- package/cjs/alert/local-alert/root/LocalAlertRoot.js +81 -0
- package/cjs/alert/local-alert/root/LocalAlertRoot.js.map +1 -0
- package/cjs/alert/local-alert/title/LocalAlertTitle.d.ts +17 -0
- package/cjs/alert/local-alert/title/LocalAlertTitle.js +19 -0
- package/cjs/alert/local-alert/title/LocalAlertTitle.js.map +1 -0
- package/cjs/date/Date.locale.d.ts +5 -0
- package/cjs/index.d.ts +4 -0
- package/cjs/index.js +9 -1
- package/cjs/index.js.map +1 -1
- package/cjs/inline-message/icon/InlineMessageIcon.d.ts +5 -0
- package/cjs/inline-message/icon/InlineMessageIcon.js +24 -0
- package/cjs/inline-message/icon/InlineMessageIcon.js.map +1 -0
- package/cjs/inline-message/index.d.ts +2 -0
- package/cjs/inline-message/index.js +7 -0
- package/cjs/inline-message/index.js.map +1 -0
- package/cjs/inline-message/root/InlineMessage.d.ts +36 -0
- package/cjs/inline-message/root/InlineMessage.js +91 -0
- package/cjs/inline-message/root/InlineMessage.js.map +1 -0
- package/cjs/timeline/period/ClickablePeriod.js +3 -15
- package/cjs/timeline/period/ClickablePeriod.js.map +1 -1
- package/cjs/timeline/pin/PinInternal.js +3 -15
- package/cjs/timeline/pin/PinInternal.js.map +1 -1
- package/cjs/util/i18n/locales/en.d.ts +1 -4
- package/cjs/util/i18n/locales/en.js +1 -4
- package/cjs/util/i18n/locales/en.js.map +1 -1
- package/cjs/util/i18n/locales/nb.d.ts +2 -6
- package/cjs/util/i18n/locales/nb.js +2 -6
- package/cjs/util/i18n/locales/nb.js.map +1 -1
- package/cjs/util/i18n/locales/nn.d.ts +1 -4
- package/cjs/util/i18n/locales/nn.js +1 -4
- package/cjs/util/i18n/locales/nn.js.map +1 -1
- package/esm/alert/Alert.js +2 -4
- package/esm/alert/Alert.js.map +1 -1
- package/esm/alert/base-alert/close-button/BaseAlertCloseButton.d.ts +17 -0
- package/esm/alert/base-alert/close-button/BaseAlertCloseButton.js +36 -0
- package/esm/alert/base-alert/close-button/BaseAlertCloseButton.js.map +1 -0
- package/esm/alert/base-alert/content/BaseAlertContent.d.ts +20 -0
- package/esm/alert/base-alert/content/BaseAlertContent.js +34 -0
- package/esm/alert/base-alert/content/BaseAlertContent.js.map +1 -0
- package/esm/alert/base-alert/header/BaseAlertHeader.d.ts +22 -0
- package/esm/alert/base-alert/header/BaseAlertHeader.js +41 -0
- package/esm/alert/base-alert/header/BaseAlertHeader.js.map +1 -0
- package/esm/alert/base-alert/index.d.ts +1 -0
- package/esm/alert/base-alert/index.js +3 -0
- package/esm/alert/base-alert/index.js.map +1 -0
- package/esm/alert/base-alert/namespace.d.ts +10 -0
- package/esm/alert/base-alert/namespace.js +6 -0
- package/esm/alert/base-alert/namespace.js.map +1 -0
- package/esm/alert/base-alert/root/BaseAlertRoot.context.d.ts +12 -0
- package/esm/alert/base-alert/root/BaseAlertRoot.context.js +7 -0
- package/esm/alert/base-alert/root/BaseAlertRoot.context.js.map +1 -0
- package/esm/alert/base-alert/root/BaseAlertRoot.d.ts +43 -0
- package/esm/alert/base-alert/root/BaseAlertRoot.js +29 -0
- package/esm/alert/base-alert/root/BaseAlertRoot.js.map +1 -0
- package/esm/alert/base-alert/root/BaseAlertRoot.utils.d.ts +9 -0
- package/esm/alert/base-alert/root/BaseAlertRoot.utils.js +42 -0
- package/esm/alert/base-alert/root/BaseAlertRoot.utils.js.map +1 -0
- package/esm/alert/base-alert/title/BaseAlertTitle.d.ts +24 -0
- package/esm/alert/base-alert/title/BaseAlertTitle.js +38 -0
- package/esm/alert/base-alert/title/BaseAlertTitle.js.map +1 -0
- package/esm/alert/global-alert/close-button/GlobalAlertCloseButton.d.ts +17 -0
- package/esm/alert/global-alert/close-button/GlobalAlertCloseButton.js +16 -0
- package/esm/alert/global-alert/close-button/GlobalAlertCloseButton.js.map +1 -0
- package/esm/alert/global-alert/content/GlobalAlertContent.d.ts +18 -0
- package/esm/alert/global-alert/content/GlobalAlertContent.js +17 -0
- package/esm/alert/global-alert/content/GlobalAlertContent.js.map +1 -0
- package/esm/alert/global-alert/header/GlobalAlertHeader.d.ts +17 -0
- package/esm/alert/global-alert/header/GlobalAlertHeader.js +18 -0
- package/esm/alert/global-alert/header/GlobalAlertHeader.js.map +1 -0
- package/esm/alert/global-alert/index.d.ts +2 -0
- package/esm/alert/global-alert/index.js +3 -0
- package/esm/alert/global-alert/index.js.map +1 -0
- package/esm/alert/global-alert/root/GlobalAlertRoot.d.ts +81 -0
- package/esm/alert/global-alert/root/GlobalAlertRoot.js +30 -0
- package/esm/alert/global-alert/root/GlobalAlertRoot.js.map +1 -0
- package/esm/alert/global-alert/title/GlobalAlertTitle.d.ts +17 -0
- package/esm/alert/global-alert/title/GlobalAlertTitle.js +16 -0
- package/esm/alert/global-alert/title/GlobalAlertTitle.js.map +1 -0
- package/esm/alert/info-card/content/InfoCardContent.d.ts +18 -0
- package/esm/alert/info-card/content/InfoCardContent.js +17 -0
- package/esm/alert/info-card/content/InfoCardContent.js.map +1 -0
- package/esm/alert/info-card/header/InfoCardHeader.d.ts +16 -0
- package/esm/alert/info-card/header/InfoCardHeader.js +15 -0
- package/esm/alert/info-card/header/InfoCardHeader.js.map +1 -0
- package/esm/alert/info-card/index.d.ts +2 -0
- package/esm/alert/info-card/index.js +3 -0
- package/esm/alert/info-card/index.js.map +1 -0
- package/esm/alert/info-card/root/InfoCardRoot.d.ts +76 -0
- package/esm/alert/info-card/root/InfoCardRoot.js +40 -0
- package/esm/alert/info-card/root/InfoCardRoot.js.map +1 -0
- package/esm/alert/info-card/title/InfoCardTitle.d.ts +17 -0
- package/esm/alert/info-card/title/InfoCardTitle.js +16 -0
- package/esm/alert/info-card/title/InfoCardTitle.js.map +1 -0
- package/esm/alert/local-alert/close-button/LocalAlertCloseButton.d.ts +17 -0
- package/esm/alert/local-alert/close-button/LocalAlertCloseButton.js +16 -0
- package/esm/alert/local-alert/close-button/LocalAlertCloseButton.js.map +1 -0
- package/esm/alert/local-alert/content/LocalAlertContent.d.ts +18 -0
- package/esm/alert/local-alert/content/LocalAlertContent.js +17 -0
- package/esm/alert/local-alert/content/LocalAlertContent.js.map +1 -0
- package/esm/alert/local-alert/header/LocalAlertHeader.d.ts +17 -0
- package/esm/alert/local-alert/header/LocalAlertHeader.js +18 -0
- package/esm/alert/local-alert/header/LocalAlertHeader.js.map +1 -0
- package/esm/alert/local-alert/index.d.ts +2 -0
- package/esm/alert/local-alert/index.js +3 -0
- package/esm/alert/local-alert/index.js.map +1 -0
- package/esm/alert/local-alert/root/LocalAlertRoot.d.ts +81 -0
- package/esm/alert/local-alert/root/LocalAlertRoot.js +42 -0
- package/esm/alert/local-alert/root/LocalAlertRoot.js.map +1 -0
- package/esm/alert/local-alert/title/LocalAlertTitle.d.ts +17 -0
- package/esm/alert/local-alert/title/LocalAlertTitle.js +16 -0
- package/esm/alert/local-alert/title/LocalAlertTitle.js.map +1 -0
- package/esm/date/Date.locale.d.ts +5 -0
- package/esm/index.d.ts +4 -0
- package/esm/index.js +4 -0
- package/esm/index.js.map +1 -1
- package/esm/inline-message/icon/InlineMessageIcon.d.ts +5 -0
- package/esm/inline-message/icon/InlineMessageIcon.js +19 -0
- package/esm/inline-message/icon/InlineMessageIcon.js.map +1 -0
- package/esm/inline-message/index.d.ts +2 -0
- package/esm/inline-message/index.js +3 -0
- package/esm/inline-message/index.js.map +1 -0
- package/esm/inline-message/root/InlineMessage.d.ts +36 -0
- package/esm/inline-message/root/InlineMessage.js +52 -0
- package/esm/inline-message/root/InlineMessage.js.map +1 -0
- package/esm/timeline/period/ClickablePeriod.js +6 -18
- package/esm/timeline/period/ClickablePeriod.js.map +1 -1
- package/esm/timeline/pin/PinInternal.js +6 -18
- package/esm/timeline/pin/PinInternal.js.map +1 -1
- package/esm/util/i18n/locales/en.d.ts +1 -4
- package/esm/util/i18n/locales/en.js +1 -4
- package/esm/util/i18n/locales/en.js.map +1 -1
- package/esm/util/i18n/locales/nb.d.ts +2 -6
- package/esm/util/i18n/locales/nb.js +2 -6
- package/esm/util/i18n/locales/nb.js.map +1 -1
- package/esm/util/i18n/locales/nn.d.ts +1 -4
- package/esm/util/i18n/locales/nn.js +1 -4
- package/esm/util/i18n/locales/nn.js.map +1 -1
- package/package.json +45 -4
- package/src/alert/Alert.tsx +2 -10
- package/src/alert/base-alert/close-button/BaseAlertCloseButton.tsx +44 -0
- package/src/alert/base-alert/content/BaseAlertContent.tsx +43 -0
- package/src/alert/base-alert/header/BaseAlertHeader.tsx +61 -0
- package/src/alert/base-alert/index.ts +2 -0
- package/src/alert/base-alert/namespace.ts +11 -0
- package/src/alert/base-alert/root/BaseAlertRoot.context.tsx +17 -0
- package/src/alert/base-alert/root/BaseAlertRoot.tsx +102 -0
- package/src/alert/base-alert/root/BaseAlertRoot.utils.tsx +67 -0
- package/src/alert/base-alert/title/BaseAlertTitle.tsx +63 -0
- package/src/alert/global-alert/close-button/GlobalAlertCloseButton.tsx +20 -0
- package/src/alert/global-alert/content/GlobalAlertContent.tsx +21 -0
- package/src/alert/global-alert/header/GlobalAlertHeader.tsx +24 -0
- package/src/alert/global-alert/index.ts +16 -0
- package/src/alert/global-alert/root/GlobalAlertRoot.tsx +132 -0
- package/src/alert/global-alert/title/GlobalAlertTitle.tsx +20 -0
- package/src/alert/info-card/content/InfoCardContent.tsx +21 -0
- package/src/alert/info-card/header/InfoCardHeader.tsx +19 -0
- package/src/alert/info-card/index.ts +14 -0
- package/src/alert/info-card/root/InfoCardRoot.tsx +120 -0
- package/src/alert/info-card/title/InfoCardTitle.tsx +20 -0
- package/src/alert/local-alert/close-button/LocalAlertCloseButton.tsx +20 -0
- package/src/alert/local-alert/content/LocalAlertContent.tsx +21 -0
- package/src/alert/local-alert/header/LocalAlertHeader.tsx +24 -0
- package/src/alert/local-alert/index.ts +16 -0
- package/src/alert/local-alert/root/LocalAlertRoot.tsx +133 -0
- package/src/alert/local-alert/title/LocalAlertTitle.tsx +20 -0
- package/src/index.ts +24 -0
- package/src/inline-message/icon/InlineMessageIcon.tsx +33 -0
- package/src/inline-message/index.ts +3 -0
- package/src/inline-message/root/InlineMessage.tsx +92 -0
- package/src/timeline/period/ClickablePeriod.tsx +5 -34
- package/src/timeline/pin/PinInternal.tsx +5 -28
- package/src/util/i18n/locales/en.ts +1 -5
- package/src/util/i18n/locales/nb.ts +1 -5
- package/src/util/i18n/locales/nn.ts +1 -5
- package/cjs/util/renderStoriesForChromatic.d.ts +0 -5
- package/cjs/util/renderStoriesForChromatic.js +0 -21
- package/cjs/util/renderStoriesForChromatic.js.map +0 -1
- package/esm/util/renderStoriesForChromatic.d.ts +0 -5
- package/esm/util/renderStoriesForChromatic.js +0 -15
- package/esm/util/renderStoriesForChromatic.js.map +0 -1
- package/src/util/renderStoriesForChromatic.tsx +0 -26
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BaseAlert } from "../../base-alert";
|
|
2
|
+
|
|
3
|
+
type InfoCardHeaderProps = BaseAlert.HeaderProps;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @see 🏷️ {@link InfoCardHeaderProps}
|
|
7
|
+
* @example
|
|
8
|
+
* ```jsx
|
|
9
|
+
* <InfoCard>
|
|
10
|
+
* <InfoCard.Header icon={<InformationSquareIcon aria-hidden />}>
|
|
11
|
+
* <InfoCard.Title>Info title</InfoCard.Title>
|
|
12
|
+
* </InfoCard.Header>
|
|
13
|
+
* </InfoCard>
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
const InfoCardHeader = BaseAlert.Header;
|
|
17
|
+
|
|
18
|
+
export { InfoCardHeader };
|
|
19
|
+
export type { InfoCardHeaderProps };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
export {
|
|
3
|
+
InfoCard,
|
|
4
|
+
InfoCardHeader,
|
|
5
|
+
InfoCardTitle,
|
|
6
|
+
InfoCardContent,
|
|
7
|
+
} from "./root/InfoCardRoot";
|
|
8
|
+
|
|
9
|
+
export type {
|
|
10
|
+
InfoCardProps,
|
|
11
|
+
InfoCardHeaderProps,
|
|
12
|
+
InfoCardTitleProps,
|
|
13
|
+
InfoCardContentProps,
|
|
14
|
+
} from "./root/InfoCardRoot";
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
|
+
import { BaseAlert } from "../../base-alert";
|
|
3
|
+
import {
|
|
4
|
+
InfoCardContent,
|
|
5
|
+
type InfoCardContentProps,
|
|
6
|
+
} from "../content/InfoCardContent";
|
|
7
|
+
import {
|
|
8
|
+
InfoCardHeader,
|
|
9
|
+
type InfoCardHeaderProps,
|
|
10
|
+
} from "../header/InfoCardHeader";
|
|
11
|
+
import { InfoCardTitle, type InfoCardTitleProps } from "../title/InfoCardTitle";
|
|
12
|
+
|
|
13
|
+
type InfoCardProps = Omit<BaseAlert.RootProps, "type" | "global" | "status"> & {
|
|
14
|
+
/**
|
|
15
|
+
* Changes the HTML element used for the root element.
|
|
16
|
+
*
|
|
17
|
+
* **When using `section`, provide either `aria-label` or `aria-labelledby` for better accessibility.**
|
|
18
|
+
* `axe-core` might warn about unique landmarks if you have multiple InfoCards on page with the same label.
|
|
19
|
+
* In those cases consider updating to unique `aria-label` or `aria-labelledby` props.
|
|
20
|
+
* @see [📝 Landmarks unique](https://dequeuniversity.com/rules/axe/4.6/landmark-unique)
|
|
21
|
+
* @default "div"
|
|
22
|
+
*/
|
|
23
|
+
as?: "div" | "section";
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
interface InfoCardComponent
|
|
27
|
+
extends React.ForwardRefExoticComponent<
|
|
28
|
+
InfoCardProps & React.RefAttributes<HTMLDivElement>
|
|
29
|
+
> {
|
|
30
|
+
/**
|
|
31
|
+
* @see 🏷️ {@link InfoCardHeaderProps}
|
|
32
|
+
* @example
|
|
33
|
+
* ```jsx
|
|
34
|
+
* <InfoCard>
|
|
35
|
+
* <InfoCard.Header icon={<InformationSquareIcon aria-hidden />}>
|
|
36
|
+
* <InfoCard.Title>Info title</InfoCard.Title>
|
|
37
|
+
* </InfoCard.Header>
|
|
38
|
+
* </InfoCard>
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
Header: typeof InfoCardHeader;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Title component for InfoCard. Remember to use correct heading-level with the `as` prop.
|
|
45
|
+
* @see 🏷️ {@link InfoCardTitleProps}
|
|
46
|
+
* @example
|
|
47
|
+
* ```jsx
|
|
48
|
+
* <InfoCard>
|
|
49
|
+
* <InfoCard.Header>
|
|
50
|
+
* <InfoCard.Title as="h2">Info title</InfoCard.Title>
|
|
51
|
+
* </InfoCard.Header>
|
|
52
|
+
* </InfoCard>
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
Title: typeof InfoCardTitle;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @see 🏷️ {@link InfoCardContentProps}
|
|
59
|
+
* @example
|
|
60
|
+
* ```jsx
|
|
61
|
+
* <InfoCard>
|
|
62
|
+
* <InfoCard.Header>
|
|
63
|
+
* <InfoCard.Title>Info title</InfoCard.Title>
|
|
64
|
+
* </InfoCard.Header>
|
|
65
|
+
*
|
|
66
|
+
* <InfoCard.Content>Content</InfoCard.Content>
|
|
67
|
+
* </InfoCard>
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
Content: typeof InfoCardContent;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* A component for displaying informational content in a card format.
|
|
75
|
+
* @see [📝 Documentation](https://aksel.nav.no/komponenter/core/infocard)
|
|
76
|
+
* @see 🏷️ {@link InfoCardProps}
|
|
77
|
+
* @example
|
|
78
|
+
* ```jsx
|
|
79
|
+
* <InfoCard data-color="info">
|
|
80
|
+
* <InfoCard.Header icon={<InformationSquareIcon aria-hidden />}>
|
|
81
|
+
* <InfoCard.Title>Info title</InfoCard.Title>
|
|
82
|
+
* </InfoCard.Header>
|
|
83
|
+
* <InfoCard.Content>Content</InfoCard.Content>
|
|
84
|
+
* </InfoCard>
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export const InfoCard = forwardRef<HTMLDivElement, InfoCardProps>(
|
|
88
|
+
(
|
|
89
|
+
{
|
|
90
|
+
"data-color": dataColor = "info",
|
|
91
|
+
as = "div",
|
|
92
|
+
...restProps
|
|
93
|
+
}: InfoCardProps,
|
|
94
|
+
forwardedRef,
|
|
95
|
+
) => {
|
|
96
|
+
return (
|
|
97
|
+
<BaseAlert.Root
|
|
98
|
+
ref={forwardedRef}
|
|
99
|
+
data-color={dataColor}
|
|
100
|
+
{...restProps}
|
|
101
|
+
type="moderate"
|
|
102
|
+
global={false}
|
|
103
|
+
as={as}
|
|
104
|
+
/>
|
|
105
|
+
);
|
|
106
|
+
},
|
|
107
|
+
) as InfoCardComponent;
|
|
108
|
+
|
|
109
|
+
InfoCard.Header = InfoCardHeader;
|
|
110
|
+
InfoCard.Title = InfoCardTitle;
|
|
111
|
+
InfoCard.Content = InfoCardContent;
|
|
112
|
+
|
|
113
|
+
export default InfoCard;
|
|
114
|
+
export { InfoCardContent, InfoCardHeader, InfoCardTitle };
|
|
115
|
+
export type {
|
|
116
|
+
InfoCardProps,
|
|
117
|
+
InfoCardHeaderProps,
|
|
118
|
+
InfoCardTitleProps,
|
|
119
|
+
InfoCardContentProps,
|
|
120
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BaseAlert } from "../../base-alert";
|
|
2
|
+
|
|
3
|
+
type InfoCardTitleProps = BaseAlert.TitleProps;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Title component for InfoCard. Remember to use correct heading-level with the `as` prop.
|
|
7
|
+
* @see 🏷️ {@link InfoCardTitleProps}
|
|
8
|
+
* @example
|
|
9
|
+
* ```jsx
|
|
10
|
+
* <InfoCard>
|
|
11
|
+
* <InfoCard.Header>
|
|
12
|
+
* <InfoCard.Title as="h2">Info title</InfoCard.Title>
|
|
13
|
+
* </InfoCard.Header>
|
|
14
|
+
* </InfoCard>
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
const InfoCardTitle = BaseAlert.Title;
|
|
18
|
+
|
|
19
|
+
export { InfoCardTitle };
|
|
20
|
+
export type { InfoCardTitleProps };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BaseAlert } from "../../base-alert";
|
|
2
|
+
|
|
3
|
+
type LocalAlertCloseButtonProps = BaseAlert.CloseButtonProps;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @see 🏷️ {@link LocalAlertCloseButtonProps}
|
|
7
|
+
* @example
|
|
8
|
+
* ```jsx
|
|
9
|
+
* <LocalAlert>
|
|
10
|
+
* <LocalAlert.Header>
|
|
11
|
+
* <LocalAlert.Title>Info title</LocalAlert.Title>
|
|
12
|
+
* <LocalAlert.CloseButton onClick={() => alert("Closed!")} />
|
|
13
|
+
* </LocalAlert.Header>
|
|
14
|
+
* </LocalAlert>
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
const LocalAlertCloseButton = BaseAlert.CloseButton;
|
|
18
|
+
|
|
19
|
+
export { LocalAlertCloseButton };
|
|
20
|
+
export type { LocalAlertCloseButtonProps };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BaseAlert } from "../../base-alert";
|
|
2
|
+
|
|
3
|
+
type LocalAlertContentProps = BaseAlert.ContentProps;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @see 🏷️ {@link LocalAlertContentProps}
|
|
7
|
+
* @example
|
|
8
|
+
* ```jsx
|
|
9
|
+
* <LocalAlert>
|
|
10
|
+
* <LocalAlert.Header>
|
|
11
|
+
* <LocalAlert.Title>Info title</LocalAlert.Title>
|
|
12
|
+
* </LocalAlert.Header>
|
|
13
|
+
*
|
|
14
|
+
* <LocalAlert.Content>Content</LocalAlert.Content>
|
|
15
|
+
* </LocalAlert>
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
const LocalAlertContent = BaseAlert.Content;
|
|
19
|
+
|
|
20
|
+
export { LocalAlertContent };
|
|
21
|
+
export type { LocalAlertContentProps };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
|
+
import { BaseAlert } from "../../base-alert";
|
|
3
|
+
|
|
4
|
+
type LocalAlertHeaderProps = Omit<BaseAlert.HeaderProps, "icon">;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @see 🏷️ {@link LocalAlertHeaderProps}
|
|
8
|
+
* @example
|
|
9
|
+
* ```jsx
|
|
10
|
+
* <LocalAlert>
|
|
11
|
+
* <LocalAlert.Header>
|
|
12
|
+
* <LocalAlert.Title>Info title</LocalAlert.Title>
|
|
13
|
+
* </LocalAlert.Header>
|
|
14
|
+
* </LocalAlert>
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
const LocalAlertHeader = forwardRef<HTMLDivElement, LocalAlertHeaderProps>(
|
|
18
|
+
(props, forwardedRef) => {
|
|
19
|
+
return <BaseAlert.Header ref={forwardedRef} {...props} />;
|
|
20
|
+
},
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
export { LocalAlertHeader };
|
|
24
|
+
export type { LocalAlertHeaderProps };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
export {
|
|
3
|
+
LocalAlert,
|
|
4
|
+
LocalAlertHeader,
|
|
5
|
+
LocalAlertTitle,
|
|
6
|
+
LocalAlertContent,
|
|
7
|
+
LocalAlertCloseButton,
|
|
8
|
+
} from "./root/LocalAlertRoot";
|
|
9
|
+
|
|
10
|
+
export type {
|
|
11
|
+
LocalAlertProps,
|
|
12
|
+
LocalAlertHeaderProps,
|
|
13
|
+
LocalAlertTitleProps,
|
|
14
|
+
LocalAlertContentProps,
|
|
15
|
+
LocalAlertCloseButtonProps,
|
|
16
|
+
} from "./root/LocalAlertRoot";
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
|
+
import { BaseAlert } from "../../base-alert";
|
|
3
|
+
import {
|
|
4
|
+
LocalAlertCloseButton,
|
|
5
|
+
type LocalAlertCloseButtonProps,
|
|
6
|
+
} from "../close-button/LocalAlertCloseButton";
|
|
7
|
+
import {
|
|
8
|
+
LocalAlertContent,
|
|
9
|
+
type LocalAlertContentProps,
|
|
10
|
+
} from "../content/LocalAlertContent";
|
|
11
|
+
import {
|
|
12
|
+
LocalAlertHeader,
|
|
13
|
+
type LocalAlertHeaderProps,
|
|
14
|
+
} from "../header/LocalAlertHeader";
|
|
15
|
+
import {
|
|
16
|
+
LocalAlertTitle,
|
|
17
|
+
type LocalAlertTitleProps,
|
|
18
|
+
} from "../title/LocalAlertTitle";
|
|
19
|
+
|
|
20
|
+
interface LocalAlertProps
|
|
21
|
+
extends Omit<BaseAlert.RootProps, "type" | "global" | "data-color"> {
|
|
22
|
+
status: Exclude<BaseAlert.RootProps["status"], undefined>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface LocalAlertComponent
|
|
26
|
+
extends React.ForwardRefExoticComponent<
|
|
27
|
+
LocalAlertProps & React.RefAttributes<HTMLDivElement>
|
|
28
|
+
> {
|
|
29
|
+
/**
|
|
30
|
+
* @see 🏷️ {@link LocalAlertHeaderProps}
|
|
31
|
+
* @example
|
|
32
|
+
* ```jsx
|
|
33
|
+
* <LocalAlert>
|
|
34
|
+
* <LocalAlert.Header>
|
|
35
|
+
* <LocalAlert.Title>Info title</LocalAlert.Title>
|
|
36
|
+
* </LocalAlert.Header>
|
|
37
|
+
* </LocalAlert>
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
Header: typeof LocalAlertHeader;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Title component for LocalAlert. Remember to use correct heading-level with the `as` prop.
|
|
44
|
+
* @see 🏷️ {@link LocalAlertTitleProps}
|
|
45
|
+
* @example
|
|
46
|
+
* ```jsx
|
|
47
|
+
* <LocalAlert>
|
|
48
|
+
* <LocalAlert.Header>
|
|
49
|
+
* <LocalAlert.Title as="h2">Info title</LocalAlert.Title>
|
|
50
|
+
* </LocalAlert.Header>
|
|
51
|
+
* </LocalAlert>
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
Title: typeof LocalAlertTitle;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @see 🏷️ {@link LocalAlertContentProps}
|
|
58
|
+
* @example
|
|
59
|
+
* ```jsx
|
|
60
|
+
* <LocalAlert>
|
|
61
|
+
* <LocalAlert.Header>
|
|
62
|
+
* <LocalAlert.Title>Info title</LocalAlert.Title>
|
|
63
|
+
* </LocalAlert.Header>
|
|
64
|
+
*
|
|
65
|
+
* <LocalAlert.Content>Content</LocalAlert.Content>
|
|
66
|
+
* </LocalAlert>
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
Content: typeof LocalAlertContent;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @see 🏷️ {@link LocalAlertCloseProps}
|
|
73
|
+
* @example
|
|
74
|
+
* ```jsx
|
|
75
|
+
* <LocalAlert>
|
|
76
|
+
* <LocalAlert.Header>
|
|
77
|
+
* <LocalAlert.Title>Info title</LocalAlert.Title>
|
|
78
|
+
* <LocalAlert.CloseButton onClick={() => alert("Closed!")} />
|
|
79
|
+
* </LocalAlert.Header>
|
|
80
|
+
* </LocalAlert>
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
CloseButton: typeof LocalAlertCloseButton;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* A component for displaying important messages about a certain part of the page.
|
|
88
|
+
* @see [📝 Documentation](https://aksel.nav.no/komponenter/core/localalert)
|
|
89
|
+
* @see 🏷️ {@link LocalAlertProps}
|
|
90
|
+
* @example
|
|
91
|
+
* ```jsx
|
|
92
|
+
* <LocalAlert status="error">
|
|
93
|
+
* <LocalAlert.Header>
|
|
94
|
+
* <LocalAlert.Title>Alert title</LocalAlert.Title>
|
|
95
|
+
* </LocalAlert.Header>
|
|
96
|
+
* <LocalAlert.Content>Content</LocalAlert.Content>
|
|
97
|
+
* </LocalAlert>
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
export const LocalAlert = forwardRef<HTMLDivElement, LocalAlertProps>(
|
|
101
|
+
({ status, ...restProps }: LocalAlertProps, forwardedRef) => {
|
|
102
|
+
return (
|
|
103
|
+
<BaseAlert.Root
|
|
104
|
+
ref={forwardedRef}
|
|
105
|
+
role="alert"
|
|
106
|
+
{...restProps}
|
|
107
|
+
type="strong"
|
|
108
|
+
global={false}
|
|
109
|
+
status={status}
|
|
110
|
+
/>
|
|
111
|
+
);
|
|
112
|
+
},
|
|
113
|
+
) as LocalAlertComponent;
|
|
114
|
+
|
|
115
|
+
LocalAlert.Header = LocalAlertHeader;
|
|
116
|
+
LocalAlert.Title = LocalAlertTitle;
|
|
117
|
+
LocalAlert.Content = LocalAlertContent;
|
|
118
|
+
LocalAlert.CloseButton = LocalAlertCloseButton;
|
|
119
|
+
|
|
120
|
+
export default LocalAlert;
|
|
121
|
+
export {
|
|
122
|
+
LocalAlertContent,
|
|
123
|
+
LocalAlertHeader,
|
|
124
|
+
LocalAlertTitle,
|
|
125
|
+
LocalAlertCloseButton,
|
|
126
|
+
};
|
|
127
|
+
export type {
|
|
128
|
+
LocalAlertProps,
|
|
129
|
+
LocalAlertContentProps,
|
|
130
|
+
LocalAlertHeaderProps,
|
|
131
|
+
LocalAlertTitleProps,
|
|
132
|
+
LocalAlertCloseButtonProps,
|
|
133
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BaseAlert } from "../../base-alert";
|
|
2
|
+
|
|
3
|
+
type LocalAlertTitleProps = BaseAlert.TitleProps;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Title component for LocalAlert. Remember to use correct heading-level with the `as` prop.
|
|
7
|
+
* @see 🏷️ {@link LocalAlertTitleProps}
|
|
8
|
+
* @example
|
|
9
|
+
* ```jsx
|
|
10
|
+
* <LocalAlert>
|
|
11
|
+
* <LocalAlert.Header>
|
|
12
|
+
* <LocalAlert.Title as="h2">Info title</LocalAlert.Title>
|
|
13
|
+
* </LocalAlert.Header>
|
|
14
|
+
* </LocalAlert>
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
const LocalAlertTitle = BaseAlert.Title;
|
|
18
|
+
|
|
19
|
+
export { LocalAlertTitle };
|
|
20
|
+
export type { LocalAlertTitleProps };
|
package/src/index.ts
CHANGED
|
@@ -163,6 +163,30 @@ export {
|
|
|
163
163
|
type LinkCardIconProps,
|
|
164
164
|
type LinkCardImageProps,
|
|
165
165
|
} from "./link-card";
|
|
166
|
+
export { InlineMessage, type InlineMessageProps } from "./inline-message";
|
|
167
|
+
export {
|
|
168
|
+
GlobalAlert,
|
|
169
|
+
type GlobalAlertProps,
|
|
170
|
+
type GlobalAlertHeaderProps,
|
|
171
|
+
type GlobalAlertTitleProps,
|
|
172
|
+
type GlobalAlertContentProps,
|
|
173
|
+
type GlobalAlertCloseButtonProps,
|
|
174
|
+
} from "./alert/global-alert";
|
|
175
|
+
export {
|
|
176
|
+
InfoCard,
|
|
177
|
+
type InfoCardProps,
|
|
178
|
+
type InfoCardHeaderProps,
|
|
179
|
+
type InfoCardTitleProps,
|
|
180
|
+
type InfoCardContentProps,
|
|
181
|
+
} from "./alert/info-card";
|
|
182
|
+
export {
|
|
183
|
+
LocalAlert,
|
|
184
|
+
type LocalAlertProps,
|
|
185
|
+
type LocalAlertHeaderProps,
|
|
186
|
+
type LocalAlertTitleProps,
|
|
187
|
+
type LocalAlertContentProps,
|
|
188
|
+
type LocalAlertCloseButtonProps,
|
|
189
|
+
} from "./alert/local-alert";
|
|
166
190
|
|
|
167
191
|
/**
|
|
168
192
|
* Theming
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {
|
|
3
|
+
CheckmarkCircleFillIcon,
|
|
4
|
+
ExclamationmarkTriangleFillIcon,
|
|
5
|
+
InformationSquareFillIcon,
|
|
6
|
+
XMarkOctagonFillIcon,
|
|
7
|
+
} from "@navikt/aksel-icons";
|
|
8
|
+
import { useRenameCSS } from "../../theme/Theme";
|
|
9
|
+
|
|
10
|
+
const STATUS_ICONS = {
|
|
11
|
+
info: InformationSquareFillIcon,
|
|
12
|
+
success: CheckmarkCircleFillIcon,
|
|
13
|
+
warning: ExclamationmarkTriangleFillIcon,
|
|
14
|
+
error: XMarkOctagonFillIcon,
|
|
15
|
+
} as const;
|
|
16
|
+
|
|
17
|
+
function InlineMessageIcon({
|
|
18
|
+
status,
|
|
19
|
+
}: {
|
|
20
|
+
status: "info" | "success" | "warning" | "error";
|
|
21
|
+
}) {
|
|
22
|
+
const { cn } = useRenameCSS();
|
|
23
|
+
|
|
24
|
+
if (!(status in STATUS_ICONS)) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const Icon = STATUS_ICONS[status];
|
|
29
|
+
|
|
30
|
+
return <Icon className={cn("navds-inline-message__icon")} aria-hidden />;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { InlineMessageIcon };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import cl from "clsx";
|
|
2
|
+
import React, { forwardRef } from "react";
|
|
3
|
+
import { useRenameCSS, useThemeInternal } from "../../theme/Theme";
|
|
4
|
+
import { BodyShort } from "../../typography";
|
|
5
|
+
import { type OverridableComponent, useId } from "../../util";
|
|
6
|
+
import { useI18n } from "../../util/i18n/i18n.hooks";
|
|
7
|
+
import { InlineMessageIcon } from "../icon/InlineMessageIcon";
|
|
8
|
+
|
|
9
|
+
interface InlineMessageProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
10
|
+
/**
|
|
11
|
+
* InlineMessage status.
|
|
12
|
+
*/
|
|
13
|
+
status: "info" | "success" | "warning" | "error";
|
|
14
|
+
/**
|
|
15
|
+
* InlineMessage size.
|
|
16
|
+
* @default "medium"
|
|
17
|
+
*/
|
|
18
|
+
size?: "medium" | "small";
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* InlineMessage is used to highlight short messages next to other content.
|
|
23
|
+
* @see [📝 Documentation](https://aksel.nav.no/komponenter/core/inline-message)
|
|
24
|
+
* @see 🏷️ {@link InlineMessageProps}
|
|
25
|
+
* @see [🤖 OverridableComponent](https://aksel.nav.no/grunnleggende/kode/overridablecomponent) support
|
|
26
|
+
* @example
|
|
27
|
+
* ```jsx
|
|
28
|
+
* <InlineMessage status="error">
|
|
29
|
+
* Inline Errormessage
|
|
30
|
+
* </InlineMessage>
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* As a link
|
|
35
|
+
* ```jsx
|
|
36
|
+
* <InlineMessage status="error" as={Link} href="#">
|
|
37
|
+
* Inline Errormessage
|
|
38
|
+
* </InlineMessage>
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export const InlineMessage: OverridableComponent<
|
|
42
|
+
InlineMessageProps,
|
|
43
|
+
HTMLDivElement
|
|
44
|
+
> = forwardRef(
|
|
45
|
+
(
|
|
46
|
+
{
|
|
47
|
+
as: Component = "div",
|
|
48
|
+
children,
|
|
49
|
+
className,
|
|
50
|
+
status,
|
|
51
|
+
size = "medium",
|
|
52
|
+
...restProps
|
|
53
|
+
}: InlineMessageProps & { as?: React.ElementType },
|
|
54
|
+
forwardedRef,
|
|
55
|
+
) => {
|
|
56
|
+
const { cn } = useRenameCSS();
|
|
57
|
+
const themeContext = useThemeInternal(false);
|
|
58
|
+
|
|
59
|
+
const translate = useI18n("global");
|
|
60
|
+
const statusId = useId();
|
|
61
|
+
const contentId = useId();
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<BodyShort
|
|
65
|
+
ref={forwardedRef}
|
|
66
|
+
className={cn("navds-inline-message", className)}
|
|
67
|
+
data-color={status === "error" ? "danger" : status}
|
|
68
|
+
{...restProps}
|
|
69
|
+
size={size}
|
|
70
|
+
as={Component}
|
|
71
|
+
data-size={size}
|
|
72
|
+
>
|
|
73
|
+
<InlineMessageIcon status={status} />
|
|
74
|
+
{status && (
|
|
75
|
+
<BodyShort id={statusId} aria-hidden visuallyHidden>
|
|
76
|
+
{`${translate(status)}: `}
|
|
77
|
+
</BodyShort>
|
|
78
|
+
)}
|
|
79
|
+
<span
|
|
80
|
+
data-color={themeContext?.color}
|
|
81
|
+
id={contentId}
|
|
82
|
+
aria-labelledby={cl(statusId, contentId)}
|
|
83
|
+
>
|
|
84
|
+
{children}
|
|
85
|
+
</span>
|
|
86
|
+
</BodyShort>
|
|
87
|
+
);
|
|
88
|
+
},
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
export default InlineMessage;
|
|
92
|
+
export type { InlineMessageProps };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FloatingFocusManager,
|
|
3
3
|
autoUpdate,
|
|
4
|
-
arrow as flArrow,
|
|
5
4
|
flip,
|
|
6
5
|
offset,
|
|
7
6
|
safePolygon,
|
|
@@ -12,8 +11,8 @@ import {
|
|
|
12
11
|
useHover,
|
|
13
12
|
useInteractions,
|
|
14
13
|
} from "@floating-ui/react";
|
|
15
|
-
import React, {
|
|
16
|
-
import { useRenameCSS
|
|
14
|
+
import React, { useState } from "react";
|
|
15
|
+
import { useRenameCSS } from "../../theme/Theme";
|
|
17
16
|
import { useMergeRefs } from "../../util/hooks/useMergeRefs";
|
|
18
17
|
import { useI18n } from "../../util/i18n/i18n.hooks";
|
|
19
18
|
import { usePeriodContext } from "../hooks/usePeriodContext";
|
|
@@ -57,28 +56,18 @@ const ClickablePeriod = React.memo(
|
|
|
57
56
|
const { index } = useRowContext();
|
|
58
57
|
const { firstFocus } = usePeriodContext();
|
|
59
58
|
const { initiate, addFocusable } = useTimelineContext();
|
|
60
|
-
const arrowRef = useRef<HTMLDivElement | null>(null);
|
|
61
|
-
const translate = useI18n("Timeline");
|
|
62
59
|
|
|
63
|
-
const
|
|
64
|
-
const showArrow = !themeContext?.isDarkside;
|
|
60
|
+
const translate = useI18n("Timeline");
|
|
65
61
|
|
|
66
|
-
const {
|
|
67
|
-
context,
|
|
68
|
-
placement,
|
|
69
|
-
middlewareData: { arrow: { x: arrowX, y: arrowY } = {} },
|
|
70
|
-
refs,
|
|
71
|
-
floatingStyles,
|
|
72
|
-
} = useFloating({
|
|
62
|
+
const { context, placement, refs, floatingStyles } = useFloating({
|
|
73
63
|
placement: restProps?.placement ?? "top",
|
|
74
64
|
open,
|
|
75
65
|
onOpenChange: (_open) => setOpen(_open),
|
|
76
66
|
whileElementsMounted: autoUpdate,
|
|
77
67
|
middleware: [
|
|
78
|
-
offset(
|
|
68
|
+
offset(8),
|
|
79
69
|
shift(),
|
|
80
70
|
flip({ padding: 5, fallbackPlacements: ["bottom", "top"] }),
|
|
81
|
-
flArrow({ element: arrowRef, padding: 5 }),
|
|
82
71
|
],
|
|
83
72
|
});
|
|
84
73
|
|
|
@@ -99,13 +88,6 @@ const ClickablePeriod = React.memo(
|
|
|
99
88
|
|
|
100
89
|
const mergedRef = useMergeRefs(refs.setReference, periodRef);
|
|
101
90
|
|
|
102
|
-
const staticSide = {
|
|
103
|
-
top: "bottom",
|
|
104
|
-
right: "left",
|
|
105
|
-
bottom: "top",
|
|
106
|
-
left: "right",
|
|
107
|
-
}[placement.split("-")[0]];
|
|
108
|
-
|
|
109
91
|
const label = ariaLabel(start, end, status, statusLabel, translate);
|
|
110
92
|
|
|
111
93
|
return (
|
|
@@ -175,17 +157,6 @@ const ClickablePeriod = React.memo(
|
|
|
175
157
|
style={floatingStyles}
|
|
176
158
|
>
|
|
177
159
|
{children}
|
|
178
|
-
{showArrow && (
|
|
179
|
-
<div
|
|
180
|
-
ref={arrowRef}
|
|
181
|
-
style={{
|
|
182
|
-
...(arrowX != null ? { left: arrowX } : {}),
|
|
183
|
-
...(arrowY != null ? { top: arrowY } : {}),
|
|
184
|
-
...(staticSide ? { [staticSide]: "-0.5rem" } : {}),
|
|
185
|
-
}}
|
|
186
|
-
className={cn("navds-timeline__popover-arrow")}
|
|
187
|
-
/>
|
|
188
|
-
)}
|
|
189
160
|
</div>
|
|
190
161
|
</FloatingFocusManager>
|
|
191
162
|
)}
|