@workday/canvas-kit-react 5.3.0-next.9 → 5.3.3
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/common/lib/styles/accessibleHide.ts +2 -2
- package/cookie-banner/README.md +10 -15
- package/cookie-banner/index.ts +3 -3
- package/cookie-banner/lib/CookieBanner.tsx +4 -29
- package/dist/commonjs/common/lib/styles/accessibleHide.d.ts +2 -2
- package/dist/commonjs/common/lib/styles/accessibleHide.d.ts.map +1 -1
- package/dist/commonjs/cookie-banner/index.d.ts +3 -3
- package/dist/commonjs/cookie-banner/index.d.ts.map +1 -1
- package/dist/commonjs/cookie-banner/index.js +1 -1
- package/dist/commonjs/cookie-banner/lib/CookieBanner.d.ts +2 -19
- package/dist/commonjs/cookie-banner/lib/CookieBanner.d.ts.map +1 -1
- package/dist/commonjs/cookie-banner/lib/CookieBanner.js +8 -19
- package/dist/commonjs/page-header/index.d.ts +3 -3
- package/dist/commonjs/page-header/index.d.ts.map +1 -1
- package/dist/commonjs/page-header/index.js +1 -1
- package/dist/commonjs/page-header/lib/PageHeader.d.ts +2 -19
- package/dist/commonjs/page-header/lib/PageHeader.d.ts.map +1 -1
- package/dist/commonjs/page-header/lib/PageHeader.js +7 -18
- package/dist/commonjs/pagination/lib/Pagination/GoTo/Label.d.ts +3 -0
- package/dist/commonjs/pagination/lib/Pagination/GoTo/Label.d.ts.map +1 -1
- package/dist/commonjs/pagination/lib/Pagination/types.d.ts +39 -0
- package/dist/commonjs/pagination/lib/Pagination/types.d.ts.map +1 -1
- package/dist/commonjs/pagination/lib/Pagination/usePaginationModel.d.ts +19 -0
- package/dist/commonjs/pagination/lib/Pagination/usePaginationModel.d.ts.map +1 -1
- package/dist/commonjs/tabs/lib/Tab.d.ts.map +1 -1
- package/dist/commonjs/tabs/lib/Tab.js +18 -24
- package/dist/commonjs/tooltip/lib/OverflowTooltip.d.ts +10 -0
- package/dist/commonjs/tooltip/lib/OverflowTooltip.d.ts.map +1 -1
- package/dist/commonjs/tooltip/lib/OverflowTooltip.js +8 -6
- package/dist/commonjs/tooltip/lib/Tooltip.d.ts +9 -1
- package/dist/commonjs/tooltip/lib/Tooltip.d.ts.map +1 -1
- package/dist/commonjs/tooltip/lib/Tooltip.js +7 -2
- package/dist/commonjs/tooltip/lib/useTooltip.d.ts +9 -1
- package/dist/commonjs/tooltip/lib/useTooltip.d.ts.map +1 -1
- package/dist/commonjs/tooltip/lib/useTooltip.js +13 -8
- package/dist/es6/common/lib/styles/accessibleHide.d.ts +2 -2
- package/dist/es6/common/lib/styles/accessibleHide.d.ts.map +1 -1
- package/dist/es6/cookie-banner/index.d.ts +3 -3
- package/dist/es6/cookie-banner/index.d.ts.map +1 -1
- package/dist/es6/cookie-banner/index.js +3 -3
- package/dist/es6/cookie-banner/lib/CookieBanner.d.ts +2 -19
- package/dist/es6/cookie-banner/lib/CookieBanner.d.ts.map +1 -1
- package/dist/es6/cookie-banner/lib/CookieBanner.js +8 -19
- package/dist/es6/page-header/index.d.ts +3 -3
- package/dist/es6/page-header/index.d.ts.map +1 -1
- package/dist/es6/page-header/index.js +3 -3
- package/dist/es6/page-header/lib/PageHeader.d.ts +2 -19
- package/dist/es6/page-header/lib/PageHeader.d.ts.map +1 -1
- package/dist/es6/page-header/lib/PageHeader.js +7 -18
- package/dist/es6/pagination/lib/Pagination/GoTo/Label.d.ts +3 -0
- package/dist/es6/pagination/lib/Pagination/GoTo/Label.d.ts.map +1 -1
- package/dist/es6/pagination/lib/Pagination/types.d.ts +39 -0
- package/dist/es6/pagination/lib/Pagination/types.d.ts.map +1 -1
- package/dist/es6/pagination/lib/Pagination/usePaginationModel.d.ts +19 -0
- package/dist/es6/pagination/lib/Pagination/usePaginationModel.d.ts.map +1 -1
- package/dist/es6/tabs/lib/Tab.d.ts.map +1 -1
- package/dist/es6/tabs/lib/Tab.js +18 -24
- package/dist/es6/tooltip/lib/OverflowTooltip.d.ts +10 -0
- package/dist/es6/tooltip/lib/OverflowTooltip.d.ts.map +1 -1
- package/dist/es6/tooltip/lib/OverflowTooltip.js +5 -3
- package/dist/es6/tooltip/lib/Tooltip.d.ts +9 -1
- package/dist/es6/tooltip/lib/Tooltip.d.ts.map +1 -1
- package/dist/es6/tooltip/lib/Tooltip.js +7 -2
- package/dist/es6/tooltip/lib/useTooltip.d.ts +9 -1
- package/dist/es6/tooltip/lib/useTooltip.d.ts.map +1 -1
- package/dist/es6/tooltip/lib/useTooltip.js +13 -8
- package/package.json +5 -5
- package/page-header/README.md +6 -11
- package/page-header/index.ts +3 -3
- package/page-header/lib/PageHeader.tsx +3 -28
- package/pagination/lib/Pagination/GoTo/Label.tsx +3 -0
- package/pagination/lib/Pagination/types.ts +44 -5
- package/pagination/lib/Pagination/usePaginationModel.ts +19 -0
- package/tabs/lib/Tab.tsx +53 -59
- package/tooltip/lib/OverflowTooltip.tsx +5 -3
- package/tooltip/lib/Tooltip.tsx +16 -1
- package/tooltip/lib/useTooltip.tsx +21 -6
- package/ts3.5/dist/commonjs/common/lib/styles/accessibleHide.d.ts +2 -2
- package/ts3.5/dist/commonjs/cookie-banner/index.d.ts +3 -3
- package/ts3.5/dist/commonjs/cookie-banner/lib/CookieBanner.d.ts +2 -19
- package/ts3.5/dist/commonjs/page-header/index.d.ts +3 -3
- package/ts3.5/dist/commonjs/page-header/lib/PageHeader.d.ts +2 -19
- package/ts3.5/dist/commonjs/pagination/lib/Pagination/GoTo/Label.d.ts +3 -0
- package/ts3.5/dist/commonjs/pagination/lib/Pagination/types.d.ts +39 -0
- package/ts3.5/dist/commonjs/pagination/lib/Pagination/usePaginationModel.d.ts +19 -0
- package/ts3.5/dist/commonjs/tooltip/lib/OverflowTooltip.d.ts +10 -0
- package/ts3.5/dist/commonjs/tooltip/lib/Tooltip.d.ts +9 -1
- package/ts3.5/dist/commonjs/tooltip/lib/useTooltip.d.ts +9 -1
- package/ts3.5/dist/es6/common/lib/styles/accessibleHide.d.ts +2 -2
- package/ts3.5/dist/es6/cookie-banner/index.d.ts +3 -3
- package/ts3.5/dist/es6/cookie-banner/lib/CookieBanner.d.ts +2 -19
- package/ts3.5/dist/es6/page-header/index.d.ts +3 -3
- package/ts3.5/dist/es6/page-header/lib/PageHeader.d.ts +2 -19
- package/ts3.5/dist/es6/pagination/lib/Pagination/GoTo/Label.d.ts +3 -0
- package/ts3.5/dist/es6/pagination/lib/Pagination/types.d.ts +39 -0
- package/ts3.5/dist/es6/pagination/lib/Pagination/usePaginationModel.d.ts +19 -0
- package/ts3.5/dist/es6/tooltip/lib/OverflowTooltip.d.ts +10 -0
- package/ts3.5/dist/es6/tooltip/lib/Tooltip.d.ts +9 -1
- package/ts3.5/dist/es6/tooltip/lib/useTooltip.d.ts +9 -1
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
* Convenience hook for creating components with tooltips. It will return an object of properties to mix
|
|
4
4
|
* into a target, popper and tooltip
|
|
5
5
|
*/
|
|
6
|
-
export declare function useTooltip<T extends Element = Element>({ type, titleText, }?: {
|
|
6
|
+
export declare function useTooltip<T extends Element = Element>({ type, titleText, showDelay, hideDelay, }?: {
|
|
7
7
|
/**
|
|
8
8
|
* Determines the tooltip type for accessibility.
|
|
9
9
|
*
|
|
@@ -25,6 +25,14 @@ export declare function useTooltip<T extends Element = Element>({ type, titleTex
|
|
|
25
25
|
* The content of the `aria-label` if `type` is `label.
|
|
26
26
|
*/
|
|
27
27
|
titleText?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Amount of time (in ms) to delay before showing the tooltip
|
|
30
|
+
*/
|
|
31
|
+
showDelay?: number;
|
|
32
|
+
/**
|
|
33
|
+
* Amount of time (in ms) to delay before hiding the tooltip
|
|
34
|
+
*/
|
|
35
|
+
hideDelay?: number;
|
|
28
36
|
}): {
|
|
29
37
|
/** Mix these properties into the target element. **Must be an Element** */
|
|
30
38
|
targetProps: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTooltip.d.ts","sourceRoot":"","sources":["../../../../tooltip/lib/useTooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAiD/B;;;GAGG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,EAAE,EACtD,IAAc,EACd,SAAc,
|
|
1
|
+
{"version":3,"file":"useTooltip.d.ts","sourceRoot":"","sources":["../../../../tooltip/lib/useTooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAiD/B;;;GAGG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,EAAE,EACtD,IAAc,EACd,SAAc,EACd,SAAe,EACf,SAAe,GAChB,GAAE;IACD;;;;;;;;;;;;;;;OAeG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,UAAU,GAAG,OAAO,CAAC;IACtC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACf;IA4CF,2EAA2E;;;;;;;;;;IAY3E,uDAAuD;;;;;;IAMvD,iEAAiE;;;;;;;EAQpE"}
|
|
@@ -41,15 +41,20 @@ var isInteractiveElement = function (element) {
|
|
|
41
41
|
* into a target, popper and tooltip
|
|
42
42
|
*/
|
|
43
43
|
export function useTooltip(_a) {
|
|
44
|
-
var _b = _a === void 0 ? {} : _a, _c = _b.type, type = _c === void 0 ? 'label' : _c, _d = _b.titleText, titleText = _d === void 0 ? '' : _d;
|
|
44
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.type, type = _c === void 0 ? 'label' : _c, _d = _b.titleText, titleText = _d === void 0 ? '' : _d, _e = _b.showDelay, showDelay = _e === void 0 ? 300 : _e, _f = _b.hideDelay, hideDelay = _f === void 0 ? 100 : _f;
|
|
45
45
|
var mouseDownRef = React.useRef(false); // use to prevent newly focused from making tooltip flash
|
|
46
46
|
var popupModel = usePopupModel();
|
|
47
|
-
var
|
|
47
|
+
var _g = React.useState(null), anchorElement = _g[0], setAnchorElement = _g[1];
|
|
48
48
|
var id = React.useState(function () { return uuid(); })[0];
|
|
49
|
-
var
|
|
49
|
+
var intentTimerHide = useIntentTimer(popupModel.events.hide, hideDelay);
|
|
50
|
+
var intentTimerShow = useIntentTimer(popupModel.events.show, showDelay);
|
|
51
|
+
var onHide = function () {
|
|
52
|
+
intentTimerHide.start();
|
|
53
|
+
intentTimerShow.clear();
|
|
54
|
+
};
|
|
50
55
|
var onOpen = function () {
|
|
51
|
-
|
|
52
|
-
|
|
56
|
+
intentTimerShow.start();
|
|
57
|
+
intentTimerHide.clear();
|
|
53
58
|
};
|
|
54
59
|
var onOpenFromTarget = function (event) {
|
|
55
60
|
setAnchorElement(event.currentTarget);
|
|
@@ -78,10 +83,10 @@ export function useTooltip(_a) {
|
|
|
78
83
|
// This will replace the accessible name of the target element
|
|
79
84
|
'aria-label': type === 'label' ? titleText : undefined,
|
|
80
85
|
onMouseEnter: onOpenFromTarget,
|
|
81
|
-
onMouseLeave:
|
|
86
|
+
onMouseLeave: onHide,
|
|
82
87
|
onMouseDown: onMouseDown,
|
|
83
88
|
onFocus: onFocus,
|
|
84
|
-
onBlur:
|
|
89
|
+
onBlur: onHide,
|
|
85
90
|
},
|
|
86
91
|
/** Mix these properties into the `Popper` component */
|
|
87
92
|
popperProps: {
|
|
@@ -94,7 +99,7 @@ export function useTooltip(_a) {
|
|
|
94
99
|
id: type === 'describe' && visible ? id : undefined,
|
|
95
100
|
role: 'tooltip',
|
|
96
101
|
onMouseEnter: onOpen,
|
|
97
|
-
onMouseLeave:
|
|
102
|
+
onMouseLeave: onHide,
|
|
98
103
|
},
|
|
99
104
|
};
|
|
100
105
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workday/canvas-kit-react",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.3",
|
|
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",
|
|
@@ -57,9 +57,9 @@
|
|
|
57
57
|
"@popperjs/core": "^2.5.4",
|
|
58
58
|
"@workday/canvas-colors-web": "^2.0.0",
|
|
59
59
|
"@workday/canvas-depth-web": "^0.16.4",
|
|
60
|
-
"@workday/canvas-kit-labs-react": "^5.3.
|
|
61
|
-
"@workday/canvas-kit-popup-stack": "^5.3.
|
|
62
|
-
"@workday/canvas-kit-preview-react": "^5.3.
|
|
60
|
+
"@workday/canvas-kit-labs-react": "^5.3.3",
|
|
61
|
+
"@workday/canvas-kit-popup-stack": "^5.3.3",
|
|
62
|
+
"@workday/canvas-kit-preview-react": "^5.3.3",
|
|
63
63
|
"@workday/canvas-system-icons-web": "1.0.41",
|
|
64
64
|
"@workday/design-assets-types": "^0.2.4",
|
|
65
65
|
"chroma-js": "^2.1.0",
|
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
"@workday/canvas-accent-icons-web": "^1.0.0",
|
|
76
76
|
"@workday/canvas-applet-icons-web": "^0.17.50"
|
|
77
77
|
},
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "a7a2e0b0ba0e84487df0113fba21b4f22dcd38e9"
|
|
79
79
|
}
|
package/page-header/README.md
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
# Canvas Kit Page Header
|
|
2
|
-
|
|
3
|
-
> Note: As of Canvas Kit v6, PageHeader is being soft-deprecated. It will be hard-deprecated
|
|
4
|
-
> (completely removed) in v7. Please see the
|
|
5
|
-
> [migration guide](https://workday.github.io/canvas-kit/?path=/story/welcome-migration-guides-v6-0--page)
|
|
6
|
-
> for more information.
|
|
1
|
+
# Canvas Kit Page Header
|
|
7
2
|
|
|
8
3
|
A Canvas component that displays the header of a specific page within a website or application. It
|
|
9
4
|
is generally used as a sub-header to the main application header
|
|
@@ -21,19 +16,19 @@ yarn add @workday/canvas-kit-react
|
|
|
21
16
|
|
|
22
17
|
```tsx
|
|
23
18
|
import * as React from 'react';
|
|
24
|
-
import {
|
|
19
|
+
import {PageHeader} from '@workday/canvas-kit-react/page-header';
|
|
25
20
|
import {IconButton} from '@workday/canvas-kit-react/button';
|
|
26
21
|
import {exportIcon, fullscreenIcon} from '@workday/canvas-system-icons-web';
|
|
27
22
|
|
|
28
|
-
<
|
|
23
|
+
<PageHeader title="Product">
|
|
29
24
|
<IconButton icon={exportIcon} />
|
|
30
25
|
<IconButton icon={fullscreenIcon} />
|
|
31
|
-
</
|
|
26
|
+
</PageHeader>
|
|
32
27
|
|
|
33
|
-
<
|
|
28
|
+
<PageHeader title="With Cap Width" capWidth={true}>
|
|
34
29
|
<IconButton icon={exportIcon} />
|
|
35
30
|
<IconButton icon={fullscreenIcon} />
|
|
36
|
-
</
|
|
31
|
+
</PageHeader>
|
|
37
32
|
```
|
|
38
33
|
|
|
39
34
|
## Static Properties
|
package/page-header/index.ts
CHANGED
|
@@ -3,15 +3,7 @@ import styled from '@emotion/styled';
|
|
|
3
3
|
import {colors, gradients, space, type} from '@workday/canvas-kit-react/tokens';
|
|
4
4
|
import {IconButton, IconButtonProps} from '@workday/canvas-kit-react/button';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
* ### Deprecated Page Header Props
|
|
8
|
-
*
|
|
9
|
-
* As of Canvas Kit v6, PageHeader is being soft-deprecated.
|
|
10
|
-
* It will be hard-deprecated (completely removed) in v7. Please see the
|
|
11
|
-
* [migration guide](https://workday.github.io/canvas-kit/?path=/story/welcome-migration-guides-v6-0--page)
|
|
12
|
-
* for more information.
|
|
13
|
-
*/
|
|
14
|
-
export interface DeprecatedPageHeaderProps {
|
|
6
|
+
export interface PageHeaderProps {
|
|
15
7
|
/**
|
|
16
8
|
* The text of the PageHeader title.
|
|
17
9
|
*/
|
|
@@ -36,7 +28,7 @@ const Header = styled('header')({
|
|
|
36
28
|
MozOsxFontSmoothing: 'grayscale',
|
|
37
29
|
});
|
|
38
30
|
|
|
39
|
-
const Container = styled('div')<Pick<
|
|
31
|
+
const Container = styled('div')<Pick<PageHeaderProps, 'breakpoint' | 'capWidth'>>(
|
|
40
32
|
{
|
|
41
33
|
display: 'flex',
|
|
42
34
|
alignItems: 'center',
|
|
@@ -76,24 +68,7 @@ const IconList = styled('div')({
|
|
|
76
68
|
},
|
|
77
69
|
});
|
|
78
70
|
|
|
79
|
-
|
|
80
|
-
* ### Deprecated Page Header
|
|
81
|
-
*
|
|
82
|
-
* As of Canvas Kit v6, this component is being soft-deprecated.
|
|
83
|
-
* It will be hard-deprecated (completely removed) in v7. Please see the
|
|
84
|
-
* [migration guide](https://workday.github.io/canvas-kit/?path=/story/welcome-migration-guides-v6-0--page)
|
|
85
|
-
* for more information.
|
|
86
|
-
*/
|
|
87
|
-
export default class DeprecatedPageHeader extends React.Component<DeprecatedPageHeaderProps> {
|
|
88
|
-
componentDidMount() {
|
|
89
|
-
console.warn(
|
|
90
|
-
`This component is being deprecated and will be removed in Canvas Kit V7.\n
|
|
91
|
-
For more information, please see the V6 migration guide:\n
|
|
92
|
-
https://workday.github.io/canvas-kit/?path=/story/welcome-migration-guides-v6-0--page
|
|
93
|
-
`
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
|
|
71
|
+
export default class PageHeader extends React.Component<PageHeaderProps> {
|
|
97
72
|
private renderChildren(children: React.ReactNode): React.ReactNode {
|
|
98
73
|
return React.Children.map(children, child => {
|
|
99
74
|
if (!React.isValidElement(child)) {
|
|
@@ -7,6 +7,9 @@ import {PaginationModel} from '../types';
|
|
|
7
7
|
|
|
8
8
|
export interface GoToLabelProps extends React.LabelHTMLAttributes<HTMLLabelElement> {
|
|
9
9
|
model: PaginationModel;
|
|
10
|
+
/**
|
|
11
|
+
* Accepts child elements or a render prop.
|
|
12
|
+
*/
|
|
10
13
|
children?: (model: PaginationModel) => React.ReactNode | React.ReactNode;
|
|
11
14
|
}
|
|
12
15
|
|
|
@@ -1,17 +1,56 @@
|
|
|
1
1
|
export interface PaginationState {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
/**
|
|
3
|
+
* The page number for the current page
|
|
4
|
+
*/
|
|
5
|
+
currentPage: number;
|
|
6
|
+
/**
|
|
7
|
+
* The page number for the first page
|
|
8
|
+
*/
|
|
9
|
+
firstPage: number;
|
|
10
|
+
/**
|
|
11
|
+
* The page number for the last page (it can also be used as a total page
|
|
12
|
+
* count)
|
|
13
|
+
*/
|
|
14
|
+
lastPage: number;
|
|
15
|
+
/**
|
|
16
|
+
* An array of page numbers included in the pagination range
|
|
17
|
+
*/
|
|
18
|
+
range: number[];
|
|
19
|
+
/**
|
|
20
|
+
* The size of the pagination range
|
|
21
|
+
*/
|
|
22
|
+
rangeSize: number;
|
|
7
23
|
}
|
|
8
24
|
|
|
9
25
|
export interface PaginationEvents {
|
|
26
|
+
/**
|
|
27
|
+
* Sets the current page to a given page number (no safeguards)
|
|
28
|
+
*/
|
|
10
29
|
setCurrentPage: (page: number) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Sets the current page to the first page
|
|
32
|
+
*/
|
|
11
33
|
first: () => void;
|
|
34
|
+
/**
|
|
35
|
+
* Sets the current page to the last page
|
|
36
|
+
*/
|
|
12
37
|
last: () => void;
|
|
38
|
+
/**
|
|
39
|
+
* Increments the current page by 1
|
|
40
|
+
*/
|
|
13
41
|
next: () => void;
|
|
42
|
+
/**
|
|
43
|
+
* Decrements the current page by 1
|
|
44
|
+
*/
|
|
14
45
|
previous: () => void;
|
|
46
|
+
/**
|
|
47
|
+
* Sets the current page to a given page number (with safeguards). `goTo`
|
|
48
|
+
* is very similar to `setCurrentPage`, but it has some built-in safeguards.
|
|
49
|
+
* If the page number provided is below the first page (e.g: `0`),
|
|
50
|
+
* `currentPage` will be set to the `firstPage`. Similarly, if the number
|
|
51
|
+
* provided is larger than the `lastPage`, it will set `currentPage` to the
|
|
52
|
+
* `lastPage`.
|
|
53
|
+
*/
|
|
15
54
|
goTo: (page: number) => void;
|
|
16
55
|
}
|
|
17
56
|
|
|
@@ -5,10 +5,29 @@ import {getRangeMax, getRangeMin} from './common/utils/helpers';
|
|
|
5
5
|
import {PaginationModel} from './types';
|
|
6
6
|
|
|
7
7
|
export type UsePaginationModelConfig = {
|
|
8
|
+
/**
|
|
9
|
+
* The page number for the last page (it can also be used as a total page
|
|
10
|
+
* count)
|
|
11
|
+
*/
|
|
8
12
|
lastPage: number;
|
|
13
|
+
/**
|
|
14
|
+
* The page number for the first page
|
|
15
|
+
* @default 1
|
|
16
|
+
*/
|
|
9
17
|
firstPage?: number;
|
|
18
|
+
/**
|
|
19
|
+
* The initial current page
|
|
20
|
+
* @default 1
|
|
21
|
+
*/
|
|
10
22
|
initialCurrentPage?: number;
|
|
23
|
+
/**
|
|
24
|
+
* The function called when the page changes
|
|
25
|
+
*/
|
|
11
26
|
onPageChange?: (pageNumber: number) => void;
|
|
27
|
+
/**
|
|
28
|
+
* The size of the pagination range
|
|
29
|
+
* @default 5
|
|
30
|
+
*/
|
|
12
31
|
rangeSize?: number;
|
|
13
32
|
};
|
|
14
33
|
|
package/tabs/lib/Tab.tsx
CHANGED
|
@@ -63,72 +63,66 @@ export interface TabProps {
|
|
|
63
63
|
tabIndex?: number;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
const StyledButton = styled('button')<{isSelected: boolean} & StyledType>(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
},
|
|
66
|
+
const StyledButton = styled('button')<{isSelected: boolean} & StyledType>({
|
|
67
|
+
...type.levels.subtext.large,
|
|
68
|
+
fontWeight: type.properties.fontWeights.medium,
|
|
69
|
+
border: 'none',
|
|
70
|
+
backgroundColor: 'transparent',
|
|
71
|
+
flex: '0 0 auto',
|
|
72
|
+
maxWidth: '280px',
|
|
73
|
+
padding: space.s,
|
|
74
|
+
boxSizing: 'border-box',
|
|
75
|
+
cursor: 'pointer',
|
|
76
|
+
color: colors.licorice300,
|
|
77
|
+
position: 'relative',
|
|
78
|
+
marginLeft: `${space.xxxs}`,
|
|
79
|
+
borderRadius: `${borderRadius.m} ${borderRadius.m} 0px 0px`,
|
|
80
|
+
transition: 'background 150ms ease, color 150ms ease',
|
|
81
|
+
|
|
82
|
+
'&:first-of-type': {
|
|
83
|
+
marginLeft: 0,
|
|
84
|
+
},
|
|
86
85
|
|
|
87
|
-
|
|
86
|
+
...hideMouseFocus,
|
|
88
87
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
88
|
+
'&:hover, &:focus': {
|
|
89
|
+
backgroundColor: colors.soap200,
|
|
90
|
+
color: colors.blackPepper400,
|
|
91
|
+
},
|
|
93
92
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
'&:focus': {
|
|
94
|
+
outline: `none`,
|
|
95
|
+
...focusRing({inset: 'outer', width: 0, separation: 2}),
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
'&:disabled': {
|
|
99
|
+
color: colors.licorice100,
|
|
100
|
+
'&:hover': {
|
|
101
|
+
cursor: 'auto',
|
|
102
|
+
backgroundColor: `transparent`,
|
|
97
103
|
},
|
|
104
|
+
},
|
|
98
105
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
106
|
+
'&[aria-selected=true]': {
|
|
107
|
+
color: colors.blueberry400,
|
|
108
|
+
cursor: 'default',
|
|
109
|
+
'&:after': {
|
|
110
|
+
position: 'absolute',
|
|
111
|
+
height: space.xxxs,
|
|
112
|
+
borderRadius: `${borderRadius.m} ${borderRadius.m} 0px 0px`,
|
|
113
|
+
backgroundColor: colors.blueberry400,
|
|
114
|
+
bottom: 0,
|
|
115
|
+
content: `''`,
|
|
116
|
+
left: 0,
|
|
117
|
+
marginTop: '-2px',
|
|
118
|
+
width: '100%',
|
|
119
|
+
},
|
|
120
|
+
'&:hover, &:focus': {
|
|
121
|
+
backgroundColor: `transparent`,
|
|
122
|
+
color: colors.blueberry400,
|
|
105
123
|
},
|
|
106
124
|
},
|
|
107
|
-
|
|
108
|
-
if (isSelected) {
|
|
109
|
-
return {
|
|
110
|
-
color: colors.blueberry400,
|
|
111
|
-
cursor: 'default',
|
|
112
|
-
'&:after': {
|
|
113
|
-
position: 'absolute',
|
|
114
|
-
height: space.xxxs,
|
|
115
|
-
borderRadius: `${borderRadius.m} ${borderRadius.m} 0px 0px`,
|
|
116
|
-
backgroundColor: colors.blueberry400,
|
|
117
|
-
bottom: 0,
|
|
118
|
-
content: `''`,
|
|
119
|
-
left: 0,
|
|
120
|
-
marginTop: '-2px',
|
|
121
|
-
width: '100%',
|
|
122
|
-
},
|
|
123
|
-
'&:hover, &:focus': {
|
|
124
|
-
backgroundColor: `transparent`,
|
|
125
|
-
color: colors.blueberry400,
|
|
126
|
-
},
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
return {};
|
|
130
|
-
}
|
|
131
|
-
);
|
|
125
|
+
});
|
|
132
126
|
|
|
133
127
|
const useTab = (
|
|
134
128
|
model: TabsModel,
|
|
@@ -10,7 +10,7 @@ import {useTooltip} from './useTooltip';
|
|
|
10
10
|
* Look for an element within the tree for an overflow element (auto, scroll, clip, or hidden).
|
|
11
11
|
* This could be the passed element, or a descendant. If no element is found, `null` is returned.
|
|
12
12
|
*/
|
|
13
|
-
const findOverflowElement = (element: Element): Element | null => {
|
|
13
|
+
export const findOverflowElement = (element: Element): Element | null => {
|
|
14
14
|
const style = getComputedStyle(element);
|
|
15
15
|
if (
|
|
16
16
|
style.overflow === 'auto' ||
|
|
@@ -36,11 +36,12 @@ const findOverflowElement = (element: Element): Element | null => {
|
|
|
36
36
|
* Look for an element within the tree for a `text-overflow` CSS property of `ellipsis`.
|
|
37
37
|
* This could be the passed element, or a descendant. If no element is found, `null` is returned.
|
|
38
38
|
*/
|
|
39
|
-
const findEllipsisElement = (element: Element): Element | null => {
|
|
39
|
+
export const findEllipsisElement = (element: Element): Element | null => {
|
|
40
40
|
const style = getComputedStyle(element);
|
|
41
41
|
if (style.textOverflow === 'ellipsis' || Number(style.webkitLineClamp) > 0) {
|
|
42
42
|
return element;
|
|
43
|
-
} else {
|
|
43
|
+
} else if (element.children) {
|
|
44
|
+
// `children` is not defined for SVGElement in IE11
|
|
44
45
|
for (let i = 0; i < element.children.length; i++) {
|
|
45
46
|
const overflowElement = findEllipsisElement(element.children[i]);
|
|
46
47
|
if (overflowElement) {
|
|
@@ -49,6 +50,7 @@ const findEllipsisElement = (element: Element): Element | null => {
|
|
|
49
50
|
}
|
|
50
51
|
return null;
|
|
51
52
|
}
|
|
53
|
+
return null;
|
|
52
54
|
};
|
|
53
55
|
|
|
54
56
|
const isOverflowed = (element: Element) => {
|
package/tooltip/lib/Tooltip.tsx
CHANGED
|
@@ -44,6 +44,14 @@ export interface TooltipProps extends Omit<React.HTMLAttributes<HTMLDivElement>,
|
|
|
44
44
|
* @default 'label'
|
|
45
45
|
*/
|
|
46
46
|
type?: 'label' | 'describe' | 'muted';
|
|
47
|
+
/**
|
|
48
|
+
* Amount of time (in ms) to delay before showing the tooltip
|
|
49
|
+
*/
|
|
50
|
+
showDelay?: number;
|
|
51
|
+
/**
|
|
52
|
+
* Amount of time (in ms) to delay before hiding the tooltip
|
|
53
|
+
*/
|
|
54
|
+
hideDelay?: number;
|
|
47
55
|
}
|
|
48
56
|
|
|
49
57
|
function mergeCallbacks<T extends {[key: string]: any}>(
|
|
@@ -66,10 +74,17 @@ export const Tooltip = ({
|
|
|
66
74
|
placement = 'top',
|
|
67
75
|
title,
|
|
68
76
|
children,
|
|
77
|
+
showDelay = 300,
|
|
78
|
+
hideDelay = 100,
|
|
69
79
|
...elemProps
|
|
70
80
|
}: TooltipProps) => {
|
|
71
81
|
const titleText = innerText(title);
|
|
72
|
-
const {targetProps, popperProps, tooltipProps} = useTooltip({
|
|
82
|
+
const {targetProps, popperProps, tooltipProps} = useTooltip({
|
|
83
|
+
type,
|
|
84
|
+
titleText,
|
|
85
|
+
showDelay,
|
|
86
|
+
hideDelay,
|
|
87
|
+
});
|
|
73
88
|
|
|
74
89
|
return (
|
|
75
90
|
<React.Fragment>
|
|
@@ -54,6 +54,8 @@ const isInteractiveElement = (element: Element) => {
|
|
|
54
54
|
export function useTooltip<T extends Element = Element>({
|
|
55
55
|
type = 'label',
|
|
56
56
|
titleText = '',
|
|
57
|
+
showDelay = 300,
|
|
58
|
+
hideDelay = 100,
|
|
57
59
|
}: {
|
|
58
60
|
/**
|
|
59
61
|
* Determines the tooltip type for accessibility.
|
|
@@ -76,17 +78,30 @@ export function useTooltip<T extends Element = Element>({
|
|
|
76
78
|
* The content of the `aria-label` if `type` is `label.
|
|
77
79
|
*/
|
|
78
80
|
titleText?: string;
|
|
81
|
+
/**
|
|
82
|
+
* Amount of time (in ms) to delay before showing the tooltip
|
|
83
|
+
*/
|
|
84
|
+
showDelay?: number;
|
|
85
|
+
/**
|
|
86
|
+
* Amount of time (in ms) to delay before hiding the tooltip
|
|
87
|
+
*/
|
|
88
|
+
hideDelay?: number;
|
|
79
89
|
} = {}) {
|
|
80
90
|
const mouseDownRef = React.useRef(false); // use to prevent newly focused from making tooltip flash
|
|
81
91
|
const popupModel = usePopupModel();
|
|
82
92
|
const [anchorElement, setAnchorElement] = React.useState<T | null>(null);
|
|
83
93
|
const [id] = React.useState(() => uuid());
|
|
94
|
+
const intentTimerHide = useIntentTimer(popupModel.events.hide, hideDelay);
|
|
95
|
+
const intentTimerShow = useIntentTimer(popupModel.events.show, showDelay);
|
|
84
96
|
|
|
85
|
-
const
|
|
97
|
+
const onHide = () => {
|
|
98
|
+
intentTimerHide.start();
|
|
99
|
+
intentTimerShow.clear();
|
|
100
|
+
};
|
|
86
101
|
|
|
87
102
|
const onOpen = () => {
|
|
88
|
-
|
|
89
|
-
|
|
103
|
+
intentTimerShow.start();
|
|
104
|
+
intentTimerHide.clear();
|
|
90
105
|
};
|
|
91
106
|
|
|
92
107
|
const onOpenFromTarget = (event: React.SyntheticEvent) => {
|
|
@@ -122,10 +137,10 @@ export function useTooltip<T extends Element = Element>({
|
|
|
122
137
|
// This will replace the accessible name of the target element
|
|
123
138
|
'aria-label': type === 'label' ? titleText : undefined,
|
|
124
139
|
onMouseEnter: onOpenFromTarget,
|
|
125
|
-
onMouseLeave:
|
|
140
|
+
onMouseLeave: onHide,
|
|
126
141
|
onMouseDown,
|
|
127
142
|
onFocus,
|
|
128
|
-
onBlur:
|
|
143
|
+
onBlur: onHide,
|
|
129
144
|
},
|
|
130
145
|
/** Mix these properties into the `Popper` component */
|
|
131
146
|
popperProps: {
|
|
@@ -138,7 +153,7 @@ export function useTooltip<T extends Element = Element>({
|
|
|
138
153
|
id: type === 'describe' && visible ? id : undefined,
|
|
139
154
|
role: 'tooltip',
|
|
140
155
|
onMouseEnter: onOpen,
|
|
141
|
-
onMouseLeave:
|
|
156
|
+
onMouseLeave: onHide,
|
|
142
157
|
},
|
|
143
158
|
};
|
|
144
159
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CSSObject } from '@emotion/core';
|
|
2
2
|
/**
|
|
3
3
|
* A utility to hide content normal users while still making accessible to screenreaders
|
|
4
4
|
* See https://a11y-101.com/development/skip-link
|
|
5
5
|
*/
|
|
6
|
-
export declare const accessibleHide:
|
|
6
|
+
export declare const accessibleHide: CSSObject;
|
|
7
7
|
//# sourceMappingURL=accessibleHide.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
export default
|
|
3
|
-
export {
|
|
1
|
+
import CookieBanner from './lib/CookieBanner';
|
|
2
|
+
export default CookieBanner;
|
|
3
|
+
export { CookieBanner };
|
|
4
4
|
export * from './lib/CookieBanner';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
* ### Deprecated Cookie Banner Props
|
|
4
|
-
*
|
|
5
|
-
* As of Canvas Kit v6, CookieBanner is being soft-deprecated.
|
|
6
|
-
* It will be hard-deprecated (completely removed) in v7. Please see the
|
|
7
|
-
* [migration guide](https://workday.github.io/canvas-kit/?path=/story/welcome-migration-guides-v6-0--page)
|
|
8
|
-
* for more information.
|
|
9
|
-
*/
|
|
10
|
-
export interface DeprecatedCookieBannerProps {
|
|
2
|
+
export interface CookieBannerProps {
|
|
11
3
|
/**
|
|
12
4
|
* If true, set the CookieBanner to the closed state.
|
|
13
5
|
* @default false
|
|
@@ -32,16 +24,7 @@ export interface DeprecatedCookieBannerProps {
|
|
|
32
24
|
*/
|
|
33
25
|
settingsLabel?: string;
|
|
34
26
|
}
|
|
35
|
-
|
|
36
|
-
* ### Deprecated Cookie Banner
|
|
37
|
-
*
|
|
38
|
-
* As of Canvas Kit v6, this component is being soft-deprecated.
|
|
39
|
-
* It will be hard-deprecated (completely removed) in v7. Please see the
|
|
40
|
-
* [migration guide](https://workday.github.io/canvas-kit/?path=/story/welcome-migration-guides-v6-0--page)
|
|
41
|
-
* for more information.
|
|
42
|
-
*/
|
|
43
|
-
export default class DeprecatedCookieBanner extends React.Component<DeprecatedCookieBannerProps> {
|
|
44
|
-
componentDidMount(): void;
|
|
27
|
+
export default class CookieBanner extends React.Component<CookieBannerProps> {
|
|
45
28
|
static DefaultNotice: string;
|
|
46
29
|
render(): React.ReactNode;
|
|
47
30
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
export default
|
|
3
|
-
export {
|
|
1
|
+
import PageHeader from './lib/PageHeader';
|
|
2
|
+
export default PageHeader;
|
|
3
|
+
export { PageHeader };
|
|
4
4
|
export * from './lib/PageHeader';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
* ### Deprecated Page Header Props
|
|
4
|
-
*
|
|
5
|
-
* As of Canvas Kit v6, PageHeader is being soft-deprecated.
|
|
6
|
-
* It will be hard-deprecated (completely removed) in v7. Please see the
|
|
7
|
-
* [migration guide](https://workday.github.io/canvas-kit/?path=/story/welcome-migration-guides-v6-0--page)
|
|
8
|
-
* for more information.
|
|
9
|
-
*/
|
|
10
|
-
export interface DeprecatedPageHeaderProps {
|
|
2
|
+
export interface PageHeaderProps {
|
|
11
3
|
/**
|
|
12
4
|
* The text of the PageHeader title.
|
|
13
5
|
*/
|
|
@@ -23,16 +15,7 @@ export interface DeprecatedPageHeaderProps {
|
|
|
23
15
|
*/
|
|
24
16
|
breakpoint?: number;
|
|
25
17
|
}
|
|
26
|
-
|
|
27
|
-
* ### Deprecated Page Header
|
|
28
|
-
*
|
|
29
|
-
* As of Canvas Kit v6, this component is being soft-deprecated.
|
|
30
|
-
* It will be hard-deprecated (completely removed) in v7. Please see the
|
|
31
|
-
* [migration guide](https://workday.github.io/canvas-kit/?path=/story/welcome-migration-guides-v6-0--page)
|
|
32
|
-
* for more information.
|
|
33
|
-
*/
|
|
34
|
-
export default class DeprecatedPageHeader extends React.Component<DeprecatedPageHeaderProps> {
|
|
35
|
-
componentDidMount(): void;
|
|
18
|
+
export default class PageHeader extends React.Component<PageHeaderProps> {
|
|
36
19
|
private renderChildren;
|
|
37
20
|
render(): JSX.Element;
|
|
38
21
|
}
|