@workday/canvas-kit-react 6.1.5 → 6.3.0-next.0

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.
Files changed (100) hide show
  1. package/checkbox/lib/Checkbox.tsx +1 -1
  2. package/common/README.md +78 -0
  3. package/common/lib/utils/index.ts +1 -0
  4. package/common/lib/utils/useIsFullscreen.ts +20 -0
  5. package/common/lib/utils/useUniqueId.ts +44 -3
  6. package/dist/commonjs/checkbox/lib/Checkbox.d.ts +1 -1
  7. package/dist/commonjs/common/lib/utils/index.d.ts +1 -0
  8. package/dist/commonjs/common/lib/utils/index.d.ts.map +1 -1
  9. package/dist/commonjs/common/lib/utils/index.js +1 -0
  10. package/dist/commonjs/common/lib/utils/useIsFullscreen.d.ts +2 -0
  11. package/dist/commonjs/common/lib/utils/useIsFullscreen.d.ts.map +1 -0
  12. package/dist/commonjs/common/lib/utils/useIsFullscreen.js +20 -0
  13. package/dist/commonjs/common/lib/utils/useUniqueId.d.ts +28 -0
  14. package/dist/commonjs/common/lib/utils/useUniqueId.d.ts.map +1 -1
  15. package/dist/commonjs/common/lib/utils/useUniqueId.js +40 -5
  16. package/dist/commonjs/form-field/lib/FormField.d.ts.map +1 -1
  17. package/dist/commonjs/form-field/lib/FormField.js +1 -2
  18. package/dist/commonjs/popup/lib/hooks/focus-trap-js.d.ts.map +1 -1
  19. package/dist/commonjs/popup/lib/hooks/focus-trap-js.js +1 -0
  20. package/dist/commonjs/popup/lib/hooks/index.d.ts +3 -0
  21. package/dist/commonjs/popup/lib/hooks/index.d.ts.map +1 -1
  22. package/dist/commonjs/popup/lib/hooks/index.js +3 -0
  23. package/dist/commonjs/popup/lib/hooks/useCloseOnFullscreenExit.d.ts +7 -0
  24. package/dist/commonjs/popup/lib/hooks/useCloseOnFullscreenExit.d.ts.map +1 -0
  25. package/dist/commonjs/popup/lib/hooks/useCloseOnFullscreenExit.js +34 -0
  26. package/dist/commonjs/popup/lib/hooks/usePopupStack.d.ts.map +1 -1
  27. package/dist/commonjs/popup/lib/hooks/usePopupStack.js +1 -1
  28. package/dist/commonjs/popup/lib/hooks/useTransferOnFullscreenEnter.d.ts +10 -0
  29. package/dist/commonjs/popup/lib/hooks/useTransferOnFullscreenEnter.d.ts.map +1 -0
  30. package/dist/commonjs/popup/lib/hooks/useTransferOnFullscreenEnter.js +41 -0
  31. package/dist/commonjs/popup/lib/hooks/useTransferOnFullscreenExit.d.ts +9 -0
  32. package/dist/commonjs/popup/lib/hooks/useTransferOnFullscreenExit.d.ts.map +1 -0
  33. package/dist/commonjs/popup/lib/hooks/useTransferOnFullscreenExit.js +40 -0
  34. package/dist/commonjs/radio/lib/Radio.d.ts +1 -1
  35. package/dist/commonjs/switch/lib/Switch.d.ts +1 -1
  36. package/dist/commonjs/tooltip/lib/useTooltip.d.ts.map +1 -1
  37. package/dist/commonjs/tooltip/lib/useTooltip.js +3 -5
  38. package/dist/es6/checkbox/lib/Checkbox.d.ts +1 -1
  39. package/dist/es6/common/lib/utils/index.d.ts +1 -0
  40. package/dist/es6/common/lib/utils/index.d.ts.map +1 -1
  41. package/dist/es6/common/lib/utils/index.js +1 -0
  42. package/dist/es6/common/lib/utils/useIsFullscreen.d.ts +2 -0
  43. package/dist/es6/common/lib/utils/useIsFullscreen.d.ts.map +1 -0
  44. package/dist/es6/common/lib/utils/useIsFullscreen.js +15 -0
  45. package/dist/es6/common/lib/utils/useUniqueId.d.ts +28 -0
  46. package/dist/es6/common/lib/utils/useUniqueId.d.ts.map +1 -1
  47. package/dist/es6/common/lib/utils/useUniqueId.js +40 -2
  48. package/dist/es6/form-field/lib/FormField.d.ts.map +1 -1
  49. package/dist/es6/form-field/lib/FormField.js +2 -3
  50. package/dist/es6/popup/lib/hooks/focus-trap-js.d.ts.map +1 -1
  51. package/dist/es6/popup/lib/hooks/focus-trap-js.js +1 -0
  52. package/dist/es6/popup/lib/hooks/index.d.ts +3 -0
  53. package/dist/es6/popup/lib/hooks/index.d.ts.map +1 -1
  54. package/dist/es6/popup/lib/hooks/index.js +3 -0
  55. package/dist/es6/popup/lib/hooks/useCloseOnFullscreenExit.d.ts +7 -0
  56. package/dist/es6/popup/lib/hooks/useCloseOnFullscreenExit.d.ts.map +1 -0
  57. package/dist/es6/popup/lib/hooks/useCloseOnFullscreenExit.js +29 -0
  58. package/dist/es6/popup/lib/hooks/usePopupStack.d.ts.map +1 -1
  59. package/dist/es6/popup/lib/hooks/usePopupStack.js +1 -1
  60. package/dist/es6/popup/lib/hooks/useTransferOnFullscreenEnter.d.ts +10 -0
  61. package/dist/es6/popup/lib/hooks/useTransferOnFullscreenEnter.d.ts.map +1 -0
  62. package/dist/es6/popup/lib/hooks/useTransferOnFullscreenEnter.js +36 -0
  63. package/dist/es6/popup/lib/hooks/useTransferOnFullscreenExit.d.ts +9 -0
  64. package/dist/es6/popup/lib/hooks/useTransferOnFullscreenExit.d.ts.map +1 -0
  65. package/dist/es6/popup/lib/hooks/useTransferOnFullscreenExit.js +35 -0
  66. package/dist/es6/radio/lib/Radio.d.ts +1 -1
  67. package/dist/es6/switch/lib/Switch.d.ts +1 -1
  68. package/dist/es6/tooltip/lib/useTooltip.d.ts.map +1 -1
  69. package/dist/es6/tooltip/lib/useTooltip.js +4 -3
  70. package/form-field/lib/FormField.tsx +8 -3
  71. package/package.json +7 -7
  72. package/popup/lib/hooks/focus-trap-js.ts +1 -0
  73. package/popup/lib/hooks/index.ts +3 -0
  74. package/popup/lib/hooks/useCloseOnFullscreenExit.ts +37 -0
  75. package/popup/lib/hooks/usePopupStack.ts +2 -1
  76. package/popup/lib/hooks/useTransferOnFullscreenEnter.ts +44 -0
  77. package/popup/lib/hooks/useTransferOnFullscreenExit.ts +43 -0
  78. package/radio/lib/Radio.tsx +1 -1
  79. package/switch/lib/Switch.tsx +1 -1
  80. package/tooltip/lib/useTooltip.tsx +4 -2
  81. package/ts3.5/dist/commonjs/checkbox/lib/Checkbox.d.ts +1 -1
  82. package/ts3.5/dist/commonjs/common/lib/utils/index.d.ts +1 -0
  83. package/ts3.5/dist/commonjs/common/lib/utils/useIsFullscreen.d.ts +2 -0
  84. package/ts3.5/dist/commonjs/common/lib/utils/useUniqueId.d.ts +28 -0
  85. package/ts3.5/dist/commonjs/popup/lib/hooks/index.d.ts +3 -0
  86. package/ts3.5/dist/commonjs/popup/lib/hooks/useCloseOnFullscreenExit.d.ts +7 -0
  87. package/ts3.5/dist/commonjs/popup/lib/hooks/useTransferOnFullscreenEnter.d.ts +10 -0
  88. package/ts3.5/dist/commonjs/popup/lib/hooks/useTransferOnFullscreenExit.d.ts +9 -0
  89. package/ts3.5/dist/commonjs/radio/lib/Radio.d.ts +1 -1
  90. package/ts3.5/dist/commonjs/switch/lib/Switch.d.ts +1 -1
  91. package/ts3.5/dist/es6/checkbox/lib/Checkbox.d.ts +1 -1
  92. package/ts3.5/dist/es6/common/lib/utils/index.d.ts +1 -0
  93. package/ts3.5/dist/es6/common/lib/utils/useIsFullscreen.d.ts +2 -0
  94. package/ts3.5/dist/es6/common/lib/utils/useUniqueId.d.ts +28 -0
  95. package/ts3.5/dist/es6/popup/lib/hooks/index.d.ts +3 -0
  96. package/ts3.5/dist/es6/popup/lib/hooks/useCloseOnFullscreenExit.d.ts +7 -0
  97. package/ts3.5/dist/es6/popup/lib/hooks/useTransferOnFullscreenEnter.d.ts +10 -0
  98. package/ts3.5/dist/es6/popup/lib/hooks/useTransferOnFullscreenExit.d.ts +9 -0
  99. package/ts3.5/dist/es6/radio/lib/Radio.d.ts +1 -1
  100. package/ts3.5/dist/es6/switch/lib/Switch.d.ts +1 -1
@@ -6,13 +6,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
6
6
  result["default"] = mod;
7
7
  return result;
8
8
  };
9
- var __importDefault = (this && this.__importDefault) || function (mod) {
10
- return (mod && mod.__esModule) ? mod : { "default": mod };
11
- };
12
9
  Object.defineProperty(exports, "__esModule", { value: true });
13
10
  var React = __importStar(require("react"));
14
- var v4_1 = __importDefault(require("uuid/v4"));
15
11
  var popup_1 = require("@workday/canvas-kit-react/popup");
12
+ var common_1 = require("@workday/canvas-kit-react/common");
16
13
  var useIntentTimer = function (fn, waitMs) {
17
14
  if (waitMs === void 0) { waitMs = 0; }
18
15
  var timer = React.useRef();
@@ -57,7 +54,7 @@ function useTooltip(_a) {
57
54
  var mouseDownRef = React.useRef(false); // use to prevent newly focused from making tooltip flash
58
55
  var popupModel = popup_1.usePopupModel();
59
56
  var _g = React.useState(null), anchorElement = _g[0], setAnchorElement = _g[1];
60
- var id = React.useState(function () { return v4_1.default(); })[0];
57
+ var id = common_1.useUniqueId();
61
58
  var intentTimerHide = useIntentTimer(popupModel.events.hide, hideDelay);
62
59
  var intentTimerShow = useIntentTimer(popupModel.events.show, showDelay);
63
60
  var onHide = function () {
@@ -86,6 +83,7 @@ function useTooltip(_a) {
86
83
  };
87
84
  popup_1.useCloseOnEscape(popupModel);
88
85
  popup_1.useAlwaysCloseOnOutsideClick(popupModel);
86
+ popup_1.useCloseOnFullscreenExit(popupModel);
89
87
  var visible = popupModel.state.visibility !== 'hidden';
90
88
  return {
91
89
  /** Mix these properties into the target element. **Must be an Element** */
@@ -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 by uuid()
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"}
@@ -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,2 @@
1
+ export declare const useIsFullscreen: () => boolean;
2
+ //# sourceMappingURL=useIsFullscreen.d.ts.map
@@ -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,15 @@
1
+ import React from 'react';
2
+ import screenfull from 'screenfull';
3
+ export var useIsFullscreen = function () {
4
+ var _a = React.useState(false), isFullscreen = _a[0], setIsFullscreen = _a[1];
5
+ var handler = React.useCallback(function () {
6
+ setIsFullscreen(screenfull.isFullscreen);
7
+ }, []);
8
+ React.useEffect(function () {
9
+ screenfull.on('change', handler);
10
+ return function () {
11
+ screenfull.off('change', handler);
12
+ };
13
+ }, [handler]);
14
+ return isFullscreen;
15
+ };
@@ -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":"AAIA,eAAO,MAAM,gBAAgB,cAA0C,CAAC;AAExE;;;GAGG;AACH,eAAO,MAAM,WAAW,qCAIvB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,QAAQ,qCAAc,CAAC"}
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,6 +1,21 @@
1
- import uuid from 'uuid/v4';
2
1
  import { useConstant } from './useConstant';
3
- export var generateUniqueId = function () { return uuid().replace(/^[0-9\-]*/gi, ''); };
2
+ // Create a unique seed per import to prevent collisions from other versions of `useUniqueId`
3
+ var seed = Math.random()
4
+ .toString(36)
5
+ .slice(2)
6
+ .replace(/[0-9]*/, '')
7
+ .substr(0, 4);
8
+ var c = 0;
9
+ /**
10
+ * Generates a unique and HTML5 compliant identifier every time it is called. Internally it uses a 4
11
+ * character random seed starting with a letter. This seed is unique to each instance of this
12
+ * package meaning different versions of Canvas Kit on the page will have a different seed. Each
13
+ * call will use a Base 36 string (10 numbers + 26 letters) based on an incremented number. The
14
+ * incremented number always starts at 0 and can be reset for testing purposes using
15
+ * [resetUniqueIdCount](#resetuniqueidcount). [setUniqueSeed](#setuniqueseed) can also be used for
16
+ * testing or server side rendering to get the same results during hydration.
17
+ */
18
+ export var generateUniqueId = function () { return seed + (c++).toString(36); };
4
19
  /**
5
20
  * Generate a unique ID if one is not provided. The generated ID will be stable across renders
6
21
  * @param id Optional ID provided that will be used instead of a unique ID
@@ -16,3 +31,26 @@ export var useUniqueId = function (id) {
16
31
  * TODO: Remove in major release
17
32
  */
18
33
  export var uniqueId = useUniqueId;
34
+ /**
35
+ * Update the seed used by the id generator. This is useful for snapshot tests to help stabilize ids
36
+ * generated each run. This could also be used for server-side hydration - if you choose the same
37
+ * seed for server and set that on the client before components are rendered, the ids generated will
38
+ * be the same.
39
+ * @example
40
+ * // set in a script tag from the server
41
+ * setSeed(window.__ID_SEED); // set in a script tag from the server
42
+ *
43
+ * // jest setup
44
+ * before(() => {
45
+ * setSeed('a')
46
+ * })
47
+ */
48
+ export var setUniqueSeed = function (s) {
49
+ seed = s;
50
+ };
51
+ /**
52
+ * This should only be called for tests in an `beforeEach`
53
+ */
54
+ export var resetUniqueIdCount = function () {
55
+ c = 0;
56
+ };
@@ -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,EAAC,cAAc,EAAE,SAAS,EAAU,SAAS,EAAC,MAAM,kCAAkC,CAAC;AAG9F,OAAO,EAAC,sBAAsB,EAAiC,MAAM,SAAS,CAAC;AAG/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,CAAwC;IAEvD,OAAO,CAAC,cAAc,CA8BpB;IAEF,MAAM;CA2DP;AAKD,eAAe,SAAS,CAAC"}
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"}
@@ -35,11 +35,10 @@ var __rest = (this && this.__rest) || function (s, e) {
35
35
  };
36
36
  import * as React from 'react';
37
37
  import { space } from '@workday/canvas-kit-react/tokens';
38
- import { ErrorType, styled } from '@workday/canvas-kit-react/common';
38
+ import { ErrorType, styled, generateUniqueId, } from '@workday/canvas-kit-react/common';
39
39
  import Hint from './Hint';
40
40
  import Label from './Label';
41
41
  import { FormFieldLabelPosition } from './types';
42
- import uuid from 'uuid/v4';
43
42
  // Use a fieldset element for accessible radio groups
44
43
  var FormFieldFieldsetContainer = styled('fieldset')(function (_a) {
45
44
  var grow = _a.grow, labelPosition = _a.labelPosition;
@@ -99,7 +98,7 @@ var FormField = /** @class */ (function (_super) {
99
98
  __extends(FormField, _super);
100
99
  function FormField() {
101
100
  var _this = _super !== null && _super.apply(this, arguments) || this;
102
- _this.inputId = _this.props.inputId || uuid();
101
+ _this.inputId = _this.props.inputId || generateUniqueId();
103
102
  _this.renderChildren = function (child) {
104
103
  if (React.isValidElement(child)) {
105
104
  var props = __assign({}, child.props);
@@ -1 +1 @@
1
- {"version":3,"file":"focus-trap-js.d.ts","sourceRoot":"","sources":["../../../../../popup/lib/hooks/focus-trap-js.ts"],"names":[],"mappings":"AAiFA,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"}
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"}
@@ -1,4 +1,5 @@
1
1
  // refactor for v5
2
+ /// <reference types="@types/node" />
2
3
  var candidateSelectors = [
3
4
  'input',
4
5
  'select',
@@ -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"}
@@ -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,3 +16,5 @@ 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';
@@ -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,29 @@
1
+ import React from 'react';
2
+ import screenfull from 'screenfull';
3
+ /**
4
+ * Closes the popup when fullscreen is exited. Entering/exiting fullscreen changes the context of
5
+ * the entire screen. This should be added to popup types that are very context sensitive like
6
+ * Tooltips.
7
+ */
8
+ export var useCloseOnFullscreenExit = function (model, elemProps) {
9
+ if (elemProps === void 0) { elemProps = {}; }
10
+ var handler = React.useCallback(function (event) {
11
+ if (!screenfull.isFullscreen) {
12
+ model.events.hide({ event: event });
13
+ }
14
+ }, [model.events]);
15
+ var visible = model.state.visibility !== 'hidden';
16
+ React.useEffect(function () {
17
+ if (!visible) {
18
+ return;
19
+ }
20
+ if (screenfull.isEnabled) {
21
+ screenfull.on('change', handler);
22
+ return function () {
23
+ screenfull.off('change', handler);
24
+ };
25
+ }
26
+ return;
27
+ }, [handler, visible]);
28
+ return elemProps;
29
+ };
@@ -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,wMA6CzB,CAAC"}
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"}
@@ -56,8 +56,8 @@ export var usePopupStack = function (ref, target) {
56
56
  ? target.current || undefined
57
57
  : target
58
58
  : undefined;
59
- PopupStack.add({ element: localRef.current, owner: targetEl });
60
59
  var element = localRef.current;
60
+ PopupStack.add({ element: element, owner: targetEl });
61
61
  return function () {
62
62
  PopupStack.remove(element);
63
63
  };
@@ -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,36 @@
1
+ import React from 'react';
2
+ import screenfull from 'screenfull';
3
+ import { PopupStack } from '@workday/canvas-kit-popup-stack';
4
+ /**
5
+ * Makes the popup transfer to the fullscreen element when fullscreen is entered. Without this, the
6
+ * popup would seem to disappear because the popup container element is not a child of the
7
+ * fullscreen element.
8
+ *
9
+ * Don't use this in conjunction with a hook that will close the popup when entering fullscreen.
10
+ * Doing so would open the popup when the intention was to close it.
11
+ */
12
+ export var useTransferOnFullscreenEnter = function (model, elemProps) {
13
+ if (elemProps === void 0) { elemProps = {}; }
14
+ var handler = React.useCallback(function (event) {
15
+ if (screenfull.isFullscreen && model.state.stackRef.current) {
16
+ PopupStack.transferToCurrentContext({
17
+ element: model.state.stackRef.current,
18
+ owner: model.state.targetRef.current,
19
+ });
20
+ }
21
+ }, [model.state.stackRef, model.state.targetRef]);
22
+ var visible = model.state.visibility !== 'hidden';
23
+ React.useEffect(function () {
24
+ if (!visible) {
25
+ return;
26
+ }
27
+ if (screenfull.isEnabled) {
28
+ screenfull.on('change', handler);
29
+ return function () {
30
+ screenfull.off('change', handler);
31
+ };
32
+ }
33
+ return;
34
+ }, [handler, visible]);
35
+ return elemProps;
36
+ };
@@ -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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTransferOnFullscreenExit.d.ts","sourceRoot":"","sources":["../../../../../popup/lib/hooks/useTransferOnFullscreenExit.ts"],"names":[],"mappings":"AAMA;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,sIA6BvC,CAAC"}
@@ -0,0 +1,35 @@
1
+ import React from 'react';
2
+ import screenfull from 'screenfull';
3
+ import { PopupStack } from '@workday/canvas-kit-popup-stack';
4
+ /**
5
+ * Makes the popup transfer to fullscreen when fullscreen is exited. Without this hook, the popup
6
+ * would not operate correctly with other popups on the screen.
7
+ *
8
+ * Don't use this in conjunction with a hook that will close the popup when exiting fullscreen.
9
+ * Doing so would open the popup when the intention was to close it.
10
+ */
11
+ export var useTransferOnFullscreenExit = function (model, elemProps) {
12
+ if (elemProps === void 0) { elemProps = {}; }
13
+ var handler = React.useCallback(function (event) {
14
+ if (!screenfull.isFullscreen && model.state.stackRef.current) {
15
+ PopupStack.transferToCurrentContext({
16
+ element: model.state.stackRef.current,
17
+ owner: model.state.targetRef.current,
18
+ });
19
+ }
20
+ }, [model.state.stackRef, model.state.targetRef]);
21
+ var visible = model.state.visibility !== 'hidden';
22
+ React.useEffect(function () {
23
+ if (!visible) {
24
+ return;
25
+ }
26
+ if (screenfull.isEnabled) {
27
+ screenfull.on('change', handler);
28
+ return function () {
29
+ screenfull.off('change', handler);
30
+ };
31
+ }
32
+ return;
33
+ }, [handler, visible]);
34
+ return elemProps;
35
+ };
@@ -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 by uuid()
16
+ * @default A uniquely generated id
17
17
  */
18
18
  id?: string;
19
19
  /**
@@ -13,7 +13,7 @@ export interface SwitchProps extends Themeable {
13
13
  disabled?: boolean;
14
14
  /**
15
15
  * The HTML `id` of the underlying checkbox input element.
16
- * @default A uniquely generated id by uuid()
16
+ * @default A uniquely generated id
17
17
  */
18
18
  id?: string;
19
19
  /**
@@ -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,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"}
1
+ {"version":3,"file":"useTooltip.d.ts","sourceRoot":"","sources":["../../../../tooltip/lib/useTooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAkD/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;IA6CF,2EAA2E;;;;;;;;;;IAY3E,uDAAuD;;;;;;IAMvD,iEAAiE;;;;;;;EAQpE"}
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
- import uuid from 'uuid/v4';
3
- import { useCloseOnEscape, useAlwaysCloseOnOutsideClick, usePopupModel, } from '@workday/canvas-kit-react/popup';
2
+ import { useCloseOnEscape, useAlwaysCloseOnOutsideClick, usePopupModel, useCloseOnFullscreenExit, } from '@workday/canvas-kit-react/popup';
3
+ import { useUniqueId } from '@workday/canvas-kit-react/common';
4
4
  var useIntentTimer = function (fn, waitMs) {
5
5
  if (waitMs === void 0) { waitMs = 0; }
6
6
  var timer = React.useRef();
@@ -45,7 +45,7 @@ export function useTooltip(_a) {
45
45
  var mouseDownRef = React.useRef(false); // use to prevent newly focused from making tooltip flash
46
46
  var popupModel = usePopupModel();
47
47
  var _g = React.useState(null), anchorElement = _g[0], setAnchorElement = _g[1];
48
- var id = React.useState(function () { return uuid(); })[0];
48
+ var id = useUniqueId();
49
49
  var intentTimerHide = useIntentTimer(popupModel.events.hide, hideDelay);
50
50
  var intentTimerShow = useIntentTimer(popupModel.events.show, showDelay);
51
51
  var onHide = function () {
@@ -74,6 +74,7 @@ export function useTooltip(_a) {
74
74
  };
75
75
  useCloseOnEscape(popupModel);
76
76
  useAlwaysCloseOnOutsideClick(popupModel);
77
+ useCloseOnFullscreenExit(popupModel);
77
78
  var visible = popupModel.state.visibility !== 'hidden';
78
79
  return {
79
80
  /** Mix these properties into the target element. **Must be an Element** */
@@ -1,10 +1,15 @@
1
1
  import * as React from 'react';
2
2
  import {space} from '@workday/canvas-kit-react/tokens';
3
- import {GrowthBehavior, ErrorType, styled, Themeable} from '@workday/canvas-kit-react/common';
3
+ import {
4
+ GrowthBehavior,
5
+ ErrorType,
6
+ styled,
7
+ Themeable,
8
+ generateUniqueId,
9
+ } from '@workday/canvas-kit-react/common';
4
10
  import Hint from './Hint';
5
11
  import Label from './Label';
6
12
  import {FormFieldLabelPosition, FormFieldLabelPositionBehavior} from './types';
7
- import uuid from 'uuid/v4';
8
13
 
9
14
  export interface FormFieldProps
10
15
  extends Themeable,
@@ -135,7 +140,7 @@ class FormField extends React.Component<FormFieldProps> {
135
140
  static LabelPosition = FormFieldLabelPosition;
136
141
  static ErrorType = ErrorType;
137
142
 
138
- private inputId: string = this.props.inputId || uuid();
143
+ private inputId: string = this.props.inputId || generateUniqueId();
139
144
 
140
145
  private renderChildren = (child: React.ReactNode): React.ReactNode => {
141
146
  if (React.isValidElement(child)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workday/canvas-kit-react",
3
- "version": "6.1.5",
3
+ "version": "6.3.0-next.0+6e10a940",
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
  "@emotion/styled": "^10.0.27",
58
58
  "@popperjs/core": "^2.5.4",
59
59
  "@workday/canvas-colors-web": "^2.0.0",
60
- "@workday/canvas-kit-labs-react": "^6.1.5",
61
- "@workday/canvas-kit-popup-stack": "^6.1.5",
62
- "@workday/canvas-kit-preview-react": "^6.1.5",
60
+ "@workday/canvas-kit-labs-react": "^6.3.0-next.0+6e10a940",
61
+ "@workday/canvas-kit-popup-stack": "^6.3.0-next.0+6e10a940",
62
+ "@workday/canvas-kit-preview-react": "^6.3.0-next.0+6e10a940",
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",
@@ -70,12 +70,12 @@
70
70
  "react-innertext": "^1.1.5",
71
71
  "resize-observer-polyfill": "^1.5.1",
72
72
  "rtl-css-js": "^1.14.1",
73
- "use-resize-observer": "~7.0.1",
74
- "uuid": "^3.3.3"
73
+ "screenfull": "^5.2.0",
74
+ "use-resize-observer": "~7.0.1"
75
75
  },
76
76
  "devDependencies": {
77
77
  "@workday/canvas-accent-icons-web": "^1.0.0",
78
78
  "@workday/canvas-applet-icons-web": "^0.17.50"
79
79
  },
80
- "gitHead": "33b9994408c63b78923a201af73d8c2e6f7e5914"
80
+ "gitHead": "6e10a940283828fb6e34b23598a917a478bbabd6"
81
81
  }
@@ -1,4 +1,5 @@
1
1
  // refactor for v5
2
+ /// <reference types="@types/node" />
2
3
 
3
4
  const candidateSelectors = [
4
5
  'input',
@@ -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,3 +16,5 @@ 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';
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+ import screenfull from 'screenfull';
3
+
4
+ import {PopupModel} from './usePopupModel';
5
+
6
+ /**
7
+ * Closes the popup when fullscreen is exited. Entering/exiting fullscreen changes the context of
8
+ * the entire screen. This should be added to popup types that are very context sensitive like
9
+ * Tooltips.
10
+ */
11
+ export const useCloseOnFullscreenExit = (model: PopupModel, elemProps = {}) => {
12
+ const handler = React.useCallback(
13
+ event => {
14
+ if (!screenfull.isFullscreen) {
15
+ model.events.hide({event});
16
+ }
17
+ },
18
+ [model.events]
19
+ );
20
+
21
+ const visible = model.state.visibility !== 'hidden';
22
+
23
+ React.useEffect(() => {
24
+ if (!visible) {
25
+ return;
26
+ }
27
+ if (screenfull.isEnabled) {
28
+ screenfull.on('change', handler);
29
+ return () => {
30
+ screenfull.off('change', handler);
31
+ };
32
+ }
33
+ return;
34
+ }, [handler, visible]);
35
+
36
+ return elemProps;
37
+ };
@@ -64,8 +64,9 @@ export const usePopupStack = <E extends HTMLElement>(
64
64
  ? target.current || undefined
65
65
  : target
66
66
  : undefined;
67
- PopupStack.add({element: localRef.current!, owner: targetEl});
68
67
  const element = localRef.current!;
68
+
69
+ PopupStack.add({element: element, owner: targetEl});
69
70
  return () => {
70
71
  PopupStack.remove(element);
71
72
  };