@navikt/ds-react 0.18.4 → 0.18.5
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/_docs.json
CHANGED
|
@@ -707,44 +707,61 @@
|
|
|
707
707
|
"name": "ReactNode"
|
|
708
708
|
}
|
|
709
709
|
},
|
|
710
|
-
"
|
|
710
|
+
"error": {
|
|
711
711
|
"defaultValue": null,
|
|
712
|
-
"description": "",
|
|
713
|
-
"name": "
|
|
712
|
+
"description": "Error message for element",
|
|
713
|
+
"name": "error",
|
|
714
714
|
"parent": {
|
|
715
|
-
"fileName": "
|
|
716
|
-
"name": "
|
|
715
|
+
"fileName": "src/form/ConfirmationPanel.tsx",
|
|
716
|
+
"name": "ConfirmationPanelProps"
|
|
717
717
|
},
|
|
718
718
|
"declarations": [
|
|
719
719
|
{
|
|
720
|
-
"fileName": "
|
|
721
|
-
"name": "
|
|
720
|
+
"fileName": "src/form/ConfirmationPanel.tsx",
|
|
721
|
+
"name": "ConfirmationPanelProps"
|
|
722
722
|
}
|
|
723
723
|
],
|
|
724
724
|
"required": false,
|
|
725
725
|
"type": {
|
|
726
|
-
"name": "
|
|
726
|
+
"name": "ReactNode"
|
|
727
727
|
}
|
|
728
728
|
},
|
|
729
|
-
"
|
|
730
|
-
"defaultValue":
|
|
731
|
-
|
|
729
|
+
"errorId": {
|
|
730
|
+
"defaultValue": null,
|
|
731
|
+
"description": "Override internal errorId",
|
|
732
|
+
"name": "errorId",
|
|
733
|
+
"parent": {
|
|
734
|
+
"fileName": "src/form/ConfirmationPanel.tsx",
|
|
735
|
+
"name": "ConfirmationPanelProps"
|
|
732
736
|
},
|
|
733
|
-
"
|
|
734
|
-
|
|
737
|
+
"declarations": [
|
|
738
|
+
{
|
|
739
|
+
"fileName": "src/form/ConfirmationPanel.tsx",
|
|
740
|
+
"name": "ConfirmationPanelProps"
|
|
741
|
+
}
|
|
742
|
+
],
|
|
743
|
+
"required": false,
|
|
744
|
+
"type": {
|
|
745
|
+
"name": "string"
|
|
746
|
+
}
|
|
747
|
+
},
|
|
748
|
+
"className": {
|
|
749
|
+
"defaultValue": null,
|
|
750
|
+
"description": "",
|
|
751
|
+
"name": "className",
|
|
735
752
|
"parent": {
|
|
736
|
-
"fileName": "
|
|
737
|
-
"name": "
|
|
753
|
+
"fileName": "nav-frontend-moduler/node_modules/@types/react/index.d.ts",
|
|
754
|
+
"name": "HTMLAttributes"
|
|
738
755
|
},
|
|
739
756
|
"declarations": [
|
|
740
757
|
{
|
|
741
|
-
"fileName": "
|
|
742
|
-
"name": "
|
|
758
|
+
"fileName": "nav-frontend-moduler/node_modules/@types/react/index.d.ts",
|
|
759
|
+
"name": "HTMLAttributes"
|
|
743
760
|
}
|
|
744
761
|
],
|
|
745
762
|
"required": false,
|
|
746
763
|
"type": {
|
|
747
|
-
"name": "
|
|
764
|
+
"name": "string"
|
|
748
765
|
}
|
|
749
766
|
},
|
|
750
767
|
"size": {
|
|
@@ -41,14 +41,19 @@ exports.ConfirmationPanel = void 0;
|
|
|
41
41
|
const react_1 = __importStar(require("react"));
|
|
42
42
|
const classnames_1 = __importDefault(require("classnames"));
|
|
43
43
|
const __1 = require("..");
|
|
44
|
+
const ErrorMessage_1 = __importDefault(require("./ErrorMessage"));
|
|
45
|
+
const useFormField_1 = require("./useFormField");
|
|
44
46
|
exports.ConfirmationPanel = (0, react_1.forwardRef)((_a, ref) => {
|
|
45
47
|
var { className, children, label } = _a, props = __rest(_a, ["className", "children", "label"]);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"navds-confirmation-panel--
|
|
48
|
+
const { errorId, showErrorMsg, hasError, size, inputProps } = (0, useFormField_1.useFormField)(props, "confirmationPanel");
|
|
49
|
+
return (react_1.default.createElement("div", { ref: ref, className: (0, classnames_1.default)("navds-confirmation-panel", "navds-form-field", className, {
|
|
50
|
+
"navds-confirmation-panel--small": size === "small",
|
|
51
|
+
"navds-confirmation-panel--error": hasError,
|
|
49
52
|
"navds-confirmation-panel--checked": !!props.checked,
|
|
50
53
|
}) },
|
|
51
|
-
|
|
52
|
-
|
|
54
|
+
react_1.default.createElement("div", { className: "navds-confirmation-panel__inner" },
|
|
55
|
+
children && (react_1.default.createElement(__1.BodyLong, { size: props.size, className: "navds-confirmation-panel__content" }, children)),
|
|
56
|
+
react_1.default.createElement(__1.Checkbox, Object.assign({}, props, inputProps, { error: hasError, size: size }), label)),
|
|
57
|
+
react_1.default.createElement("div", { id: errorId, "aria-relevant": "additions removals", "aria-live": "polite" }, showErrorMsg && react_1.default.createElement(ErrorMessage_1.default, { size: size }, props.error))));
|
|
53
58
|
});
|
|
54
59
|
exports.default = exports.ConfirmationPanel;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { CheckboxProps } from "..";
|
|
3
|
-
export interface ConfirmationPanelProps extends Omit<CheckboxProps, "children" | "indeterminate" | "hideLabel"> {
|
|
3
|
+
export interface ConfirmationPanelProps extends Omit<CheckboxProps, "children" | "indeterminate" | "hideLabel" | "error"> {
|
|
4
4
|
/**
|
|
5
5
|
* Additional information on panel
|
|
6
6
|
*/
|
|
@@ -9,6 +9,14 @@ export interface ConfirmationPanelProps extends Omit<CheckboxProps, "children" |
|
|
|
9
9
|
* Checkbox label
|
|
10
10
|
*/
|
|
11
11
|
label: React.ReactNode;
|
|
12
|
+
/**
|
|
13
|
+
* Error message for element
|
|
14
|
+
*/
|
|
15
|
+
error?: React.ReactNode;
|
|
16
|
+
/**
|
|
17
|
+
* Override internal errorId
|
|
18
|
+
*/
|
|
19
|
+
errorId?: string;
|
|
12
20
|
}
|
|
13
21
|
export declare const ConfirmationPanel: React.ForwardRefExoticComponent<ConfirmationPanelProps & React.RefAttributes<HTMLDivElement>>;
|
|
14
22
|
export default ConfirmationPanel;
|
|
@@ -12,15 +12,20 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import React, { forwardRef } from "react";
|
|
13
13
|
import cl from "classnames";
|
|
14
14
|
import { BodyLong, Checkbox } from "..";
|
|
15
|
+
import ErrorMessage from "./ErrorMessage";
|
|
16
|
+
import { useFormField } from "./useFormField";
|
|
15
17
|
export const ConfirmationPanel = forwardRef((_a, ref) => {
|
|
16
18
|
var { className, children, label } = _a, props = __rest(_a, ["className", "children", "label"]);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"navds-confirmation-panel--
|
|
19
|
+
const { errorId, showErrorMsg, hasError, size, inputProps } = useFormField(props, "confirmationPanel");
|
|
20
|
+
return (React.createElement("div", { ref: ref, className: cl("navds-confirmation-panel", "navds-form-field", className, {
|
|
21
|
+
"navds-confirmation-panel--small": size === "small",
|
|
22
|
+
"navds-confirmation-panel--error": hasError,
|
|
20
23
|
"navds-confirmation-panel--checked": !!props.checked,
|
|
21
24
|
}) },
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
React.createElement("div", { className: "navds-confirmation-panel__inner" },
|
|
26
|
+
children && (React.createElement(BodyLong, { size: props.size, className: "navds-confirmation-panel__content" }, children)),
|
|
27
|
+
React.createElement(Checkbox, Object.assign({}, props, inputProps, { error: hasError, size: size }), label)),
|
|
28
|
+
React.createElement("div", { id: errorId, "aria-relevant": "additions removals", "aria-live": "polite" }, showErrorMsg && React.createElement(ErrorMessage, { size: size }, props.error))));
|
|
24
29
|
});
|
|
25
30
|
export default ConfirmationPanel;
|
|
26
31
|
//# sourceMappingURL=ConfirmationPanel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfirmationPanel.js","sourceRoot":"","sources":["../../src/form/ConfirmationPanel.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAiB,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"ConfirmationPanel.js","sourceRoot":"","sources":["../../src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AAI,IAAG,KAAK,CAAC,KAAK,CAAgB,CACnE,CACF,CACP,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,iBAAiB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navikt/ds-react",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "NAV designsystem react components",
|
|
6
6
|
"author": "NAV Designsystem team",
|
|
@@ -74,5 +74,5 @@
|
|
|
74
74
|
"@types/react": "^17.0.30 || ^18.0.0",
|
|
75
75
|
"react": "^17.0.0 || ^18.0.0"
|
|
76
76
|
},
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "7fb0ac1e3de0ea6e17bc436ea75c389ae236ac65"
|
|
78
78
|
}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import React, { forwardRef } from "react";
|
|
2
2
|
import cl from "classnames";
|
|
3
3
|
import { BodyLong, Checkbox, CheckboxProps } from "..";
|
|
4
|
+
import ErrorMessage from "./ErrorMessage";
|
|
5
|
+
import { useFormField } from "./useFormField";
|
|
4
6
|
|
|
5
7
|
export interface ConfirmationPanelProps
|
|
6
|
-
extends Omit<
|
|
8
|
+
extends Omit<
|
|
9
|
+
CheckboxProps,
|
|
10
|
+
"children" | "indeterminate" | "hideLabel" | "error"
|
|
11
|
+
> {
|
|
7
12
|
/**
|
|
8
13
|
* Additional information on panel
|
|
9
14
|
*/
|
|
@@ -12,30 +17,50 @@ export interface ConfirmationPanelProps
|
|
|
12
17
|
* Checkbox label
|
|
13
18
|
*/
|
|
14
19
|
label: React.ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* Error message for element
|
|
22
|
+
*/
|
|
23
|
+
error?: React.ReactNode;
|
|
24
|
+
/**
|
|
25
|
+
* Override internal errorId
|
|
26
|
+
*/
|
|
27
|
+
errorId?: string;
|
|
15
28
|
}
|
|
16
29
|
|
|
17
30
|
export const ConfirmationPanel = forwardRef<
|
|
18
31
|
HTMLDivElement,
|
|
19
32
|
ConfirmationPanelProps
|
|
20
33
|
>(({ className, children, label, ...props }, ref) => {
|
|
34
|
+
const { errorId, showErrorMsg, hasError, size, inputProps } = useFormField(
|
|
35
|
+
props,
|
|
36
|
+
"confirmationPanel"
|
|
37
|
+
);
|
|
38
|
+
|
|
21
39
|
return (
|
|
22
40
|
<div
|
|
23
41
|
ref={ref}
|
|
24
|
-
className={cl("navds-confirmation-panel", className, {
|
|
25
|
-
"navds-confirmation-panel--small":
|
|
26
|
-
"navds-confirmation-panel--error":
|
|
42
|
+
className={cl("navds-confirmation-panel", "navds-form-field", className, {
|
|
43
|
+
"navds-confirmation-panel--small": size === "small",
|
|
44
|
+
"navds-confirmation-panel--error": hasError,
|
|
27
45
|
"navds-confirmation-panel--checked": !!props.checked,
|
|
28
46
|
})}
|
|
29
47
|
>
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
48
|
+
<div className="navds-confirmation-panel__inner">
|
|
49
|
+
{children && (
|
|
50
|
+
<BodyLong
|
|
51
|
+
size={props.size}
|
|
52
|
+
className="navds-confirmation-panel__content"
|
|
53
|
+
>
|
|
54
|
+
{children}
|
|
55
|
+
</BodyLong>
|
|
56
|
+
)}
|
|
57
|
+
<Checkbox {...props} {...inputProps} error={hasError} size={size}>
|
|
58
|
+
{label}
|
|
59
|
+
</Checkbox>
|
|
60
|
+
</div>
|
|
61
|
+
<div id={errorId} aria-relevant="additions removals" aria-live="polite">
|
|
62
|
+
{showErrorMsg && <ErrorMessage size={size}>{props.error}</ErrorMessage>}
|
|
63
|
+
</div>
|
|
39
64
|
</div>
|
|
40
65
|
);
|
|
41
66
|
});
|