@navikt/ds-react 0.17.26 → 0.17.27
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/form/Textarea.js +2 -1
- package/esm/form/ConfirmationPanel.d.ts +1 -5
- package/esm/form/ConfirmationPanel.js.map +1 -1
- package/esm/form/Textarea.d.ts +2 -2
- package/esm/form/Textarea.js +2 -1
- package/esm/form/Textarea.js.map +1 -1
- package/package.json +2 -2
- package/src/form/ConfirmationPanel.tsx +2 -5
- package/src/form/Textarea.tsx +3 -3
- package/src/form/stories/confirmation-panel.stories.tsx +7 -0
- package/src/form/stories/textarea.stories.tsx +8 -0
package/cjs/form/Textarea.js
CHANGED
|
@@ -46,6 +46,7 @@ const ErrorMessage_1 = __importDefault(require("./ErrorMessage"));
|
|
|
46
46
|
const useFormField_1 = require("./useFormField");
|
|
47
47
|
const __2 = require("..");
|
|
48
48
|
const Textarea = (0, react_1.forwardRef)((props, ref) => {
|
|
49
|
+
var _a;
|
|
49
50
|
const { inputProps, errorId, showErrorMsg, hasError, size, inputDescriptionId, } = (0, useFormField_1.useFormField)(props, "textarea");
|
|
50
51
|
const { label, className, description, maxLength, hideLabel = false } = props, rest = __rest(props, ["label", "className", "description", "maxLength", "hideLabel"]);
|
|
51
52
|
const maxLengthId = `TextareaMaxLength-${(0, __2.useId)()}`;
|
|
@@ -74,7 +75,7 @@ const Textarea = (0, react_1.forwardRef)((props, ref) => {
|
|
|
74
75
|
" ",
|
|
75
76
|
maxLength,
|
|
76
77
|
" signs."),
|
|
77
|
-
react_1.default.createElement(exports.Counter, { maxLength: maxLength, currentLength: props.value.length, size: size })))),
|
|
78
|
+
react_1.default.createElement(exports.Counter, { maxLength: maxLength, currentLength: (_a = props.value) === null || _a === void 0 ? void 0 : _a.length, size: size })))),
|
|
78
79
|
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)))));
|
|
79
80
|
});
|
|
80
81
|
const Counter = ({ maxLength, currentLength, size }) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { CheckboxProps } from "..";
|
|
3
|
-
export interface ConfirmationPanelProps extends
|
|
3
|
+
export interface ConfirmationPanelProps extends Omit<CheckboxProps, "children"> {
|
|
4
4
|
/**
|
|
5
5
|
* Additional information on panel
|
|
6
6
|
*/
|
|
@@ -9,10 +9,6 @@ export interface ConfirmationPanelProps extends Partial<CheckboxProps> {
|
|
|
9
9
|
* Checkbox label
|
|
10
10
|
*/
|
|
11
11
|
label: React.ReactNode;
|
|
12
|
-
/**
|
|
13
|
-
* Checked state for checkbox
|
|
14
|
-
*/
|
|
15
|
-
checked: boolean;
|
|
16
12
|
}
|
|
17
13
|
declare const ConfirmationPanel: React.ForwardRefExoticComponent<ConfirmationPanelProps & React.RefAttributes<HTMLDivElement>>;
|
|
18
14
|
export default ConfirmationPanel;
|
|
@@ -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/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;AAcvD,MAAM,iBAAiB,GAAG,UAAU,CAClC,CAAC,EAAwC,EAAE,GAAG,EAAE,EAAE;QAAjD,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,OAAY,EAAP,KAAK,cAAtC,kCAAwC,CAAF;IACrC,OAAO,CACL,6BACE,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CAAC,0BAA0B,EAAE,SAAS,EAAE;YACnD,iCAAiC,EAAE,KAAK,CAAC,IAAI,KAAK,OAAO;YACzD,iCAAiC,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK;YAChD,mCAAmC,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO;SACrD,CAAC;QAED,QAAQ,IAAI,CACX,oBAAC,QAAQ,IACP,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,SAAS,EAAC,mCAAmC,IAE5C,QAAQ,CACA,CACZ;QACD,oBAAC,QAAQ,oBAAK,KAAK,GAAG,KAAK,CAAY,CACnC,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
package/esm/form/Textarea.d.ts
CHANGED
|
@@ -8,8 +8,8 @@ export interface TextareaProps extends FormFieldProps, React.TextareaHTMLAttribu
|
|
|
8
8
|
* Visually allowed length of content
|
|
9
9
|
*/
|
|
10
10
|
maxLength?: number;
|
|
11
|
-
value
|
|
12
|
-
|
|
11
|
+
value?: string;
|
|
12
|
+
defaultValue?: string;
|
|
13
13
|
/**
|
|
14
14
|
* Maximum number of rows to display.
|
|
15
15
|
* @bug Internal scrolling with `maxLength` scrolls over maxLength-text
|
package/esm/form/Textarea.js
CHANGED
|
@@ -17,6 +17,7 @@ import ErrorMessage from "./ErrorMessage";
|
|
|
17
17
|
import { useFormField } from "./useFormField";
|
|
18
18
|
import { useId } from "..";
|
|
19
19
|
const Textarea = forwardRef((props, ref) => {
|
|
20
|
+
var _a;
|
|
20
21
|
const { inputProps, errorId, showErrorMsg, hasError, size, inputDescriptionId, } = useFormField(props, "textarea");
|
|
21
22
|
const { label, className, description, maxLength, hideLabel = false } = props, rest = __rest(props, ["label", "className", "description", "maxLength", "hideLabel"]);
|
|
22
23
|
const maxLengthId = `TextareaMaxLength-${useId()}`;
|
|
@@ -45,7 +46,7 @@ const Textarea = forwardRef((props, ref) => {
|
|
|
45
46
|
" ",
|
|
46
47
|
maxLength,
|
|
47
48
|
" signs."),
|
|
48
|
-
React.createElement(Counter, { maxLength: maxLength, currentLength: props.value.length, size: size })))),
|
|
49
|
+
React.createElement(Counter, { maxLength: maxLength, currentLength: (_a = props.value) === null || _a === void 0 ? void 0 : _a.length, size: size })))),
|
|
49
50
|
React.createElement("div", { id: errorId, "aria-relevant": "additions removals", "aria-live": "polite" }, showErrorMsg && (React.createElement(ErrorMessage, { size: size }, props.error)))));
|
|
50
51
|
});
|
|
51
52
|
export const Counter = ({ maxLength, currentLength, size }) => {
|
package/esm/form/Textarea.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Textarea.js","sourceRoot":"","sources":["../../src/form/Textarea.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,gBAAgB,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC5C,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAkB,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAE,MAAM,IAAI,CAAC;AAiC3B,MAAM,QAAQ,GAAG,UAAU,CACzB,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE
|
|
1
|
+
{"version":3,"file":"Textarea.js","sourceRoot":"","sources":["../../src/form/Textarea.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE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AAE,EAAE,CAAC,yBAAyB,EAAE;YACvC,gCAAgC,EAAE,UAAU,GAAG,CAAC;SACjD,CAAC,eACS,UAAU,GAAG,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,EAC7C,IAAI,EAAE,IAAI,IAET,UAAU,GAAG,CAAC;QACb,CAAC,CAAC,UAAU,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,eAAe;QAC/C,CAAC,CAAC,UAAU,UAAU,aAAa,CAC3B,CACb,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navikt/ds-react",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.27",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "NAV designsystem react components",
|
|
6
6
|
"author": "NAV Designsystem team",
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"@types/react": "^17.0.30 || ^18.0.0",
|
|
70
70
|
"react": "^17.0.0 || ^18.0.0"
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "ff48bea20bbc5ec23379ba06cad1a58ac858d0ba"
|
|
73
73
|
}
|
|
@@ -2,7 +2,8 @@ import React, { forwardRef } from "react";
|
|
|
2
2
|
import cl from "classnames";
|
|
3
3
|
import { BodyLong, Checkbox, CheckboxProps } from "..";
|
|
4
4
|
|
|
5
|
-
export interface ConfirmationPanelProps
|
|
5
|
+
export interface ConfirmationPanelProps
|
|
6
|
+
extends Omit<CheckboxProps, "children"> {
|
|
6
7
|
/**
|
|
7
8
|
* Additional information on panel
|
|
8
9
|
*/
|
|
@@ -11,10 +12,6 @@ export interface ConfirmationPanelProps extends Partial<CheckboxProps> {
|
|
|
11
12
|
* Checkbox label
|
|
12
13
|
*/
|
|
13
14
|
label: React.ReactNode;
|
|
14
|
-
/**
|
|
15
|
-
* Checked state for checkbox
|
|
16
|
-
*/
|
|
17
|
-
checked: boolean;
|
|
18
15
|
}
|
|
19
16
|
|
|
20
17
|
const ConfirmationPanel = forwardRef<HTMLDivElement, ConfirmationPanelProps>(
|
package/src/form/Textarea.tsx
CHANGED
|
@@ -16,8 +16,8 @@ export interface TextareaProps
|
|
|
16
16
|
* Visually allowed length of content
|
|
17
17
|
*/
|
|
18
18
|
maxLength?: number;
|
|
19
|
-
value
|
|
20
|
-
|
|
19
|
+
value?: string;
|
|
20
|
+
defaultValue?: string;
|
|
21
21
|
/**
|
|
22
22
|
* Maximum number of rows to display.
|
|
23
23
|
* @bug Internal scrolling with `maxLength` scrolls over maxLength-text
|
|
@@ -119,7 +119,7 @@ const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
|
119
119
|
</span>
|
|
120
120
|
<Counter
|
|
121
121
|
maxLength={maxLength}
|
|
122
|
-
currentLength={props.value
|
|
122
|
+
currentLength={props.value?.length}
|
|
123
123
|
size={size}
|
|
124
124
|
/>
|
|
125
125
|
</>
|
|
@@ -57,6 +57,13 @@ export const All = () => {
|
|
|
57
57
|
onChange={() => setChecked(!checked)}
|
|
58
58
|
label="Checkbox label text"
|
|
59
59
|
></ConfirmationPanel>
|
|
60
|
+
<h2>Uncontrolled</h2>
|
|
61
|
+
<ConfirmationPanel label="Checkbox label text"></ConfirmationPanel>
|
|
62
|
+
<h3>defaultChecked</h3>
|
|
63
|
+
<ConfirmationPanel
|
|
64
|
+
defaultChecked
|
|
65
|
+
label="Checkbox label text"
|
|
66
|
+
></ConfirmationPanel>
|
|
60
67
|
</div>
|
|
61
68
|
);
|
|
62
69
|
};
|
|
@@ -19,6 +19,14 @@ export const All = () => {
|
|
|
19
19
|
|
|
20
20
|
<Textarea label="In anim elit" value={value} onChange={handleChange} />
|
|
21
21
|
|
|
22
|
+
<h2>Uncontrolled</h2>
|
|
23
|
+
|
|
24
|
+
<Textarea label="In anim elit" />
|
|
25
|
+
|
|
26
|
+
<h3>defaultValue</h3>
|
|
27
|
+
|
|
28
|
+
<Textarea label="In anim elit" defaultValue="wat" />
|
|
29
|
+
|
|
22
30
|
<h2>Description</h2>
|
|
23
31
|
|
|
24
32
|
<Textarea
|