@navikt/ds-react 6.6.0 → 6.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/collapsible/Collapsible.context.d.ts +48 -0
- package/cjs/collapsible/Collapsible.context.js +10 -0
- package/cjs/collapsible/Collapsible.context.js.map +1 -0
- package/cjs/collapsible/Collapsible.d.ts +48 -0
- package/cjs/collapsible/Collapsible.js +91 -0
- package/cjs/collapsible/Collapsible.js.map +1 -0
- package/cjs/collapsible/Collapsible.types.d.ts +19 -0
- package/cjs/collapsible/Collapsible.types.js +3 -0
- package/cjs/collapsible/Collapsible.types.js.map +1 -0
- package/cjs/collapsible/index.d.ts +3 -0
- package/cjs/collapsible/index.js +14 -0
- package/cjs/collapsible/index.js.map +1 -0
- package/cjs/collapsible/parts/Collapsible.Content.d.ts +10 -0
- package/cjs/collapsible/parts/Collapsible.Content.js +48 -0
- package/cjs/collapsible/parts/Collapsible.Content.js.map +1 -0
- package/cjs/collapsible/parts/Collapsible.Trigger.d.ts +10 -0
- package/cjs/collapsible/parts/Collapsible.Trigger.js +49 -0
- package/cjs/collapsible/parts/Collapsible.Trigger.js.map +1 -0
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +4 -2
- package/cjs/index.js.map +1 -1
- package/cjs/layout/stack/Spacer.js +1 -1
- package/cjs/layout/stack/Spacer.js.map +1 -1
- package/cjs/progress-bar/ProgressBar.d.ts +60 -0
- package/cjs/progress-bar/ProgressBar.js +76 -0
- package/cjs/progress-bar/ProgressBar.js.map +1 -0
- package/cjs/progress-bar/index.d.ts +1 -0
- package/cjs/progress-bar/index.js +10 -0
- package/cjs/progress-bar/index.js.map +1 -0
- package/cjs/typography/BodyLong.d.ts +7 -7
- package/cjs/typography/BodyLong.js +5 -5
- package/cjs/typography/BodyShort.d.ts +5 -5
- package/cjs/typography/BodyShort.js +3 -3
- package/cjs/typography/Detail.d.ts +5 -5
- package/cjs/typography/Detail.js +3 -3
- package/cjs/typography/ErrorMessage.d.ts +5 -5
- package/cjs/typography/ErrorMessage.js +3 -3
- package/cjs/typography/Heading.d.ts +6 -6
- package/cjs/typography/Heading.js +3 -3
- package/cjs/typography/Label.d.ts +5 -5
- package/cjs/typography/Label.js +3 -3
- package/cjs/typography/types.d.ts +3 -3
- package/esm/collapsible/Collapsible.context.d.ts +48 -0
- package/esm/collapsible/Collapsible.context.js +6 -0
- package/esm/collapsible/Collapsible.context.js.map +1 -0
- package/esm/collapsible/Collapsible.d.ts +48 -0
- package/esm/collapsible/Collapsible.js +62 -0
- package/esm/collapsible/Collapsible.js.map +1 -0
- package/esm/collapsible/Collapsible.types.d.ts +19 -0
- package/esm/collapsible/Collapsible.types.js +2 -0
- package/esm/collapsible/Collapsible.types.js.map +1 -0
- package/esm/collapsible/index.d.ts +3 -0
- package/esm/collapsible/index.js +5 -0
- package/esm/collapsible/index.js.map +1 -0
- package/esm/collapsible/parts/Collapsible.Content.d.ts +10 -0
- package/esm/collapsible/parts/Collapsible.Content.js +22 -0
- package/esm/collapsible/parts/Collapsible.Content.js.map +1 -0
- package/esm/collapsible/parts/Collapsible.Trigger.d.ts +10 -0
- package/esm/collapsible/parts/Collapsible.Trigger.js +23 -0
- package/esm/collapsible/parts/Collapsible.Trigger.js.map +1 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.js +1 -0
- package/esm/index.js.map +1 -1
- package/esm/layout/stack/Spacer.js +1 -1
- package/esm/layout/stack/Spacer.js.map +1 -1
- package/esm/progress-bar/ProgressBar.d.ts +60 -0
- package/esm/progress-bar/ProgressBar.js +47 -0
- package/esm/progress-bar/ProgressBar.js.map +1 -0
- package/esm/progress-bar/index.d.ts +1 -0
- package/esm/progress-bar/index.js +3 -0
- package/esm/progress-bar/index.js.map +1 -0
- package/esm/typography/BodyLong.d.ts +7 -7
- package/esm/typography/BodyLong.js +5 -5
- package/esm/typography/BodyShort.d.ts +5 -5
- package/esm/typography/BodyShort.js +3 -3
- package/esm/typography/Detail.d.ts +5 -5
- package/esm/typography/Detail.js +3 -3
- package/esm/typography/ErrorMessage.d.ts +5 -5
- package/esm/typography/ErrorMessage.js +3 -3
- package/esm/typography/Heading.d.ts +6 -6
- package/esm/typography/Heading.js +3 -3
- package/esm/typography/Label.d.ts +5 -5
- package/esm/typography/Label.js +3 -3
- package/esm/typography/types.d.ts +3 -3
- package/package.json +13 -3
- package/src/collapsible/Collapsible.context.tsx +32 -0
- package/src/collapsible/Collapsible.tsx +100 -0
- package/src/collapsible/Collapsible.types.ts +19 -0
- package/src/collapsible/index.ts +10 -0
- package/src/collapsible/parts/Collapsible.Content.tsx +39 -0
- package/src/collapsible/parts/Collapsible.Trigger.tsx +42 -0
- package/src/index.ts +1 -0
- package/src/layout/stack/Spacer.tsx +1 -1
- package/src/progress-bar/ProgressBar.tsx +124 -0
- package/src/progress-bar/index.ts +2 -0
- package/src/typography/BodyLong.tsx +7 -7
- package/src/typography/BodyShort.tsx +5 -5
- package/src/typography/Detail.tsx +5 -5
- package/src/typography/ErrorMessage.tsx +5 -5
- package/src/typography/Heading.tsx +6 -6
- package/src/typography/Label.tsx +5 -5
- package/src/typography/types.ts +3 -3
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React, { HTMLAttributes } from "react";
|
|
2
|
+
interface ProgressBarPropsBase extends Omit<HTMLAttributes<HTMLDivElement>, "role"> {
|
|
3
|
+
/**
|
|
4
|
+
* Changes height.
|
|
5
|
+
* @default "medium"
|
|
6
|
+
*/
|
|
7
|
+
size?: "large" | "medium" | "small";
|
|
8
|
+
/**
|
|
9
|
+
* Current progress. When duration is set, value is ignored.
|
|
10
|
+
*/
|
|
11
|
+
value?: number;
|
|
12
|
+
/**
|
|
13
|
+
* Maximum progress.
|
|
14
|
+
* @default 100
|
|
15
|
+
*/
|
|
16
|
+
valueMax?: number;
|
|
17
|
+
/**
|
|
18
|
+
* Expected task duration in seconds.
|
|
19
|
+
* ProgressBar grows with a preset animation for {duration} seconds.
|
|
20
|
+
* After a 4 sec delay, it then shows an indeterminate animation.
|
|
21
|
+
* A duration of 0 will show an indeterminate animation immediately.
|
|
22
|
+
* Temporary removed to avoid conflicts when updating API
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* String ID of the element that labels the progress bar.
|
|
26
|
+
* Not needed if `aria-label` is used.
|
|
27
|
+
*/
|
|
28
|
+
"aria-labelledby"?: string;
|
|
29
|
+
/**
|
|
30
|
+
* String value that labels the progress bar.
|
|
31
|
+
* Not needed if `aria-labelledby` is used.
|
|
32
|
+
*/
|
|
33
|
+
"aria-label"?: string;
|
|
34
|
+
}
|
|
35
|
+
export type ProgressBarProps = ProgressBarPropsBase & ({
|
|
36
|
+
"aria-hidden": string;
|
|
37
|
+
} | {
|
|
38
|
+
"aria-labelledby": string;
|
|
39
|
+
"aria-label"?: never;
|
|
40
|
+
} | {
|
|
41
|
+
"aria-label": string;
|
|
42
|
+
"aria-labelledby"?: never;
|
|
43
|
+
});
|
|
44
|
+
/**
|
|
45
|
+
* ProgressBar
|
|
46
|
+
* A component for visualizing progression in a process.
|
|
47
|
+
*
|
|
48
|
+
* @see [📝 Documentation](https://aksel.nav.no/komponenter/core/progress-bar)
|
|
49
|
+
* @see 🏷️ {@link ProgressBarProps}
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* // For loading content with an approximate duration in sec.
|
|
53
|
+
* <ProgressBar duration={30} />
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* // As a step indicator for forms, questionnaires, etc.
|
|
57
|
+
* <ProgressBar value={2} valueMax={7} />
|
|
58
|
+
*/
|
|
59
|
+
export declare const ProgressBar: React.ForwardRefExoticComponent<ProgressBarProps & React.RefAttributes<HTMLDivElement>>;
|
|
60
|
+
export default ProgressBar;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import cl from "clsx";
|
|
13
|
+
import React, { forwardRef } from "react";
|
|
14
|
+
/**
|
|
15
|
+
* ProgressBar
|
|
16
|
+
* A component for visualizing progression in a process.
|
|
17
|
+
*
|
|
18
|
+
* @see [📝 Documentation](https://aksel.nav.no/komponenter/core/progress-bar)
|
|
19
|
+
* @see 🏷️ {@link ProgressBarProps}
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* // For loading content with an approximate duration in sec.
|
|
23
|
+
* <ProgressBar duration={30} />
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // As a step indicator for forms, questionnaires, etc.
|
|
27
|
+
* <ProgressBar value={2} valueMax={7} />
|
|
28
|
+
*/
|
|
29
|
+
export const ProgressBar = forwardRef((_a, ref) => {
|
|
30
|
+
var { size = "medium", value = 0, valueMax = 100, "aria-labelledby": ariaLabelledBy, "aria-label": ariaLabel, className } = _a, rest = __rest(_a, ["size", "value", "valueMax", "aria-labelledby", "aria-label", "className"]);
|
|
31
|
+
const translate = 100 - (Math.round(value) / valueMax) * 100;
|
|
32
|
+
const duration = undefined;
|
|
33
|
+
return (React.createElement("div", Object.assign({ ref: ref, className: cl("navds-progress-bar", `navds-progress-bar--${size}`, className), "aria-valuemax": duration ? 0 : Math.round(valueMax), "aria-valuenow": duration ? 0 : Math.round(value), "aria-valuetext": duration
|
|
34
|
+
? "Fremdrift kan ikke beregnes"
|
|
35
|
+
: `${Math.round(value)} av ${Math.round(valueMax)}`, role: "progressbar", "aria-labelledby": ariaLabelledBy, "aria-label": ariaLabel }, rest),
|
|
36
|
+
React.createElement("div", { className: cl("navds-progress-bar__foreground", {
|
|
37
|
+
"navds-progress-bar__foreground--indeterminate": Number.isInteger(duration),
|
|
38
|
+
}), style: {
|
|
39
|
+
"--__ac-progress-bar-duration": Number.isInteger(duration)
|
|
40
|
+
? `${duration}s`
|
|
41
|
+
: undefined,
|
|
42
|
+
"--__ac-progress-bar-delay": `${duration === 0 ? 0 : 4}s`,
|
|
43
|
+
"--__ac-progress-bar-translate": `-${translate}%`,
|
|
44
|
+
} })));
|
|
45
|
+
});
|
|
46
|
+
export default ProgressBar;
|
|
47
|
+
//# sourceMappingURL=ProgressBar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProgressBar.js","sourceRoot":"","sources":["../../src/progress-bar/ProgressBar.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,EAAE,EAAkB,UAAU,EAAE,MAAM,OAAO,CAAC;AAqD1D;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,UAAU,CACnC,CACE,EAQC,EACD,GAAG,EACH,EAAE;QAVF,EACE,IAAI,GAAG,QAAQ,EACf,KAAK,GAAG,CAAC,EACT,QAAQ,GAAG,GAAG,EACd,iBAAiB,EAAE,cAAc,EACjC,YAAY,EAAE,SAAS,EACvB,SAAS,OAEV,EADI,IAAI,cAPT,2EAQC,CADQ;IAIT,MAAM,SAAS,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC,GAAG,GAAG,CAAC;IAC7D,MAAM,QAAQ,GAAG,SAAS,CAAC;IAE3B,OAAO,CACL,2CACE,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CACX,oBAAoB,EACpB,uBAAuB,IAAI,EAAE,EAC7B,SAAS,CACV,mBACc,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,mBACnC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,oBAE7C,QAAQ;YACN,CAAC,CAAC,6BAA6B;YAC/B,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,EAEvD,IAAI,EAAC,aAAa,qBACD,cAAc,gBACnB,SAAS,IACjB,IAAI;QAER,6BACE,SAAS,EAAE,EAAE,CAAC,gCAAgC,EAAE;gBAC9C,+CAA+C,EAC7C,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC;aAC7B,CAAC,EACF,KAAK,EAAE;gBACL,8BAA8B,EAAE,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC;oBACxD,CAAC,CAAC,GAAG,QAAQ,GAAG;oBAChB,CAAC,CAAC,SAAS;gBACb,2BAA2B,EAAE,GAAG,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG;gBACzD,+BAA+B,EAAE,IAAI,SAAS,GAAG;aAClD,GACD,CACE,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as ProgressBar, type ProgressBarProps } from "./ProgressBar.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/progress-bar/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,EAAE,OAAO,IAAI,WAAW,EAAyB,MAAM,eAAe,CAAC"}
|
|
@@ -3,12 +3,12 @@ import { OverridableComponent } from "../util/types/index.js";
|
|
|
3
3
|
import { TypoProps } from "./types.js";
|
|
4
4
|
export interface BodyLongProps extends TypoProps, React.HTMLAttributes<HTMLParagraphElement> {
|
|
5
5
|
/**
|
|
6
|
-
* large: 20px, medium: 18px, small: 16px
|
|
6
|
+
* large: 20px, medium: 18px, small: 16px.
|
|
7
7
|
* @default "medium"
|
|
8
8
|
*/
|
|
9
9
|
size?: "large" | "medium" | "small";
|
|
10
10
|
/**
|
|
11
|
-
* Text
|
|
11
|
+
* Text.
|
|
12
12
|
*/
|
|
13
13
|
children: React.ReactNode;
|
|
14
14
|
}
|
|
@@ -21,11 +21,11 @@ export interface BodyLongProps extends TypoProps, React.HTMLAttributes<HTMLParag
|
|
|
21
21
|
*
|
|
22
22
|
* @example
|
|
23
23
|
* ```jsx
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
24
|
+
* <BodyLong>
|
|
25
|
+
* Hvis du ikke bor sammen med begge foreldrene dine,
|
|
26
|
+
* kan du ha rett til barnebidrag fra en eller begge foreldre mens du
|
|
27
|
+
* fullfører videregående skole eller tilsvarende.
|
|
28
|
+
* </BodyLong>
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
31
|
export declare const BodyLong: OverridableComponent<BodyLongProps, HTMLParagraphElement>;
|
|
@@ -21,11 +21,11 @@ import { typoClassNames } from "./util.js";
|
|
|
21
21
|
*
|
|
22
22
|
* @example
|
|
23
23
|
* ```jsx
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
24
|
+
* <BodyLong>
|
|
25
|
+
* Hvis du ikke bor sammen med begge foreldrene dine,
|
|
26
|
+
* kan du ha rett til barnebidrag fra en eller begge foreldre mens du
|
|
27
|
+
* fullfører videregående skole eller tilsvarende.
|
|
28
|
+
* </BodyLong>
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
31
|
export const BodyLong = forwardRef((_a, ref) => {
|
|
@@ -3,12 +3,12 @@ import { OverridableComponent } from "../util/types/index.js";
|
|
|
3
3
|
import { TypoProps } from "./types.js";
|
|
4
4
|
export interface BodyShortProps extends TypoProps, React.HTMLAttributes<HTMLParagraphElement> {
|
|
5
5
|
/**
|
|
6
|
-
* large: 20px, medium: 18px, small: 16px
|
|
6
|
+
* large: 20px, medium: 18px, small: 16px.
|
|
7
7
|
* @default "medium"
|
|
8
8
|
*/
|
|
9
9
|
size?: "large" | "medium" | "small";
|
|
10
10
|
/**
|
|
11
|
-
* Paragraph text
|
|
11
|
+
* Paragraph text.
|
|
12
12
|
*/
|
|
13
13
|
children: React.ReactNode;
|
|
14
14
|
}
|
|
@@ -21,9 +21,9 @@ export interface BodyShortProps extends TypoProps, React.HTMLAttributes<HTMLPara
|
|
|
21
21
|
*
|
|
22
22
|
* @example
|
|
23
23
|
* ```jsx
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
24
|
+
* <BodyShort>
|
|
25
|
+
* Du må gjøre en filtrering for å se brukere i listen.
|
|
26
|
+
* </BodyShort>
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
29
|
export declare const BodyShort: OverridableComponent<BodyShortProps, HTMLParagraphElement>;
|
|
@@ -21,9 +21,9 @@ import { typoClassNames } from "./util.js";
|
|
|
21
21
|
*
|
|
22
22
|
* @example
|
|
23
23
|
* ```jsx
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
24
|
+
* <BodyShort>
|
|
25
|
+
* Du må gjøre en filtrering for å se brukere i listen.
|
|
26
|
+
* </BodyShort>
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
29
|
export const BodyShort = forwardRef((_a, ref) => {
|
|
@@ -7,11 +7,11 @@ export interface DetailProps extends TypoProps, React.HTMLAttributes<HTMLParagra
|
|
|
7
7
|
*/
|
|
8
8
|
size?: "medium" | "small";
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* Text.
|
|
11
11
|
*/
|
|
12
12
|
children: React.ReactNode;
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* ALL CAPS.
|
|
15
15
|
*/
|
|
16
16
|
uppercase?: boolean;
|
|
17
17
|
}
|
|
@@ -24,9 +24,9 @@ export interface DetailProps extends TypoProps, React.HTMLAttributes<HTMLParagra
|
|
|
24
24
|
*
|
|
25
25
|
* @example
|
|
26
26
|
* ```jsx
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
27
|
+
* <Detail>
|
|
28
|
+
* Du må gjøre en filtrering for å se brukere i listen.
|
|
29
|
+
* </Detail>
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
|
32
32
|
export declare const Detail: OverridableComponent<DetailProps, HTMLParagraphElement>;
|
package/esm/typography/Detail.js
CHANGED
|
@@ -21,9 +21,9 @@ import { typoClassNames } from "./util.js";
|
|
|
21
21
|
*
|
|
22
22
|
* @example
|
|
23
23
|
* ```jsx
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
24
|
+
* <Detail>
|
|
25
|
+
* Du må gjøre en filtrering for å se brukere i listen.
|
|
26
|
+
* </Detail>
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
29
|
export const Detail = forwardRef((_a, ref) => {
|
|
@@ -3,12 +3,12 @@ import { OverridableComponent } from "../util/types/index.js";
|
|
|
3
3
|
import { TypoProps } from "./types.js";
|
|
4
4
|
export interface ErrorMessageProps extends Pick<TypoProps, "spacing">, React.HTMLAttributes<HTMLParagraphElement> {
|
|
5
5
|
/**
|
|
6
|
-
* medium: 18px, small: 16px
|
|
6
|
+
* medium: 18px, small: 16px.
|
|
7
7
|
* @default "medium"
|
|
8
8
|
*/
|
|
9
9
|
size?: "medium" | "small";
|
|
10
10
|
/**
|
|
11
|
-
* Error text
|
|
11
|
+
* Error text.
|
|
12
12
|
*/
|
|
13
13
|
children: React.ReactNode;
|
|
14
14
|
}
|
|
@@ -21,9 +21,9 @@ export interface ErrorMessageProps extends Pick<TypoProps, "spacing">, React.HTM
|
|
|
21
21
|
*
|
|
22
22
|
* @example
|
|
23
23
|
* ```jsx
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
24
|
+
* <ErrorMessage>
|
|
25
|
+
* Du må fylle ut: Oppgi årsaken til at du har ventet mer enn 6 måneder med å søke om refusjon
|
|
26
|
+
* </ErrorMessage>
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
29
|
export declare const ErrorMessage: OverridableComponent<ErrorMessageProps, HTMLParagraphElement>;
|
|
@@ -21,9 +21,9 @@ import { typoClassNames } from "./util.js";
|
|
|
21
21
|
*
|
|
22
22
|
* @example
|
|
23
23
|
* ```jsx
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
24
|
+
* <ErrorMessage>
|
|
25
|
+
* Du må fylle ut: Oppgi årsaken til at du har ventet mer enn 6 måneder med å søke om refusjon
|
|
26
|
+
* </ErrorMessage>
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
29
|
export const ErrorMessage = forwardRef((_a, ref) => {
|
|
@@ -3,16 +3,16 @@ import { OverridableComponent } from "../util/types/index.js";
|
|
|
3
3
|
import { TypoProps } from "./types.js";
|
|
4
4
|
export interface HeadingProps extends Pick<TypoProps, "spacing" | "visuallyHidden" | "align" | "textColor">, React.HTMLAttributes<HTMLHeadingElement> {
|
|
5
5
|
/**
|
|
6
|
-
* Heading level
|
|
6
|
+
* Heading level.
|
|
7
7
|
* @default "1"
|
|
8
8
|
*/
|
|
9
9
|
level?: "1" | "2" | "3" | "4" | "5" | "6";
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* xlarge: 40px, large: 32px, medium: 24px, small: 20px, xsmall: 18px.
|
|
12
12
|
*/
|
|
13
13
|
size: "xlarge" | "large" | "medium" | "small" | "xsmall";
|
|
14
14
|
/**
|
|
15
|
-
* Heading text
|
|
15
|
+
* Heading text.
|
|
16
16
|
*/
|
|
17
17
|
children: React.ReactNode;
|
|
18
18
|
}
|
|
@@ -25,9 +25,9 @@ export interface HeadingProps extends Pick<TypoProps, "spacing" | "visuallyHidde
|
|
|
25
25
|
*
|
|
26
26
|
* @example
|
|
27
27
|
* ```jsx
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
28
|
+
* <Heading level="1" size="xlarge">
|
|
29
|
+
* Hva kan vi hjelpe deg med?
|
|
30
|
+
* </Heading>
|
|
31
31
|
* ```
|
|
32
32
|
*/
|
|
33
33
|
export declare const Heading: OverridableComponent<HeadingProps, HTMLHeadingElement>;
|
|
@@ -21,9 +21,9 @@ import { typoClassNames } from "./util.js";
|
|
|
21
21
|
*
|
|
22
22
|
* @example
|
|
23
23
|
* ```jsx
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
24
|
+
* <Heading level="1" size="xlarge">
|
|
25
|
+
* Hva kan vi hjelpe deg med?
|
|
26
|
+
* </Heading>
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
29
|
export const Heading = forwardRef((_a, ref) => {
|
|
@@ -3,12 +3,12 @@ import { OverridableComponent } from "../util/types/index.js";
|
|
|
3
3
|
import { TypoProps } from "./types.js";
|
|
4
4
|
export interface LabelProps extends Omit<TypoProps, "weight" | "align" | "truncate">, React.LabelHTMLAttributes<HTMLLabelElement> {
|
|
5
5
|
/**
|
|
6
|
-
* medium: 18px, small: 16px
|
|
6
|
+
* medium: 18px, small: 16px.
|
|
7
7
|
* @default "medium"
|
|
8
8
|
*/
|
|
9
9
|
size?: "medium" | "small";
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* Label text.
|
|
12
12
|
*/
|
|
13
13
|
children: React.ReactNode;
|
|
14
14
|
}
|
|
@@ -21,9 +21,9 @@ export interface LabelProps extends Omit<TypoProps, "weight" | "align" | "trunca
|
|
|
21
21
|
*
|
|
22
22
|
* @example
|
|
23
23
|
* ```jsx
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
24
|
+
* <Label>
|
|
25
|
+
* Oppgi årsaken til at du har ventet mer enn 6 måneder med å søke om refusjon
|
|
26
|
+
* </Label>
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
29
|
export declare const Label: OverridableComponent<LabelProps, HTMLLabelElement>;
|
package/esm/typography/Label.js
CHANGED
|
@@ -21,9 +21,9 @@ import { typoClassNames } from "./util.js";
|
|
|
21
21
|
*
|
|
22
22
|
* @example
|
|
23
23
|
* ```jsx
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
24
|
+
* <Label>
|
|
25
|
+
* Oppgi årsaken til at du har ventet mer enn 6 måneder med å søke om refusjon
|
|
26
|
+
* </Label>
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
29
|
export const Label = forwardRef((_a, ref) => {
|
|
@@ -12,15 +12,15 @@ export type TypoProps = {
|
|
|
12
12
|
*/
|
|
13
13
|
align?: "start" | "center" | "end";
|
|
14
14
|
/**
|
|
15
|
-
* Visually hide text. Text will still be accessible for screenreaders
|
|
15
|
+
* Visually hide text. Text will still be accessible for screenreaders.
|
|
16
16
|
*/
|
|
17
17
|
visuallyHidden?: boolean;
|
|
18
18
|
/**
|
|
19
|
-
* Adds spacing below text
|
|
19
|
+
* Adds spacing below text.
|
|
20
20
|
*/
|
|
21
21
|
spacing?: boolean;
|
|
22
22
|
/**
|
|
23
|
-
* Adjusts color
|
|
23
|
+
* Adjusts color.
|
|
24
24
|
*/
|
|
25
25
|
textColor?: "default" | "subtle";
|
|
26
26
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navikt/ds-react",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.7.0",
|
|
4
4
|
"description": "React components from the Norwegian Labour and Welfare Administration.",
|
|
5
5
|
"author": "Aksel, a team part of the Norwegian Labour and Welfare Administration.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -310,6 +310,16 @@
|
|
|
310
310
|
"default": "./cjs/popover/index.js"
|
|
311
311
|
}
|
|
312
312
|
},
|
|
313
|
+
"./ProgressBar": {
|
|
314
|
+
"import": {
|
|
315
|
+
"types": "./esm/progress-bar/index.d.ts",
|
|
316
|
+
"default": "./esm/progress-bar/index.js"
|
|
317
|
+
},
|
|
318
|
+
"require": {
|
|
319
|
+
"types": "./cjs/progress-bar/index.d.ts",
|
|
320
|
+
"default": "./cjs/progress-bar/index.js"
|
|
321
|
+
}
|
|
322
|
+
},
|
|
313
323
|
"./Provider": {
|
|
314
324
|
"import": {
|
|
315
325
|
"types": "./esm/provider/index.d.ts",
|
|
@@ -573,8 +583,8 @@
|
|
|
573
583
|
},
|
|
574
584
|
"dependencies": {
|
|
575
585
|
"@floating-ui/react": "0.25.4",
|
|
576
|
-
"@navikt/aksel-icons": "^6.
|
|
577
|
-
"@navikt/ds-tokens": "^6.
|
|
586
|
+
"@navikt/aksel-icons": "^6.7.0",
|
|
587
|
+
"@navikt/ds-tokens": "^6.7.0",
|
|
578
588
|
"clsx": "^2.1.0",
|
|
579
589
|
"date-fns": "^3.0.0",
|
|
580
590
|
"react-day-picker": "8.10.0"
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { createContext } from "../util/create-context";
|
|
2
|
+
import { CollapsibleBaseProps } from "./Collapsible.types";
|
|
3
|
+
|
|
4
|
+
export type CollapsibleContextProps = Pick<CollapsibleBaseProps, "open"> & {
|
|
5
|
+
/**
|
|
6
|
+
* Allows connecting trigger to content
|
|
7
|
+
*/
|
|
8
|
+
contentId: string;
|
|
9
|
+
/**
|
|
10
|
+
* Allows connecting content to trigger
|
|
11
|
+
*/
|
|
12
|
+
triggerId: string;
|
|
13
|
+
/**
|
|
14
|
+
* Callback for toggling open state
|
|
15
|
+
*/
|
|
16
|
+
onOpenToggle: () => void;
|
|
17
|
+
/**
|
|
18
|
+
* Allows always rendering children in content when closed
|
|
19
|
+
*/
|
|
20
|
+
lazy: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Utility for getting state as string. Usefull for data-attributes.
|
|
23
|
+
*/
|
|
24
|
+
state: "open" | "closed";
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const [CollapsibleContextProvider, useCollapsibleContext] =
|
|
28
|
+
createContext<CollapsibleContextProps>({
|
|
29
|
+
name: "CollapsibleContext",
|
|
30
|
+
errorMessage:
|
|
31
|
+
"<Collapsible.Trigger> and <Collapsible.Content> must be used within a <Collapsible>",
|
|
32
|
+
});
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import React, { forwardRef, useCallback } from "react";
|
|
2
|
+
import { useControllableState, useId } from "../util/hooks";
|
|
3
|
+
import { CollapsibleContextProvider } from "./Collapsible.context";
|
|
4
|
+
import { CollapsibleBaseProps } from "./Collapsible.types";
|
|
5
|
+
import CollapsibleContent from "./parts/Collapsible.Content";
|
|
6
|
+
import CollapsibleTrigger from "./parts/Collapsible.Trigger";
|
|
7
|
+
|
|
8
|
+
export interface CollapsibleProps
|
|
9
|
+
extends CollapsibleBaseProps,
|
|
10
|
+
React.HTMLAttributes<HTMLDivElement> {}
|
|
11
|
+
|
|
12
|
+
interface CollapsibleComponent
|
|
13
|
+
extends React.ForwardRefExoticComponent<
|
|
14
|
+
CollapsibleProps & React.RefAttributes<HTMLDivElement>
|
|
15
|
+
> {
|
|
16
|
+
/**
|
|
17
|
+
* @see 🏷️ {@link CollapsibleTriggerProps}
|
|
18
|
+
*/
|
|
19
|
+
Trigger: typeof CollapsibleTrigger;
|
|
20
|
+
/**
|
|
21
|
+
* @see 🏷️ {@link CollapsibleContentProps}
|
|
22
|
+
*/
|
|
23
|
+
Content: typeof CollapsibleContent;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Collapsible is a component that allows you to toggle visibility of content.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```jsx
|
|
31
|
+
* <Collapsible>
|
|
32
|
+
* <Collapsible.Trigger>Trigger</Collapsible.Trigger>
|
|
33
|
+
* <Collapsible.Content>
|
|
34
|
+
* Lorem ipsum dolor sit amet consectetur adipisicing elit. Recusandae
|
|
35
|
+
* corporis maxime aliquam, voluptates nobis numquam, non odit optio
|
|
36
|
+
* architecto iure laborum possimus! Quibusdam sit ullam, consequatur sunt
|
|
37
|
+
* tempore optio aliquid!
|
|
38
|
+
* </Collapsible.Content>
|
|
39
|
+
* </Collapsible>
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @example With asChild
|
|
43
|
+
* ```jsx
|
|
44
|
+
* <Collapsible>
|
|
45
|
+
* <Collapsible.Trigger asChild>
|
|
46
|
+
* <Button>Button</Button>
|
|
47
|
+
* </Collapsible.Trigger>
|
|
48
|
+
* <Collapsible.Content asChild>
|
|
49
|
+
* <Box padding="4" background="surface-alt-3-subtle">
|
|
50
|
+
* <div>lorem ipsum</div>
|
|
51
|
+
* </Box>
|
|
52
|
+
* </Collapsible.Content>
|
|
53
|
+
* </Collapsible>
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export const Collapsible = forwardRef<HTMLDivElement, CollapsibleProps>(
|
|
57
|
+
(
|
|
58
|
+
{
|
|
59
|
+
children,
|
|
60
|
+
open,
|
|
61
|
+
defaultOpen = false,
|
|
62
|
+
onOpenChange,
|
|
63
|
+
lazy = false,
|
|
64
|
+
...rest
|
|
65
|
+
},
|
|
66
|
+
ref,
|
|
67
|
+
) => {
|
|
68
|
+
const [_open, setOpen] = useControllableState({
|
|
69
|
+
value: open,
|
|
70
|
+
defaultValue: defaultOpen,
|
|
71
|
+
onChange: onOpenChange,
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const internalId = useId();
|
|
75
|
+
const state = _open ? "open" : "closed";
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<CollapsibleContextProvider
|
|
79
|
+
open={_open}
|
|
80
|
+
onOpenToggle={useCallback(
|
|
81
|
+
() => setOpen((prevOpen) => !prevOpen),
|
|
82
|
+
[setOpen],
|
|
83
|
+
)}
|
|
84
|
+
contentId={`collapsible-content-${internalId}`}
|
|
85
|
+
triggerId={`collapsible-trigger-${internalId}`}
|
|
86
|
+
lazy={lazy}
|
|
87
|
+
state={state}
|
|
88
|
+
>
|
|
89
|
+
<div ref={ref} data-state={state} {...rest}>
|
|
90
|
+
{children}
|
|
91
|
+
</div>
|
|
92
|
+
</CollapsibleContextProvider>
|
|
93
|
+
);
|
|
94
|
+
},
|
|
95
|
+
) as CollapsibleComponent;
|
|
96
|
+
|
|
97
|
+
Collapsible.Trigger = CollapsibleTrigger;
|
|
98
|
+
Collapsible.Content = CollapsibleContent;
|
|
99
|
+
|
|
100
|
+
export default Collapsible;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface CollapsibleBaseProps {
|
|
2
|
+
/**
|
|
3
|
+
* The open state of the collapsible when it is initially rendered. Use when you do not need to control its open state.
|
|
4
|
+
*/
|
|
5
|
+
defaultOpen?: boolean;
|
|
6
|
+
/**
|
|
7
|
+
* The controlled open state of the collapsible. Must be used in conjunction with onOpenChange.
|
|
8
|
+
*/
|
|
9
|
+
open?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Event handler called when the open state of the collapsible changes.
|
|
12
|
+
*/
|
|
13
|
+
onOpenChange?: (open: boolean) => void;
|
|
14
|
+
/**
|
|
15
|
+
* Render the collapsible content lazily. This means that the content will not be rendered until the collapsible is open.
|
|
16
|
+
* @default false
|
|
17
|
+
*/
|
|
18
|
+
lazy?: boolean;
|
|
19
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
export { default as Collapsible, type CollapsibleProps } from "./Collapsible";
|
|
3
|
+
export {
|
|
4
|
+
default as CollapsibleTrigger,
|
|
5
|
+
type CollapsibleTriggerProps,
|
|
6
|
+
} from "./parts/Collapsible.Trigger";
|
|
7
|
+
export {
|
|
8
|
+
default as CollapsibleContent,
|
|
9
|
+
type CollapsibleContentProps,
|
|
10
|
+
} from "./parts/Collapsible.Content";
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
|
+
import { Slot } from "../../util/Slot";
|
|
3
|
+
import { useCollapsibleContext } from "../Collapsible.context";
|
|
4
|
+
|
|
5
|
+
export interface CollapsibleContentProps
|
|
6
|
+
extends Omit<
|
|
7
|
+
React.HTMLAttributes<HTMLDivElement>,
|
|
8
|
+
"hidden" | "aria-controls" | "id"
|
|
9
|
+
> {
|
|
10
|
+
/**
|
|
11
|
+
* When true, will render element as its child. This merges classes, styles and event handlers.
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
asChild?: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const CollapsibleContent = forwardRef<
|
|
18
|
+
HTMLDivElement,
|
|
19
|
+
CollapsibleContentProps
|
|
20
|
+
>(({ children, asChild, ...rest }, ref) => {
|
|
21
|
+
const ctx = useCollapsibleContext();
|
|
22
|
+
|
|
23
|
+
const Comp = asChild ? Slot : "div";
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<Comp
|
|
27
|
+
ref={ref}
|
|
28
|
+
{...rest}
|
|
29
|
+
data-state={ctx.state}
|
|
30
|
+
hidden={!ctx.open}
|
|
31
|
+
aria-controls={ctx.open ? ctx.triggerId : undefined}
|
|
32
|
+
id={ctx.contentId}
|
|
33
|
+
>
|
|
34
|
+
{ctx.lazy || ctx.open ? children : null}
|
|
35
|
+
</Comp>
|
|
36
|
+
);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export default CollapsibleContent;
|