@norges-domstoler/dds-components 12.1.3 → 13.0.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/Button/Button.d.ts +1 -0
- package/dist/cjs/components/Button/Button.stories.d.ts +1 -0
- package/dist/cjs/components/Button/Button.types.d.ts +2 -0
- package/dist/cjs/components/LocalMessage/LocalMessage.stories.d.ts +1 -0
- package/dist/cjs/components/LocalMessage/LocalMessage.tokens.d.ts +23 -20
- package/dist/cjs/components/ProgressTracker/ProgressTracker.d.ts +0 -2
- package/dist/cjs/components/ProgressTracker/ProgressTracker.stories.d.ts +1 -2
- package/dist/cjs/components/Search/Search.tokens.d.ts +6 -1
- package/dist/cjs/components/Search/Search.utils.d.ts +9 -0
- package/dist/cjs/components/Spinner/Spinner.d.ts +2 -0
- package/dist/cjs/components/Spinner/Spinner.stories.d.ts +7 -1
- package/dist/cjs/components/Stack/Stack.d.ts +3 -5
- package/dist/cjs/index.js +214 -186
- package/dist/components/Button/Button.d.ts +1 -0
- package/dist/components/Button/Button.js +5 -2
- package/dist/components/Button/Button.stories.d.ts +1 -0
- package/dist/components/Button/Button.types.d.ts +2 -0
- package/dist/components/LocalMessage/LocalMessage.js +64 -65
- package/dist/components/LocalMessage/LocalMessage.stories.d.ts +1 -0
- package/dist/components/LocalMessage/LocalMessage.tokens.d.ts +23 -20
- package/dist/components/LocalMessage/LocalMessage.tokens.js +4 -21
- package/dist/components/ProgressTracker/ProgressTracker.d.ts +0 -2
- package/dist/components/ProgressTracker/ProgressTracker.js +2 -4
- package/dist/components/ProgressTracker/ProgressTracker.stories.d.ts +1 -2
- package/dist/components/ProgressTracker/ProgressTrackerItem.js +5 -23
- package/dist/components/Search/Search.js +40 -16
- package/dist/components/Search/Search.tokens.d.ts +6 -1
- package/dist/components/Search/Search.tokens.js +9 -3
- package/dist/components/Search/Search.utils.d.ts +9 -0
- package/dist/components/Search/Search.utils.js +35 -0
- package/dist/components/Spinner/Spinner.d.ts +2 -0
- package/dist/components/Spinner/Spinner.js +5 -3
- package/dist/components/Spinner/Spinner.stories.d.ts +7 -1
- package/dist/components/Stack/Stack.d.ts +3 -5
- package/package.json +3 -3
|
@@ -6,6 +6,7 @@ export declare const Button: import("react").ForwardRefExoticComponent<Pick<Omit
|
|
|
6
6
|
iconPosition?: import("./Button.types").IconPosition | undefined;
|
|
7
7
|
appearance?: import("./Button.types").ButtonAppearance | undefined;
|
|
8
8
|
loading?: boolean | undefined;
|
|
9
|
+
loadingTooltip?: string | undefined;
|
|
9
10
|
icon?: import("../../icons/utils").SvgIcon | undefined;
|
|
10
11
|
fullWidth?: boolean | undefined;
|
|
11
12
|
href?: string | undefined;
|
|
@@ -24,6 +24,8 @@ var Button = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
24
24
|
target = props.target,
|
|
25
25
|
_props$loading = props.loading,
|
|
26
26
|
loading = _props$loading === void 0 ? false : _props$loading,
|
|
27
|
+
_props$loadingTooltip = props.loadingTooltip,
|
|
28
|
+
loadingTooltip = _props$loadingTooltip === void 0 ? 'Lagring pågår' : _props$loadingTooltip,
|
|
27
29
|
_props$fullWidth = props.fullWidth,
|
|
28
30
|
fullWidth = _props$fullWidth === void 0 ? false : _props$fullWidth,
|
|
29
31
|
icon = props.icon,
|
|
@@ -33,7 +35,7 @@ var Button = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
33
35
|
id = props.id,
|
|
34
36
|
className = props.className,
|
|
35
37
|
htmlProps = props.htmlProps,
|
|
36
|
-
rest = __rest(props, ["label", "purpose", "size", "iconPosition", "appearance", "href", "target", "loading", "fullWidth", "icon", "onClick", "onFocus", "onBlur", "id", "className", "htmlProps"]);
|
|
38
|
+
rest = __rest(props, ["label", "purpose", "size", "iconPosition", "appearance", "href", "target", "loading", "loadingTooltip", "fullWidth", "icon", "onClick", "onFocus", "onBlur", "id", "className", "htmlProps"]);
|
|
37
39
|
var as = href ? 'a' : 'button';
|
|
38
40
|
var hasLabel = !!label;
|
|
39
41
|
var hasIcon = !!icon;
|
|
@@ -87,7 +89,8 @@ var Button = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
87
89
|
}, {
|
|
88
90
|
children: jsx(Spinner, {
|
|
89
91
|
color: appearances[appearance].purpose[purpose].base.color,
|
|
90
|
-
size: sizes[size].justIcon.icon.fontSize
|
|
92
|
+
size: sizes[size].justIcon.icon.fontSize,
|
|
93
|
+
tooltip: loadingTooltip
|
|
91
94
|
})
|
|
92
95
|
}))]
|
|
93
96
|
}));
|
|
@@ -8,6 +8,7 @@ declare const _default: {
|
|
|
8
8
|
iconPosition?: import("./Button.types").IconPosition | undefined;
|
|
9
9
|
appearance?: import("./Button.types").ButtonAppearance | undefined;
|
|
10
10
|
loading?: boolean | undefined;
|
|
11
|
+
loadingTooltip?: string | undefined;
|
|
11
12
|
icon?: import("../../icons/utils").SvgIcon | undefined;
|
|
12
13
|
fullWidth?: boolean | undefined;
|
|
13
14
|
href?: string | undefined;
|
|
@@ -19,6 +19,8 @@ export type ButtonProps = BaseComponentProps<HTMLButtonElement, {
|
|
|
19
19
|
appearance?: ButtonAppearance;
|
|
20
20
|
/**Indikerer en loading-knapp. */
|
|
21
21
|
loading?: boolean;
|
|
22
|
+
/**Tooltip som vises ved loading. */
|
|
23
|
+
loadingTooltip?: string;
|
|
22
24
|
/**Ikonet som ligger i knappen. */
|
|
23
25
|
icon?: SvgIcon;
|
|
24
26
|
/**Knapp med full bredde. */
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { slicedToArray as _slicedToArray } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
2
|
import { __rest } from 'tslib';
|
|
3
|
-
import { jsx,
|
|
3
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
4
4
|
import styled, { css } from 'styled-components';
|
|
5
5
|
import { Button } from '../Button/Button.js';
|
|
6
6
|
import { forwardRef, useState } from 'react';
|
|
7
|
-
import { localMessageTokens
|
|
7
|
+
import { localMessageTokens } from './LocalMessage.tokens.js';
|
|
8
8
|
import { Icon } from '../Icon/Icon.js';
|
|
9
9
|
import { Typography } from '../Typography/Typography/Typography.js';
|
|
10
10
|
import '../../helpers/Backdrop/Backdrop.js';
|
|
@@ -31,45 +31,57 @@ import { getFontStyling, defaultTypographyType } from '../Typography/Typography.
|
|
|
31
31
|
|
|
32
32
|
var defaultWidth = '400px';
|
|
33
33
|
var container = localMessageTokens.container,
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
icon = localMessageTokens.icon,
|
|
35
|
+
purposeVariants = localMessageTokens.purposeVariants;
|
|
36
36
|
var Container = styled.div.withConfig({
|
|
37
37
|
displayName: "LocalMessage__Container",
|
|
38
38
|
componentId: "sc-kmfp8w-0"
|
|
39
|
-
})(["box-sizing:border-box;display:
|
|
40
|
-
var layout = _ref.layout
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
})(["box-sizing:border-box;display:grid;grid-template-areas:", ";grid-template-columns:", ";box-shadow:", ";border:", ";border-radius:", ";padding:", ";gap:", ";align-items:center;", " *::selection{", "}", " width:", ";"], function (_ref) {
|
|
40
|
+
var layout = _ref.layout,
|
|
41
|
+
closable = _ref.closable;
|
|
42
|
+
return getGridTemplateAreas(layout, closable);
|
|
43
|
+
}, function (_ref2) {
|
|
44
|
+
var layout = _ref2.layout,
|
|
45
|
+
closable = _ref2.closable;
|
|
46
|
+
return getGridTemplateColumns(layout, closable);
|
|
47
|
+
}, container.base.boxShadow, container.base.border, container.base.borderRadius, container.base.padding, container.base.gap, getFontStyling(defaultTypographyType, true), selection, function (_ref3) {
|
|
46
48
|
var purpose = _ref3.purpose;
|
|
47
49
|
return purpose && css(["border-color:", ";background-color:", ";"], container.purpose[purpose].borderColor, container.purpose[purpose].backgroundColor);
|
|
48
50
|
}, function (_ref4) {
|
|
49
51
|
var width = _ref4.width;
|
|
50
52
|
return width;
|
|
51
53
|
});
|
|
54
|
+
function getGridTemplateAreas(layout, closeable) {
|
|
55
|
+
if (closeable) {
|
|
56
|
+
if (layout === 'horisontal') {
|
|
57
|
+
return '"icon text closeButton"';
|
|
58
|
+
}
|
|
59
|
+
return '"icon closeButton" "text text"';
|
|
60
|
+
} else {
|
|
61
|
+
if (layout === 'horisontal') {
|
|
62
|
+
return '"icon text"';
|
|
63
|
+
}
|
|
64
|
+
return '"icon icon" "text text"';
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function getGridTemplateColumns(layout, closable) {
|
|
68
|
+
if (closable) {
|
|
69
|
+
return layout === 'horisontal' ? 'min-content 1fr min-content' : '1fr min-content';
|
|
70
|
+
}
|
|
71
|
+
return layout === 'horisontal' ? 'min-content 1fr' : '1fr';
|
|
72
|
+
}
|
|
52
73
|
var MessageIconWrapper = styled(Icon).withConfig({
|
|
53
74
|
displayName: "LocalMessage__MessageIconWrapper",
|
|
54
75
|
componentId: "sc-kmfp8w-1"
|
|
55
|
-
})(["
|
|
56
|
-
var
|
|
57
|
-
displayName: "
|
|
76
|
+
})(["grid-area:icon;"]);
|
|
77
|
+
var TextContainer = styled.div.withConfig({
|
|
78
|
+
displayName: "LocalMessage__TextContainer",
|
|
58
79
|
componentId: "sc-kmfp8w-2"
|
|
59
|
-
})(["
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}, function (_ref6) {
|
|
63
|
-
var layout = _ref6.layout;
|
|
64
|
-
return layout === 'vertical' ? css(["padding-bottom:", ";"], contentContainer.vertical.paddingBottom) : css(["display:flex;align-items:center;padding-bottom:", ";"], contentContainer.paddingBottom);
|
|
65
|
-
});
|
|
66
|
-
var TopContainer = styled.div.withConfig({
|
|
67
|
-
displayName: "LocalMessage__TopContainer",
|
|
80
|
+
})(["grid-area:text;"]);
|
|
81
|
+
var CloseButton = styled(Button).withConfig({
|
|
82
|
+
displayName: "LocalMessage__CloseButton",
|
|
68
83
|
componentId: "sc-kmfp8w-3"
|
|
69
|
-
})(["
|
|
70
|
-
var closable = _ref7.closable;
|
|
71
|
-
return closable ? topContainer.withClosable.paddingTop : topContainer.paddingTop;
|
|
72
|
-
});
|
|
84
|
+
})(["grid-area:closeButton;margin:-", " 0;"], container.base.padding);
|
|
73
85
|
var LocalMessage = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
74
86
|
var message = props.message,
|
|
75
87
|
_props$purpose = props.purpose,
|
|
@@ -93,47 +105,34 @@ var LocalMessage = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
93
105
|
purpose: purpose,
|
|
94
106
|
width: width,
|
|
95
107
|
layout: layout,
|
|
108
|
+
closable: closable,
|
|
96
109
|
ref: ref
|
|
97
110
|
});
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}, {
|
|
109
|
-
children: message
|
|
110
|
-
}));
|
|
111
|
-
var closeButton = closable && jsx(Button, {
|
|
112
|
-
icon: CloseIcon,
|
|
113
|
-
purpose: purposeVariants[purpose].closeButtonPurpose,
|
|
114
|
-
appearance: "borderless",
|
|
115
|
-
onClick: function onClick() {
|
|
116
|
-
setClosed(true);
|
|
117
|
-
onClose && onClose();
|
|
118
|
-
},
|
|
119
|
-
size: "small",
|
|
120
|
-
"aria-label": "Lukk melding"
|
|
121
|
-
});
|
|
122
|
-
return !isClosed ? jsx(Container, Object.assign({}, containerProps, {
|
|
123
|
-
children: layout === 'horisontal' ? jsxs(Fragment, {
|
|
124
|
-
children: [jsxs(ContentContainer, Object.assign({}, contentContainerProps, {
|
|
125
|
-
children: [messageIconWrapper, " ", content]
|
|
126
|
-
})), closeButton]
|
|
127
|
-
}) : jsxs(Fragment, {
|
|
128
|
-
children: [jsxs(TopContainer, Object.assign({
|
|
129
|
-
closable: closable
|
|
111
|
+
if (isClosed) {
|
|
112
|
+
return jsx(Fragment, {});
|
|
113
|
+
}
|
|
114
|
+
return jsxs(Container, Object.assign({}, containerProps, {
|
|
115
|
+
children: [jsx(MessageIconWrapper, {
|
|
116
|
+
icon: purposeVariants[purpose].icon,
|
|
117
|
+
color: icon[purpose].color
|
|
118
|
+
}), jsx(TextContainer, {
|
|
119
|
+
children: children !== null && children !== void 0 ? children : jsx(Typography, Object.assign({
|
|
120
|
+
as: "span"
|
|
130
121
|
}, {
|
|
131
|
-
children:
|
|
132
|
-
}))
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
122
|
+
children: message
|
|
123
|
+
}))
|
|
124
|
+
}), closable && jsx(CloseButton, {
|
|
125
|
+
icon: CloseIcon,
|
|
126
|
+
purpose: purposeVariants[purpose].closeButtonPurpose,
|
|
127
|
+
appearance: "borderless",
|
|
128
|
+
onClick: function onClick() {
|
|
129
|
+
setClosed(true);
|
|
130
|
+
onClose && onClose();
|
|
131
|
+
},
|
|
132
|
+
size: "small",
|
|
133
|
+
"aria-label": "Lukk melding"
|
|
134
|
+
})]
|
|
135
|
+
}));
|
|
137
136
|
});
|
|
138
137
|
|
|
139
138
|
export { LocalMessage };
|
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import { SvgIcon } from '../../icons/utils';
|
|
2
2
|
import { ButtonPurpose } from '../Button';
|
|
3
3
|
import { StaticTypographyType } from '../Typography';
|
|
4
|
-
import { LocalMessagePurpose } from './LocalMessage';
|
|
5
4
|
export declare const typographyType: StaticTypographyType;
|
|
6
|
-
export declare const purposeVariants: {
|
|
7
|
-
[k in LocalMessagePurpose]: {
|
|
8
|
-
icon: SvgIcon;
|
|
9
|
-
closeButtonPurpose: ButtonPurpose;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
5
|
export declare const localMessageTokens: {
|
|
13
6
|
container: {
|
|
14
7
|
base: {
|
|
@@ -16,6 +9,7 @@ export declare const localMessageTokens: {
|
|
|
16
9
|
borderRadius: string;
|
|
17
10
|
border: string;
|
|
18
11
|
padding: string;
|
|
12
|
+
gap: string;
|
|
19
13
|
};
|
|
20
14
|
purpose: {
|
|
21
15
|
info: {
|
|
@@ -44,21 +38,30 @@ export declare const localMessageTokens: {
|
|
|
44
38
|
};
|
|
45
39
|
};
|
|
46
40
|
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
withClosable: {
|
|
52
|
-
paddingRight: string;
|
|
41
|
+
purposeVariants: {
|
|
42
|
+
info: {
|
|
43
|
+
icon: SvgIcon;
|
|
44
|
+
closeButtonPurpose: ButtonPurpose;
|
|
53
45
|
};
|
|
54
|
-
|
|
55
|
-
|
|
46
|
+
warning: {
|
|
47
|
+
icon: SvgIcon;
|
|
48
|
+
closeButtonPurpose: ButtonPurpose;
|
|
56
49
|
};
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
50
|
+
danger: {
|
|
51
|
+
icon: SvgIcon;
|
|
52
|
+
closeButtonPurpose: ButtonPurpose;
|
|
53
|
+
};
|
|
54
|
+
confidential: {
|
|
55
|
+
icon: SvgIcon;
|
|
56
|
+
closeButtonPurpose: ButtonPurpose;
|
|
57
|
+
};
|
|
58
|
+
success: {
|
|
59
|
+
icon: SvgIcon;
|
|
60
|
+
closeButtonPurpose: ButtonPurpose;
|
|
61
|
+
};
|
|
62
|
+
tips: {
|
|
63
|
+
icon: SvgIcon;
|
|
64
|
+
closeButtonPurpose: ButtonPurpose;
|
|
62
65
|
};
|
|
63
66
|
};
|
|
64
67
|
icon: {
|
|
@@ -18,7 +18,8 @@ var container = {
|
|
|
18
18
|
boxShadow: outerShadow.DdsShadow1Onlight,
|
|
19
19
|
borderRadius: borderRadius.RadiiDdsBorderRadius1Radius,
|
|
20
20
|
border: "".concat(border.BordersDdsBorderStyleLightStrokeWeight, " solid"),
|
|
21
|
-
padding:
|
|
21
|
+
padding: spacing.SizesDdsSpacingLocalX075,
|
|
22
|
+
gap: spacing.SizesDdsSpacingLocalX05
|
|
22
23
|
},
|
|
23
24
|
purpose: {
|
|
24
25
|
info: {
|
|
@@ -94,28 +95,10 @@ var icon = {
|
|
|
94
95
|
color: colors.DdsColorDangerDarkest
|
|
95
96
|
}
|
|
96
97
|
};
|
|
97
|
-
var contentContainer = {
|
|
98
|
-
paddingRight: spacing.SizesDdsSpacingLocalX15,
|
|
99
|
-
paddingTop: spacing.SizesDdsSpacingLocalX075,
|
|
100
|
-
paddingBottom: spacing.SizesDdsSpacingLocalX075,
|
|
101
|
-
withClosable: {
|
|
102
|
-
paddingRight: spacing.SizesDdsSpacingLocalX075
|
|
103
|
-
},
|
|
104
|
-
vertical: {
|
|
105
|
-
paddingBottom: spacing.SizesDdsSpacingLocalX15
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
var topContainer = {
|
|
109
|
-
paddingTop: spacing.SizesDdsSpacingLocalX15,
|
|
110
|
-
withClosable: {
|
|
111
|
-
paddingTop: spacing.SizesDdsSpacingLocalX1
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
98
|
var localMessageTokens = {
|
|
115
99
|
container: container,
|
|
116
|
-
|
|
117
|
-
topContainer: topContainer,
|
|
100
|
+
purposeVariants: purposeVariants,
|
|
118
101
|
icon: icon
|
|
119
102
|
};
|
|
120
103
|
|
|
121
|
-
export { localMessageTokens
|
|
104
|
+
export { localMessageTokens };
|
|
@@ -6,8 +6,6 @@ type ProgressTrackerProps = BaseComponentPropsWithChildren<HTMLDivElement, {
|
|
|
6
6
|
activeStep?: number;
|
|
7
7
|
/** Ekstra logikk ved klikking på et steg. */
|
|
8
8
|
onStepChange?: (step: number) => void;
|
|
9
|
-
/** Om brukeren kan hoppe mellom stegene via museklikk på et steg. */
|
|
10
|
-
clickable?: boolean;
|
|
11
9
|
}>;
|
|
12
10
|
type ProgressTrackerComponent = ForwardRefExoticComponent<ProgressTrackerProps> & {
|
|
13
11
|
Item: typeof ProgressTrackerItem;
|
|
@@ -22,12 +22,10 @@ var ProgressTracker = function () {
|
|
|
22
22
|
_props$activeStep = props.activeStep,
|
|
23
23
|
activeStep = _props$activeStep === void 0 ? 0 : _props$activeStep,
|
|
24
24
|
onStepChange = props.onStepChange,
|
|
25
|
-
_props$clickable = props.clickable,
|
|
26
|
-
clickable = _props$clickable === void 0 ? false : _props$clickable,
|
|
27
25
|
children = props.children,
|
|
28
26
|
className = props.className,
|
|
29
27
|
htmlProps = props.htmlProps,
|
|
30
|
-
rest = __rest(props, ["id", "activeStep", "onStepChange", "
|
|
28
|
+
rest = __rest(props, ["id", "activeStep", "onStepChange", "children", "className", "htmlProps"]);
|
|
31
29
|
var _useState = useState(activeStep),
|
|
32
30
|
_useState2 = _slicedToArray(_useState, 2),
|
|
33
31
|
thisActiveStep = _useState2[0],
|
|
@@ -53,7 +51,7 @@ var ProgressTracker = function () {
|
|
|
53
51
|
return jsx(ProgressTrackerContext.Provider, Object.assign({
|
|
54
52
|
value: {
|
|
55
53
|
activeStep: thisActiveStep,
|
|
56
|
-
handleStepChange:
|
|
54
|
+
handleStepChange: handleChange
|
|
57
55
|
}
|
|
58
56
|
}, {
|
|
59
57
|
children: jsx("div", Object.assign({
|
|
@@ -3,7 +3,6 @@ declare const _default: {
|
|
|
3
3
|
component: import("react").ForwardRefExoticComponent<Pick<import("react").HTMLAttributes<HTMLDivElement>, "className" | "id"> & {
|
|
4
4
|
activeStep?: number | undefined;
|
|
5
5
|
onStepChange?: ((step: number) => void) | undefined;
|
|
6
|
-
clickable?: boolean | undefined;
|
|
7
6
|
} & {
|
|
8
7
|
children?: import("react").ReactNode;
|
|
9
8
|
} & {
|
|
@@ -39,4 +38,4 @@ declare const _default: {
|
|
|
39
38
|
export default _default;
|
|
40
39
|
export declare const Overview: () => JSX.Element;
|
|
41
40
|
export declare const WithIcons: () => JSX.Element;
|
|
42
|
-
export declare const
|
|
41
|
+
export declare const FutureStepsDisabled: () => JSX.Element;
|
|
@@ -66,29 +66,12 @@ var ItemText = styled.div.withConfig({
|
|
|
66
66
|
return css(["color:", ";text-decoration:", ";"], itemText.disabled.color, itemText.disabled.textDecoration);
|
|
67
67
|
}
|
|
68
68
|
});
|
|
69
|
-
var ItemContentWrapper = styled.
|
|
69
|
+
var ItemContentWrapper = styled.button.withConfig({
|
|
70
70
|
displayName: "ProgressTrackerItem__ItemContentWrapper",
|
|
71
71
|
componentId: "sc-1j9qaj9-3"
|
|
72
|
-
})(["background:none;border:none;margin:0;padding:0;display:grid;grid-template-columns:", " 1fr;justify-content:flex-start;align-items:center;font-family:inherit;gap:", ";transition:", ";:focus-visible{", "}", "
|
|
73
|
-
var
|
|
74
|
-
|
|
75
|
-
if (clickable) {
|
|
76
|
-
return css([":hover{", "{", "}", "{", "}}"], ItemNumber, function () {
|
|
77
|
-
if (state === 'inactiveCompleted') {
|
|
78
|
-
return css(["border-color:", ";color:", ";background-color:", ";"], itemNumber.completed.hover.borderColor, itemNumber.completed.hover.color, itemNumber.completed.hover.backgroundColor);
|
|
79
|
-
} else if (state === 'inactiveIncomplete') {
|
|
80
|
-
return css(["border-color:", ";color:", ";background-color:", ";"], itemNumber.inactive.hover.borderColor, itemNumber.inactive.hover.color, itemNumber.inactive.hover.backgroundColor);
|
|
81
|
-
}
|
|
82
|
-
}, ItemText, function () {
|
|
83
|
-
if (state !== 'disabled') {
|
|
84
|
-
return css(["text-decoration-color:", ";"], itemText.inactive.hover.textDecorationColor);
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
}, function (_ref4) {
|
|
89
|
-
var clickable = _ref4.clickable,
|
|
90
|
-
state = _ref4.state;
|
|
91
|
-
return clickable && state !== 'disabled' && css(["cursor:pointer;"]);
|
|
72
|
+
})(["background:none;border:none;margin:0;padding:0;display:grid;grid-template-columns:", " 1fr;justify-content:flex-start;align-items:center;font-family:inherit;gap:", ";transition:", ";:focus-visible{", "}", ""], itemNumber.size, itemContentWrapper.gap, focusVisibleTransitionValue, focusVisible, function (_ref3) {
|
|
73
|
+
var state = _ref3.state;
|
|
74
|
+
return state !== 'disabled' && css(["cursor:pointer;"]);
|
|
92
75
|
});
|
|
93
76
|
var getVisuallyHiddenText = function getVisuallyHiddenText(active, completed, index) {
|
|
94
77
|
return "".concat(index + 1, ", ").concat(active ? '' : 'Trinn, ').concat(completed ? 'Ferdig, ' : 'Ikke ferdig, ');
|
|
@@ -107,8 +90,7 @@ var ProgressTrackerItem = function ProgressTrackerItem(props) {
|
|
|
107
90
|
handleStepChange = _useProgressTrackerCo.handleStepChange;
|
|
108
91
|
var active = activeStep === index;
|
|
109
92
|
var styleProps = {
|
|
110
|
-
state: toItemState(active, completed, disabled)
|
|
111
|
-
clickable: handleStepChange !== undefined
|
|
93
|
+
state: toItemState(active, completed, disabled)
|
|
112
94
|
};
|
|
113
95
|
var stepNumberContent = useMemo(function () {
|
|
114
96
|
if (completed) {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import { slicedToArray as _slicedToArray } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
1
2
|
import { __rest } from 'tslib';
|
|
2
3
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
3
|
-
import { forwardRef, useId } from 'react';
|
|
4
|
+
import { forwardRef, useId, useState } from 'react';
|
|
4
5
|
import styled, { css } from 'styled-components';
|
|
5
|
-
import { Button } from '../Button/Button.js';
|
|
6
|
-
import { searchTokens, typographyTypes } from './Search.tokens.js';
|
|
7
6
|
import '../../helpers/Backdrop/Backdrop.js';
|
|
8
7
|
import '../../helpers/Chevron/AnimatedChevronUpDown.styles.js';
|
|
9
8
|
import '../../helpers/HiddenInput/HiddenInput.js';
|
|
@@ -17,21 +16,26 @@ import '../../hooks/useFloatPosition.js';
|
|
|
17
16
|
import { spaceSeparatedIdListGenerator, derivativeIdGenerator } from '../../utils/idGenerator.js';
|
|
18
17
|
import '../../utils/color.js';
|
|
19
18
|
import '../../hooks/useScreenSize.js';
|
|
20
|
-
import { Icon } from '../Icon/Icon.js';
|
|
21
19
|
import '../../icons/utils/StyledSvg.js';
|
|
20
|
+
import { CloseSmallIcon } from '../../icons/tsx/closeSmall.js';
|
|
22
21
|
import { SearchIcon } from '../../icons/tsx/search.js';
|
|
22
|
+
import { Button } from '../Button/Button.js';
|
|
23
|
+
import { Icon } from '../Icon/Icon.js';
|
|
23
24
|
import '../Typography/Typography/Typography.js';
|
|
24
25
|
import { Label } from '../Typography/Label/Label.js';
|
|
25
26
|
import '../Typography/Link/Link.js';
|
|
26
27
|
import { getFontStyling } from '../Typography/Typography.utils.js';
|
|
27
|
-
import { SearchSuggestions } from './SearchSuggestions.js';
|
|
28
|
-
import { useAutocompleteSearch } from './AutocompleteSearch.context.js';
|
|
29
28
|
import { VisuallyHidden } from '../VisuallyHidden/VisuallyHidden.js';
|
|
29
|
+
import { useAutocompleteSearch } from './AutocompleteSearch.context.js';
|
|
30
|
+
import { searchTokens, typographyTypes } from './Search.tokens.js';
|
|
31
|
+
import { SearchSuggestions } from './SearchSuggestions.js';
|
|
32
|
+
import { createEmptyChangeEvent } from './Search.utils.js';
|
|
30
33
|
|
|
31
34
|
var input = searchTokens.input,
|
|
32
35
|
outerContainer = searchTokens.outerContainer,
|
|
33
36
|
horisontalContainer = searchTokens.horisontalContainer,
|
|
34
|
-
|
|
37
|
+
searchIcon = searchTokens.searchIcon,
|
|
38
|
+
clearButton = searchTokens.clearButton;
|
|
35
39
|
var getIconSize = function getIconSize(size) {
|
|
36
40
|
switch (size) {
|
|
37
41
|
case 'large':
|
|
@@ -49,27 +53,31 @@ var Input = styled(Input$1).withConfig({
|
|
|
49
53
|
var componentSize = _ref.componentSize;
|
|
50
54
|
return css(["padding-top:", ";padding-bottom:", ";padding-left:", ";", ""], input.sizes[componentSize].paddingTop, input.sizes[componentSize].paddingBottom, input.sizes[componentSize].paddingLeft, getFontStyling(typographyTypes[componentSize]));
|
|
51
55
|
});
|
|
52
|
-
var
|
|
53
|
-
displayName: "
|
|
56
|
+
var StyledSearchIcon = styled(Icon).withConfig({
|
|
57
|
+
displayName: "Search__StyledSearchIcon",
|
|
54
58
|
componentId: "sc-1ax3s9s-1"
|
|
55
|
-
})(["position:absolute;left:", ";color:", ";", " z-index:1;"],
|
|
59
|
+
})(["position:absolute;left:", ";color:", ";", " z-index:1;"], searchIcon.base.left, searchIcon.base.color, function (_ref2) {
|
|
56
60
|
var size = _ref2.size;
|
|
57
|
-
return css(["top:", ";"], searchTokens.
|
|
61
|
+
return css(["top:", ";"], searchTokens.searchIcon[size].top);
|
|
58
62
|
});
|
|
63
|
+
var StyledClearButton = styled(Button).withConfig({
|
|
64
|
+
displayName: "Search__StyledClearButton",
|
|
65
|
+
componentId: "sc-1ax3s9s-2"
|
|
66
|
+
})(["position:absolute;right:", ";color:", ";top:", ";"], clearButton.right, clearButton.color, clearButton.top);
|
|
59
67
|
var OuterContainer = styled.div.withConfig({
|
|
60
68
|
displayName: "Search__OuterContainer",
|
|
61
|
-
componentId: "sc-1ax3s9s-
|
|
69
|
+
componentId: "sc-1ax3s9s-3"
|
|
62
70
|
})(["display:flex;flex-direction:column;gap:", ";"], outerContainer.gap);
|
|
63
71
|
var HorisontalContainer = styled.div.withConfig({
|
|
64
72
|
displayName: "Search__HorisontalContainer",
|
|
65
|
-
componentId: "sc-1ax3s9s-
|
|
73
|
+
componentId: "sc-1ax3s9s-4"
|
|
66
74
|
})(["", ""], function (props) {
|
|
67
75
|
return props.hasSearchButton && css(["display:grid;grid-template-columns:1fr auto;gap:", ";"], horisontalContainer.gap);
|
|
68
76
|
});
|
|
69
77
|
var InputContainer = styled.div.withConfig({
|
|
70
78
|
displayName: "Search__InputContainer",
|
|
71
|
-
componentId: "sc-1ax3s9s-
|
|
72
|
-
})(["position:relative;"]);
|
|
79
|
+
componentId: "sc-1ax3s9s-5"
|
|
80
|
+
})(["position:relative;display:flex;"]);
|
|
73
81
|
var Search = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
74
82
|
var _a$componentSize = _a.componentSize,
|
|
75
83
|
componentSize = _a$componentSize === void 0 ? 'medium' : _a$componentSize,
|
|
@@ -90,12 +98,21 @@ var Search = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
90
98
|
var tipId = derivativeIdGenerator(uniqueId, 'tip');
|
|
91
99
|
var suggestionsId = derivativeIdGenerator(uniqueId, 'suggestions');
|
|
92
100
|
var suggestionsDescriptionId = derivativeIdGenerator(uniqueId, 'suggestions-description');
|
|
101
|
+
var _useState = useState(!!value),
|
|
102
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
103
|
+
hasValue = _useState2[0],
|
|
104
|
+
setHasValue = _useState2[1];
|
|
93
105
|
var context = useAutocompleteSearch();
|
|
94
106
|
var combinedRef = context.inputRef ? useCombinedRef(context.inputRef, ref) : ref;
|
|
95
107
|
var handleChange = function handleChange(e) {
|
|
108
|
+
setHasValue(e.target.value !== '');
|
|
96
109
|
context.onValueChange && context.onValueChange(e);
|
|
97
110
|
onChange && onChange(e);
|
|
98
111
|
};
|
|
112
|
+
var clearInput = function clearInput() {
|
|
113
|
+
var emptyChangeEvent = createEmptyChangeEvent(uniqueId);
|
|
114
|
+
handleChange(emptyChangeEvent);
|
|
115
|
+
};
|
|
99
116
|
var containerProps = {
|
|
100
117
|
className: className,
|
|
101
118
|
style: style
|
|
@@ -127,7 +144,7 @@ var Search = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
127
144
|
hasSearchButton: showSearchButton
|
|
128
145
|
}, containerProps, {
|
|
129
146
|
children: [jsxs(InputContainer, {
|
|
130
|
-
children: [jsx(
|
|
147
|
+
children: [jsx(StyledSearchIcon, {
|
|
131
148
|
icon: SearchIcon,
|
|
132
149
|
size: componentSize,
|
|
133
150
|
iconSize: getIconSize(componentSize)
|
|
@@ -151,6 +168,13 @@ var Search = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
151
168
|
}, {
|
|
152
169
|
children: "Bla i s\xF8keforslag med piltaster n\xE5r listen er utvidet."
|
|
153
170
|
}))]
|
|
171
|
+
}), hasValue && jsx(StyledClearButton, {
|
|
172
|
+
icon: CloseSmallIcon,
|
|
173
|
+
size: "tiny",
|
|
174
|
+
purpose: "secondary",
|
|
175
|
+
appearance: "borderless",
|
|
176
|
+
"aria-label": "T\xF8m",
|
|
177
|
+
onClick: clearInput
|
|
154
178
|
})]
|
|
155
179
|
}), showSearchButton && jsx(Button, Object.assign({
|
|
156
180
|
size: componentSize,
|
|
@@ -27,7 +27,7 @@ export declare const searchTokens: {
|
|
|
27
27
|
};
|
|
28
28
|
};
|
|
29
29
|
};
|
|
30
|
-
|
|
30
|
+
searchIcon: {
|
|
31
31
|
base: {
|
|
32
32
|
left: string;
|
|
33
33
|
color: string;
|
|
@@ -42,6 +42,11 @@ export declare const searchTokens: {
|
|
|
42
42
|
top: string;
|
|
43
43
|
};
|
|
44
44
|
};
|
|
45
|
+
clearButton: {
|
|
46
|
+
right: string;
|
|
47
|
+
top: string;
|
|
48
|
+
color: string;
|
|
49
|
+
};
|
|
45
50
|
horisontalContainer: {
|
|
46
51
|
gap: string;
|
|
47
52
|
};
|
|
@@ -14,7 +14,7 @@ var paddingLeftMedium = "".concat(spacing.SizesDdsSpacingLocalX075NumberPx + ico
|
|
|
14
14
|
var paddingLeftLarge = "".concat(spacing.SizesDdsSpacingLocalX075NumberPx + iconSizes.DdsIconsizeMediumNumberPx + spacing.SizesDdsSpacingLocalX05NumberPx, "px");
|
|
15
15
|
var input = {
|
|
16
16
|
base: {
|
|
17
|
-
paddingRight: spacing.
|
|
17
|
+
paddingRight: spacing.SizesDdsSpacingLocalX25,
|
|
18
18
|
paddingLeft: spacing.SizesDdsSpacingLocalX3
|
|
19
19
|
},
|
|
20
20
|
sizes: {
|
|
@@ -41,7 +41,7 @@ var horisontalContainer = {
|
|
|
41
41
|
var outerContainer = {
|
|
42
42
|
gap: spacing.SizesDdsSpacingLocalX0125
|
|
43
43
|
};
|
|
44
|
-
var
|
|
44
|
+
var searchIcon = {
|
|
45
45
|
base: {
|
|
46
46
|
left: spacing.SizesDdsSpacingLocalX075,
|
|
47
47
|
color: textDefault.textColor
|
|
@@ -56,6 +56,11 @@ var icon = {
|
|
|
56
56
|
top: "calc(50% - ".concat(iconSizes.DdsIconsizeMediumNumberPx / 2, "px)")
|
|
57
57
|
}
|
|
58
58
|
};
|
|
59
|
+
var clearButton = {
|
|
60
|
+
right: spacing.SizesDdsSpacingLocalX075,
|
|
61
|
+
top: "calc(50% - 14px)",
|
|
62
|
+
color: textDefault.textColor
|
|
63
|
+
};
|
|
59
64
|
var suggestionsContainer = {
|
|
60
65
|
marginTop: spacing.SizesDdsSpacingLocalX025,
|
|
61
66
|
border: "1px solid ".concat(colors.DdsColorInteractiveBase),
|
|
@@ -66,7 +71,8 @@ var suggestionsHeader = {
|
|
|
66
71
|
};
|
|
67
72
|
var searchTokens = {
|
|
68
73
|
input: input,
|
|
69
|
-
|
|
74
|
+
searchIcon: searchIcon,
|
|
75
|
+
clearButton: clearButton,
|
|
70
76
|
horisontalContainer: horisontalContainer,
|
|
71
77
|
outerContainer: outerContainer,
|
|
72
78
|
suggestionsContainer: suggestionsContainer,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ChangeEvent } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Lager en change-event som kan resette verdien i et input-felt.
|
|
4
|
+
* Dette vil resultere i en event som har: event.target.value = ''.
|
|
5
|
+
*
|
|
6
|
+
* @param inputElementId Id'en til et gitt input-felt
|
|
7
|
+
* @returns En change-event som har en tom streng som target value
|
|
8
|
+
*/
|
|
9
|
+
export declare function createEmptyChangeEvent(inputElementId: string): ChangeEvent<HTMLInputElement>;
|