@norges-domstoler/dds-components 13.0.3 → 13.1.1
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/InlineEdit/InlineEdit.styles.d.ts +6 -0
- package/dist/cjs/components/TextArea/TextArea.d.ts +3 -0
- package/dist/cjs/components/TextInput/TextInput.d.ts +2 -0
- package/dist/cjs/components/TextInput/TextInput.stories.d.ts +13 -0
- package/dist/cjs/components/TextInput/TextInput.styles.d.ts +3 -0
- package/dist/cjs/components/TextInput/TextInput.tokens.d.ts +5 -0
- package/dist/cjs/components/TextInput/TextInput.types.d.ts +13 -0
- package/dist/cjs/helpers/Input/Input.styles.d.ts +4 -0
- package/dist/cjs/helpers/Input/Input.tokens.d.ts +3 -0
- package/dist/cjs/helpers/Input/Input.types.d.ts +4 -1
- package/dist/cjs/index.js +103 -16
- package/dist/components/InlineEdit/InlineEdit.styles.d.ts +6 -0
- package/dist/components/TextArea/TextArea.d.ts +3 -0
- package/dist/components/TextInput/TextInput.d.ts +2 -0
- package/dist/components/TextInput/TextInput.js +79 -11
- package/dist/components/TextInput/TextInput.stories.d.ts +13 -0
- package/dist/components/TextInput/TextInput.styles.d.ts +3 -0
- package/dist/components/TextInput/TextInput.tokens.d.ts +5 -0
- package/dist/components/TextInput/TextInput.tokens.js +7 -1
- package/dist/components/TextInput/TextInput.types.d.ts +13 -0
- package/dist/helpers/Input/Input.styles.d.ts +4 -0
- package/dist/helpers/Input/Input.styles.js +19 -7
- package/dist/helpers/Input/Input.tokens.d.ts +3 -0
- package/dist/helpers/Input/Input.tokens.js +3 -0
- package/dist/helpers/Input/Input.types.d.ts +4 -1
- package/package.json +1 -1
|
@@ -6,9 +6,15 @@ type StyledInlineInputProps = {
|
|
|
6
6
|
};
|
|
7
7
|
export declare const StyledInlineInput: import("styled-components").StyledComponent<"input", any, Pick<import("../../helpers").InputProps, "disabled" | "readOnly"> & {
|
|
8
8
|
hasErrorMessage: boolean;
|
|
9
|
+
} & {
|
|
10
|
+
prefixLength?: number | undefined;
|
|
11
|
+
suffixLength?: number | undefined;
|
|
9
12
|
} & Pick<import("../../helpers").InputProps, "componentSize"> & StyledInlineInputProps, never>;
|
|
10
13
|
export declare const StyledInlineTextArea: import("styled-components").StyledComponent<"input", any, Pick<import("../../helpers").InputProps, "disabled" | "readOnly"> & {
|
|
11
14
|
hasErrorMessage: boolean;
|
|
15
|
+
} & {
|
|
16
|
+
prefixLength?: number | undefined;
|
|
17
|
+
suffixLength?: number | undefined;
|
|
12
18
|
} & Pick<import("../../helpers").InputProps, "componentSize"> & StyledInlineInputProps, never>;
|
|
13
19
|
export declare const IconWrapper: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
14
20
|
export {};
|
|
@@ -2,6 +2,9 @@ import { TextareaHTMLAttributes } from 'react';
|
|
|
2
2
|
import { CommonInputProps } from '../../helpers/Input';
|
|
3
3
|
export declare const StyledTextArea: import("styled-components").StyledComponent<"input", any, Pick<import("../../helpers/Input").InputProps, "disabled" | "readOnly"> & {
|
|
4
4
|
hasErrorMessage: boolean;
|
|
5
|
+
} & {
|
|
6
|
+
prefixLength?: number | undefined;
|
|
7
|
+
suffixLength?: number | undefined;
|
|
5
8
|
} & Pick<import("../../helpers/Input").InputProps, "componentSize">, never>;
|
|
6
9
|
export type TextAreaProps = CommonInputProps & TextareaHTMLAttributes<HTMLTextAreaElement>;
|
|
7
10
|
export declare const TextArea: import("react").ForwardRefExoticComponent<CommonInputProps & TextareaHTMLAttributes<HTMLTextAreaElement> & import("react").RefAttributes<HTMLTextAreaElement>>;
|
|
@@ -5,4 +5,6 @@ export declare const TextInput: React.ForwardRefExoticComponent<import("../../he
|
|
|
5
5
|
} & React.InputHTMLAttributes<HTMLInputElement> & {
|
|
6
6
|
withCharacterCounter?: boolean | undefined;
|
|
7
7
|
icon?: import("../../icons/utils").SvgIcon | undefined;
|
|
8
|
+
prefix?: string | undefined;
|
|
9
|
+
suffix?: string | undefined;
|
|
8
10
|
} & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -6,6 +6,8 @@ declare const _default: {
|
|
|
6
6
|
} & import("react").InputHTMLAttributes<HTMLInputElement> & {
|
|
7
7
|
withCharacterCounter?: boolean | undefined;
|
|
8
8
|
icon?: import("../../icons/utils").SvgIcon | undefined;
|
|
9
|
+
prefix?: string | undefined;
|
|
10
|
+
suffix?: string | undefined;
|
|
9
11
|
} & import("react").RefAttributes<HTMLInputElement>>;
|
|
10
12
|
argTypes: {
|
|
11
13
|
label: {
|
|
@@ -43,6 +45,16 @@ declare const _default: {
|
|
|
43
45
|
type: string;
|
|
44
46
|
};
|
|
45
47
|
};
|
|
48
|
+
prefix: {
|
|
49
|
+
control: {
|
|
50
|
+
type: string;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
suffix: {
|
|
54
|
+
control: {
|
|
55
|
+
type: string;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
46
58
|
};
|
|
47
59
|
parameters: {
|
|
48
60
|
controls: {
|
|
@@ -56,3 +68,4 @@ export declare const TextInputOverviewSizes: () => JSX.Element;
|
|
|
56
68
|
export declare const Default: (args: TextInputProps) => JSX.Element;
|
|
57
69
|
export declare const WithLabel: (args: TextInputProps) => JSX.Element;
|
|
58
70
|
export declare const WithCharacterCount: (args: TextInputProps) => JSX.Element;
|
|
71
|
+
export declare const TextInputAffixes: (args: TextInputProps) => JSX.Element;
|
|
@@ -10,5 +10,8 @@ type StyledInputProps = {
|
|
|
10
10
|
};
|
|
11
11
|
export declare const StyledInput: import("styled-components").StyledComponent<"input", any, Pick<import("../../helpers").InputProps, "disabled" | "readOnly"> & {
|
|
12
12
|
hasErrorMessage: boolean;
|
|
13
|
+
} & {
|
|
14
|
+
prefixLength?: number | undefined;
|
|
15
|
+
suffixLength?: number | undefined;
|
|
13
16
|
} & Pick<import("../../helpers").InputProps, "componentSize"> & StyledInputProps, never>;
|
|
14
17
|
export {};
|
|
@@ -5,4 +5,17 @@ export type TextInputProps = InputProps & {
|
|
|
5
5
|
withCharacterCounter?: boolean;
|
|
6
6
|
/** Ikonet som vises i komponenten. */
|
|
7
7
|
icon?: SvgIcon;
|
|
8
|
+
/**
|
|
9
|
+
* Prefiks som vises før inputfeltet.
|
|
10
|
+
* OBS! Prefiks leses ikke av skjermleser og skal derfor ikke brukes som en erstatter
|
|
11
|
+
* for en beskrivende label. */
|
|
12
|
+
prefix?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Suffiks som vises etter inputfeltet.
|
|
15
|
+
* OBS! Suffiks leses ikke av skjermleser og skal derfor ikke brukes som en erstatter
|
|
16
|
+
* for en beskrivende label. */
|
|
17
|
+
suffix?: string;
|
|
18
|
+
};
|
|
19
|
+
export type TextAffixProps = {
|
|
20
|
+
readOnly?: boolean;
|
|
8
21
|
};
|
|
@@ -2,6 +2,9 @@ import { Property } from 'csstype';
|
|
|
2
2
|
export declare const Input: import("styled-components").StyledComponent<"input", any, {}, never>;
|
|
3
3
|
export declare const StatefulInput: import("styled-components").StyledComponent<"input", any, Pick<import("./Input.types").InputProps, "disabled" | "readOnly"> & {
|
|
4
4
|
hasErrorMessage: boolean;
|
|
5
|
+
} & {
|
|
6
|
+
prefixLength?: number | undefined;
|
|
7
|
+
suffixLength?: number | undefined;
|
|
5
8
|
} & Pick<import("./Input.types").InputProps, "componentSize">, never>;
|
|
6
9
|
type OuterInputContainerProps = {
|
|
7
10
|
width?: Property.Width;
|
|
@@ -9,4 +12,5 @@ type OuterInputContainerProps = {
|
|
|
9
12
|
export declare const OuterInputContainer: import("styled-components").StyledComponent<"div", any, OuterInputContainerProps, never>;
|
|
10
13
|
/**Brukes som container til input og ikon for posisjonering. */
|
|
11
14
|
export declare const InputContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
15
|
+
export declare const InputAffixContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
12
16
|
export {};
|
|
@@ -19,7 +19,10 @@ export type InputProps = CommonInputProps & {
|
|
|
19
19
|
export type StyledCommonInputProps = Pick<InputProps, 'readOnly' | 'disabled'> & {
|
|
20
20
|
hasErrorMessage: boolean;
|
|
21
21
|
};
|
|
22
|
-
export type StyledInputProps = StyledCommonInputProps &
|
|
22
|
+
export type StyledInputProps = StyledCommonInputProps & {
|
|
23
|
+
prefixLength?: number;
|
|
24
|
+
suffixLength?: number;
|
|
25
|
+
} & Pick<InputProps, 'componentSize'>;
|
|
23
26
|
export type InputTypographyTypes = {
|
|
24
27
|
[k in InputSize]: StaticTypographyType;
|
|
25
28
|
};
|
package/dist/cjs/index.js
CHANGED
|
@@ -813,6 +813,9 @@ var input$5 = {
|
|
|
813
813
|
tiny: {
|
|
814
814
|
padding: "".concat(spacing$B.SizesDdsSpacingLocalX025, " ").concat(spacing$B.SizesDdsSpacingLocalX05, " ").concat(spacing$B.SizesDdsSpacingLocalX025, " ").concat(spacing$B.SizesDdsSpacingLocalX05)
|
|
815
815
|
}
|
|
816
|
+
},
|
|
817
|
+
affix: {
|
|
818
|
+
gap: spacing$B.SizesDdsSpacingLocalX1NumberPx
|
|
816
819
|
}
|
|
817
820
|
};
|
|
818
821
|
var container$g = {
|
|
@@ -832,18 +835,26 @@ var Input$2 = styled__default.default.input.withConfig({
|
|
|
832
835
|
var StatefulInput = styled__default.default(Input$2).withConfig({
|
|
833
836
|
displayName: "Inputstyles__StatefulInput",
|
|
834
837
|
componentId: "sc-1oz9x8w-1"
|
|
835
|
-
})(["-webkit-appearance:textfield;", " ", " &:enabled:read-only{border:none;outline:none;cursor:default;background-color:", ";padding-left:0;}&:disabled{cursor:not-allowed;color:", ";background-color:", ";}"], function (_ref) {
|
|
836
|
-
var
|
|
837
|
-
|
|
838
|
+
})(["-webkit-appearance:textfield;padding-left:", ";padding-right:", ";", " ", " &:enabled:read-only{border:none;outline:none;cursor:default;background-color:", ";padding-left:0;}&:disabled{cursor:not-allowed;color:", ";background-color:", ";}"], function (_ref) {
|
|
839
|
+
var prefixLength = _ref.prefixLength,
|
|
840
|
+
readOnly = _ref.readOnly;
|
|
841
|
+
return prefixLength && (readOnly ? "".concat(prefixLength, "px !important") : "calc(".concat(input$4.affix.gap, "px + ").concat(prefixLength, "px) !important"));
|
|
838
842
|
}, function (_ref2) {
|
|
839
|
-
var
|
|
843
|
+
var suffixLength = _ref2.suffixLength,
|
|
844
|
+
readOnly = _ref2.readOnly;
|
|
845
|
+
return suffixLength && (readOnly ? "".concat(suffixLength, "px !important") : "calc(".concat(input$4.affix.gap, "px + ").concat(suffixLength, "px) !important"));
|
|
846
|
+
}, function (_ref3) {
|
|
847
|
+
var componentSize = _ref3.componentSize;
|
|
848
|
+
return componentSize && styled.css(["padding:", ";", ""], input$4.sizes[componentSize].padding, getFontStyling(inputTypographyTypes[componentSize]));
|
|
849
|
+
}, function (_ref4) {
|
|
850
|
+
var hasErrorMessage = _ref4.hasErrorMessage;
|
|
840
851
|
return hasErrorMessage && styled.css(["", " &:hover:enabled:read-write{", "}&:focus:enabled:read-write,&:active:enabled:read-write{", "}"], dangerInputfield, hoverDangerInputfield, focusDangerInputfield);
|
|
841
852
|
}, input$4.readOnly.backgroundColor, input$4.disabled.color, input$4.disabled.backgroundColor);
|
|
842
853
|
var OuterInputContainer = styled__default.default.div.withConfig({
|
|
843
854
|
displayName: "Inputstyles__OuterInputContainer",
|
|
844
855
|
componentId: "sc-1oz9x8w-2"
|
|
845
|
-
})(["position:relative;gap:", ";width:", ";"], container$f.gap, function (
|
|
846
|
-
var width =
|
|
856
|
+
})(["position:relative;gap:", ";width:", ";"], container$f.gap, function (_ref5) {
|
|
857
|
+
var width = _ref5.width;
|
|
847
858
|
return width;
|
|
848
859
|
});
|
|
849
860
|
/**Brukes som container til input og ikon for posisjonering. */
|
|
@@ -851,6 +862,10 @@ var InputContainer$1 = styled__default.default.div.withConfig({
|
|
|
851
862
|
displayName: "Inputstyles__InputContainer",
|
|
852
863
|
componentId: "sc-1oz9x8w-3"
|
|
853
864
|
})(["position:relative;"]);
|
|
865
|
+
var InputAffixContainer = styled__default.default.div.withConfig({
|
|
866
|
+
displayName: "Inputstyles__InputAffixContainer",
|
|
867
|
+
componentId: "sc-1oz9x8w-4"
|
|
868
|
+
})(["position:relative;display:flex;align-items:center;"]);
|
|
854
869
|
|
|
855
870
|
var getSize = function getSize(iconSize) {
|
|
856
871
|
switch (iconSize) {
|
|
@@ -4254,6 +4269,11 @@ var input$3 = {
|
|
|
4254
4269
|
}
|
|
4255
4270
|
}
|
|
4256
4271
|
};
|
|
4272
|
+
var affix = {
|
|
4273
|
+
border: {
|
|
4274
|
+
color: colors$o.DdsColorNeutralsGray5
|
|
4275
|
+
}
|
|
4276
|
+
};
|
|
4257
4277
|
var icon$9 = {
|
|
4258
4278
|
color: colors$o.DdsColorNeutralsGray9,
|
|
4259
4279
|
sizes: {
|
|
@@ -4273,7 +4293,8 @@ var icon$9 = {
|
|
|
4273
4293
|
};
|
|
4274
4294
|
var textInputTokens = {
|
|
4275
4295
|
input: input$3,
|
|
4276
|
-
icon: icon$9
|
|
4296
|
+
icon: icon$9,
|
|
4297
|
+
affix: affix
|
|
4277
4298
|
};
|
|
4278
4299
|
|
|
4279
4300
|
var iconSizes$4 = ddsDesignTokens.ddsBaseTokens.iconSizes;
|
|
@@ -4309,6 +4330,24 @@ var getWidth$1 = function getWidth(size, width) {
|
|
|
4309
4330
|
}
|
|
4310
4331
|
return defaultWidth$5;
|
|
4311
4332
|
};
|
|
4333
|
+
var Affix = styled__default.default.span.withConfig({
|
|
4334
|
+
displayName: "TextInput__Affix",
|
|
4335
|
+
componentId: "sc-k8umq3-0"
|
|
4336
|
+
})(["position:absolute;height:100%;top:50%;transform:translateY(-50%);display:flex;align-items:center;pointer-events:none;z-index:1;"]);
|
|
4337
|
+
var Prefix = styled__default.default(Affix).withConfig({
|
|
4338
|
+
displayName: "TextInput__Prefix",
|
|
4339
|
+
componentId: "sc-k8umq3-1"
|
|
4340
|
+
})(["left:0;margin-left:8px;padding-right:8px;border-right:1px solid ", ";", ";"], textInputTokens.affix.border.color, function (_ref) {
|
|
4341
|
+
var readOnly = _ref.readOnly;
|
|
4342
|
+
return readOnly && styled.css(["margin-left:0;padding-right:0.5ch;border-right:none;"]);
|
|
4343
|
+
});
|
|
4344
|
+
var Suffix = styled__default.default(Affix).withConfig({
|
|
4345
|
+
displayName: "TextInput__Suffix",
|
|
4346
|
+
componentId: "sc-k8umq3-2"
|
|
4347
|
+
})(["right:0;margin-right:8px;padding-left:8px;border-left:1px solid ", ";", ";"], textInputTokens.affix.border.color, function (_ref2) {
|
|
4348
|
+
var readOnly = _ref2.readOnly;
|
|
4349
|
+
return readOnly && styled.css(["margin-right:0;padding-left:0.5ch;border-left:none;"]);
|
|
4350
|
+
});
|
|
4312
4351
|
var TextInput = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
4313
4352
|
var label = _a.label,
|
|
4314
4353
|
disabled = _a.disabled,
|
|
@@ -4333,11 +4372,31 @@ var TextInput = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
4333
4372
|
ariaRequired = _a['aria-required'],
|
|
4334
4373
|
ariaDescribedby = _a['aria-describedby'],
|
|
4335
4374
|
icon = _a.icon,
|
|
4336
|
-
|
|
4375
|
+
prefix = _a.prefix,
|
|
4376
|
+
suffix = _a.suffix,
|
|
4377
|
+
rest = tslib.__rest(_a, ["label", "disabled", "readOnly", "errorMessage", "tip", "required", "maxLength", "onChange", "id", "width", "componentSize", "type", "withCharacterCounter", "className", "style", "value", "defaultValue", 'aria-required', 'aria-describedby', "icon", "prefix", "suffix"]);
|
|
4337
4378
|
var _useState = React.useState(getDefaultText(value, defaultValue)),
|
|
4338
4379
|
_useState2 = _slicedToArray(_useState, 2),
|
|
4339
4380
|
text = _useState2[0],
|
|
4340
4381
|
setText = _useState2[1];
|
|
4382
|
+
var prefixRef = React.useRef(null);
|
|
4383
|
+
var suffixRef = React.useRef(null);
|
|
4384
|
+
var _useState3 = React.useState(0),
|
|
4385
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
4386
|
+
prefixLength = _useState4[0],
|
|
4387
|
+
setPrefixLength = _useState4[1];
|
|
4388
|
+
var _useState5 = React.useState(0),
|
|
4389
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
4390
|
+
suffixLength = _useState6[0],
|
|
4391
|
+
setSuffixLength = _useState6[1];
|
|
4392
|
+
React.useLayoutEffect(function () {
|
|
4393
|
+
if (prefixRef.current) {
|
|
4394
|
+
setPrefixLength(prefixRef.current.offsetWidth);
|
|
4395
|
+
}
|
|
4396
|
+
if (suffixRef.current) {
|
|
4397
|
+
setSuffixLength(suffixRef.current.offsetWidth);
|
|
4398
|
+
}
|
|
4399
|
+
}, [prefix, suffix, readOnly]);
|
|
4341
4400
|
var onChangeHandler = function onChangeHandler(event) {
|
|
4342
4401
|
setText(event.target.value);
|
|
4343
4402
|
if (onChange) {
|
|
@@ -4351,6 +4410,7 @@ var TextInput = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
4351
4410
|
var hasLabel = !!label;
|
|
4352
4411
|
var hasMessage = hasErrorMessage || hasTip || !!maxLength;
|
|
4353
4412
|
var hasIcon = !!icon;
|
|
4413
|
+
var hasAffix = !!(prefix || suffix);
|
|
4354
4414
|
var characterCounterId = derivativeIdGenerator(uniqueId, 'characterCounter');
|
|
4355
4415
|
var tipId = derivativeIdGenerator(uniqueId, 'tip');
|
|
4356
4416
|
var errorMessageId = derivativeIdGenerator(uniqueId, 'errorMessage');
|
|
@@ -4375,13 +4435,9 @@ var TextInput = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
4375
4435
|
width: getWidth$1(componentSize, width)
|
|
4376
4436
|
};
|
|
4377
4437
|
var showRequiredStyling = !!(required || ariaRequired);
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
showRequiredStyling: showRequiredStyling
|
|
4382
|
-
}, {
|
|
4383
|
-
children: label
|
|
4384
|
-
})), hasIcon ? jsxRuntime.jsxs(InputContainer$1, {
|
|
4438
|
+
var extendedInput = null;
|
|
4439
|
+
if (hasIcon) {
|
|
4440
|
+
extendedInput = jsxRuntime.jsxs(InputContainer$1, {
|
|
4385
4441
|
children: [jsxRuntime.jsx(StyledIcon$3, {
|
|
4386
4442
|
icon: icon,
|
|
4387
4443
|
iconSize: getFormInputIconSize(componentSize),
|
|
@@ -4393,7 +4449,38 @@ var TextInput = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
4393
4449
|
componentSize: componentSize,
|
|
4394
4450
|
hasIcon: hasIcon
|
|
4395
4451
|
}, generalInputProps))]
|
|
4396
|
-
})
|
|
4452
|
+
});
|
|
4453
|
+
} else if (hasAffix) {
|
|
4454
|
+
extendedInput = jsxRuntime.jsxs(InputAffixContainer, {
|
|
4455
|
+
children: [prefix && jsxRuntime.jsx(Prefix, Object.assign({
|
|
4456
|
+
readOnly: readOnly,
|
|
4457
|
+
ref: prefixRef,
|
|
4458
|
+
"aria-hidden": true
|
|
4459
|
+
}, {
|
|
4460
|
+
children: prefix
|
|
4461
|
+
})), jsxRuntime.jsx(StatefulInput, Object.assign({
|
|
4462
|
+
ref: ref,
|
|
4463
|
+
onChange: onChangeHandler,
|
|
4464
|
+
type: type,
|
|
4465
|
+
componentSize: componentSize,
|
|
4466
|
+
prefixLength: prefixLength,
|
|
4467
|
+
suffixLength: suffixLength
|
|
4468
|
+
}, generalInputProps)), suffix && jsxRuntime.jsx(Suffix, Object.assign({
|
|
4469
|
+
readOnly: readOnly,
|
|
4470
|
+
ref: suffixRef,
|
|
4471
|
+
"aria-hidden": true
|
|
4472
|
+
}, {
|
|
4473
|
+
children: suffix
|
|
4474
|
+
}))]
|
|
4475
|
+
});
|
|
4476
|
+
}
|
|
4477
|
+
return jsxRuntime.jsxs(OuterInputContainer, Object.assign({}, outerInputContainerProps, {
|
|
4478
|
+
children: [hasLabel && jsxRuntime.jsx(Label$2, Object.assign({
|
|
4479
|
+
htmlFor: uniqueId,
|
|
4480
|
+
showRequiredStyling: showRequiredStyling
|
|
4481
|
+
}, {
|
|
4482
|
+
children: label
|
|
4483
|
+
})), extendedInput ? extendedInput : jsxRuntime.jsx(StatefulInput, Object.assign({
|
|
4397
4484
|
ref: ref,
|
|
4398
4485
|
onChange: onChangeHandler,
|
|
4399
4486
|
type: type,
|
|
@@ -6,9 +6,15 @@ type StyledInlineInputProps = {
|
|
|
6
6
|
};
|
|
7
7
|
export declare const StyledInlineInput: import("styled-components").StyledComponent<"input", any, Pick<import("../../helpers").InputProps, "disabled" | "readOnly"> & {
|
|
8
8
|
hasErrorMessage: boolean;
|
|
9
|
+
} & {
|
|
10
|
+
prefixLength?: number | undefined;
|
|
11
|
+
suffixLength?: number | undefined;
|
|
9
12
|
} & Pick<import("../../helpers").InputProps, "componentSize"> & StyledInlineInputProps, never>;
|
|
10
13
|
export declare const StyledInlineTextArea: import("styled-components").StyledComponent<"input", any, Pick<import("../../helpers").InputProps, "disabled" | "readOnly"> & {
|
|
11
14
|
hasErrorMessage: boolean;
|
|
15
|
+
} & {
|
|
16
|
+
prefixLength?: number | undefined;
|
|
17
|
+
suffixLength?: number | undefined;
|
|
12
18
|
} & Pick<import("../../helpers").InputProps, "componentSize"> & StyledInlineInputProps, never>;
|
|
13
19
|
export declare const IconWrapper: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
14
20
|
export {};
|
|
@@ -2,6 +2,9 @@ import { TextareaHTMLAttributes } from 'react';
|
|
|
2
2
|
import { CommonInputProps } from '../../helpers/Input';
|
|
3
3
|
export declare const StyledTextArea: import("styled-components").StyledComponent<"input", any, Pick<import("../../helpers/Input").InputProps, "disabled" | "readOnly"> & {
|
|
4
4
|
hasErrorMessage: boolean;
|
|
5
|
+
} & {
|
|
6
|
+
prefixLength?: number | undefined;
|
|
7
|
+
suffixLength?: number | undefined;
|
|
5
8
|
} & Pick<import("../../helpers/Input").InputProps, "componentSize">, never>;
|
|
6
9
|
export type TextAreaProps = CommonInputProps & TextareaHTMLAttributes<HTMLTextAreaElement>;
|
|
7
10
|
export declare const TextArea: import("react").ForwardRefExoticComponent<CommonInputProps & TextareaHTMLAttributes<HTMLTextAreaElement> & import("react").RefAttributes<HTMLTextAreaElement>>;
|
|
@@ -5,4 +5,6 @@ export declare const TextInput: React.ForwardRefExoticComponent<import("../../he
|
|
|
5
5
|
} & React.InputHTMLAttributes<HTMLInputElement> & {
|
|
6
6
|
withCharacterCounter?: boolean | undefined;
|
|
7
7
|
icon?: import("../../icons/utils").SvgIcon | undefined;
|
|
8
|
+
prefix?: string | undefined;
|
|
9
|
+
suffix?: string | undefined;
|
|
8
10
|
} & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -1,12 +1,12 @@
|
|
|
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, useState, useId } from 'react';
|
|
4
|
+
import { forwardRef, useState, useRef, useLayoutEffect, useId } from 'react';
|
|
5
5
|
import CharCounter from './CharCounter.js';
|
|
6
6
|
import '../../helpers/Backdrop/Backdrop.js';
|
|
7
7
|
import '../../helpers/Chevron/AnimatedChevronUpDown.styles.js';
|
|
8
8
|
import '../../helpers/HiddenInput/HiddenInput.js';
|
|
9
|
-
import {
|
|
9
|
+
import { InputContainer, InputAffixContainer, StatefulInput, OuterInputContainer } from '../../helpers/Input/Input.styles.js';
|
|
10
10
|
import '../../helpers/Input/Input.tokens.js';
|
|
11
11
|
import { getDefaultText, getFormInputIconSize, renderInputMessage } from '../../helpers/Input/Input.utils.js';
|
|
12
12
|
import '../../helpers/Paper/Paper.js';
|
|
@@ -19,6 +19,8 @@ import { StyledIcon, StyledInput, MessageContainer } from './TextInput.styles.js
|
|
|
19
19
|
import '../Typography/Typography/Typography.js';
|
|
20
20
|
import { Label } from '../Typography/Label/Label.js';
|
|
21
21
|
import '../Typography/Link/Link.js';
|
|
22
|
+
import styled, { css } from 'styled-components';
|
|
23
|
+
import { textInputTokens } from './TextInput.tokens.js';
|
|
22
24
|
|
|
23
25
|
var defaultWidth = '320px';
|
|
24
26
|
var defaultTinyWidth = '210px';
|
|
@@ -29,6 +31,24 @@ var getWidth = function getWidth(size, width) {
|
|
|
29
31
|
}
|
|
30
32
|
return defaultWidth;
|
|
31
33
|
};
|
|
34
|
+
var Affix = styled.span.withConfig({
|
|
35
|
+
displayName: "TextInput__Affix",
|
|
36
|
+
componentId: "sc-k8umq3-0"
|
|
37
|
+
})(["position:absolute;height:100%;top:50%;transform:translateY(-50%);display:flex;align-items:center;pointer-events:none;z-index:1;"]);
|
|
38
|
+
var Prefix = styled(Affix).withConfig({
|
|
39
|
+
displayName: "TextInput__Prefix",
|
|
40
|
+
componentId: "sc-k8umq3-1"
|
|
41
|
+
})(["left:0;margin-left:8px;padding-right:8px;border-right:1px solid ", ";", ";"], textInputTokens.affix.border.color, function (_ref) {
|
|
42
|
+
var readOnly = _ref.readOnly;
|
|
43
|
+
return readOnly && css(["margin-left:0;padding-right:0.5ch;border-right:none;"]);
|
|
44
|
+
});
|
|
45
|
+
var Suffix = styled(Affix).withConfig({
|
|
46
|
+
displayName: "TextInput__Suffix",
|
|
47
|
+
componentId: "sc-k8umq3-2"
|
|
48
|
+
})(["right:0;margin-right:8px;padding-left:8px;border-left:1px solid ", ";", ";"], textInputTokens.affix.border.color, function (_ref2) {
|
|
49
|
+
var readOnly = _ref2.readOnly;
|
|
50
|
+
return readOnly && css(["margin-right:0;padding-left:0.5ch;border-left:none;"]);
|
|
51
|
+
});
|
|
32
52
|
var TextInput = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
33
53
|
var label = _a.label,
|
|
34
54
|
disabled = _a.disabled,
|
|
@@ -53,11 +73,31 @@ var TextInput = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
53
73
|
ariaRequired = _a['aria-required'],
|
|
54
74
|
ariaDescribedby = _a['aria-describedby'],
|
|
55
75
|
icon = _a.icon,
|
|
56
|
-
|
|
76
|
+
prefix = _a.prefix,
|
|
77
|
+
suffix = _a.suffix,
|
|
78
|
+
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", "prefix", "suffix"]);
|
|
57
79
|
var _useState = useState(getDefaultText(value, defaultValue)),
|
|
58
80
|
_useState2 = _slicedToArray(_useState, 2),
|
|
59
81
|
text = _useState2[0],
|
|
60
82
|
setText = _useState2[1];
|
|
83
|
+
var prefixRef = useRef(null);
|
|
84
|
+
var suffixRef = useRef(null);
|
|
85
|
+
var _useState3 = useState(0),
|
|
86
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
87
|
+
prefixLength = _useState4[0],
|
|
88
|
+
setPrefixLength = _useState4[1];
|
|
89
|
+
var _useState5 = useState(0),
|
|
90
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
91
|
+
suffixLength = _useState6[0],
|
|
92
|
+
setSuffixLength = _useState6[1];
|
|
93
|
+
useLayoutEffect(function () {
|
|
94
|
+
if (prefixRef.current) {
|
|
95
|
+
setPrefixLength(prefixRef.current.offsetWidth);
|
|
96
|
+
}
|
|
97
|
+
if (suffixRef.current) {
|
|
98
|
+
setSuffixLength(suffixRef.current.offsetWidth);
|
|
99
|
+
}
|
|
100
|
+
}, [prefix, suffix, readOnly]);
|
|
61
101
|
var onChangeHandler = function onChangeHandler(event) {
|
|
62
102
|
setText(event.target.value);
|
|
63
103
|
if (onChange) {
|
|
@@ -71,6 +111,7 @@ var TextInput = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
71
111
|
var hasLabel = !!label;
|
|
72
112
|
var hasMessage = hasErrorMessage || hasTip || !!maxLength;
|
|
73
113
|
var hasIcon = !!icon;
|
|
114
|
+
var hasAffix = !!(prefix || suffix);
|
|
74
115
|
var characterCounterId = derivativeIdGenerator(uniqueId, 'characterCounter');
|
|
75
116
|
var tipId = derivativeIdGenerator(uniqueId, 'tip');
|
|
76
117
|
var errorMessageId = derivativeIdGenerator(uniqueId, 'errorMessage');
|
|
@@ -95,13 +136,9 @@ var TextInput = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
95
136
|
width: getWidth(componentSize, width)
|
|
96
137
|
};
|
|
97
138
|
var showRequiredStyling = !!(required || ariaRequired);
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
showRequiredStyling: showRequiredStyling
|
|
102
|
-
}, {
|
|
103
|
-
children: label
|
|
104
|
-
})), hasIcon ? jsxs(InputContainer, {
|
|
139
|
+
var extendedInput = null;
|
|
140
|
+
if (hasIcon) {
|
|
141
|
+
extendedInput = jsxs(InputContainer, {
|
|
105
142
|
children: [jsx(StyledIcon, {
|
|
106
143
|
icon: icon,
|
|
107
144
|
iconSize: getFormInputIconSize(componentSize),
|
|
@@ -113,7 +150,38 @@ var TextInput = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
113
150
|
componentSize: componentSize,
|
|
114
151
|
hasIcon: hasIcon
|
|
115
152
|
}, generalInputProps))]
|
|
116
|
-
})
|
|
153
|
+
});
|
|
154
|
+
} else if (hasAffix) {
|
|
155
|
+
extendedInput = jsxs(InputAffixContainer, {
|
|
156
|
+
children: [prefix && jsx(Prefix, Object.assign({
|
|
157
|
+
readOnly: readOnly,
|
|
158
|
+
ref: prefixRef,
|
|
159
|
+
"aria-hidden": true
|
|
160
|
+
}, {
|
|
161
|
+
children: prefix
|
|
162
|
+
})), jsx(StatefulInput, Object.assign({
|
|
163
|
+
ref: ref,
|
|
164
|
+
onChange: onChangeHandler,
|
|
165
|
+
type: type,
|
|
166
|
+
componentSize: componentSize,
|
|
167
|
+
prefixLength: prefixLength,
|
|
168
|
+
suffixLength: suffixLength
|
|
169
|
+
}, generalInputProps)), suffix && jsx(Suffix, Object.assign({
|
|
170
|
+
readOnly: readOnly,
|
|
171
|
+
ref: suffixRef,
|
|
172
|
+
"aria-hidden": true
|
|
173
|
+
}, {
|
|
174
|
+
children: suffix
|
|
175
|
+
}))]
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
return jsxs(OuterInputContainer, Object.assign({}, outerInputContainerProps, {
|
|
179
|
+
children: [hasLabel && jsx(Label, Object.assign({
|
|
180
|
+
htmlFor: uniqueId,
|
|
181
|
+
showRequiredStyling: showRequiredStyling
|
|
182
|
+
}, {
|
|
183
|
+
children: label
|
|
184
|
+
})), extendedInput ? extendedInput : jsx(StatefulInput, Object.assign({
|
|
117
185
|
ref: ref,
|
|
118
186
|
onChange: onChangeHandler,
|
|
119
187
|
type: type,
|
|
@@ -6,6 +6,8 @@ declare const _default: {
|
|
|
6
6
|
} & import("react").InputHTMLAttributes<HTMLInputElement> & {
|
|
7
7
|
withCharacterCounter?: boolean | undefined;
|
|
8
8
|
icon?: import("../../icons/utils").SvgIcon | undefined;
|
|
9
|
+
prefix?: string | undefined;
|
|
10
|
+
suffix?: string | undefined;
|
|
9
11
|
} & import("react").RefAttributes<HTMLInputElement>>;
|
|
10
12
|
argTypes: {
|
|
11
13
|
label: {
|
|
@@ -43,6 +45,16 @@ declare const _default: {
|
|
|
43
45
|
type: string;
|
|
44
46
|
};
|
|
45
47
|
};
|
|
48
|
+
prefix: {
|
|
49
|
+
control: {
|
|
50
|
+
type: string;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
suffix: {
|
|
54
|
+
control: {
|
|
55
|
+
type: string;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
46
58
|
};
|
|
47
59
|
parameters: {
|
|
48
60
|
controls: {
|
|
@@ -56,3 +68,4 @@ export declare const TextInputOverviewSizes: () => JSX.Element;
|
|
|
56
68
|
export declare const Default: (args: TextInputProps) => JSX.Element;
|
|
57
69
|
export declare const WithLabel: (args: TextInputProps) => JSX.Element;
|
|
58
70
|
export declare const WithCharacterCount: (args: TextInputProps) => JSX.Element;
|
|
71
|
+
export declare const TextInputAffixes: (args: TextInputProps) => JSX.Element;
|
|
@@ -10,5 +10,8 @@ type StyledInputProps = {
|
|
|
10
10
|
};
|
|
11
11
|
export declare const StyledInput: import("styled-components").StyledComponent<"input", any, Pick<import("../../helpers").InputProps, "disabled" | "readOnly"> & {
|
|
12
12
|
hasErrorMessage: boolean;
|
|
13
|
+
} & {
|
|
14
|
+
prefixLength?: number | undefined;
|
|
15
|
+
suffixLength?: number | undefined;
|
|
13
16
|
} & Pick<import("../../helpers").InputProps, "componentSize"> & StyledInputProps, never>;
|
|
14
17
|
export {};
|
|
@@ -16,6 +16,11 @@ var input = {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
|
+
var affix = {
|
|
20
|
+
border: {
|
|
21
|
+
color: colors.DdsColorNeutralsGray5
|
|
22
|
+
}
|
|
23
|
+
};
|
|
19
24
|
var icon = {
|
|
20
25
|
color: colors.DdsColorNeutralsGray9,
|
|
21
26
|
sizes: {
|
|
@@ -35,7 +40,8 @@ var icon = {
|
|
|
35
40
|
};
|
|
36
41
|
var textInputTokens = {
|
|
37
42
|
input: input,
|
|
38
|
-
icon: icon
|
|
43
|
+
icon: icon,
|
|
44
|
+
affix: affix
|
|
39
45
|
};
|
|
40
46
|
|
|
41
47
|
export { textInputTokens };
|
|
@@ -5,4 +5,17 @@ export type TextInputProps = InputProps & {
|
|
|
5
5
|
withCharacterCounter?: boolean;
|
|
6
6
|
/** Ikonet som vises i komponenten. */
|
|
7
7
|
icon?: SvgIcon;
|
|
8
|
+
/**
|
|
9
|
+
* Prefiks som vises før inputfeltet.
|
|
10
|
+
* OBS! Prefiks leses ikke av skjermleser og skal derfor ikke brukes som en erstatter
|
|
11
|
+
* for en beskrivende label. */
|
|
12
|
+
prefix?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Suffiks som vises etter inputfeltet.
|
|
15
|
+
* OBS! Suffiks leses ikke av skjermleser og skal derfor ikke brukes som en erstatter
|
|
16
|
+
* for en beskrivende label. */
|
|
17
|
+
suffix?: string;
|
|
18
|
+
};
|
|
19
|
+
export type TextAffixProps = {
|
|
20
|
+
readOnly?: boolean;
|
|
8
21
|
};
|
|
@@ -2,6 +2,9 @@ import { Property } from 'csstype';
|
|
|
2
2
|
export declare const Input: import("styled-components").StyledComponent<"input", any, {}, never>;
|
|
3
3
|
export declare const StatefulInput: import("styled-components").StyledComponent<"input", any, Pick<import("./Input.types").InputProps, "disabled" | "readOnly"> & {
|
|
4
4
|
hasErrorMessage: boolean;
|
|
5
|
+
} & {
|
|
6
|
+
prefixLength?: number | undefined;
|
|
7
|
+
suffixLength?: number | undefined;
|
|
5
8
|
} & Pick<import("./Input.types").InputProps, "componentSize">, never>;
|
|
6
9
|
type OuterInputContainerProps = {
|
|
7
10
|
width?: Property.Width;
|
|
@@ -9,4 +12,5 @@ type OuterInputContainerProps = {
|
|
|
9
12
|
export declare const OuterInputContainer: import("styled-components").StyledComponent<"div", any, OuterInputContainerProps, never>;
|
|
10
13
|
/**Brukes som container til input og ikon for posisjonering. */
|
|
11
14
|
export declare const InputContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
15
|
+
export declare const InputAffixContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
12
16
|
export {};
|
|
@@ -16,18 +16,26 @@ var Input = styled.input.withConfig({
|
|
|
16
16
|
var StatefulInput = styled(Input).withConfig({
|
|
17
17
|
displayName: "Inputstyles__StatefulInput",
|
|
18
18
|
componentId: "sc-1oz9x8w-1"
|
|
19
|
-
})(["-webkit-appearance:textfield;", " ", " &:enabled:read-only{border:none;outline:none;cursor:default;background-color:", ";padding-left:0;}&:disabled{cursor:not-allowed;color:", ";background-color:", ";}"], function (_ref) {
|
|
20
|
-
var
|
|
21
|
-
|
|
19
|
+
})(["-webkit-appearance:textfield;padding-left:", ";padding-right:", ";", " ", " &:enabled:read-only{border:none;outline:none;cursor:default;background-color:", ";padding-left:0;}&:disabled{cursor:not-allowed;color:", ";background-color:", ";}"], function (_ref) {
|
|
20
|
+
var prefixLength = _ref.prefixLength,
|
|
21
|
+
readOnly = _ref.readOnly;
|
|
22
|
+
return prefixLength && (readOnly ? "".concat(prefixLength, "px !important") : "calc(".concat(input.affix.gap, "px + ").concat(prefixLength, "px) !important"));
|
|
22
23
|
}, function (_ref2) {
|
|
23
|
-
var
|
|
24
|
+
var suffixLength = _ref2.suffixLength,
|
|
25
|
+
readOnly = _ref2.readOnly;
|
|
26
|
+
return suffixLength && (readOnly ? "".concat(suffixLength, "px !important") : "calc(".concat(input.affix.gap, "px + ").concat(suffixLength, "px) !important"));
|
|
27
|
+
}, function (_ref3) {
|
|
28
|
+
var componentSize = _ref3.componentSize;
|
|
29
|
+
return componentSize && css(["padding:", ";", ""], input.sizes[componentSize].padding, getFontStyling(inputTypographyTypes[componentSize]));
|
|
30
|
+
}, function (_ref4) {
|
|
31
|
+
var hasErrorMessage = _ref4.hasErrorMessage;
|
|
24
32
|
return hasErrorMessage && css(["", " &:hover:enabled:read-write{", "}&:focus:enabled:read-write,&:active:enabled:read-write{", "}"], dangerInputfield, hoverDangerInputfield, focusDangerInputfield);
|
|
25
33
|
}, input.readOnly.backgroundColor, input.disabled.color, input.disabled.backgroundColor);
|
|
26
34
|
var OuterInputContainer = styled.div.withConfig({
|
|
27
35
|
displayName: "Inputstyles__OuterInputContainer",
|
|
28
36
|
componentId: "sc-1oz9x8w-2"
|
|
29
|
-
})(["position:relative;gap:", ";width:", ";"], container.gap, function (
|
|
30
|
-
var width =
|
|
37
|
+
})(["position:relative;gap:", ";width:", ";"], container.gap, function (_ref5) {
|
|
38
|
+
var width = _ref5.width;
|
|
31
39
|
return width;
|
|
32
40
|
});
|
|
33
41
|
/**Brukes som container til input og ikon for posisjonering. */
|
|
@@ -35,5 +43,9 @@ var InputContainer = styled.div.withConfig({
|
|
|
35
43
|
displayName: "Inputstyles__InputContainer",
|
|
36
44
|
componentId: "sc-1oz9x8w-3"
|
|
37
45
|
})(["position:relative;"]);
|
|
46
|
+
var InputAffixContainer = styled.div.withConfig({
|
|
47
|
+
displayName: "Inputstyles__InputAffixContainer",
|
|
48
|
+
componentId: "sc-1oz9x8w-4"
|
|
49
|
+
})(["position:relative;display:flex;align-items:center;"]);
|
|
38
50
|
|
|
39
|
-
export { Input, InputContainer, OuterInputContainer, StatefulInput };
|
|
51
|
+
export { Input, InputAffixContainer, InputContainer, OuterInputContainer, StatefulInput };
|
|
@@ -35,6 +35,9 @@ var input = {
|
|
|
35
35
|
tiny: {
|
|
36
36
|
padding: "".concat(spacing.SizesDdsSpacingLocalX025, " ").concat(spacing.SizesDdsSpacingLocalX05, " ").concat(spacing.SizesDdsSpacingLocalX025, " ").concat(spacing.SizesDdsSpacingLocalX05)
|
|
37
37
|
}
|
|
38
|
+
},
|
|
39
|
+
affix: {
|
|
40
|
+
gap: spacing.SizesDdsSpacingLocalX1NumberPx
|
|
38
41
|
}
|
|
39
42
|
};
|
|
40
43
|
var container = {
|
|
@@ -19,7 +19,10 @@ export type InputProps = CommonInputProps & {
|
|
|
19
19
|
export type StyledCommonInputProps = Pick<InputProps, 'readOnly' | 'disabled'> & {
|
|
20
20
|
hasErrorMessage: boolean;
|
|
21
21
|
};
|
|
22
|
-
export type StyledInputProps = StyledCommonInputProps &
|
|
22
|
+
export type StyledInputProps = StyledCommonInputProps & {
|
|
23
|
+
prefixLength?: number;
|
|
24
|
+
suffixLength?: number;
|
|
25
|
+
} & Pick<InputProps, 'componentSize'>;
|
|
23
26
|
export type InputTypographyTypes = {
|
|
24
27
|
[k in InputSize]: StaticTypographyType;
|
|
25
28
|
};
|