@workday/canvas-kit-react 8.3.10 → 8.3.12
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/commonjs/tabs/lib/TabsList.d.ts +4 -0
- package/dist/commonjs/tabs/lib/TabsList.d.ts.map +1 -1
- package/dist/commonjs/tabs/lib/TabsList.js +42 -14
- package/dist/es6/tabs/lib/TabsList.d.ts +4 -0
- package/dist/es6/tabs/lib/TabsList.d.ts.map +1 -1
- package/dist/es6/tabs/lib/TabsList.js +40 -13
- package/package.json +3 -3
- package/tabs/lib/TabsList.tsx +45 -14
|
@@ -229,4 +229,8 @@ export declare const TabsList: import("../../common").ElementComponentM<"div", T
|
|
|
229
229
|
navigation: import("../../collection/lib/useCursorListModel").NavigationManager;
|
|
230
230
|
getId: (item: any) => string;
|
|
231
231
|
}>;
|
|
232
|
+
export declare const useTouchDirection: () => {
|
|
233
|
+
direction: string;
|
|
234
|
+
isDragging: boolean;
|
|
235
|
+
};
|
|
232
236
|
//# sourceMappingURL=TabsList.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabsList.d.ts","sourceRoot":"","sources":["../../../../tabs/lib/TabsList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAIL,YAAY,EAIb,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAC,KAAK,EAAC,MAAM,kCAAkC,CAAC;AAUvD,MAAM,WAAW,YAAY,CAAC,CAAC,GAAG,GAAG,CACnC,SAAQ,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC;IACpE;;;;;;;;OAQG;IACH,QAAQ,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,KAAK,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC;IAC3D,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAClC;AAED,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAOvB,CAAC;
|
|
1
|
+
{"version":3,"file":"TabsList.d.ts","sourceRoot":"","sources":["../../../../tabs/lib/TabsList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAIL,YAAY,EAIb,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAC,KAAK,EAAC,MAAM,kCAAkC,CAAC;AAUvD,MAAM,WAAW,YAAY,CAAC,CAAC,GAAG,GAAG,CACnC,SAAQ,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC;IACpE;;;;;;;;OAQG;IACH,QAAQ,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,KAAK,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC;IAC3D,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAClC;AAED,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAOvB,CAAC;AAMF,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2BnB,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;CA+B7B,CAAC"}
|
|
@@ -41,7 +41,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
41
41
|
return t;
|
|
42
42
|
};
|
|
43
43
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
-
exports.TabsList = exports.useTabsList = void 0;
|
|
44
|
+
exports.useTouchDirection = exports.TabsList = exports.useTabsList = void 0;
|
|
45
45
|
var React = __importStar(require("react"));
|
|
46
46
|
var tokens_1 = require("@workday/canvas-kit-react/tokens");
|
|
47
47
|
var common_1 = require("@workday/canvas-kit-react/common");
|
|
@@ -52,18 +52,11 @@ exports.useTabsList = common_1.composeHooks(common_1.createElemPropsHook(useTabs
|
|
|
52
52
|
var modality = common_1.useModalityType();
|
|
53
53
|
return { role: 'tablist', overflowX: modality === 'touch' ? 'auto' : undefined };
|
|
54
54
|
}), collection_1.useOverflowListMeasure, collection_1.useListResetCursorOnBlur);
|
|
55
|
-
var StyledStack = common_1.styled(layout_1.Stack)({
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
minWidth: 30,
|
|
61
|
-
background: "linear-gradient(to right,rgba(255,255,255,0),white);",
|
|
62
|
-
zIndex: 1,
|
|
63
|
-
right: 0,
|
|
64
|
-
top: 0,
|
|
65
|
-
pointerEvents: 'none',
|
|
66
|
-
},
|
|
55
|
+
var StyledStack = common_1.styled(layout_1.Stack)(function (_a) {
|
|
56
|
+
var maskImage = _a.maskImage;
|
|
57
|
+
return ({
|
|
58
|
+
maskImage: maskImage,
|
|
59
|
+
});
|
|
67
60
|
});
|
|
68
61
|
exports.TabsList = common_1.createSubcomponent('div')({
|
|
69
62
|
displayName: 'Tabs.List',
|
|
@@ -72,7 +65,42 @@ exports.TabsList = common_1.createSubcomponent('div')({
|
|
|
72
65
|
})(function (_a, Element, model) {
|
|
73
66
|
var children = _a.children, overflowButton = _a.overflowButton, elemProps = __rest(_a, ["children", "overflowButton"]);
|
|
74
67
|
var modality = common_1.useModalityType();
|
|
75
|
-
|
|
68
|
+
var touchStates = exports.useTouchDirection();
|
|
69
|
+
return (React.createElement(StyledStack, __assign({ as: Element, position: "relative", borderBottom: "1px solid " + tokens_1.commonColors.divider, paddingX: modality === 'touch' ? 'zero' : 'm', spacing: "xs", maskImage: modality === 'touch' && touchStates.isDragging
|
|
70
|
+
? "linear-gradient(" + (touchStates.direction === 'left' ? 'to left' : 'to right') + ", white 80%, transparent)"
|
|
71
|
+
: undefined }, elemProps),
|
|
76
72
|
collection_1.useListRenderItems(model, children),
|
|
77
73
|
overflowButton));
|
|
78
74
|
});
|
|
75
|
+
var useTouchDirection = function () {
|
|
76
|
+
var _a = React.useState(false), isDragging = _a[0], setIsDragging = _a[1];
|
|
77
|
+
var _b = React.useState('right'), touchDir = _b[0], setTouchDirection = _b[1];
|
|
78
|
+
React.useEffect(function () {
|
|
79
|
+
var prevXPos = window.pageXOffset;
|
|
80
|
+
var handleTouchMove = function (e) {
|
|
81
|
+
var currXPos = e.touches[0].clientX;
|
|
82
|
+
setIsDragging(true);
|
|
83
|
+
if (currXPos > prevXPos) {
|
|
84
|
+
setTouchDirection('left');
|
|
85
|
+
}
|
|
86
|
+
else if (currXPos < prevXPos) {
|
|
87
|
+
setTouchDirection('right');
|
|
88
|
+
}
|
|
89
|
+
prevXPos = currXPos;
|
|
90
|
+
e.preventDefault();
|
|
91
|
+
};
|
|
92
|
+
var handleDragEnd = function () {
|
|
93
|
+
setIsDragging(false);
|
|
94
|
+
};
|
|
95
|
+
window.addEventListener('touchmove', handleTouchMove);
|
|
96
|
+
window.addEventListener('touchstart', handleDragEnd);
|
|
97
|
+
window.addEventListener('touchend', handleDragEnd);
|
|
98
|
+
return function () {
|
|
99
|
+
window.removeEventListener('touchmove', handleTouchMove);
|
|
100
|
+
window.removeEventListener('touchstart', handleDragEnd);
|
|
101
|
+
window.removeEventListener('touchend', handleDragEnd);
|
|
102
|
+
};
|
|
103
|
+
}, []);
|
|
104
|
+
return { direction: touchDir, isDragging: isDragging };
|
|
105
|
+
};
|
|
106
|
+
exports.useTouchDirection = useTouchDirection;
|
|
@@ -229,4 +229,8 @@ export declare const TabsList: import("../../common").ElementComponentM<"div", T
|
|
|
229
229
|
navigation: import("../../collection/lib/useCursorListModel").NavigationManager;
|
|
230
230
|
getId: (item: any) => string;
|
|
231
231
|
}>;
|
|
232
|
+
export declare const useTouchDirection: () => {
|
|
233
|
+
direction: string;
|
|
234
|
+
isDragging: boolean;
|
|
235
|
+
};
|
|
232
236
|
//# sourceMappingURL=TabsList.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabsList.d.ts","sourceRoot":"","sources":["../../../../tabs/lib/TabsList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAIL,YAAY,EAIb,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAC,KAAK,EAAC,MAAM,kCAAkC,CAAC;AAUvD,MAAM,WAAW,YAAY,CAAC,CAAC,GAAG,GAAG,CACnC,SAAQ,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC;IACpE;;;;;;;;OAQG;IACH,QAAQ,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,KAAK,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC;IAC3D,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAClC;AAED,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAOvB,CAAC;
|
|
1
|
+
{"version":3,"file":"TabsList.d.ts","sourceRoot":"","sources":["../../../../tabs/lib/TabsList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAIL,YAAY,EAIb,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAC,KAAK,EAAC,MAAM,kCAAkC,CAAC;AAUvD,MAAM,WAAW,YAAY,CAAC,CAAC,GAAG,GAAG,CACnC,SAAQ,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC;IACpE;;;;;;;;OAQG;IACH,QAAQ,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,KAAK,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC;IAC3D,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAClC;AAED,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAOvB,CAAC;AAMF,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2BnB,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;CA+B7B,CAAC"}
|
|
@@ -30,18 +30,11 @@ export var useTabsList = composeHooks(createElemPropsHook(useTabsModel)(function
|
|
|
30
30
|
var modality = useModalityType();
|
|
31
31
|
return { role: 'tablist', overflowX: modality === 'touch' ? 'auto' : undefined };
|
|
32
32
|
}), useOverflowListMeasure, useListResetCursorOnBlur);
|
|
33
|
-
var StyledStack = styled(Stack)({
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
minWidth: 30,
|
|
39
|
-
background: "linear-gradient(to right,rgba(255,255,255,0),white);",
|
|
40
|
-
zIndex: 1,
|
|
41
|
-
right: 0,
|
|
42
|
-
top: 0,
|
|
43
|
-
pointerEvents: 'none',
|
|
44
|
-
},
|
|
33
|
+
var StyledStack = styled(Stack)(function (_a) {
|
|
34
|
+
var maskImage = _a.maskImage;
|
|
35
|
+
return ({
|
|
36
|
+
maskImage: maskImage,
|
|
37
|
+
});
|
|
45
38
|
});
|
|
46
39
|
export var TabsList = createSubcomponent('div')({
|
|
47
40
|
displayName: 'Tabs.List',
|
|
@@ -50,7 +43,41 @@ export var TabsList = createSubcomponent('div')({
|
|
|
50
43
|
})(function (_a, Element, model) {
|
|
51
44
|
var children = _a.children, overflowButton = _a.overflowButton, elemProps = __rest(_a, ["children", "overflowButton"]);
|
|
52
45
|
var modality = useModalityType();
|
|
53
|
-
|
|
46
|
+
var touchStates = useTouchDirection();
|
|
47
|
+
return (React.createElement(StyledStack, __assign({ as: Element, position: "relative", borderBottom: "1px solid " + commonColors.divider, paddingX: modality === 'touch' ? 'zero' : 'm', spacing: "xs", maskImage: modality === 'touch' && touchStates.isDragging
|
|
48
|
+
? "linear-gradient(" + (touchStates.direction === 'left' ? 'to left' : 'to right') + ", white 80%, transparent)"
|
|
49
|
+
: undefined }, elemProps),
|
|
54
50
|
useListRenderItems(model, children),
|
|
55
51
|
overflowButton));
|
|
56
52
|
});
|
|
53
|
+
export var useTouchDirection = function () {
|
|
54
|
+
var _a = React.useState(false), isDragging = _a[0], setIsDragging = _a[1];
|
|
55
|
+
var _b = React.useState('right'), touchDir = _b[0], setTouchDirection = _b[1];
|
|
56
|
+
React.useEffect(function () {
|
|
57
|
+
var prevXPos = window.pageXOffset;
|
|
58
|
+
var handleTouchMove = function (e) {
|
|
59
|
+
var currXPos = e.touches[0].clientX;
|
|
60
|
+
setIsDragging(true);
|
|
61
|
+
if (currXPos > prevXPos) {
|
|
62
|
+
setTouchDirection('left');
|
|
63
|
+
}
|
|
64
|
+
else if (currXPos < prevXPos) {
|
|
65
|
+
setTouchDirection('right');
|
|
66
|
+
}
|
|
67
|
+
prevXPos = currXPos;
|
|
68
|
+
e.preventDefault();
|
|
69
|
+
};
|
|
70
|
+
var handleDragEnd = function () {
|
|
71
|
+
setIsDragging(false);
|
|
72
|
+
};
|
|
73
|
+
window.addEventListener('touchmove', handleTouchMove);
|
|
74
|
+
window.addEventListener('touchstart', handleDragEnd);
|
|
75
|
+
window.addEventListener('touchend', handleDragEnd);
|
|
76
|
+
return function () {
|
|
77
|
+
window.removeEventListener('touchmove', handleTouchMove);
|
|
78
|
+
window.removeEventListener('touchstart', handleDragEnd);
|
|
79
|
+
window.removeEventListener('touchend', handleDragEnd);
|
|
80
|
+
};
|
|
81
|
+
}, []);
|
|
82
|
+
return { direction: touchDir, isDragging: isDragging };
|
|
83
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workday/canvas-kit-react",
|
|
3
|
-
"version": "8.3.
|
|
3
|
+
"version": "8.3.12",
|
|
4
4
|
"description": "The parent module that contains all Workday Canvas Kit React components",
|
|
5
5
|
"author": "Workday, Inc. (https://www.workday.com)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@emotion/styled": "^11.6.0",
|
|
50
50
|
"@popperjs/core": "^2.5.4",
|
|
51
51
|
"@workday/canvas-colors-web": "^2.0.0",
|
|
52
|
-
"@workday/canvas-kit-popup-stack": "^8.3.
|
|
52
|
+
"@workday/canvas-kit-popup-stack": "^8.3.12",
|
|
53
53
|
"@workday/canvas-system-icons-web": "^3.0.0",
|
|
54
54
|
"@workday/design-assets-types": "^0.2.8",
|
|
55
55
|
"chroma-js": "^2.1.0",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"@workday/canvas-accent-icons-web": "^3.0.0",
|
|
68
68
|
"@workday/canvas-applet-icons-web": "^2.0.0"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "d25589ebd7cfc15b5c2b532b055f657201610484"
|
|
71
71
|
}
|
package/tabs/lib/TabsList.tsx
CHANGED
|
@@ -44,19 +44,9 @@ export const useTabsList = composeHooks(
|
|
|
44
44
|
useListResetCursorOnBlur
|
|
45
45
|
);
|
|
46
46
|
|
|
47
|
-
const StyledStack = styled(Stack)<StyledType>({
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
position: 'sticky',
|
|
51
|
-
height: 52,
|
|
52
|
-
minWidth: 30,
|
|
53
|
-
background: `linear-gradient(to right,rgba(255,255,255,0),white);`,
|
|
54
|
-
zIndex: 1,
|
|
55
|
-
right: 0,
|
|
56
|
-
top: 0,
|
|
57
|
-
pointerEvents: 'none',
|
|
58
|
-
},
|
|
59
|
-
});
|
|
47
|
+
const StyledStack = styled(Stack)<StyledType & {maskImage?: string}>(({maskImage}) => ({
|
|
48
|
+
maskImage: maskImage,
|
|
49
|
+
}));
|
|
60
50
|
|
|
61
51
|
export const TabsList = createSubcomponent('div')({
|
|
62
52
|
displayName: 'Tabs.List',
|
|
@@ -64,13 +54,21 @@ export const TabsList = createSubcomponent('div')({
|
|
|
64
54
|
elemPropsHook: useTabsList,
|
|
65
55
|
})<TabListProps>(({children, overflowButton, ...elemProps}, Element, model) => {
|
|
66
56
|
const modality = useModalityType();
|
|
57
|
+
const touchStates = useTouchDirection();
|
|
67
58
|
return (
|
|
68
59
|
<StyledStack
|
|
69
60
|
as={Element}
|
|
70
61
|
position="relative"
|
|
71
62
|
borderBottom={`1px solid ${commonColors.divider}`}
|
|
72
63
|
paddingX={modality === 'touch' ? 'zero' : 'm'}
|
|
73
|
-
spacing="
|
|
64
|
+
spacing="xs"
|
|
65
|
+
maskImage={
|
|
66
|
+
modality === 'touch' && touchStates.isDragging
|
|
67
|
+
? `linear-gradient(${
|
|
68
|
+
touchStates.direction === 'left' ? 'to left' : 'to right'
|
|
69
|
+
}, white 80%, transparent)`
|
|
70
|
+
: undefined
|
|
71
|
+
}
|
|
74
72
|
{...elemProps}
|
|
75
73
|
>
|
|
76
74
|
{useListRenderItems(model, children)}
|
|
@@ -78,3 +76,36 @@ export const TabsList = createSubcomponent('div')({
|
|
|
78
76
|
</StyledStack>
|
|
79
77
|
);
|
|
80
78
|
});
|
|
79
|
+
|
|
80
|
+
export const useTouchDirection = () => {
|
|
81
|
+
const [isDragging, setIsDragging] = React.useState(false);
|
|
82
|
+
const [touchDir, setTouchDirection] = React.useState('right');
|
|
83
|
+
|
|
84
|
+
React.useEffect(() => {
|
|
85
|
+
let prevXPos = window.pageXOffset;
|
|
86
|
+
const handleTouchMove = function(e: TouchEvent) {
|
|
87
|
+
const currXPos = e.touches[0].clientX;
|
|
88
|
+
setIsDragging(true);
|
|
89
|
+
if (currXPos > prevXPos) {
|
|
90
|
+
setTouchDirection('left');
|
|
91
|
+
} else if (currXPos < prevXPos) {
|
|
92
|
+
setTouchDirection('right');
|
|
93
|
+
}
|
|
94
|
+
prevXPos = currXPos;
|
|
95
|
+
e.preventDefault();
|
|
96
|
+
};
|
|
97
|
+
const handleDragEnd = function() {
|
|
98
|
+
setIsDragging(false);
|
|
99
|
+
};
|
|
100
|
+
window.addEventListener('touchmove', handleTouchMove);
|
|
101
|
+
window.addEventListener('touchstart', handleDragEnd);
|
|
102
|
+
window.addEventListener('touchend', handleDragEnd);
|
|
103
|
+
return () => {
|
|
104
|
+
window.removeEventListener('touchmove', handleTouchMove);
|
|
105
|
+
window.removeEventListener('touchstart', handleDragEnd);
|
|
106
|
+
window.removeEventListener('touchend', handleDragEnd);
|
|
107
|
+
};
|
|
108
|
+
}, []);
|
|
109
|
+
|
|
110
|
+
return {direction: touchDir, isDragging: isDragging};
|
|
111
|
+
};
|