@norges-domstoler/dds-components 5.2.0-beta.0 → 5.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/assets/svg/calendar_today.svg.js +1 -1
- package/dist/cjs/components/DescriptionList/DescriptionList.tokens.d.ts +70 -0
- package/dist/cjs/components/Drawer/DrawerGroup.d.ts +1 -1
- package/dist/cjs/components/Modal/Modal.tokens.d.ts +0 -6
- package/dist/cjs/components/Modal/ModalBody.d.ts +6 -1
- package/dist/cjs/components/OverflowMenu/OverflowMenuGroup.d.ts +1 -1
- package/dist/cjs/components/Popover/PopoverGroup.d.ts +1 -1
- package/dist/cjs/components/RadioButton/RadioButton.d.ts +2 -0
- package/dist/cjs/components/RadioButton/RadioButton.stories.d.ts +2 -0
- package/dist/cjs/components/RadioButton/RadioButton.types.d.ts +2 -2
- package/dist/cjs/components/ScrollableContainer/ScrollableContainer.d.ts +7 -0
- package/dist/cjs/components/ScrollableContainer/ScrollableContainer.stories.d.ts +15 -0
- package/dist/cjs/components/ScrollableContainer/ScrollableContainer.tokens.d.ts +25 -0
- package/dist/cjs/components/ScrollableContainer/Scrollbar.d.ts +7 -0
- package/dist/cjs/components/ScrollableContainer/index.d.ts +3 -0
- package/dist/cjs/components/ScrollableContainer/scrollbarStyling.d.ts +26 -0
- package/dist/cjs/helpers/Chevron/AnimatedChevronUpDown.d.ts +1 -1
- package/dist/cjs/helpers/styling/index.d.ts +0 -1
- package/dist/cjs/hooks/useRoveFocus.d.ts +2 -1
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +897 -614
- package/dist/components/Datepicker/Datepicker.js +1 -1
- package/dist/components/DescriptionList/DescriptionList.js +6 -3
- package/dist/components/DescriptionList/DescriptionList.tokens.d.ts +70 -0
- package/dist/components/DescriptionList/DescriptionList.tokens.js +60 -0
- package/dist/components/DescriptionList/DescriptionListDesc.js +2 -2
- package/dist/components/DescriptionList/DescriptionListGroup.js +4 -4
- package/dist/components/Drawer/Drawer.js +12 -10
- package/dist/components/Drawer/DrawerGroup.d.ts +1 -1
- package/dist/components/List/List.js +1 -1
- package/dist/components/Modal/Modal.tokens.d.ts +0 -6
- package/dist/components/Modal/Modal.tokens.js +0 -10
- package/dist/components/Modal/ModalBody.d.ts +6 -1
- package/dist/components/Modal/ModalBody.js +13 -13
- package/dist/components/OverflowMenu/OverflowMenu.js +3 -3
- package/dist/components/OverflowMenu/OverflowMenuGroup.d.ts +1 -1
- package/dist/components/Popover/PopoverGroup.d.ts +1 -1
- package/dist/components/RadioButton/RadioButton.d.ts +2 -0
- package/dist/components/RadioButton/RadioButton.stories.d.ts +2 -0
- package/dist/components/RadioButton/RadioButton.types.d.ts +2 -2
- package/dist/components/ScrollableContainer/ScrollableContainer.d.ts +7 -0
- package/dist/components/ScrollableContainer/ScrollableContainer.js +47 -0
- package/dist/components/ScrollableContainer/ScrollableContainer.stories.d.ts +15 -0
- package/dist/components/ScrollableContainer/ScrollableContainer.tokens.d.ts +25 -0
- package/dist/components/ScrollableContainer/ScrollableContainer.tokens.js +36 -0
- package/dist/components/ScrollableContainer/Scrollbar.d.ts +7 -0
- package/dist/components/ScrollableContainer/Scrollbar.js +178 -0
- package/dist/components/ScrollableContainer/index.d.ts +3 -0
- package/dist/components/ScrollableContainer/scrollbarStyling.d.ts +26 -0
- package/dist/components/ScrollableContainer/scrollbarStyling.js +40 -0
- package/dist/components/Select/Select.styles.js +3 -3
- package/dist/components/Table/Table.js +2 -2
- package/dist/components/Table/TableWrapper.js +3 -3
- package/dist/components/Tabs/TabList.js +2 -2
- package/dist/components/TextInput/TextInput.styles.js +2 -2
- package/dist/components/TextInput/TextInput.tokens.js +1 -1
- package/dist/helpers/Chevron/AnimatedChevronUpDown.d.ts +1 -1
- package/dist/helpers/styling/focusVisible.js +3 -2
- package/dist/helpers/styling/index.d.ts +0 -1
- package/dist/hooks/useRoveFocus.d.ts +2 -1
- package/dist/hooks/useRoveFocus.js +9 -6
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/package.json +48 -43
- package/dist/cjs/components/DescriptionList/DescriptionListDesc.tokens.d.ts +0 -7
- package/dist/cjs/components/DescriptionList/DescriptionListGroup.tokens.d.ts +0 -4
- package/dist/cjs/components/DescriptionList/DescriptionListTerm.tokens.d.ts +0 -13
- package/dist/cjs/helpers/styling/scrollbarStyling.d.ts +0 -3
- package/dist/components/DescriptionList/DescriptionListDesc.tokens.d.ts +0 -7
- package/dist/components/DescriptionList/DescriptionListDesc.tokens.js +0 -22
- package/dist/components/DescriptionList/DescriptionListGroup.tokens.d.ts +0 -4
- package/dist/components/DescriptionList/DescriptionListGroup.tokens.js +0 -11
- package/dist/components/DescriptionList/DescriptionListTerm.tokens.d.ts +0 -13
- package/dist/components/DescriptionList/DescriptionListTerm.tokens.js +0 -27
- package/dist/helpers/styling/scrollbarStyling.d.ts +0 -3
- package/dist/helpers/styling/scrollbarStyling.js +0 -8
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { slicedToArray as _slicedToArray } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import { __rest } from 'tslib';
|
|
3
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
4
|
+
import { useRef, useState, useCallback, useEffect } from 'react';
|
|
5
|
+
import styled from 'styled-components';
|
|
6
|
+
import { scrollbarTokens } from './ScrollableContainer.tokens.js';
|
|
7
|
+
import { getBaseHTMLProps } from '../../types/BaseComponentProps.js';
|
|
8
|
+
|
|
9
|
+
var track = scrollbarTokens.track,
|
|
10
|
+
thumb = scrollbarTokens.thumb,
|
|
11
|
+
minThumbHeightPx = scrollbarTokens.minThumbHeightPx;
|
|
12
|
+
var ScrollbarOuterWrapper = styled.div.withConfig({
|
|
13
|
+
displayName: "Scrollbar__ScrollbarOuterWrapper",
|
|
14
|
+
componentId: "sc-mphi5n-0"
|
|
15
|
+
})([""]);
|
|
16
|
+
var ScrollbarElements = styled.div.withConfig({
|
|
17
|
+
displayName: "Scrollbar__ScrollbarElements",
|
|
18
|
+
componentId: "sc-mphi5n-1"
|
|
19
|
+
})(["display:block;height:100%;position:relative;display:grid;justify-items:center;"]);
|
|
20
|
+
var Track = styled.div.withConfig({
|
|
21
|
+
displayName: "Scrollbar__Track",
|
|
22
|
+
componentId: "sc-mphi5n-2"
|
|
23
|
+
})(["bottom:0;top:0;position:absolute;background-color:", ";border-radius:", ";width:", ";"], track.backgroundColor, track.borderRadius, track.width);
|
|
24
|
+
var Thumb = styled.div.withConfig({
|
|
25
|
+
displayName: "Scrollbar__Thumb",
|
|
26
|
+
componentId: "sc-mphi5n-3"
|
|
27
|
+
})(["position:absolute;background-color:", ";border-radius:", ";width:", ";transition:background-color 0.2s;&:hover{background-color:", ";}"], thumb.base.backgroundColor, thumb.base.borderRadius, thumb.base.width, thumb.hover.backgroundColor);
|
|
28
|
+
var Scrollbar = function Scrollbar(props) {
|
|
29
|
+
var id = props.id,
|
|
30
|
+
className = props.className,
|
|
31
|
+
htmlProps = props.htmlProps,
|
|
32
|
+
contentRef = props.contentRef,
|
|
33
|
+
rest = __rest(props, ["id", "className", "htmlProps", "contentRef"]);
|
|
34
|
+
|
|
35
|
+
var trackRef = useRef(null);
|
|
36
|
+
var thumbRef = useRef(null);
|
|
37
|
+
|
|
38
|
+
var _useState = useState(minThumbHeightPx),
|
|
39
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
40
|
+
thumbHeight = _useState2[0],
|
|
41
|
+
setThumbHeight = _useState2[1];
|
|
42
|
+
|
|
43
|
+
var _useState3 = useState(true),
|
|
44
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
45
|
+
isScrollable = _useState4[0],
|
|
46
|
+
setIsScrollable = _useState4[1];
|
|
47
|
+
|
|
48
|
+
var _useState5 = useState(0),
|
|
49
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
50
|
+
thumbTop = _useState6[0],
|
|
51
|
+
setThumbTop = _useState6[1];
|
|
52
|
+
|
|
53
|
+
var observer = useRef(null);
|
|
54
|
+
|
|
55
|
+
var _useState7 = useState(0),
|
|
56
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
57
|
+
scrollStartPosition = _useState8[0],
|
|
58
|
+
setScrollStartPosition = _useState8[1];
|
|
59
|
+
|
|
60
|
+
var _useState9 = useState(0),
|
|
61
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
62
|
+
initialScrollTop = _useState10[0],
|
|
63
|
+
setInitialScrollTop = _useState10[1];
|
|
64
|
+
|
|
65
|
+
var _useState11 = useState(false),
|
|
66
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
67
|
+
isDragging = _useState12[0],
|
|
68
|
+
setIsDragging = _useState12[1];
|
|
69
|
+
|
|
70
|
+
function handleResize(ref, trackSize) {
|
|
71
|
+
var clientHeight = ref.clientHeight,
|
|
72
|
+
scrollHeight = ref.scrollHeight;
|
|
73
|
+
setIsScrollable(clientHeight !== scrollHeight);
|
|
74
|
+
setThumbHeight(Math.max(clientHeight / scrollHeight * trackSize, minThumbHeightPx));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
var handleTrackClick = useCallback(function (e) {
|
|
78
|
+
if (contentRef && contentRef.current) {
|
|
79
|
+
var trackCurrent = trackRef.current;
|
|
80
|
+
var contentCurrent = contentRef.current;
|
|
81
|
+
|
|
82
|
+
if (trackCurrent && contentCurrent) {
|
|
83
|
+
var clientY = e.clientY;
|
|
84
|
+
var target = e.target;
|
|
85
|
+
var rect = target.getBoundingClientRect();
|
|
86
|
+
var trackTop = rect.top;
|
|
87
|
+
var thumbOffset = -(thumbHeight / 2);
|
|
88
|
+
var clickRatio = (clientY - trackTop + thumbOffset) / trackCurrent.clientHeight;
|
|
89
|
+
var scrollAmount = Math.floor(clickRatio * contentCurrent.scrollHeight);
|
|
90
|
+
contentCurrent.scrollTo({
|
|
91
|
+
top: scrollAmount,
|
|
92
|
+
behavior: 'smooth'
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}, [thumbHeight]);
|
|
97
|
+
var handleThumbPositioning = useCallback(function () {
|
|
98
|
+
console.log('positioning');
|
|
99
|
+
|
|
100
|
+
if (!(contentRef === null || contentRef === void 0 ? void 0 : contentRef.current) || !trackRef.current || !thumbRef.current) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
var _contentRef$current = contentRef.current,
|
|
105
|
+
contentTop = _contentRef$current.scrollTop,
|
|
106
|
+
contentHeight = _contentRef$current.scrollHeight;
|
|
107
|
+
var clientHeight = trackRef.current.clientHeight;
|
|
108
|
+
var newTop = +contentTop / +contentHeight * clientHeight;
|
|
109
|
+
newTop = Math.min(newTop, clientHeight - thumbHeight);
|
|
110
|
+
setThumbTop(newTop);
|
|
111
|
+
}, []);
|
|
112
|
+
useEffect(function () {
|
|
113
|
+
if (contentRef && contentRef.current && trackRef.current) {
|
|
114
|
+
var ref = contentRef.current;
|
|
115
|
+
var clientHeight = trackRef.current.clientHeight;
|
|
116
|
+
observer.current = new ResizeObserver(function () {
|
|
117
|
+
handleResize(ref, clientHeight);
|
|
118
|
+
});
|
|
119
|
+
observer.current.observe(ref);
|
|
120
|
+
ref.addEventListener('scroll', handleThumbPositioning);
|
|
121
|
+
return function () {
|
|
122
|
+
var _a;
|
|
123
|
+
|
|
124
|
+
(_a = observer.current) === null || _a === void 0 ? void 0 : _a.unobserve(ref);
|
|
125
|
+
ref.removeEventListener('scroll', handleThumbPositioning);
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}, []);
|
|
129
|
+
var handleThumbMousedown = useCallback(function (e) {
|
|
130
|
+
setScrollStartPosition(e.clientY);
|
|
131
|
+
if (contentRef && contentRef.current) setInitialScrollTop(contentRef.current.scrollTop);
|
|
132
|
+
setIsDragging(true);
|
|
133
|
+
}, []);
|
|
134
|
+
var handleThumbMouseup = useCallback(function () {
|
|
135
|
+
if (isDragging) {
|
|
136
|
+
setIsDragging(false);
|
|
137
|
+
}
|
|
138
|
+
}, [isDragging]);
|
|
139
|
+
var handleThumbMousemove = useCallback(function (e) {
|
|
140
|
+
if (contentRef && contentRef.current) {
|
|
141
|
+
if (isDragging) {
|
|
142
|
+
var _contentRef$current2 = contentRef.current,
|
|
143
|
+
contentScrollHeight = _contentRef$current2.scrollHeight,
|
|
144
|
+
contentOffsetHeight = _contentRef$current2.offsetHeight;
|
|
145
|
+
var deltaY = (e.clientY - scrollStartPosition) * (contentOffsetHeight / thumbHeight);
|
|
146
|
+
var newScrollTop = Math.min(initialScrollTop + deltaY, contentScrollHeight - contentOffsetHeight);
|
|
147
|
+
contentRef.current.scrollTop = newScrollTop;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}, [isDragging, scrollStartPosition, thumbHeight]);
|
|
151
|
+
useEffect(function () {
|
|
152
|
+
document.addEventListener('mousemove', handleThumbMousemove);
|
|
153
|
+
document.addEventListener('mouseup', handleThumbMouseup);
|
|
154
|
+
document.addEventListener('mouseleave', handleThumbMouseup);
|
|
155
|
+
return function () {
|
|
156
|
+
document.removeEventListener('mousemove', handleThumbMousemove);
|
|
157
|
+
document.removeEventListener('mouseup', handleThumbMouseup);
|
|
158
|
+
document.removeEventListener('mouseleave', handleThumbMouseup);
|
|
159
|
+
};
|
|
160
|
+
}, [handleThumbMousemove, handleThumbMouseup]);
|
|
161
|
+
return isScrollable ? jsx(ScrollbarOuterWrapper, Object.assign({}, getBaseHTMLProps(id, className, htmlProps, rest), {
|
|
162
|
+
children: jsxs(ScrollbarElements, {
|
|
163
|
+
children: [jsx(Track, {
|
|
164
|
+
ref: trackRef,
|
|
165
|
+
onClick: handleTrackClick
|
|
166
|
+
}), jsx(Thumb, {
|
|
167
|
+
style: {
|
|
168
|
+
height: thumbHeight,
|
|
169
|
+
top: thumbTop
|
|
170
|
+
},
|
|
171
|
+
ref: thumbRef,
|
|
172
|
+
onMouseDown: handleThumbMousedown
|
|
173
|
+
})]
|
|
174
|
+
})
|
|
175
|
+
})) : null;
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
export { Scrollbar };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CSS-in-JS scrollbar styling til bruk der det ikke passer å bruke dedikerte komponenter. Inkluderer styling for webkit pseudo-elementer og for Firefox.
|
|
3
|
+
*/
|
|
4
|
+
export declare const scrollbarStyling: {
|
|
5
|
+
webkit: {
|
|
6
|
+
'&::-webkit-scrollbar': {
|
|
7
|
+
width: string;
|
|
8
|
+
height: string;
|
|
9
|
+
};
|
|
10
|
+
'&::-webkit-scrollbar-track': {
|
|
11
|
+
background: string;
|
|
12
|
+
borderRadius: string;
|
|
13
|
+
};
|
|
14
|
+
'&::-webkit-scrollbar-thumb': {
|
|
15
|
+
background: string;
|
|
16
|
+
borderRadius: string;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
'&::-webkit-scrollbar-thumb:hover': {
|
|
20
|
+
background: string;
|
|
21
|
+
};
|
|
22
|
+
firefox: {
|
|
23
|
+
scrollbarColor: string;
|
|
24
|
+
scrollbarWidth: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { scrollbarTokens } from './ScrollableContainer.tokens.js';
|
|
2
|
+
|
|
3
|
+
var thumb = scrollbarTokens.thumb,
|
|
4
|
+
track = scrollbarTokens.track;
|
|
5
|
+
/**
|
|
6
|
+
* CSS-in-JS scrollbar styling til bruk der det ikke passer å bruke dedikerte komponenter. Inkluderer styling for webkit pseudo-elementer og for Firefox.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
var scrollbarStyling = {
|
|
10
|
+
webkit: {
|
|
11
|
+
/* width */
|
|
12
|
+
'&::-webkit-scrollbar': {
|
|
13
|
+
width: track.width,
|
|
14
|
+
height: track.width
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
/* Track */
|
|
18
|
+
'&::-webkit-scrollbar-track': {
|
|
19
|
+
background: track.backgroundColor,
|
|
20
|
+
borderRadius: track.borderRadius
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
/* Handle */
|
|
24
|
+
'&::-webkit-scrollbar-thumb': {
|
|
25
|
+
background: thumb.base.backgroundColor,
|
|
26
|
+
borderRadius: thumb.base.borderRadius
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
/* Handle on hover */
|
|
31
|
+
'&::-webkit-scrollbar-thumb:hover': {
|
|
32
|
+
background: thumb.hover.backgroundColor
|
|
33
|
+
},
|
|
34
|
+
firefox: {
|
|
35
|
+
scrollbarColor: thumb.base.backgroundColor + ' ' + track.backgroundColor,
|
|
36
|
+
scrollbarWidth: 'thin'
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export { scrollbarStyling };
|
|
@@ -2,7 +2,7 @@ import styled, { css } from 'styled-components';
|
|
|
2
2
|
import { typographyTokens } from '../Typography/Typography.tokens.js';
|
|
3
3
|
import { selectTokens } from './Select.tokens.js';
|
|
4
4
|
import { Typography } from '../Typography/Typography.js';
|
|
5
|
-
import { scrollbarStyling } from '
|
|
5
|
+
import { scrollbarStyling } from '../ScrollableContainer/scrollbarStyling.js';
|
|
6
6
|
|
|
7
7
|
var prefix = 'dds-select';
|
|
8
8
|
var Label = styled(Typography).withConfig({
|
|
@@ -12,14 +12,14 @@ var Label = styled(Typography).withConfig({
|
|
|
12
12
|
var Container = styled.div.withConfig({
|
|
13
13
|
displayName: "Selectstyles__Container",
|
|
14
14
|
componentId: "sc-19jkd5s-1"
|
|
15
|
-
})(["@media (prefers-reduced-motion:no-preference){transition:box-shadow 0.2s,border-color 0.2s,background-color 0.2s;}position:relative;", "
|
|
15
|
+
})(["@media (prefers-reduced-motion:no-preference){transition:box-shadow 0.2s,border-color 0.2s,background-color 0.2s;}position:relative;", " *::selection{", "}", " &:hover{", " ", "{", "}}&:focus-within{", " ", "{", "}}", " .", "__menu-list{", " ", "}&:hover .", "__dropdown-indicator,&:focus-within .", "__dropdown-indicator{", "}", " ", ""], selectTokens.container.base, typographyTokens.selection.base, function (_ref) {
|
|
16
16
|
var hasLabel = _ref.hasLabel,
|
|
17
17
|
isMulti = _ref.isMulti;
|
|
18
18
|
return isMulti && hasLabel ? css([".", "__value-container{", "}.", "__indicators{", "}"], prefix, selectTokens.valueContainer.isMulti.withLabel.base, prefix, selectTokens.indicatorsContainer.isMulti.withLabel.base) : isMulti && !hasLabel ? css([".", "__control{", "}.", "__value-container{", "}.", "__indicators{", "}"], prefix, selectTokens.input.isMulti.noLabel.base, prefix, selectTokens.valueContainer.isMulti.noLabel.base, prefix, selectTokens.indicatorsContainer.isMulti.noLabel.base) : hasLabel ? css([".", "__value-container{", "}.", "__indicators{", "}"], prefix, selectTokens.valueContainer.withLabel.base, prefix, selectTokens.indicatorsContainer.withLabel.base) : css([".", "__control{", "}.", "__value-container{", "}.", "__indicators{", "}"], prefix, selectTokens.input.noLabel.base, prefix, selectTokens.valueContainer.noLabel.base, prefix, selectTokens.indicatorsContainer.noLabel.base);
|
|
19
19
|
}, selectTokens.container.hover.base, Label, selectTokens.label.hover.base, selectTokens.container.focus.base, Label, selectTokens.label.focus.base, function (_ref2) {
|
|
20
20
|
var errorMessage = _ref2.errorMessage;
|
|
21
21
|
return errorMessage && css(["", " &:hover{", "}&:focus-within{", "}"], selectTokens.container.danger.base, selectTokens.container.danger.hover.base, selectTokens.container.danger.focus.base);
|
|
22
|
-
}, prefix, scrollbarStyling, prefix, prefix, selectTokens.dropdownIndicator.hover.base, function (_ref3) {
|
|
22
|
+
}, prefix, scrollbarStyling.webkit, scrollbarStyling.firefox, prefix, prefix, selectTokens.dropdownIndicator.hover.base, function (_ref3) {
|
|
23
23
|
var isDisabled = _ref3.isDisabled;
|
|
24
24
|
return isDisabled && css(["cursor:not-allowed;", " &:hover{box-shadow:none;", " ", "{", "}&:hover .", "__dropdown-indicator{", "}}"], selectTokens.container.disabled.base, selectTokens.container.disabled.base, Label, selectTokens.label.base, prefix, selectTokens.dropdownIndicator.base);
|
|
25
25
|
}, function (_ref4) {
|
|
@@ -4,12 +4,12 @@ import { forwardRef } from 'react';
|
|
|
4
4
|
import styled, { css } from 'styled-components';
|
|
5
5
|
import { cellTokens } from './Cell.tokens.js';
|
|
6
6
|
import { typographyTokens } from '../Typography/Typography.tokens.js';
|
|
7
|
-
import { scrollbarStyling } from '
|
|
7
|
+
import { scrollbarStyling } from '../ScrollableContainer/scrollbarStyling.js';
|
|
8
8
|
|
|
9
9
|
var StyledTable = styled.table.withConfig({
|
|
10
10
|
displayName: "Table__StyledTable",
|
|
11
11
|
componentId: "sc-bw0w0a-0"
|
|
12
|
-
})(["border-spacing:0;border-collapse:collapse;*::selection{", "}", " ", " ", ""], typographyTokens.selection.base, scrollbarStyling, function (_ref) {
|
|
12
|
+
})(["border-spacing:0;border-collapse:collapse;*::selection{", "}", " ", " ", " ", ""], typographyTokens.selection.base, scrollbarStyling.webkit, scrollbarStyling.firefox, function (_ref) {
|
|
13
13
|
var density = _ref.density;
|
|
14
14
|
return density && css(["td,th{", "}"], cellTokens.density[density].base);
|
|
15
15
|
}, function (_ref2) {
|
|
@@ -3,15 +3,15 @@ import { __rest } from 'tslib';
|
|
|
3
3
|
import { jsx } from 'react/jsx-runtime';
|
|
4
4
|
import { useState, useRef, useEffect } from 'react';
|
|
5
5
|
import styled, { css } from 'styled-components';
|
|
6
|
-
import { scrollbarStyling } from '
|
|
6
|
+
import { scrollbarStyling } from '../ScrollableContainer/scrollbarStyling.js';
|
|
7
7
|
|
|
8
8
|
var Wrapper = styled.div.withConfig({
|
|
9
9
|
displayName: "TableWrapper__Wrapper",
|
|
10
10
|
componentId: "sc-eb384b-0"
|
|
11
|
-
})(["", " ", ""], function (_ref) {
|
|
11
|
+
})(["", " ", " ", ""], function (_ref) {
|
|
12
12
|
var overflowX = _ref.overflowX;
|
|
13
13
|
return overflowX && css(["overflow-x:auto;"]);
|
|
14
|
-
}, scrollbarStyling);
|
|
14
|
+
}, scrollbarStyling.webkit, scrollbarStyling.firefox);
|
|
15
15
|
var TableWrapper = function TableWrapper(_a) {
|
|
16
16
|
var children = _a.children,
|
|
17
17
|
rest = __rest(_a, ["children"]);
|
|
@@ -5,7 +5,7 @@ import { forwardRef, useState, Children, isValidElement, cloneElement } from 're
|
|
|
5
5
|
import styled from 'styled-components';
|
|
6
6
|
import { tabsTokens } from './Tabs.tokens.js';
|
|
7
7
|
import { useTabsContext } from './Tabs.context.js';
|
|
8
|
-
import { scrollbarStyling } from '
|
|
8
|
+
import { scrollbarStyling } from '../ScrollableContainer/scrollbarStyling.js';
|
|
9
9
|
import { useRoveFocus } from '../../hooks/useRoveFocus.js';
|
|
10
10
|
import { useCombinedRef } from '../../hooks/useCombinedRefs.js';
|
|
11
11
|
import { useOnKeyDown } from '../../hooks/useOnKeyDown.js';
|
|
@@ -14,7 +14,7 @@ import { useOnClickOutside } from '../../hooks/useOnClickOutside.js';
|
|
|
14
14
|
var TabRow = styled.div.withConfig({
|
|
15
15
|
displayName: "TabList__TabRow",
|
|
16
16
|
componentId: "sc-1ldr0lz-0"
|
|
17
|
-
})(["", " ", " scroll-snap-type:x mandatory;@media (prefers-reduced-motion:no-preference){scroll-behavior:smooth;}&:focus-visible{", "}&:focus-visible button{outline:none;}"], tabsTokens.tabList.base, scrollbarStyling, tabsTokens.tabList.focus.base);
|
|
17
|
+
})(["", " ", " ", " scroll-snap-type:x mandatory;@media (prefers-reduced-motion:no-preference){scroll-behavior:smooth;}&:focus-visible{", "}&:focus-visible button{outline:none;}"], tabsTokens.tabList.base, scrollbarStyling.webkit, scrollbarStyling.firefox, tabsTokens.tabList.focus.base);
|
|
18
18
|
var TabList = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
19
19
|
var children = _a.children,
|
|
20
20
|
id = _a.id,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import styled, { css } from 'styled-components';
|
|
2
2
|
import { textInputTokens } from './TextInput.tokens.js';
|
|
3
3
|
import { StatefulInput, Label as Label$1 } from '../../helpers/Input/Input.styles.js';
|
|
4
|
-
import { scrollbarStyling } from '
|
|
4
|
+
import { scrollbarStyling } from '../ScrollableContainer/scrollbarStyling.js';
|
|
5
5
|
import { inputTokens } from '../../helpers/Input/Input.tokens.js';
|
|
6
6
|
|
|
7
7
|
var TextArea = styled(StatefulInput).withConfig({
|
|
8
8
|
displayName: "TextInputstyles__TextArea",
|
|
9
9
|
componentId: "sc-165zflr-0"
|
|
10
|
-
})(["", " ", " ", " &:hover:enabled:read-write ~ label{background-color:", ";}"], scrollbarStyling, textInputTokens.multiline.base, function (_ref) {
|
|
10
|
+
})(["", " ", " ", " ", " &:hover:enabled:read-write ~ label{background-color:", ";}"], scrollbarStyling.webkit, scrollbarStyling.firefox, textInputTokens.multiline.base, function (_ref) {
|
|
11
11
|
var hasLabel = _ref.hasLabel;
|
|
12
12
|
return css(["", ""], textInputTokens.multiline[hasLabel].base);
|
|
13
13
|
}, function (_ref2) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ddsBaseTokens, ddsReferenceTokens } from '@norges-domstoler/dds-design-tokens';
|
|
2
|
-
import { scrollbarWidthNumberPx } from '
|
|
2
|
+
import { scrollbarWidthNumberPx } from '../ScrollableContainer/ScrollableContainer.tokens.js';
|
|
3
3
|
|
|
4
4
|
var Colors = ddsBaseTokens.colors,
|
|
5
5
|
Spacing = ddsBaseTokens.spacing;
|
|
@@ -4,5 +4,5 @@ declare type SvgChevronProps = {
|
|
|
4
4
|
height?: Property.Height<string>;
|
|
5
5
|
width?: Property.Width<string>;
|
|
6
6
|
};
|
|
7
|
-
export declare const AnimatedChevronUpDown: ({ isUp, height, width }: SvgChevronProps) => JSX.Element;
|
|
7
|
+
export declare const AnimatedChevronUpDown: ({ isUp, height, width, }: SvgChevronProps) => JSX.Element;
|
|
8
8
|
export {};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ddsBaseTokens } from '@norges-domstoler/dds-design-tokens';
|
|
2
2
|
|
|
3
3
|
var Border = ddsBaseTokens.border,
|
|
4
|
-
Colors = ddsBaseTokens.colors
|
|
5
|
-
|
|
4
|
+
Colors = ddsBaseTokens.colors,
|
|
5
|
+
spacing = ddsBaseTokens.spacing;
|
|
6
|
+
var outlineOffset = spacing.SizesDdsSpacingLocalX0125;
|
|
6
7
|
var focusVisible = {
|
|
7
8
|
outline: "".concat(Border.BordersDdsBorderFocusBaseStrokeWeight, " ").concat(Border.BordersDdsBorderFocusBaseStroke, " solid"),
|
|
8
9
|
outlineOffset: outlineOffset
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { Dispatch, SetStateAction } from 'react';
|
|
1
|
+
import { Dispatch, SetStateAction, KeyboardEvent } from 'react';
|
|
2
2
|
import { Direction } from '../types';
|
|
3
|
+
export declare const isKeyboardEvent: (e: Event | KeyboardEvent<Element>) => e is KeyboardEvent<Element>;
|
|
3
4
|
export declare function useRoveFocus(size: number | undefined, reset?: boolean, direction?: Direction): [number, Dispatch<SetStateAction<number>>];
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { slicedToArray as _slicedToArray } from '../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
2
|
import { useState, useCallback, useEffect } from 'react';
|
|
3
3
|
|
|
4
|
+
var isKeyboardEvent = function isKeyboardEvent(e) {
|
|
5
|
+
return e.key !== undefined;
|
|
6
|
+
};
|
|
4
7
|
function useRoveFocus(size, reset) {
|
|
5
8
|
var direction = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'column';
|
|
6
9
|
|
|
@@ -9,17 +12,17 @@ function useRoveFocus(size, reset) {
|
|
|
9
12
|
currentFocus = _useState2[0],
|
|
10
13
|
setCurrentFocus = _useState2[1];
|
|
11
14
|
|
|
12
|
-
var nextKey = direction === 'row' ?
|
|
13
|
-
var previousKey = direction === 'row' ?
|
|
15
|
+
var nextKey = direction === 'row' ? 'ArrowRight' : 'ArrowDown';
|
|
16
|
+
var previousKey = direction === 'row' ? 'ArrowLeft' : 'ArrowUp';
|
|
14
17
|
var handleKeyDown = useCallback(function (e) {
|
|
15
|
-
if (!size) return;
|
|
18
|
+
if (!size || !isKeyboardEvent(e)) return;
|
|
16
19
|
if (reset) setCurrentFocus(-1);
|
|
17
20
|
|
|
18
|
-
if (e.
|
|
21
|
+
if (e.key === nextKey) {
|
|
19
22
|
// Down arrow
|
|
20
23
|
e.preventDefault();
|
|
21
24
|
setCurrentFocus(currentFocus === size - 1 ? 0 : currentFocus + 1);
|
|
22
|
-
} else if (e.
|
|
25
|
+
} else if (e.key === previousKey) {
|
|
23
26
|
// Up arrow
|
|
24
27
|
e.preventDefault();
|
|
25
28
|
|
|
@@ -37,4 +40,4 @@ function useRoveFocus(size, reset) {
|
|
|
37
40
|
return [currentFocus, setCurrentFocus];
|
|
38
41
|
}
|
|
39
42
|
|
|
40
|
-
export { useRoveFocus };
|
|
43
|
+
export { isKeyboardEvent, useRoveFocus };
|
package/dist/index.d.ts
CHANGED
|
@@ -33,5 +33,6 @@ export * from './components/Tabs';
|
|
|
33
33
|
export * from './components/Tag';
|
|
34
34
|
export * from './components/Chip';
|
|
35
35
|
export * from './components/VisuallyHidden';
|
|
36
|
+
export * from './components/ScrollableContainer';
|
|
36
37
|
export * from './icons/tsx';
|
|
37
38
|
export * from './components/Stepper';
|
package/dist/index.js
CHANGED
|
@@ -59,6 +59,9 @@ export { Tag } from './components/Tag/Tag.js';
|
|
|
59
59
|
export { Chip } from './components/Chip/Chip.js';
|
|
60
60
|
export { ChipGroup } from './components/Chip/ChipGroup.js';
|
|
61
61
|
export { VisuallyHidden } from './components/VisuallyHidden/VisuallyHidden.js';
|
|
62
|
+
export { Scrollbar } from './components/ScrollableContainer/Scrollbar.js';
|
|
63
|
+
export { ScrollableContainer } from './components/ScrollableContainer/ScrollableContainer.js';
|
|
64
|
+
export { scrollbarStyling } from './components/ScrollableContainer/scrollbarStyling.js';
|
|
62
65
|
export { AppsIcon } from './icons/tsx/apps.js';
|
|
63
66
|
export { ArchiveIcon } from './icons/tsx/archive.js';
|
|
64
67
|
export { ArrowDownIcon } from './icons/tsx/arrowDown.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@norges-domstoler/dds-components",
|
|
3
|
-
"version": "5.2.0
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"description": "React components used in Elsa - domstolenes designsystem",
|
|
5
5
|
"author": "Elsa team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,16 +20,21 @@
|
|
|
20
20
|
"homepage": "https://design.domstol.no",
|
|
21
21
|
"scripts": {
|
|
22
22
|
"clean": "rm -r dist || :",
|
|
23
|
-
"test": "jest
|
|
24
|
-
"test:watch": "jest --
|
|
23
|
+
"test": "jest",
|
|
24
|
+
"test:watch": "jest --watch",
|
|
25
25
|
"build": "rollup -c",
|
|
26
26
|
"build:watch": "rollup -c -w",
|
|
27
27
|
"storybook": "start-storybook -p 6006 -s ./.storybook/images",
|
|
28
28
|
"build-storybook": "build-storybook -o docs",
|
|
29
29
|
"lint": "eslint --ext=jsx,ts,tsx src",
|
|
30
|
-
"prettier": "prettier --write
|
|
31
|
-
"check
|
|
32
|
-
"build:clean": "npm run clean && npm run build"
|
|
30
|
+
"prettier": "prettier --write .",
|
|
31
|
+
"prettier:check": "prettier --check .",
|
|
32
|
+
"build:clean": "npm run clean && npm run build",
|
|
33
|
+
"verify:types": "tsc --noEmit",
|
|
34
|
+
"verify:lint": "npm run lint",
|
|
35
|
+
"verify:test": "npm test",
|
|
36
|
+
"verify:prettier": "npm run prettier:check",
|
|
37
|
+
"verify": "concurrently 'npm:verify:*'"
|
|
33
38
|
},
|
|
34
39
|
"keywords": [
|
|
35
40
|
"dds",
|
|
@@ -42,53 +47,55 @@
|
|
|
42
47
|
"elsa"
|
|
43
48
|
],
|
|
44
49
|
"devDependencies": {
|
|
45
|
-
"@babel/core": "^7.
|
|
46
|
-
"@babel/preset-env": "^7.
|
|
47
|
-
"@babel/preset-react": "^7.
|
|
48
|
-
"@mdx-js/react": "^2.1.
|
|
50
|
+
"@babel/core": "^7.18.10",
|
|
51
|
+
"@babel/preset-env": "^7.18.10",
|
|
52
|
+
"@babel/preset-react": "^7.18.6",
|
|
53
|
+
"@mdx-js/react": "^2.1.3",
|
|
49
54
|
"@rollup/plugin-babel": "^5.3.1",
|
|
50
55
|
"@rollup/plugin-commonjs": "^22.0.2",
|
|
51
56
|
"@rollup/plugin-image": "^2.1.1",
|
|
52
|
-
"@rollup/plugin-node-resolve": "^13.
|
|
53
|
-
"@storybook/addon-actions": "^6.5.
|
|
54
|
-
"@storybook/addon-essentials": "^6.5.
|
|
55
|
-
"@storybook/addon-links": "^6.5.
|
|
56
|
-
"@storybook/addons": "^6.5.
|
|
57
|
+
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
58
|
+
"@storybook/addon-actions": "^6.5.10",
|
|
59
|
+
"@storybook/addon-essentials": "^6.5.10",
|
|
60
|
+
"@storybook/addon-links": "^6.5.10",
|
|
61
|
+
"@storybook/addons": "^6.5.10",
|
|
57
62
|
"@storybook/mdx2-csf": "^0.0.3",
|
|
58
|
-
"@storybook/react": "^6.5.
|
|
59
|
-
"@storybook/theming": "^6.5.
|
|
60
|
-
"@testing-library/jest-dom": "^5.16.
|
|
61
|
-
"@testing-library/react": "^13.
|
|
62
|
-
"@testing-library/user-event": "^14.
|
|
63
|
-
"@types/jest": "^
|
|
64
|
-
"@types/react": "^
|
|
63
|
+
"@storybook/react": "^6.5.10",
|
|
64
|
+
"@storybook/theming": "^6.5.10",
|
|
65
|
+
"@testing-library/jest-dom": "^5.16.5",
|
|
66
|
+
"@testing-library/react": "^13.3.0",
|
|
67
|
+
"@testing-library/user-event": "^14.4.3",
|
|
68
|
+
"@types/jest": "^28.1.7",
|
|
69
|
+
"@types/react": "^18.0.17",
|
|
65
70
|
"@types/react-dom": "^18.0.6",
|
|
66
|
-
"@types/styled-components": "^5.1.
|
|
67
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
68
|
-
"@typescript-eslint/parser": "^5.
|
|
69
|
-
"babel-loader": "^8.2.
|
|
71
|
+
"@types/styled-components": "^5.1.26",
|
|
72
|
+
"@typescript-eslint/eslint-plugin": "^5.33.1",
|
|
73
|
+
"@typescript-eslint/parser": "^5.33.1",
|
|
74
|
+
"babel-loader": "^8.2.5",
|
|
70
75
|
"babel-plugin-styled-components": "^2.0.7",
|
|
71
|
-
"
|
|
76
|
+
"concurrently": "^7.3.0",
|
|
77
|
+
"eslint": "^8.22.0",
|
|
72
78
|
"eslint-config-prettier": "^8.5.0",
|
|
73
|
-
"eslint-plugin-prettier": "^4.
|
|
74
|
-
"eslint-plugin-react": "^7.
|
|
75
|
-
"eslint-plugin-storybook": "^0.6.
|
|
76
|
-
"jest": "^
|
|
77
|
-
"
|
|
78
|
-
"react
|
|
79
|
-
"
|
|
79
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
80
|
+
"eslint-plugin-react": "^7.30.1",
|
|
81
|
+
"eslint-plugin-storybook": "^0.6.4",
|
|
82
|
+
"jest": "^28.1.3",
|
|
83
|
+
"jest-environment-jsdom": "^28.1.3",
|
|
84
|
+
"react": "^18.2.0",
|
|
85
|
+
"react-dom": "^18.2.0",
|
|
86
|
+
"rollup": "^2.78.1",
|
|
80
87
|
"rollup-plugin-copy": "^3.4.0",
|
|
81
88
|
"rollup-plugin-import-css": "^3.0.3",
|
|
82
|
-
"rollup-plugin-sass": "^1.2.
|
|
83
|
-
"rollup-plugin-typescript2": "^0.
|
|
84
|
-
"ts-jest": "^
|
|
85
|
-
"typescript": "^4.
|
|
89
|
+
"rollup-plugin-sass": "^1.2.13",
|
|
90
|
+
"rollup-plugin-typescript2": "^0.33.0",
|
|
91
|
+
"ts-jest": "^28.0.8",
|
|
92
|
+
"typescript": "^4.7.4"
|
|
86
93
|
},
|
|
87
94
|
"peerDependencies": {
|
|
95
|
+
"@norges-domstoler/dds-design-tokens": "^1.3.0",
|
|
88
96
|
"react": "^16 || ^17 || ^18",
|
|
89
97
|
"react-dom": "^16 || ^17 || ^18",
|
|
90
|
-
"styled-components": "^5"
|
|
91
|
-
"@norges-domstoler/dds-design-tokens": "^1"
|
|
98
|
+
"styled-components": "^5"
|
|
92
99
|
},
|
|
93
100
|
"jest": {
|
|
94
101
|
"preset": "ts-jest",
|
|
@@ -109,11 +116,9 @@
|
|
|
109
116
|
}
|
|
110
117
|
},
|
|
111
118
|
"dependencies": {
|
|
112
|
-
"@emotion/react": "^11.9.0",
|
|
113
|
-
"@emotion/styled": "^11.8.1",
|
|
114
119
|
"@floating-ui/react-dom": "^1.0.0",
|
|
115
120
|
"focus-visible": "^5.2.0",
|
|
116
|
-
"react-select": "^5.
|
|
121
|
+
"react-select": "^5.4.0",
|
|
117
122
|
"tslib": "^2.4.0"
|
|
118
123
|
}
|
|
119
124
|
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { CSSObject } from 'styled-components';
|
|
2
|
-
export declare const descriptionListTermTokens: {
|
|
3
|
-
appearance: {
|
|
4
|
-
small: {
|
|
5
|
-
base: CSSObject;
|
|
6
|
-
};
|
|
7
|
-
bold: {
|
|
8
|
-
base: CSSObject;
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
unwrappedTopAndBottomSpace: string;
|
|
12
|
-
unwrappedBetweenSpace: string;
|
|
13
|
-
};
|