@norges-domstoler/dds-components 4.1.1 → 4.2.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/dist/cjs/components/TextInput/TextInput.d.ts +1 -0
- package/dist/cjs/components/TextInput/TextInput.stories.d.ts +1 -0
- package/dist/cjs/components/TextInput/TextInput.types.d.ts +2 -0
- package/dist/cjs/components/Typography/Typography.d.ts +1 -0
- package/dist/cjs/components/Typography/Typography.stories.d.ts +5 -0
- package/dist/cjs/components/Typography/Typography.types.d.ts +1 -0
- package/dist/cjs/index.js +15 -5
- package/dist/cjs/utils/idGenerator.d.ts +1 -1
- package/dist/components/TextInput/TextInput.d.ts +1 -0
- package/dist/components/TextInput/TextInput.js +5 -3
- package/dist/components/TextInput/TextInput.stories.d.ts +1 -0
- package/dist/components/TextInput/TextInput.types.d.ts +2 -0
- package/dist/components/Typography/Typography.d.ts +1 -0
- package/dist/components/Typography/Typography.js +10 -3
- package/dist/components/Typography/Typography.stories.d.ts +5 -0
- package/dist/components/Typography/Typography.types.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/utils/idGenerator.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export declare const TextInput: React.ForwardRefExoticComponent<{
|
|
3
3
|
multiline?: boolean | undefined;
|
|
4
|
+
withCharacterCounter?: boolean | undefined;
|
|
4
5
|
} & {
|
|
5
6
|
label?: string | undefined;
|
|
6
7
|
width?: import("csstype").Property.Width<string> | undefined;
|
|
@@ -4,6 +4,7 @@ declare const _default: {
|
|
|
4
4
|
title: string;
|
|
5
5
|
component: import("react").ForwardRefExoticComponent<{
|
|
6
6
|
multiline?: boolean | undefined;
|
|
7
|
+
withCharacterCounter?: boolean | undefined;
|
|
7
8
|
} & {
|
|
8
9
|
label?: string | undefined;
|
|
9
10
|
width?: import("csstype").Property.Width<string> | undefined;
|
|
@@ -3,4 +3,6 @@ import { InputProps } from '../../helpers';
|
|
|
3
3
|
export declare type TextInputProps = {
|
|
4
4
|
/**Gjør inputfeltet om til `<textarea>`. */
|
|
5
5
|
multiline?: boolean;
|
|
6
|
+
/** Spesifiserer om tegntelleren skal vises. */
|
|
7
|
+
withCharacterCounter?: boolean;
|
|
6
8
|
} & InputProps & InputHTMLAttributes<HTMLTextAreaElement>;
|
|
@@ -2,6 +2,7 @@ import { ElementType, PropsWithChildren, HTMLAttributes, AnchorHTMLAttributes }
|
|
|
2
2
|
import { CSSObject } from 'styled-components';
|
|
3
3
|
import { TextColor, OtherTypographyType, AnchorTypographyType, LabelTypographyType } from './Typography.types';
|
|
4
4
|
import { BaseComponentProps } from '../../types';
|
|
5
|
+
export declare const inlineElements: ElementType[];
|
|
5
6
|
export declare function isTextColor(color: string): color is TextColor;
|
|
6
7
|
export declare const getTextColor: (color: TextColor | string) => string;
|
|
7
8
|
export declare type TypographyInteractionProps = {
|
|
@@ -9,4 +9,5 @@ export declare type LabelTypographyType = 'supportingStyleLabel01';
|
|
|
9
9
|
export declare type OtherTypographyType = TypographyHeadingType | TypographyBodyType | TypographyLeadType | TypographySupportingType;
|
|
10
10
|
export declare type TypographyType = AnchorTypographyType | LabelTypographyType | OtherTypographyType;
|
|
11
11
|
export declare type TextColor = 'interactive' | 'primary' | 'danger' | 'warning' | 'success' | 'onLight' | 'onDark' | 'gray1' | 'gray2' | 'gray3' | 'gray4' | 'gray5' | 'gray6' | 'gray7' | 'gray8' | 'gray9';
|
|
12
|
+
export declare type InlineElement = 'a' | 'abbr' | 'audio' | 'b' | 'bdi' | 'bdo' | 'big' | 'br' | 'button' | 'canvas' | 'cite' | 'code' | 'data' | 'datalist' | 'del' | 'dfn' | 'em' | 'embed' | 'i' | 'iframe' | 'img' | 'input' | 'ins' | 'kbd' | 'label' | 'map' | 'mark' | 'meter' | 'noscript' | 'object' | 'output' | 'picture' | 'progress' | 'q' | 'ruby' | 's' | 'samp' | 'script' | 'select' | 'slot' | 'small' | 'span' | 'strong' | 'sub' | 'sup' | 'svg' | 'template' | 'textarea' | 'time' | 'u' | 'var' | 'video' | 'wbr';
|
|
12
13
|
export {};
|
package/dist/cjs/index.js
CHANGED
|
@@ -912,6 +912,12 @@ var getElementType = function getElementType(element) {
|
|
|
912
912
|
}
|
|
913
913
|
};
|
|
914
914
|
|
|
915
|
+
var inlineElements = ['a', 'abbr', 'audio', 'b', 'bdi', 'bdo', 'big', 'br', 'button', 'canvas', 'cite', 'code', 'data', 'datalist', 'del', 'dfn', 'em', 'embed', 'i', 'iframe', 'img', 'input', 'ins', 'kbd', 'label', 'map', 'mark', 'meter', 'noscript', 'object', 'output', 'picture', 'progress', 'q', 'ruby', 's', 'samp', 'script', 'select', 'slot', 'small', 'span', 'strong', 'sub', 'sup', 'svg', 'template', 'textarea', 'time', 'u', 'var', 'video', 'wbr'];
|
|
916
|
+
|
|
917
|
+
var isInlineElement = function isInlineElement(as) {
|
|
918
|
+
return inlineElements.indexOf(as) !== -1;
|
|
919
|
+
};
|
|
920
|
+
|
|
915
921
|
function isTextColor(color) {
|
|
916
922
|
return textColorsArray.indexOf(color) !== -1;
|
|
917
923
|
}
|
|
@@ -946,8 +952,9 @@ var StyledTypography = styled__default["default"].p.withConfig({
|
|
|
946
952
|
return interactionProps && interactionProps.active && styled.css(["&:active{", "}"], interactionProps.active);
|
|
947
953
|
}, function (_ref5) {
|
|
948
954
|
var withMargins = _ref5.withMargins,
|
|
949
|
-
typographyType = _ref5.typographyType
|
|
950
|
-
|
|
955
|
+
typographyType = _ref5.typographyType,
|
|
956
|
+
as = _ref5.as;
|
|
957
|
+
return withMargins && typographyType && isInlineElement(as) ? styled.css(["", " display:block;"], typographyTokens.typographyType[typographyType].margins.base) : withMargins && typographyType ? styled.css(["", ""], typographyTokens.typographyType[typographyType].margins.base) : styled.css(["margin:0;"]);
|
|
951
958
|
}, function (_ref6) {
|
|
952
959
|
var color = _ref6.color;
|
|
953
960
|
return color && styled.css(["color:", ";"], getTextColor(color));
|
|
@@ -2791,10 +2798,12 @@ var TextInput = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
2791
2798
|
width = _a$width === void 0 ? textInputTokens.wrapper.defaultWidth : _a$width,
|
|
2792
2799
|
_a$type = _a.type,
|
|
2793
2800
|
type = _a$type === void 0 ? 'text' : _a$type,
|
|
2801
|
+
_a$withCharacterCount = _a.withCharacterCounter,
|
|
2802
|
+
withCharacterCounter = _a$withCharacterCount === void 0 ? true : _a$withCharacterCount,
|
|
2794
2803
|
className = _a.className,
|
|
2795
2804
|
style = _a.style,
|
|
2796
2805
|
ariaDescribedby = _a['aria-describedby'],
|
|
2797
|
-
rest = tslib.__rest(_a, ["label", "disabled", "readOnly", "errorMessage", "tip", "required", "maxLength", "multiline", "onChange", "id", "width", "type", "className", "style", 'aria-describedby']);
|
|
2806
|
+
rest = tslib.__rest(_a, ["label", "disabled", "readOnly", "errorMessage", "tip", "required", "maxLength", "multiline", "onChange", "id", "width", "type", "withCharacterCounter", "className", "style", 'aria-describedby']);
|
|
2798
2807
|
|
|
2799
2808
|
var textAreaRef = React.useRef(null);
|
|
2800
2809
|
|
|
@@ -2834,7 +2843,7 @@ var TextInput = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
2834
2843
|
var hasLabel = !!label;
|
|
2835
2844
|
var labelPresence = hasLabel ? 'hasLabel' : 'noLabel';
|
|
2836
2845
|
var hasMessage = hasErrorMessage || hasTip || !!maxLength;
|
|
2837
|
-
var characterCounterId = derivativeIdGenerator(uniqueId, 'characterCounter', maxLength);
|
|
2846
|
+
var characterCounterId = derivativeIdGenerator(uniqueId, 'characterCounter', maxLength && withCharacterCounter);
|
|
2838
2847
|
var tipId = derivativeIdGenerator(uniqueId, 'tip', tip);
|
|
2839
2848
|
var errorMessageId = derivativeIdGenerator(uniqueId, 'errorMessage', errorMessage);
|
|
2840
2849
|
var generalInputProps = Object.assign({
|
|
@@ -2890,7 +2899,7 @@ var TextInput = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
2890
2899
|
message: tip,
|
|
2891
2900
|
messageType: "tip",
|
|
2892
2901
|
id: tipId
|
|
2893
|
-
}), maxLength && Number.isInteger(maxLength) && maxLength > 0 && jsxRuntime.jsx(CharCounter, {
|
|
2902
|
+
}), maxLength && Number.isInteger(maxLength) && maxLength > 0 && withCharacterCounter && jsxRuntime.jsx(CharCounter, {
|
|
2894
2903
|
id: characterCounterId,
|
|
2895
2904
|
current: text.length,
|
|
2896
2905
|
max: maxLength
|
|
@@ -7973,5 +7982,6 @@ exports.Tooltip = Tooltip;
|
|
|
7973
7982
|
exports.Typography = Typography;
|
|
7974
7983
|
exports.createSelectOptions = createSelectOptions;
|
|
7975
7984
|
exports.getTextColor = getTextColor;
|
|
7985
|
+
exports.inlineElements = inlineElements;
|
|
7976
7986
|
exports.isTextColor = isTextColor;
|
|
7977
7987
|
exports.searchFilter = searchFilter;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const derivativeIdGenerator: (prefix: string, suffix: string, value?: string | number) => string | undefined;
|
|
1
|
+
export declare const derivativeIdGenerator: (prefix: string, suffix: string, value?: string | number | boolean) => string | undefined;
|
|
2
2
|
export declare const idArrayGenerator: (values: (string | undefined)[]) => string[] | undefined;
|
|
3
3
|
export declare const spaceSeparatedIdListGenerator: (values: (string | undefined)[]) => string | undefined;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export declare const TextInput: React.ForwardRefExoticComponent<{
|
|
3
3
|
multiline?: boolean | undefined;
|
|
4
|
+
withCharacterCounter?: boolean | undefined;
|
|
4
5
|
} & {
|
|
5
6
|
label?: string | undefined;
|
|
6
7
|
width?: import("csstype").Property.Width<string> | undefined;
|
|
@@ -26,10 +26,12 @@ var TextInput = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
26
26
|
width = _a$width === void 0 ? textInputTokens.wrapper.defaultWidth : _a$width,
|
|
27
27
|
_a$type = _a.type,
|
|
28
28
|
type = _a$type === void 0 ? 'text' : _a$type,
|
|
29
|
+
_a$withCharacterCount = _a.withCharacterCounter,
|
|
30
|
+
withCharacterCounter = _a$withCharacterCount === void 0 ? true : _a$withCharacterCount,
|
|
29
31
|
className = _a.className,
|
|
30
32
|
style = _a.style,
|
|
31
33
|
ariaDescribedby = _a['aria-describedby'],
|
|
32
|
-
rest = __rest(_a, ["label", "disabled", "readOnly", "errorMessage", "tip", "required", "maxLength", "multiline", "onChange", "id", "width", "type", "className", "style", 'aria-describedby']);
|
|
34
|
+
rest = __rest(_a, ["label", "disabled", "readOnly", "errorMessage", "tip", "required", "maxLength", "multiline", "onChange", "id", "width", "type", "withCharacterCounter", "className", "style", 'aria-describedby']);
|
|
33
35
|
|
|
34
36
|
var textAreaRef = useRef(null);
|
|
35
37
|
|
|
@@ -69,7 +71,7 @@ var TextInput = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
69
71
|
var hasLabel = !!label;
|
|
70
72
|
var labelPresence = hasLabel ? 'hasLabel' : 'noLabel';
|
|
71
73
|
var hasMessage = hasErrorMessage || hasTip || !!maxLength;
|
|
72
|
-
var characterCounterId = derivativeIdGenerator(uniqueId, 'characterCounter', maxLength);
|
|
74
|
+
var characterCounterId = derivativeIdGenerator(uniqueId, 'characterCounter', maxLength && withCharacterCounter);
|
|
73
75
|
var tipId = derivativeIdGenerator(uniqueId, 'tip', tip);
|
|
74
76
|
var errorMessageId = derivativeIdGenerator(uniqueId, 'errorMessage', errorMessage);
|
|
75
77
|
var generalInputProps = Object.assign({
|
|
@@ -125,7 +127,7 @@ var TextInput = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
125
127
|
message: tip,
|
|
126
128
|
messageType: "tip",
|
|
127
129
|
id: tipId
|
|
128
|
-
}), maxLength && Number.isInteger(maxLength) && maxLength > 0 && jsx(CharCounter, {
|
|
130
|
+
}), maxLength && Number.isInteger(maxLength) && maxLength > 0 && withCharacterCounter && jsx(CharCounter, {
|
|
129
131
|
id: characterCounterId,
|
|
130
132
|
current: text.length,
|
|
131
133
|
max: maxLength
|
|
@@ -4,6 +4,7 @@ declare const _default: {
|
|
|
4
4
|
title: string;
|
|
5
5
|
component: import("react").ForwardRefExoticComponent<{
|
|
6
6
|
multiline?: boolean | undefined;
|
|
7
|
+
withCharacterCounter?: boolean | undefined;
|
|
7
8
|
} & {
|
|
8
9
|
label?: string | undefined;
|
|
9
10
|
width?: import("csstype").Property.Width<string> | undefined;
|
|
@@ -3,4 +3,6 @@ import { InputProps } from '../../helpers';
|
|
|
3
3
|
export declare type TextInputProps = {
|
|
4
4
|
/**Gjør inputfeltet om til `<textarea>`. */
|
|
5
5
|
multiline?: boolean;
|
|
6
|
+
/** Spesifiserer om tegntelleren skal vises. */
|
|
7
|
+
withCharacterCounter?: boolean;
|
|
6
8
|
} & InputProps & InputHTMLAttributes<HTMLTextAreaElement>;
|
|
@@ -2,6 +2,7 @@ import { ElementType, PropsWithChildren, HTMLAttributes, AnchorHTMLAttributes }
|
|
|
2
2
|
import { CSSObject } from 'styled-components';
|
|
3
3
|
import { TextColor, OtherTypographyType, AnchorTypographyType, LabelTypographyType } from './Typography.types';
|
|
4
4
|
import { BaseComponentProps } from '../../types';
|
|
5
|
+
export declare const inlineElements: ElementType[];
|
|
5
6
|
export declare function isTextColor(color: string): color is TextColor;
|
|
6
7
|
export declare const getTextColor: (color: TextColor | string) => string;
|
|
7
8
|
export declare type TypographyInteractionProps = {
|
|
@@ -61,6 +61,12 @@ var getElementType = function getElementType(element) {
|
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
+
var inlineElements = ['a', 'abbr', 'audio', 'b', 'bdi', 'bdo', 'big', 'br', 'button', 'canvas', 'cite', 'code', 'data', 'datalist', 'del', 'dfn', 'em', 'embed', 'i', 'iframe', 'img', 'input', 'ins', 'kbd', 'label', 'map', 'mark', 'meter', 'noscript', 'object', 'output', 'picture', 'progress', 'q', 'ruby', 's', 'samp', 'script', 'select', 'slot', 'small', 'span', 'strong', 'sub', 'sup', 'svg', 'template', 'textarea', 'time', 'u', 'var', 'video', 'wbr'];
|
|
65
|
+
|
|
66
|
+
var isInlineElement = function isInlineElement(as) {
|
|
67
|
+
return inlineElements.indexOf(as) !== -1;
|
|
68
|
+
};
|
|
69
|
+
|
|
64
70
|
function isTextColor(color) {
|
|
65
71
|
return textColorsArray.indexOf(color) !== -1;
|
|
66
72
|
}
|
|
@@ -95,8 +101,9 @@ var StyledTypography = styled.p.withConfig({
|
|
|
95
101
|
return interactionProps && interactionProps.active && css(["&:active{", "}"], interactionProps.active);
|
|
96
102
|
}, function (_ref5) {
|
|
97
103
|
var withMargins = _ref5.withMargins,
|
|
98
|
-
typographyType = _ref5.typographyType
|
|
99
|
-
|
|
104
|
+
typographyType = _ref5.typographyType,
|
|
105
|
+
as = _ref5.as;
|
|
106
|
+
return withMargins && typographyType && isInlineElement(as) ? css(["", " display:block;"], typographyTokens.typographyType[typographyType].margins.base) : withMargins && typographyType ? css(["", ""], typographyTokens.typographyType[typographyType].margins.base) : css(["margin:0;"]);
|
|
100
107
|
}, function (_ref6) {
|
|
101
108
|
var color = _ref6.color;
|
|
102
109
|
return color && css(["color:", ";"], getTextColor(color));
|
|
@@ -162,4 +169,4 @@ var Typography = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
162
169
|
}));
|
|
163
170
|
});
|
|
164
171
|
|
|
165
|
-
export { Typography, getTextColor, isTextColor };
|
|
172
|
+
export { Typography, getTextColor, inlineElements, isTextColor };
|
|
@@ -9,4 +9,5 @@ export declare type LabelTypographyType = 'supportingStyleLabel01';
|
|
|
9
9
|
export declare type OtherTypographyType = TypographyHeadingType | TypographyBodyType | TypographyLeadType | TypographySupportingType;
|
|
10
10
|
export declare type TypographyType = AnchorTypographyType | LabelTypographyType | OtherTypographyType;
|
|
11
11
|
export declare type TextColor = 'interactive' | 'primary' | 'danger' | 'warning' | 'success' | 'onLight' | 'onDark' | 'gray1' | 'gray2' | 'gray3' | 'gray4' | 'gray5' | 'gray6' | 'gray7' | 'gray8' | 'gray9';
|
|
12
|
+
export declare type InlineElement = 'a' | 'abbr' | 'audio' | 'b' | 'bdi' | 'bdo' | 'big' | 'br' | 'button' | 'canvas' | 'cite' | 'code' | 'data' | 'datalist' | 'del' | 'dfn' | 'em' | 'embed' | 'i' | 'iframe' | 'img' | 'input' | 'ins' | 'kbd' | 'label' | 'map' | 'mark' | 'meter' | 'noscript' | 'object' | 'output' | 'picture' | 'progress' | 'q' | 'ruby' | 's' | 'samp' | 'script' | 'select' | 'slot' | 'small' | 'span' | 'strong' | 'sub' | 'sup' | 'svg' | 'template' | 'textarea' | 'time' | 'u' | 'var' | 'video' | 'wbr';
|
|
12
13
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ export { Select, createSelectOptions, searchFilter } from './components/Select/S
|
|
|
9
9
|
export { GlobalMessage } from './components/GlobalMessage/GlobalMessage.js';
|
|
10
10
|
export { LocalMessage } from './components/LocalMessage/LocalMessage.js';
|
|
11
11
|
export { Search } from './components/Search/Search.js';
|
|
12
|
-
export { Typography, getTextColor, isTextColor } from './components/Typography/Typography.js';
|
|
12
|
+
export { Typography, getTextColor, inlineElements, isTextColor } from './components/Typography/Typography.js';
|
|
13
13
|
export { Table } from './components/Table/Table.js';
|
|
14
14
|
export { Body } from './components/Table/Body.js';
|
|
15
15
|
export { Head } from './components/Table/Head.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const derivativeIdGenerator: (prefix: string, suffix: string, value?: string | number) => string | undefined;
|
|
1
|
+
export declare const derivativeIdGenerator: (prefix: string, suffix: string, value?: string | number | boolean) => string | undefined;
|
|
2
2
|
export declare const idArrayGenerator: (values: (string | undefined)[]) => string[] | undefined;
|
|
3
3
|
export declare const spaceSeparatedIdListGenerator: (values: (string | undefined)[]) => string | undefined;
|