@navikt/ds-react 0.19.8 → 0.19.9

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
@@ -1723,6 +1723,25 @@
1723
1723
  "name": "boolean"
1724
1724
  }
1725
1725
  },
1726
+ "resize": {
1727
+ "defaultValue": null,
1728
+ "description": "Enables resizing of field",
1729
+ "name": "resize",
1730
+ "parent": {
1731
+ "fileName": "src/form/Textarea.tsx",
1732
+ "name": "TextareaProps"
1733
+ },
1734
+ "declarations": [
1735
+ {
1736
+ "fileName": "src/form/Textarea.tsx",
1737
+ "name": "TextareaProps"
1738
+ }
1739
+ ],
1740
+ "required": false,
1741
+ "type": {
1742
+ "name": "boolean"
1743
+ }
1744
+ },
1726
1745
  "error": {
1727
1746
  "defaultValue": null,
1728
1747
  "description": "Error message for element",
@@ -47,13 +47,21 @@ const __2 = require("..");
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 } = props, rest = __rest(props, ["label", "className", "description", "maxLength", "hideLabel"]);
50
+ const { label, className, description, maxLength, hideLabel = false, resize } = props, rest = __rest(props, ["label", "className", "description", "maxLength", "hideLabel", "resize"]);
51
51
  const maxLengthId = `TextareaMaxLength-${(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 : "");
54
+ const getMinRows = () => {
55
+ let rows = (rest === null || rest === void 0 ? void 0 : rest.minRows) && (rest === null || rest === void 0 ? void 0 : rest.minRows) >= 3 ? rest === null || rest === void 0 ? void 0 : rest.minRows : 3;
56
+ if (size === "small") {
57
+ rows = (rest === null || rest === void 0 ? void 0 : rest.minRows) && (rest === null || rest === void 0 ? void 0 : rest.minRows) >= 2 ? rest === null || rest === void 0 ? void 0 : rest.minRows : 2;
58
+ }
59
+ return rows;
60
+ };
54
61
  return (react_1.default.createElement("div", { className: (0, classnames_1.default)(className, "navds-form-field", `navds-form-field--${size}`, {
55
62
  "navds-textarea--error": hasError,
56
63
  "navds-textarea--disabled": !!inputProps.disabled,
64
+ "navds-textarea--resize": resize,
57
65
  }) },
58
66
  react_1.default.createElement(__1.Label, { htmlFor: inputProps.id, size: size, as: "label", className: (0, classnames_1.default)("navds-textarea__label", {
59
67
  "navds-sr-only": hideLabel,
@@ -64,7 +72,7 @@ exports.Textarea = (0, react_1.forwardRef)((props, ref) => {
64
72
  react_1.default.createElement("div", { className: "navds-textarea__wrapper" },
65
73
  react_1.default.createElement(TextareaAutosize_1.default, Object.assign({}, (0, __1.omit)(rest, ["error", "errorId", "size"]), inputProps, { onChange: (e) => props.onChange
66
74
  ? props.onChange(e)
67
- : setControlledValue(e.target.value), ref: ref, className: (0, classnames_1.default)("navds-textarea__input", "navds-body-short", `navds-body-${size !== null && size !== void 0 ? size : "medium"}`, {
75
+ : setControlledValue(e.target.value), minRows: getMinRows(), ref: ref, className: (0, classnames_1.default)("navds-textarea__input", "navds-body-short", `navds-body-${size !== null && size !== void 0 ? size : "medium"}`, {
68
76
  "navds-textarea--counter": hasMaxLength,
69
77
  }), "aria-describedby": (0, classnames_1.default)(inputProps["aria-describedby"], {
70
78
  [maxLengthId]: hasMaxLength,
@@ -85,8 +93,8 @@ const Counter = ({ maxLength, currentLength, size }) => {
85
93
  return (react_1.default.createElement(__1.BodyShort, { className: (0, classnames_1.default)("navds-textarea__counter", {
86
94
  "navds-textarea__counter--error": difference < 0,
87
95
  }), "aria-live": difference < 20 ? "polite" : "off", size: size }, difference < 0
88
- ? `Du har ${Math.abs(difference)} tegn for mye`
89
- : `Du har ${difference} tegn igjen`));
96
+ ? `Antall tegn for mye ${Math.abs(difference)}`
97
+ : `Antall tegn igjen ${difference}`));
90
98
  };
91
99
  exports.Counter = Counter;
92
100
  exports.default = exports.Textarea;
@@ -34,6 +34,10 @@ export interface TextareaProps extends FormFieldProps, React.TextareaHTMLAttribu
34
34
  * If enabled shows the label and description for screenreaders only
35
35
  */
36
36
  hideLabel?: boolean;
37
+ /**
38
+ * Enables resizing of field
39
+ */
40
+ resize?: boolean;
37
41
  }
38
42
  export declare const Textarea: React.ForwardRefExoticComponent<TextareaProps & React.RefAttributes<HTMLTextAreaElement>>;
39
43
  export declare const Counter: ({ maxLength, currentLength, size }: {
@@ -18,13 +18,21 @@ import { useId } from "..";
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 } = props, rest = __rest(props, ["label", "className", "description", "maxLength", "hideLabel"]);
21
+ const { label, className, description, maxLength, hideLabel = false, resize } = props, rest = __rest(props, ["label", "className", "description", "maxLength", "hideLabel", "resize"]);
22
22
  const maxLengthId = `TextareaMaxLength-${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 : "");
25
+ const getMinRows = () => {
26
+ let rows = (rest === null || rest === void 0 ? void 0 : rest.minRows) && (rest === null || rest === void 0 ? void 0 : rest.minRows) >= 3 ? rest === null || rest === void 0 ? void 0 : rest.minRows : 3;
27
+ if (size === "small") {
28
+ rows = (rest === null || rest === void 0 ? void 0 : rest.minRows) && (rest === null || rest === void 0 ? void 0 : rest.minRows) >= 2 ? rest === null || rest === void 0 ? void 0 : rest.minRows : 2;
29
+ }
30
+ return rows;
31
+ };
25
32
  return (React.createElement("div", { className: cl(className, "navds-form-field", `navds-form-field--${size}`, {
26
33
  "navds-textarea--error": hasError,
27
34
  "navds-textarea--disabled": !!inputProps.disabled,
35
+ "navds-textarea--resize": resize,
28
36
  }) },
29
37
  React.createElement(Label, { htmlFor: inputProps.id, size: size, as: "label", className: cl("navds-textarea__label", {
30
38
  "navds-sr-only": hideLabel,
@@ -35,7 +43,7 @@ export const Textarea = forwardRef((props, ref) => {
35
43
  React.createElement("div", { className: "navds-textarea__wrapper" },
36
44
  React.createElement(TextareaAutosize, Object.assign({}, omit(rest, ["error", "errorId", "size"]), inputProps, { onChange: (e) => props.onChange
37
45
  ? props.onChange(e)
38
- : setControlledValue(e.target.value), ref: ref, className: cl("navds-textarea__input", "navds-body-short", `navds-body-${size !== null && size !== void 0 ? size : "medium"}`, {
46
+ : setControlledValue(e.target.value), minRows: getMinRows(), ref: ref, className: cl("navds-textarea__input", "navds-body-short", `navds-body-${size !== null && size !== void 0 ? size : "medium"}`, {
39
47
  "navds-textarea--counter": hasMaxLength,
40
48
  }), "aria-describedby": cl(inputProps["aria-describedby"], {
41
49
  [maxLengthId]: hasMaxLength,
@@ -56,8 +64,8 @@ export const Counter = ({ maxLength, currentLength, size }) => {
56
64
  return (React.createElement(BodyShort, { className: cl("navds-textarea__counter", {
57
65
  "navds-textarea__counter--error": difference < 0,
58
66
  }), "aria-live": difference < 20 ? "polite" : "off", size: size }, difference < 0
59
- ? `Du har ${Math.abs(difference)} tegn for mye`
60
- : `Du har ${difference} tegn igjen`));
67
+ ? `Antall tegn for mye ${Math.abs(difference)}`
68
+ : `Antall tegn igjen ${difference}`));
61
69
  };
62
70
  export default Textarea;
63
71
  //# sourceMappingURL=Textarea.js.map
@@ -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,YAAY,CAAC;AAC5B,OAAO,gBAAgB,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,SAA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;oBACnB,SAAS;;oBAA2B,GAAG;oBACjE,SAAS;8BACL;gBACP,oBAAC,OAAO,IACN,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,MAAA,MAAA,KAAK,CAAC,KAAK,0CAAE,MAAM,mCAAI,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,MAAM,EAC7D,IAAI,EAAE,IAAI,GACV,CACD,CACJ,CACG;QACN,6BAAK,EAAE,EAAE,OAAO,mBAAgB,oBAAoB,eAAW,QAAQ,IACpE,YAAY,IAAI,CACf,oBAAC,YAAY,IAAC,IAAI,EAAE,IAAI,IAAG,KAAK,CAAC,KAAK,CAAgB,CACvD,CACG,CACF,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,EAAE,SAAS,EAAE,aAAa,EAAE,IAAI,EAAE,EAAE,EAAE;IAC5D,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,eACS,UAAU,GAAG,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,EAC7C,IAAI,EAAE,IAAI,IAET,UAAU,GAAG,CAAC;QACb,CAAC,CAAC,uBAAuB,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;QAC/C,CAAC,CAAC,qBAAqB,UAAU,EAAE,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.19.8",
3
+ "version": "0.19.9",
4
4
  "description": "NAV designsystem react components",
5
5
  "author": "NAV Designsystem team",
6
6
  "license": "MIT",
@@ -76,5 +76,5 @@
76
76
  "@types/react": "^17.0.30 || ^18.0.0",
77
77
  "react": "^17.0.0 || ^18.0.0"
78
78
  },
79
- "gitHead": "adfdfceef32a159b51ee7499449468f5044b0961"
79
+ "gitHead": "e586812ddffa50fc5aad663c30121ba09ae2ffef"
80
80
  }
@@ -41,6 +41,10 @@ export interface TextareaProps
41
41
  * If enabled shows the label and description for screenreaders only
42
42
  */
43
43
  hideLabel?: boolean;
44
+ /**
45
+ * Enables resizing of field
46
+ */
47
+ resize?: boolean;
44
48
  }
45
49
 
46
50
  export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
@@ -60,6 +64,7 @@ export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
60
64
  description,
61
65
  maxLength,
62
66
  hideLabel = false,
67
+ resize,
63
68
  ...rest
64
69
  } = props;
65
70
 
@@ -70,6 +75,14 @@ export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
70
75
  props?.defaultValue ?? ""
71
76
  );
72
77
 
78
+ const getMinRows = () => {
79
+ let rows = rest?.minRows && rest?.minRows >= 3 ? rest?.minRows : 3;
80
+ if (size === "small") {
81
+ rows = rest?.minRows && rest?.minRows >= 2 ? rest?.minRows : 2;
82
+ }
83
+ return rows;
84
+ };
85
+
73
86
  return (
74
87
  <div
75
88
  className={cl(
@@ -79,6 +92,7 @@ export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
79
92
  {
80
93
  "navds-textarea--error": hasError,
81
94
  "navds-textarea--disabled": !!inputProps.disabled,
95
+ "navds-textarea--resize": resize,
82
96
  }
83
97
  )}
84
98
  >
@@ -113,6 +127,7 @@ export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
113
127
  ? props.onChange(e)
114
128
  : setControlledValue(e.target.value)
115
129
  }
130
+ minRows={getMinRows()}
116
131
  ref={ref}
117
132
  className={cl(
118
133
  "navds-textarea__input",
@@ -162,8 +177,8 @@ export const Counter = ({ maxLength, currentLength, size }) => {
162
177
  size={size}
163
178
  >
164
179
  {difference < 0
165
- ? `Du har ${Math.abs(difference)} tegn for mye`
166
- : `Du har ${difference} tegn igjen`}
180
+ ? `Antall tegn for mye ${Math.abs(difference)}`
181
+ : `Antall tegn igjen ${difference}`}
167
182
  </BodyShort>
168
183
  );
169
184
  };
@@ -23,6 +23,12 @@ export default {
23
23
  disabled: {
24
24
  type: "boolean",
25
25
  },
26
+ maxRows: {
27
+ type: "number",
28
+ },
29
+ minRows: {
30
+ type: "number",
31
+ },
26
32
  },
27
33
  } as Meta;
28
34
 
@@ -109,3 +115,7 @@ export const MaxRows = () => {
109
115
  />
110
116
  );
111
117
  };
118
+
119
+ export const Resize = () => {
120
+ return <Textarea resize label="Ipsum enim quis culpa" />;
121
+ };