@workday/canvas-kit-react 5.3.0-next.18 → 5.3.0-next.32
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/checkbox/lib/Checkbox.tsx +1 -1
- package/common/README.md +78 -0
- package/common/lib/utils/index.ts +1 -0
- package/common/lib/utils/useIsFullscreen.ts +20 -0
- package/common/lib/utils/useUniqueId.ts +44 -3
- package/dist/commonjs/checkbox/lib/Checkbox.d.ts +1 -1
- package/dist/commonjs/common/lib/utils/index.d.ts +1 -0
- package/dist/commonjs/common/lib/utils/index.d.ts.map +1 -1
- package/dist/commonjs/common/lib/utils/index.js +1 -0
- package/dist/commonjs/common/lib/utils/useIsFullscreen.d.ts +2 -0
- package/dist/commonjs/common/lib/utils/useIsFullscreen.d.ts.map +1 -0
- package/dist/commonjs/common/lib/utils/useIsFullscreen.js +20 -0
- package/dist/commonjs/common/lib/utils/useUniqueId.d.ts +28 -0
- package/dist/commonjs/common/lib/utils/useUniqueId.d.ts.map +1 -1
- package/dist/commonjs/common/lib/utils/useUniqueId.js +40 -5
- package/dist/commonjs/form-field/lib/FormField.d.ts.map +1 -1
- package/dist/commonjs/form-field/lib/FormField.js +1 -2
- package/dist/commonjs/loading-animation/lib/LoadingDots.js +3 -6
- package/dist/commonjs/popup/lib/PopupCard.d.ts.map +1 -1
- package/dist/commonjs/popup/lib/PopupCard.js +3 -9
- package/dist/commonjs/popup/lib/hooks/focus-trap-js.d.ts.map +1 -1
- package/dist/commonjs/popup/lib/hooks/focus-trap-js.js +1 -0
- package/dist/commonjs/popup/lib/hooks/index.d.ts +3 -0
- package/dist/commonjs/popup/lib/hooks/index.d.ts.map +1 -1
- package/dist/commonjs/popup/lib/hooks/index.js +3 -0
- package/dist/commonjs/popup/lib/hooks/useCloseOnFullscreenExit.d.ts +7 -0
- package/dist/commonjs/popup/lib/hooks/useCloseOnFullscreenExit.d.ts.map +1 -0
- package/dist/commonjs/popup/lib/hooks/useCloseOnFullscreenExit.js +34 -0
- package/dist/commonjs/popup/lib/hooks/usePopupStack.d.ts.map +1 -1
- package/dist/commonjs/popup/lib/hooks/usePopupStack.js +1 -1
- package/dist/commonjs/popup/lib/hooks/useReturnFocus.d.ts +1 -1
- package/dist/commonjs/popup/lib/hooks/useReturnFocus.js +1 -1
- package/dist/commonjs/popup/lib/hooks/useTransferOnFullscreenEnter.d.ts +10 -0
- package/dist/commonjs/popup/lib/hooks/useTransferOnFullscreenEnter.d.ts.map +1 -0
- package/dist/commonjs/popup/lib/hooks/useTransferOnFullscreenEnter.js +41 -0
- package/dist/commonjs/popup/lib/hooks/useTransferOnFullscreenExit.d.ts +9 -0
- package/dist/commonjs/popup/lib/hooks/useTransferOnFullscreenExit.d.ts.map +1 -0
- package/dist/commonjs/popup/lib/hooks/useTransferOnFullscreenExit.js +40 -0
- package/dist/commonjs/radio/lib/Radio.d.ts +1 -1
- package/dist/commonjs/switch/lib/Switch.d.ts +1 -1
- package/dist/commonjs/tabs/lib/menu/MenuList.d.ts.map +1 -1
- package/dist/commonjs/tabs/lib/menu/MenuList.js +1 -1
- package/dist/commonjs/tabs/lib/overflow/useOverflowModel.d.ts.map +1 -1
- package/dist/commonjs/tabs/lib/overflow/useOverflowModel.js +9 -0
- package/dist/commonjs/tabs/lib/overflow/useOverflowTarget.js +1 -1
- 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 +16 -13
- package/dist/es6/checkbox/lib/Checkbox.d.ts +1 -1
- package/dist/es6/common/lib/utils/index.d.ts +1 -0
- package/dist/es6/common/lib/utils/index.d.ts.map +1 -1
- package/dist/es6/common/lib/utils/index.js +1 -0
- package/dist/es6/common/lib/utils/useIsFullscreen.d.ts +2 -0
- package/dist/es6/common/lib/utils/useIsFullscreen.d.ts.map +1 -0
- package/dist/es6/common/lib/utils/useIsFullscreen.js +15 -0
- package/dist/es6/common/lib/utils/useUniqueId.d.ts +28 -0
- package/dist/es6/common/lib/utils/useUniqueId.d.ts.map +1 -1
- package/dist/es6/common/lib/utils/useUniqueId.js +40 -2
- package/dist/es6/form-field/lib/FormField.d.ts.map +1 -1
- package/dist/es6/form-field/lib/FormField.js +2 -3
- package/dist/es6/loading-animation/lib/LoadingDots.js +1 -1
- package/dist/es6/popup/lib/PopupCard.d.ts.map +1 -1
- package/dist/es6/popup/lib/PopupCard.js +3 -9
- package/dist/es6/popup/lib/hooks/focus-trap-js.d.ts.map +1 -1
- package/dist/es6/popup/lib/hooks/focus-trap-js.js +1 -0
- package/dist/es6/popup/lib/hooks/index.d.ts +3 -0
- package/dist/es6/popup/lib/hooks/index.d.ts.map +1 -1
- package/dist/es6/popup/lib/hooks/index.js +3 -0
- package/dist/es6/popup/lib/hooks/useCloseOnFullscreenExit.d.ts +7 -0
- package/dist/es6/popup/lib/hooks/useCloseOnFullscreenExit.d.ts.map +1 -0
- package/dist/es6/popup/lib/hooks/useCloseOnFullscreenExit.js +29 -0
- package/dist/es6/popup/lib/hooks/usePopupStack.d.ts.map +1 -1
- package/dist/es6/popup/lib/hooks/usePopupStack.js +1 -1
- package/dist/es6/popup/lib/hooks/useReturnFocus.d.ts +1 -1
- package/dist/es6/popup/lib/hooks/useReturnFocus.js +1 -1
- package/dist/es6/popup/lib/hooks/useTransferOnFullscreenEnter.d.ts +10 -0
- package/dist/es6/popup/lib/hooks/useTransferOnFullscreenEnter.d.ts.map +1 -0
- package/dist/es6/popup/lib/hooks/useTransferOnFullscreenEnter.js +36 -0
- package/dist/es6/popup/lib/hooks/useTransferOnFullscreenExit.d.ts +9 -0
- package/dist/es6/popup/lib/hooks/useTransferOnFullscreenExit.d.ts.map +1 -0
- package/dist/es6/popup/lib/hooks/useTransferOnFullscreenExit.js +35 -0
- package/dist/es6/radio/lib/Radio.d.ts +1 -1
- package/dist/es6/switch/lib/Switch.d.ts +1 -1
- package/dist/es6/tabs/lib/menu/MenuList.d.ts.map +1 -1
- package/dist/es6/tabs/lib/menu/MenuList.js +1 -1
- package/dist/es6/tabs/lib/overflow/useOverflowModel.d.ts.map +1 -1
- package/dist/es6/tabs/lib/overflow/useOverflowModel.js +9 -0
- package/dist/es6/tabs/lib/overflow/useOverflowTarget.js +1 -1
- 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 +17 -11
- package/form-field/lib/FormField.tsx +8 -3
- package/loading-animation/lib/LoadingDots.tsx +1 -1
- package/package.json +9 -8
- package/popup/lib/PopupCard.tsx +19 -30
- package/popup/lib/hooks/focus-trap-js.ts +1 -0
- package/popup/lib/hooks/index.ts +3 -0
- package/popup/lib/hooks/useCloseOnFullscreenExit.ts +37 -0
- package/popup/lib/hooks/usePopupStack.ts +2 -1
- package/popup/lib/hooks/useReturnFocus.tsx +1 -1
- package/popup/lib/hooks/useTransferOnFullscreenEnter.ts +44 -0
- package/popup/lib/hooks/useTransferOnFullscreenExit.ts +43 -0
- package/radio/lib/Radio.tsx +1 -1
- package/switch/lib/Switch.tsx +1 -1
- package/tabs/lib/menu/MenuList.tsx +2 -3
- package/tabs/lib/overflow/useOverflowModel.tsx +22 -0
- package/tabs/lib/overflow/useOverflowTarget.tsx +1 -1
- package/tooltip/lib/Tooltip.tsx +16 -1
- package/tooltip/lib/useTooltip.tsx +25 -8
- package/ts3.5/dist/commonjs/checkbox/lib/Checkbox.d.ts +1 -1
- package/ts3.5/dist/commonjs/common/lib/utils/index.d.ts +1 -0
- package/ts3.5/dist/commonjs/common/lib/utils/useIsFullscreen.d.ts +2 -0
- package/ts3.5/dist/commonjs/common/lib/utils/useUniqueId.d.ts +28 -0
- package/ts3.5/dist/commonjs/popup/lib/hooks/index.d.ts +3 -0
- package/ts3.5/dist/commonjs/popup/lib/hooks/useCloseOnFullscreenExit.d.ts +7 -0
- package/ts3.5/dist/commonjs/popup/lib/hooks/useReturnFocus.d.ts +1 -1
- package/ts3.5/dist/commonjs/popup/lib/hooks/useTransferOnFullscreenEnter.d.ts +10 -0
- package/ts3.5/dist/commonjs/popup/lib/hooks/useTransferOnFullscreenExit.d.ts +9 -0
- package/ts3.5/dist/commonjs/radio/lib/Radio.d.ts +1 -1
- package/ts3.5/dist/commonjs/switch/lib/Switch.d.ts +1 -1
- 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/checkbox/lib/Checkbox.d.ts +1 -1
- package/ts3.5/dist/es6/common/lib/utils/index.d.ts +1 -0
- package/ts3.5/dist/es6/common/lib/utils/useIsFullscreen.d.ts +2 -0
- package/ts3.5/dist/es6/common/lib/utils/useUniqueId.d.ts +28 -0
- package/ts3.5/dist/es6/popup/lib/hooks/index.d.ts +3 -0
- package/ts3.5/dist/es6/popup/lib/hooks/useCloseOnFullscreenExit.d.ts +7 -0
- package/ts3.5/dist/es6/popup/lib/hooks/useReturnFocus.d.ts +1 -1
- package/ts3.5/dist/es6/popup/lib/hooks/useTransferOnFullscreenEnter.d.ts +10 -0
- package/ts3.5/dist/es6/popup/lib/hooks/useTransferOnFullscreenExit.d.ts +9 -0
- package/ts3.5/dist/es6/radio/lib/Radio.d.ts +1 -1
- package/ts3.5/dist/es6/switch/lib/Switch.d.ts +1 -1
- package/ts3.5/dist/es6/tooltip/lib/Tooltip.d.ts +9 -1
- package/ts3.5/dist/es6/tooltip/lib/useTooltip.d.ts +9 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import screenfull from 'screenfull';
|
|
3
|
+
|
|
4
|
+
import {PopupModel} from './usePopupModel';
|
|
5
|
+
import {PopupStack} from '@workday/canvas-kit-popup-stack';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Makes the popup transfer to fullscreen when fullscreen is exited. Without this hook, the popup
|
|
9
|
+
* would not operate correctly with other popups on the screen.
|
|
10
|
+
*
|
|
11
|
+
* Don't use this in conjunction with a hook that will close the popup when exiting fullscreen.
|
|
12
|
+
* Doing so would open the popup when the intention was to close it.
|
|
13
|
+
*/
|
|
14
|
+
export const useTransferOnFullscreenExit = (model: PopupModel, elemProps = {}) => {
|
|
15
|
+
const handler = React.useCallback(
|
|
16
|
+
event => {
|
|
17
|
+
if (!screenfull.isFullscreen && model.state.stackRef.current) {
|
|
18
|
+
PopupStack.transferToCurrentContext({
|
|
19
|
+
element: model.state.stackRef.current,
|
|
20
|
+
owner: model.state.targetRef.current!,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
[model.state.stackRef, model.state.targetRef]
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
const visible = model.state.visibility !== 'hidden';
|
|
28
|
+
|
|
29
|
+
React.useEffect(() => {
|
|
30
|
+
if (!visible) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (screenfull.isEnabled) {
|
|
34
|
+
screenfull.on('change', handler);
|
|
35
|
+
return () => {
|
|
36
|
+
screenfull.off('change', handler);
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
return;
|
|
40
|
+
}, [handler, visible]);
|
|
41
|
+
|
|
42
|
+
return elemProps;
|
|
43
|
+
};
|
package/radio/lib/Radio.tsx
CHANGED
|
@@ -28,7 +28,7 @@ export interface RadioProps extends Themeable {
|
|
|
28
28
|
disabled?: boolean;
|
|
29
29
|
/**
|
|
30
30
|
* The HTML `id` of the underlying radio input element. This is required if `label` is defined as a non-empty string.
|
|
31
|
-
* @default A uniquely generated id
|
|
31
|
+
* @default A uniquely generated id
|
|
32
32
|
*/
|
|
33
33
|
id?: string;
|
|
34
34
|
/**
|
package/switch/lib/Switch.tsx
CHANGED
|
@@ -36,10 +36,9 @@ export const MenuList = createComponent('div')({
|
|
|
36
36
|
<Stack
|
|
37
37
|
as={Element}
|
|
38
38
|
background={commonColors.background}
|
|
39
|
-
borderRadius="
|
|
39
|
+
borderRadius="zero"
|
|
40
40
|
padding="zero"
|
|
41
|
-
marginY="
|
|
42
|
-
marginX="xxs"
|
|
41
|
+
marginY="xxs"
|
|
43
42
|
spacing="zero"
|
|
44
43
|
overflowY="auto"
|
|
45
44
|
flexDirection={localModel.state.orientation === 'vertical' ? 'column' : 'row'}
|
|
@@ -92,6 +92,8 @@ export function getHiddenIds(
|
|
|
92
92
|
// at least the selected item and overflow target fit. Update our itemWidth with the sum
|
|
93
93
|
itemWidth += itemWidthCache[selectedKey] + overflowTargetWidth;
|
|
94
94
|
}
|
|
95
|
+
} else {
|
|
96
|
+
itemWidth += overflowTargetWidth;
|
|
95
97
|
}
|
|
96
98
|
|
|
97
99
|
for (const key in itemWidthCache) {
|
|
@@ -166,12 +168,32 @@ export const useOverflowModel = <T extends unknown>(
|
|
|
166
168
|
itemWidthCacheRef.current = {...itemWidthCacheRef.current, [id]: width};
|
|
167
169
|
|
|
168
170
|
setItemWidthCache(itemWidthCacheRef.current);
|
|
171
|
+
|
|
172
|
+
const ids = getHiddenIds(
|
|
173
|
+
containerWidthRef.current,
|
|
174
|
+
overflowTargetWidthRef.current,
|
|
175
|
+
itemWidthCacheRef.current,
|
|
176
|
+
state.selectedIds
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
setHiddenIds(ids);
|
|
169
180
|
},
|
|
170
181
|
removeItemWidth({id}) {
|
|
171
182
|
const newCache = {...itemWidthCacheRef.current};
|
|
172
183
|
delete newCache[id];
|
|
173
184
|
itemWidthCacheRef.current = newCache;
|
|
174
185
|
setItemWidthCache(itemWidthCacheRef.current);
|
|
186
|
+
|
|
187
|
+
const ids = getHiddenIds(
|
|
188
|
+
containerWidthRef.current,
|
|
189
|
+
overflowTargetWidthRef.current,
|
|
190
|
+
itemWidthCacheRef.current,
|
|
191
|
+
state.selectedIds !== 'all'
|
|
192
|
+
? state.selectedIds.filter(sId => id !== sId)
|
|
193
|
+
: state.selectedIds
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
setHiddenIds(ids);
|
|
175
197
|
},
|
|
176
198
|
addHiddenKey({id}) {
|
|
177
199
|
setHiddenIds(ids => ids.concat(id));
|
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>
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import uuid from 'uuid/v4';
|
|
3
2
|
import {
|
|
4
3
|
useCloseOnEscape,
|
|
5
4
|
useAlwaysCloseOnOutsideClick,
|
|
6
5
|
usePopupModel,
|
|
6
|
+
useCloseOnFullscreenExit,
|
|
7
7
|
} from '@workday/canvas-kit-react/popup';
|
|
8
|
+
import {useUniqueId} from '@workday/canvas-kit-react/common';
|
|
8
9
|
|
|
9
10
|
const useIntentTimer = (fn: Function, waitMs: number = 0): {start(): void; clear(): void} => {
|
|
10
11
|
const timer = React.useRef() as React.MutableRefObject<number | undefined>;
|
|
@@ -54,6 +55,8 @@ const isInteractiveElement = (element: Element) => {
|
|
|
54
55
|
export function useTooltip<T extends Element = Element>({
|
|
55
56
|
type = 'label',
|
|
56
57
|
titleText = '',
|
|
58
|
+
showDelay = 300,
|
|
59
|
+
hideDelay = 100,
|
|
57
60
|
}: {
|
|
58
61
|
/**
|
|
59
62
|
* Determines the tooltip type for accessibility.
|
|
@@ -76,17 +79,30 @@ export function useTooltip<T extends Element = Element>({
|
|
|
76
79
|
* The content of the `aria-label` if `type` is `label.
|
|
77
80
|
*/
|
|
78
81
|
titleText?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Amount of time (in ms) to delay before showing the tooltip
|
|
84
|
+
*/
|
|
85
|
+
showDelay?: number;
|
|
86
|
+
/**
|
|
87
|
+
* Amount of time (in ms) to delay before hiding the tooltip
|
|
88
|
+
*/
|
|
89
|
+
hideDelay?: number;
|
|
79
90
|
} = {}) {
|
|
80
91
|
const mouseDownRef = React.useRef(false); // use to prevent newly focused from making tooltip flash
|
|
81
92
|
const popupModel = usePopupModel();
|
|
82
93
|
const [anchorElement, setAnchorElement] = React.useState<T | null>(null);
|
|
83
|
-
const
|
|
94
|
+
const id = useUniqueId();
|
|
95
|
+
const intentTimerHide = useIntentTimer(popupModel.events.hide, hideDelay);
|
|
96
|
+
const intentTimerShow = useIntentTimer(popupModel.events.show, showDelay);
|
|
84
97
|
|
|
85
|
-
const
|
|
98
|
+
const onHide = () => {
|
|
99
|
+
intentTimerHide.start();
|
|
100
|
+
intentTimerShow.clear();
|
|
101
|
+
};
|
|
86
102
|
|
|
87
103
|
const onOpen = () => {
|
|
88
|
-
|
|
89
|
-
|
|
104
|
+
intentTimerShow.start();
|
|
105
|
+
intentTimerHide.clear();
|
|
90
106
|
};
|
|
91
107
|
|
|
92
108
|
const onOpenFromTarget = (event: React.SyntheticEvent) => {
|
|
@@ -111,6 +127,7 @@ export function useTooltip<T extends Element = Element>({
|
|
|
111
127
|
|
|
112
128
|
useCloseOnEscape(popupModel);
|
|
113
129
|
useAlwaysCloseOnOutsideClick(popupModel);
|
|
130
|
+
useCloseOnFullscreenExit(popupModel);
|
|
114
131
|
|
|
115
132
|
const visible = popupModel.state.visibility !== 'hidden';
|
|
116
133
|
|
|
@@ -122,10 +139,10 @@ export function useTooltip<T extends Element = Element>({
|
|
|
122
139
|
// This will replace the accessible name of the target element
|
|
123
140
|
'aria-label': type === 'label' ? titleText : undefined,
|
|
124
141
|
onMouseEnter: onOpenFromTarget,
|
|
125
|
-
onMouseLeave:
|
|
142
|
+
onMouseLeave: onHide,
|
|
126
143
|
onMouseDown,
|
|
127
144
|
onFocus,
|
|
128
|
-
onBlur:
|
|
145
|
+
onBlur: onHide,
|
|
129
146
|
},
|
|
130
147
|
/** Mix these properties into the `Popper` component */
|
|
131
148
|
popperProps: {
|
|
@@ -138,7 +155,7 @@ export function useTooltip<T extends Element = Element>({
|
|
|
138
155
|
id: type === 'describe' && visible ? id : undefined,
|
|
139
156
|
role: 'tooltip',
|
|
140
157
|
onMouseEnter: onOpen,
|
|
141
|
-
onMouseLeave:
|
|
158
|
+
onMouseLeave: onHide,
|
|
142
159
|
},
|
|
143
160
|
};
|
|
144
161
|
}
|
|
@@ -13,7 +13,7 @@ export interface CheckboxProps extends Themeable {
|
|
|
13
13
|
disabled?: boolean;
|
|
14
14
|
/**
|
|
15
15
|
* The HTML `id` of the underlying checkbox input element. This is required if `label` is defined as a non-empty string.
|
|
16
|
-
* @default A uniquely generated id
|
|
16
|
+
* @default A uniquely generated id
|
|
17
17
|
*/
|
|
18
18
|
id?: string;
|
|
19
19
|
/**
|
|
@@ -10,6 +10,7 @@ export * from './useMount';
|
|
|
10
10
|
export * from './components';
|
|
11
11
|
export * from './models';
|
|
12
12
|
export * from './elements';
|
|
13
|
+
export * from './useIsFullscreen';
|
|
13
14
|
export * from './useWindowSize';
|
|
14
15
|
export * from './useResizeObserver';
|
|
15
16
|
export * from './StaticStates';
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates a unique and HTML5 compliant identifier every time it is called. Internally it uses a 4
|
|
3
|
+
* character random seed starting with a letter. This seed is unique to each instance of this
|
|
4
|
+
* package meaning different versions of Canvas Kit on the page will have a different seed. Each
|
|
5
|
+
* call will use a Base 36 string (10 numbers + 26 letters) based on an incremented number. The
|
|
6
|
+
* incremented number always starts at 0 and can be reset for testing purposes using
|
|
7
|
+
* [resetUniqueIdCount](#resetuniqueidcount). [setUniqueSeed](#setuniqueseed) can also be used for
|
|
8
|
+
* testing or server side rendering to get the same results during hydration.
|
|
9
|
+
*/
|
|
1
10
|
export declare const generateUniqueId: () => string;
|
|
2
11
|
/**
|
|
3
12
|
* Generate a unique ID if one is not provided. The generated ID will be stable across renders
|
|
@@ -10,4 +19,23 @@ export declare const useUniqueId: (id?: string | undefined) => string;
|
|
|
10
19
|
* TODO: Remove in major release
|
|
11
20
|
*/
|
|
12
21
|
export declare const uniqueId: (id?: string | undefined) => string;
|
|
22
|
+
/**
|
|
23
|
+
* Update the seed used by the id generator. This is useful for snapshot tests to help stabilize ids
|
|
24
|
+
* generated each run. This could also be used for server-side hydration - if you choose the same
|
|
25
|
+
* seed for server and set that on the client before components are rendered, the ids generated will
|
|
26
|
+
* be the same.
|
|
27
|
+
* @example
|
|
28
|
+
* // set in a script tag from the server
|
|
29
|
+
* setSeed(window.__ID_SEED); // set in a script tag from the server
|
|
30
|
+
*
|
|
31
|
+
* // jest setup
|
|
32
|
+
* before(() => {
|
|
33
|
+
* setSeed('a')
|
|
34
|
+
* })
|
|
35
|
+
*/
|
|
36
|
+
export declare const setUniqueSeed: (s: string) => void;
|
|
37
|
+
/**
|
|
38
|
+
* This should only be called for tests in an `beforeEach`
|
|
39
|
+
*/
|
|
40
|
+
export declare const resetUniqueIdCount: () => void;
|
|
13
41
|
//# sourceMappingURL=useUniqueId.d.ts.map
|
|
@@ -2,6 +2,7 @@ export * from './useAlwaysCloseOnOutsideClick';
|
|
|
2
2
|
export * from './useAssistiveHideSiblings';
|
|
3
3
|
export * from './useBringToTopOnClick';
|
|
4
4
|
export * from './useCloseOnEscape';
|
|
5
|
+
export * from './useCloseOnFullscreenExit';
|
|
5
6
|
export * from './useCloseOnOutsideClick';
|
|
6
7
|
export * from './useDisableBodyScroll';
|
|
7
8
|
export * from './useFocusRedirect';
|
|
@@ -15,4 +16,6 @@ export * from './usePopupPopper';
|
|
|
15
16
|
export * from './usePopupStack';
|
|
16
17
|
export * from './usePopupTarget';
|
|
17
18
|
export * from './useReturnFocus';
|
|
19
|
+
export * from './useTransferOnFullscreenEnter';
|
|
20
|
+
export * from './useTransferOnFullscreenExit';
|
|
18
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Closes the popup when fullscreen is exited. Entering/exiting fullscreen changes the context of
|
|
3
|
+
* the entire screen. This should be added to popup types that are very context sensitive like
|
|
4
|
+
* Tooltips.
|
|
5
|
+
*/
|
|
6
|
+
export declare const useCloseOnFullscreenExit: (model: import("../../..").Model<import("./usePopupModel").PopupState, import("./usePopupModel").PopupEvents>, elemProps?: {}) => {};
|
|
7
|
+
//# sourceMappingURL=useCloseOnFullscreenExit.d.ts.map
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* `useInitialFocus`. This should be used with `useFocusRedirect` or `useFocusTrap` for a complete
|
|
4
4
|
* focus management solution.
|
|
5
5
|
*
|
|
6
|
-
* This should
|
|
6
|
+
* This should be used on popup elements that use `useInitialFocus`.
|
|
7
7
|
*/
|
|
8
8
|
export declare const useReturnFocus: (model: import("../../../common").Model<import("./usePopupModel").PopupState, import("./usePopupModel").PopupEvents>, elemProps?: {}) => {};
|
|
9
9
|
//# sourceMappingURL=useReturnFocus.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Makes the popup transfer to the fullscreen element when fullscreen is entered. Without this, the
|
|
3
|
+
* popup would seem to disappear because the popup container element is not a child of the
|
|
4
|
+
* fullscreen element.
|
|
5
|
+
*
|
|
6
|
+
* Don't use this in conjunction with a hook that will close the popup when entering fullscreen.
|
|
7
|
+
* Doing so would open the popup when the intention was to close it.
|
|
8
|
+
*/
|
|
9
|
+
export declare const useTransferOnFullscreenEnter: (model: import("../../..").Model<import("./usePopupModel").PopupState, import("./usePopupModel").PopupEvents>, elemProps?: {}) => {};
|
|
10
|
+
//# sourceMappingURL=useTransferOnFullscreenEnter.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Makes the popup transfer to fullscreen when fullscreen is exited. Without this hook, the popup
|
|
3
|
+
* would not operate correctly with other popups on the screen.
|
|
4
|
+
*
|
|
5
|
+
* Don't use this in conjunction with a hook that will close the popup when exiting fullscreen.
|
|
6
|
+
* Doing so would open the popup when the intention was to close it.
|
|
7
|
+
*/
|
|
8
|
+
export declare const useTransferOnFullscreenExit: (model: import("../../..").Model<import("./usePopupModel").PopupState, import("./usePopupModel").PopupEvents>, elemProps?: {}) => {};
|
|
9
|
+
//# sourceMappingURL=useTransferOnFullscreenExit.d.ts.map
|
|
@@ -13,7 +13,7 @@ export interface RadioProps extends Themeable {
|
|
|
13
13
|
disabled?: boolean;
|
|
14
14
|
/**
|
|
15
15
|
* The HTML `id` of the underlying radio input element. This is required if `label` is defined as a non-empty string.
|
|
16
|
-
* @default A uniquely generated id
|
|
16
|
+
* @default A uniquely generated id
|
|
17
17
|
*/
|
|
18
18
|
id?: string;
|
|
19
19
|
/**
|
|
@@ -37,6 +37,14 @@ export interface TooltipProps extends Omit<React.HTMLAttributes<HTMLDivElement>,
|
|
|
37
37
|
* @default 'label'
|
|
38
38
|
*/
|
|
39
39
|
type?: 'label' | 'describe' | 'muted';
|
|
40
|
+
/**
|
|
41
|
+
* Amount of time (in ms) to delay before showing the tooltip
|
|
42
|
+
*/
|
|
43
|
+
showDelay?: number;
|
|
44
|
+
/**
|
|
45
|
+
* Amount of time (in ms) to delay before hiding the tooltip
|
|
46
|
+
*/
|
|
47
|
+
hideDelay?: number;
|
|
40
48
|
}
|
|
41
|
-
export declare const Tooltip: ({ type, placement, title, children, ...elemProps }: TooltipProps) => JSX.Element;
|
|
49
|
+
export declare const Tooltip: ({ type, placement, title, children, showDelay, hideDelay, ...elemProps }: TooltipProps) => JSX.Element;
|
|
42
50
|
//# sourceMappingURL=Tooltip.d.ts.map
|
|
@@ -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: {
|
|
@@ -13,7 +13,7 @@ export interface CheckboxProps extends Themeable {
|
|
|
13
13
|
disabled?: boolean;
|
|
14
14
|
/**
|
|
15
15
|
* The HTML `id` of the underlying checkbox input element. This is required if `label` is defined as a non-empty string.
|
|
16
|
-
* @default A uniquely generated id
|
|
16
|
+
* @default A uniquely generated id
|
|
17
17
|
*/
|
|
18
18
|
id?: string;
|
|
19
19
|
/**
|
|
@@ -10,6 +10,7 @@ export * from './useMount';
|
|
|
10
10
|
export * from './components';
|
|
11
11
|
export * from './models';
|
|
12
12
|
export * from './elements';
|
|
13
|
+
export * from './useIsFullscreen';
|
|
13
14
|
export * from './useWindowSize';
|
|
14
15
|
export * from './useResizeObserver';
|
|
15
16
|
export * from './StaticStates';
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates a unique and HTML5 compliant identifier every time it is called. Internally it uses a 4
|
|
3
|
+
* character random seed starting with a letter. This seed is unique to each instance of this
|
|
4
|
+
* package meaning different versions of Canvas Kit on the page will have a different seed. Each
|
|
5
|
+
* call will use a Base 36 string (10 numbers + 26 letters) based on an incremented number. The
|
|
6
|
+
* incremented number always starts at 0 and can be reset for testing purposes using
|
|
7
|
+
* [resetUniqueIdCount](#resetuniqueidcount). [setUniqueSeed](#setuniqueseed) can also be used for
|
|
8
|
+
* testing or server side rendering to get the same results during hydration.
|
|
9
|
+
*/
|
|
1
10
|
export declare const generateUniqueId: () => string;
|
|
2
11
|
/**
|
|
3
12
|
* Generate a unique ID if one is not provided. The generated ID will be stable across renders
|
|
@@ -10,4 +19,23 @@ export declare const useUniqueId: (id?: string | undefined) => string;
|
|
|
10
19
|
* TODO: Remove in major release
|
|
11
20
|
*/
|
|
12
21
|
export declare const uniqueId: (id?: string | undefined) => string;
|
|
22
|
+
/**
|
|
23
|
+
* Update the seed used by the id generator. This is useful for snapshot tests to help stabilize ids
|
|
24
|
+
* generated each run. This could also be used for server-side hydration - if you choose the same
|
|
25
|
+
* seed for server and set that on the client before components are rendered, the ids generated will
|
|
26
|
+
* be the same.
|
|
27
|
+
* @example
|
|
28
|
+
* // set in a script tag from the server
|
|
29
|
+
* setSeed(window.__ID_SEED); // set in a script tag from the server
|
|
30
|
+
*
|
|
31
|
+
* // jest setup
|
|
32
|
+
* before(() => {
|
|
33
|
+
* setSeed('a')
|
|
34
|
+
* })
|
|
35
|
+
*/
|
|
36
|
+
export declare const setUniqueSeed: (s: string) => void;
|
|
37
|
+
/**
|
|
38
|
+
* This should only be called for tests in an `beforeEach`
|
|
39
|
+
*/
|
|
40
|
+
export declare const resetUniqueIdCount: () => void;
|
|
13
41
|
//# sourceMappingURL=useUniqueId.d.ts.map
|
|
@@ -2,6 +2,7 @@ export * from './useAlwaysCloseOnOutsideClick';
|
|
|
2
2
|
export * from './useAssistiveHideSiblings';
|
|
3
3
|
export * from './useBringToTopOnClick';
|
|
4
4
|
export * from './useCloseOnEscape';
|
|
5
|
+
export * from './useCloseOnFullscreenExit';
|
|
5
6
|
export * from './useCloseOnOutsideClick';
|
|
6
7
|
export * from './useDisableBodyScroll';
|
|
7
8
|
export * from './useFocusRedirect';
|
|
@@ -15,4 +16,6 @@ export * from './usePopupPopper';
|
|
|
15
16
|
export * from './usePopupStack';
|
|
16
17
|
export * from './usePopupTarget';
|
|
17
18
|
export * from './useReturnFocus';
|
|
19
|
+
export * from './useTransferOnFullscreenEnter';
|
|
20
|
+
export * from './useTransferOnFullscreenExit';
|
|
18
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Closes the popup when fullscreen is exited. Entering/exiting fullscreen changes the context of
|
|
3
|
+
* the entire screen. This should be added to popup types that are very context sensitive like
|
|
4
|
+
* Tooltips.
|
|
5
|
+
*/
|
|
6
|
+
export declare const useCloseOnFullscreenExit: (model: import("../../..").Model<import("./usePopupModel").PopupState, import("./usePopupModel").PopupEvents>, elemProps?: {}) => {};
|
|
7
|
+
//# sourceMappingURL=useCloseOnFullscreenExit.d.ts.map
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* `useInitialFocus`. This should be used with `useFocusRedirect` or `useFocusTrap` for a complete
|
|
4
4
|
* focus management solution.
|
|
5
5
|
*
|
|
6
|
-
* This should
|
|
6
|
+
* This should be used on popup elements that use `useInitialFocus`.
|
|
7
7
|
*/
|
|
8
8
|
export declare const useReturnFocus: (model: import("../../../common").Model<import("./usePopupModel").PopupState, import("./usePopupModel").PopupEvents>, elemProps?: {}) => {};
|
|
9
9
|
//# sourceMappingURL=useReturnFocus.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Makes the popup transfer to the fullscreen element when fullscreen is entered. Without this, the
|
|
3
|
+
* popup would seem to disappear because the popup container element is not a child of the
|
|
4
|
+
* fullscreen element.
|
|
5
|
+
*
|
|
6
|
+
* Don't use this in conjunction with a hook that will close the popup when entering fullscreen.
|
|
7
|
+
* Doing so would open the popup when the intention was to close it.
|
|
8
|
+
*/
|
|
9
|
+
export declare const useTransferOnFullscreenEnter: (model: import("../../..").Model<import("./usePopupModel").PopupState, import("./usePopupModel").PopupEvents>, elemProps?: {}) => {};
|
|
10
|
+
//# sourceMappingURL=useTransferOnFullscreenEnter.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Makes the popup transfer to fullscreen when fullscreen is exited. Without this hook, the popup
|
|
3
|
+
* would not operate correctly with other popups on the screen.
|
|
4
|
+
*
|
|
5
|
+
* Don't use this in conjunction with a hook that will close the popup when exiting fullscreen.
|
|
6
|
+
* Doing so would open the popup when the intention was to close it.
|
|
7
|
+
*/
|
|
8
|
+
export declare const useTransferOnFullscreenExit: (model: import("../../..").Model<import("./usePopupModel").PopupState, import("./usePopupModel").PopupEvents>, elemProps?: {}) => {};
|
|
9
|
+
//# sourceMappingURL=useTransferOnFullscreenExit.d.ts.map
|
|
@@ -13,7 +13,7 @@ export interface RadioProps extends Themeable {
|
|
|
13
13
|
disabled?: boolean;
|
|
14
14
|
/**
|
|
15
15
|
* The HTML `id` of the underlying radio input element. This is required if `label` is defined as a non-empty string.
|
|
16
|
-
* @default A uniquely generated id
|
|
16
|
+
* @default A uniquely generated id
|
|
17
17
|
*/
|
|
18
18
|
id?: string;
|
|
19
19
|
/**
|
|
@@ -37,6 +37,14 @@ export interface TooltipProps extends Omit<React.HTMLAttributes<HTMLDivElement>,
|
|
|
37
37
|
* @default 'label'
|
|
38
38
|
*/
|
|
39
39
|
type?: 'label' | 'describe' | 'muted';
|
|
40
|
+
/**
|
|
41
|
+
* Amount of time (in ms) to delay before showing the tooltip
|
|
42
|
+
*/
|
|
43
|
+
showDelay?: number;
|
|
44
|
+
/**
|
|
45
|
+
* Amount of time (in ms) to delay before hiding the tooltip
|
|
46
|
+
*/
|
|
47
|
+
hideDelay?: number;
|
|
40
48
|
}
|
|
41
|
-
export declare const Tooltip: ({ type, placement, title, children, ...elemProps }: TooltipProps) => JSX.Element;
|
|
49
|
+
export declare const Tooltip: ({ type, placement, title, children, showDelay, hideDelay, ...elemProps }: TooltipProps) => JSX.Element;
|
|
42
50
|
//# sourceMappingURL=Tooltip.d.ts.map
|
|
@@ -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: {
|