@workday/canvas-kit-react 8.0.0-alpha.151-next.3 → 8.0.0-alpha.153-next.5

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.
@@ -11,24 +11,24 @@ type Modality = 'mouse' | 'touch' | 'pen';
11
11
  // a. if localStorage isn't primed, use clientWidth of the browsers
12
12
  // b. if < 768, default to 'touch'
13
13
  // c. else default to 'mouse'
14
- const localStorageValue = 'mouse' as Modality; //((typeof localStorage !== 'undefined'
15
- // ? localStorage.getItem('modality')
16
- // : '') ||
17
- // (typeof document !== 'undefined'
18
- // ? document.documentElement.clientWidth < 768
19
- // ? 'touch'
20
- // : ''
21
- // : '') ||
22
- // 'mouse') as Modality;
14
+ let localStorageValue = ((typeof localStorage !== 'undefined'
15
+ ? localStorage.getItem('modality')
16
+ : '') ||
17
+ (typeof document !== 'undefined'
18
+ ? document.documentElement.clientWidth < 768
19
+ ? 'touch'
20
+ : ''
21
+ : '') ||
22
+ 'mouse') as Modality;
23
23
 
24
24
  // Update the `localStorageValue`, but conditionally update localStorage only if the value has
25
25
  // changed. This prevents too many calls to `localStorage` which can be costly on spinning disk
26
26
  // drives
27
27
  const updateLocalStorage = (value: Modality) => {
28
- // if (localStorageValue !== value) {
29
- // localStorage.setItem('modality', value);
30
- // }
31
- // localStorageValue = value;
28
+ if (localStorageValue !== value) {
29
+ localStorage.setItem('modality', value);
30
+ }
31
+ localStorageValue = value;
32
32
  };
33
33
 
34
34
  /**
@@ -14,23 +14,23 @@ var react_1 = __importDefault(require("react"));
14
14
  // a. if localStorage isn't primed, use clientWidth of the browsers
15
15
  // b. if < 768, default to 'touch'
16
16
  // c. else default to 'mouse'
17
- var localStorageValue = 'mouse'; //((typeof localStorage !== 'undefined'
18
- // ? localStorage.getItem('modality')
19
- // : '') ||
20
- // (typeof document !== 'undefined'
21
- // ? document.documentElement.clientWidth < 768
22
- // ? 'touch'
23
- // : ''
24
- // : '') ||
25
- // 'mouse') as Modality;
17
+ var localStorageValue = ((typeof localStorage !== 'undefined'
18
+ ? localStorage.getItem('modality')
19
+ : '') ||
20
+ (typeof document !== 'undefined'
21
+ ? document.documentElement.clientWidth < 768
22
+ ? 'touch'
23
+ : ''
24
+ : '') ||
25
+ 'mouse');
26
26
  // Update the `localStorageValue`, but conditionally update localStorage only if the value has
27
27
  // changed. This prevents too many calls to `localStorage` which can be costly on spinning disk
28
28
  // drives
29
29
  var updateLocalStorage = function (value) {
30
- // if (localStorageValue !== value) {
31
- // localStorage.setItem('modality', value);
32
- // }
33
- // localStorageValue = value;
30
+ if (localStorageValue !== value) {
31
+ localStorage.setItem('modality', value);
32
+ }
33
+ localStorageValue = value;
34
34
  };
35
35
  /**
36
36
  * Uses heuristics to determine if the user is on a touch device, uses a pen, or a mouse. This hook
@@ -1 +1 @@
1
- {"version":3,"file":"ModalCard.d.ts","sourceRoot":"","sources":["../../../../modal/lib/ModalCard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAqB,YAAY,EAAC,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAC,KAAK,EAAC,MAAM,iCAAiC,CAAC;AAItD,MAAM,WAAW,cAAe,SAAQ,YAAY,CAAC,OAAO,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC;CAAG;AAEjF,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;EAQpB,CAAC"}
1
+ {"version":3,"file":"ModalCard.d.ts","sourceRoot":"","sources":["../../../../modal/lib/ModalCard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAEL,YAAY,EAGb,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAAC,KAAK,EAAC,MAAM,iCAAiC,CAAC;AAItD,MAAM,WAAW,cAAe,SAAQ,YAAY,CAAC,OAAO,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC;CAAG;AAWjF,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;EAMpB,CAAC"}
@@ -33,12 +33,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
33
33
  exports.ModalCard = void 0;
34
34
  var React = __importStar(require("react"));
35
35
  var common_1 = require("@workday/canvas-kit-react/common");
36
+ var tokens_1 = require("@workday/canvas-kit-react/tokens");
36
37
  var popup_1 = require("@workday/canvas-kit-react/popup");
37
38
  var hooks_1 = require("./hooks");
39
+ var ResponsiveModalCard = common_1.styled(popup_1.Popup.Card)(function (_a) {
40
+ var _b;
41
+ var theme = _a.theme;
42
+ return (_b = {
43
+ margin: tokens_1.space.xl,
44
+ padding: tokens_1.space.l
45
+ },
46
+ _b[theme.canvas.breakpoints.down('s')] = {
47
+ margin: "0 0 " + tokens_1.space.xl,
48
+ padding: tokens_1.space.m,
49
+ },
50
+ _b);
51
+ });
38
52
  exports.ModalCard = common_1.createSubcomponent('div')({
39
53
  displayName: 'Modal.Card',
40
54
  modelHook: hooks_1.useModalModel,
41
55
  elemPropsHook: hooks_1.useModalCard,
42
56
  })(function (elemProps, Element) {
43
- return (React.createElement(popup_1.Popup.Card, __assign({ as: Element, width: 440, borderWidth: 0, margin: "xl", depth: 6 }, elemProps)));
57
+ return React.createElement(ResponsiveModalCard, __assign({ as: Element, width: 440, borderWidth: 0, depth: 6 }, elemProps));
44
58
  });
@@ -1 +1 @@
1
- {"version":3,"file":"ModalOverlay.d.ts","sourceRoot":"","sources":["../../../../modal/lib/ModalOverlay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAa1B,OAAO,EAAM,QAAQ,EAAC,MAAM,kCAAkC,CAAC;AAG/D,MAAM,WAAW,iBAAkB,SAAQ,QAAQ;CAAG;AA+CtD,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;EAOvB,CAAC;AAEH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;OAQ1B,CAAC"}
1
+ {"version":3,"file":"ModalOverlay.d.ts","sourceRoot":"","sources":["../../../../modal/lib/ModalOverlay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAa1B,OAAO,EAAM,QAAQ,EAAC,MAAM,kCAAkC,CAAC;AAG/D,MAAM,WAAW,iBAAkB,SAAQ,QAAQ;CAAG;AAiDtD,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;EAOvB,CAAC;AAEH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;OAQ1B,CAAC"}
@@ -46,20 +46,28 @@ var Container = styled_1.default(layout_1.Box)({
46
46
  // positioning, but seems to when using flexbox centering. This messes up Popper calculations inside
47
47
  // the Modal. The centering container forces a "center" pixel calculation by making sure the width
48
48
  // is always an even number
49
- var CenteringContainer = styled_1.default('div')({
50
- maxHeight: '100vh',
51
- display: 'flex',
52
- position: 'absolute',
53
- left: 0,
54
- top: 0,
55
- alignItems: 'center',
56
- justifyContent: 'center',
57
- // IE11 fix for setting min-height in a flex container
58
- ':before': {
59
- display: 'block',
60
- content: "''",
61
- height: '100vh',
62
- },
49
+ var ResponsiveContainer = styled_1.default('div')(function (_a) {
50
+ var _b;
51
+ var theme = _a.theme;
52
+ return (_b = {
53
+ maxHeight: '100vh',
54
+ display: 'flex',
55
+ position: 'absolute',
56
+ left: 0,
57
+ top: 0,
58
+ justifyContent: 'center',
59
+ alignItems: 'center',
60
+ // IE11 fix for setting min-height in a flex container
61
+ ':before': {
62
+ display: 'block',
63
+ content: "''",
64
+ height: '100vh',
65
+ }
66
+ },
67
+ _b[theme.canvas.breakpoints.down('s')] = {
68
+ alignItems: 'end',
69
+ },
70
+ _b);
63
71
  });
64
72
  exports.ModalOverlay = common_1.createSubcomponent('div')({
65
73
  displayName: 'Modal.Overlay',
@@ -83,13 +91,15 @@ var OpenModalOverlay = common_1.createSubcomponent('div')({
83
91
  })(function (elemProps, Element, model) {
84
92
  var windowSize = common_1.useWindowSize();
85
93
  var content = (react_1.default.createElement(Container, __assign({ as: Element }, elemProps),
86
- react_1.default.createElement(CenteringContainer
94
+ react_1.default.createElement(ResponsiveContainer
87
95
  // make sure the centering container is an even number of pixels to avoid sub-pixel
88
96
  // inaccuracies due to centering
89
97
  , {
90
98
  // make sure the centering container is an even number of pixels to avoid sub-pixel
91
99
  // inaccuracies due to centering
92
- style: { width: windowSize.width % 2 === 1 ? 'calc(100vw - 1px)' : '100vw' } }, elemProps.children)));
100
+ style: {
101
+ width: windowSize.width % 2 === 1 ? 'calc(100vw - 1px)' : '100vw',
102
+ } }, elemProps.children)));
93
103
  // only render something on the client
94
104
  if (typeof window !== 'undefined') {
95
105
  return react_dom_1.default.createPortal(content, model.state.stackRef.current);
@@ -1 +1 @@
1
- {"version":3,"file":"useCloseOnOverlayClick.d.ts","sourceRoot":"","sources":["../../../../../modal/lib/hooks/useCloseOnOverlayClick.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B;;;;GAIG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;OA8CjC,CAAC"}
1
+ {"version":3,"file":"useCloseOnOverlayClick.d.ts","sourceRoot":"","sources":["../../../../../modal/lib/hooks/useCloseOnOverlayClick.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B;;;;GAIG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;OAgDjC,CAAC"}
@@ -14,6 +14,7 @@ var popup_1 = require("@workday/canvas-kit-react/popup");
14
14
  * and `useCloseOnOverlayClick` is the Overlay is a child of a `stackRef` element and has a different
15
15
  */
16
16
  exports.useCloseOnOverlayClick = common_1.createElemPropsHook(popup_1.usePopupModel)(function (model) {
17
+ var modality = common_1.useModalityType();
17
18
  var onClick = react_1.default.useCallback(function (event) {
18
19
  if (!model.state.stackRef.current) {
19
20
  return;
@@ -30,12 +31,13 @@ exports.useCloseOnOverlayClick = common_1.createElemPropsHook(popup_1.usePopupMo
30
31
  element = (element === null || element === void 0 ? void 0 : element.parentElement) || null;
31
32
  }
32
33
  if (dialog &&
34
+ modality !== 'touch' &&
33
35
  elements.length &&
34
36
  elements[elements.length - 1] === model.state.stackRef.current &&
35
37
  elementsBetweenDialogAnBody.some(function (element) { return element === event.target; })) {
36
38
  model.events.hide(event);
37
39
  }
38
- }, [model.state.stackRef, model.events]);
40
+ }, [model.state.stackRef, model.events, modality]);
39
41
  var visible = model.state.visibility !== 'hidden';
40
42
  react_1.default.useLayoutEffect(function () {
41
43
  var _a;
@@ -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,EAKL,YAAY,EAGb,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAQ,eAAe,EAAC,MAAM,kCAAkC,CAAC;AAKxE,MAAM,WAAW,cAAe,SAAQ,YAAY,CAAC,OAAO,IAAI,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC;IAChG,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAmCD,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;EAiCpB,CAAC"}
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,EAKL,YAAY,EAGb,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAQ,eAAe,EAAC,MAAM,kCAAkC,CAAC;AAKxE,MAAM,WAAW,cAAe,SAAQ,YAAY,CAAC,OAAO,IAAI,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC;IAChG,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AA0CD,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;EAiCpB,CAAC"}
@@ -59,20 +59,28 @@ var popupAnimation = function (transformOrigin) {
59
59
  return react_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);
60
60
  };
61
61
  var StyledPopupCard = common_1.styled(card_1.Card)(function (_a) {
62
- var transformOrigin = _a.transformOrigin;
62
+ var _b;
63
+ var transformOrigin = _a.transformOrigin, theme = _a.theme;
63
64
  if (transformOrigin == null) {
64
65
  return {};
65
66
  }
66
- return {
67
- animation: popupAnimation(transformOrigin),
68
- animationDuration: '150ms',
69
- animationTimingFunction: 'ease-out',
70
- transformOrigin: transformOrigin.vertical + " " + transformOrigin.horizontal,
67
+ return _b = {
68
+ animation: popupAnimation(transformOrigin),
69
+ animationDuration: '150ms',
70
+ animationTimingFunction: 'ease-out',
71
+ transformOrigin: transformOrigin.vertical + " " + transformOrigin.horizontal
72
+ },
73
+ _b[theme.canvas.breakpoints.down('s')] = {
74
+ animation: popupAnimation({ vertical: 'bottom', horizontal: 'center' }),
75
+ animationDuration: '150ms',
76
+ animationTimingFunction: 'ease-out',
77
+ transformOrigin: 'bottom center',
78
+ },
71
79
  // Allow overriding of animation in special cases
72
- '.wd-no-animation &': {
80
+ _b['.wd-no-animation &'] = {
73
81
  animation: 'none',
74
82
  },
75
- };
83
+ _b;
76
84
  });
77
85
  exports.PopupCard = common_1.createSubcomponent('div')({
78
86
  displayName: 'Popup.Card',
@@ -8,23 +8,23 @@ import React from 'react';
8
8
  // a. if localStorage isn't primed, use clientWidth of the browsers
9
9
  // b. if < 768, default to 'touch'
10
10
  // c. else default to 'mouse'
11
- var localStorageValue = 'mouse'; //((typeof localStorage !== 'undefined'
12
- // ? localStorage.getItem('modality')
13
- // : '') ||
14
- // (typeof document !== 'undefined'
15
- // ? document.documentElement.clientWidth < 768
16
- // ? 'touch'
17
- // : ''
18
- // : '') ||
19
- // 'mouse') as Modality;
11
+ var localStorageValue = ((typeof localStorage !== 'undefined'
12
+ ? localStorage.getItem('modality')
13
+ : '') ||
14
+ (typeof document !== 'undefined'
15
+ ? document.documentElement.clientWidth < 768
16
+ ? 'touch'
17
+ : ''
18
+ : '') ||
19
+ 'mouse');
20
20
  // Update the `localStorageValue`, but conditionally update localStorage only if the value has
21
21
  // changed. This prevents too many calls to `localStorage` which can be costly on spinning disk
22
22
  // drives
23
23
  var updateLocalStorage = function (value) {
24
- // if (localStorageValue !== value) {
25
- // localStorage.setItem('modality', value);
26
- // }
27
- // localStorageValue = value;
24
+ if (localStorageValue !== value) {
25
+ localStorage.setItem('modality', value);
26
+ }
27
+ localStorageValue = value;
28
28
  };
29
29
  /**
30
30
  * Uses heuristics to determine if the user is on a touch device, uses a pen, or a mouse. This hook
@@ -1 +1 @@
1
- {"version":3,"file":"ModalCard.d.ts","sourceRoot":"","sources":["../../../../modal/lib/ModalCard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAqB,YAAY,EAAC,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAC,KAAK,EAAC,MAAM,iCAAiC,CAAC;AAItD,MAAM,WAAW,cAAe,SAAQ,YAAY,CAAC,OAAO,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC;CAAG;AAEjF,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;EAQpB,CAAC"}
1
+ {"version":3,"file":"ModalCard.d.ts","sourceRoot":"","sources":["../../../../modal/lib/ModalCard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAEL,YAAY,EAGb,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAAC,KAAK,EAAC,MAAM,iCAAiC,CAAC;AAItD,MAAM,WAAW,cAAe,SAAQ,YAAY,CAAC,OAAO,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC;CAAG;AAWjF,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;EAMpB,CAAC"}
@@ -10,13 +10,27 @@ var __assign = (this && this.__assign) || function () {
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
12
  import * as React from 'react';
13
- import { createSubcomponent } from '@workday/canvas-kit-react/common';
13
+ import { createSubcomponent, styled, } from '@workday/canvas-kit-react/common';
14
+ import { space } from '@workday/canvas-kit-react/tokens';
14
15
  import { Popup } from '@workday/canvas-kit-react/popup';
15
16
  import { useModalCard, useModalModel } from './hooks';
17
+ var ResponsiveModalCard = styled(Popup.Card)(function (_a) {
18
+ var _b;
19
+ var theme = _a.theme;
20
+ return (_b = {
21
+ margin: space.xl,
22
+ padding: space.l
23
+ },
24
+ _b[theme.canvas.breakpoints.down('s')] = {
25
+ margin: "0 0 " + space.xl,
26
+ padding: space.m,
27
+ },
28
+ _b);
29
+ });
16
30
  export var ModalCard = createSubcomponent('div')({
17
31
  displayName: 'Modal.Card',
18
32
  modelHook: useModalModel,
19
33
  elemPropsHook: useModalCard,
20
34
  })(function (elemProps, Element) {
21
- return (React.createElement(Popup.Card, __assign({ as: Element, width: 440, borderWidth: 0, margin: "xl", depth: 6 }, elemProps)));
35
+ return React.createElement(ResponsiveModalCard, __assign({ as: Element, width: 440, borderWidth: 0, depth: 6 }, elemProps));
22
36
  });
@@ -1 +1 @@
1
- {"version":3,"file":"ModalOverlay.d.ts","sourceRoot":"","sources":["../../../../modal/lib/ModalOverlay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAa1B,OAAO,EAAM,QAAQ,EAAC,MAAM,kCAAkC,CAAC;AAG/D,MAAM,WAAW,iBAAkB,SAAQ,QAAQ;CAAG;AA+CtD,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;EAOvB,CAAC;AAEH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;OAQ1B,CAAC"}
1
+ {"version":3,"file":"ModalOverlay.d.ts","sourceRoot":"","sources":["../../../../modal/lib/ModalOverlay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAa1B,OAAO,EAAM,QAAQ,EAAC,MAAM,kCAAkC,CAAC;AAG/D,MAAM,WAAW,iBAAkB,SAAQ,QAAQ;CAAG;AAiDtD,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;EAOvB,CAAC;AAEH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;OAQ1B,CAAC"}
@@ -40,20 +40,28 @@ var Container = styled(Box)({
40
40
  // positioning, but seems to when using flexbox centering. This messes up Popper calculations inside
41
41
  // the Modal. The centering container forces a "center" pixel calculation by making sure the width
42
42
  // is always an even number
43
- var CenteringContainer = styled('div')({
44
- maxHeight: '100vh',
45
- display: 'flex',
46
- position: 'absolute',
47
- left: 0,
48
- top: 0,
49
- alignItems: 'center',
50
- justifyContent: 'center',
51
- // IE11 fix for setting min-height in a flex container
52
- ':before': {
53
- display: 'block',
54
- content: "''",
55
- height: '100vh',
56
- },
43
+ var ResponsiveContainer = styled('div')(function (_a) {
44
+ var _b;
45
+ var theme = _a.theme;
46
+ return (_b = {
47
+ maxHeight: '100vh',
48
+ display: 'flex',
49
+ position: 'absolute',
50
+ left: 0,
51
+ top: 0,
52
+ justifyContent: 'center',
53
+ alignItems: 'center',
54
+ // IE11 fix for setting min-height in a flex container
55
+ ':before': {
56
+ display: 'block',
57
+ content: "''",
58
+ height: '100vh',
59
+ }
60
+ },
61
+ _b[theme.canvas.breakpoints.down('s')] = {
62
+ alignItems: 'end',
63
+ },
64
+ _b);
57
65
  });
58
66
  export var ModalOverlay = createSubcomponent('div')({
59
67
  displayName: 'Modal.Overlay',
@@ -77,13 +85,15 @@ var OpenModalOverlay = createSubcomponent('div')({
77
85
  })(function (elemProps, Element, model) {
78
86
  var windowSize = useWindowSize();
79
87
  var content = (React.createElement(Container, __assign({ as: Element }, elemProps),
80
- React.createElement(CenteringContainer
88
+ React.createElement(ResponsiveContainer
81
89
  // make sure the centering container is an even number of pixels to avoid sub-pixel
82
90
  // inaccuracies due to centering
83
91
  , {
84
92
  // make sure the centering container is an even number of pixels to avoid sub-pixel
85
93
  // inaccuracies due to centering
86
- style: { width: windowSize.width % 2 === 1 ? 'calc(100vw - 1px)' : '100vw' } }, elemProps.children)));
94
+ style: {
95
+ width: windowSize.width % 2 === 1 ? 'calc(100vw - 1px)' : '100vw',
96
+ } }, elemProps.children)));
87
97
  // only render something on the client
88
98
  if (typeof window !== 'undefined') {
89
99
  return ReactDOM.createPortal(content, model.state.stackRef.current);
@@ -1 +1 @@
1
- {"version":3,"file":"useCloseOnOverlayClick.d.ts","sourceRoot":"","sources":["../../../../../modal/lib/hooks/useCloseOnOverlayClick.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B;;;;GAIG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;OA8CjC,CAAC"}
1
+ {"version":3,"file":"useCloseOnOverlayClick.d.ts","sourceRoot":"","sources":["../../../../../modal/lib/hooks/useCloseOnOverlayClick.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B;;;;GAIG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;OAgDjC,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { PopupStack } from '@workday/canvas-kit-popup-stack';
3
- import { createElemPropsHook } from '@workday/canvas-kit-react/common';
3
+ import { createElemPropsHook, useModalityType } from '@workday/canvas-kit-react/common';
4
4
  import { usePopupModel } from '@workday/canvas-kit-react/popup';
5
5
  /**
6
6
  * Registers global listener for all clicks. It will only call the PopupModel's `hide` event if the
@@ -8,6 +8,7 @@ import { usePopupModel } from '@workday/canvas-kit-react/popup';
8
8
  * and `useCloseOnOverlayClick` is the Overlay is a child of a `stackRef` element and has a different
9
9
  */
10
10
  export var useCloseOnOverlayClick = createElemPropsHook(usePopupModel)(function (model) {
11
+ var modality = useModalityType();
11
12
  var onClick = React.useCallback(function (event) {
12
13
  if (!model.state.stackRef.current) {
13
14
  return;
@@ -24,12 +25,13 @@ export var useCloseOnOverlayClick = createElemPropsHook(usePopupModel)(function
24
25
  element = (element === null || element === void 0 ? void 0 : element.parentElement) || null;
25
26
  }
26
27
  if (dialog &&
28
+ modality !== 'touch' &&
27
29
  elements.length &&
28
30
  elements[elements.length - 1] === model.state.stackRef.current &&
29
31
  elementsBetweenDialogAnBody.some(function (element) { return element === event.target; })) {
30
32
  model.events.hide(event);
31
33
  }
32
- }, [model.state.stackRef, model.events]);
34
+ }, [model.state.stackRef, model.events, modality]);
33
35
  var visible = model.state.visibility !== 'hidden';
34
36
  React.useLayoutEffect(function () {
35
37
  var _a;
@@ -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,EAKL,YAAY,EAGb,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAQ,eAAe,EAAC,MAAM,kCAAkC,CAAC;AAKxE,MAAM,WAAW,cAAe,SAAQ,YAAY,CAAC,OAAO,IAAI,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC;IAChG,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAmCD,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;EAiCpB,CAAC"}
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,EAKL,YAAY,EAGb,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAQ,eAAe,EAAC,MAAM,kCAAkC,CAAC;AAKxE,MAAM,WAAW,cAAe,SAAQ,YAAY,CAAC,OAAO,IAAI,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC;IAChG,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AA0CD,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;EAiCpB,CAAC"}
@@ -37,20 +37,28 @@ var popupAnimation = function (transformOrigin) {
37
37
  return 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);
38
38
  };
39
39
  var StyledPopupCard = styled(Card)(function (_a) {
40
- var transformOrigin = _a.transformOrigin;
40
+ var _b;
41
+ var transformOrigin = _a.transformOrigin, theme = _a.theme;
41
42
  if (transformOrigin == null) {
42
43
  return {};
43
44
  }
44
- return {
45
- animation: popupAnimation(transformOrigin),
46
- animationDuration: '150ms',
47
- animationTimingFunction: 'ease-out',
48
- transformOrigin: transformOrigin.vertical + " " + transformOrigin.horizontal,
45
+ return _b = {
46
+ animation: popupAnimation(transformOrigin),
47
+ animationDuration: '150ms',
48
+ animationTimingFunction: 'ease-out',
49
+ transformOrigin: transformOrigin.vertical + " " + transformOrigin.horizontal
50
+ },
51
+ _b[theme.canvas.breakpoints.down('s')] = {
52
+ animation: popupAnimation({ vertical: 'bottom', horizontal: 'center' }),
53
+ animationDuration: '150ms',
54
+ animationTimingFunction: 'ease-out',
55
+ transformOrigin: 'bottom center',
56
+ },
49
57
  // Allow overriding of animation in special cases
50
- '.wd-no-animation &': {
58
+ _b['.wd-no-animation &'] = {
51
59
  animation: 'none',
52
60
  },
53
- };
61
+ _b;
54
62
  });
55
63
  export var PopupCard = createSubcomponent('div')({
56
64
  displayName: 'Popup.Card',
@@ -1,18 +1,31 @@
1
1
  import * as React from 'react';
2
2
 
3
- import {createSubcomponent, ExtractProps} from '@workday/canvas-kit-react/common';
3
+ import {
4
+ createSubcomponent,
5
+ ExtractProps,
6
+ StyledType,
7
+ styled,
8
+ } from '@workday/canvas-kit-react/common';
9
+ import {space} from '@workday/canvas-kit-react/tokens';
4
10
  import {Popup} from '@workday/canvas-kit-react/popup';
5
11
 
6
12
  import {useModalCard, useModalModel} from './hooks';
7
13
 
8
14
  export interface ModalCardProps extends ExtractProps<typeof Popup.Card, never> {}
9
15
 
16
+ const ResponsiveModalCard = styled(Popup.Card)<ModalCardProps & StyledType>(({theme}) => ({
17
+ margin: space.xl,
18
+ padding: space.l,
19
+ [theme.canvas.breakpoints.down('s')]: {
20
+ margin: `0 0 ${space.xl}`,
21
+ padding: space.m,
22
+ },
23
+ }));
24
+
10
25
  export const ModalCard = createSubcomponent('div')({
11
26
  displayName: 'Modal.Card',
12
27
  modelHook: useModalModel,
13
28
  elemPropsHook: useModalCard,
14
29
  })<ModalCardProps>((elemProps, Element) => {
15
- return (
16
- <Popup.Card as={Element} width={440} borderWidth={0} margin="xl" depth={6} {...elemProps} />
17
- );
30
+ return <ResponsiveModalCard as={Element} width={440} borderWidth={0} depth={6} {...elemProps} />;
18
31
  });
@@ -44,22 +44,24 @@ const Container = styled(Box)<StyledType>({
44
44
  // positioning, but seems to when using flexbox centering. This messes up Popper calculations inside
45
45
  // the Modal. The centering container forces a "center" pixel calculation by making sure the width
46
46
  // is always an even number
47
- const CenteringContainer = styled('div')({
47
+ const ResponsiveContainer = styled('div')(({theme}) => ({
48
48
  maxHeight: '100vh',
49
49
  display: 'flex',
50
50
  position: 'absolute',
51
51
  left: 0,
52
52
  top: 0,
53
- alignItems: 'center',
54
53
  justifyContent: 'center',
55
-
54
+ alignItems: 'center',
56
55
  // IE11 fix for setting min-height in a flex container
57
56
  ':before': {
58
57
  display: 'block',
59
58
  content: "''",
60
59
  height: '100vh',
61
60
  },
62
- });
61
+ [theme.canvas.breakpoints.down('s')]: {
62
+ alignItems: 'end',
63
+ },
64
+ }));
63
65
 
64
66
  export const ModalOverlay = createSubcomponent('div')({
65
67
  displayName: 'Modal.Overlay',
@@ -86,16 +88,17 @@ const OpenModalOverlay = createSubcomponent('div')({
86
88
  elemPropsHook: useModalOverlay,
87
89
  })<ModalOverlayProps>((elemProps, Element, model) => {
88
90
  const windowSize = useWindowSize();
89
-
90
91
  const content = (
91
92
  <Container as={Element} {...elemProps}>
92
- <CenteringContainer
93
+ <ResponsiveContainer
93
94
  // make sure the centering container is an even number of pixels to avoid sub-pixel
94
95
  // inaccuracies due to centering
95
- style={{width: windowSize.width % 2 === 1 ? 'calc(100vw - 1px)' : '100vw'}}
96
+ style={{
97
+ width: windowSize.width % 2 === 1 ? 'calc(100vw - 1px)' : '100vw',
98
+ }}
96
99
  >
97
100
  {elemProps.children}
98
- </CenteringContainer>
101
+ </ResponsiveContainer>
99
102
  </Container>
100
103
  );
101
104
 
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
 
3
3
  import {PopupStack} from '@workday/canvas-kit-popup-stack';
4
- import {createElemPropsHook} from '@workday/canvas-kit-react/common';
4
+ import {createElemPropsHook, useModalityType} from '@workday/canvas-kit-react/common';
5
5
  import {usePopupModel} from '@workday/canvas-kit-react/popup';
6
6
 
7
7
  /**
@@ -10,6 +10,7 @@ import {usePopupModel} from '@workday/canvas-kit-react/popup';
10
10
  * and `useCloseOnOverlayClick` is the Overlay is a child of a `stackRef` element and has a different
11
11
  */
12
12
  export const useCloseOnOverlayClick = createElemPropsHook(usePopupModel)(model => {
13
+ const modality = useModalityType();
13
14
  const onClick = React.useCallback(
14
15
  (event: MouseEvent) => {
15
16
  if (!model.state.stackRef.current) {
@@ -30,6 +31,7 @@ export const useCloseOnOverlayClick = createElemPropsHook(usePopupModel)(model =
30
31
 
31
32
  if (
32
33
  dialog &&
34
+ modality !== 'touch' &&
33
35
  elements.length &&
34
36
  elements[elements.length - 1] === model.state.stackRef.current &&
35
37
  elementsBetweenDialogAnBody.some(element => element === event.target)
@@ -37,7 +39,7 @@ export const useCloseOnOverlayClick = createElemPropsHook(usePopupModel)(model =
37
39
  model.events.hide(event);
38
40
  }
39
41
  },
40
- [model.state.stackRef, model.events]
42
+ [model.state.stackRef, model.events, modality]
41
43
  );
42
44
 
43
45
  const visible = model.state.visibility !== 'hidden';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workday/canvas-kit-react",
3
- "version": "8.0.0-alpha.151-next.3+548c0a40",
3
+ "version": "8.0.0-alpha.153-next.5+e2311293",
4
4
  "description": "The parent module that contains all Workday Canvas Kit React components",
5
5
  "author": "Workday, Inc. (https://www.workday.com)",
6
6
  "license": "Apache-2.0",
@@ -49,9 +49,9 @@
49
49
  "@emotion/styled": "^11.6.0",
50
50
  "@popperjs/core": "^2.5.4",
51
51
  "@workday/canvas-colors-web": "^2.0.0",
52
- "@workday/canvas-kit-labs-react": "^8.0.0-alpha.151-next.3+548c0a40",
53
- "@workday/canvas-kit-popup-stack": "^8.0.0-alpha.151-next.3+548c0a40",
54
- "@workday/canvas-kit-preview-react": "^8.0.0-alpha.151-next.3+548c0a40",
52
+ "@workday/canvas-kit-labs-react": "^8.0.0-alpha.153-next.5+e2311293",
53
+ "@workday/canvas-kit-popup-stack": "^8.0.0-alpha.153-next.5+e2311293",
54
+ "@workday/canvas-kit-preview-react": "^8.0.0-alpha.153-next.5+e2311293",
55
55
  "@workday/canvas-system-icons-web": "^3.0.0",
56
56
  "@workday/design-assets-types": "^0.2.8",
57
57
  "chroma-js": "^2.1.0",
@@ -70,5 +70,5 @@
70
70
  "@workday/canvas-accent-icons-web": "^3.0.0",
71
71
  "@workday/canvas-applet-icons-web": "^2.0.0"
72
72
  },
73
- "gitHead": "548c0a4090f25b1feeabaf1c1288fec4539e7d0a"
73
+ "gitHead": "e23112938a59c4ba7993592f072ef524077ad111"
74
74
  }
@@ -38,15 +38,22 @@ const popupAnimation = (transformOrigin: TransformOrigin) => {
38
38
 
39
39
  const StyledPopupCard = styled(Card)<
40
40
  StyledType & {width?: number | string; transformOrigin?: TransformOrigin}
41
- >(({transformOrigin}) => {
41
+ >(({transformOrigin, theme}) => {
42
42
  if (transformOrigin == null) {
43
43
  return {};
44
44
  }
45
+
45
46
  return {
46
47
  animation: popupAnimation(transformOrigin),
47
48
  animationDuration: '150ms',
48
49
  animationTimingFunction: 'ease-out',
49
50
  transformOrigin: `${transformOrigin.vertical} ${transformOrigin.horizontal}`,
51
+ [theme.canvas.breakpoints.down('s')]: {
52
+ animation: popupAnimation({vertical: 'bottom', horizontal: 'center'}),
53
+ animationDuration: '150ms',
54
+ animationTimingFunction: 'ease-out',
55
+ transformOrigin: 'bottom center',
56
+ },
50
57
  // Allow overriding of animation in special cases
51
58
  '.wd-no-animation &': {
52
59
  animation: 'none',