@axinom/mosaic-ui 0.36.0-rc.20 → 0.36.0-rc.21
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/components/DateTime/TimePicker/ScrollColumn/ScrollColumn.d.ts.map +1 -1
- package/dist/index.es.js +4 -4
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/DateTime/TimePicker/ScrollColumn/ScrollColumn.scss +2 -0
- package/src/components/DateTime/TimePicker/ScrollColumn/ScrollColumn.spec.tsx +19 -0
- package/src/components/DateTime/TimePicker/ScrollColumn/ScrollColumn.tsx +20 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axinom/mosaic-ui",
|
|
3
|
-
"version": "0.36.0-rc.
|
|
3
|
+
"version": "0.36.0-rc.21",
|
|
4
4
|
"description": "UI components for building Axinom Mosaic applications",
|
|
5
5
|
"author": "Axinom",
|
|
6
6
|
"license": "PROPRIETARY",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"build-storybook": "storybook build"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@axinom/mosaic-core": "^0.4.9-rc.
|
|
35
|
+
"@axinom/mosaic-core": "^0.4.9-rc.21",
|
|
36
36
|
"@faker-js/faker": "^7.4.0",
|
|
37
37
|
"@popperjs/core": "^2.9.2",
|
|
38
38
|
"clsx": "^1.1.0",
|
|
@@ -104,5 +104,5 @@
|
|
|
104
104
|
"publishConfig": {
|
|
105
105
|
"access": "public"
|
|
106
106
|
},
|
|
107
|
-
"gitHead": "
|
|
107
|
+
"gitHead": "6bb383f5b32f71867fc9b78f37bf5bf23facc481"
|
|
108
108
|
}
|
|
@@ -54,4 +54,23 @@ describe('ScrollColumn', () => {
|
|
|
54
54
|
|
|
55
55
|
expect(selectedSpy).toHaveBeenCalled();
|
|
56
56
|
});
|
|
57
|
+
|
|
58
|
+
it('fires onSelected event when an item is selected through the wheel', () => {
|
|
59
|
+
const itemContent = 'test';
|
|
60
|
+
const selectedSpy = jest.fn();
|
|
61
|
+
const wrapper = mount(
|
|
62
|
+
<ScrollColumn
|
|
63
|
+
items={[itemContent]}
|
|
64
|
+
selectedItem={null}
|
|
65
|
+
isActive={true}
|
|
66
|
+
onSelected={selectedSpy}
|
|
67
|
+
/>,
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
const item = wrapper.find('.item');
|
|
71
|
+
|
|
72
|
+
item.simulate('wheel', { deltaY: 1 });
|
|
73
|
+
|
|
74
|
+
expect(selectedSpy).toHaveBeenCalled();
|
|
75
|
+
});
|
|
57
76
|
});
|
|
@@ -53,20 +53,37 @@ export const ScrollColumn = <T,>({
|
|
|
53
53
|
transform: `translate(0, ${scrollerTranslate}px)`,
|
|
54
54
|
};
|
|
55
55
|
|
|
56
|
+
const selectPrevious = () => {
|
|
57
|
+
onSelected(items[selectedIndex - 1]);
|
|
58
|
+
};
|
|
59
|
+
const selectNext = () => {
|
|
60
|
+
onSelected(items[selectedIndex + 1]);
|
|
61
|
+
};
|
|
62
|
+
|
|
56
63
|
return (
|
|
57
64
|
<div className={classes.container}>
|
|
58
65
|
<button
|
|
59
66
|
className={clsx(classes.button, !isActive && classes.hidden)}
|
|
60
67
|
onClick={(e) => {
|
|
61
68
|
e.preventDefault();
|
|
62
|
-
|
|
69
|
+
selectPrevious();
|
|
63
70
|
}}
|
|
64
71
|
>
|
|
65
72
|
<Icons icon={IconName.ChevronUp} className={classes.icon} />
|
|
66
73
|
</button>
|
|
67
74
|
<div className={classes['scroll-container']} style={containerStyles}>
|
|
68
75
|
{isActive ? (
|
|
69
|
-
<div
|
|
76
|
+
<div
|
|
77
|
+
className={classes.scroller}
|
|
78
|
+
style={scrollerStyles}
|
|
79
|
+
onWheel={(e) => {
|
|
80
|
+
if (e.deltaY > 0) {
|
|
81
|
+
selectNext();
|
|
82
|
+
} else {
|
|
83
|
+
selectPrevious();
|
|
84
|
+
}
|
|
85
|
+
}}
|
|
86
|
+
>
|
|
70
87
|
{items.map((item, key) => {
|
|
71
88
|
return (
|
|
72
89
|
<button
|
|
@@ -121,11 +138,7 @@ export const ScrollColumn = <T,>({
|
|
|
121
138
|
className={clsx(classes.button, !isActive && classes.hidden)}
|
|
122
139
|
onClick={(e) => {
|
|
123
140
|
e.preventDefault();
|
|
124
|
-
|
|
125
|
-
selectedIndex < items.length - 1
|
|
126
|
-
? items[selectedIndex + 1]
|
|
127
|
-
: items[items.length - 1],
|
|
128
|
-
);
|
|
141
|
+
selectNext();
|
|
129
142
|
}}
|
|
130
143
|
>
|
|
131
144
|
<Icons icon={IconName.ChevronDown} className={classes.icon} />
|