@navikt/ds-react 5.10.1 → 5.10.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 +47 -7
- package/cjs/form/Textarea.js +7 -18
- package/cjs/form/TextareaCounter.js +18 -0
- package/cjs/form/error-summary/ErrorSummary.js +4 -1
- package/cjs/form/index.js +15 -16
- package/esm/form/Textarea.d.ts +1 -8
- package/esm/form/Textarea.js +5 -15
- package/esm/form/Textarea.js.map +1 -1
- package/esm/form/TextareaCounter.d.ts +10 -0
- package/esm/form/TextareaCounter.js +14 -0
- package/esm/form/TextareaCounter.js.map +1 -0
- package/esm/form/error-summary/ErrorSummary.js +5 -2
- package/esm/form/error-summary/ErrorSummary.js.map +1 -1
- package/esm/form/index.d.ts +7 -7
- package/esm/form/index.js +6 -6
- package/esm/form/index.js.map +1 -1
- package/esm/util/OverridableComponent.d.ts +18 -1
- package/package.json +3 -3
- package/src/form/Textarea.tsx +6 -27
- package/src/form/TextareaCounter.tsx +31 -0
- package/src/form/error-summary/ErrorSummary.tsx +5 -2
- package/src/form/index.ts +10 -10
- package/src/form/stories/textarea.stories.tsx +16 -1
- package/src/layout/bleed/Bleed.stories.tsx +2 -2
- package/src/util/OverridableComponent.ts +18 -1
package/_docs.json
CHANGED
|
@@ -3418,7 +3418,7 @@
|
|
|
3418
3418
|
},
|
|
3419
3419
|
"maxRows": {
|
|
3420
3420
|
"defaultValue": null,
|
|
3421
|
-
"description": "Maximum number of character rows to display
|
|
3421
|
+
"description": "Maximum number of character rows to display.",
|
|
3422
3422
|
"name": "maxRows",
|
|
3423
3423
|
"parent": {
|
|
3424
3424
|
"fileName": "src/form/Textarea.tsx",
|
|
@@ -3704,43 +3704,83 @@
|
|
|
3704
3704
|
}
|
|
3705
3705
|
},
|
|
3706
3706
|
{
|
|
3707
|
-
"filePath": "src/form/
|
|
3708
|
-
"displayName": "
|
|
3707
|
+
"filePath": "src/form/TextareaCounter.tsx",
|
|
3708
|
+
"displayName": "TextareaCounter",
|
|
3709
3709
|
"props": {
|
|
3710
3710
|
"maxLength": {
|
|
3711
3711
|
"defaultValue": null,
|
|
3712
3712
|
"description": "",
|
|
3713
3713
|
"name": "maxLength",
|
|
3714
|
+
"parent": {
|
|
3715
|
+
"fileName": "src/form/TextareaCounter.tsx",
|
|
3716
|
+
"name": "Props"
|
|
3717
|
+
},
|
|
3718
|
+
"declarations": [
|
|
3719
|
+
{
|
|
3720
|
+
"fileName": "src/form/TextareaCounter.tsx",
|
|
3721
|
+
"name": "Props"
|
|
3722
|
+
}
|
|
3723
|
+
],
|
|
3714
3724
|
"required": true,
|
|
3715
3725
|
"type": {
|
|
3716
|
-
"name": "
|
|
3726
|
+
"name": "number"
|
|
3717
3727
|
}
|
|
3718
3728
|
},
|
|
3719
3729
|
"currentLength": {
|
|
3720
3730
|
"defaultValue": null,
|
|
3721
3731
|
"description": "",
|
|
3722
3732
|
"name": "currentLength",
|
|
3733
|
+
"parent": {
|
|
3734
|
+
"fileName": "src/form/TextareaCounter.tsx",
|
|
3735
|
+
"name": "Props"
|
|
3736
|
+
},
|
|
3737
|
+
"declarations": [
|
|
3738
|
+
{
|
|
3739
|
+
"fileName": "src/form/TextareaCounter.tsx",
|
|
3740
|
+
"name": "Props"
|
|
3741
|
+
}
|
|
3742
|
+
],
|
|
3723
3743
|
"required": true,
|
|
3724
3744
|
"type": {
|
|
3725
|
-
"name": "
|
|
3745
|
+
"name": "number"
|
|
3726
3746
|
}
|
|
3727
3747
|
},
|
|
3728
3748
|
"size": {
|
|
3729
3749
|
"defaultValue": null,
|
|
3730
3750
|
"description": "",
|
|
3731
3751
|
"name": "size",
|
|
3752
|
+
"parent": {
|
|
3753
|
+
"fileName": "src/form/TextareaCounter.tsx",
|
|
3754
|
+
"name": "Props"
|
|
3755
|
+
},
|
|
3756
|
+
"declarations": [
|
|
3757
|
+
{
|
|
3758
|
+
"fileName": "src/form/TextareaCounter.tsx",
|
|
3759
|
+
"name": "Props"
|
|
3760
|
+
}
|
|
3761
|
+
],
|
|
3732
3762
|
"required": true,
|
|
3733
3763
|
"type": {
|
|
3734
|
-
"name": "
|
|
3764
|
+
"name": "\"medium\" | \"small\" | undefined"
|
|
3735
3765
|
}
|
|
3736
3766
|
},
|
|
3737
3767
|
"i18n": {
|
|
3738
3768
|
"defaultValue": null,
|
|
3739
3769
|
"description": "",
|
|
3740
3770
|
"name": "i18n",
|
|
3771
|
+
"parent": {
|
|
3772
|
+
"fileName": "src/form/TextareaCounter.tsx",
|
|
3773
|
+
"name": "Props"
|
|
3774
|
+
},
|
|
3775
|
+
"declarations": [
|
|
3776
|
+
{
|
|
3777
|
+
"fileName": "src/form/TextareaCounter.tsx",
|
|
3778
|
+
"name": "Props"
|
|
3779
|
+
}
|
|
3780
|
+
],
|
|
3741
3781
|
"required": true,
|
|
3742
3782
|
"type": {
|
|
3743
|
-
"name": "
|
|
3783
|
+
"name": "{ counterLeft?: string | undefined; counterTooMuch?: string | undefined; } | undefined"
|
|
3744
3784
|
}
|
|
3745
3785
|
}
|
|
3746
3786
|
}
|
package/cjs/form/Textarea.js
CHANGED
|
@@ -37,14 +37,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
37
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
38
|
};
|
|
39
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
exports.
|
|
40
|
+
exports.Textarea = void 0;
|
|
41
41
|
const clsx_1 = __importDefault(require("clsx"));
|
|
42
42
|
const react_1 = __importStar(require("react"));
|
|
43
43
|
const typography_1 = require("../typography");
|
|
44
|
+
const util_1 = require("../util");
|
|
44
45
|
const TextareaAutoSize_1 = __importDefault(require("../util/TextareaAutoSize"));
|
|
45
|
-
const useFormField_1 = require("./useFormField");
|
|
46
46
|
const ReadOnlyIcon_1 = require("./ReadOnlyIcon");
|
|
47
|
-
const
|
|
47
|
+
const TextareaCounter_1 = __importDefault(require("./TextareaCounter"));
|
|
48
|
+
const useFormField_1 = require("./useFormField");
|
|
48
49
|
/**
|
|
49
50
|
* A component that displays a textarea input field with a label.
|
|
50
51
|
*
|
|
@@ -91,22 +92,10 @@ exports.Textarea = (0, react_1.forwardRef)((props, ref) => {
|
|
|
91
92
|
react_1.default.createElement("div", { className: "navds-textarea__wrapper" },
|
|
92
93
|
react_1.default.createElement(TextareaAutoSize_1.default, Object.assign({}, (0, util_1.omit)(rest, ["error", "errorId", "size"]), inputProps, { onChange: (e) => props.onChange
|
|
93
94
|
? props.onChange(e)
|
|
94
|
-
: setControlledValue(e.target.value), minRows: getMinRows(), ref: ref, readOnly: readOnly, className: (0, clsx_1.default)("navds-textarea__input", "navds-body-short", `navds-body-short--${size !== null && size !== void 0 ? size : "medium"}
|
|
95
|
-
|
|
96
|
-
}) }, (describedBy ? { "aria-describedby": describedBy } : {}))),
|
|
97
|
-
hasMaxLength && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
95
|
+
: setControlledValue(e.target.value), minRows: getMinRows(), ref: ref, readOnly: readOnly, className: (0, clsx_1.default)("navds-textarea__input", "navds-body-short", `navds-body-short--${size !== null && size !== void 0 ? size : "medium"}`) }, (describedBy ? { "aria-describedby": describedBy } : {}))),
|
|
96
|
+
hasMaxLength && !readOnly && !inputProps.disabled && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
98
97
|
react_1.default.createElement("span", { id: maxLengthId, className: "navds-sr-only" }, `Tekstområde med plass til ${maxLength} tegn.`),
|
|
99
|
-
react_1.default.createElement(
|
|
98
|
+
react_1.default.createElement(TextareaCounter_1.default, { 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 })))),
|
|
100
99
|
react_1.default.createElement("div", { className: "navds-form-field__error", id: errorId, "aria-relevant": "additions removals", "aria-live": "polite" }, showErrorMsg && (react_1.default.createElement(typography_1.ErrorMessage, { size: size }, props.error)))));
|
|
101
100
|
});
|
|
102
|
-
const Counter = ({ maxLength, currentLength, size, i18n }) => {
|
|
103
|
-
var _a, _b;
|
|
104
|
-
const difference = maxLength - currentLength;
|
|
105
|
-
return (react_1.default.createElement(typography_1.BodyShort, { className: (0, clsx_1.default)("navds-textarea__counter", {
|
|
106
|
-
"navds-textarea__counter--error": difference < 0,
|
|
107
|
-
}), "aria-live": difference < 20 ? "polite" : "off", size: size }, difference < 0
|
|
108
|
-
? `${Math.abs(difference)} ${(_a = i18n === null || i18n === void 0 ? void 0 : i18n.counterTooMuch) !== null && _a !== void 0 ? _a : "tegn for mye"}`
|
|
109
|
-
: `${difference} ${(_b = i18n === null || i18n === void 0 ? void 0 : i18n.counterLeft) !== null && _b !== void 0 ? _b : "tegn igjen"}`));
|
|
110
|
-
};
|
|
111
|
-
exports.Counter = Counter;
|
|
112
101
|
exports.default = exports.Textarea;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const clsx_1 = __importDefault(require("clsx"));
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const typography_1 = require("../typography");
|
|
9
|
+
const TextareaCounter = ({ maxLength, currentLength, size, i18n }) => {
|
|
10
|
+
var _a, _b;
|
|
11
|
+
const difference = maxLength - currentLength;
|
|
12
|
+
return (react_1.default.createElement(typography_1.BodyShort, { className: (0, clsx_1.default)("navds-textarea__counter", {
|
|
13
|
+
"navds-textarea__counter--error": difference < 0,
|
|
14
|
+
}), role: difference < 20 ? "status" : undefined, size: size }, difference < 0
|
|
15
|
+
? `${Math.abs(difference)} ${(_a = i18n === null || i18n === void 0 ? void 0 : i18n.counterTooMuch) !== null && _a !== void 0 ? _a : "tegn for mye"}`
|
|
16
|
+
: `${difference} ${(_b = i18n === null || i18n === void 0 ? void 0 : i18n.counterLeft) !== null && _b !== void 0 ? _b : "tegn igjen"}`));
|
|
17
|
+
};
|
|
18
|
+
exports.default = TextareaCounter;
|
|
@@ -67,7 +67,10 @@ exports.ErrorSummary = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
67
67
|
return (react_1.default.createElement("section", Object.assign({ ref: ref }, rest, { className: (0, clsx_1.default)(className, "navds-error-summary", `navds-error-summary--${size}`), tabIndex: -1, "aria-live": "polite", "aria-relevant": "all", "aria-labelledby": headingId }),
|
|
68
68
|
react_1.default.createElement(typography_1.Heading, { className: "navds-error-summary__heading", as: headingTag, size: "small", id: headingId }, heading),
|
|
69
69
|
react_1.default.createElement(typography_1.BodyShort, { as: "ul", size: size, className: "navds-error-summary__list" }, react_1.default.Children.map(children, (child) => {
|
|
70
|
-
|
|
70
|
+
if (!(0, react_1.isValidElement)(child)) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
return react_1.default.createElement("li", { key: child.toString() }, child);
|
|
71
74
|
}))));
|
|
72
75
|
});
|
|
73
76
|
exports.ErrorSummary.Item = ErrorSummaryItem_1.default;
|
package/cjs/form/index.js
CHANGED
|
@@ -3,30 +3,29 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
var checkbox_1 = require("./checkbox");
|
|
8
|
-
Object.defineProperty(exports, "Checkbox", { enumerable: true, get: function () { return checkbox_1.Checkbox; } });
|
|
9
|
-
Object.defineProperty(exports, "CheckboxGroup", { enumerable: true, get: function () { return checkbox_1.CheckboxGroup; } });
|
|
6
|
+
exports.Search = exports.RadioGroup = exports.Radio = exports.ErrorSummary = exports.UNSAFE_Combobox = exports.CheckboxGroup = exports.Checkbox = exports.Textarea = exports.TextField = exports.Switch = exports.Select = exports.FieldsetContext = exports.Fieldset = exports.ConfirmationPanel = void 0;
|
|
10
7
|
var ConfirmationPanel_1 = require("./ConfirmationPanel");
|
|
11
8
|
Object.defineProperty(exports, "ConfirmationPanel", { enumerable: true, get: function () { return __importDefault(ConfirmationPanel_1).default; } });
|
|
12
|
-
var error_summary_1 = require("./error-summary");
|
|
13
|
-
Object.defineProperty(exports, "ErrorSummary", { enumerable: true, get: function () { return error_summary_1.ErrorSummary; } });
|
|
14
9
|
var Fieldset_1 = require("./Fieldset");
|
|
15
10
|
Object.defineProperty(exports, "Fieldset", { enumerable: true, get: function () { return Fieldset_1.Fieldset; } });
|
|
16
11
|
Object.defineProperty(exports, "FieldsetContext", { enumerable: true, get: function () { return Fieldset_1.FieldsetContext; } });
|
|
17
|
-
var radio_1 = require("./radio");
|
|
18
|
-
Object.defineProperty(exports, "Radio", { enumerable: true, get: function () { return radio_1.Radio; } });
|
|
19
|
-
Object.defineProperty(exports, "RadioGroup", { enumerable: true, get: function () { return radio_1.RadioGroup; } });
|
|
20
|
-
var search_1 = require("./search");
|
|
21
|
-
Object.defineProperty(exports, "Search", { enumerable: true, get: function () { return search_1.Search; } });
|
|
22
|
-
var combobox_1 = require("./combobox");
|
|
23
|
-
Object.defineProperty(exports, "UNSAFE_Combobox", { enumerable: true, get: function () { return combobox_1.Combobox; } });
|
|
24
12
|
var Select_1 = require("./Select");
|
|
25
13
|
Object.defineProperty(exports, "Select", { enumerable: true, get: function () { return __importDefault(Select_1).default; } });
|
|
26
14
|
var Switch_1 = require("./Switch");
|
|
27
15
|
Object.defineProperty(exports, "Switch", { enumerable: true, get: function () { return __importDefault(Switch_1).default; } });
|
|
28
|
-
var Textarea_1 = require("./Textarea");
|
|
29
|
-
Object.defineProperty(exports, "Counter", { enumerable: true, get: function () { return Textarea_1.Counter; } });
|
|
30
|
-
Object.defineProperty(exports, "Textarea", { enumerable: true, get: function () { return __importDefault(Textarea_1).default; } });
|
|
31
16
|
var TextField_1 = require("./TextField");
|
|
32
17
|
Object.defineProperty(exports, "TextField", { enumerable: true, get: function () { return __importDefault(TextField_1).default; } });
|
|
18
|
+
var Textarea_1 = require("./Textarea");
|
|
19
|
+
Object.defineProperty(exports, "Textarea", { enumerable: true, get: function () { return __importDefault(Textarea_1).default; } });
|
|
20
|
+
var checkbox_1 = require("./checkbox");
|
|
21
|
+
Object.defineProperty(exports, "Checkbox", { enumerable: true, get: function () { return checkbox_1.Checkbox; } });
|
|
22
|
+
Object.defineProperty(exports, "CheckboxGroup", { enumerable: true, get: function () { return checkbox_1.CheckboxGroup; } });
|
|
23
|
+
var combobox_1 = require("./combobox");
|
|
24
|
+
Object.defineProperty(exports, "UNSAFE_Combobox", { enumerable: true, get: function () { return combobox_1.Combobox; } });
|
|
25
|
+
var error_summary_1 = require("./error-summary");
|
|
26
|
+
Object.defineProperty(exports, "ErrorSummary", { enumerable: true, get: function () { return error_summary_1.ErrorSummary; } });
|
|
27
|
+
var radio_1 = require("./radio");
|
|
28
|
+
Object.defineProperty(exports, "Radio", { enumerable: true, get: function () { return radio_1.Radio; } });
|
|
29
|
+
Object.defineProperty(exports, "RadioGroup", { enumerable: true, get: function () { return radio_1.RadioGroup; } });
|
|
30
|
+
var search_1 = require("./search");
|
|
31
|
+
Object.defineProperty(exports, "Search", { enumerable: true, get: function () { return search_1.Search; } });
|
package/esm/form/Textarea.d.ts
CHANGED
|
@@ -19,7 +19,6 @@ export interface TextareaProps extends FormFieldProps, React.TextareaHTMLAttribu
|
|
|
19
19
|
defaultValue?: string;
|
|
20
20
|
/**
|
|
21
21
|
* Maximum number of character rows to display.
|
|
22
|
-
* @bug Internal scrolling with `maxLength` scrolls over maxLength-text
|
|
23
22
|
*/
|
|
24
23
|
maxRows?: number;
|
|
25
24
|
/**
|
|
@@ -42,7 +41,7 @@ export interface TextareaProps extends FormFieldProps, React.TextareaHTMLAttribu
|
|
|
42
41
|
* i18n-translations for counter-text
|
|
43
42
|
*/
|
|
44
43
|
i18n?: {
|
|
45
|
-
/** @default
|
|
44
|
+
/** @default tegn igjen */
|
|
46
45
|
counterLeft?: string;
|
|
47
46
|
/** @default tegn for mye */
|
|
48
47
|
counterTooMuch?: string;
|
|
@@ -60,10 +59,4 @@ export interface TextareaProps extends FormFieldProps, React.TextareaHTMLAttribu
|
|
|
60
59
|
* ```
|
|
61
60
|
*/
|
|
62
61
|
export declare const Textarea: React.ForwardRefExoticComponent<TextareaProps & React.RefAttributes<HTMLTextAreaElement>>;
|
|
63
|
-
export declare const Counter: ({ maxLength, currentLength, size, i18n }: {
|
|
64
|
-
maxLength: any;
|
|
65
|
-
currentLength: any;
|
|
66
|
-
size: any;
|
|
67
|
-
i18n: any;
|
|
68
|
-
}) => React.JSX.Element;
|
|
69
62
|
export default Textarea;
|
package/esm/form/Textarea.js
CHANGED
|
@@ -12,10 +12,11 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import cl from "clsx";
|
|
13
13
|
import React, { forwardRef, useState } from "react";
|
|
14
14
|
import { BodyShort, ErrorMessage, Label } from "../typography";
|
|
15
|
+
import { omit, useId } from "../util";
|
|
15
16
|
import TextareaAutosize from "../util/TextareaAutoSize";
|
|
16
|
-
import { useFormField } from "./useFormField";
|
|
17
17
|
import { ReadOnlyIcon } from "./ReadOnlyIcon";
|
|
18
|
-
import
|
|
18
|
+
import Counter from "./TextareaCounter";
|
|
19
|
+
import { useFormField } from "./useFormField";
|
|
19
20
|
/**
|
|
20
21
|
* A component that displays a textarea input field with a label.
|
|
21
22
|
*
|
|
@@ -62,22 +63,11 @@ export const Textarea = forwardRef((props, ref) => {
|
|
|
62
63
|
React.createElement("div", { className: "navds-textarea__wrapper" },
|
|
63
64
|
React.createElement(TextareaAutosize, Object.assign({}, omit(rest, ["error", "errorId", "size"]), inputProps, { onChange: (e) => props.onChange
|
|
64
65
|
? props.onChange(e)
|
|
65
|
-
: setControlledValue(e.target.value), minRows: getMinRows(), ref: ref, readOnly: readOnly, className: cl("navds-textarea__input", "navds-body-short", `navds-body-short--${size !== null && size !== void 0 ? size : "medium"}
|
|
66
|
-
|
|
67
|
-
}) }, (describedBy ? { "aria-describedby": describedBy } : {}))),
|
|
68
|
-
hasMaxLength && (React.createElement(React.Fragment, null,
|
|
66
|
+
: setControlledValue(e.target.value), minRows: getMinRows(), ref: ref, readOnly: readOnly, className: cl("navds-textarea__input", "navds-body-short", `navds-body-short--${size !== null && size !== void 0 ? size : "medium"}`) }, (describedBy ? { "aria-describedby": describedBy } : {}))),
|
|
67
|
+
hasMaxLength && !readOnly && !inputProps.disabled && (React.createElement(React.Fragment, null,
|
|
69
68
|
React.createElement("span", { id: maxLengthId, className: "navds-sr-only" }, `Tekstområde med plass til ${maxLength} tegn.`),
|
|
70
69
|
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 })))),
|
|
71
70
|
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)))));
|
|
72
71
|
});
|
|
73
|
-
export const Counter = ({ maxLength, currentLength, size, i18n }) => {
|
|
74
|
-
var _a, _b;
|
|
75
|
-
const difference = maxLength - currentLength;
|
|
76
|
-
return (React.createElement(BodyShort, { className: cl("navds-textarea__counter", {
|
|
77
|
-
"navds-textarea__counter--error": difference < 0,
|
|
78
|
-
}), "aria-live": difference < 20 ? "polite" : "off", size: size }, difference < 0
|
|
79
|
-
? `${Math.abs(difference)} ${(_a = i18n === null || i18n === void 0 ? void 0 : i18n.counterTooMuch) !== null && _a !== void 0 ? _a : "tegn for mye"}`
|
|
80
|
-
: `${difference} ${(_b = i18n === null || i18n === void 0 ? void 0 : i18n.counterLeft) !== null && _b !== void 0 ? _b : "tegn igjen"}`));
|
|
81
|
-
};
|
|
82
72
|
export default Textarea;
|
|
83
73
|
//# 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,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,
|
|
1
|
+
{"version":3,"file":"Textarea.js","sourceRoot":"","sources":["../../src/form/Textarea.tsx"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { TextareaProps } from "./Textarea";
|
|
3
|
+
interface Props {
|
|
4
|
+
maxLength: number;
|
|
5
|
+
currentLength: number;
|
|
6
|
+
size: TextareaProps["size"];
|
|
7
|
+
i18n: TextareaProps["i18n"];
|
|
8
|
+
}
|
|
9
|
+
declare const TextareaCounter: ({ maxLength, currentLength, size, i18n }: Props) => React.JSX.Element;
|
|
10
|
+
export default TextareaCounter;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import cl from "clsx";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { BodyShort } from "../typography";
|
|
4
|
+
const TextareaCounter = ({ maxLength, currentLength, size, i18n }) => {
|
|
5
|
+
var _a, _b;
|
|
6
|
+
const difference = maxLength - currentLength;
|
|
7
|
+
return (React.createElement(BodyShort, { className: cl("navds-textarea__counter", {
|
|
8
|
+
"navds-textarea__counter--error": difference < 0,
|
|
9
|
+
}), role: difference < 20 ? "status" : undefined, size: size }, difference < 0
|
|
10
|
+
? `${Math.abs(difference)} ${(_a = i18n === null || i18n === void 0 ? void 0 : i18n.counterTooMuch) !== null && _a !== void 0 ? _a : "tegn for mye"}`
|
|
11
|
+
: `${difference} ${(_b = i18n === null || i18n === void 0 ? void 0 : i18n.counterLeft) !== null && _b !== void 0 ? _b : "tegn igjen"}`));
|
|
12
|
+
};
|
|
13
|
+
export default TextareaCounter;
|
|
14
|
+
//# sourceMappingURL=TextareaCounter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextareaCounter.js","sourceRoot":"","sources":["../../src/form/TextareaCounter.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAU1C,MAAM,eAAe,GAAG,CAAC,EAAE,SAAS,EAAE,aAAa,EAAE,IAAI,EAAE,IAAI,EAAS,EAAE,EAAE;;IAC1E,MAAM,UAAU,GAAG,SAAS,GAAG,aAAa,CAAC;IAE7C,OAAO,CACL,oBAAC,SAAS,IACR,SAAS,EAAE,EAAE,CAAC,yBAAyB,EAAE;YACvC,gCAAgC,EAAE,UAAU,GAAG,CAAC;SACjD,CAAC,EACF,IAAI,EAAE,UAAU,GAAG,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,EAC5C,IAAI,EAAE,IAAI,IAET,UAAU,GAAG,CAAC;QACb,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,cAAc,mCAAI,cAAc,EAAE;QACrE,CAAC,CAAC,GAAG,UAAU,IAAI,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,mCAAI,YAAY,EAAE,CAC9C,CACb,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -9,7 +9,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import React, { forwardRef } from "react";
|
|
12
|
+
import React, { forwardRef, isValidElement } from "react";
|
|
13
13
|
import cl from "clsx";
|
|
14
14
|
import { Heading, BodyShort } from "../../typography";
|
|
15
15
|
import ErrorSummaryItem from "./ErrorSummaryItem";
|
|
@@ -38,7 +38,10 @@ export const ErrorSummary = forwardRef((_a, ref) => {
|
|
|
38
38
|
return (React.createElement("section", Object.assign({ ref: ref }, rest, { className: cl(className, "navds-error-summary", `navds-error-summary--${size}`), tabIndex: -1, "aria-live": "polite", "aria-relevant": "all", "aria-labelledby": headingId }),
|
|
39
39
|
React.createElement(Heading, { className: "navds-error-summary__heading", as: headingTag, size: "small", id: headingId }, heading),
|
|
40
40
|
React.createElement(BodyShort, { as: "ul", size: size, className: "navds-error-summary__list" }, React.Children.map(children, (child) => {
|
|
41
|
-
|
|
41
|
+
if (!isValidElement(child)) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
return React.createElement("li", { key: child.toString() }, child);
|
|
42
45
|
}))));
|
|
43
46
|
});
|
|
44
47
|
ErrorSummary.Item = ErrorSummaryItem;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorSummary.js","sourceRoot":"","sources":["../../../src/form/error-summary/ErrorSummary.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAkB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ErrorSummary.js","sourceRoot":"","sources":["../../../src/form/error-summary/ErrorSummary.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAkB,cAAc,EAAE,MAAM,OAAO,CAAC;AAC1E,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,gBAA0C,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AA0CnC;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,CACpC,CACE,EAOC,EACD,GAAG,EACH,EAAE;QATF,EACE,QAAQ,EACR,SAAS,EACT,IAAI,GAAG,QAAQ,EACf,UAAU,GAAG,IAAI,EACjB,OAAO,OAER,EADI,IAAI,cANT,0DAOC,CADQ;IAIT,MAAM,SAAS,GAAG,KAAK,EAAE,CAAC;IAE1B,OAAO,CACL,+CACE,GAAG,EAAE,GAAG,IACJ,IAAI,IACR,SAAS,EAAE,EAAE,CACX,SAAS,EACT,qBAAqB,EACrB,wBAAwB,IAAI,EAAE,CAC/B,EACD,QAAQ,EAAE,CAAC,CAAC,eACF,QAAQ,mBACJ,KAAK,qBACF,SAAS;QAE1B,oBAAC,OAAO,IACN,SAAS,EAAC,8BAA8B,EACxC,EAAE,EAAE,UAAU,EACd,IAAI,EAAC,OAAO,EACZ,EAAE,EAAE,SAAS,IAEZ,OAAO,CACA;QACV,oBAAC,SAAS,IAAC,EAAE,EAAC,IAAI,EAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAC,2BAA2B,IACjE,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;YACtC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE;gBAC1B,OAAO,IAAI,CAAC;aACb;YACD,OAAO,4BAAI,GAAG,EAAE,KAAK,CAAC,QAAQ,EAAE,IAAG,KAAK,CAAM,CAAC;QACjD,CAAC,CAAC,CACQ,CACJ,CACX,CAAC;AACJ,CAAC,CACuB,CAAC;AAE3B,YAAY,CAAC,IAAI,GAAG,gBAAgB,CAAC;AAErC,eAAe,YAAY,CAAC"}
|
package/esm/form/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { type ConfirmationPanelProps, default as ConfirmationPanel, } from "./ConfirmationPanel";
|
|
3
|
-
export { ErrorSummary, type ErrorSummaryProps } from "./error-summary";
|
|
1
|
+
export { default as ConfirmationPanel, type ConfirmationPanelProps, } from "./ConfirmationPanel";
|
|
4
2
|
export { Fieldset, FieldsetContext, type FieldsetProps } from "./Fieldset";
|
|
5
|
-
export { Radio, RadioGroup, type RadioGroupProps, type RadioProps, } from "./radio";
|
|
6
|
-
export { Search, type SearchClearEvent, type SearchProps } from "./search";
|
|
7
|
-
export { Combobox as UNSAFE_Combobox, type ComboboxProps } from "./combobox";
|
|
8
3
|
export { default as Select, type SelectProps } from "./Select";
|
|
9
4
|
export { default as Switch, type SwitchProps } from "./Switch";
|
|
10
|
-
export { Counter, default as Textarea, type TextareaProps } from "./Textarea";
|
|
11
5
|
export { default as TextField, type TextFieldProps } from "./TextField";
|
|
6
|
+
export { default as Textarea, type TextareaProps } from "./Textarea";
|
|
7
|
+
export { Checkbox, CheckboxGroup, type CheckboxGroupProps, type CheckboxProps, } from "./checkbox";
|
|
8
|
+
export { Combobox as UNSAFE_Combobox, type ComboboxProps } from "./combobox";
|
|
9
|
+
export { ErrorSummary, type ErrorSummaryProps } from "./error-summary";
|
|
10
|
+
export { Radio, RadioGroup, type RadioGroupProps, type RadioProps, } from "./radio";
|
|
11
|
+
export { Search, type SearchClearEvent, type SearchProps } from "./search";
|
package/esm/form/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export { Checkbox, CheckboxGroup, } from "./checkbox";
|
|
2
1
|
export { default as ConfirmationPanel, } from "./ConfirmationPanel";
|
|
3
|
-
export { ErrorSummary } from "./error-summary";
|
|
4
2
|
export { Fieldset, FieldsetContext } from "./Fieldset";
|
|
5
|
-
export { Radio, RadioGroup, } from "./radio";
|
|
6
|
-
export { Search } from "./search";
|
|
7
|
-
export { Combobox as UNSAFE_Combobox } from "./combobox";
|
|
8
3
|
export { default as Select } from "./Select";
|
|
9
4
|
export { default as Switch } from "./Switch";
|
|
10
|
-
export { Counter, default as Textarea } from "./Textarea";
|
|
11
5
|
export { default as TextField } from "./TextField";
|
|
6
|
+
export { default as Textarea } from "./Textarea";
|
|
7
|
+
export { Checkbox, CheckboxGroup, } from "./checkbox";
|
|
8
|
+
export { Combobox as UNSAFE_Combobox } from "./combobox";
|
|
9
|
+
export { ErrorSummary } from "./error-summary";
|
|
10
|
+
export { Radio, RadioGroup, } from "./radio";
|
|
11
|
+
export { Search } from "./search";
|
|
12
12
|
//# sourceMappingURL=index.js.map
|
package/esm/form/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/form/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/form/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,IAAI,iBAAiB,GAE7B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAsB,MAAM,YAAY,CAAC;AAC3E,OAAO,EAAE,OAAO,IAAI,MAAM,EAAoB,MAAM,UAAU,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,MAAM,EAAoB,MAAM,UAAU,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,SAAS,EAAuB,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAsB,MAAM,YAAY,CAAC;AACrE,OAAO,EACL,QAAQ,EACR,aAAa,GAGd,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,QAAQ,IAAI,eAAe,EAAsB,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,YAAY,EAA0B,MAAM,iBAAiB,CAAC;AACvE,OAAO,EACL,KAAK,EACL,UAAU,GAGX,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,MAAM,EAA2C,MAAM,UAAU,CAAC"}
|
|
@@ -1,7 +1,24 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* This interface represents a component that can be overridden with different props and elements.
|
|
4
|
+
* @template Component The type of the props for the component.
|
|
5
|
+
* @template Element The type of the HTML element that the component renders.
|
|
6
|
+
*/
|
|
2
7
|
export interface OverridableComponent<Component, Element extends HTMLElement> {
|
|
8
|
+
/**
|
|
9
|
+
* This is a function type that takes props and returns a React functional component.
|
|
10
|
+
* @param props The props for the component, which are a combination of the Component type and React.RefAttributes for the Element type.
|
|
11
|
+
* @returns A React functional component.
|
|
12
|
+
*/
|
|
3
13
|
(props: Component & React.RefAttributes<Element>): ReturnType<React.FC>;
|
|
14
|
+
/**
|
|
15
|
+
* This is a function type that takes props and returns a React functional component.
|
|
16
|
+
* It allows for the 'as' prop to override the type of element that the component renders.
|
|
17
|
+
* @template As The type of the element that the component should render as.
|
|
18
|
+
* @param props The props for the component, which are a combination of the Component type, the 'as' prop, and any other props that are not part of the Component type or the 'as' prop.
|
|
19
|
+
* @returns A React functional component.
|
|
20
|
+
*/
|
|
4
21
|
<As extends React.ElementType>(props: {
|
|
5
|
-
as
|
|
22
|
+
as?: As;
|
|
6
23
|
} & Component & Omit<React.ComponentPropsWithRef<As>, keyof Component | "as">): ReturnType<React.FC>;
|
|
7
24
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navikt/ds-react",
|
|
3
|
-
"version": "5.10.
|
|
3
|
+
"version": "5.10.3",
|
|
4
4
|
"description": "Aksel react-components for NAV designsystem",
|
|
5
5
|
"author": "Aksel | NAV designsystem team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@floating-ui/react": "0.25.4",
|
|
41
|
-
"@navikt/aksel-icons": "^5.10.
|
|
42
|
-
"@navikt/ds-tokens": "^5.10.
|
|
41
|
+
"@navikt/aksel-icons": "^5.10.3",
|
|
42
|
+
"@navikt/ds-tokens": "^5.10.3",
|
|
43
43
|
"@radix-ui/react-tabs": "1.0.0",
|
|
44
44
|
"@radix-ui/react-toggle-group": "1.0.0",
|
|
45
45
|
"clsx": "^1.2.1",
|
package/src/form/Textarea.tsx
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
2
|
import React, { forwardRef, useState } from "react";
|
|
3
3
|
import { BodyShort, ErrorMessage, Label } from "../typography";
|
|
4
|
+
import { omit, useId } from "../util";
|
|
4
5
|
import TextareaAutosize from "../util/TextareaAutoSize";
|
|
5
|
-
import { FormFieldProps, useFormField } from "./useFormField";
|
|
6
6
|
import { ReadOnlyIcon } from "./ReadOnlyIcon";
|
|
7
|
-
import
|
|
7
|
+
import Counter from "./TextareaCounter";
|
|
8
|
+
import { FormFieldProps, useFormField } from "./useFormField";
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* TODO: Mulighet for lokalisering av sr-only/counter text
|
|
@@ -27,7 +28,6 @@ export interface TextareaProps
|
|
|
27
28
|
defaultValue?: string;
|
|
28
29
|
/**
|
|
29
30
|
* Maximum number of character rows to display.
|
|
30
|
-
* @bug Internal scrolling with `maxLength` scrolls over maxLength-text
|
|
31
31
|
*/
|
|
32
32
|
maxRows?: number;
|
|
33
33
|
/**
|
|
@@ -50,7 +50,7 @@ export interface TextareaProps
|
|
|
50
50
|
* i18n-translations for counter-text
|
|
51
51
|
*/
|
|
52
52
|
i18n?: {
|
|
53
|
-
/** @default
|
|
53
|
+
/** @default tegn igjen */
|
|
54
54
|
counterLeft?: string;
|
|
55
55
|
/** @default tegn for mye */
|
|
56
56
|
counterTooMuch?: string;
|
|
@@ -162,14 +162,11 @@ export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
|
162
162
|
className={cl(
|
|
163
163
|
"navds-textarea__input",
|
|
164
164
|
"navds-body-short",
|
|
165
|
-
`navds-body-short--${size ?? "medium"}
|
|
166
|
-
{
|
|
167
|
-
"navds-textarea--counter": hasMaxLength,
|
|
168
|
-
}
|
|
165
|
+
`navds-body-short--${size ?? "medium"}`
|
|
169
166
|
)}
|
|
170
167
|
{...(describedBy ? { "aria-describedby": describedBy } : {})}
|
|
171
168
|
/>
|
|
172
|
-
{hasMaxLength && (
|
|
169
|
+
{hasMaxLength && !readOnly && !inputProps.disabled && (
|
|
173
170
|
<>
|
|
174
171
|
<span id={maxLengthId} className="navds-sr-only">
|
|
175
172
|
{`Tekstområde med plass til ${maxLength} tegn.`}
|
|
@@ -198,22 +195,4 @@ export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
|
198
195
|
}
|
|
199
196
|
);
|
|
200
197
|
|
|
201
|
-
export const Counter = ({ maxLength, currentLength, size, i18n }) => {
|
|
202
|
-
const difference = maxLength - currentLength;
|
|
203
|
-
|
|
204
|
-
return (
|
|
205
|
-
<BodyShort
|
|
206
|
-
className={cl("navds-textarea__counter", {
|
|
207
|
-
"navds-textarea__counter--error": difference < 0,
|
|
208
|
-
})}
|
|
209
|
-
aria-live={difference < 20 ? "polite" : "off"}
|
|
210
|
-
size={size}
|
|
211
|
-
>
|
|
212
|
-
{difference < 0
|
|
213
|
-
? `${Math.abs(difference)} ${i18n?.counterTooMuch ?? "tegn for mye"}`
|
|
214
|
-
: `${difference} ${i18n?.counterLeft ?? "tegn igjen"}`}
|
|
215
|
-
</BodyShort>
|
|
216
|
-
);
|
|
217
|
-
};
|
|
218
|
-
|
|
219
198
|
export default Textarea;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import cl from "clsx";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { BodyShort } from "../typography";
|
|
4
|
+
import type { TextareaProps } from "./Textarea";
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
maxLength: number;
|
|
8
|
+
currentLength: number;
|
|
9
|
+
size: TextareaProps["size"];
|
|
10
|
+
i18n: TextareaProps["i18n"];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const TextareaCounter = ({ maxLength, currentLength, size, i18n }: Props) => {
|
|
14
|
+
const difference = maxLength - currentLength;
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<BodyShort
|
|
18
|
+
className={cl("navds-textarea__counter", {
|
|
19
|
+
"navds-textarea__counter--error": difference < 0,
|
|
20
|
+
})}
|
|
21
|
+
role={difference < 20 ? "status" : undefined}
|
|
22
|
+
size={size}
|
|
23
|
+
>
|
|
24
|
+
{difference < 0
|
|
25
|
+
? `${Math.abs(difference)} ${i18n?.counterTooMuch ?? "tegn for mye"}`
|
|
26
|
+
: `${difference} ${i18n?.counterLeft ?? "tegn igjen"}`}
|
|
27
|
+
</BodyShort>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default TextareaCounter;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { forwardRef, HTMLAttributes } from "react";
|
|
1
|
+
import React, { forwardRef, HTMLAttributes, isValidElement } from "react";
|
|
2
2
|
import cl from "clsx";
|
|
3
3
|
import { Heading, BodyShort } from "../../typography";
|
|
4
4
|
import ErrorSummaryItem, { ErrorSummaryItemType } from "./ErrorSummaryItem";
|
|
@@ -100,7 +100,10 @@ export const ErrorSummary = forwardRef<HTMLDivElement, ErrorSummaryProps>(
|
|
|
100
100
|
</Heading>
|
|
101
101
|
<BodyShort as="ul" size={size} className="navds-error-summary__list">
|
|
102
102
|
{React.Children.map(children, (child) => {
|
|
103
|
-
|
|
103
|
+
if (!isValidElement(child)) {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
return <li key={child.toString()}>{child}</li>;
|
|
104
107
|
})}
|
|
105
108
|
</BodyShort>
|
|
106
109
|
</section>
|
package/src/form/index.ts
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
|
+
export {
|
|
2
|
+
default as ConfirmationPanel,
|
|
3
|
+
type ConfirmationPanelProps,
|
|
4
|
+
} from "./ConfirmationPanel";
|
|
5
|
+
export { Fieldset, FieldsetContext, type FieldsetProps } from "./Fieldset";
|
|
6
|
+
export { default as Select, type SelectProps } from "./Select";
|
|
7
|
+
export { default as Switch, type SwitchProps } from "./Switch";
|
|
8
|
+
export { default as TextField, type TextFieldProps } from "./TextField";
|
|
9
|
+
export { default as Textarea, type TextareaProps } from "./Textarea";
|
|
1
10
|
export {
|
|
2
11
|
Checkbox,
|
|
3
12
|
CheckboxGroup,
|
|
4
13
|
type CheckboxGroupProps,
|
|
5
14
|
type CheckboxProps,
|
|
6
15
|
} from "./checkbox";
|
|
7
|
-
export {
|
|
8
|
-
type ConfirmationPanelProps,
|
|
9
|
-
default as ConfirmationPanel,
|
|
10
|
-
} from "./ConfirmationPanel";
|
|
16
|
+
export { Combobox as UNSAFE_Combobox, type ComboboxProps } from "./combobox";
|
|
11
17
|
export { ErrorSummary, type ErrorSummaryProps } from "./error-summary";
|
|
12
|
-
export { Fieldset, FieldsetContext, type FieldsetProps } from "./Fieldset";
|
|
13
18
|
export {
|
|
14
19
|
Radio,
|
|
15
20
|
RadioGroup,
|
|
@@ -17,8 +22,3 @@ export {
|
|
|
17
22
|
type RadioProps,
|
|
18
23
|
} from "./radio";
|
|
19
24
|
export { Search, type SearchClearEvent, type SearchProps } from "./search";
|
|
20
|
-
export { Combobox as UNSAFE_Combobox, type ComboboxProps } from "./combobox";
|
|
21
|
-
export { default as Select, type SelectProps } from "./Select";
|
|
22
|
-
export { default as Switch, type SwitchProps } from "./Switch";
|
|
23
|
-
export { Counter, default as Textarea, type TextareaProps } from "./Textarea";
|
|
24
|
-
export { default as TextField, type TextFieldProps } from "./TextField";
|
|
@@ -14,7 +14,7 @@ export const Default: StoryObj<typeof Textarea> = {
|
|
|
14
14
|
},
|
|
15
15
|
|
|
16
16
|
args: {
|
|
17
|
-
maxLength:
|
|
17
|
+
maxLength: 0,
|
|
18
18
|
label: "Ipsum enim quis culpa",
|
|
19
19
|
resize: false,
|
|
20
20
|
},
|
|
@@ -28,6 +28,7 @@ export const Default: StoryObj<typeof Textarea> = {
|
|
|
28
28
|
error: { type: "string" },
|
|
29
29
|
hideLabel: { type: "boolean" },
|
|
30
30
|
disabled: { type: "boolean" },
|
|
31
|
+
readOnly: { type: "boolean" },
|
|
31
32
|
maxRows: { type: "number" },
|
|
32
33
|
minRows: { type: "number" },
|
|
33
34
|
},
|
|
@@ -66,6 +67,20 @@ export const Error = () => {
|
|
|
66
67
|
error="Consectetur labore velit eiusmod Lorem ut nostrud mollit labore ullamco laboris laboris in."
|
|
67
68
|
size="small"
|
|
68
69
|
/>
|
|
70
|
+
|
|
71
|
+
<Textarea
|
|
72
|
+
label="Ipsum enim quis culpa"
|
|
73
|
+
error="Consectetur labore velit eiusmod Lorem ut nostrud mollit labore ullamco laboris laboris in."
|
|
74
|
+
maxLength={20}
|
|
75
|
+
/>
|
|
76
|
+
|
|
77
|
+
<Textarea
|
|
78
|
+
label="Ipsum enim quis culpa"
|
|
79
|
+
error="Consectetur labore velit eiusmod Lorem ut nostrud mollit labore ullamco laboris laboris in."
|
|
80
|
+
value="Sed dignissim sollicitudin porta."
|
|
81
|
+
maxLength={20}
|
|
82
|
+
size="small"
|
|
83
|
+
/>
|
|
69
84
|
</div>
|
|
70
85
|
);
|
|
71
86
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React from "react";
|
|
2
1
|
import type { Meta } from "@storybook/react";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { Box, HStack, VStack } from "../..";
|
|
3
4
|
import { BodyLong } from "../../typography";
|
|
4
5
|
import { Bleed } from "./Bleed";
|
|
5
|
-
import { Box, HStack, VStack } from "../..";
|
|
6
6
|
|
|
7
7
|
export default {
|
|
8
8
|
title: "ds-react/Primitives/Bleed",
|
|
@@ -1,11 +1,28 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* This interface represents a component that can be overridden with different props and elements.
|
|
5
|
+
* @template Component The type of the props for the component.
|
|
6
|
+
* @template Element The type of the HTML element that the component renders.
|
|
7
|
+
*/
|
|
3
8
|
export interface OverridableComponent<Component, Element extends HTMLElement> {
|
|
9
|
+
/**
|
|
10
|
+
* This is a function type that takes props and returns a React functional component.
|
|
11
|
+
* @param props The props for the component, which are a combination of the Component type and React.RefAttributes for the Element type.
|
|
12
|
+
* @returns A React functional component.
|
|
13
|
+
*/
|
|
4
14
|
(props: Component & React.RefAttributes<Element>): ReturnType<React.FC>;
|
|
5
15
|
|
|
16
|
+
/**
|
|
17
|
+
* This is a function type that takes props and returns a React functional component.
|
|
18
|
+
* It allows for the 'as' prop to override the type of element that the component renders.
|
|
19
|
+
* @template As The type of the element that the component should render as.
|
|
20
|
+
* @param props The props for the component, which are a combination of the Component type, the 'as' prop, and any other props that are not part of the Component type or the 'as' prop.
|
|
21
|
+
* @returns A React functional component.
|
|
22
|
+
*/
|
|
6
23
|
<As extends React.ElementType>(
|
|
7
24
|
props: {
|
|
8
|
-
as
|
|
25
|
+
as?: As;
|
|
9
26
|
} & Component &
|
|
10
27
|
Omit<React.ComponentPropsWithRef<As>, keyof Component | "as">
|
|
11
28
|
): ReturnType<React.FC>;
|