@mirai/ui 1.0.78 → 1.0.79

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -322,6 +322,7 @@ A hyperlink component that receives the following props:
322
322
 
323
323
  - `children:node|string`
324
324
  - `disabled:boolean` applying 'disabled' attribute
325
+ - `inline:boolean` modifying the button padding size
325
326
  - `large:boolean` modifying the button size
326
327
  - `small:boolean` modifying the button size
327
328
  - `tag:string` html tag of resulting element ('button' by default)
@@ -676,8 +677,9 @@ A modal component receiving the following props:
676
677
  - `portal:bool` if you want use _portal feature_ of React API
677
678
  - `title:string` shows a title for the modal
678
679
  - `visible:boolean` if true modal is shown
679
- - `onBack:function` executed once back button is clicked
680
- - `onClose:function` executed once close button is clicked
680
+ - `onBack:function` executed once back button is touched
681
+ - `onClose:function` executed once close button is touched
682
+ - `onOverflow:function` executed once overflow is touched
681
683
 
682
684
  ```jsx
683
685
  import { Modal, View } from '@mirai/ui';
@@ -10,7 +10,7 @@ var _react = _interopRequireDefault(require("react"));
10
10
  var _helpers = require("../../helpers");
11
11
  var _primitives = require("../../primitives");
12
12
  var _ActionModule = _interopRequireDefault(require("./Action.module.css"));
13
- var _excluded = ["children", "disabled", "large", "small", "tag", "wide", "onPress"];
13
+ var _excluded = ["children", "disabled", "inline", "large", "small", "tag", "wide", "onPress"];
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
16
16
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
@@ -22,6 +22,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
22
22
  var Action = function Action(_ref) {
23
23
  var children = _ref.children,
24
24
  disabled = _ref.disabled,
25
+ inline = _ref.inline,
25
26
  large = _ref.large,
26
27
  small = _ref.small,
27
28
  _ref$tag = _ref.tag,
@@ -32,8 +33,8 @@ var Action = function Action(_ref) {
32
33
  return /*#__PURE__*/_react.default.createElement(_primitives.Pressable, _objectSpread(_objectSpread({}, others), {}, {
33
34
  disabled: disabled,
34
35
  tag: tag,
35
- className: (0, _helpers.styles)(_ActionModule.default.action, large && _ActionModule.default.large, small && _ActionModule.default.small, wide && _ActionModule.default.wide, others.className),
36
- onPress: !disabled ? onPress : undefined
36
+ className: (0, _helpers.styles)(_ActionModule.default.action, inline && _ActionModule.default.inline, large && _ActionModule.default.large, small && _ActionModule.default.small, wide && _ActionModule.default.wide, others.className),
37
+ onPress: onPress
37
38
  }), children);
38
39
  };
39
40
  exports.Action = Action;
@@ -41,6 +42,7 @@ Action.displayName = 'Component:Action';
41
42
  Action.propTypes = {
42
43
  children: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]),
43
44
  disabled: _propTypes.default.bool,
45
+ inline: _propTypes.default.bool,
44
46
  large: _propTypes.default.bool,
45
47
  small: _propTypes.default.bool,
46
48
  tag: _propTypes.default.string,
@@ -1 +1 @@
1
- {"version":3,"file":"Action.js","names":["Action","children","disabled","large","small","tag","wide","onPress","others","React","createElement","Pressable","className","styles","style","action","undefined","displayName","propTypes","PropTypes","oneOfType","string","node","bool","onEnter","func","onLeave"],"sources":["../../../src/components/Action/Action.jsx"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React from 'react';\n\nimport { styles } from '../../helpers';\nimport { Pressable } from '../../primitives';\nimport style from './Action.module.css';\n\nconst Action = ({ children, disabled, large, small, tag = 'button', wide, onPress, ...others }) =>\n React.createElement(\n Pressable,\n {\n ...others,\n disabled,\n tag,\n className: styles(style.action, large && style.large, small && style.small, wide && style.wide, others.className),\n onPress: !disabled ? onPress : undefined,\n },\n children,\n );\n\nAction.displayName = 'Component:Action';\n\nAction.propTypes = {\n children: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),\n disabled: PropTypes.bool,\n large: PropTypes.bool,\n small: PropTypes.bool,\n tag: PropTypes.string,\n wide: PropTypes.bool,\n onEnter: PropTypes.func,\n onLeave: PropTypes.func,\n onPress: PropTypes.func,\n};\n\nexport { Action };\n"],"mappings":";;;;;;;AAAA;AACA;AAEA;AACA;AACA;AAAwC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAExC,IAAMA,MAAM,GAAG,SAATA,MAAM;EAAA,IAAMC,QAAQ,QAARA,QAAQ;IAAEC,QAAQ,QAARA,QAAQ;IAAEC,KAAK,QAALA,KAAK;IAAEC,KAAK,QAALA,KAAK;IAAA,gBAAEC,GAAG;IAAHA,GAAG,yBAAG,QAAQ;IAAEC,IAAI,QAAJA,IAAI;IAAEC,OAAO,QAAPA,OAAO;IAAKC,MAAM;EAAA,oBAC1FC,cAAK,CAACC,aAAa,CACjBC,qBAAS,kCAEJH,MAAM;IACTN,QAAQ,EAARA,QAAQ;IACRG,GAAG,EAAHA,GAAG;IACHO,SAAS,EAAE,IAAAC,eAAM,EAACC,qBAAK,CAACC,MAAM,EAAEZ,KAAK,IAAIW,qBAAK,CAACX,KAAK,EAAEC,KAAK,IAAIU,qBAAK,CAACV,KAAK,EAAEE,IAAI,IAAIQ,qBAAK,CAACR,IAAI,EAAEE,MAAM,CAACI,SAAS,CAAC;IACjHL,OAAO,EAAE,CAACL,QAAQ,GAAGK,OAAO,GAAGS;EAAS,IAE1Cf,QAAQ,CACT;AAAA;AAAC;AAEJD,MAAM,CAACiB,WAAW,GAAG,kBAAkB;AAEvCjB,MAAM,CAACkB,SAAS,GAAG;EACjBjB,QAAQ,EAAEkB,kBAAS,CAACC,SAAS,CAAC,CAACD,kBAAS,CAACE,MAAM,EAAEF,kBAAS,CAACG,IAAI,CAAC,CAAC;EACjEpB,QAAQ,EAAEiB,kBAAS,CAACI,IAAI;EACxBpB,KAAK,EAAEgB,kBAAS,CAACI,IAAI;EACrBnB,KAAK,EAAEe,kBAAS,CAACI,IAAI;EACrBlB,GAAG,EAAEc,kBAAS,CAACE,MAAM;EACrBf,IAAI,EAAEa,kBAAS,CAACI,IAAI;EACpBC,OAAO,EAAEL,kBAAS,CAACM,IAAI;EACvBC,OAAO,EAAEP,kBAAS,CAACM,IAAI;EACvBlB,OAAO,EAAEY,kBAAS,CAACM;AACrB,CAAC"}
1
+ {"version":3,"file":"Action.js","names":["Action","children","disabled","inline","large","small","tag","wide","onPress","others","React","createElement","Pressable","className","styles","style","action","displayName","propTypes","PropTypes","oneOfType","string","node","bool","onEnter","func","onLeave"],"sources":["../../../src/components/Action/Action.jsx"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React from 'react';\n\nimport { styles } from '../../helpers';\nimport { Pressable } from '../../primitives';\nimport style from './Action.module.css';\n\nconst Action = ({ children, disabled, inline, large, small, tag = 'button', wide, onPress, ...others }) =>\n React.createElement(\n Pressable,\n {\n ...others,\n disabled,\n tag,\n className: styles(\n style.action,\n inline && style.inline,\n large && style.large,\n small && style.small,\n wide && style.wide,\n others.className,\n ),\n onPress,\n },\n children,\n );\n\nAction.displayName = 'Component:Action';\n\nAction.propTypes = {\n children: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),\n disabled: PropTypes.bool,\n inline: PropTypes.bool,\n large: PropTypes.bool,\n small: PropTypes.bool,\n tag: PropTypes.string,\n wide: PropTypes.bool,\n onEnter: PropTypes.func,\n onLeave: PropTypes.func,\n onPress: PropTypes.func,\n};\n\nexport { Action };\n"],"mappings":";;;;;;;AAAA;AACA;AAEA;AACA;AACA;AAAwC;AAAA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OAAO,EAAEP,kBAAS,CAACM,IAAI;EACvBjB,OAAO,EAAEW,kBAAS,CAACM;AACrB,CAAC"}
@@ -6,7 +6,6 @@
6
6
  font-size: var(--mirai-ui-font-size-action);
7
7
  font-weight: var(--mirai-ui-action-font-weight);
8
8
  justify-content: center;
9
- padding: var(--mirai-ui-button-padding-y) 0;
10
9
  position: relative;
11
10
  width: fit-content;
12
11
  }
@@ -19,13 +18,23 @@
19
18
  color: var(--mirai-ui-action-color-active);
20
19
  }
21
20
 
21
+ .action:not(.inline):not(.large):not(.small) {
22
+ padding: var(--mirai-ui-button-padding-y) 0;
23
+ }
24
+
22
25
  .large {
23
26
  font-size: var(--mirai-ui-font-size-paragraph);
27
+ }
28
+
29
+ .large:not(.inline) {
24
30
  padding: var(--mirai-ui-button-padding-y) 0;
25
31
  }
26
32
 
27
33
  .small {
28
34
  font-size: var(--mirai-ui-font-size-small);
35
+ }
36
+
37
+ .small:not(.inline) {
29
38
  padding: var(--mirai-ui-button-padding-y) 0;
30
39
  }
31
40
 
@@ -24,6 +24,8 @@ Story.storyName = 'Action';
24
24
  Story.args = _defineProperty({
25
25
  children: 'children',
26
26
  disabled: false,
27
+ href: undefined,
28
+ inline: false,
27
29
  large: false,
28
30
  small: false,
29
31
  tag: 'button',
@@ -1 +1 @@
1
- {"version":3,"file":"Action.stories.js","names":["title","Story","props","storyName","args","children","disabled","large","small","tag","wide","argTypes","onEnter","action","onLeave","onPress"],"sources":["../../../src/components/Action/Action.stories.jsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Action } from './Action';\n\nexport default { title: 'Components' };\n\nexport const Story = (props) => <Action {...props} />;\n\nStory.storyName = 'Action';\n\nStory.args = {\n children: 'children',\n disabled: false,\n large: false,\n small: false,\n tag: 'button',\n wide: false,\n ['data-testid']: 'test-story',\n};\n\nStory.argTypes = {\n onEnter: { action: 'onEnter' },\n onLeave: { action: 'onLeave' },\n onPress: { action: 'onPress' },\n};\n"],"mappings":";;;;;;AAAA;AAEA;AAAkC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAEnB;EAAEA,KAAK,EAAE;AAAa,CAAC;AAAA;AAE/B,IAAMC,KAAK,GAAG,SAARA,KAAK,CAAIC,KAAK;EAAA,oBAAK,oBAAC,cAAM,EAAKA,KAAK,CAAI;AAAA;AAAC;AAEtDD,KAAK,CAACE,SAAS,GAAG,QAAQ;AAE1BF,KAAK,CAACG,IAAI;EACRC,QAAQ,EAAE,UAAU;EACpBC,QAAQ,EAAE,KAAK;EACfC,KAAK,EAAE,KAAK;EACZC,KAAK,EAAE,KAAK;EACZC,GAAG,EAAE,QAAQ;EACbC,IAAI,EAAE;AAAK,GACV,aAAa,EAAG,YAAY,CAC9B;AAEDT,KAAK,CAACU,QAAQ,GAAG;EACfC,OAAO,EAAE;IAAEC,MAAM,EAAE;EAAU,CAAC;EAC9BC,OAAO,EAAE;IAAED,MAAM,EAAE;EAAU,CAAC;EAC9BE,OAAO,EAAE;IAAEF,MAAM,EAAE;EAAU;AAC/B,CAAC"}
1
+ {"version":3,"file":"Action.stories.js","names":["title","Story","props","storyName","args","children","disabled","href","undefined","inline","large","small","tag","wide","argTypes","onEnter","action","onLeave","onPress"],"sources":["../../../src/components/Action/Action.stories.jsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Action } from './Action';\n\nexport default { title: 'Components' };\n\nexport const Story = (props) => <Action {...props} />;\n\nStory.storyName = 'Action';\n\nStory.args = {\n children: 'children',\n disabled: false,\n href: undefined,\n inline: false,\n large: false,\n small: false,\n tag: 'button',\n wide: false,\n ['data-testid']: 'test-story',\n};\n\nStory.argTypes = {\n onEnter: { action: 'onEnter' },\n onLeave: { action: 'onLeave' },\n onPress: { action: 'onPress' },\n};\n"],"mappings":";;;;;;AAAA;AAEA;AAAkC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAEnB;EAAEA,KAAK,EAAE;AAAa,CAAC;AAAA;AAE/B,IAAMC,KAAK,GAAG,SAARA,KAAK,CAAIC,KAAK;EAAA,oBAAK,oBAAC,cAAM,EAAKA,KAAK,CAAI;AAAA;AAAC;AAEtDD,KAAK,CAACE,SAAS,GAAG,QAAQ;AAE1BF,KAAK,CAACG,IAAI;EACRC,QAAQ,EAAE,UAAU;EACpBC,QAAQ,EAAE,KAAK;EACfC,IAAI,EAAEC,SAAS;EACfC,MAAM,EAAE,KAAK;EACbC,KAAK,EAAE,KAAK;EACZC,KAAK,EAAE,KAAK;EACZC,GAAG,EAAE,QAAQ;EACbC,IAAI,EAAE;AAAK,GACV,aAAa,EAAG,YAAY,CAC9B;AAEDZ,KAAK,CAACa,QAAQ,GAAG;EACfC,OAAO,EAAE;IAAEC,MAAM,EAAE;EAAU,CAAC;EAC9BC,OAAO,EAAE;IAAED,MAAM,EAAE;EAAU,CAAC;EAC9BE,OAAO,EAAE;IAAEF,MAAM,EAAE;EAAU;AAC/B,CAAC"}
@@ -21,6 +21,36 @@ exports[`component:<Action> prop:disabled 1`] = `
21
21
  </DocumentFragment>
22
22
  `;
23
23
 
24
+ exports[`component:<Action> prop:inline & prop:large 1`] = `
25
+ <DocumentFragment>
26
+ <button
27
+ class="pressable action inline large"
28
+ >
29
+ children
30
+ </button>
31
+ </DocumentFragment>
32
+ `;
33
+
34
+ exports[`component:<Action> prop:inline & prop:small 1`] = `
35
+ <DocumentFragment>
36
+ <button
37
+ class="pressable action inline small"
38
+ >
39
+ children
40
+ </button>
41
+ </DocumentFragment>
42
+ `;
43
+
44
+ exports[`component:<Action> prop:inline default 1`] = `
45
+ <DocumentFragment>
46
+ <button
47
+ class="pressable action inline"
48
+ >
49
+ children
50
+ </button>
51
+ </DocumentFragment>
52
+ `;
53
+
24
54
  exports[`component:<Action> prop:large 1`] = `
25
55
  <DocumentFragment>
26
56
  <button
@@ -31,7 +31,9 @@ var Menu = function Menu(_ref) {
31
31
  var _useDevice = (0, _hooks.useDevice)(),
32
32
  isDesktop = _useDevice.isDesktop;
33
33
  var renderOptions = function renderOptions() {
34
- return options.map(function () {
34
+ return options.filter(function (option) {
35
+ return !!option;
36
+ }).map(function () {
35
37
  var option = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
36
38
  var index = arguments.length > 1 ? arguments[1] : undefined;
37
39
  return /*#__PURE__*/_react.default.createElement(Template, _extends({
@@ -47,7 +49,7 @@ var Menu = function Menu(_ref) {
47
49
  return isDesktop ? /*#__PURE__*/_react.default.createElement(_primitives.Layer, _extends({
48
50
  forceRender: false
49
51
  }, others, {
50
- className: (0, _helpers.styles)(_MenuModule.default.menu, _MenuModule.default.desktop, visible && _MenuModule.default.visible, others.className),
52
+ className: (0, _helpers.styles)(_MenuModule.default.menu, visible && _MenuModule.default.visible, others.className),
51
53
  visible: visible
52
54
  }), children, /*#__PURE__*/_react.default.createElement(_primitives.LayerContent, null, renderOptions())) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children, /*#__PURE__*/_react.default.createElement(_Modal.Modal, {
53
55
  title: title,
@@ -55,6 +57,9 @@ var Menu = function Menu(_ref) {
55
57
  onClose: function onClose(event) {
56
58
  return _onPress(undefined, event);
57
59
  },
60
+ onOverflow: function onOverflow(event) {
61
+ return _onPress(undefined, event);
62
+ },
58
63
  className: (0, _helpers.styles)(_MenuModule.default.menu, others.className)
59
64
  }, renderOptions()));
60
65
  };
@@ -1 +1 @@
1
- {"version":3,"file":"Menu.js","names":["Menu","children","options","Template","Option","title","visible","onPress","others","useDevice","isDesktop","renderOptions","map","option","index","undefined","event","value","styles","style","menu","desktop","className","displayName","propTypes","PropTypes","node","arrayOf","shape","disabled","bool","divider","icon","func","label","string","oneOfType","number","any","onClose"],"sources":["../../../src/components/Menu/Menu.jsx"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React from 'react';\n\nimport { styles } from '../../helpers';\nimport { useDevice } from '../../hooks';\nimport { Layer, LayerContent } from '../../primitives';\nimport { Modal } from '../Modal';\nimport style from './Menu.module.css';\nimport { Option } from './Menu.Option';\n\nconst Menu = ({ children, options = [], Template = Option, title, visible, onPress = () => {}, ...others }) => {\n const { isDesktop } = useDevice();\n\n const renderOptions = () =>\n options.map((option = {}, index) => (\n <Template\n data-testid={others['data-testid'] ? `${others['data-testid']}-${index}` : undefined}\n {...option}\n key={index}\n onPress={(event) => onPress(option.value, event)}\n />\n ));\n\n return isDesktop ? (\n <Layer\n forceRender={false}\n {...others}\n className={styles(style.menu, style.desktop, visible && style.visible, others.className)}\n visible={visible}\n >\n {children}\n <LayerContent>{renderOptions()}</LayerContent>\n </Layer>\n ) : (\n <>\n {children}\n <Modal\n title={title}\n visible={visible}\n onClose={(event) => onPress(undefined, event)}\n className={styles(style.menu, others.className)}\n >\n {renderOptions()}\n </Modal>\n </>\n );\n};\n\nMenu.displayName = 'Component:Menu';\n\nMenu.propTypes = {\n children: PropTypes.node,\n options: PropTypes.arrayOf(\n PropTypes.shape({\n children: PropTypes.node,\n disabled: PropTypes.bool,\n divider: PropTypes.bool,\n icon: PropTypes.func,\n label: PropTypes.string,\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n }),\n ),\n Template: PropTypes.any,\n title: PropTypes.string,\n visible: PropTypes.bool,\n onPress: PropTypes.func,\n onClose: PropTypes.func,\n};\n\nexport { Menu };\n"],"mappings":";;;;;;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAAuC;AAAA;AAAA;AAAA;AAAA;AAEvC,IAAMA,IAAI,GAAG,SAAPA,IAAI,OAAqG;EAAA,IAA/FC,QAAQ,QAARA,QAAQ;IAAA,oBAAEC,OAAO;IAAPA,OAAO,6BAAG,EAAE;IAAA,qBAAEC,QAAQ;IAARA,QAAQ,8BAAGC,YAAM;IAAEC,KAAK,QAALA,KAAK;IAAEC,OAAO,QAAPA,OAAO;IAAA,oBAAEC,OAAO;IAAPA,QAAO,6BAAG,YAAM,CAAC,CAAC;IAAKC,MAAM;EACtG,iBAAsB,IAAAC,gBAAS,GAAE;IAAzBC,SAAS,cAATA,SAAS;EAEjB,IAAMC,aAAa,GAAG,SAAhBA,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d3B,QAAQ,EAAEwB,kBAAS,CAACC,IAAI;IACxBG,QAAQ,EAAEJ,kBAAS,CAACK,IAAI;IACxBC,OAAO,EAAEN,kBAAS,CAACK,IAAI;IACvBE,IAAI,EAAEP,kBAAS,CAACQ,IAAI;IACpBC,KAAK,EAAET,kBAAS,CAACU,MAAM;IACvBlB,KAAK,EAAEQ,kBAAS,CAACW,SAAS,CAAC,CAACX,kBAAS,CAACU,MAAM,EAAEV,kBAAS,CAACY,MAAM,CAAC;EACjE,CAAC,CAAC,CACH;EACDlC,QAAQ,EAAEsB,kBAAS,CAACa,GAAG;EACvBjC,KAAK,EAAEoB,kBAAS,CAACU,MAAM;EACvB7B,OAAO,EAAEmB,kBAAS,CAACK,IAAI;EACvBvB,OAAO,EAAEkB,kBAAS,CAACQ,IAAI;EACvBM,OAAO,EAAEd,kBAAS,CAACQ;AACrB,CAAC"}
1
+ {"version":3,"file":"Menu.js","names":["Menu","children","options","Template","Option","title","visible","onPress","others","useDevice","isDesktop","renderOptions","filter","option","map","index","undefined","event","value","styles","style","menu","className","displayName","propTypes","PropTypes","node","arrayOf","shape","disabled","bool","divider","icon","func","label","string","oneOfType","number","any","onClose"],"sources":["../../../src/components/Menu/Menu.jsx"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React from 'react';\n\nimport { styles } from '../../helpers';\nimport { useDevice } from '../../hooks';\nimport { Layer, LayerContent } from '../../primitives';\nimport { Modal } from '../Modal';\nimport style from './Menu.module.css';\nimport { Option } from './Menu.Option';\n\nconst Menu = ({ children, options = [], Template = Option, title, visible, onPress = () => {}, ...others }) => {\n const { isDesktop } = useDevice();\n\n const renderOptions = () =>\n options\n .filter((option) => !!option)\n .map((option = {}, index) => (\n <Template\n data-testid={others['data-testid'] ? `${others['data-testid']}-${index}` : undefined}\n {...option}\n key={index}\n onPress={(event) => onPress(option.value, event)}\n />\n ));\n\n return isDesktop ? (\n <Layer\n forceRender={false}\n {...others}\n className={styles(style.menu, visible && style.visible, others.className)}\n visible={visible}\n >\n {children}\n <LayerContent>{renderOptions()}</LayerContent>\n </Layer>\n ) : (\n <>\n {children}\n <Modal\n title={title}\n visible={visible}\n onClose={(event) => onPress(undefined, event)}\n onOverflow={(event) => onPress(undefined, event)}\n className={styles(style.menu, others.className)}\n >\n {renderOptions()}\n </Modal>\n </>\n );\n};\n\nMenu.displayName = 'Component:Menu';\n\nMenu.propTypes = {\n children: PropTypes.node,\n options: PropTypes.arrayOf(\n PropTypes.shape({\n children: PropTypes.node,\n disabled: PropTypes.bool,\n divider: PropTypes.bool,\n icon: PropTypes.func,\n label: PropTypes.string,\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n }),\n ),\n Template: PropTypes.any,\n title: PropTypes.string,\n visible: PropTypes.bool,\n onPress: PropTypes.func,\n onClose: PropTypes.func,\n};\n\nexport { Menu };\n"],"mappings":";;;;;;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAAuC;AAAA;AAAA;AAAA;AAAA;AAEvC,IAAMA,IAAI,GAAG,SAAPA,IAAI,OAAqG;EAAA,IAA/FC,QAAQ,QAARA,QAAQ;IAAA,oBAAEC,OAAO;IAAPA,OAAO,6BAAG,EAAE;IAAA,qBAAEC,QAAQ;IAARA,QAAQ,8BAAGC,YAAM;IAAEC,KAAK,QAALA,KAAK;IAAEC,OAAO,QAAPA,OAAO;IAAA,oBAAEC,OAAO;IAAPA,QAAO,6BAAG,YAAM,CAAC,CAAC;IAAKC,MAAM;EACtG,iBAAsB,IAAAC,gBAAS,GAAE;IAAzBC,SAAS,cAATA,SAAS;EAEjB,IAAMC,aAAa,GAAG,SAAhBA,aAAa;IAAA,OACjBT,OAAO,CACJU,MAAM,CAAC,UAACC,MAAM;MAAA,OAAK,CAAC,CAACA,MAAM;IAAA,EAAC,CAC5BC,GAAG,CAAC;MAAA,IAACD,MAAM,uEAAG,CAAC,CAAC;MAAA,IAAEE,KAAK;MAAA,oBACtB,6BAAC,QAAQ;QACP,eAAaP,MAAM,CAAC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xBC,OAAO,EAAEN,kBAAS,CAACK,IAAI;IACvBE,IAAI,EAAEP,kBAAS,CAACQ,IAAI;IACpBC,KAAK,EAAET,kBAAS,CAACU,MAAM;IACvBjB,KAAK,EAAEO,kBAAS,CAACW,SAAS,CAAC,CAACX,kBAAS,CAACU,MAAM,EAAEV,kBAAS,CAACY,MAAM,CAAC;EACjE,CAAC,CAAC,CACH;EACDlC,QAAQ,EAAEsB,kBAAS,CAACa,GAAG;EACvBjC,KAAK,EAAEoB,kBAAS,CAACU,MAAM;EACvB7B,OAAO,EAAEmB,kBAAS,CAACK,IAAI;EACvBvB,OAAO,EAAEkB,kBAAS,CAACQ,IAAI;EACvBM,OAAO,EAAEd,kBAAS,CAACQ;AACrB,CAAC"}
@@ -52,3 +52,20 @@
52
52
  color: var(--mirai-ui-menu-option-disabled);
53
53
  cursor: default;
54
54
  }
55
+
56
+ /* S */
57
+ @media only screen and (max-width: 430px) {
58
+ .menu {
59
+ padding-bottom: var(--mirai-ui-space-XS);
60
+ }
61
+ }
62
+
63
+ @media only screen and (min-width: 430px) {
64
+ .menu {
65
+ background-color: var(--mirai-ui-menu-base);
66
+ border-radius: var(--mirai-ui-menu-border-radius);
67
+ box-shadow: var(--mirai-ui-menu-shadow);
68
+ min-width: var(--mirai-ui-menu-min-width);
69
+ overflow: hidden;
70
+ }
71
+ }
@@ -31,10 +31,10 @@ Story.args = _defineProperty({
31
31
  bold: true
32
32
  }, "Lorem"), /*#__PURE__*/React.createElement(_primitives.Text, null, "Ipsum is simply dummy text...")),
33
33
  divider: true
34
- }, {
34
+ }, undefined, {
35
35
  label: 'Lorem Ipsum is simply dummy text...',
36
36
  divider: true
37
- }, _defineProperty({
37
+ }, undefined, undefined, _defineProperty({
38
38
  icon: _primitives.ICON.ADD,
39
39
  label: 'Item 1',
40
40
  value: 'one'
@@ -1 +1 @@
1
- {"version":3,"file":"Menu.stories.js","names":["title","Story","props","storyName","args","options","children","divider","label","icon","ICON","ADD","value","disabled","visible","argTypes","onPress","action"],"sources":["../../../src/components/Menu/Menu.stories.jsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Button } from '../';\nimport { ICON, Text } from '../../primitives';\nimport { Menu } from './Menu';\n\nexport default { title: 'Components' };\n\nexport const Story = (props) => (\n <Menu {...props}>\n <span className=\"children\">children</span>\n </Menu>\n);\n\nStory.storyName = 'Menu';\n\nStory.args = {\n options: [\n {\n children: (\n <>\n <Text bold>Lorem</Text>\n <Text>Ipsum is simply dummy text...</Text>\n </>\n ),\n divider: true,\n },\n { label: 'Lorem Ipsum is simply dummy text...', divider: true },\n { icon: ICON.ADD, label: 'Item 1', value: 'one', ['data-testid']: 'custom-test' },\n { icon: ICON.ADD, label: 'Item 2', disabled: true, value: 'two' },\n { label: 'Item 3', divider: true, value: 'three' },\n { label: 'Item 4', children: <Button small>Add</Button>, value: 'four' },\n {\n children: (\n <Button secondary wide>\n Logout\n </Button>\n ),\n },\n ],\n title: 'title',\n visible: true,\n ['data-testid']: 'test-story',\n};\n\nStory.argTypes = {\n onPress: { action: 'onPress' },\n};\n"],"mappings":";;;;;;AAAA;AAEA;AACA;AACA;AAA8B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAEf;EAAEA,KAAK,EAAE;AAAa,CAAC;AAAA;AAE/B,IAAMC,KAAK,GAAG,SAARA,KAAK,CAAIC,KAAK;EAAA,oBACzB,oBAAC,UAAI,EAAKA,KAAK,eACb;IAAM,SAAS,EAAC;EAAU,cAAgB,CACrC;AAAA,CACR;AAAC;AAEFD,KAAK,CAACE,SAAS,GAAG,MAAM;AAExBF,KAAK,CAACG,IAAI;EACRC,OAAO,EAAE,CACP;IACEC,QAAQ,eACN,uDACE,oBAAC,gBAAI;MAAC,IAAI;IAAA,WAAa,eACvB,oBAAC,gBAAI,wCAAqC,CAE7C;IACDC,OAAO,EAAE;EACX,CAAC,EACD;IAAEC,KAAK,EAAE,qCAAqC;IAAED,OAAO,EAAE;EAAK,CAAC;IAC7DE,IAAI,EAAEC,gBAAI,CAACC,GAAG;IAAEH,KAAK,EAAE,QAAQ;IAAEI,KAAK,EAAE;EAAK,GAAG,aAAa,EAAG,aAAa,GAC/E;IAAEH,IAAI,EAAEC,gBAAI,CAACC,GAAG;IAAEH,KAAK,EAAE,QAAQ;IAAEK,QAAQ,EAAE,IAAI;IAAED,KAAK,EAAE;EAAM,CAAC,EACjE;IAAEJ,KAAK,EAAE,QAAQ;IAAED,OAAO,EAAE,IAAI;IAAEK,KAAK,EAAE;EAAQ,CAAC,EAClD;IAAEJ,KAAK,EAAE,QAAQ;IAAEF,QAAQ,eAAE,oBAAC,QAAM;MAAC,KAAK;IAAA,SAAa;IAAEM,KAAK,EAAE;EAAO,CAAC,EACxE;IACEN,QAAQ,eACN,oBAAC,QAAM;MAAC,SAAS;MAAC,IAAI;IAAA;EAI1B,CAAC,CACF;EACDN,KAAK,EAAE,OAAO;EACdc,OAAO,EAAE;AAAI,GACZ,aAAa,EAAG,YAAY,CAC9B;AAEDb,KAAK,CAACc,QAAQ,GAAG;EACfC,OAAO,EAAE;IAAEC,MAAM,EAAE;EAAU;AAC/B,CAAC"}
1
+ {"version":3,"file":"Menu.stories.js","names":["title","Story","props","storyName","args","options","children","divider","undefined","label","icon","ICON","ADD","value","disabled","visible","argTypes","onPress","action"],"sources":["../../../src/components/Menu/Menu.stories.jsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Button } from '../';\nimport { ICON, Text } from '../../primitives';\nimport { Menu } from './Menu';\n\nexport default { title: 'Components' };\n\nexport const Story = (props) => (\n <Menu {...props}>\n <span className=\"children\">children</span>\n </Menu>\n);\n\nStory.storyName = 'Menu';\n\nStory.args = {\n options: [\n {\n children: (\n <>\n <Text bold>Lorem</Text>\n <Text>Ipsum is simply dummy text...</Text>\n </>\n ),\n divider: true,\n },\n undefined,\n { label: 'Lorem Ipsum is simply dummy text...', divider: true },\n undefined,\n undefined,\n { icon: ICON.ADD, label: 'Item 1', value: 'one', ['data-testid']: 'custom-test' },\n { icon: ICON.ADD, label: 'Item 2', disabled: true, value: 'two' },\n { label: 'Item 3', divider: true, value: 'three' },\n { label: 'Item 4', children: <Button small>Add</Button>, value: 'four' },\n {\n children: (\n <Button secondary wide>\n Logout\n </Button>\n ),\n },\n ],\n title: 'title',\n visible: true,\n ['data-testid']: 'test-story',\n};\n\nStory.argTypes = {\n onPress: { action: 'onPress' },\n};\n"],"mappings":";;;;;;AAAA;AAEA;AACA;AACA;AAA8B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAEf;EAAEA,KAAK,EAAE;AAAa,CAAC;AAAA;AAE/B,IAAMC,KAAK,GAAG,SAARA,KAAK,CAAIC,KAAK;EAAA,oBACzB,oBAAC,UAAI,EAAKA,KAAK,eACb;IAAM,SAAS,EAAC;EAAU,cAAgB,CACrC;AAAA,CACR;AAAC;AAEFD,KAAK,CAACE,SAAS,GAAG,MAAM;AAExBF,KAAK,CAACG,IAAI;EACRC,OAAO,EAAE,CACP;IACEC,QAAQ,eACN,uDACE,oBAAC,gBAAI;MAAC,IAAI;IAAA,WAAa,eACvB,oBAAC,gBAAI,wCAAqC,CAE7C;IACDC,OAAO,EAAE;EACX,CAAC,EACDC,SAAS,EACT;IAAEC,KAAK,EAAE,qCAAqC;IAAEF,OAAO,EAAE;EAAK,CAAC,EAC/DC,SAAS,EACTA,SAAS;IACPE,IAAI,EAAEC,gBAAI,CAACC,GAAG;IAAEH,KAAK,EAAE,QAAQ;IAAEI,KAAK,EAAE;EAAK,GAAG,aAAa,EAAG,aAAa,GAC/E;IAAEH,IAAI,EAAEC,gBAAI,CAACC,GAAG;IAAEH,KAAK,EAAE,QAAQ;IAAEK,QAAQ,EAAE,IAAI;IAAED,KAAK,EAAE;EAAM,CAAC,EACjE;IAAEJ,KAAK,EAAE,QAAQ;IAAEF,OAAO,EAAE,IAAI;IAAEM,KAAK,EAAE;EAAQ,CAAC,EAClD;IAAEJ,KAAK,EAAE,QAAQ;IAAEH,QAAQ,eAAE,oBAAC,QAAM;MAAC,KAAK;IAAA,SAAa;IAAEO,KAAK,EAAE;EAAO,CAAC,EACxE;IACEP,QAAQ,eACN,oBAAC,QAAM;MAAC,SAAS;MAAC,IAAI;IAAA;EAI1B,CAAC,CACF;EACDN,KAAK,EAAE,OAAO;EACde,OAAO,EAAE;AAAI,GACZ,aAAa,EAAG,YAAY,CAC9B;AAEDd,KAAK,CAACe,QAAQ,GAAG;EACfC,OAAO,EAAE;IAAEC,MAAM,EAAE;EAAU;AAC/B,CAAC"}
@@ -40,7 +40,7 @@ exports[`component:<Menu> prop:options & visible 1`] = `
40
40
  </button>
41
41
  </span>
42
42
  <div
43
- class="layer menu desktop visible"
43
+ class="layer menu visible"
44
44
  style="left: 0px; top: 0px;"
45
45
  >
46
46
  <div
@@ -171,7 +171,7 @@ exports[`component:<Menu> prop:title 1`] = `
171
171
  </button>
172
172
  </span>
173
173
  <div
174
- class="layer menu desktop visible"
174
+ class="layer menu visible"
175
175
  style="left: 0px; top: 0px;"
176
176
  />
177
177
  </DocumentFragment>
@@ -12,11 +12,17 @@ var _helpers = require("../../helpers");
12
12
  var _hooks = require("../../hooks");
13
13
  var _primitives = require("../../primitives");
14
14
  var _ModalModule = _interopRequireDefault(require("./Modal.module.css"));
15
- var _excluded = ["blur", "children", "fit", "overflow", "portal", "title", "visible", "onBack", "onClose"];
15
+ var _excluded = ["blur", "children", "fit", "overflow", "portal", "title", "visible", "onBack", "onClose", "onOverflow"];
16
16
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
17
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
18
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
19
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
20
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
21
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
22
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
23
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
24
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0) { ; } } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
25
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
20
26
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
21
27
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
22
28
  var Modal = function Modal(_ref) {
@@ -33,19 +39,35 @@ var Modal = function Modal(_ref) {
33
39
  visible = _ref.visible,
34
40
  onBack = _ref.onBack,
35
41
  onClose = _ref.onClose,
42
+ onOverflow = _ref.onOverflow,
36
43
  others = _objectWithoutProperties(_ref, _excluded);
37
44
  var _useDevice = (0, _hooks.useDevice)(),
38
45
  isDesktop = _useDevice.isDesktop;
46
+ var _useState = (0, _react.useState)(),
47
+ _useState2 = _slicedToArray(_useState, 2),
48
+ dataset = _useState2[0],
49
+ setDataset = _useState2[1];
39
50
  (0, _react.useEffect)(function () {
40
- document.body.style.overflow = visible ? 'hidden' : 'inherit';
41
- }, [visible]);
51
+ if (visible && !dataset) {
52
+ setDataset(true);
53
+ document.body.dataset.miraiModal = true;
54
+ }
55
+ return function () {
56
+ if (visible && dataset) {
57
+ setDataset(undefined);
58
+ delete document.body.dataset.miraiModal;
59
+ }
60
+ };
61
+ }, [dataset, visible]);
42
62
  var renderer = _helpers.IS_JEST || !portal ? function (jsx) {
43
63
  return jsx;
44
64
  } : _reactDom.default.createPortal;
45
65
  var testId = others['data-testid'];
46
- return renderer( /*#__PURE__*/_react.default.createElement(_primitives.View, {
47
- row: true,
48
- className: (0, _helpers.styles)(_ModalModule.default.container, overflow && _ModalModule.default.overflow, overflow && blur && _ModalModule.default.blur, visible && _ModalModule.default.visible)
66
+ return renderer( /*#__PURE__*/_react.default.createElement(_primitives.Pressable, {
67
+ className: (0, _helpers.styles)(_ModalModule.default.container, overflow && _ModalModule.default.overflow, overflow && blur && _ModalModule.default.blur, visible && _ModalModule.default.visible),
68
+ preventDefault: true,
69
+ onPress: visible && overflow ? onOverflow : undefined,
70
+ "data-testid": testId ? "".concat(testId, "-overflow") : undefined
49
71
  }, /*#__PURE__*/_react.default.createElement(_primitives.View, _extends({}, others, {
50
72
  fit: true,
51
73
  className: (0, _helpers.styles)(_ModalModule.default.modal, !fit && _ModalModule.default.calcWidth, visible && _ModalModule.default.visible, others.className)
@@ -53,6 +75,7 @@ var Modal = function Modal(_ref) {
53
75
  row: true,
54
76
  className: _ModalModule.default.header
55
77
  }, onBack && /*#__PURE__*/_react.default.createElement(_primitives.Pressable, {
78
+ preventDefault: true,
56
79
  onPress: onBack,
57
80
  "data-testid": testId ? "".concat(testId, "-button-back") : undefined
58
81
  }, /*#__PURE__*/_react.default.createElement(_primitives.Icon, {
@@ -62,6 +85,7 @@ var Modal = function Modal(_ref) {
62
85
  headline: true,
63
86
  className: (0, _helpers.styles)(_ModalModule.default.title, !onBack && _ModalModule.default.left, !onClose && _ModalModule.default.right)
64
87
  }, title), onClose && /*#__PURE__*/_react.default.createElement(_primitives.Pressable, {
88
+ preventDefault: true,
65
89
  onPress: onClose,
66
90
  "data-testid": testId ? "".concat(testId, "-button-close") : undefined
67
91
  }, /*#__PURE__*/_react.default.createElement(_primitives.Icon, {
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.js","names":["Modal","blur","children","fit","overflow","portal","title","visible","onBack","onClose","others","useDevice","isDesktop","useEffect","document","body","style","renderer","IS_JEST","jsx","ReactDOM","createPortal","testId","styles","container","modal","calcWidth","className","header","undefined","ICON","LEFT","icon","left","right","CLOSE","EXPAND_MORE","propTypes","PropTypes","bool","node","string","func"],"sources":["../../../src/components/Modal/Modal.jsx"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React, { useEffect } from 'react';\nimport ReactDOM from 'react-dom';\n\nimport { IS_JEST, styles } from '../../helpers';\nimport { useDevice } from '../../hooks';\nimport { Icon, ICON, Pressable, Text, View } from '../../primitives';\nimport style from './Modal.module.css';\n\nconst Modal = ({\n blur = false,\n children,\n fit = false,\n overflow = true,\n portal = false,\n title,\n visible,\n onBack,\n onClose,\n ...others\n}) => {\n const { isDesktop } = useDevice();\n\n useEffect(() => {\n document.body.style.overflow = visible ? 'hidden' : 'inherit';\n }, [visible]);\n\n const renderer = IS_JEST || !portal ? (jsx) => jsx : ReactDOM.createPortal;\n\n const { ['data-testid']: testId } = others;\n\n return renderer(\n <View\n row\n className={styles(\n style.container,\n overflow && style.overflow,\n overflow && blur && style.blur,\n visible && style.visible,\n )}\n >\n <View\n {...others}\n fit\n className={styles(style.modal, !fit && style.calcWidth, visible && style.visible, others.className)}\n >\n {(title || onBack || onClose) && (\n <View row className={style.header}>\n {onBack && (\n <Pressable onPress={onBack} data-testid={testId ? `${testId}-button-back` : undefined}>\n <Icon value={ICON.LEFT} className={style.icon} />\n </Pressable>\n )}\n {title && (\n <Text headline className={styles(style.title, !onBack && style.left, !onClose && style.right)}>\n {title}\n </Text>\n )}\n {onClose && (\n <Pressable onPress={onClose} data-testid={testId ? `${testId}-button-close` : undefined}>\n <Icon value={isDesktop || title !== undefined ? ICON.CLOSE : ICON.EXPAND_MORE} className={style.icon} />\n </Pressable>\n )}\n </View>\n )}\n {children}\n </View>\n </View>,\n document.body,\n );\n};\n\nModal.propTypes = {\n blur: PropTypes.bool,\n children: PropTypes.node,\n fit: PropTypes.bool,\n overflow: PropTypes.bool,\n portal: PropTypes.bool,\n title: PropTypes.string,\n visible: PropTypes.bool,\n onBack: PropTypes.func,\n onClose: PropTypes.func,\n};\n\nexport { Modal };\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEvC,IAAMA,KAAK,GAAG,SAARA,KAAK,OAWL;EAAA,qBAVJC,IAAI;IAAJA,IAAI,0BAAG,KAAK;IACZC,QAAQ,QAARA,QAAQ;IAAA,gBACRC,GAAG;IAAHA,GAAG,yBAAG,KAAK;IAAA,qBACXC,QAAQ;IAARA,QAAQ,8BAAG,IAAI;IAAA,mBACfC,MAAM;IAANA,MAAM,4BAAG,KAAK;IACdC,KAAK,QAALA,KAAK;IACLC,OAAO,QAAPA,OAAO;IACPC,MAAM,QAANA,MAAM;IACNC,OAAO,QAAPA,OAAO;IACJC,MAAM;EAET,iBAAsB,IAAAC,gBAAS,GAAE;IAAzBC,SAAS,cAATA,SAAS;EAEjB,IAAAC,gBAAS,EAAC,YAAM;IACdC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAACZ,QAAQ,GAAGG,OAAO,GAAG,QAAQ,GAAG,SAAS;EAC/D,CAAC,EAAE,CAACA,OAAO,CAAC,CAAC;EAEb,IAAMU,QAAQ,GAAGC,gBAAO,IAAI,CAACb,MAAM,GAAG,UAACc,GAAG;IAAA,OAAKA,GAAG;EAAA,IAAGC,iBAAQ,CAACC,YAAY;EAE1E,IAAyBC,MAAM,GAAKZ,MAAM,CAAjC,aAAa;EAEtB,OAAOO,QAAQ,eACb,6BAAC,gBAAI;IACH,GAAG;IACH,SAAS,EAAE,IAAAM,eAAM,EACfP,oBAAK,CAACQ,SAAS,EACfpB,QAAQ,IAAIY,oBAAK,CAACZ,QAAQ,EAC1BA,QAAQ,IAAIH,IAAI,IAAIe,oBAAK,CAACf,IAAI,EAC9BM,OAAO,IAAIS,oBAA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kBAAS,CAACC,IAAI;EACpBrC,QAAQ,EAAEoC,kBAAS,CAACE,IAAI;EACxBrC,GAAG,EAAEmC,kBAAS,CAACC,IAAI;EACnBnC,QAAQ,EAAEkC,kBAAS,CAACC,IAAI;EACxBlC,MAAM,EAAEiC,kBAAS,CAACC,IAAI;EACtBjC,KAAK,EAAEgC,kBAAS,CAACG,MAAM;EACvBlC,OAAO,EAAE+B,kBAAS,CAACC,IAAI;EACvB/B,MAAM,EAAE8B,kBAAS,CAACI,IAAI;EACtBjC,OAAO,EAAE6B,kBAAS,CAACI;AACrB,CAAC"}
1
+ {"version":3,"file":"Modal.js","names":["Modal","blur","children","fit","overflow","portal","title","visible","onBack","onClose","onOverflow","others","useDevice","isDesktop","useState","dataset","setDataset","useEffect","document","body","miraiModal","undefined","renderer","IS_JEST","jsx","ReactDOM","createPortal","testId","styles","style","container","modal","calcWidth","className","header","ICON","LEFT","icon","left","right","CLOSE","EXPAND_MORE","propTypes","PropTypes","bool","node","string","func"],"sources":["../../../src/components/Modal/Modal.jsx"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React, { useEffect, useState } from 'react';\nimport ReactDOM from 'react-dom';\n\nimport { IS_JEST, styles } from '../../helpers';\nimport { useDevice } from '../../hooks';\nimport { Icon, ICON, Pressable, Text, View } from '../../primitives';\nimport style from './Modal.module.css';\n\nconst Modal = ({\n blur = false,\n children,\n fit = false,\n overflow = true,\n portal = false,\n title,\n visible,\n onBack,\n onClose,\n onOverflow,\n ...others\n}) => {\n const { isDesktop } = useDevice();\n\n const [dataset, setDataset] = useState();\n\n useEffect(() => {\n if (visible && !dataset) {\n setDataset(true);\n document.body.dataset.miraiModal = true;\n }\n\n return () => {\n if (visible && dataset) {\n setDataset(undefined);\n delete document.body.dataset.miraiModal;\n }\n };\n }, [dataset, visible]);\n\n const renderer = IS_JEST || !portal ? (jsx) => jsx : ReactDOM.createPortal;\n\n const { ['data-testid']: testId } = others;\n\n return renderer(\n <Pressable\n className={styles(\n style.container,\n overflow && style.overflow,\n overflow && blur && style.blur,\n visible && style.visible,\n )}\n preventDefault\n onPress={visible && overflow ? onOverflow : undefined}\n data-testid={testId ? `${testId}-overflow` : undefined}\n >\n <View\n {...others}\n fit\n className={styles(style.modal, !fit && style.calcWidth, visible && style.visible, others.className)}\n >\n {(title || onBack || onClose) && (\n <View row className={style.header}>\n {onBack && (\n <Pressable preventDefault onPress={onBack} data-testid={testId ? `${testId}-button-back` : undefined}>\n <Icon value={ICON.LEFT} className={style.icon} />\n </Pressable>\n )}\n {title && (\n <Text headline className={styles(style.title, !onBack && style.left, !onClose && style.right)}>\n {title}\n </Text>\n )}\n {onClose && (\n <Pressable preventDefault onPress={onClose} data-testid={testId ? `${testId}-button-close` : undefined}>\n <Icon value={isDesktop || title !== undefined ? ICON.CLOSE : ICON.EXPAND_MORE} className={style.icon} />\n </Pressable>\n )}\n </View>\n )}\n {children}\n </View>\n </Pressable>,\n document.body,\n );\n};\n\nModal.propTypes = {\n blur: PropTypes.bool,\n children: PropTypes.node,\n fit: PropTypes.bool,\n overflow: PropTypes.bool,\n portal: PropTypes.bool,\n title: PropTypes.string,\n visible: PropTypes.bool,\n onBack: PropTypes.func,\n onClose: PropTypes.func,\n};\n\nexport { Modal };\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEvC,IAAMA,KAAK,GAAG,SAARA,KAAK,OAYL;EAAA,qBAXJC,IAAI;IAAJA,IAAI,0BAAG,KAAK;IACZC,QAAQ,QAARA,QAAQ;IAAA,gBACRC,GAAG;IAAHA,GAAG,yBAAG,KAAK;IAAA,qBACXC,QAAQ;IAARA,QAAQ,8BAAG,IAAI;IAAA,mBACfC,MAAM;IAANA,MAAM,4BAAG,KAAK;IACdC,KAAK,QAALA,KAAK;IACLC,OAAO,QAAPA,OAAO;IACPC,MAAM,QAANA,MAAM;IAC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,kBAAS,CAACC,IAAI;EACnBxC,QAAQ,EAAEuC,kBAAS,CAACC,IAAI;EACxBvC,MAAM,EAAEsC,kBAAS,CAACC,IAAI;EACtBtC,KAAK,EAAEqC,kBAAS,CAACG,MAAM;EACvBvC,OAAO,EAAEoC,kBAAS,CAACC,IAAI;EACvBpC,MAAM,EAAEmC,kBAAS,CAACI,IAAI;EACtBtC,OAAO,EAAEkC,kBAAS,CAACI;AACrB,CAAC"}
@@ -1,4 +1,9 @@
1
+ [data-mirai-modal] {
2
+ overflow: hidden;
3
+ }
4
+
1
5
  .container {
6
+ display: flex;
2
7
  height: 100vh;
3
8
  justify-content: center;
4
9
  left: 0;
@@ -37,6 +37,9 @@ Story.argTypes = {
37
37
  },
38
38
  onClose: {
39
39
  action: 'onClose'
40
+ },
41
+ onOverflow: {
42
+ action: 'onOverflow'
40
43
  }
41
44
  };
42
45
  //# sourceMappingURL=Modal.stories.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.stories.js","names":["title","Story","props","storyName","args","blur","fit","overflow","portal","visible","argTypes","onBack","action","onClose"],"sources":["../../../src/components/Modal/Modal.stories.jsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Modal } from './Modal';\n\nexport default { title: 'Components' };\n\nexport const Story = (props) => (\n <Modal {...props}>\n <span className=\"children\">children</span>\n </Modal>\n);\n\nStory.storyName = 'Modal';\n\nStory.args = {\n blur: false,\n fit: false,\n overflow: true,\n portal: false,\n title: 'title',\n visible: true,\n ['data-testid']: 'test-story',\n};\n\nStory.argTypes = {\n onBack: { action: 'onBack' },\n onClose: { action: 'onClose' },\n};\n"],"mappings":";;;;;;AAAA;AAEA;AAAgC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAEjB;EAAEA,KAAK,EAAE;AAAa,CAAC;AAAA;AAE/B,IAAMC,KAAK,GAAG,SAARA,KAAK,CAAIC,KAAK;EAAA,oBACzB,oBAAC,YAAK,EAAKA,KAAK,eACd;IAAM,SAAS,EAAC;EAAU,cAAgB,CACpC;AAAA,CACT;AAAC;AAEFD,KAAK,CAACE,SAAS,GAAG,OAAO;AAEzBF,KAAK,CAACG,IAAI;EACRC,IAAI,EAAE,KAAK;EACXC,GAAG,EAAE,KAAK;EACVC,QAAQ,EAAE,IAAI;EACdC,MAAM,EAAE,KAAK;EACbR,KAAK,EAAE,OAAO;EACdS,OAAO,EAAE;AAAI,GACZ,aAAa,EAAG,YAAY,CAC9B;AAEDR,KAAK,CAACS,QAAQ,GAAG;EACfC,MAAM,EAAE;IAAEC,MAAM,EAAE;EAAS,CAAC;EAC5BC,OAAO,EAAE;IAAED,MAAM,EAAE;EAAU;AAC/B,CAAC"}
1
+ {"version":3,"file":"Modal.stories.js","names":["title","Story","props","storyName","args","blur","fit","overflow","portal","visible","argTypes","onBack","action","onClose","onOverflow"],"sources":["../../../src/components/Modal/Modal.stories.jsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Modal } from './Modal';\n\nexport default { title: 'Components' };\n\nexport const Story = (props) => (\n <Modal {...props}>\n <span className=\"children\">children</span>\n </Modal>\n);\n\nStory.storyName = 'Modal';\n\nStory.args = {\n blur: false,\n fit: false,\n overflow: true,\n portal: false,\n title: 'title',\n visible: true,\n ['data-testid']: 'test-story',\n};\n\nStory.argTypes = {\n onBack: { action: 'onBack' },\n onClose: { action: 'onClose' },\n onOverflow: { action: 'onOverflow' },\n};\n"],"mappings":";;;;;;AAAA;AAEA;AAAgC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAEjB;EAAEA,KAAK,EAAE;AAAa,CAAC;AAAA;AAE/B,IAAMC,KAAK,GAAG,SAARA,KAAK,CAAIC,KAAK;EAAA,oBACzB,oBAAC,YAAK,EAAKA,KAAK,eACd;IAAM,SAAS,EAAC;EAAU,cAAgB,CACpC;AAAA,CACT;AAAC;AAEFD,KAAK,CAACE,SAAS,GAAG,OAAO;AAEzBF,KAAK,CAACG,IAAI;EACRC,IAAI,EAAE,KAAK;EACXC,GAAG,EAAE,KAAK;EACVC,QAAQ,EAAE,IAAI;EACdC,MAAM,EAAE,KAAK;EACbR,KAAK,EAAE,OAAO;EACdS,OAAO,EAAE;AAAI,GACZ,aAAa,EAAG,YAAY,CAC9B;AAEDR,KAAK,CAACS,QAAQ,GAAG;EACfC,MAAM,EAAE;IAAEC,MAAM,EAAE;EAAS,CAAC;EAC5BC,OAAO,EAAE;IAAED,MAAM,EAAE;EAAU,CAAC;EAC9BE,UAAU,EAAE;IAAEF,MAAM,EAAE;EAAa;AACrC,CAAC"}
@@ -2,8 +2,9 @@
2
2
 
3
3
  exports[`component:<Modal> Mobile environment prop:onClose 1`] = `
4
4
  <DocumentFragment>
5
- <div
6
- class="view row container overflow visible"
5
+ <button
6
+ class="pressable container overflow visible"
7
+ data-testid="mirai-onClose-overflow"
7
8
  >
8
9
  <div
9
10
  class="view fit modal calcWidth visible"
@@ -11,68 +12,67 @@ exports[`component:<Modal> Mobile environment prop:onClose 1`] = `
11
12
  >
12
13
  <div
13
14
  class="view row header"
14
- >
15
- <button
16
- class="pressable"
17
- data-testid="mirai-onClose-button-close"
18
- >
19
- <span
20
- class="icon headline-3 icon"
21
- >
22
- <svg
23
- fill="currentColor"
24
- height="1em"
25
- stroke="currentColor"
26
- stroke-width="0"
27
- viewBox="0 0 24 24"
28
- width="1em"
29
- xmlns="http://www.w3.org/2000/svg"
30
- >
31
- <path
32
- d="M24 24H0V0h24v24z"
33
- fill="none"
34
- opacity=".87"
35
- />
36
- <path
37
- d="M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6-1.41-1.41z"
38
- />
39
- </svg>
40
- </span>
41
- </button>
42
- </div>
15
+ />
43
16
  </div>
44
- </div>
17
+ </button>
18
+ <button
19
+ class="pressable"
20
+ data-testid="mirai-onClose-button-close"
21
+ >
22
+ <span
23
+ class="icon headline-3 icon"
24
+ >
25
+ <svg
26
+ fill="currentColor"
27
+ height="1em"
28
+ stroke="currentColor"
29
+ stroke-width="0"
30
+ viewBox="0 0 24 24"
31
+ width="1em"
32
+ xmlns="http://www.w3.org/2000/svg"
33
+ >
34
+ <path
35
+ d="M24 24H0V0h24v24z"
36
+ fill="none"
37
+ opacity=".87"
38
+ />
39
+ <path
40
+ d="M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6-1.41-1.41z"
41
+ />
42
+ </svg>
43
+ </span>
44
+ </button>
45
45
  </DocumentFragment>
46
46
  `;
47
47
 
48
48
  exports[`component:<Modal> Mobile environment prop:visible 1`] = `
49
49
  <DocumentFragment>
50
- <div
51
- class="view row container overflow visible"
50
+ <button
51
+ class="pressable container overflow visible"
52
52
  >
53
53
  <div
54
54
  class="view fit modal calcWidth visible"
55
55
  />
56
- </div>
56
+ </button>
57
57
  </DocumentFragment>
58
58
  `;
59
59
 
60
60
  exports[`component:<Modal> inherit:className 1`] = `
61
61
  <DocumentFragment>
62
- <div
63
- class="view row container overflow"
62
+ <button
63
+ class="pressable container overflow"
64
64
  >
65
65
  <div
66
66
  class="view fit modal calcWidth mirai"
67
67
  />
68
- </div>
68
+ </button>
69
69
  </DocumentFragment>
70
70
  `;
71
71
 
72
72
  exports[`component:<Modal> prop:children 1`] = `
73
73
  <DocumentFragment>
74
- <div
75
- class="view row container overflow"
74
+ <button
75
+ class="pressable container overflow"
76
76
  >
77
77
  <div
78
78
  class="view fit modal calcWidth"
@@ -81,26 +81,27 @@ exports[`component:<Modal> prop:children 1`] = `
81
81
  children
82
82
  </span>
83
83
  </div>
84
- </div>
84
+ </button>
85
85
  </DocumentFragment>
86
86
  `;
87
87
 
88
88
  exports[`component:<Modal> prop:fit 1`] = `
89
89
  <DocumentFragment>
90
- <div
91
- class="view row container overflow"
90
+ <button
91
+ class="pressable container overflow"
92
92
  >
93
93
  <div
94
94
  class="view fit modal"
95
95
  />
96
- </div>
96
+ </button>
97
97
  </DocumentFragment>
98
98
  `;
99
99
 
100
100
  exports[`component:<Modal> prop:onBack 1`] = `
101
101
  <DocumentFragment>
102
- <div
103
- class="view row container overflow visible"
102
+ <button
103
+ class="pressable container overflow visible"
104
+ data-testid="mirai-onBack-overflow"
104
105
  >
105
106
  <div
106
107
  class="view fit modal calcWidth visible"
@@ -108,43 +109,43 @@ exports[`component:<Modal> prop:onBack 1`] = `
108
109
  >
109
110
  <div
110
111
  class="view row header"
111
- >
112
- <button
113
- class="pressable"
114
- data-testid="mirai-onBack-button-back"
115
- >
116
- <span
117
- class="icon headline-3 icon"
118
- >
119
- <svg
120
- fill="currentColor"
121
- height="1em"
122
- stroke="currentColor"
123
- stroke-width="0"
124
- viewBox="0 0 24 24"
125
- width="1em"
126
- xmlns="http://www.w3.org/2000/svg"
127
- >
128
- <path
129
- d="M0 0h24v24H0V0z"
130
- fill="none"
131
- />
132
- <path
133
- d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"
134
- />
135
- </svg>
136
- </span>
137
- </button>
138
- </div>
112
+ />
139
113
  </div>
140
- </div>
114
+ </button>
115
+ <button
116
+ class="pressable"
117
+ data-testid="mirai-onBack-button-back"
118
+ >
119
+ <span
120
+ class="icon headline-3 icon"
121
+ >
122
+ <svg
123
+ fill="currentColor"
124
+ height="1em"
125
+ stroke="currentColor"
126
+ stroke-width="0"
127
+ viewBox="0 0 24 24"
128
+ width="1em"
129
+ xmlns="http://www.w3.org/2000/svg"
130
+ >
131
+ <path
132
+ d="M0 0h24v24H0V0z"
133
+ fill="none"
134
+ />
135
+ <path
136
+ d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"
137
+ />
138
+ </svg>
139
+ </span>
140
+ </button>
141
141
  </DocumentFragment>
142
142
  `;
143
143
 
144
144
  exports[`component:<Modal> prop:onClose 1`] = `
145
145
  <DocumentFragment>
146
- <div
147
- class="view row container overflow visible"
146
+ <button
147
+ class="pressable container overflow visible"
148
+ data-testid="mirai-onClose-overflow"
148
149
  >
149
150
  <div
150
151
  class="view fit modal calcWidth visible"
@@ -152,56 +153,69 @@ exports[`component:<Modal> prop:onClose 1`] = `
152
153
  >
153
154
  <div
154
155
  class="view row header"
155
- >
156
- <button
157
- class="pressable"
158
- data-testid="mirai-onClose-button-close"
159
- >
160
- <span
161
- class="icon headline-3 icon"
162
- >
163
- <svg
164
- fill="currentColor"
165
- height="1em"
166
- stroke="currentColor"
167
- stroke-width="0"
168
- viewBox="0 0 24 24"
169
- width="1em"
170
- xmlns="http://www.w3.org/2000/svg"
171
- >
172
- <path
173
- d="M24 24H0V0h24v24z"
174
- fill="none"
175
- opacity=".87"
176
- />
177
- <path
178
- d="M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6-1.41-1.41z"
179
- />
180
- </svg>
181
- </span>
182
- </button>
183
- </div>
156
+ />
184
157
  </div>
185
- </div>
158
+ </button>
159
+ <button
160
+ class="pressable"
161
+ data-testid="mirai-onClose-button-close"
162
+ >
163
+ <span
164
+ class="icon headline-3 icon"
165
+ >
166
+ <svg
167
+ fill="currentColor"
168
+ height="1em"
169
+ stroke="currentColor"
170
+ stroke-width="0"
171
+ viewBox="0 0 24 24"
172
+ width="1em"
173
+ xmlns="http://www.w3.org/2000/svg"
174
+ >
175
+ <path
176
+ d="M24 24H0V0h24v24z"
177
+ fill="none"
178
+ opacity=".87"
179
+ />
180
+ <path
181
+ d="M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6-1.41-1.41z"
182
+ />
183
+ </svg>
184
+ </span>
185
+ </button>
186
+ </DocumentFragment>
187
+ `;
188
+
189
+ exports[`component:<Modal> prop:onOverflow 1`] = `
190
+ <DocumentFragment>
191
+ <button
192
+ class="pressable container overflow visible"
193
+ data-testid="mirai-onOverflow-overflow"
194
+ >
195
+ <div
196
+ class="view fit modal calcWidth visible"
197
+ data-testid="mirai-onOverflow"
198
+ />
199
+ </button>
186
200
  </DocumentFragment>
187
201
  `;
188
202
 
189
203
  exports[`component:<Modal> prop:portal 1`] = `
190
204
  <DocumentFragment>
191
- <div
192
- class="view row container overflow"
205
+ <button
206
+ class="pressable container overflow"
193
207
  >
194
208
  <div
195
209
  class="view fit modal calcWidth"
196
210
  />
197
- </div>
211
+ </button>
198
212
  </DocumentFragment>
199
213
  `;
200
214
 
201
215
  exports[`component:<Modal> prop:title 1`] = `
202
216
  <DocumentFragment>
203
- <div
204
- class="view row container overflow"
217
+ <button
218
+ class="pressable container overflow"
205
219
  >
206
220
  <div
207
221
  class="view fit modal calcWidth"
@@ -216,67 +230,68 @@ exports[`component:<Modal> prop:title 1`] = `
216
230
  </h3>
217
231
  </div>
218
232
  </div>
219
- </div>
233
+ </button>
220
234
  </DocumentFragment>
221
235
  `;
222
236
 
223
237
  exports[`component:<Modal> prop:visible & prop:blur 1`] = `
224
238
  <DocumentFragment>
225
- <div
226
- class="view row container overflow blur visible"
239
+ <button
240
+ class="pressable container overflow blur visible"
227
241
  >
228
242
  <div
229
243
  class="view fit modal calcWidth visible"
230
244
  />
231
- </div>
245
+ </button>
232
246
  </DocumentFragment>
233
247
  `;
234
248
 
235
249
  exports[`component:<Modal> prop:visible & prop:overflow (false) 1`] = `
236
250
  <DocumentFragment>
237
- <div
238
- class="view row container visible"
251
+ <button
252
+ class="pressable container visible"
239
253
  >
240
254
  <div
241
255
  class="view fit modal calcWidth visible"
242
256
  />
243
- </div>
257
+ </button>
244
258
  </DocumentFragment>
245
259
  `;
246
260
 
247
261
  exports[`component:<Modal> prop:visible renders 1`] = `
248
262
  <DocumentFragment>
249
- <div
250
- class="view row container overflow visible"
263
+ <button
264
+ class="pressable container overflow visible"
251
265
  >
252
266
  <div
253
267
  class="view fit modal calcWidth visible"
254
268
  />
255
- </div>
269
+ </button>
256
270
  </DocumentFragment>
257
271
  `;
258
272
 
259
273
  exports[`component:<Modal> renders 1`] = `
260
274
  <DocumentFragment>
261
- <div
262
- class="view row container overflow"
275
+ <button
276
+ class="pressable container overflow"
263
277
  >
264
278
  <div
265
279
  class="view fit modal calcWidth"
266
280
  />
267
- </div>
281
+ </button>
268
282
  </DocumentFragment>
269
283
  `;
270
284
 
271
285
  exports[`component:<Modal> testID 1`] = `
272
286
  <DocumentFragment>
273
- <div
274
- class="view row container overflow"
287
+ <button
288
+ class="pressable container overflow"
289
+ data-testid="mirai-overflow"
275
290
  >
276
291
  <div
277
292
  class="view fit modal calcWidth"
278
293
  data-testid="mirai"
279
294
  />
280
- </div>
295
+ </button>
281
296
  </DocumentFragment>
282
297
  `;
@@ -10,7 +10,8 @@ var _react = _interopRequireWildcard(require("react"));
10
10
  var _helpers = require("../../helpers");
11
11
  var _primitives = require("../../primitives");
12
12
  var _TooltipModule = _interopRequireDefault(require("./Tooltip.module.css"));
13
- var _excluded = ["children", "Template", "text"];
13
+ var _excluded = ["children", "Template", "text"],
14
+ _excluded2 = ["data-testid"];
14
15
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
16
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
16
17
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -37,26 +38,28 @@ var Tooltip = function Tooltip(_ref) {
37
38
  _useState2 = _slicedToArray(_useState, 2),
38
39
  visible = _useState2[0],
39
40
  setVisible = _useState2[1];
40
- return /*#__PURE__*/_react.default.createElement(_primitives.Layer, _extends({
41
- forceRender: false
42
- }, others, {
41
+ var testId = others['data-testid'],
42
+ rest = _objectWithoutProperties(others, _excluded2);
43
+ return /*#__PURE__*/_react.default.createElement(_primitives.Layer, {
43
44
  centered: true,
44
- visible: visible
45
- }), _react.default.Children.map(children, function (child, index) {
45
+ forceRender: false,
46
+ visible: visible,
47
+ "data-testid": testId
48
+ }, _react.default.Children.map(children, function (child, index) {
46
49
  return /*#__PURE__*/_react.default.cloneElement(child, _objectSpread(_objectSpread({}, child.props), {}, {
47
50
  key: index,
48
- 'data-testid': others['data-testid'] ? "".concat(others['data-testid'], "-dispatcher") : undefined,
49
- className: (0, _helpers.styles)(_TooltipModule.default.dispatcher, child.props.className),
50
51
  onMouseEnter: function onMouseEnter() {
51
52
  return setVisible(true);
52
53
  },
53
54
  onMouseLeave: function onMouseLeave() {
54
55
  return setVisible(false);
55
- }
56
+ },
57
+ className: (0, _helpers.styles)(_TooltipModule.default.dispatcher, child.props.className),
58
+ 'data-testid': testId ? "".concat(testId, "-dispatcher") : undefined
56
59
  }));
57
- }), /*#__PURE__*/_react.default.createElement(_primitives.LayerContent, null, /*#__PURE__*/_react.default.createElement(_primitives.View, {
58
- className: _TooltipModule.default.tooltip
59
- }, Template ? /*#__PURE__*/_react.default.createElement(Template, null) : /*#__PURE__*/_react.default.createElement(_primitives.Text, {
60
+ }), /*#__PURE__*/_react.default.createElement(_primitives.LayerContent, null, /*#__PURE__*/_react.default.createElement(_primitives.View, _extends({}, rest, {
61
+ className: (0, _helpers.styles)(_TooltipModule.default.tooltip, rest.className)
62
+ }), Template ? /*#__PURE__*/_react.default.createElement(Template, null) : /*#__PURE__*/_react.default.createElement(_primitives.Text, {
60
63
  bold: true,
61
64
  small: true,
62
65
  className: _TooltipModule.default.text
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.js","names":["Tooltip","children","Template","text","others","useState","visible","setVisible","React","Children","map","child","index","cloneElement","props","key","undefined","className","styles","style","dispatcher","onMouseEnter","onMouseLeave","tooltip","displayName","propTypes","PropTypes","node","oneOfType","func","string","bool"],"sources":["../../../src/components/Tooltip/Tooltip.jsx"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React, { useState } from 'react';\n\nimport { styles } from '../../helpers';\nimport { Layer, LayerContent, Text, View } from '../../primitives';\nimport style from './Tooltip.module.css';\n\nconst Tooltip = ({ children, Template, text, ...others }) => {\n const [visible, setVisible] = useState(others.visible || false);\n\n return (\n <Layer forceRender={false} {...others} centered visible={visible}>\n {React.Children.map(children, (child, index) =>\n React.cloneElement(child, {\n ...child.props,\n key: index,\n 'data-testid': others['data-testid'] ? `${others['data-testid']}-dispatcher` : undefined,\n className: styles(style.dispatcher, child.props.className),\n onMouseEnter: () => setVisible(true),\n onMouseLeave: () => setVisible(false),\n }),\n )}\n\n <LayerContent>\n <View className={style.tooltip}>\n {Template ? (\n <Template />\n ) : (\n <Text bold small className={style.text}>\n {text}\n </Text>\n )}\n </View>\n </LayerContent>\n </Layer>\n );\n};\n\nTooltip.displayName = 'Component:Tooltip';\n\nTooltip.propTypes = {\n children: PropTypes.node,\n Template: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),\n text: PropTypes.string,\n visible: PropTypes.bool,\n};\n\nexport { Tooltip };\n"],"mappings":";;;;;;;AAAA;AACA;AAEA;AACA;AACA;AAAyC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEzC,IAAMA,OAAO,GAAG,SAAVA,OAAO,OAAgD;EAAA,IAA1CC,QAAQ,QAARA,QAAQ;IAAEC,QAAQ,QAARA,QAAQ;IAAEC,IAAI,QAAJA,IAAI;IAAKC,MAAM;EACpD,gBAA8B,IAAAC,eAAQ,EAACD,MAAM,CAACE,OAAO,IAAI,KAAK,CAAC;IAAA;IAAxDA,OAAO;IAAEC,UAAU;EAE1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names":["Tooltip","children","Template","text","others","useState","visible","setVisible","testId","rest","React","Children","map","child","index","cloneElement","props","key","onMouseEnter","onMouseLeave","className","styles","style","dispatcher","undefined","tooltip","displayName","propTypes","PropTypes","node","oneOfType","func","string","bool"],"sources":["../../../src/components/Tooltip/Tooltip.jsx"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React, { useState } from 'react';\n\nimport { styles } from '../../helpers';\nimport { Layer, LayerContent, Text, View } from '../../primitives';\nimport style from './Tooltip.module.css';\n\nconst Tooltip = ({ children, Template, text, ...others }) => {\n const [visible, setVisible] = useState(others.visible || false);\n\n const { ['data-testid']: testId, ...rest } = others;\n\n return (\n <Layer centered forceRender={false} visible={visible} data-testid={testId}>\n {React.Children.map(children, (child, index) =>\n React.cloneElement(child, {\n ...child.props,\n key: index,\n onMouseEnter: () => setVisible(true),\n onMouseLeave: () => setVisible(false),\n className: styles(style.dispatcher, child.props.className),\n 'data-testid': testId ? `${testId}-dispatcher` : undefined,\n }),\n )}\n\n <LayerContent>\n <View {...rest} className={styles(style.tooltip, rest.className)}>\n {Template ? (\n <Template />\n ) : (\n <Text bold small className={style.text}>\n {text}\n </Text>\n )}\n </View>\n </LayerContent>\n </Layer>\n );\n};\n\nTooltip.displayName = 'Component:Tooltip';\n\nTooltip.propTypes = {\n children: PropTypes.node,\n Template: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),\n text: PropTypes.string,\n visible: PropTypes.bool,\n};\n\nexport { Tooltip };\n"],"mappings":";;;;;;;AAAA;AACA;AAEA;AACA;AACA;AAAyC;EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEzC,IAAMA,OAAO,GAAG,SAAVA,OAAO,OAAgD;EAAA,IAA1CC,QAAQ,QAARA,QAAQ;IAAEC,QAAQ,QAARA,QAAQ;IAAEC,IAAI,QAAJA,IAAI;IAAKC,MAAM;EACpD,gBAA8B,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BAAS,CAACE,SAAS,CAAC,CAACF,kBAAS,CAACC,IAAI,EAAED,kBAAS,CAACG,IAAI,CAAC,CAAC;EAC/D5B,IAAI,EAAEyB,kBAAS,CAACI,MAAM;EACtB1B,OAAO,EAAEsB,kBAAS,CAACK;AACrB,CAAC"}
@@ -14,5 +14,4 @@
14
14
 
15
15
  .tooltip .text {
16
16
  color: var(--mirai-ui-tooltip-color);
17
- text-align: center;
18
17
  }
@@ -36,12 +36,18 @@ var Pressable = function Pressable(_ref) {
36
36
  className: (0, _helpers.styles)(_PressableModule.default.pressable, others.className)
37
37
  }, !disabled ? {
38
38
  onClick: function onClick(event) {
39
- if (preventDefault) event.preventDefault();
39
+ if (preventDefault) {
40
+ event.preventDefault();
41
+ event.stopPropagation();
42
+ }
40
43
  onPress(event);
41
44
  },
42
45
  onKeyPress: function onKeyPress(event) {
43
46
  if (event.keyCode === _Pressable.KEY_ENTER) {
44
- if (preventDefault) event.preventDefault();
47
+ if (preventDefault) {
48
+ event.preventDefault();
49
+ event.stopPropagation();
50
+ }
45
51
  onPress(event);
46
52
  }
47
53
  },
@@ -1 +1 @@
1
- {"version":3,"file":"Pressable.js","names":["Pressable","children","disabled","preventDefault","tag","onEnter","onLeave","onPress","others","React","createElement","className","styles","style","pressable","onClick","event","onKeyPress","keyCode","KEY_ENTER","onMouseEnter","onMouseLeave","displayName","propTypes","PropTypes","oneOfType","string","node","bool","func"],"sources":["../../../src/primitives/Pressable/Pressable.jsx"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React from 'react';\n\nimport { styles } from '../../helpers';\nimport { KEY_ENTER } from './Pressable.constants';\nimport style from './Pressable.module.css';\n\nconst Pressable = ({\n children,\n disabled,\n preventDefault = false,\n tag = 'button',\n onEnter,\n onLeave,\n onPress = () => {},\n ...others\n}) =>\n React.createElement(\n tag,\n {\n ...others,\n disabled,\n className: styles(style.pressable, others.className),\n ...(!disabled\n ? {\n onClick: (event) => {\n if (preventDefault) event.preventDefault();\n onPress(event);\n },\n onKeyPress: (event) => {\n if (event.keyCode === KEY_ENTER) {\n if (preventDefault) event.preventDefault();\n onPress(event);\n }\n },\n onMouseEnter: onEnter,\n onMouseLeave: onLeave,\n }\n : {}),\n },\n children,\n );\n\nPressable.displayName = 'Primitive:Pressable';\n\nPressable.propTypes = {\n children: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),\n disabled: PropTypes.bool,\n preventDefault: PropTypes.bool,\n tag: PropTypes.string,\n onEnter: PropTypes.func,\n onLeave: PropTypes.func,\n onPress: PropTypes.func,\n};\n\nexport { Pressable };\n"],"mappings":";;;;;;;AAAA;AACA;AAEA;AACA;AACA;AAA2C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAE3C,IAAMA,SAAS,GAAG,SAAZA,SAAS;EAAA,IACbC,QAAQ,QAARA,QAAQ;IACRC,QAAQ,QAARA,QAAQ;IAAA,2BACRC,cAAc;IAAdA,cAAc,oCAAG,KAAK;IAAA,gBACtBC,GAAG;IAAHA,GAAG,yBAAG,QAAQ;IACdC,OAAO,QAAPA,OAAO;IACPC,OAAO,QAAPA,OAAO;IAAA,oBACPC,OAAO;IAAPA,OAAO,6BAAG,YAAM,CAAC,CAAC;IACfC,MAAM;EAAA,oBAETC,cAAK,CAACC,aAAa,CACjBN,GAAG,kCAEEI,MAAM;IACTN,QAAQ,EAARA,QAAQ;IACRS,SAAS,EAAE,IAAAC,eAAM,EAACC,wBAAK,CAACC,SAAS,EAAEN,MAAM,CAACG,SAAS;EAAC,GAChD,CAACT,QAAQ,GACT;IACEa,OAAO,EAAE,iBAACC,KAAK,EAAK;MAClB,IAAIb,cAAc,EAAEa,KAAK,CAACb,cAAc,EAAE;MAC1CI,OAAO,CAACS,KAAK,CAAC;IAChB,CAAC;IACDC,UAAU,EAAE,oBAACD,KAAK,EAAK;MACrB,IAAIA,KAAK,CAACE,OAAO,KAAKC,oBAAS,EAAE;QAC/B,IAAIhB,cAAc,EAAEa,KAAK,CAACb,cAAc,EAAE;QAC1CI,OAAO,CAACS,KAAK,CAAC;MAChB;IACF,CAAC;IACDI,YAAY,EAAEf,OAAO;IACrBgB,YAAY,EAAEf;EAChB,CAAC,GACD,CAAC,CAAC,GAERL,QAAQ,CACT;AAAA;AAAC;AAEJD,SAAS,CAACsB,WAAW,GAAG,qBAAqB;AAE7CtB,SAAS,CAACuB,SAAS,GAAG;EACpBtB,QAAQ,EAAEuB,kBAAS,CAACC,SAAS,CAAC,CAACD,kBAAS,CAACE,MAAM,EAAEF,kBAAS,CAACG,IAAI,CAAC,CAAC;EACjEzB,QAAQ,EAAEsB,kBAAS,CAACI,IAAI;EACxBzB,cAAc,EAAEqB,kBAAS,CAACI,IAAI;EAC9BxB,GAAG,EAAEoB,kBAAS,CAACE,MAAM;EACrBrB,OAAO,EAAEmB,kBAAS,CAACK,IAAI;EACvBvB,OAAO,EAAEkB,kBAAS,CAACK,IAAI;EACvBtB,OAAO,EAAEiB,kBAAS,CAACK;AACrB,CAAC"}
1
+ {"version":3,"file":"Pressable.js","names":["Pressable","children","disabled","preventDefault","tag","onEnter","onLeave","onPress","others","React","createElement","className","styles","style","pressable","onClick","event","stopPropagation","onKeyPress","keyCode","KEY_ENTER","onMouseEnter","onMouseLeave","displayName","propTypes","PropTypes","oneOfType","string","node","bool","func"],"sources":["../../../src/primitives/Pressable/Pressable.jsx"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React from 'react';\n\nimport { styles } from '../../helpers';\nimport { KEY_ENTER } from './Pressable.constants';\nimport style from './Pressable.module.css';\n\nconst Pressable = ({\n children,\n disabled,\n preventDefault = false,\n tag = 'button',\n onEnter,\n onLeave,\n onPress = () => {},\n ...others\n}) =>\n React.createElement(\n tag,\n {\n ...others,\n disabled,\n className: styles(style.pressable, others.className),\n ...(!disabled\n ? {\n onClick: (event) => {\n if (preventDefault) {\n event.preventDefault();\n event.stopPropagation();\n }\n onPress(event);\n },\n onKeyPress: (event) => {\n if (event.keyCode === KEY_ENTER) {\n if (preventDefault) {\n event.preventDefault();\n event.stopPropagation();\n }\n onPress(event);\n }\n },\n onMouseEnter: onEnter,\n onMouseLeave: onLeave,\n }\n : {}),\n },\n children,\n );\n\nPressable.displayName = 'Primitive:Pressable';\n\nPressable.propTypes = {\n children: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),\n disabled: PropTypes.bool,\n preventDefault: PropTypes.bool,\n tag: PropTypes.string,\n onEnter: PropTypes.func,\n onLeave: PropTypes.func,\n onPress: PropTypes.func,\n};\n\nexport { Pressable };\n"],"mappings":";;;;;;;AAAA;AACA;AAEA;AACA;AACA;AAA2C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAE3C,IAAMA,SAAS,GAAG,SAAZA,SAAS;EAAA,IACbC,QAAQ,QAARA,QAAQ;IACRC,QAAQ,QAARA,QAAQ;IAAA,2BACRC,cAAc;IAAdA,cAAc,oCAAG,KAAK;IAAA,gBACtBC,GAAG;IAAHA,GAAG,yBAAG,QAAQ;IACdC,OAAO,QAAPA,OAAO;IACPC,OAAO,QAAPA,OAAO;IAAA,oBACPC,OAAO;IAAPA,OAAO,6BAAG,YAAM,CAAC,CAAC;IACfC,MAAM;EAAA,oBAETC,cAAK,CAACC,aAAa,CACjBN,GAAG,kCAEEI,MAAM;IACTN,QAAQ,EAARA,QAAQ;IACRS,SAAS,EAAE,IAAAC,eAAM,EAACC,wBAAK,CAACC,SAAS,EAAEN,MAAM,CAACG,SAAS;EAAC,GAChD,CAACT,QAAQ,GACT;IACEa,OAAO,EAAE,iBAACC,KAAK,EAAK;MAClB,IAAIb,cAAc,EAAE;QAClBa,KAAK,CAACb,cAAc,EAAE;QACtBa,KAAK,CAACC,eAAe,EAAE;MACzB;MACAV,OAAO,CAACS,KAAK,CAAC;IAChB,CAAC;IACDE,UAAU,EAAE,oBAACF,KAAK,EAAK;MACrB,IAAIA,KAAK,CAACG,OAAO,KAAKC,oBAAS,EAAE;QAC/B,IAAIjB,cAAc,EAAE;UAClBa,KAAK,CAACb,cAAc,EAAE;UACtBa,KAAK,CAACC,eAAe,EAAE;QACzB;QACAV,OAAO,CAACS,KAAK,CAAC;MAChB;IACF,CAAC;IACDK,YAAY,EAAEhB,OAAO;IACrBiB,YAAY,EAAEhB;EAChB,CAAC,GACD,CAAC,CAAC,GAERL,QAAQ,CACT;AAAA;AAAC;AAEJD,SAAS,CAACuB,WAAW,GAAG,qBAAqB;AAE7CvB,SAAS,CAACwB,SAAS,GAAG;EACpBvB,QAAQ,EAAEwB,kBAAS,CAACC,SAAS,CAAC,CAACD,kBAAS,CAACE,MAAM,EAAEF,kBAAS,CAACG,IAAI,CAAC,CAAC;EACjE1B,QAAQ,EAAEuB,kBAAS,CAACI,IAAI;EACxB1B,cAAc,EAAEsB,kBAAS,CAACI,IAAI;EAC9BzB,GAAG,EAAEqB,kBAAS,CAACE,MAAM;EACrBtB,OAAO,EAAEoB,kBAAS,CAACK,IAAI;EACvBxB,OAAO,EAAEmB,kBAAS,CAACK,IAAI;EACvBvB,OAAO,EAAEkB,kBAAS,CAACK;AACrB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mirai/ui",
3
- "version": "1.0.78",
3
+ "version": "1.0.79",
4
4
  "repository": "git@gitlab.com:miraicorp/dev/frontend/ui.git",
5
5
  "author": "JΛVI <hello@soyjavi.com>",
6
6
  "license": "MIT",