@navikt/ds-react 2.8.2 → 2.8.3
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 +28 -19
- package/cjs/form/Textarea.js +6 -5
- package/esm/form/Textarea.d.ts +11 -1
- package/esm/form/Textarea.js +6 -5
- package/esm/form/Textarea.js.map +1 -1
- package/esm/popover/PopoverContent.d.ts +0 -3
- package/esm/popover/PopoverContent.js.map +1 -1
- package/package.json +3 -3
- package/src/form/Textarea.tsx +14 -3
- package/src/popover/PopoverContent.tsx +0 -3
package/_docs.json
CHANGED
|
@@ -3067,6 +3067,25 @@
|
|
|
3067
3067
|
"name": "boolean"
|
|
3068
3068
|
}
|
|
3069
3069
|
},
|
|
3070
|
+
"i18n": {
|
|
3071
|
+
"defaultValue": null,
|
|
3072
|
+
"description": "i18n-translations for counter-text",
|
|
3073
|
+
"name": "i18n",
|
|
3074
|
+
"parent": {
|
|
3075
|
+
"fileName": "src/form/Textarea.tsx",
|
|
3076
|
+
"name": "TextareaProps"
|
|
3077
|
+
},
|
|
3078
|
+
"declarations": [
|
|
3079
|
+
{
|
|
3080
|
+
"fileName": "src/form/Textarea.tsx",
|
|
3081
|
+
"name": "TextareaProps"
|
|
3082
|
+
}
|
|
3083
|
+
],
|
|
3084
|
+
"required": false,
|
|
3085
|
+
"type": {
|
|
3086
|
+
"name": "{ counterLeft?: string; counterTooMuch?: string; } | undefined"
|
|
3087
|
+
}
|
|
3088
|
+
},
|
|
3070
3089
|
"error": {
|
|
3071
3090
|
"defaultValue": null,
|
|
3072
3091
|
"description": "Error message for element",
|
|
@@ -3251,6 +3270,15 @@
|
|
|
3251
3270
|
"type": {
|
|
3252
3271
|
"name": "any"
|
|
3253
3272
|
}
|
|
3273
|
+
},
|
|
3274
|
+
"i18n": {
|
|
3275
|
+
"defaultValue": null,
|
|
3276
|
+
"description": "",
|
|
3277
|
+
"name": "i18n",
|
|
3278
|
+
"required": true,
|
|
3279
|
+
"type": {
|
|
3280
|
+
"name": "any"
|
|
3281
|
+
}
|
|
3254
3282
|
}
|
|
3255
3283
|
}
|
|
3256
3284
|
},
|
|
@@ -5513,25 +5541,6 @@
|
|
|
5513
5541
|
"filePath": "src/popover/PopoverContent.tsx",
|
|
5514
5542
|
"displayName": "PopoverContent",
|
|
5515
5543
|
"props": {
|
|
5516
|
-
"children": {
|
|
5517
|
-
"defaultValue": null,
|
|
5518
|
-
"description": "Modal.Content content",
|
|
5519
|
-
"name": "children",
|
|
5520
|
-
"parent": {
|
|
5521
|
-
"fileName": "src/popover/PopoverContent.tsx",
|
|
5522
|
-
"name": "PopoverContentProps"
|
|
5523
|
-
},
|
|
5524
|
-
"declarations": [
|
|
5525
|
-
{
|
|
5526
|
-
"fileName": "src/popover/PopoverContent.tsx",
|
|
5527
|
-
"name": "PopoverContentProps"
|
|
5528
|
-
}
|
|
5529
|
-
],
|
|
5530
|
-
"required": true,
|
|
5531
|
-
"type": {
|
|
5532
|
-
"name": "ReactNode"
|
|
5533
|
-
}
|
|
5534
|
-
},
|
|
5535
5544
|
"className": {
|
|
5536
5545
|
"defaultValue": null,
|
|
5537
5546
|
"description": "",
|
package/cjs/form/Textarea.js
CHANGED
|
@@ -47,7 +47,7 @@ const TextareaAutoSize_1 = __importDefault(require("../util/TextareaAutoSize"));
|
|
|
47
47
|
exports.Textarea = (0, react_1.forwardRef)((props, ref) => {
|
|
48
48
|
var _a, _b, _c;
|
|
49
49
|
const { inputProps, errorId, showErrorMsg, hasError, size, inputDescriptionId, } = (0, useFormField_1.useFormField)(props, "textarea");
|
|
50
|
-
const { label, className, description, maxLength, hideLabel = false, resize } = props, rest = __rest(props, ["label", "className", "description", "maxLength", "hideLabel", "resize"]);
|
|
50
|
+
const { label, className, description, maxLength, hideLabel = false, resize, i18n } = props, rest = __rest(props, ["label", "className", "description", "maxLength", "hideLabel", "resize", "i18n"]);
|
|
51
51
|
const maxLengthId = (0, __2.useId)();
|
|
52
52
|
const hasMaxLength = maxLength !== undefined && maxLength > 0;
|
|
53
53
|
const [controlledValue, setControlledValue] = (0, react_1.useState)((_a = props === null || props === void 0 ? void 0 : props.defaultValue) !== null && _a !== void 0 ? _a : "");
|
|
@@ -85,16 +85,17 @@ exports.Textarea = (0, react_1.forwardRef)((props, ref) => {
|
|
|
85
85
|
"Tekstomr\u00E5de med plass til ",
|
|
86
86
|
maxLength,
|
|
87
87
|
" tegn."),
|
|
88
|
-
react_1.default.createElement(exports.Counter, { maxLength: maxLength, currentLength: (_c = (_b = props.value) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : controlledValue === null || controlledValue === void 0 ? void 0 : controlledValue.length, size: size })))),
|
|
88
|
+
react_1.default.createElement(exports.Counter, { maxLength: maxLength, currentLength: (_c = (_b = props.value) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : controlledValue === null || controlledValue === void 0 ? void 0 : controlledValue.length, size: size, i18n: i18n })))),
|
|
89
89
|
react_1.default.createElement("div", { className: "navds-form-field__error", id: errorId, "aria-relevant": "additions removals", "aria-live": "polite" }, showErrorMsg && (react_1.default.createElement(__1.ErrorMessage, { size: size }, props.error)))));
|
|
90
90
|
});
|
|
91
|
-
const Counter = ({ maxLength, currentLength, size }) => {
|
|
91
|
+
const Counter = ({ maxLength, currentLength, size, i18n }) => {
|
|
92
|
+
var _a, _b;
|
|
92
93
|
const difference = maxLength - currentLength;
|
|
93
94
|
return (react_1.default.createElement(__1.BodyShort, { className: (0, clsx_1.default)("navds-textarea__counter", {
|
|
94
95
|
"navds-textarea__counter--error": difference < 0,
|
|
95
96
|
}), "aria-live": difference < 20 ? "polite" : "off", size: size }, difference < 0
|
|
96
|
-
?
|
|
97
|
-
:
|
|
97
|
+
? `${Math.abs(difference)} ${(_a = i18n === null || i18n === void 0 ? void 0 : i18n.counterLeft) !== null && _a !== void 0 ? _a : "tegn for mye"}`
|
|
98
|
+
: `${difference} ${(_b = i18n === null || i18n === void 0 ? void 0 : i18n.counterTooMuch) !== null && _b !== void 0 ? _b : "tegn igjen"}`));
|
|
98
99
|
};
|
|
99
100
|
exports.Counter = Counter;
|
|
100
101
|
exports.default = exports.Textarea;
|
package/esm/form/Textarea.d.ts
CHANGED
|
@@ -38,11 +38,21 @@ export interface TextareaProps extends FormFieldProps, React.TextareaHTMLAttribu
|
|
|
38
38
|
* Enables resizing of field
|
|
39
39
|
*/
|
|
40
40
|
resize?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* i18n-translations for counter-text
|
|
43
|
+
*/
|
|
44
|
+
i18n?: {
|
|
45
|
+
/** @default Antall tegn igjen */
|
|
46
|
+
counterLeft?: string;
|
|
47
|
+
/** @default tegn for mye */
|
|
48
|
+
counterTooMuch?: string;
|
|
49
|
+
};
|
|
41
50
|
}
|
|
42
51
|
export declare const Textarea: React.ForwardRefExoticComponent<TextareaProps & React.RefAttributes<HTMLTextAreaElement>>;
|
|
43
|
-
export declare const Counter: ({ maxLength, currentLength, size }: {
|
|
52
|
+
export declare const Counter: ({ maxLength, currentLength, size, i18n }: {
|
|
44
53
|
maxLength: any;
|
|
45
54
|
currentLength: any;
|
|
46
55
|
size: any;
|
|
56
|
+
i18n: any;
|
|
47
57
|
}) => JSX.Element;
|
|
48
58
|
export default Textarea;
|
package/esm/form/Textarea.js
CHANGED
|
@@ -18,7 +18,7 @@ import TextareaAutosize from "../util/TextareaAutoSize";
|
|
|
18
18
|
export const Textarea = forwardRef((props, ref) => {
|
|
19
19
|
var _a, _b, _c;
|
|
20
20
|
const { inputProps, errorId, showErrorMsg, hasError, size, inputDescriptionId, } = useFormField(props, "textarea");
|
|
21
|
-
const { label, className, description, maxLength, hideLabel = false, resize } = props, rest = __rest(props, ["label", "className", "description", "maxLength", "hideLabel", "resize"]);
|
|
21
|
+
const { label, className, description, maxLength, hideLabel = false, resize, i18n } = props, rest = __rest(props, ["label", "className", "description", "maxLength", "hideLabel", "resize", "i18n"]);
|
|
22
22
|
const maxLengthId = useId();
|
|
23
23
|
const hasMaxLength = maxLength !== undefined && maxLength > 0;
|
|
24
24
|
const [controlledValue, setControlledValue] = useState((_a = props === null || props === void 0 ? void 0 : props.defaultValue) !== null && _a !== void 0 ? _a : "");
|
|
@@ -56,16 +56,17 @@ export const Textarea = forwardRef((props, ref) => {
|
|
|
56
56
|
"Tekstomr\u00E5de med plass til ",
|
|
57
57
|
maxLength,
|
|
58
58
|
" tegn."),
|
|
59
|
-
React.createElement(Counter, { maxLength: maxLength, currentLength: (_c = (_b = props.value) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : controlledValue === null || controlledValue === void 0 ? void 0 : controlledValue.length, size: size })))),
|
|
59
|
+
React.createElement(Counter, { maxLength: maxLength, currentLength: (_c = (_b = props.value) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : controlledValue === null || controlledValue === void 0 ? void 0 : controlledValue.length, size: size, i18n: i18n })))),
|
|
60
60
|
React.createElement("div", { className: "navds-form-field__error", id: errorId, "aria-relevant": "additions removals", "aria-live": "polite" }, showErrorMsg && (React.createElement(ErrorMessage, { size: size }, props.error)))));
|
|
61
61
|
});
|
|
62
|
-
export const Counter = ({ maxLength, currentLength, size }) => {
|
|
62
|
+
export const Counter = ({ maxLength, currentLength, size, i18n }) => {
|
|
63
|
+
var _a, _b;
|
|
63
64
|
const difference = maxLength - currentLength;
|
|
64
65
|
return (React.createElement(BodyShort, { className: cl("navds-textarea__counter", {
|
|
65
66
|
"navds-textarea__counter--error": difference < 0,
|
|
66
67
|
}), "aria-live": difference < 20 ? "polite" : "off", size: size }, difference < 0
|
|
67
|
-
?
|
|
68
|
-
:
|
|
68
|
+
? `${Math.abs(difference)} ${(_a = i18n === null || i18n === void 0 ? void 0 : i18n.counterLeft) !== null && _a !== void 0 ? _a : "tegn for mye"}`
|
|
69
|
+
: `${difference} ${(_b = i18n === null || i18n === void 0 ? void 0 : i18n.counterTooMuch) !== null && _b !== void 0 ? _b : "tegn igjen"}`));
|
|
69
70
|
};
|
|
70
71
|
export default Textarea;
|
|
71
72
|
//# sourceMappingURL=Textarea.js.map
|
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,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC5E,OAAO,EAAkB,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAE,MAAM,IAAI,CAAC;AAC3B,OAAO,gBAAgB,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"Textarea.js","sourceRoot":"","sources":["../../src/form/Textarea.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC5E,OAAO,EAAkB,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAE,MAAM,IAAI,CAAC;AAC3B,OAAO,gBAAgB,MAAM,0BAA0B,CAAC;AAqDxD,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAChC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;;IACb,MAAM,EACJ,UAAU,EACV,OAAO,EACP,YAAY,EACZ,QAAQ,EACR,IAAI,EACJ,kBAAkB,GACnB,GAAG,YAAY,CAAC,KAAK,EAAE,UAAU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GAAG,UAAU,IAAI,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,cAAc,mCAAI,YAAY,EAAE,CACjD,CACb,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
export interface PopoverContentProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
|
-
/**
|
|
4
|
-
* Modal.Content content
|
|
5
|
-
*/
|
|
6
3
|
children: React.ReactNode;
|
|
7
4
|
}
|
|
8
5
|
export type PopoverContentType = React.ForwardRefExoticComponent<PopoverContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopoverContent.js","sourceRoot":"","sources":["../../src/popover/PopoverContent.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"PopoverContent.js","sourceRoot":"","sources":["../../src/popover/PopoverContent.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,MAAM,MAAM,CAAC;AAWtB,MAAM,cAAc,GAAuB,UAAU,CACnD,CAAC,EAAsB,EAAE,GAAG,EAAE,EAAE;QAA/B,EAAE,SAAS,OAAW,EAAN,IAAI,cAApB,aAAsB,CAAF;IAAY,OAAA,CAC/B,6CACM,IAAI,IACR,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CAAC,wBAAwB,EAAE,SAAS,CAAC,IAClD,CACH,CAAA;CAAA,CACF,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navikt/ds-react",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.3",
|
|
4
4
|
"description": "Aksel react-components for NAV designsystem",
|
|
5
5
|
"author": "Aksel | NAV designsystem team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@floating-ui/react": "0.17.0",
|
|
40
|
-
"@navikt/aksel-icons": "^2.8.
|
|
41
|
-
"@navikt/ds-icons": "^2.8.
|
|
40
|
+
"@navikt/aksel-icons": "^2.8.3",
|
|
41
|
+
"@navikt/ds-icons": "^2.8.3",
|
|
42
42
|
"@radix-ui/react-tabs": "1.0.0",
|
|
43
43
|
"@radix-ui/react-toggle-group": "1.0.0",
|
|
44
44
|
"clsx": "^1.2.1",
|
package/src/form/Textarea.tsx
CHANGED
|
@@ -45,6 +45,15 @@ export interface TextareaProps
|
|
|
45
45
|
* Enables resizing of field
|
|
46
46
|
*/
|
|
47
47
|
resize?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* i18n-translations for counter-text
|
|
50
|
+
*/
|
|
51
|
+
i18n?: {
|
|
52
|
+
/** @default Antall tegn igjen */
|
|
53
|
+
counterLeft?: string;
|
|
54
|
+
/** @default tegn for mye */
|
|
55
|
+
counterTooMuch?: string;
|
|
56
|
+
};
|
|
48
57
|
}
|
|
49
58
|
|
|
50
59
|
export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
@@ -65,6 +74,7 @@ export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
|
65
74
|
maxLength,
|
|
66
75
|
hideLabel = false,
|
|
67
76
|
resize,
|
|
77
|
+
i18n,
|
|
68
78
|
...rest
|
|
69
79
|
} = props;
|
|
70
80
|
|
|
@@ -166,6 +176,7 @@ export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
|
166
176
|
maxLength={maxLength}
|
|
167
177
|
currentLength={props.value?.length ?? controlledValue?.length}
|
|
168
178
|
size={size}
|
|
179
|
+
i18n={i18n}
|
|
169
180
|
/>
|
|
170
181
|
</>
|
|
171
182
|
)}
|
|
@@ -185,7 +196,7 @@ export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
|
185
196
|
}
|
|
186
197
|
);
|
|
187
198
|
|
|
188
|
-
export const Counter = ({ maxLength, currentLength, size }) => {
|
|
199
|
+
export const Counter = ({ maxLength, currentLength, size, i18n }) => {
|
|
189
200
|
const difference = maxLength - currentLength;
|
|
190
201
|
|
|
191
202
|
return (
|
|
@@ -197,8 +208,8 @@ export const Counter = ({ maxLength, currentLength, size }) => {
|
|
|
197
208
|
size={size}
|
|
198
209
|
>
|
|
199
210
|
{difference < 0
|
|
200
|
-
?
|
|
201
|
-
:
|
|
211
|
+
? `${Math.abs(difference)} ${i18n?.counterLeft ?? "tegn for mye"}`
|
|
212
|
+
: `${difference} ${i18n?.counterTooMuch ?? "tegn igjen"}`}
|
|
202
213
|
</BodyShort>
|
|
203
214
|
);
|
|
204
215
|
};
|