@muraldevkit/ui-toolkit 4.70.2 → 4.70.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,6 +3,7 @@
3
3
  var _rollupPluginBabelHelpers = require('../../../../_virtual/_rollupPluginBabelHelpers.js');
4
4
  var React = require('react');
5
5
  var Select = require('react-select');
6
+ var useMenuEscapeContainment = require('../utils/useMenuEscapeContainment.js');
6
7
 
7
8
  function _interopNamespace(e) {
8
9
  if (e && e.__esModule) return e;
@@ -27,13 +28,17 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
27
28
  /**
28
29
  * MrlSelectContainer component
29
30
  *
31
+ * Adds `data-qa` support and keeps the `Escape` press that dismisses an open menu
32
+ * from also closing an outer dismissible surface (e.g. a select inside MrlModal).
33
+ *
30
34
  * @param props - the react-select container props
31
35
  * @returns a select container
32
36
  */
33
37
  function MrlSelectContainer(props) {
34
38
  var dataQa = props.selectProps['data-qa'];
39
+ var escapeContainment = useMenuEscapeContainment.useMenuEscapeContainment(props.selectProps.menuIsOpen, props.innerProps.onKeyDown);
35
40
  return /*#__PURE__*/React__namespace.createElement(Select.components.SelectContainer, _rollupPluginBabelHelpers.extends({}, props, {
36
- innerProps: _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, props.innerProps), dataQa && {
41
+ innerProps: _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, props.innerProps), escapeContainment), dataQa && {
37
42
  'data-qa': "".concat(dataQa, "-container")
38
43
  })
39
44
  }));
@@ -1 +1 @@
1
- {"version":3,"file":"MrlSelectContainer.js","sources":["../../../../../../src/components/form/select/components/MrlSelectContainer.tsx"],"sourcesContent":["import * as React from 'react';\nimport { GroupBase, components, ContainerProps } from 'react-select';\n\n/**\n * MrlSelectContainer component\n *\n * @param props - the react-select container props\n * @returns a select container\n */\nexport function MrlSelectContainer<\n\tT,\n\tIsMulti extends boolean = false,\n\tGroup extends GroupBase<T> = GroupBase<T>\n>(props: ContainerProps<T, IsMulti, Group>): JSX.Element {\n\tconst dataQa = props.selectProps['data-qa'];\n\treturn (\n\t\t<components.SelectContainer\n\t\t\t{...props}\n\t\t\tinnerProps={{\n\t\t\t\t...props.innerProps,\n\t\t\t\t...(dataQa && { 'data-qa': `${dataQa}-container` })\n\t\t\t}}\n\t\t/>\n\t);\n}\n"],"names":["MrlSelectContainer","props","dataQa","selectProps","React","createElement","components","SelectContainer","_extends","innerProps","_objectSpread","concat"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,kBAAkBA,CAIhCC,KAAwC,EAAe;AACxD,EAAA,IAAMC,MAAM,GAAGD,KAAK,CAACE,WAAW,CAAC,SAAS,CAAC;EAC3C,oBACCC,gBAAA,CAAAC,aAAA,CAACC,iBAAU,CAACC,eAAe,EAAAC,iCAAA,CAAA,EAAA,EACtBP,KAAK,EAAA;IACTQ,UAAU,EAAAC,uCAAA,CAAAA,uCAAA,CAAA,EAAA,EACNT,KAAK,CAACQ,UAAU,CAAA,EACfP,MAAM,IAAI;MAAE,SAAS,EAAA,EAAA,CAAAS,MAAA,CAAKT,MAAM,EAAA,YAAA;KAAc;AACjD,GAAA,CACF,CAAC;AAEJ;;;;"}
1
+ {"version":3,"file":"MrlSelectContainer.js","sources":["../../../../../../src/components/form/select/components/MrlSelectContainer.tsx"],"sourcesContent":["import * as React from 'react';\nimport { GroupBase, components, ContainerProps } from 'react-select';\nimport { useMenuEscapeContainment } from '../utils/useMenuEscapeContainment';\n\n/**\n * MrlSelectContainer component\n *\n * Adds `data-qa` support and keeps the `Escape` press that dismisses an open menu\n * from also closing an outer dismissible surface (e.g. a select inside MrlModal).\n *\n * @param props - the react-select container props\n * @returns a select container\n */\nexport function MrlSelectContainer<\n\tT,\n\tIsMulti extends boolean = false,\n\tGroup extends GroupBase<T> = GroupBase<T>\n>(props: ContainerProps<T, IsMulti, Group>): JSX.Element {\n\tconst dataQa = props.selectProps['data-qa'];\n\tconst escapeContainment = useMenuEscapeContainment(\n\t\tprops.selectProps.menuIsOpen,\n\t\tprops.innerProps.onKeyDown\n\t);\n\n\treturn (\n\t\t<components.SelectContainer\n\t\t\t{...props}\n\t\t\tinnerProps={{\n\t\t\t\t...props.innerProps,\n\t\t\t\t...escapeContainment,\n\t\t\t\t...(dataQa && { 'data-qa': `${dataQa}-container` })\n\t\t\t}}\n\t\t/>\n\t);\n}\n"],"names":["MrlSelectContainer","props","dataQa","selectProps","escapeContainment","useMenuEscapeContainment","menuIsOpen","innerProps","onKeyDown","React","createElement","components","SelectContainer","_extends","_objectSpread","concat"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,kBAAkBA,CAIhCC,KAAwC,EAAe;AACxD,EAAA,IAAMC,MAAM,GAAGD,KAAK,CAACE,WAAW,CAAC,SAAS,CAAC;AAC3C,EAAA,IAAMC,iBAAiB,GAAGC,iDAAwB,CACjDJ,KAAK,CAACE,WAAW,CAACG,UAAU,EAC5BL,KAAK,CAACM,UAAU,CAACC,SAClB,CAAC;EAED,oBACCC,gBAAA,CAAAC,aAAA,CAACC,iBAAU,CAACC,eAAe,EAAAC,iCAAA,CAAA,EAAA,EACtBZ,KAAK,EAAA;AACTM,IAAAA,UAAU,EAAAO,uCAAA,CAAAA,uCAAA,CAAAA,uCAAA,CAAA,EAAA,EACNb,KAAK,CAACM,UAAU,CAAA,EAChBH,iBAAiB,CAAA,EAChBF,MAAM,IAAI;MAAE,SAAS,EAAA,EAAA,CAAAa,MAAA,CAAKb,MAAM,EAAA,YAAA;KAAc;AACjD,GAAA,CACF,CAAC;AAEJ;;;;"}
@@ -0,0 +1,59 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+
5
+ function _interopNamespace(e) {
6
+ if (e && e.__esModule) return e;
7
+ var n = Object.create(null);
8
+ if (e) {
9
+ Object.keys(e).forEach(function (k) {
10
+ if (k !== 'default') {
11
+ var d = Object.getOwnPropertyDescriptor(e, k);
12
+ Object.defineProperty(n, k, d.get ? d : {
13
+ enumerable: true,
14
+ get: function () { return e[k]; }
15
+ });
16
+ }
17
+ });
18
+ }
19
+ n.default = e;
20
+ return Object.freeze(n);
21
+ }
22
+
23
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
24
+
25
+ /**
26
+ * Keeps the `Escape` press that dismisses an open select menu from reaching outer
27
+ * dismissible surfaces. MrlModal, MrlPanel and MrlPopover close on `Escape` keydown
28
+ * and MrlSidebar on keyup, so without containment a single press would close the
29
+ * menu and the surface behind it at the same time.
30
+ *
31
+ * While the menu is open, the `Escape` keydown and its paired keyup stop propagating
32
+ * after react-select handles them. Once the menu is closed, `Escape` bubbles as
33
+ * usual so the outer surface can respond to the next press.
34
+ *
35
+ * @param menuIsOpen - the resolved react-select menu state
36
+ * @param onKeyDown - react-select's container keydown handler to wrap
37
+ * @returns key event handlers to spread into the select container's `innerProps`
38
+ */
39
+ function useMenuEscapeContainment(menuIsOpen, onKeyDown) {
40
+ var escapeDismissedTheMenu = React__namespace.useRef(false);
41
+ var handleKeyDown = event => {
42
+ onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
43
+ if (event.key !== 'Escape') return;
44
+ escapeDismissedTheMenu.current = menuIsOpen;
45
+ if (menuIsOpen) event.stopPropagation();
46
+ };
47
+ var handleKeyUp = event => {
48
+ if (event.key !== 'Escape') return;
49
+ if (escapeDismissedTheMenu.current) event.stopPropagation();
50
+ escapeDismissedTheMenu.current = false;
51
+ };
52
+ return {
53
+ onKeyDown: handleKeyDown,
54
+ onKeyUp: handleKeyUp
55
+ };
56
+ }
57
+
58
+ exports.useMenuEscapeContainment = useMenuEscapeContainment;
59
+ //# sourceMappingURL=useMenuEscapeContainment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMenuEscapeContainment.js","sources":["../../../../../../src/components/form/select/utils/useMenuEscapeContainment.ts"],"sourcesContent":["import * as React from 'react';\n\ninterface MenuEscapeContainmentHandlers {\n\tonKeyDown: React.KeyboardEventHandler<HTMLDivElement>;\n\tonKeyUp: React.KeyboardEventHandler<HTMLDivElement>;\n}\n\n/**\n * Keeps the `Escape` press that dismisses an open select menu from reaching outer\n * dismissible surfaces. MrlModal, MrlPanel and MrlPopover close on `Escape` keydown\n * and MrlSidebar on keyup, so without containment a single press would close the\n * menu and the surface behind it at the same time.\n *\n * While the menu is open, the `Escape` keydown and its paired keyup stop propagating\n * after react-select handles them. Once the menu is closed, `Escape` bubbles as\n * usual so the outer surface can respond to the next press.\n *\n * @param menuIsOpen - the resolved react-select menu state\n * @param onKeyDown - react-select's container keydown handler to wrap\n * @returns key event handlers to spread into the select container's `innerProps`\n */\nexport function useMenuEscapeContainment(\n\tmenuIsOpen: boolean,\n\tonKeyDown: React.KeyboardEventHandler<HTMLDivElement> | undefined\n): MenuEscapeContainmentHandlers {\n\tconst escapeDismissedTheMenu = React.useRef(false);\n\n\tconst handleKeyDown: React.KeyboardEventHandler<HTMLDivElement> = (event) => {\n\t\tonKeyDown?.(event);\n\n\t\tif (event.key !== 'Escape') return;\n\n\t\tescapeDismissedTheMenu.current = menuIsOpen;\n\t\tif (menuIsOpen) event.stopPropagation();\n\t};\n\n\tconst handleKeyUp: React.KeyboardEventHandler<HTMLDivElement> = (event) => {\n\t\tif (event.key !== 'Escape') return;\n\n\t\tif (escapeDismissedTheMenu.current) event.stopPropagation();\n\t\tescapeDismissedTheMenu.current = false;\n\t};\n\n\treturn { onKeyDown: handleKeyDown, onKeyUp: handleKeyUp };\n}\n"],"names":["useMenuEscapeContainment","menuIsOpen","onKeyDown","escapeDismissedTheMenu","React","useRef","handleKeyDown","event","key","current","stopPropagation","handleKeyUp","onKeyUp"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,wBAAwBA,CACvCC,UAAmB,EACnBC,SAAiE,EACjC;AAChC,EAAA,IAAMC,sBAAsB,GAAGC,gBAAK,CAACC,MAAM,CAAC,KAAK,CAAC;EAElD,IAAMC,aAAyD,GAAIC,KAAK,IAAK;AAC5EL,IAAAA,SAAS,aAATA,SAAS,KAAA,MAAA,GAAA,MAAA,GAATA,SAAS,CAAGK,KAAK,CAAC;AAElB,IAAA,IAAIA,KAAK,CAACC,GAAG,KAAK,QAAQ,EAAE;IAE5BL,sBAAsB,CAACM,OAAO,GAAGR,UAAU;AAC3C,IAAA,IAAIA,UAAU,EAAEM,KAAK,CAACG,eAAe,EAAE;EACxC,CAAC;EAED,IAAMC,WAAuD,GAAIJ,KAAK,IAAK;AAC1E,IAAA,IAAIA,KAAK,CAACC,GAAG,KAAK,QAAQ,EAAE;IAE5B,IAAIL,sBAAsB,CAACM,OAAO,EAAEF,KAAK,CAACG,eAAe,EAAE;IAC3DP,sBAAsB,CAACM,OAAO,GAAG,KAAK;EACvC,CAAC;EAED,OAAO;AAAEP,IAAAA,SAAS,EAAEI,aAAa;AAAEM,IAAAA,OAAO,EAAED;GAAa;AAC1D;;;;"}
@@ -2,6 +2,9 @@ import { GroupBase, ContainerProps } from 'react-select';
2
2
  /**
3
3
  * MrlSelectContainer component
4
4
  *
5
+ * Adds `data-qa` support and keeps the `Escape` press that dismisses an open menu
6
+ * from also closing an outer dismissible surface (e.g. a select inside MrlModal).
7
+ *
5
8
  * @param props - the react-select container props
6
9
  * @returns a select container
7
10
  */
@@ -0,0 +1,21 @@
1
+ import * as React from 'react';
2
+ interface MenuEscapeContainmentHandlers {
3
+ onKeyDown: React.KeyboardEventHandler<HTMLDivElement>;
4
+ onKeyUp: React.KeyboardEventHandler<HTMLDivElement>;
5
+ }
6
+ /**
7
+ * Keeps the `Escape` press that dismisses an open select menu from reaching outer
8
+ * dismissible surfaces. MrlModal, MrlPanel and MrlPopover close on `Escape` keydown
9
+ * and MrlSidebar on keyup, so without containment a single press would close the
10
+ * menu and the surface behind it at the same time.
11
+ *
12
+ * While the menu is open, the `Escape` keydown and its paired keyup stop propagating
13
+ * after react-select handles them. Once the menu is closed, `Escape` bubbles as
14
+ * usual so the outer surface can respond to the next press.
15
+ *
16
+ * @param menuIsOpen - the resolved react-select menu state
17
+ * @param onKeyDown - react-select's container keydown handler to wrap
18
+ * @returns key event handlers to spread into the select container's `innerProps`
19
+ */
20
+ export declare function useMenuEscapeContainment(menuIsOpen: boolean, onKeyDown: React.KeyboardEventHandler<HTMLDivElement> | undefined): MenuEscapeContainmentHandlers;
21
+ export {};
@@ -1,17 +1,22 @@
1
1
  import { extends as _extends, objectSpread2 as _objectSpread2 } from '../../../../_virtual/_rollupPluginBabelHelpers.js';
2
2
  import * as React from 'react';
3
3
  import { components } from 'react-select';
4
+ import { useMenuEscapeContainment } from '../utils/useMenuEscapeContainment.js';
4
5
 
5
6
  /**
6
7
  * MrlSelectContainer component
7
8
  *
9
+ * Adds `data-qa` support and keeps the `Escape` press that dismisses an open menu
10
+ * from also closing an outer dismissible surface (e.g. a select inside MrlModal).
11
+ *
8
12
  * @param props - the react-select container props
9
13
  * @returns a select container
10
14
  */
11
15
  function MrlSelectContainer(props) {
12
16
  var dataQa = props.selectProps['data-qa'];
17
+ var escapeContainment = useMenuEscapeContainment(props.selectProps.menuIsOpen, props.innerProps.onKeyDown);
13
18
  return /*#__PURE__*/React.createElement(components.SelectContainer, _extends({}, props, {
14
- innerProps: _objectSpread2(_objectSpread2({}, props.innerProps), dataQa && {
19
+ innerProps: _objectSpread2(_objectSpread2(_objectSpread2({}, props.innerProps), escapeContainment), dataQa && {
15
20
  'data-qa': "".concat(dataQa, "-container")
16
21
  })
17
22
  }));
@@ -1 +1 @@
1
- {"version":3,"file":"MrlSelectContainer.js","sources":["../../../../../../src/components/form/select/components/MrlSelectContainer.tsx"],"sourcesContent":["import * as React from 'react';\nimport { GroupBase, components, ContainerProps } from 'react-select';\n\n/**\n * MrlSelectContainer component\n *\n * @param props - the react-select container props\n * @returns a select container\n */\nexport function MrlSelectContainer<\n\tT,\n\tIsMulti extends boolean = false,\n\tGroup extends GroupBase<T> = GroupBase<T>\n>(props: ContainerProps<T, IsMulti, Group>): JSX.Element {\n\tconst dataQa = props.selectProps['data-qa'];\n\treturn (\n\t\t<components.SelectContainer\n\t\t\t{...props}\n\t\t\tinnerProps={{\n\t\t\t\t...props.innerProps,\n\t\t\t\t...(dataQa && { 'data-qa': `${dataQa}-container` })\n\t\t\t}}\n\t\t/>\n\t);\n}\n"],"names":["MrlSelectContainer","props","dataQa","selectProps","React","createElement","components","SelectContainer","_extends","innerProps","_objectSpread","concat"],"mappings":";;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,kBAAkBA,CAIhCC,KAAwC,EAAe;AACxD,EAAA,IAAMC,MAAM,GAAGD,KAAK,CAACE,WAAW,CAAC,SAAS,CAAC;EAC3C,oBACCC,KAAA,CAAAC,aAAA,CAACC,UAAU,CAACC,eAAe,EAAAC,QAAA,CAAA,EAAA,EACtBP,KAAK,EAAA;IACTQ,UAAU,EAAAC,cAAA,CAAAA,cAAA,CAAA,EAAA,EACNT,KAAK,CAACQ,UAAU,CAAA,EACfP,MAAM,IAAI;MAAE,SAAS,EAAA,EAAA,CAAAS,MAAA,CAAKT,MAAM,EAAA,YAAA;KAAc;AACjD,GAAA,CACF,CAAC;AAEJ;;;;"}
1
+ {"version":3,"file":"MrlSelectContainer.js","sources":["../../../../../../src/components/form/select/components/MrlSelectContainer.tsx"],"sourcesContent":["import * as React from 'react';\nimport { GroupBase, components, ContainerProps } from 'react-select';\nimport { useMenuEscapeContainment } from '../utils/useMenuEscapeContainment';\n\n/**\n * MrlSelectContainer component\n *\n * Adds `data-qa` support and keeps the `Escape` press that dismisses an open menu\n * from also closing an outer dismissible surface (e.g. a select inside MrlModal).\n *\n * @param props - the react-select container props\n * @returns a select container\n */\nexport function MrlSelectContainer<\n\tT,\n\tIsMulti extends boolean = false,\n\tGroup extends GroupBase<T> = GroupBase<T>\n>(props: ContainerProps<T, IsMulti, Group>): JSX.Element {\n\tconst dataQa = props.selectProps['data-qa'];\n\tconst escapeContainment = useMenuEscapeContainment(\n\t\tprops.selectProps.menuIsOpen,\n\t\tprops.innerProps.onKeyDown\n\t);\n\n\treturn (\n\t\t<components.SelectContainer\n\t\t\t{...props}\n\t\t\tinnerProps={{\n\t\t\t\t...props.innerProps,\n\t\t\t\t...escapeContainment,\n\t\t\t\t...(dataQa && { 'data-qa': `${dataQa}-container` })\n\t\t\t}}\n\t\t/>\n\t);\n}\n"],"names":["MrlSelectContainer","props","dataQa","selectProps","escapeContainment","useMenuEscapeContainment","menuIsOpen","innerProps","onKeyDown","React","createElement","components","SelectContainer","_extends","_objectSpread","concat"],"mappings":";;;;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,kBAAkBA,CAIhCC,KAAwC,EAAe;AACxD,EAAA,IAAMC,MAAM,GAAGD,KAAK,CAACE,WAAW,CAAC,SAAS,CAAC;AAC3C,EAAA,IAAMC,iBAAiB,GAAGC,wBAAwB,CACjDJ,KAAK,CAACE,WAAW,CAACG,UAAU,EAC5BL,KAAK,CAACM,UAAU,CAACC,SAClB,CAAC;EAED,oBACCC,KAAA,CAAAC,aAAA,CAACC,UAAU,CAACC,eAAe,EAAAC,QAAA,CAAA,EAAA,EACtBZ,KAAK,EAAA;AACTM,IAAAA,UAAU,EAAAO,cAAA,CAAAA,cAAA,CAAAA,cAAA,CAAA,EAAA,EACNb,KAAK,CAACM,UAAU,CAAA,EAChBH,iBAAiB,CAAA,EAChBF,MAAM,IAAI;MAAE,SAAS,EAAA,EAAA,CAAAa,MAAA,CAAKb,MAAM,EAAA,YAAA;KAAc;AACjD,GAAA,CACF,CAAC;AAEJ;;;;"}
@@ -0,0 +1,37 @@
1
+ import * as React from 'react';
2
+
3
+ /**
4
+ * Keeps the `Escape` press that dismisses an open select menu from reaching outer
5
+ * dismissible surfaces. MrlModal, MrlPanel and MrlPopover close on `Escape` keydown
6
+ * and MrlSidebar on keyup, so without containment a single press would close the
7
+ * menu and the surface behind it at the same time.
8
+ *
9
+ * While the menu is open, the `Escape` keydown and its paired keyup stop propagating
10
+ * after react-select handles them. Once the menu is closed, `Escape` bubbles as
11
+ * usual so the outer surface can respond to the next press.
12
+ *
13
+ * @param menuIsOpen - the resolved react-select menu state
14
+ * @param onKeyDown - react-select's container keydown handler to wrap
15
+ * @returns key event handlers to spread into the select container's `innerProps`
16
+ */
17
+ function useMenuEscapeContainment(menuIsOpen, onKeyDown) {
18
+ var escapeDismissedTheMenu = React.useRef(false);
19
+ var handleKeyDown = event => {
20
+ onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
21
+ if (event.key !== 'Escape') return;
22
+ escapeDismissedTheMenu.current = menuIsOpen;
23
+ if (menuIsOpen) event.stopPropagation();
24
+ };
25
+ var handleKeyUp = event => {
26
+ if (event.key !== 'Escape') return;
27
+ if (escapeDismissedTheMenu.current) event.stopPropagation();
28
+ escapeDismissedTheMenu.current = false;
29
+ };
30
+ return {
31
+ onKeyDown: handleKeyDown,
32
+ onKeyUp: handleKeyUp
33
+ };
34
+ }
35
+
36
+ export { useMenuEscapeContainment };
37
+ //# sourceMappingURL=useMenuEscapeContainment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMenuEscapeContainment.js","sources":["../../../../../../src/components/form/select/utils/useMenuEscapeContainment.ts"],"sourcesContent":["import * as React from 'react';\n\ninterface MenuEscapeContainmentHandlers {\n\tonKeyDown: React.KeyboardEventHandler<HTMLDivElement>;\n\tonKeyUp: React.KeyboardEventHandler<HTMLDivElement>;\n}\n\n/**\n * Keeps the `Escape` press that dismisses an open select menu from reaching outer\n * dismissible surfaces. MrlModal, MrlPanel and MrlPopover close on `Escape` keydown\n * and MrlSidebar on keyup, so without containment a single press would close the\n * menu and the surface behind it at the same time.\n *\n * While the menu is open, the `Escape` keydown and its paired keyup stop propagating\n * after react-select handles them. Once the menu is closed, `Escape` bubbles as\n * usual so the outer surface can respond to the next press.\n *\n * @param menuIsOpen - the resolved react-select menu state\n * @param onKeyDown - react-select's container keydown handler to wrap\n * @returns key event handlers to spread into the select container's `innerProps`\n */\nexport function useMenuEscapeContainment(\n\tmenuIsOpen: boolean,\n\tonKeyDown: React.KeyboardEventHandler<HTMLDivElement> | undefined\n): MenuEscapeContainmentHandlers {\n\tconst escapeDismissedTheMenu = React.useRef(false);\n\n\tconst handleKeyDown: React.KeyboardEventHandler<HTMLDivElement> = (event) => {\n\t\tonKeyDown?.(event);\n\n\t\tif (event.key !== 'Escape') return;\n\n\t\tescapeDismissedTheMenu.current = menuIsOpen;\n\t\tif (menuIsOpen) event.stopPropagation();\n\t};\n\n\tconst handleKeyUp: React.KeyboardEventHandler<HTMLDivElement> = (event) => {\n\t\tif (event.key !== 'Escape') return;\n\n\t\tif (escapeDismissedTheMenu.current) event.stopPropagation();\n\t\tescapeDismissedTheMenu.current = false;\n\t};\n\n\treturn { onKeyDown: handleKeyDown, onKeyUp: handleKeyUp };\n}\n"],"names":["useMenuEscapeContainment","menuIsOpen","onKeyDown","escapeDismissedTheMenu","React","useRef","handleKeyDown","event","key","current","stopPropagation","handleKeyUp","onKeyUp"],"mappings":";;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,wBAAwBA,CACvCC,UAAmB,EACnBC,SAAiE,EACjC;AAChC,EAAA,IAAMC,sBAAsB,GAAGC,KAAK,CAACC,MAAM,CAAC,KAAK,CAAC;EAElD,IAAMC,aAAyD,GAAIC,KAAK,IAAK;AAC5EL,IAAAA,SAAS,aAATA,SAAS,KAAA,MAAA,GAAA,MAAA,GAATA,SAAS,CAAGK,KAAK,CAAC;AAElB,IAAA,IAAIA,KAAK,CAACC,GAAG,KAAK,QAAQ,EAAE;IAE5BL,sBAAsB,CAACM,OAAO,GAAGR,UAAU;AAC3C,IAAA,IAAIA,UAAU,EAAEM,KAAK,CAACG,eAAe,EAAE;EACxC,CAAC;EAED,IAAMC,WAAuD,GAAIJ,KAAK,IAAK;AAC1E,IAAA,IAAIA,KAAK,CAACC,GAAG,KAAK,QAAQ,EAAE;IAE5B,IAAIL,sBAAsB,CAACM,OAAO,EAAEF,KAAK,CAACG,eAAe,EAAE;IAC3DP,sBAAsB,CAACM,OAAO,GAAG,KAAK;EACvC,CAAC;EAED,OAAO;AAAEP,IAAAA,SAAS,EAAEI,aAAa;AAAEM,IAAAA,OAAO,EAAED;GAAa;AAC1D;;;;"}
@@ -2,6 +2,9 @@ import { GroupBase, ContainerProps } from 'react-select';
2
2
  /**
3
3
  * MrlSelectContainer component
4
4
  *
5
+ * Adds `data-qa` support and keeps the `Escape` press that dismisses an open menu
6
+ * from also closing an outer dismissible surface (e.g. a select inside MrlModal).
7
+ *
5
8
  * @param props - the react-select container props
6
9
  * @returns a select container
7
10
  */
@@ -0,0 +1,21 @@
1
+ import * as React from 'react';
2
+ interface MenuEscapeContainmentHandlers {
3
+ onKeyDown: React.KeyboardEventHandler<HTMLDivElement>;
4
+ onKeyUp: React.KeyboardEventHandler<HTMLDivElement>;
5
+ }
6
+ /**
7
+ * Keeps the `Escape` press that dismisses an open select menu from reaching outer
8
+ * dismissible surfaces. MrlModal, MrlPanel and MrlPopover close on `Escape` keydown
9
+ * and MrlSidebar on keyup, so without containment a single press would close the
10
+ * menu and the surface behind it at the same time.
11
+ *
12
+ * While the menu is open, the `Escape` keydown and its paired keyup stop propagating
13
+ * after react-select handles them. Once the menu is closed, `Escape` bubbles as
14
+ * usual so the outer surface can respond to the next press.
15
+ *
16
+ * @param menuIsOpen - the resolved react-select menu state
17
+ * @param onKeyDown - react-select's container keydown handler to wrap
18
+ * @returns key event handlers to spread into the select container's `innerProps`
19
+ */
20
+ export declare function useMenuEscapeContainment(menuIsOpen: boolean, onKeyDown: React.KeyboardEventHandler<HTMLDivElement> | undefined): MenuEscapeContainmentHandlers;
21
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@muraldevkit/ui-toolkit",
3
- "version": "4.70.2",
3
+ "version": "4.70.3",
4
4
  "description": "Mural's UI Toolkit",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",