@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
|
@@ -33,7 +33,7 @@ export interface CheckboxProps extends Themeable {
|
|
|
33
33
|
disabled?: boolean;
|
|
34
34
|
/**
|
|
35
35
|
* The HTML `id` of the underlying checkbox input element. This is required if `label` is defined as a non-empty string.
|
|
36
|
-
* @default A uniquely generated id
|
|
36
|
+
* @default A uniquely generated id
|
|
37
37
|
*/
|
|
38
38
|
id?: string;
|
|
39
39
|
/**
|
package/common/README.md
CHANGED
|
@@ -17,6 +17,9 @@ Includes:
|
|
|
17
17
|
- [Component Functions](#component-functions)
|
|
18
18
|
- [createComponent](#createcomponent)
|
|
19
19
|
- [ExtractProps](#extractprops)
|
|
20
|
+
- [Common Hooks](#common-hooks)
|
|
21
|
+
- [useUniqueId](#useuniqueid)
|
|
22
|
+
- [Utility Functions](#utility-functions)
|
|
20
23
|
|
|
21
24
|
## CanvasProvider
|
|
22
25
|
|
|
@@ -369,3 +372,78 @@ const MyNewComponent = createComponent('aside')(
|
|
|
369
372
|
|
|
370
373
|
If the component is a `Component` and not an `ElementComponent`, only the prop interface will ever
|
|
371
374
|
be returned since there is not HTML attribute interface associated with `Component`.
|
|
375
|
+
|
|
376
|
+
## Common Hooks
|
|
377
|
+
|
|
378
|
+
### useUniqueId
|
|
379
|
+
|
|
380
|
+
A hook to generate a unique identifier for an element. Most commonly used for accessibility. The
|
|
381
|
+
hook will generate a unique id the first render and always return the same id every render. This
|
|
382
|
+
uses [generateUniqueId](#generateuniqueid) internally.
|
|
383
|
+
|
|
384
|
+
```tsx
|
|
385
|
+
const MyComponent = () => {
|
|
386
|
+
const id = useUniqueId();
|
|
387
|
+
|
|
388
|
+
return <div id={id}>Hello!</div>;
|
|
389
|
+
};
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
If you wish to support user-defined ids, `useUniqueId` allows an optional id to override. This
|
|
393
|
+
provides a safe and easy way of handling id overrides without conditional hooks.
|
|
394
|
+
|
|
395
|
+
```tsx
|
|
396
|
+
const MyComponent = ({id}) => {
|
|
397
|
+
const localId = useUniqueId(id);
|
|
398
|
+
|
|
399
|
+
return <div id={localId}>Hello!</div>;
|
|
400
|
+
};
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
## Utility Functions
|
|
404
|
+
|
|
405
|
+
### generateUniqueId
|
|
406
|
+
|
|
407
|
+
Generates a unique and HTML5 compliant identifier every time it is called. Internally it uses a 4
|
|
408
|
+
character random seed starting with a letter. This seed is unique to each instance of this package
|
|
409
|
+
meaning different versions of Canvas Kit on the page will have a different seed. Each call will use
|
|
410
|
+
a Base 36 string (10 numbers + 26 letters) based on an incremented number. The incremented number
|
|
411
|
+
always starts at 0 and can be reset for testing purposes using
|
|
412
|
+
[resetUniqueIdCount](#resetuniqueidcount). [setUniqueSeed](#setuniqueseed) can also be used for
|
|
413
|
+
testing or server side rendering to get the same results during hydration.
|
|
414
|
+
|
|
415
|
+
```ts
|
|
416
|
+
const id1 = generateUniqueId(); // vi1e0
|
|
417
|
+
const id2 = generateUniqueId(); // vi1e1
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
### setUniqueSeed
|
|
421
|
+
|
|
422
|
+
Update the seed used by the id generator. This is useful for snapshot tests to help stabilize ids
|
|
423
|
+
generated each run. This could also be used for server-side hydration - if you choose the same seed
|
|
424
|
+
for server and set that on the client before components are rendered, the ids generated will be the
|
|
425
|
+
same.
|
|
426
|
+
|
|
427
|
+
For snapshot testing, this will help stabilize snapshot tests. Use in conjunction with
|
|
428
|
+
[resetUniqueIdCount](#resetuniqueidcount).
|
|
429
|
+
|
|
430
|
+
```ts
|
|
431
|
+
// set in a script tag from the server
|
|
432
|
+
setUniqueSeed(window.__ID_SEED); // set in a script tag from the server
|
|
433
|
+
|
|
434
|
+
// jest setup
|
|
435
|
+
before(() => {
|
|
436
|
+
setUniqueSeed('a');
|
|
437
|
+
});
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
### resetUniqueIdCount
|
|
441
|
+
|
|
442
|
+
This should only be called for tests in `beforeEach` for snapshot tests. Use in conjunction with
|
|
443
|
+
[setUniqueSeed](#setuniqueseed).
|
|
444
|
+
|
|
445
|
+
```ts
|
|
446
|
+
beforeEach(() => {
|
|
447
|
+
resetUniqueIdCount();
|
|
448
|
+
});
|
|
449
|
+
```
|
|
@@ -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';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import screenfull from 'screenfull';
|
|
3
|
+
|
|
4
|
+
export const useIsFullscreen = () => {
|
|
5
|
+
const [isFullscreen, setIsFullscreen] = React.useState(false);
|
|
6
|
+
|
|
7
|
+
const handler = React.useCallback(() => {
|
|
8
|
+
setIsFullscreen(screenfull.isFullscreen);
|
|
9
|
+
}, []);
|
|
10
|
+
|
|
11
|
+
React.useEffect(() => {
|
|
12
|
+
screenfull.on('change', handler);
|
|
13
|
+
|
|
14
|
+
return () => {
|
|
15
|
+
screenfull.off('change', handler);
|
|
16
|
+
};
|
|
17
|
+
}, [handler]);
|
|
18
|
+
|
|
19
|
+
return isFullscreen;
|
|
20
|
+
};
|
|
@@ -1,8 +1,24 @@
|
|
|
1
|
-
import uuid from 'uuid/v4';
|
|
2
|
-
|
|
3
1
|
import {useConstant} from './useConstant';
|
|
4
2
|
|
|
5
|
-
|
|
3
|
+
// Create a unique seed per import to prevent collisions from other versions of `useUniqueId`
|
|
4
|
+
let seed = Math.random()
|
|
5
|
+
.toString(36)
|
|
6
|
+
.slice(2)
|
|
7
|
+
.replace(/[0-9]*/, '')
|
|
8
|
+
.substr(0, 4);
|
|
9
|
+
|
|
10
|
+
let c = 0;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Generates a unique and HTML5 compliant identifier every time it is called. Internally it uses a 4
|
|
14
|
+
* character random seed starting with a letter. This seed is unique to each instance of this
|
|
15
|
+
* package meaning different versions of Canvas Kit on the page will have a different seed. Each
|
|
16
|
+
* call will use a Base 36 string (10 numbers + 26 letters) based on an incremented number. The
|
|
17
|
+
* incremented number always starts at 0 and can be reset for testing purposes using
|
|
18
|
+
* [resetUniqueIdCount](#resetuniqueidcount). [setUniqueSeed](#setuniqueseed) can also be used for
|
|
19
|
+
* testing or server side rendering to get the same results during hydration.
|
|
20
|
+
*/
|
|
21
|
+
export const generateUniqueId = () => seed + (c++).toString(36);
|
|
6
22
|
|
|
7
23
|
/**
|
|
8
24
|
* Generate a unique ID if one is not provided. The generated ID will be stable across renders
|
|
@@ -20,3 +36,28 @@ export const useUniqueId = (id?: string) => {
|
|
|
20
36
|
* TODO: Remove in major release
|
|
21
37
|
*/
|
|
22
38
|
export const uniqueId = useUniqueId;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Update the seed used by the id generator. This is useful for snapshot tests to help stabilize ids
|
|
42
|
+
* generated each run. This could also be used for server-side hydration - if you choose the same
|
|
43
|
+
* seed for server and set that on the client before components are rendered, the ids generated will
|
|
44
|
+
* be the same.
|
|
45
|
+
* @example
|
|
46
|
+
* // set in a script tag from the server
|
|
47
|
+
* setSeed(window.__ID_SEED); // set in a script tag from the server
|
|
48
|
+
*
|
|
49
|
+
* // jest setup
|
|
50
|
+
* before(() => {
|
|
51
|
+
* setSeed('a')
|
|
52
|
+
* })
|
|
53
|
+
*/
|
|
54
|
+
export const setUniqueSeed = (s: string) => {
|
|
55
|
+
seed = s;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* This should only be called for tests in an `beforeEach`
|
|
60
|
+
*/
|
|
61
|
+
export const resetUniqueIdCount = () => {
|
|
62
|
+
c = 0;
|
|
63
|
+
};
|
|
@@ -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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../common/lib/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../common/lib/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC"}
|
|
@@ -15,6 +15,7 @@ __export(require("./useMount"));
|
|
|
15
15
|
__export(require("./components"));
|
|
16
16
|
__export(require("./models"));
|
|
17
17
|
__export(require("./elements"));
|
|
18
|
+
__export(require("./useIsFullscreen"));
|
|
18
19
|
__export(require("./useWindowSize"));
|
|
19
20
|
__export(require("./useResizeObserver"));
|
|
20
21
|
__export(require("./StaticStates"));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIsFullscreen.d.ts","sourceRoot":"","sources":["../../../../../common/lib/utils/useIsFullscreen.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe,eAgB3B,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var react_1 = __importDefault(require("react"));
|
|
7
|
+
var screenfull_1 = __importDefault(require("screenfull"));
|
|
8
|
+
exports.useIsFullscreen = function () {
|
|
9
|
+
var _a = react_1.default.useState(false), isFullscreen = _a[0], setIsFullscreen = _a[1];
|
|
10
|
+
var handler = react_1.default.useCallback(function () {
|
|
11
|
+
setIsFullscreen(screenfull_1.default.isFullscreen);
|
|
12
|
+
}, []);
|
|
13
|
+
react_1.default.useEffect(function () {
|
|
14
|
+
screenfull_1.default.on('change', handler);
|
|
15
|
+
return function () {
|
|
16
|
+
screenfull_1.default.off('change', handler);
|
|
17
|
+
};
|
|
18
|
+
}, [handler]);
|
|
19
|
+
return isFullscreen;
|
|
20
|
+
};
|
|
@@ -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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUniqueId.d.ts","sourceRoot":"","sources":["../../../../../common/lib/utils/useUniqueId.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useUniqueId.d.ts","sourceRoot":"","sources":["../../../../../common/lib/utils/useUniqueId.ts"],"names":[],"mappings":"AAWA;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,cAAkC,CAAC;AAEhE;;;GAGG;AACH,eAAO,MAAM,WAAW,qCAIvB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,QAAQ,qCAAc,CAAC;AAEpC;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,aAAa,qBAEzB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,YAE9B,CAAC"}
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
var v4_1 = __importDefault(require("uuid/v4"));
|
|
7
3
|
var useConstant_1 = require("./useConstant");
|
|
8
|
-
|
|
4
|
+
// Create a unique seed per import to prevent collisions from other versions of `useUniqueId`
|
|
5
|
+
var seed = Math.random()
|
|
6
|
+
.toString(36)
|
|
7
|
+
.slice(2)
|
|
8
|
+
.replace(/[0-9]*/, '')
|
|
9
|
+
.substr(0, 4);
|
|
10
|
+
var c = 0;
|
|
11
|
+
/**
|
|
12
|
+
* Generates a unique and HTML5 compliant identifier every time it is called. Internally it uses a 4
|
|
13
|
+
* character random seed starting with a letter. This seed is unique to each instance of this
|
|
14
|
+
* package meaning different versions of Canvas Kit on the page will have a different seed. Each
|
|
15
|
+
* call will use a Base 36 string (10 numbers + 26 letters) based on an incremented number. The
|
|
16
|
+
* incremented number always starts at 0 and can be reset for testing purposes using
|
|
17
|
+
* [resetUniqueIdCount](#resetuniqueidcount). [setUniqueSeed](#setuniqueseed) can also be used for
|
|
18
|
+
* testing or server side rendering to get the same results during hydration.
|
|
19
|
+
*/
|
|
20
|
+
exports.generateUniqueId = function () { return seed + (c++).toString(36); };
|
|
9
21
|
/**
|
|
10
22
|
* Generate a unique ID if one is not provided. The generated ID will be stable across renders
|
|
11
23
|
* @param id Optional ID provided that will be used instead of a unique ID
|
|
@@ -21,3 +33,26 @@ exports.useUniqueId = function (id) {
|
|
|
21
33
|
* TODO: Remove in major release
|
|
22
34
|
*/
|
|
23
35
|
exports.uniqueId = exports.useUniqueId;
|
|
36
|
+
/**
|
|
37
|
+
* Update the seed used by the id generator. This is useful for snapshot tests to help stabilize ids
|
|
38
|
+
* generated each run. This could also be used for server-side hydration - if you choose the same
|
|
39
|
+
* seed for server and set that on the client before components are rendered, the ids generated will
|
|
40
|
+
* be the same.
|
|
41
|
+
* @example
|
|
42
|
+
* // set in a script tag from the server
|
|
43
|
+
* setSeed(window.__ID_SEED); // set in a script tag from the server
|
|
44
|
+
*
|
|
45
|
+
* // jest setup
|
|
46
|
+
* before(() => {
|
|
47
|
+
* setSeed('a')
|
|
48
|
+
* })
|
|
49
|
+
*/
|
|
50
|
+
exports.setUniqueSeed = function (s) {
|
|
51
|
+
seed = s;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* This should only be called for tests in an `beforeEach`
|
|
55
|
+
*/
|
|
56
|
+
exports.resetUniqueIdCount = function () {
|
|
57
|
+
c = 0;
|
|
58
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormField.d.ts","sourceRoot":"","sources":["../../../../form-field/lib/FormField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,
|
|
1
|
+
{"version":3,"file":"FormField.d.ts","sourceRoot":"","sources":["../../../../form-field/lib/FormField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EACL,cAAc,EACd,SAAS,EAET,SAAS,EAEV,MAAM,kCAAkC,CAAC;AAG1C,OAAO,EAAC,sBAAsB,EAAiC,MAAM,SAAS,CAAC;AAE/E,MAAM,WAAW,cACf,SAAQ,SAAS,EACf,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EACpC,cAAc;IAChB;;;OAGG;IACH,aAAa,CAAC,EAAE,sBAAsB,CAAC;IACvC;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAoED,cAAM,SAAU,SAAQ,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC;IACrD,MAAM,CAAC,aAAa,gCAA0B;IAC9C,MAAM,CAAC,SAAS,mBAAa;IAE7B,OAAO,CAAC,OAAO,CAAoD;IAEnE,OAAO,CAAC,cAAc,CA8BpB;IAEF,MAAM;CA2DP;AAKD,eAAe,SAAS,CAAC"}
|
|
@@ -51,7 +51,6 @@ var common_1 = require("@workday/canvas-kit-react/common");
|
|
|
51
51
|
var Hint_1 = __importDefault(require("./Hint"));
|
|
52
52
|
var Label_1 = __importDefault(require("./Label"));
|
|
53
53
|
var types_1 = require("./types");
|
|
54
|
-
var v4_1 = __importDefault(require("uuid/v4"));
|
|
55
54
|
// Use a fieldset element for accessible radio groups
|
|
56
55
|
var FormFieldFieldsetContainer = common_1.styled('fieldset')(function (_a) {
|
|
57
56
|
var grow = _a.grow, labelPosition = _a.labelPosition;
|
|
@@ -111,7 +110,7 @@ var FormField = /** @class */ (function (_super) {
|
|
|
111
110
|
__extends(FormField, _super);
|
|
112
111
|
function FormField() {
|
|
113
112
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
114
|
-
_this.inputId = _this.props.inputId ||
|
|
113
|
+
_this.inputId = _this.props.inputId || common_1.generateUniqueId();
|
|
115
114
|
_this.renderChildren = function (child) {
|
|
116
115
|
if (React.isValidElement(child)) {
|
|
117
116
|
var props = __assign({}, child.props);
|
|
@@ -32,14 +32,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
32
32
|
result["default"] = mod;
|
|
33
33
|
return result;
|
|
34
34
|
};
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
36
|
var React = __importStar(require("react"));
|
|
40
37
|
var core_1 = require("@emotion/core");
|
|
41
|
-
var styled_1 = __importDefault(require("@emotion/styled"));
|
|
42
38
|
var tokens_1 = __importStar(require("@workday/canvas-kit-react/tokens"));
|
|
39
|
+
var common_1 = require("@workday/canvas-kit-react/common");
|
|
43
40
|
/**
|
|
44
41
|
* Keyframe for the dots loading animation.
|
|
45
42
|
*/
|
|
@@ -47,7 +44,7 @@ var keyframesLoading = core_1.keyframes(templateObject_1 || (templateObject_1 =
|
|
|
47
44
|
/**
|
|
48
45
|
* The actual loading dot div.
|
|
49
46
|
*/
|
|
50
|
-
var LoadingAnimationDot =
|
|
47
|
+
var LoadingAnimationDot = common_1.styled('div')({
|
|
51
48
|
backgroundColor: tokens_1.default.colors.soap400,
|
|
52
49
|
width: tokens_1.default.space.s,
|
|
53
50
|
height: tokens_1.default.space.s,
|
|
@@ -73,7 +70,7 @@ var LoadingAnimationDot = styled_1.default('div')({
|
|
|
73
70
|
/**
|
|
74
71
|
* A simple container for the loading dots.
|
|
75
72
|
*/
|
|
76
|
-
var Container =
|
|
73
|
+
var Container = common_1.styled('div')({
|
|
77
74
|
display: 'inline-block',
|
|
78
75
|
});
|
|
79
76
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopupCard.d.ts","sourceRoot":"","sources":["../../../../popup/lib/PopupCard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAC,IAAI,EAAC,MAAM,gCAAgC,CAAC;AAEpD,OAAO,EAOL,YAAY,EACb,MAAM,kCAAkC,CAAC;AAG1C,OAAO,EAAe,UAAU,EAAoB,MAAM,SAAS,CAAC;AAEpE,MAAM,WAAW,cAAe,SAAQ,YAAY,CAAC,OAAO,IAAI,EAAE,KAAK,CAAC;IACtE;;;OAGG;IACH,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;
|
|
1
|
+
{"version":3,"file":"PopupCard.d.ts","sourceRoot":"","sources":["../../../../popup/lib/PopupCard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAC,IAAI,EAAC,MAAM,gCAAgC,CAAC;AAEpD,OAAO,EAOL,YAAY,EACb,MAAM,kCAAkC,CAAC;AAG1C,OAAO,EAAe,UAAU,EAAoB,MAAM,SAAS,CAAC;AAEpE,MAAM,WAAW,cAAe,SAAQ,YAAY,CAAC,OAAO,IAAI,EAAE,KAAK,CAAC;IACtE;;;OAGG;IACH,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAmCD,eAAO,MAAM,SAAS,gEAuBpB,CAAC"}
|
|
@@ -44,13 +44,7 @@ var popupAnimation = function (transformOrigin) {
|
|
|
44
44
|
var translate = common_1.getTranslateFromOrigin(transformOrigin, tokens_1.space.xxs);
|
|
45
45
|
return core_1.keyframes(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n 0% {\n opacity: 0;\n transform: translate(", "px, ", "px);\n }\n 100% {\n opacity: 1;\n transform: translate(0);\n }\n "], ["\n 0% {\n opacity: 0;\n transform: translate(", "px, ", "px);\n }\n 100% {\n opacity: 1;\n transform: translate(0);\n }\n "])), translate.x, translate.y);
|
|
46
46
|
};
|
|
47
|
-
var StyledPopupCard = common_1.styled(card_1.Card)(tokens_1.type.levels.subtext.large, {
|
|
48
|
-
position: 'relative',
|
|
49
|
-
maxWidth: "calc(100vw - " + tokens_1.space.l + ")",
|
|
50
|
-
}, function (_a) {
|
|
51
|
-
var width = _a.width;
|
|
52
|
-
return width && { width: width };
|
|
53
|
-
}, function (_a) {
|
|
47
|
+
var StyledPopupCard = common_1.styled(card_1.Card)(tokens_1.type.levels.subtext.large, function (_a) {
|
|
54
48
|
var transformOrigin = _a.transformOrigin;
|
|
55
49
|
if (transformOrigin == null) {
|
|
56
50
|
return {};
|
|
@@ -69,13 +63,13 @@ var StyledPopupCard = common_1.styled(card_1.Card)(tokens_1.type.levels.subtext.
|
|
|
69
63
|
exports.PopupCard = common_1.createComponent('div')({
|
|
70
64
|
displayName: 'Popup.Card',
|
|
71
65
|
Component: function (_a, ref, Element) {
|
|
72
|
-
var children = _a.children, model = _a.model,
|
|
66
|
+
var children = _a.children, model = _a.model, elemProps = __rest(_a, ["children", "model"]);
|
|
73
67
|
var localModel = common_1.useModelContext(hooks_1.PopupModelContext, model);
|
|
74
68
|
var props = hooks_1.usePopupCard(localModel, elemProps, ref);
|
|
75
69
|
var transformOrigin = React.useMemo(function () {
|
|
76
70
|
return getTransformFromPlacement_1.getTransformFromPlacement(localModel.state.placement || 'bottom');
|
|
77
71
|
}, [localModel.state.placement]);
|
|
78
|
-
return (React.createElement(StyledPopupCard, __assign({ as: Element, transformOrigin: transformOrigin,
|
|
72
|
+
return (React.createElement(StyledPopupCard, __assign({ as: Element, transformOrigin: transformOrigin, position: "relative", padding: "l", depth: 2, maxWidth: "calc(100vw - " + tokens_1.space.l + ")" }, props), children));
|
|
79
73
|
},
|
|
80
74
|
});
|
|
81
75
|
var templateObject_1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"focus-trap-js.d.ts","sourceRoot":"","sources":["../../../../../popup/lib/hooks/focus-trap-js.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"focus-trap-js.d.ts","sourceRoot":"","sources":["../../../../../popup/lib/hooks/focus-trap-js.ts"],"names":[],"mappings":"AAkFA,iBAAS,cAAc,CACrB,KAAK,EAAE,aAAa,EACpB,UAAU,EAAE,WAAW,GAAG,QAAQ,EAClC,YAAY,GAAE,WAAW,EAAE,GAAG,IAAW,uBAgC1C;kBAnCQ,cAAc;;;AA0DvB,OAAO,EAAC,cAAc,EAAC,CAAC"}
|
|
@@ -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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../popup/lib/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../popup/lib/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC"}
|
|
@@ -7,6 +7,7 @@ __export(require("./useAlwaysCloseOnOutsideClick"));
|
|
|
7
7
|
__export(require("./useAssistiveHideSiblings"));
|
|
8
8
|
__export(require("./useBringToTopOnClick"));
|
|
9
9
|
__export(require("./useCloseOnEscape"));
|
|
10
|
+
__export(require("./useCloseOnFullscreenExit"));
|
|
10
11
|
__export(require("./useCloseOnOutsideClick"));
|
|
11
12
|
__export(require("./useDisableBodyScroll"));
|
|
12
13
|
__export(require("./useFocusRedirect"));
|
|
@@ -20,3 +21,5 @@ __export(require("./usePopupPopper"));
|
|
|
20
21
|
__export(require("./usePopupStack"));
|
|
21
22
|
__export(require("./usePopupTarget"));
|
|
22
23
|
__export(require("./useReturnFocus"));
|
|
24
|
+
__export(require("./useTransferOnFullscreenEnter"));
|
|
25
|
+
__export(require("./useTransferOnFullscreenExit"));
|
|
@@ -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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCloseOnFullscreenExit.d.ts","sourceRoot":"","sources":["../../../../../popup/lib/hooks/useCloseOnFullscreenExit.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,sIA0BpC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var react_1 = __importDefault(require("react"));
|
|
7
|
+
var screenfull_1 = __importDefault(require("screenfull"));
|
|
8
|
+
/**
|
|
9
|
+
* Closes the popup when fullscreen is exited. Entering/exiting fullscreen changes the context of
|
|
10
|
+
* the entire screen. This should be added to popup types that are very context sensitive like
|
|
11
|
+
* Tooltips.
|
|
12
|
+
*/
|
|
13
|
+
exports.useCloseOnFullscreenExit = function (model, elemProps) {
|
|
14
|
+
if (elemProps === void 0) { elemProps = {}; }
|
|
15
|
+
var handler = react_1.default.useCallback(function (event) {
|
|
16
|
+
if (!screenfull_1.default.isFullscreen) {
|
|
17
|
+
model.events.hide({ event: event });
|
|
18
|
+
}
|
|
19
|
+
}, [model.events]);
|
|
20
|
+
var visible = model.state.visibility !== 'hidden';
|
|
21
|
+
react_1.default.useEffect(function () {
|
|
22
|
+
if (!visible) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (screenfull_1.default.isEnabled) {
|
|
26
|
+
screenfull_1.default.on('change', handler);
|
|
27
|
+
return function () {
|
|
28
|
+
screenfull_1.default.off('change', handler);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
return;
|
|
32
|
+
}, [handler, visible]);
|
|
33
|
+
return elemProps;
|
|
34
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePopupStack.d.ts","sourceRoot":"","sources":["../../../../../popup/lib/hooks/usePopupStack.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"usePopupStack.d.ts","sourceRoot":"","sources":["../../../../../popup/lib/hooks/usePopupStack.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,aAAa,wMA8CzB,CAAC"}
|
|
@@ -61,8 +61,8 @@ exports.usePopupStack = function (ref, target) {
|
|
|
61
61
|
? target.current || undefined
|
|
62
62
|
: target
|
|
63
63
|
: undefined;
|
|
64
|
-
canvas_kit_popup_stack_1.PopupStack.add({ element: localRef.current, owner: targetEl });
|
|
65
64
|
var element = localRef.current;
|
|
65
|
+
canvas_kit_popup_stack_1.PopupStack.add({ element: element, owner: targetEl });
|
|
66
66
|
return function () {
|
|
67
67
|
canvas_kit_popup_stack_1.PopupStack.remove(element);
|
|
68
68
|
};
|
|
@@ -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
|
|
@@ -10,7 +10,7 @@ var common_1 = require("@workday/canvas-kit-react/common");
|
|
|
10
10
|
* `useInitialFocus`. This should be used with `useFocusRedirect` or `useFocusTrap` for a complete
|
|
11
11
|
* focus management solution.
|
|
12
12
|
*
|
|
13
|
-
* This should
|
|
13
|
+
* This should be used on popup elements that use `useInitialFocus`.
|
|
14
14
|
*/
|
|
15
15
|
exports.useReturnFocus = function (model, elemProps) {
|
|
16
16
|
if (elemProps === void 0) { elemProps = {}; }
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"useTransferOnFullscreenEnter.d.ts","sourceRoot":"","sources":["../../../../../popup/lib/hooks/useTransferOnFullscreenEnter.ts"],"names":[],"mappings":"AAMA;;;;;;;GAOG;AACH,eAAO,MAAM,4BAA4B,sIA6BxC,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var react_1 = __importDefault(require("react"));
|
|
7
|
+
var screenfull_1 = __importDefault(require("screenfull"));
|
|
8
|
+
var canvas_kit_popup_stack_1 = require("@workday/canvas-kit-popup-stack");
|
|
9
|
+
/**
|
|
10
|
+
* Makes the popup transfer to the fullscreen element when fullscreen is entered. Without this, the
|
|
11
|
+
* popup would seem to disappear because the popup container element is not a child of the
|
|
12
|
+
* fullscreen element.
|
|
13
|
+
*
|
|
14
|
+
* Don't use this in conjunction with a hook that will close the popup when entering fullscreen.
|
|
15
|
+
* Doing so would open the popup when the intention was to close it.
|
|
16
|
+
*/
|
|
17
|
+
exports.useTransferOnFullscreenEnter = function (model, elemProps) {
|
|
18
|
+
if (elemProps === void 0) { elemProps = {}; }
|
|
19
|
+
var handler = react_1.default.useCallback(function (event) {
|
|
20
|
+
if (screenfull_1.default.isFullscreen && model.state.stackRef.current) {
|
|
21
|
+
canvas_kit_popup_stack_1.PopupStack.transferToCurrentContext({
|
|
22
|
+
element: model.state.stackRef.current,
|
|
23
|
+
owner: model.state.targetRef.current,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}, [model.state.stackRef, model.state.targetRef]);
|
|
27
|
+
var visible = model.state.visibility !== 'hidden';
|
|
28
|
+
react_1.default.useEffect(function () {
|
|
29
|
+
if (!visible) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (screenfull_1.default.isEnabled) {
|
|
33
|
+
screenfull_1.default.on('change', handler);
|
|
34
|
+
return function () {
|
|
35
|
+
screenfull_1.default.off('change', handler);
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return;
|
|
39
|
+
}, [handler, visible]);
|
|
40
|
+
return elemProps;
|
|
41
|
+
};
|