@norges-domstoler/dds-components 8.0.1 → 9.0.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.
Files changed (84) hide show
  1. package/README.md +1 -0
  2. package/dist/cjs/components/Button/Button.stories.d.ts +3 -3
  3. package/dist/cjs/components/Checkbox/Checkbox.d.ts +1 -10
  4. package/dist/cjs/components/Checkbox/Checkbox.stories.d.ts +3 -12
  5. package/dist/cjs/components/Checkbox/Checkbox.types.d.ts +2 -3
  6. package/dist/cjs/components/RadioButton/RadioButton.stories.d.ts +3 -3
  7. package/dist/cjs/components/RadioButton/RadioButtonGroup.d.ts +1 -1
  8. package/dist/cjs/components/TextArea/TextArea.d.ts +7 -0
  9. package/dist/cjs/components/TextArea/TextArea.stories.d.ts +51 -0
  10. package/dist/cjs/components/TextArea/TextArea.tokens.d.ts +5 -0
  11. package/dist/cjs/components/TextArea/index.d.ts +1 -0
  12. package/dist/cjs/components/TextInput/TextInput.d.ts +4 -10
  13. package/dist/cjs/components/TextInput/TextInput.stories.d.ts +4 -17
  14. package/dist/cjs/components/TextInput/TextInput.styles.d.ts +2 -5
  15. package/dist/cjs/components/TextInput/TextInput.types.d.ts +3 -6
  16. package/dist/cjs/components/ToggleButton/ToggleButton.d.ts +4 -15
  17. package/dist/cjs/components/ToggleButton/ToggleButton.stories.d.ts +3 -3
  18. package/dist/cjs/components/ToggleButton/ToggleButton.types.d.ts +10 -0
  19. package/dist/cjs/components/ToggleButton/index.d.ts +1 -0
  20. package/dist/cjs/components/Tooltip/Tooltip.stories.d.ts +2 -2
  21. package/dist/cjs/helpers/Input/Input.styles.d.ts +2 -2
  22. package/dist/cjs/helpers/Input/Input.types.d.ts +8 -5
  23. package/dist/cjs/helpers/Input/Input.utils.d.ts +2 -0
  24. package/dist/cjs/index.d.ts +1 -0
  25. package/dist/cjs/index.js +502 -464
  26. package/dist/cjs/types/CheckboxPickedHTMLAttributes.d.ts +2 -0
  27. package/dist/cjs/types/index.d.ts +1 -0
  28. package/dist/components/Breadcrumbs/Breadcrumb.js +1 -0
  29. package/dist/components/Button/Button.stories.d.ts +3 -3
  30. package/dist/components/Card/CardAccordion/CardAccordionHeader.js +1 -0
  31. package/dist/components/Checkbox/Checkbox.d.ts +1 -10
  32. package/dist/components/Checkbox/Checkbox.js +1 -0
  33. package/dist/components/Checkbox/Checkbox.stories.d.ts +3 -12
  34. package/dist/components/Checkbox/Checkbox.types.d.ts +2 -3
  35. package/dist/components/Checkbox/CheckboxGroup.js +3 -11
  36. package/dist/components/Datepicker/Datepicker.js +2 -10
  37. package/dist/components/Drawer/Drawer.js +1 -0
  38. package/dist/components/GlobalMessage/GlobalMessage.js +1 -0
  39. package/dist/components/InternalHeader/InternalHeader.js +1 -0
  40. package/dist/components/LocalMessage/LocalMessage.js +1 -0
  41. package/dist/components/Modal/Modal.js +1 -0
  42. package/dist/components/Pagination/Pagination.js +1 -0
  43. package/dist/components/Popover/Popover.js +1 -0
  44. package/dist/components/RadioButton/RadioButton.js +1 -0
  45. package/dist/components/RadioButton/RadioButton.stories.d.ts +3 -3
  46. package/dist/components/RadioButton/RadioButtonGroup.d.ts +1 -1
  47. package/dist/components/RadioButton/RadioButtonGroup.js +3 -12
  48. package/dist/components/Search/Search.js +2 -7
  49. package/dist/components/Select/Select.js +2 -11
  50. package/dist/components/Tag/Tag.js +1 -0
  51. package/dist/components/TextArea/TextArea.d.ts +7 -0
  52. package/dist/components/TextArea/TextArea.js +105 -0
  53. package/dist/components/TextArea/TextArea.stories.d.ts +51 -0
  54. package/dist/components/TextArea/TextArea.tokens.d.ts +5 -0
  55. package/dist/components/TextArea/TextArea.tokens.js +11 -0
  56. package/dist/components/TextArea/index.d.ts +1 -0
  57. package/dist/components/TextInput/CharCounter.js +1 -0
  58. package/dist/components/TextInput/TextInput.d.ts +4 -10
  59. package/dist/components/TextInput/TextInput.js +6 -49
  60. package/dist/components/TextInput/TextInput.stories.d.ts +4 -17
  61. package/dist/components/TextInput/TextInput.styles.d.ts +2 -5
  62. package/dist/components/TextInput/TextInput.styles.js +6 -12
  63. package/dist/components/TextInput/TextInput.types.d.ts +3 -6
  64. package/dist/components/ToggleBar/ToggleBar.js +1 -0
  65. package/dist/components/ToggleBar/ToggleRadio.js +1 -0
  66. package/dist/components/ToggleBar/ToggleRadio.styles.js +1 -0
  67. package/dist/components/ToggleButton/ToggleButton.d.ts +4 -15
  68. package/dist/components/ToggleButton/ToggleButton.js +1 -0
  69. package/dist/components/ToggleButton/ToggleButton.stories.d.ts +3 -3
  70. package/dist/components/ToggleButton/ToggleButton.types.d.ts +10 -0
  71. package/dist/components/ToggleButton/ToggleButtonGroup.js +1 -0
  72. package/dist/components/ToggleButton/index.d.ts +1 -0
  73. package/dist/components/Tooltip/Tooltip.stories.d.ts +2 -2
  74. package/dist/components/Typography/Label/Label.js +1 -0
  75. package/dist/helpers/Backdrop/Backdrop.utils.js +7 -2
  76. package/dist/helpers/Input/Input.styles.d.ts +2 -2
  77. package/dist/helpers/Input/Input.types.d.ts +8 -5
  78. package/dist/helpers/Input/Input.utils.d.ts +2 -0
  79. package/dist/helpers/Input/Input.utils.js +28 -1
  80. package/dist/index.d.ts +1 -0
  81. package/dist/index.js +1 -0
  82. package/dist/types/CheckboxPickedHTMLAttributes.d.ts +2 -0
  83. package/dist/types/index.d.ts +1 -0
  84. package/package.json +1 -1
@@ -1,14 +1,8 @@
1
1
  import React from 'react';
2
2
  import { InputSize } from '../../helpers';
3
- import { Property } from 'csstype';
4
- export declare const TextInput: React.ForwardRefExoticComponent<{
5
- multiline?: boolean | undefined;
3
+ export declare const TextInput: React.ForwardRefExoticComponent<import("../../helpers").CommonInputProps & {
4
+ componentSize?: InputSize | undefined;
5
+ } & React.InputHTMLAttributes<HTMLInputElement> & {
6
6
  withCharacterCounter?: boolean | undefined;
7
7
  icon?: import("../../icons/utils").SvgIcon | undefined;
8
- } & {
9
- label?: string | undefined;
10
- componentSize?: InputSize | undefined;
11
- width?: Property.Width<string> | undefined;
12
- tip?: string | undefined;
13
- errorMessage?: string | undefined;
14
- } & React.InputHTMLAttributes<HTMLInputElement> & React.InputHTMLAttributes<HTMLTextAreaElement> & React.RefAttributes<HTMLInputElement>>;
8
+ } & React.RefAttributes<HTMLInputElement>>;
@@ -1,18 +1,17 @@
1
1
  import { slicedToArray as _slicedToArray } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
2
  import { __rest } from 'tslib';
3
3
  import { jsxs, jsx } from 'react/jsx-runtime';
4
- import { forwardRef, useRef, useState, useEffect, useId } from 'react';
5
- import { InputMessage } from '../InputMessage/InputMessage.js';
4
+ import { forwardRef, useState, useId } from 'react';
6
5
  import CharCounter from './CharCounter.js';
7
6
  import '../../helpers/Backdrop/Backdrop.js';
8
7
  import '../../helpers/Chevron/AnimatedChevronUpDown.styles.js';
9
8
  import '../../helpers/HiddenInput/HiddenInput.js';
10
9
  import { OuterInputContainer, InputContainer, StatefulInput } from '../../helpers/Input/Input.styles.js';
11
10
  import '../../helpers/Input/Input.tokens.js';
12
- import { getFormInputIconSize } from '../../helpers/Input/Input.utils.js';
11
+ import { getDefaultText, getFormInputIconSize, renderInputMessage } from '../../helpers/Input/Input.utils.js';
13
12
  import '../../helpers/Paper/Paper.js';
14
13
  import '../../helpers/RequiredMarker/RequiredMarker.js';
15
- import { TextArea, StyledIcon, StyledInput, MessageContainer } from './TextInput.styles.js';
14
+ import { StyledIcon, StyledInput, MessageContainer } from './TextInput.styles.js';
16
15
  import '../Typography/Typography/Typography.js';
17
16
  import { Label } from '../Typography/Label/Label.js';
18
17
  import '../Typography/Link/Link.js';
@@ -40,7 +39,6 @@ var TextInput = /*#__PURE__*/forwardRef(function (_a, ref) {
40
39
  tip = _a.tip,
41
40
  required = _a.required,
42
41
  maxLength = _a.maxLength,
43
- multiline = _a.multiline,
44
42
  onChange = _a.onChange,
45
43
  id = _a.id,
46
44
  width = _a.width,
@@ -57,21 +55,13 @@ var TextInput = /*#__PURE__*/forwardRef(function (_a, ref) {
57
55
  ariaRequired = _a['aria-required'],
58
56
  ariaDescribedby = _a['aria-describedby'],
59
57
  icon = _a.icon,
60
- rest = __rest(_a, ["label", "disabled", "readOnly", "errorMessage", "tip", "required", "maxLength", "multiline", "onChange", "id", "width", "componentSize", "type", "withCharacterCounter", "className", "style", "value", "defaultValue", 'aria-required', 'aria-describedby', "icon"]);
61
-
62
- var textAreaRef = useRef(null);
58
+ rest = __rest(_a, ["label", "disabled", "readOnly", "errorMessage", "tip", "required", "maxLength", "onChange", "id", "width", "componentSize", "type", "withCharacterCounter", "className", "style", "value", "defaultValue", 'aria-required', 'aria-describedby', "icon"]);
63
59
 
64
60
  var _useState = useState(getDefaultText(value, defaultValue)),
65
61
  _useState2 = _slicedToArray(_useState, 2),
66
62
  text = _useState2[0],
67
63
  setText = _useState2[1];
68
64
 
69
- useEffect(function () {
70
- if (textAreaRef && textAreaRef.current) {
71
- textAreaRef.current.style.height = "".concat(textAreaRef.current.scrollHeight + 2, "px");
72
- }
73
- }, [text]);
74
-
75
65
  var onChangeHandler = function onChangeHandler(event) {
76
66
  setText(event.target.value);
77
67
 
@@ -80,14 +70,6 @@ var TextInput = /*#__PURE__*/forwardRef(function (_a, ref) {
80
70
  }
81
71
  };
82
72
 
83
- var onChangeHandlerMultiline = function onChangeHandlerMultiline(event) {
84
- setText(event.target.value);
85
-
86
- if (onChange) {
87
- onChange(event);
88
- }
89
- };
90
-
91
73
  var generatedId = useId();
92
74
  var uniqueId = id !== null && id !== void 0 ? id : "".concat(generatedId, "-textInput");
93
75
  var hasErrorMessage = !!errorMessage;
@@ -114,7 +96,6 @@ var TextInput = /*#__PURE__*/forwardRef(function (_a, ref) {
114
96
  'aria-invalid': hasErrorMessage ? true : undefined
115
97
  }, rest);
116
98
  var outerInputContainerProps = {
117
- multiline: multiline,
118
99
  className: className,
119
100
  style: style,
120
101
  width: getWidth(componentSize, width)
@@ -126,11 +107,7 @@ var TextInput = /*#__PURE__*/forwardRef(function (_a, ref) {
126
107
  showRequiredStyling: showRequiredStyling
127
108
  }, {
128
109
  children: label
129
- })), multiline ? jsx(TextArea, Object.assign({
130
- ref: textAreaRef,
131
- as: "textarea",
132
- onChange: onChangeHandlerMultiline
133
- }, generalInputProps)) : hasIcon ? jsxs(InputContainer, {
110
+ })), hasIcon ? jsxs(InputContainer, {
134
111
  children: [jsx(StyledIcon, {
135
112
  icon: icon,
136
113
  iconSize: getFormInputIconSize(componentSize),
@@ -148,15 +125,7 @@ var TextInput = /*#__PURE__*/forwardRef(function (_a, ref) {
148
125
  type: type,
149
126
  componentSize: componentSize
150
127
  }, generalInputProps)), hasMessage && jsxs(MessageContainer, {
151
- children: [hasErrorMessage && jsx(InputMessage, {
152
- message: errorMessage,
153
- messageType: "error",
154
- id: errorMessageId
155
- }), hasTip && !errorMessage && jsx(InputMessage, {
156
- message: tip,
157
- messageType: "tip",
158
- id: tipId
159
- }), maxLength && Number.isInteger(maxLength) && maxLength > 0 && withCharacterCounter && jsx(CharCounter, {
128
+ children: [renderInputMessage(tip, tipId, errorMessage, errorMessageId), maxLength && Number.isInteger(maxLength) && maxLength > 0 && withCharacterCounter && jsx(CharCounter, {
160
129
  id: characterCounterId,
161
130
  current: text.length,
162
131
  max: maxLength
@@ -165,16 +134,4 @@ var TextInput = /*#__PURE__*/forwardRef(function (_a, ref) {
165
134
  }));
166
135
  });
167
136
 
168
- function getDefaultText(value, defaultValue) {
169
- if (typeof value === 'string') {
170
- return value;
171
- }
172
-
173
- if (typeof defaultValue === 'string') {
174
- return defaultValue;
175
- }
176
-
177
- return '';
178
- }
179
-
180
137
  export { TextInput };
@@ -1,17 +1,12 @@
1
1
  import { TextInputProps } from '.';
2
2
  declare const _default: {
3
3
  title: string;
4
- component: import("react").ForwardRefExoticComponent<{
5
- multiline?: boolean | undefined;
4
+ component: import("react").ForwardRefExoticComponent<import("../../helpers").CommonInputProps & {
5
+ componentSize?: import("../../helpers").InputSize | undefined;
6
+ } & import("react").InputHTMLAttributes<HTMLInputElement> & {
6
7
  withCharacterCounter?: boolean | undefined;
7
8
  icon?: import("../../icons/utils").SvgIcon | undefined;
8
- } & {
9
- label?: string | undefined;
10
- componentSize?: import("../../helpers").InputSize | undefined;
11
- width?: import("csstype").Property.Width<string> | undefined;
12
- tip?: string | undefined;
13
- errorMessage?: string | undefined;
14
- } & import("react").InputHTMLAttributes<HTMLInputElement> & import("react").InputHTMLAttributes<HTMLTextAreaElement> & import("react").RefAttributes<HTMLInputElement>>;
9
+ } & import("react").RefAttributes<HTMLInputElement>>;
15
10
  argTypes: {
16
11
  label: {
17
12
  control: {
@@ -33,11 +28,6 @@ declare const _default: {
33
28
  type: string;
34
29
  };
35
30
  };
36
- multiline: {
37
- control: {
38
- type: string;
39
- };
40
- };
41
31
  required: {
42
32
  control: {
43
33
  type: string;
@@ -63,9 +53,6 @@ declare const _default: {
63
53
  export default _default;
64
54
  export declare const TextInputOverview: (args: TextInputProps) => JSX.Element;
65
55
  export declare const TextInputOverviewSizes: () => JSX.Element;
66
- export declare const TextareaOverview: (args: TextInputProps) => JSX.Element;
67
56
  export declare const Default: (args: TextInputProps) => JSX.Element;
68
57
  export declare const WithLabel: (args: TextInputProps) => JSX.Element;
69
58
  export declare const WithCharacterCount: (args: TextInputProps) => JSX.Element;
70
- export declare const Textarea: (args: TextInputProps) => JSX.Element;
71
- export declare const TextareaWithLabel: (args: TextInputProps) => JSX.Element;
@@ -1,8 +1,5 @@
1
1
  import { InputSize } from '../../helpers';
2
2
  import { Icon } from '../Icon';
3
- export declare const TextArea: import("styled-components").StyledComponent<"input", any, Pick<import("../../helpers").InputProps, "disabled" | "readOnly" | "componentSize"> & {
4
- hasErrorMessage: boolean;
5
- } & StyledInputProps, never>;
6
3
  export declare const MessageContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
7
4
  declare type StyledIconProps = {
8
5
  size: InputSize;
@@ -11,7 +8,7 @@ export declare const StyledIcon: import("styled-components").StyledComponent<typ
11
8
  declare type StyledInputProps = {
12
9
  hasIcon?: boolean;
13
10
  };
14
- export declare const StyledInput: import("styled-components").StyledComponent<"input", any, Pick<import("../../helpers").InputProps, "disabled" | "readOnly" | "componentSize"> & {
11
+ export declare const StyledInput: import("styled-components").StyledComponent<"input", any, Pick<import("../../helpers").InputProps, "disabled" | "readOnly"> & {
15
12
  hasErrorMessage: boolean;
16
- } & StyledInputProps, never>;
13
+ } & Pick<import("../../helpers").InputProps, "componentSize"> & StyledInputProps, never>;
17
14
  export {};
@@ -5,29 +5,23 @@ import 'react/jsx-runtime';
5
5
  import '../../helpers/Chevron/AnimatedChevronUpDown.styles.js';
6
6
  import '../../helpers/HiddenInput/HiddenInput.js';
7
7
  import { StatefulInput } from '../../helpers/Input/Input.styles.js';
8
- import { inputTokens } from '../../helpers/Input/Input.tokens.js';
8
+ import '../../helpers/Input/Input.tokens.js';
9
+ import '../InputMessage/InputMessage.js';
9
10
  import '../../helpers/Paper/Paper.js';
10
11
  import '../../helpers/RequiredMarker/RequiredMarker.js';
11
- import '../ScrollableContainer/Scrollbar.js';
12
- import '../ScrollableContainer/ScrollableContainer.js';
13
- import { scrollbarStyling } from '../ScrollableContainer/scrollbarStyling.js';
14
12
  import { Icon } from '../Icon/Icon.js';
15
13
  import { ddsBaseTokens } from '@norges-domstoler/dds-design-tokens';
16
14
 
17
15
  var iconSizes = ddsBaseTokens.iconSizes;
18
16
  var input = textInputTokens.input,
19
17
  icon = textInputTokens.icon;
20
- var TextArea = styled(StatefulInput).withConfig({
21
- displayName: "TextInputstyles__TextArea",
22
- componentId: "sc-165zflr-0"
23
- })(["", " ", " height:auto;resize:vertical;vertical-align:bottom;padding-bottom:", ";", ""], scrollbarStyling.webkit, scrollbarStyling.firefox, input.multiline.paddingBottom, inputTokens.input.sizes.medium.font);
24
18
  var MessageContainer = styled.div.withConfig({
25
19
  displayName: "TextInputstyles__MessageContainer",
26
- componentId: "sc-165zflr-1"
20
+ componentId: "sc-165zflr-0"
27
21
  })(["display:flex;justify-content:space-between;"]);
28
22
  var StyledIcon = styled(Icon).withConfig({
29
23
  displayName: "TextInputstyles__StyledIcon",
30
- componentId: "sc-165zflr-2"
24
+ componentId: "sc-165zflr-1"
31
25
  })(["position:absolute;color:", ";", " z-index:1;"], icon.color, function (_ref) {
32
26
  var size = _ref.size,
33
27
  iconSize = _ref.iconSize;
@@ -35,11 +29,11 @@ var StyledIcon = styled(Icon).withConfig({
35
29
  });
36
30
  var StyledInput = styled(StatefulInput).withConfig({
37
31
  displayName: "TextInputstyles__StyledInput",
38
- componentId: "sc-165zflr-3"
32
+ componentId: "sc-165zflr-2"
39
33
  })(["", ""], function (_ref2) {
40
34
  var componentSize = _ref2.componentSize,
41
35
  hasIcon = _ref2.hasIcon;
42
36
  return hasIcon && componentSize && css(["padding-left:", ";"], input.withIcon[componentSize].paddingLeft);
43
37
  });
44
38
 
45
- export { MessageContainer, StyledIcon, StyledInput, TextArea };
39
+ export { MessageContainer, StyledIcon, StyledInput };
@@ -1,11 +1,8 @@
1
- import { InputHTMLAttributes } from 'react';
2
1
  import { InputProps } from '../../helpers';
3
2
  import { SvgIcon } from '../../icons/utils';
4
- export declare type TextInputProps = {
5
- /**Gjør inputfeltet om til `<textarea>`. */
6
- multiline?: boolean;
7
- /** Spesifiserer om tegntelleren skal vises. */
3
+ export declare type TextInputProps = InputProps & {
4
+ /** Spesifiserer om tegntelleren skal vises ved bruk av `maxLength` attributt. */
8
5
  withCharacterCounter?: boolean;
9
6
  /** Ikonet som vises i komponenten. */
10
7
  icon?: SvgIcon;
11
- } & InputProps & InputHTMLAttributes<HTMLTextAreaElement>;
8
+ };
@@ -17,6 +17,7 @@ import '../../helpers/Chevron/AnimatedChevronUpDown.styles.js';
17
17
  import '../../helpers/HiddenInput/HiddenInput.js';
18
18
  import '../../helpers/Input/Input.styles.js';
19
19
  import '../../helpers/Input/Input.tokens.js';
20
+ import '../InputMessage/InputMessage.js';
20
21
  import '../../helpers/Paper/Paper.js';
21
22
  import '../../helpers/RequiredMarker/RequiredMarker.js';
22
23
  import '../Typography/Link/Link.js';
@@ -6,6 +6,7 @@ import '../../helpers/Chevron/AnimatedChevronUpDown.styles.js';
6
6
  import { HiddenInput } from '../../helpers/HiddenInput/HiddenInput.js';
7
7
  import '../../helpers/Input/Input.styles.js';
8
8
  import '../../helpers/Input/Input.tokens.js';
9
+ import '../InputMessage/InputMessage.js';
9
10
  import '../../helpers/Paper/Paper.js';
10
11
  import '../../helpers/RequiredMarker/RequiredMarker.js';
11
12
  import { getBaseHTMLProps } from '../../types/BaseComponentProps.js';
@@ -11,6 +11,7 @@ import '../../helpers/Chevron/AnimatedChevronUpDown.styles.js';
11
11
  import { HiddenInput } from '../../helpers/HiddenInput/HiddenInput.js';
12
12
  import '../../helpers/Input/Input.styles.js';
13
13
  import '../../helpers/Input/Input.tokens.js';
14
+ import '../InputMessage/InputMessage.js';
14
15
  import '../../helpers/Paper/Paper.js';
15
16
  import '../../helpers/RequiredMarker/RequiredMarker.js';
16
17
 
@@ -1,17 +1,6 @@
1
- import { InputHTMLAttributes } from 'react';
2
- import { BaseComponentProps } from '../../types';
3
- import { SvgIcon } from '../../icons/utils';
4
- export declare type ToggleButtonProps = BaseComponentProps<HTMLInputElement, {
5
- /**Ledetekst for inputelementet. */
6
- label?: string;
7
- /** Ikon. */
8
- icon?: SvgIcon;
9
- }, InputHTMLAttributes<HTMLInputElement>>;
10
- export declare const ToggleButton: import("react").ForwardRefExoticComponent<Pick<InputHTMLAttributes<HTMLInputElement>, "className" | "id"> & {
11
- /**Ledetekst for inputelementet. */
1
+ export declare const ToggleButton: import("react").ForwardRefExoticComponent<Pick<Omit<import("react").InputHTMLAttributes<HTMLInputElement>, "name" | "defaultChecked" | "defaultValue" | "aria-describedby" | "onBlur" | "onChange" | "checked" | "value">, "className" | "id"> & {
12
2
  label?: string | undefined;
13
- /** Ikon. */
14
- icon?: SvgIcon | undefined;
15
- } & {
16
- htmlProps?: InputHTMLAttributes<HTMLInputElement> | undefined;
3
+ icon?: import("../../icons/utils").SvgIcon | undefined;
4
+ } & import("../../types").CheckboxPickedHTMLAttributes & {
5
+ htmlProps?: Omit<import("react").InputHTMLAttributes<HTMLInputElement>, "name" | "defaultChecked" | "defaultValue" | "aria-describedby" | "onBlur" | "onChange" | "checked" | "value"> | undefined;
17
6
  } & import("react").RefAttributes<HTMLInputElement>>;
@@ -16,6 +16,7 @@ import '../../helpers/Chevron/AnimatedChevronUpDown.styles.js';
16
16
  import { HiddenInput } from '../../helpers/HiddenInput/HiddenInput.js';
17
17
  import '../../helpers/Input/Input.styles.js';
18
18
  import '../../helpers/Input/Input.tokens.js';
19
+ import '../InputMessage/InputMessage.js';
19
20
  import '../../helpers/Paper/Paper.js';
20
21
  import '../../helpers/RequiredMarker/RequiredMarker.js';
21
22
 
@@ -1,11 +1,11 @@
1
1
  import { ToggleButtonProps } from '.';
2
2
  declare const _default: {
3
3
  title: string;
4
- component: import("react").ForwardRefExoticComponent<Pick<import("react").InputHTMLAttributes<HTMLInputElement>, "id" | "className"> & {
4
+ component: import("react").ForwardRefExoticComponent<Pick<Omit<import("react").InputHTMLAttributes<HTMLInputElement>, "defaultChecked" | "defaultValue" | "aria-describedby" | "onBlur" | "onChange" | "name" | "value" | "checked">, "id" | "className"> & {
5
5
  label?: string | undefined;
6
6
  icon?: import("../../icons/utils").SvgIcon | undefined;
7
- } & {
8
- htmlProps?: import("react").InputHTMLAttributes<HTMLInputElement> | undefined;
7
+ } & import("../../types").CheckboxPickedHTMLAttributes & {
8
+ htmlProps?: Omit<import("react").InputHTMLAttributes<HTMLInputElement>, "defaultChecked" | "defaultValue" | "aria-describedby" | "onBlur" | "onChange" | "name" | "value" | "checked"> | undefined;
9
9
  } & import("react").RefAttributes<HTMLInputElement>>;
10
10
  argTypes: {
11
11
  label: {
@@ -0,0 +1,10 @@
1
+ import { InputHTMLAttributes } from 'react';
2
+ import { SvgIcon } from '../../icons/utils';
3
+ import { BaseComponentProps } from '../../types';
4
+ import { CheckboxPickedHTMLAttributes } from '../../types/CheckboxPickedHTMLAttributes';
5
+ export declare type ToggleButtonProps = BaseComponentProps<HTMLInputElement, {
6
+ /**Ledetekst for inputelementet. */
7
+ label?: string;
8
+ /** Ikon. */
9
+ icon?: SvgIcon;
10
+ } & CheckboxPickedHTMLAttributes, Omit<InputHTMLAttributes<HTMLInputElement>, keyof CheckboxPickedHTMLAttributes>>;
@@ -9,6 +9,7 @@ import '../../helpers/Chevron/AnimatedChevronUpDown.styles.js';
9
9
  import '../../helpers/HiddenInput/HiddenInput.js';
10
10
  import '../../helpers/Input/Input.styles.js';
11
11
  import '../../helpers/Input/Input.tokens.js';
12
+ import '../InputMessage/InputMessage.js';
12
13
  import '../../helpers/Paper/Paper.js';
13
14
  import '../../helpers/RequiredMarker/RequiredMarker.js';
14
15
  import '../Typography/Link/Link.js';
@@ -1,2 +1,3 @@
1
1
  export * from './ToggleButton';
2
2
  export * from './ToggleButtonGroup';
3
+ export * from './ToggleButton.types';
@@ -1,7 +1,7 @@
1
1
  import { TooltipProps } from '.';
2
2
  declare const _default: {
3
3
  title: string;
4
- component: import("react").ForwardRefExoticComponent<Pick<Omit<import("react").HTMLAttributes<HTMLDivElement>, "style" | "children" | "onMouseLeave" | "onMouseOver">, "id" | "className"> & {
4
+ component: import("react").ForwardRefExoticComponent<Pick<Omit<import("react").HTMLAttributes<HTMLDivElement>, "children" | "style" | "onMouseLeave" | "onMouseOver">, "id" | "className"> & {
5
5
  text: string;
6
6
  placement?: import("../..").Placement | undefined;
7
7
  children: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> & import("react").RefAttributes<HTMLElement>;
@@ -12,7 +12,7 @@ declare const _default: {
12
12
  onMouseLeave?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
13
13
  onMouseOver?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
14
14
  } & {
15
- htmlProps?: Omit<import("react").HTMLAttributes<HTMLDivElement>, "style" | "children" | "onMouseLeave" | "onMouseOver"> | undefined;
15
+ htmlProps?: Omit<import("react").HTMLAttributes<HTMLDivElement>, "children" | "style" | "onMouseLeave" | "onMouseOver"> | undefined;
16
16
  } & import("react").RefAttributes<HTMLDivElement>>;
17
17
  argTypes: {
18
18
  text: {
@@ -6,6 +6,7 @@ import '../../../helpers/Chevron/AnimatedChevronUpDown.styles.js';
6
6
  import '../../../helpers/HiddenInput/HiddenInput.js';
7
7
  import '../../../helpers/Input/Input.styles.js';
8
8
  import '../../../helpers/Input/Input.tokens.js';
9
+ import '../../InputMessage/InputMessage.js';
9
10
  import '../../../helpers/Paper/Paper.js';
10
11
  import { RequiredMarker } from '../../../helpers/RequiredMarker/RequiredMarker.js';
11
12
  import { getBaseHTMLProps } from '../../../types/BaseComponentProps.js';
@@ -4,13 +4,18 @@ var isVerticalScrollbarDisplayed = function isVerticalScrollbarDisplayed(contain
4
4
 
5
5
  function handleElementWithBackdropMount(container) {
6
6
  if (isVerticalScrollbarDisplayed(container)) {
7
- container.style.position = 'fixed';
7
+ var scrollY = Math.round(window.scrollY);
8
8
  container.style.overflowY = 'scroll';
9
+ container.style.position = 'fixed';
10
+ container.style.top = "-".concat(scrollY, "px");
9
11
  }
10
12
  }
11
13
  function handleElementWithBackdropUnmount(container) {
12
- container.style.removeProperty('position');
14
+ var scrollY = parseInt(document.body.style.top) || 0;
13
15
  container.style.removeProperty('overflow-y');
16
+ container.style.removeProperty('position');
17
+ container.style.removeProperty('top');
18
+ window.scrollTo(0, scrollY * -1);
14
19
  }
15
20
 
16
21
  export { handleElementWithBackdropMount, handleElementWithBackdropUnmount };
@@ -1,8 +1,8 @@
1
1
  import { Property } from 'csstype';
2
2
  export declare const Input: import("styled-components").StyledComponent<"input", any, {}, never>;
3
- export declare const StatefulInput: import("styled-components").StyledComponent<"input", any, Pick<import("./Input.types").InputProps, "disabled" | "readOnly" | "componentSize"> & {
3
+ export declare const StatefulInput: import("styled-components").StyledComponent<"input", any, Pick<import("./Input.types").InputProps, "disabled" | "readOnly"> & {
4
4
  hasErrorMessage: boolean;
5
- }, never>;
5
+ } & Pick<import("./Input.types").InputProps, "componentSize">, never>;
6
6
  declare type OuterInputContainerProps = {
7
7
  width?: Property.Width<string>;
8
8
  };
@@ -1,18 +1,21 @@
1
1
  import { InputHTMLAttributes } from 'react';
2
2
  import { Property } from 'csstype';
3
- export declare type InputSize = 'medium' | 'small' | 'tiny';
4
- export declare type InputProps = {
3
+ export declare type CommonInputProps = {
5
4
  /**Ledetekst for input. */
6
5
  label?: string;
7
- /**Størrelse på inputfeltet. */
8
- componentSize?: InputSize;
9
6
  /**Bredde for inputfeltet. */
10
7
  width?: Property.Width<string>;
11
8
  /**Hjelpetekst. */
12
9
  tip?: string;
13
10
  /**Feilmelding. Setter også error state. */
14
11
  errorMessage?: string;
12
+ };
13
+ export declare type InputSize = 'medium' | 'small' | 'tiny';
14
+ export declare type InputProps = CommonInputProps & {
15
+ /**Størrelse på inputfeltet. */
16
+ componentSize?: InputSize;
15
17
  } & InputHTMLAttributes<HTMLInputElement>;
16
- export declare type StyledInputProps = Pick<InputProps, 'readOnly' | 'disabled' | 'componentSize'> & {
18
+ export declare type StyledCommonInputProps = Pick<InputProps, 'readOnly' | 'disabled'> & {
17
19
  hasErrorMessage: boolean;
18
20
  };
21
+ export declare type StyledInputProps = StyledCommonInputProps & Pick<InputProps, 'componentSize'>;
@@ -1,3 +1,5 @@
1
1
  import { IconSize } from '../../components/Icon';
2
2
  import { InputSize } from './Input.types';
3
3
  export declare const getFormInputIconSize: (componentSize: InputSize) => IconSize;
4
+ export declare function getDefaultText(value?: string | number | readonly string[], defaultValue?: string | number | readonly string[]): string;
5
+ export declare const renderInputMessage: (tip?: string, tipId?: string, errorMessage?: string, errorMessageId?: string) => JSX.Element;
@@ -1,3 +1,6 @@
1
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
2
+ import { InputMessage } from '../../components/InputMessage/InputMessage.js';
3
+
1
4
  var getFormInputIconSize = function getFormInputIconSize(componentSize) {
2
5
  switch (componentSize) {
3
6
  case 'medium':
@@ -10,5 +13,29 @@ var getFormInputIconSize = function getFormInputIconSize(componentSize) {
10
13
  return 'small';
11
14
  }
12
15
  };
16
+ function getDefaultText(value, defaultValue) {
17
+ if (typeof value === 'string') {
18
+ return value;
19
+ }
20
+
21
+ if (typeof defaultValue === 'string') {
22
+ return defaultValue;
23
+ }
24
+
25
+ return '';
26
+ }
27
+ var renderInputMessage = function renderInputMessage(tip, tipId, errorMessage, errorMessageId) {
28
+ return jsxs(Fragment, {
29
+ children: [errorMessage && errorMessageId && jsx(InputMessage, {
30
+ message: errorMessage,
31
+ messageType: "error",
32
+ id: errorMessageId
33
+ }), tip && tipId && !errorMessage && jsx(InputMessage, {
34
+ message: tip,
35
+ messageType: "tip",
36
+ id: tipId
37
+ })]
38
+ });
39
+ };
13
40
 
14
- export { getFormInputIconSize };
41
+ export { getDefaultText, getFormInputIconSize, renderInputMessage };
package/dist/index.d.ts CHANGED
@@ -39,3 +39,4 @@ export * from './components/ToggleBar';
39
39
  export * from './components/Grid';
40
40
  export * from './components/ProgressTracker';
41
41
  export * from './hooks';
42
+ export * from './components/TextArea';
package/dist/index.js CHANGED
@@ -210,3 +210,4 @@ export { useFocusTrap } from './hooks/useFocusTrap.js';
210
210
  export { useMountTransition } from './hooks/useMountTransition.js';
211
211
  export { ScreenSize, useScreenSize } from './hooks/useScreenSize.js';
212
212
  export { useReturnFocusOnBlur } from './hooks/useReturnFocusOnBlur.js';
213
+ export { StyledTextArea, TextArea } from './components/TextArea/TextArea.js';
@@ -0,0 +1,2 @@
1
+ import { InputHTMLAttributes } from 'react';
2
+ export declare type CheckboxPickedHTMLAttributes = Pick<InputHTMLAttributes<HTMLInputElement>, 'aria-describedby' | 'name' | 'checked' | 'defaultChecked' | 'value' | 'defaultValue' | 'onChange' | 'onBlur'>;
@@ -1,2 +1,3 @@
1
1
  export * from './Direction';
2
2
  export * from './BaseComponentProps';
3
+ export * from './CheckboxPickedHTMLAttributes';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@norges-domstoler/dds-components",
3
- "version": "8.0.1",
3
+ "version": "9.0.0",
4
4
  "description": "React components used in Elsa - domstolenes designsystem",
5
5
  "author": "Elsa team",
6
6
  "license": "MIT",