@navikt/ds-react 5.10.3 → 5.11.0

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
@@ -3507,6 +3507,25 @@
3507
3507
  }
3508
3508
  ],
3509
3509
  "required": false,
3510
+ "type": {
3511
+ "name": "boolean | \"vertical\" | \"horizontal\""
3512
+ }
3513
+ },
3514
+ "UNSAFE_autoScrollbar": {
3515
+ "defaultValue": null,
3516
+ "description": "Textarea will stop growing and get a scrollbar when there's no more room to grow.\nRequires `display:flex` on the parent.\nExperimental feature that may be removed or get breaking changes in a minor version.",
3517
+ "name": "UNSAFE_autoScrollbar",
3518
+ "parent": {
3519
+ "fileName": "src/form/Textarea.tsx",
3520
+ "name": "TextareaProps"
3521
+ },
3522
+ "declarations": [
3523
+ {
3524
+ "fileName": "src/form/Textarea.tsx",
3525
+ "name": "TextareaProps"
3526
+ }
3527
+ ],
3528
+ "required": false,
3510
3529
  "type": {
3511
3530
  "name": "boolean"
3512
3531
  }
@@ -4596,7 +4615,7 @@
4596
4615
  "defaultValue": {
4597
4616
  "value": "true"
4598
4617
  },
4599
- "description": "Inverts when the underline appears. If this is false,\nthe underline does not appear by default, but does appear when the link is hovered.\nThis makes it more suitable for use when inlined in text.",
4618
+ "description": "Inverts when the underline appears. If this is false,\nthe underline only appears on hover.\n\n**NB: Underline can only be removed in menus etc. where it's obvious that it's a link.**",
4600
4619
  "name": "underline",
4601
4620
  "parent": {
4602
4621
  "fileName": "src/link/Link.tsx",
@@ -10411,6 +10430,25 @@
10411
10430
  "name": "number"
10412
10431
  }
10413
10432
  },
10433
+ "autoScrollbar": {
10434
+ "defaultValue": null,
10435
+ "description": "If true, textarea will never get `overflow:hidden`",
10436
+ "name": "autoScrollbar",
10437
+ "parent": {
10438
+ "fileName": "src/util/TextareaAutoSize.tsx",
10439
+ "name": "TextareaAutosizeProps"
10440
+ },
10441
+ "declarations": [
10442
+ {
10443
+ "fileName": "src/util/TextareaAutoSize.tsx",
10444
+ "name": "TextareaAutosizeProps"
10445
+ }
10446
+ ],
10447
+ "required": false,
10448
+ "type": {
10449
+ "name": "boolean"
10450
+ }
10451
+ },
10414
10452
  "className": {
10415
10453
  "defaultValue": null,
10416
10454
  "description": "",
@@ -77,6 +77,6 @@ exports.Alert = (0, react_1.forwardRef)((_a, ref) => {
77
77
  react_1.default.createElement(Icon, { variant: variant, className: "navds-alert__icon" }),
78
78
  react_1.default.createElement(typography_1.BodyLong, { as: "div", size: size, className: "navds-alert__wrapper" }, children),
79
79
  closeButton && !inline && (react_1.default.createElement("div", { className: "navds-alert__button-wrapper" },
80
- react_1.default.createElement(button_1.Button, { className: "navds-alert__button", size: "small", variant: "tertiary-neutral", onClick: onClose, icon: react_1.default.createElement(aksel_icons_1.XMarkIcon, { title: "Lukk Alert" }) })))));
80
+ react_1.default.createElement(button_1.Button, { className: "navds-alert__button", size: "small", variant: "tertiary-neutral", onClick: onClose, type: "button", icon: react_1.default.createElement(aksel_icons_1.XMarkIcon, { title: "Lukk Alert" }) })))));
81
81
  });
82
82
  exports.default = exports.Alert;
@@ -60,7 +60,7 @@ const useFormField_1 = require("./useFormField");
60
60
  exports.Textarea = (0, react_1.forwardRef)((props, ref) => {
61
61
  var _a, _b, _c;
62
62
  const { inputProps, errorId, showErrorMsg, hasError, size, inputDescriptionId, } = (0, useFormField_1.useFormField)(props, "textarea");
63
- const { label, className, description, maxLength, hideLabel = false, resize, i18n, readOnly } = props, rest = __rest(props, ["label", "className", "description", "maxLength", "hideLabel", "resize", "i18n", "readOnly"]);
63
+ const { label, className, description, maxLength, hideLabel = false, resize, UNSAFE_autoScrollbar, i18n, readOnly } = props, rest = __rest(props, ["label", "className", "description", "maxLength", "hideLabel", "resize", "UNSAFE_autoScrollbar", "i18n", "readOnly"]);
64
64
  const maxLengthId = (0, util_1.useId)();
65
65
  const hasMaxLength = maxLength !== undefined && maxLength > 0;
66
66
  const [controlledValue, setControlledValue] = (0, react_1.useState)((_a = props === null || props === void 0 ? void 0 : props.defaultValue) !== null && _a !== void 0 ? _a : "");
@@ -79,7 +79,8 @@ exports.Textarea = (0, react_1.forwardRef)((props, ref) => {
79
79
  "navds-form-field--readonly": readOnly,
80
80
  "navds-textarea--readonly": readOnly,
81
81
  "navds-textarea--error": hasError,
82
- "navds-textarea--resize": resize,
82
+ "navds-textarea--autoscrollbar": UNSAFE_autoScrollbar,
83
+ [`navds-textarea--resize-${resize === true ? "both" : resize}`]: resize,
83
84
  }) },
84
85
  react_1.default.createElement(typography_1.Label, { htmlFor: inputProps.id, size: size, className: (0, clsx_1.default)("navds-form-field__label", {
85
86
  "navds-sr-only": hideLabel,
@@ -92,7 +93,7 @@ exports.Textarea = (0, react_1.forwardRef)((props, ref) => {
92
93
  react_1.default.createElement("div", { className: "navds-textarea__wrapper" },
93
94
  react_1.default.createElement(TextareaAutoSize_1.default, Object.assign({}, (0, util_1.omit)(rest, ["error", "errorId", "size"]), inputProps, { onChange: (e) => props.onChange
94
95
  ? props.onChange(e)
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
+ : setControlledValue(e.target.value), minRows: getMinRows(), autoScrollbar: UNSAFE_autoScrollbar, 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
97
  hasMaxLength && !readOnly && !inputProps.disabled && (react_1.default.createElement(react_1.default.Fragment, null,
97
98
  react_1.default.createElement("span", { id: maxLengthId, className: "navds-sr-only" }, `Tekstområde med plass til ${maxLength} tegn.`),
98
99
  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 })))),
@@ -1,18 +1,57 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
5
28
  Object.defineProperty(exports, "__esModule", { value: true });
6
29
  const clsx_1 = __importDefault(require("clsx"));
7
- const react_1 = __importDefault(require("react"));
30
+ const react_1 = __importStar(require("react"));
8
31
  const typography_1 = require("../typography");
32
+ const debounce_1 = __importDefault(require("../util/debounce"));
9
33
  const TextareaCounter = ({ maxLength, currentLength, size, i18n }) => {
10
- var _a, _b;
11
34
  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
35
+ const [debouncedDiff, setDebouncedDiff] = (0, react_1.useState)(difference);
36
+ (0, react_1.useEffect)(() => {
37
+ const debounceFunc = (0, debounce_1.default)(() => {
38
+ setDebouncedDiff(difference);
39
+ }, 2000);
40
+ debounceFunc();
41
+ return () => {
42
+ debounceFunc.clear();
43
+ };
44
+ }, [difference]);
45
+ return (react_1.default.createElement(react_1.default.Fragment, null,
46
+ difference < 20 && (react_1.default.createElement("span", { role: "status", className: "navds-textarea__sr-counter navds-sr-only" }, getCounterText(debouncedDiff, i18n))),
47
+ react_1.default.createElement(typography_1.BodyShort, { className: (0, clsx_1.default)("navds-textarea__counter", {
48
+ "navds-textarea__counter--error": difference < 0,
49
+ }), size: size }, getCounterText(difference, i18n))));
50
+ };
51
+ const getCounterText = (difference, i18n) => {
52
+ var _a, _b;
53
+ return difference < 0
15
54
  ? `${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"}`));
55
+ : `${difference} ${(_b = i18n === null || i18n === void 0 ? void 0 : i18n.counterLeft) !== null && _b !== void 0 ? _b : "tegn igjen"}`;
17
56
  };
18
57
  exports.default = TextareaCounter;
package/cjs/link/Link.js CHANGED
@@ -38,8 +38,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
38
38
  };
39
39
  Object.defineProperty(exports, "__esModule", { value: true });
40
40
  exports.Link = void 0;
41
- const react_1 = __importStar(require("react"));
42
41
  const clsx_1 = __importDefault(require("clsx"));
42
+ const react_1 = __importStar(require("react"));
43
43
  /**
44
44
  * A component that displays a hyperlink.
45
45
  *
@@ -37,53 +37,75 @@ 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
- /* https://github.com/mui/material-ui/blob/master/packages/mui-base/src/TextareaAutosize/TextareaAutosize.js */
40
+ /* https://github.com/mui/material-ui/blob/master/packages/mui-base/src/TextareaAutosize/TextareaAutosize.tsx */
41
41
  const react_1 = __importStar(require("react"));
42
42
  const react_dom_1 = __importDefault(require("react-dom"));
43
43
  const util_1 = require("../util");
44
+ const updateState = (prevState, newState, renders) => {
45
+ const { outerHeightStyle, overflow } = newState;
46
+ // Need a large enough difference to update the height.
47
+ // This prevents infinite rendering loop.
48
+ if (renders.current < 20 &&
49
+ ((outerHeightStyle > 0 &&
50
+ Math.abs((prevState.outerHeightStyle || 0) - outerHeightStyle) > 1) ||
51
+ prevState.overflow !== overflow)) {
52
+ renders.current += 1;
53
+ return {
54
+ overflow,
55
+ outerHeightStyle,
56
+ };
57
+ }
58
+ if (process.env.NODE_ENV !== "production") {
59
+ if (renders.current === 20) {
60
+ console.error([
61
+ "Textarea: Too many re-renders. The layout is unstable.",
62
+ "TextareaAutosize limits the number of renders to prevent an infinite loop.",
63
+ ].join("\n"));
64
+ }
65
+ }
66
+ return prevState;
67
+ };
44
68
  /**
45
- * https://github.com/mui/material-ui/blob/master/packages/mui-utils/src/ownerDocument.ts
46
- * https://github.com/mui/material-ui/blob/master/packages/mui-utils/src/ownerWindow.ts
69
+ * https://github.com/mui/material-ui/blob/master/packages/mui-utils/src/ownerDocument/ownerDocument.ts
70
+ * https://github.com/mui/material-ui/blob/master/packages/mui-utils/src/ownerWindow/ownerWindow.ts
47
71
  */
48
72
  const ownerWindow = (node) => {
49
73
  const doc = (node && node.ownerDocument) || document;
50
74
  return doc.defaultView || window;
51
75
  };
52
- function getStyleValue(computedStyle, property) {
53
- return parseInt(computedStyle[property], 10) || 0;
76
+ function getStyleValue(value) {
77
+ return parseInt(value, 10) || 0;
54
78
  }
55
79
  const TextareaAutosize = (0, react_1.forwardRef)((_a, ref) => {
56
- var { className, onChange, maxRows, minRows = 1, style, value } = _a, other = __rest(_a, ["className", "onChange", "maxRows", "minRows", "style", "value"]);
80
+ var { className, onChange, maxRows, minRows = 1, autoScrollbar, style, value } = _a, other = __rest(_a, ["className", "onChange", "maxRows", "minRows", "autoScrollbar", "style", "value"]);
57
81
  const { current: isControlled } = (0, react_1.useRef)(value != null);
58
82
  const inputRef = (0, react_1.useRef)(null);
59
83
  const handleRef = (0, react_1.useMemo)(() => (0, util_1.mergeRefs)([inputRef, ref]), [ref]);
60
84
  const shadowRef = (0, react_1.useRef)(null);
61
85
  const renders = (0, react_1.useRef)(0);
62
- const [state, setState] = (0, react_1.useState)({});
86
+ const [state, setState] = (0, react_1.useState)({ outerHeightStyle: 0 });
63
87
  const getUpdatedState = react_1.default.useCallback(() => {
64
- if (!inputRef.current || !shadowRef.current)
65
- return;
66
88
  const input = inputRef.current;
67
89
  const containerWindow = ownerWindow(input);
68
90
  const computedStyle = containerWindow.getComputedStyle(input);
69
91
  // If input's width is shrunk and it's not visible, don't sync height.
70
92
  if (computedStyle.width === "0px") {
71
- return;
93
+ return { outerHeightStyle: 0 };
72
94
  }
73
95
  const inputShallow = shadowRef.current;
74
96
  inputShallow.style.width = computedStyle.width;
75
- inputShallow.value = input.value || (other === null || other === void 0 ? void 0 : other.placeholder) || "x";
97
+ inputShallow.value = input.value || other.placeholder || "x";
76
98
  if (inputShallow.value.slice(-1) === "\n") {
77
99
  // Certain fonts which overflow the line height will cause the textarea
78
100
  // to report a different scrollHeight depending on whether the last line
79
101
  // is empty. Make it non-empty to avoid this issue.
80
102
  inputShallow.value += " ";
81
103
  }
82
- const boxSizing = computedStyle["box-sizing"];
83
- const padding = getStyleValue(computedStyle, "padding-bottom") +
84
- getStyleValue(computedStyle, "padding-top");
85
- const border = getStyleValue(computedStyle, "border-bottom-width") +
86
- getStyleValue(computedStyle, "border-top-width");
104
+ const boxSizing = computedStyle.boxSizing;
105
+ const padding = getStyleValue(computedStyle.paddingBottom) +
106
+ getStyleValue(computedStyle.paddingTop);
107
+ const border = getStyleValue(computedStyle.borderBottomWidth) +
108
+ getStyleValue(computedStyle.borderTopWidth);
87
109
  // The height of the inner content
88
110
  const innerHeight = inputShallow.scrollHeight - padding;
89
111
  // Measure height of a textarea with a single row
@@ -102,77 +124,50 @@ const TextareaAutosize = (0, react_1.forwardRef)((_a, ref) => {
102
124
  const outerHeightStyle = outerHeight + (boxSizing === "border-box" ? padding + border : 0);
103
125
  const overflow = Math.abs(outerHeight - innerHeight) <= 1;
104
126
  return { outerHeightStyle, overflow };
105
- }, [maxRows, minRows, other === null || other === void 0 ? void 0 : other.placeholder]);
127
+ }, [maxRows, minRows, other.placeholder]);
106
128
  const syncHeight = react_1.default.useCallback(() => {
107
129
  const newState = getUpdatedState();
108
130
  if (isEmpty(newState)) {
109
131
  return;
110
132
  }
111
- setState((prevState) => {
112
- return updateState(prevState, newState);
113
- });
133
+ setState((prevState) => updateState(prevState, newState, renders));
114
134
  }, [getUpdatedState]);
115
- const updateState = (prevState, newState) => {
116
- const { outerHeightStyle, overflow } = newState;
117
- // Need a large enough difference to update the height.
118
- // This prevents infinite rendering loop.
119
- if (renders.current < 20 &&
120
- ((outerHeightStyle > 0 &&
121
- Math.abs((prevState.outerHeightStyle || 0) - outerHeightStyle) > 1) ||
122
- prevState.overflow !== overflow)) {
123
- renders.current += 1;
124
- return {
125
- overflow,
126
- outerHeightStyle,
127
- };
128
- }
129
- if (process.env.NODE_ENV !== "production") {
130
- if (renders.current === 20) {
131
- console.error([
132
- "Textarea: Too many re-renders. The layout is unstable.",
133
- "TextareaAutosize limits the number of renders to prevent an infinite loop.",
134
- ].join("\n"));
135
+ (0, util_1.useClientLayoutEffect)(() => {
136
+ const syncHeightWithFlushSync = () => {
137
+ const newState = getUpdatedState();
138
+ if (isEmpty(newState)) {
139
+ return;
135
140
  }
136
- }
137
- return prevState;
138
- };
139
- const withFlushSync = () => {
140
- const newState = getUpdatedState();
141
- if (isEmpty(newState)) {
142
- return;
143
- }
144
- // In React 18, state updates in a ResizeObserver's callback are happening after the paint which causes flickering
145
- // when doing some visual updates in it. Using flushSync ensures that the dom will be painted after the states updates happen
146
- // Related issue - https://github.com/facebook/react/issues/24331
147
- react_dom_1.default.flushSync(() => {
148
- setState((prevState) => {
149
- return updateState(prevState, newState);
141
+ // In React 18, state updates in a ResizeObserver's callback are happening after
142
+ // the paint, this leads to an infinite rendering.
143
+ //
144
+ // Using flushSync ensures that the states is updated before the next pain.
145
+ // Related issue - https://github.com/facebook/react/issues/24331
146
+ react_dom_1.default.flushSync(() => {
147
+ setState((prevState) => updateState(prevState, newState, renders));
150
148
  });
151
- });
152
- };
153
- react_1.default.useEffect(() => {
154
- const handleResize = (0, util_1.debounce)(() => {
149
+ };
150
+ const handleResize = () => {
155
151
  renders.current = 0;
156
- if (inputRef.current) {
157
- withFlushSync();
158
- }
159
- });
160
- let resizeObserver;
152
+ syncHeightWithFlushSync();
153
+ };
154
+ const debounceHandleResize = (0, util_1.debounce)(handleResize);
161
155
  const input = inputRef.current;
162
156
  const containerWindow = ownerWindow(input);
163
- containerWindow.addEventListener("resize", handleResize);
157
+ containerWindow.addEventListener("resize", debounceHandleResize);
158
+ let resizeObserver;
164
159
  if (typeof ResizeObserver !== "undefined") {
165
160
  resizeObserver = new ResizeObserver(handleResize);
166
161
  resizeObserver.observe(input);
167
162
  }
168
163
  return () => {
169
- handleResize.clear();
170
- containerWindow.removeEventListener("resize", handleResize);
164
+ debounceHandleResize.clear();
165
+ containerWindow.removeEventListener("resize", debounceHandleResize);
171
166
  if (resizeObserver) {
172
167
  resizeObserver.disconnect();
173
168
  }
174
169
  };
175
- });
170
+ }, [getUpdatedState]);
176
171
  (0, util_1.useClientLayoutEffect)(() => {
177
172
  syncHeight();
178
173
  });
@@ -191,7 +186,10 @@ const TextareaAutosize = (0, react_1.forwardRef)((_a, ref) => {
191
186
  return (react_1.default.createElement(react_1.default.Fragment, null,
192
187
  react_1.default.createElement("textarea", Object.assign({ value: value, onChange: handleChange, ref: handleRef,
193
188
  // Apply the rows prop to get a "correct" first SSR paint
194
- rows: minRows, style: Object.assign(Object.assign({ height: state.outerHeightStyle }, (state.overflow ? { overflow: "hidden" } : {})), style) }, other, { className: className })),
189
+ rows: minRows, style: Object.assign({ height: state.outerHeightStyle,
190
+ // Need a large enough difference to allow scrolling.
191
+ // This prevents infinite rendering loop.
192
+ overflow: state.overflow && !autoScrollbar ? "hidden" : undefined }, style) }, other, { className: className })),
195
193
  react_1.default.createElement("textarea", { "aria-hidden": true, className: className, readOnly: true, ref: shadowRef, tabIndex: -1, style: Object.assign({
196
194
  // Visibility needed to hide the extra text area on iPads
197
195
  visibility: "hidden",
@@ -206,6 +204,6 @@ function isEmpty(obj) {
206
204
  return (obj === undefined ||
207
205
  obj === null ||
208
206
  Object.keys(obj).length === 0 ||
209
- ((obj === null || obj === void 0 ? void 0 : obj.outerHeightStyle) === 0 && !(obj === null || obj === void 0 ? void 0 : obj.overflow)));
207
+ (obj.outerHeightStyle === 0 && !obj.overflow));
210
208
  }
211
209
  exports.default = TextareaAutosize;
@@ -48,7 +48,7 @@ export const Alert = forwardRef((_a, ref) => {
48
48
  React.createElement(Icon, { variant: variant, className: "navds-alert__icon" }),
49
49
  React.createElement(BodyLong, { as: "div", size: size, className: "navds-alert__wrapper" }, children),
50
50
  closeButton && !inline && (React.createElement("div", { className: "navds-alert__button-wrapper" },
51
- React.createElement(Button, { className: "navds-alert__button", size: "small", variant: "tertiary-neutral", onClick: onClose, icon: React.createElement(XMarkIcon, { title: "Lukk Alert" }) })))));
51
+ React.createElement(Button, { className: "navds-alert__button", size: "small", variant: "tertiary-neutral", onClick: onClose, type: "button", icon: React.createElement(XMarkIcon, { title: "Lukk Alert" }) })))));
52
52
  });
53
53
  export default Alert;
54
54
  //# sourceMappingURL=Alert.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Alert.js","sourceRoot":"","sources":["../../src/alert/Alert.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EACL,yBAAyB,EACzB,uBAAuB,EACvB,+BAA+B,EAC/B,oBAAoB,EACpB,SAAS,GACV,M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AAC,QAAQ,EACb,IAAI,EAAE,oBAAC,SAAS,IAAC,KAAK,EAAC,YAAY,GAAG,GACtC,CACE,CACP,CACG,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,KAAK,CAAC"}
@@ -36,7 +36,13 @@ export interface TextareaProps extends FormFieldProps, React.TextareaHTMLAttribu
36
36
  /**
37
37
  * Enables resizing of field
38
38
  */
39
- resize?: boolean;
39
+ resize?: boolean | "vertical" | "horizontal";
40
+ /**
41
+ * Textarea will stop growing and get a scrollbar when there's no more room to grow.
42
+ * Requires `display:flex` on the parent.
43
+ * Experimental feature that may be removed or get breaking changes in a minor version.
44
+ */
45
+ UNSAFE_autoScrollbar?: boolean;
40
46
  /**
41
47
  * i18n-translations for counter-text
42
48
  */
@@ -31,7 +31,7 @@ import { useFormField } from "./useFormField";
31
31
  export const Textarea = forwardRef((props, ref) => {
32
32
  var _a, _b, _c;
33
33
  const { inputProps, errorId, showErrorMsg, hasError, size, inputDescriptionId, } = useFormField(props, "textarea");
34
- const { label, className, description, maxLength, hideLabel = false, resize, i18n, readOnly } = props, rest = __rest(props, ["label", "className", "description", "maxLength", "hideLabel", "resize", "i18n", "readOnly"]);
34
+ const { label, className, description, maxLength, hideLabel = false, resize, UNSAFE_autoScrollbar, i18n, readOnly } = props, rest = __rest(props, ["label", "className", "description", "maxLength", "hideLabel", "resize", "UNSAFE_autoScrollbar", "i18n", "readOnly"]);
35
35
  const maxLengthId = useId();
36
36
  const hasMaxLength = maxLength !== undefined && maxLength > 0;
37
37
  const [controlledValue, setControlledValue] = useState((_a = props === null || props === void 0 ? void 0 : props.defaultValue) !== null && _a !== void 0 ? _a : "");
@@ -50,7 +50,8 @@ export const Textarea = forwardRef((props, ref) => {
50
50
  "navds-form-field--readonly": readOnly,
51
51
  "navds-textarea--readonly": readOnly,
52
52
  "navds-textarea--error": hasError,
53
- "navds-textarea--resize": resize,
53
+ "navds-textarea--autoscrollbar": UNSAFE_autoScrollbar,
54
+ [`navds-textarea--resize-${resize === true ? "both" : resize}`]: resize,
54
55
  }) },
55
56
  React.createElement(Label, { htmlFor: inputProps.id, size: size, className: cl("navds-form-field__label", {
56
57
  "navds-sr-only": hideLabel,
@@ -63,7 +64,7 @@ export const Textarea = forwardRef((props, ref) => {
63
64
  React.createElement("div", { className: "navds-textarea__wrapper" },
64
65
  React.createElement(TextareaAutosize, Object.assign({}, omit(rest, ["error", "errorId", "size"]), inputProps, { onChange: (e) => props.onChange
65
66
  ? props.onChange(e)
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
+ : setControlledValue(e.target.value), minRows: getMinRows(), autoScrollbar: UNSAFE_autoScrollbar, 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
68
  hasMaxLength && !readOnly && !inputProps.disabled && (React.createElement(React.Fragment, null,
68
69
  React.createElement("span", { id: maxLengthId, className: "navds-sr-only" }, `Tekstområde med plass til ${maxLength} tegn.`),
69
70
  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 })))),
@@ -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,EAAE,IA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AAK,CAAC,KAAK,CAAgB,CACvD,CACG,CACF,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -1,14 +1,30 @@
1
1
  import cl from "clsx";
2
- import React from "react";
2
+ import React, { useEffect, useState } from "react";
3
3
  import { BodyShort } from "../typography";
4
+ import debounce from "../util/debounce";
4
5
  const TextareaCounter = ({ maxLength, currentLength, size, i18n }) => {
5
- var _a, _b;
6
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
7
+ const [debouncedDiff, setDebouncedDiff] = useState(difference);
8
+ useEffect(() => {
9
+ const debounceFunc = debounce(() => {
10
+ setDebouncedDiff(difference);
11
+ }, 2000);
12
+ debounceFunc();
13
+ return () => {
14
+ debounceFunc.clear();
15
+ };
16
+ }, [difference]);
17
+ return (React.createElement(React.Fragment, null,
18
+ difference < 20 && (React.createElement("span", { role: "status", className: "navds-textarea__sr-counter navds-sr-only" }, getCounterText(debouncedDiff, i18n))),
19
+ React.createElement(BodyShort, { className: cl("navds-textarea__counter", {
20
+ "navds-textarea__counter--error": difference < 0,
21
+ }), size: size }, getCounterText(difference, i18n))));
22
+ };
23
+ const getCounterText = (difference, i18n) => {
24
+ var _a, _b;
25
+ return difference < 0
10
26
  ? `${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"}`));
27
+ : `${difference} ${(_b = i18n === null || i18n === void 0 ? void 0 : i18n.counterLeft) !== null && _b !== void 0 ? _b : "tegn igjen"}`;
12
28
  };
13
29
  export default TextareaCounter;
14
30
  //# sourceMappingURL=TextareaCounter.js.map
@@ -1 +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"}
1
+ {"version":3,"file":"TextareaCounter.js","sourceRoot":"","sources":["../../src/form/TextareaCounter.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,QAAQ,MAAM,kBAAkB,CAAC;AAUxC,MAAM,eAAe,GAAG,CAAC,EAAE,SAAS,EA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,eAAe,CAAC"}
@@ -3,8 +3,9 @@ import { OverridableComponent } from "../util/OverridableComponent";
3
3
  export interface LinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {
4
4
  /**
5
5
  * Inverts when the underline appears. If this is false,
6
- * the underline does not appear by default, but does appear when the link is hovered.
7
- * This makes it more suitable for use when inlined in text.
6
+ * the underline only appears on hover.
7
+ *
8
+ * **NB: Underline can only be removed in menus etc. where it's obvious that it's a link.**
8
9
  * @default true
9
10
  */
10
11
  underline?: boolean;
package/esm/link/Link.js CHANGED
@@ -9,8 +9,8 @@ var __rest = (this && this.__rest) || function (s, e) {
9
9
  }
10
10
  return t;
11
11
  };
12
- import React, { forwardRef } from "react";
13
12
  import cl from "clsx";
13
+ import React, { forwardRef } from "react";
14
14
  /**
15
15
  * A component that displays a hyperlink.
16
16
  *
@@ -1 +1 @@
1
- {"version":3,"file":"Link.js","sourceRoot":"","sources":["../../src/link/Link.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,MAAM,MAAM,CAAC;AA4BtB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,IAAI,GACf,UAAU,CACR,CACE,EAOC,EACD,GAAG,EACH,EAAE;QATF,EACE,EAAE,EAAE,SAAS,GAAG,GAAG,EACnB,SAAS,EACT,SAAS,GAAG,IAAI,EAChB,OAAO,GAAG,QAAQ,EAClB,UAAU,GAAG,KAAK,OAEnB,EADI,IAAI,cANT,yDAOC,CADQ;IAGN,OAAA,CACH,oBAAC,SAAS,oBACJ,IAAI,IACR,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CAAC,YAAY,EAAE,SAAS,EAAE,eAAe,OAAO,EAAE,EAAE;YAC/D,8BAA8B,EAAE,CAAC,SAAS;YAC1C,yBAAyB,EAAE,UAAU;SACtC,CAAC,IACF,CACH,CAAA;CAAA,CACF,CAAC;AAEJ,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"Link.js","sourceRoot":"","sources":["../../src/link/Link.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AA6B1C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,IAAI,GACf,UAAU,CACR,CACE,EAOC,EACD,GAAG,EACH,EAAE;QATF,EACE,EAAE,EAAE,SAAS,GAAG,GAAG,EACnB,SAAS,EACT,SAAS,GAAG,IAAI,EAChB,OAAO,GAAG,QAAQ,EAClB,UAAU,GAAG,KAAK,OAEnB,EADI,IAAI,cANT,yDAOC,CADQ;IAGN,OAAA,CACH,oBAAC,SAAS,oBACJ,IAAI,IACR,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CAAC,YAAY,EAAE,SAAS,EAAE,eAAe,OAAO,EAAE,EAAE;YAC/D,8BAA8B,EAAE,CAAC,SAAS;YAC1C,yBAAyB,EAAE,UAAU;SACtC,CAAC,IACF,CACH,CAAA;CAAA,CACF,CAAC;AAEJ,eAAe,IAAI,CAAC"}
@@ -9,6 +9,10 @@ interface TextareaAutosizeProps extends Omit<React.TextareaHTMLAttributes<HTMLTe
9
9
  * @default 1
10
10
  */
11
11
  minRows?: number;
12
+ /**
13
+ * If true, textarea will never get `overflow:hidden`
14
+ */
15
+ autoScrollbar?: boolean;
12
16
  }
13
17
  declare const TextareaAutosize: React.ForwardRefExoticComponent<TextareaAutosizeProps & React.RefAttributes<HTMLTextAreaElement>>;
14
18
  export default TextareaAutosize;