@os-design-mobile/menu 1.0.31 → 1.0.35
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/Menu.d.ts.map +1 -1
- package/dist/Menu.js +1 -1
- package/dist/Menu.js.map +1 -1
- package/dist/MenuGroup.d.ts.map +1 -1
- package/dist/MenuGroup.js +1 -1
- package/dist/MenuGroup.js.map +1 -1
- package/package.json +9 -9
package/dist/Menu.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Menu.d.ts","sourceRoot":"","sources":["../src/Menu.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAc,iBAAiB,EAAW,MAAM,OAAO,CAAC;AACtE,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAc,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAO5D,MAAM,WAAW,SAAU,SAAQ,iBAAiB,CAAC,UAAU,CAAC;IAK9D,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAUD,QAAA,MAAM,IAAI,
|
1
|
+
{"version":3,"file":"Menu.d.ts","sourceRoot":"","sources":["../src/Menu.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAc,iBAAiB,EAAW,MAAM,OAAO,CAAC;AACtE,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAc,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAO5D,MAAM,WAAW,SAAU,SAAQ,iBAAiB,CAAC,UAAU,CAAC;IAK9D,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAUD,QAAA,MAAM,IAAI,wEAuCT,CAAC;AAIF,eAAe,IAAI,CAAC"}
|
package/dist/Menu.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends"));var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _react=_interopRequireWildcard(require("react"));var _modal=_interopRequireDefault(require("@os-design-mobile/modal"));var _menuUtils=require("@os-design/menu-utils");var _reactNativeSafeAreaContext=require("react-native-safe-area-context");var _native=_interopRequireDefault(require("@emotion/native"));var _theming=require("@os-design-mobile/theming");var _MenuGroup=_interopRequireDefault(require("./MenuGroup"));var _excluded=["closeOnSelect","onClose","children"];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);}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;}var StyledModal=(0,_native.default)(_modal.default)({paddingLeft:0,paddingRight:0});var Menu=(0,_react.forwardRef)(function(_ref,ref){var _ref$closeOnSelect=_ref.closeOnSelect,closeOnSelect=_ref$closeOnSelect===void 0?true:_ref$closeOnSelect,_ref$onClose=_ref.onClose,onClose=_ref$onClose===void 0?function(){}:_ref$onClose,children=_ref.children,rest=(0,_objectWithoutProperties2.default)(_ref,_excluded);var childrenCount=(0,_react.useMemo)(function(){return _react.default.Children.count(children);},[children]);var
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends"));var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _react=_interopRequireWildcard(require("react"));var _modal=_interopRequireDefault(require("@os-design-mobile/modal"));var _menuUtils=require("@os-design/menu-utils");var _reactNativeSafeAreaContext=require("react-native-safe-area-context");var _native=_interopRequireDefault(require("@emotion/native"));var _theming=require("@os-design-mobile/theming");var _MenuGroup=_interopRequireDefault(require("./MenuGroup"));var _excluded=["closeOnSelect","onClose","children"];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);}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;}var StyledModal=(0,_native.default)(_modal.default)({paddingLeft:0,paddingRight:0});var Menu=(0,_react.forwardRef)(function(_ref,ref){var _ref$closeOnSelect=_ref.closeOnSelect,closeOnSelect=_ref$closeOnSelect===void 0?true:_ref$closeOnSelect,_ref$onClose=_ref.onClose,onClose=_ref$onClose===void 0?function(){}:_ref$onClose,children=_ref.children,rest=(0,_objectWithoutProperties2.default)(_ref,_excluded);var _useTheme=(0,_theming.useTheme)(),theme=_useTheme.theme;var childrenCount=(0,_react.useMemo)(function(){return _react.default.Children.count(children);},[children]);var menuContext=(0,_react.useMemo)(function(){return{closeOnSelect:closeOnSelect,onClose:onClose};},[closeOnSelect,onClose]);return _react.default.createElement(_menuUtils.MenuContext.Provider,{value:menuContext},_react.default.createElement(StyledModal,(0,_extends2.default)({footer:null,onClose:onClose},rest,{ref:ref}),_react.default.createElement(_reactNativeSafeAreaContext.SafeAreaProvider,null,_react.default.Children.map(children,function(child,index){if(!_react.default.isValidElement(child)||child.type!==_MenuGroup.default)return child;var style={};if(index<childrenCount-1){style={paddingBottom:0.4*theme.fontSize,borderBottomWidth:1,borderBottomColor:(0,_theming.clr)(theme.menuGroupColorDivider)};}if(index>0){style={marginTop:theme.modalBodyPaddingVertical*theme.fontSize};}return _react.default.cloneElement(child,{style:style});}))));});Menu.displayName='Menu';var _default=Menu;exports.default=_default;
|
2
2
|
//# sourceMappingURL=Menu.js.map
|
package/dist/Menu.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/Menu.tsx"],"names":["StyledModal","Modal","paddingLeft","paddingRight","Menu","ref","closeOnSelect","onClose","children","rest","childrenCount","React","Children","count","
|
1
|
+
{"version":3,"sources":["../src/Menu.tsx"],"names":["StyledModal","Modal","paddingLeft","paddingRight","Menu","ref","closeOnSelect","onClose","children","rest","theme","childrenCount","React","Children","count","menuContext","map","child","index","isValidElement","type","MenuGroup","style","paddingBottom","fontSize","borderBottomWidth","borderBottomColor","menuGroupColorDivider","marginTop","modalBodyPaddingVertical","cloneElement","displayName"],"mappings":"mWAAA,qDAEA,sEACA,gDACA,0EACA,+DACA,kDACA,8D,+iCAUA,GAAMA,CAAAA,WAAW,CAAG,oBAAOC,cAAP,EAAc,CAChCC,WAAW,CAAE,CADmB,CAEhCC,YAAY,CAAE,CAFkB,CAAd,CAApB,CAQA,GAAMC,CAAAA,IAAI,CAAG,sBACX,cAAkEC,GAAlE,CAA0E,6B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AAK,CAACmB,wBAAN,CAAiCnB,KAAK,CAACc,QAD5C,CAAR,CAGD,CACD,MAAOZ,gBAAMkB,YAAN,CAAmBb,KAAnB,CAA0B,CAAEK,KAAK,CAALA,KAAF,CAA1B,CAAP,CACD,CAjBA,CADH,CADF,CADF,CADF,CA0BD,CAtCU,CAAb,CAyCAlB,IAAI,CAAC2B,WAAL,CAAmB,MAAnB,C,aAEe3B,I","sourcesContent":["import React, { forwardRef, PropsWithChildren, useMemo } from 'react';\nimport { View } from 'react-native';\nimport Modal, { ModalProps } from '@os-design-mobile/modal';\nimport { MenuContext } from '@os-design/menu-utils';\nimport { SafeAreaProvider } from 'react-native-safe-area-context';\nimport styled from '@emotion/native';\nimport { clr, useTheme } from '@os-design-mobile/theming';\nimport MenuGroup from './MenuGroup';\n\nexport interface MenuProps extends PropsWithChildren<ModalProps> {\n /**\n * Whether the menu closes when the user selects a menu item.\n * @default true\n */\n closeOnSelect?: boolean;\n}\n\nconst StyledModal = styled(Modal)({\n paddingLeft: 0,\n paddingRight: 0,\n});\n\n/**\n * The dropdown menu.\n */\nconst Menu = forwardRef<View, MenuProps>(\n ({ closeOnSelect = true, onClose = () => {}, children, ...rest }, ref) => {\n const { theme } = useTheme();\n const childrenCount = useMemo(\n () => React.Children.count(children),\n [children]\n );\n const menuContext = useMemo(\n () => ({ closeOnSelect, onClose }),\n [closeOnSelect, onClose]\n );\n\n return (\n <MenuContext.Provider value={menuContext}>\n <StyledModal footer={null} onClose={onClose} {...rest} ref={ref}>\n <SafeAreaProvider>\n {React.Children.map(children, (child, index) => {\n if (!React.isValidElement(child) || child.type !== MenuGroup)\n return child;\n let style = {};\n if (index < childrenCount - 1) {\n style = {\n paddingBottom: 0.4 * theme.fontSize,\n borderBottomWidth: 1,\n borderBottomColor: clr(theme.menuGroupColorDivider),\n };\n }\n if (index > 0) {\n style = {\n marginTop: theme.modalBodyPaddingVertical * theme.fontSize,\n };\n }\n return React.cloneElement(child, { style });\n })}\n </SafeAreaProvider>\n </StyledModal>\n </MenuContext.Provider>\n );\n }\n);\n\nMenu.displayName = 'Menu';\n\nexport default Menu;\n"],"file":"Menu.js"}
|
package/dist/MenuGroup.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"MenuGroup.d.ts","sourceRoot":"","sources":["../src/MenuGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAEZ,iBAAiB,EAGlB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAQ/C,MAAM,WAAW,cAAe,SAAQ,iBAAiB,CAAC,SAAS,CAAC;IAKlE,KAAK,CAAC,EAAE,MAAM,CAAC;IAKf,gBAAgB,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAKlC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IAKjB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IAKxB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CACtC;AAaD,QAAA,MAAM,SAAS,
|
1
|
+
{"version":3,"file":"MenuGroup.d.ts","sourceRoot":"","sources":["../src/MenuGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAEZ,iBAAiB,EAGlB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAQ/C,MAAM,WAAW,cAAe,SAAQ,iBAAiB,CAAC,SAAS,CAAC;IAKlE,KAAK,CAAC,EAAE,MAAM,CAAC;IAKf,gBAAgB,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAKlC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IAKjB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IAKxB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CACtC;AAaD,QAAA,MAAM,SAAS,6EA2Ed,CAAC;AAIF,eAAe,SAAS,CAAC"}
|
package/dist/MenuGroup.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends"));var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _native=_interopRequireDefault(require("@emotion/native"));var _theming=require("@os-design-mobile/theming");var _useForwardedState3=_interopRequireDefault(require("@os-design/use-forwarded-state"));var _menuUtils=require("@os-design/menu-utils");var _reactNativeSafeAreaContext=require("react-native-safe-area-context");var _MenuItem=_interopRequireDefault(require("./MenuItem"));var _excluded=["title","maxSelectedItems","value","defaultValue","onChange","children"];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);}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;}var Title=_native.default.Text(function(p){return{fontWeight:'500',fontSize:p.theme.sizes.small*p.theme.fontSize,color:(0,_theming.clr)(p.theme.menuGroupColorTitle),marginBottom:0.4*p.theme.fontSize,paddingHorizontal:p.theme.modalBodyPaddingHorizontal*p.theme.fontSize};});var MenuGroup=(0,_react.forwardRef)(function(_ref,ref){var title=_ref.title,_ref$maxSelectedItems=_ref.maxSelectedItems,maxSelectedItems=_ref$maxSelectedItems===void 0?1:_ref$maxSelectedItems,value=_ref.value,defaultValue=_ref.defaultValue,_ref$onChange=_ref.onChange,onChange=_ref$onChange===void 0?function(){}:_ref$onChange,children=_ref.children,rest=(0,_objectWithoutProperties2.default)(_ref,_excluded);var _useContext=(0,_react.useContext)(_menuUtils.MenuContext),closeOnSelect=_useContext.closeOnSelect;var _useForwardedState=(0,_useForwardedState3.default)({value:value,defaultValue:defaultValue,onChange:onChange}),_useForwardedState2=(0,_slicedToArray2.default)(_useForwardedState,2),forwardedValue=_useForwardedState2[0],setForwardedValue=_useForwardedState2[1];var safeAreaInsets=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)();var
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends"));var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _native=_interopRequireDefault(require("@emotion/native"));var _theming=require("@os-design-mobile/theming");var _useForwardedState3=_interopRequireDefault(require("@os-design/use-forwarded-state"));var _menuUtils=require("@os-design/menu-utils");var _reactNativeSafeAreaContext=require("react-native-safe-area-context");var _MenuItem=_interopRequireDefault(require("./MenuItem"));var _excluded=["title","maxSelectedItems","value","defaultValue","onChange","children"];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);}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;}var Title=_native.default.Text(function(p){return{fontWeight:'500',fontSize:p.theme.sizes.small*p.theme.fontSize,color:(0,_theming.clr)(p.theme.menuGroupColorTitle),marginBottom:0.4*p.theme.fontSize,paddingHorizontal:p.theme.modalBodyPaddingHorizontal*p.theme.fontSize};});var MenuGroup=(0,_react.forwardRef)(function(_ref,ref){var title=_ref.title,_ref$maxSelectedItems=_ref.maxSelectedItems,maxSelectedItems=_ref$maxSelectedItems===void 0?1:_ref$maxSelectedItems,value=_ref.value,defaultValue=_ref.defaultValue,_ref$onChange=_ref.onChange,onChange=_ref$onChange===void 0?function(){}:_ref$onChange,children=_ref.children,rest=(0,_objectWithoutProperties2.default)(_ref,_excluded);var _useContext=(0,_react.useContext)(_menuUtils.MenuContext),closeOnSelect=_useContext.closeOnSelect;var _useForwardedState=(0,_useForwardedState3.default)({value:value,defaultValue:defaultValue,onChange:onChange}),_useForwardedState2=(0,_slicedToArray2.default)(_useForwardedState,2),forwardedValue=_useForwardedState2[0],setForwardedValue=_useForwardedState2[1];var safeAreaInsets=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)();var onSelect=(0,_menuUtils.useSelectHandler)({value:forwardedValue||[],onChange:setForwardedValue,maxSelectedItems:maxSelectedItems});var menuItems=(0,_react.useMemo)(function(){var selectedItems=forwardedValue||[];return _react.default.Children.map(children,function(child){if(!_react.default.isValidElement(child)||child.type!==_MenuItem.default)return child;var _child$props=child.props,childValue=_child$props.value,childOnPress=_child$props.onPress;return _react.default.cloneElement(child,(0,_extends2.default)({key:childValue,selected:selectedItems.includes(childValue),onPress:function onPress(e){if(!childValue)return;onSelect(childValue);if(childOnPress)childOnPress(e);}},!closeOnSelect?{accessibilityRole:maxSelectedItems===1?'radio':'checkbox',accessibilityState:{checked:selectedItems.includes(childValue)}}:{}));});},[children,closeOnSelect,forwardedValue,maxSelectedItems,onSelect]);return _react.default.createElement(_reactNative.View,(0,_extends2.default)({},rest,{ref:ref}),title&&_react.default.createElement(Title,{numberOfLines:1,style:(0,_extends2.default)({},safeAreaInsets.left>0?{paddingLeft:safeAreaInsets.left}:{},safeAreaInsets.right>0?{paddingRight:safeAreaInsets.right}:{})},title),menuItems);});MenuGroup.displayName='MenuGroup';var _default=MenuGroup;exports.default=_default;
|
2
2
|
//# sourceMappingURL=MenuGroup.js.map
|
package/dist/MenuGroup.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/MenuGroup.tsx"],"names":["Title","styled","Text","p","fontWeight","fontSize","theme","sizes","small","color","menuGroupColorTitle","marginBottom","paddingHorizontal","modalBodyPaddingHorizontal","MenuGroup","ref","title","maxSelectedItems","value","defaultValue","onChange","children","rest","MenuContext","closeOnSelect","forwardedValue","setForwardedValue","safeAreaInsets","
|
1
|
+
{"version":3,"sources":["../src/MenuGroup.tsx"],"names":["Title","styled","Text","p","fontWeight","fontSize","theme","sizes","small","color","menuGroupColorTitle","marginBottom","paddingHorizontal","modalBodyPaddingHorizontal","MenuGroup","ref","title","maxSelectedItems","value","defaultValue","onChange","children","rest","MenuContext","closeOnSelect","forwardedValue","setForwardedValue","safeAreaInsets","onSelect","menuItems","selectedItems","React","Children","map","child","isValidElement","type","MenuItem","props","childValue","childOnPress","onPress","cloneElement","key","selected","includes","e","accessibilityRole","accessibilityState","checked","left","paddingLeft","right","paddingRight","displayName"],"mappings":"+bAAA,qDAMA,yCACA,+DACA,kDACA,0FACA,gDACA,0EACA,4D,klCA8BA,GAAMA,CAAAA,KAAK,CAAGC,gBAAOC,IAAP,CAAY,SAACC,CAAD,QAAQ,CAChCC,UAAU,CAAE,KADoB,CAEhCC,QAAQ,CAAEF,CAAC,CAACG,KAAF,CAAQC,KAAR,CAAcC,KAAd,CAAsBL,CAAC,CAACG,KAAF,CAAQD,QAFR,CAGhCI,KAAK,CAAE,iBAAIN,CAAC,CAACG,KAAF,CAAQI,mBAAZ,CAHyB,CAIhCC,YAAY,CAAE,IAAMR,CAAC,CAACG,KAAF,CAAQD,QAJI,CAKhCO,iBAAiB,CAAET,CAAC,CAACG,KAAF,CAAQO,0BAAR,CAAqCV,CAAC,CAACG,KAAF,CAAQD,QALhC,CAAR,EAAZ,CAAd,CAWA,GAAMS,CAAAA,SAAS,CAAG,sBAChB,cAUEC,GAVF,CAWK,IATDC,CAAAA,KASC,MATDA,KASC,4BARDC,gBAQC,CARDA,gBAQC,gCARkB,CAQlB,uBAPDC,KAOC,MAPDA,KAOC,CANDC,YAMC,MANDA,YAMC,oBALDC,QAKC,CALDA,QAKC,wBALU,UAAM,CAAE,CAKlB,eAJDC,QAIC,MAJDA,QAIC,CAHEC,IAGF,uDACH,gBAA0B,sBAAWC,sBAAX,CAA1B,CAAQC,aAAR,aAAQA,aAAR,CACA,uBAA4C,gCAAkB,CAC5DN,KAAK,CAALA,KAD4D,CAE5DC,YAAY,CAAZA,YAF4D,CAG5DC,QAAQ,CAARA,QAH4D,CAAlB,CAA5C,uEAAOK,cAAP,wBAAuBC,iBAAvB,wBAKA,GAAMC,CAAAA,cAAc,CAAG,mDAAvB,CAEA,GAAMC,CAAAA,QAAQ,CAAG,gCAAiB,CAChCV,KAAK,CAAEO,cAAc,EAAI,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,CADjB,CAEE,KAAK,0BACCW,cAAc,CAACuB,IAAf,CAAsB,CAAtB,CACA,CAAEC,WAAW,CAAExB,cAAc,CAACuB,IAA9B,CADA,CAEA,EAHD,CAICvB,cAAc,CAACyB,KAAf,CAAuB,CAAvB,CACA,CAAEC,YAAY,CAAE1B,cAAc,CAACyB,KAA/B,CADA,CAEA,EAND,CAFP,EAWGpC,KAXH,CAFJ,CAgBGa,SAhBH,CADF,CAoBD,CA1Ee,CAAlB,CA6EAf,SAAS,CAACwC,WAAV,CAAwB,WAAxB,C,aAEexC,S","sourcesContent":["import React, {\n forwardRef,\n PropsWithChildren,\n useContext,\n useMemo,\n} from 'react';\nimport { View, ViewProps } from 'react-native';\nimport styled from '@emotion/native';\nimport { clr } from '@os-design-mobile/theming';\nimport useForwardedState from '@os-design/use-forwarded-state';\nimport { MenuContext, useSelectHandler } from '@os-design/menu-utils';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\nimport MenuItem from './MenuItem';\n\nexport interface MenuGroupProps extends PropsWithChildren<ViewProps> {\n /**\n * The title of the menu group.\n * @default undefined\n */\n title?: string;\n /**\n * The max number of menu items that the user can select.\n * @default 1\n */\n maxSelectedItems?: number | 'all';\n /**\n * Selected menu items.\n * @default undefined\n */\n value?: string[];\n /**\n * The default value.\n * @default undefined\n */\n defaultValue?: string[];\n /**\n * The change event handler.\n * @default undefined\n */\n onChange?: (value: string[]) => void;\n}\n\nconst Title = styled.Text((p) => ({\n fontWeight: '500',\n fontSize: p.theme.sizes.small * p.theme.fontSize,\n color: clr(p.theme.menuGroupColorTitle),\n marginBottom: 0.4 * p.theme.fontSize,\n paddingHorizontal: p.theme.modalBodyPaddingHorizontal * p.theme.fontSize,\n}));\n\n/**\n * The group of menu items.\n */\nconst MenuGroup = forwardRef<View, MenuGroupProps>(\n (\n {\n title,\n maxSelectedItems = 1,\n value,\n defaultValue,\n onChange = () => {},\n children,\n ...rest\n },\n ref\n ) => {\n const { closeOnSelect } = useContext(MenuContext);\n const [forwardedValue, setForwardedValue] = useForwardedState({\n value,\n defaultValue,\n onChange,\n });\n const safeAreaInsets = useSafeAreaInsets();\n\n const onSelect = useSelectHandler({\n value: forwardedValue || [],\n onChange: setForwardedValue,\n maxSelectedItems,\n });\n\n const menuItems = useMemo(() => {\n const selectedItems = forwardedValue || [];\n return React.Children.map(children, (child) => {\n if (!React.isValidElement(child) || child.type !== MenuItem)\n return child;\n const { value: childValue, onPress: childOnPress } = child.props;\n return React.cloneElement(child, {\n key: childValue,\n selected: selectedItems.includes(childValue),\n onPress: (e) => {\n if (!childValue) return;\n onSelect(childValue);\n if (childOnPress) childOnPress(e);\n },\n ...(!closeOnSelect\n ? {\n accessibilityRole:\n maxSelectedItems === 1 ? 'radio' : 'checkbox',\n accessibilityState: {\n checked: selectedItems.includes(childValue),\n },\n }\n : {}),\n });\n });\n }, [children, closeOnSelect, forwardedValue, maxSelectedItems, onSelect]);\n\n return (\n <View {...rest} ref={ref}>\n {title && (\n <Title\n numberOfLines={1}\n style={{\n ...(safeAreaInsets.left > 0\n ? { paddingLeft: safeAreaInsets.left }\n : {}),\n ...(safeAreaInsets.right > 0\n ? { paddingRight: safeAreaInsets.right }\n : {}),\n }}\n >\n {title}\n </Title>\n )}\n {menuItems}\n </View>\n );\n }\n);\n\nMenuGroup.displayName = 'MenuGroup';\n\nexport default MenuGroup;\n"],"file":"MenuGroup.js"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@os-design-mobile/menu",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.35",
|
4
4
|
"license": "UNLICENSED",
|
5
5
|
"repository": "git@gitlab.com:os-team/libs/os-design-mobile.git",
|
6
6
|
"main": "dist/index.js",
|
@@ -19,24 +19,24 @@
|
|
19
19
|
"access": "public"
|
20
20
|
},
|
21
21
|
"dependencies": {
|
22
|
-
"@os-design-mobile/button": "^1.0.
|
23
|
-
"@os-design-mobile/icons": "^1.0.
|
24
|
-
"@os-design-mobile/modal": "^1.0.
|
25
|
-
"@os-design-mobile/theming": "^1.0.
|
26
|
-
"@os-design/menu-utils": "^1.0.
|
22
|
+
"@os-design-mobile/button": "^1.0.27",
|
23
|
+
"@os-design-mobile/icons": "^1.0.26",
|
24
|
+
"@os-design-mobile/modal": "^1.0.39",
|
25
|
+
"@os-design-mobile/theming": "^1.0.18",
|
26
|
+
"@os-design/menu-utils": "^1.0.4",
|
27
27
|
"@os-design/use-forwarded-state": "^1.0.4"
|
28
28
|
},
|
29
29
|
"devDependencies": {
|
30
|
-
"@os-design-mobile/text": "^1.0.
|
30
|
+
"@os-design-mobile/text": "^1.0.24"
|
31
31
|
},
|
32
32
|
"peerDependencies": {
|
33
33
|
"@emotion/native": ">=11",
|
34
34
|
"@emotion/react": ">=11",
|
35
35
|
"@react-native-async-storage/async-storage": ">=1",
|
36
36
|
"react": "17.0.2",
|
37
|
-
"react-native": "0.
|
37
|
+
"react-native": "0.67.2",
|
38
38
|
"react-native-safe-area-context": ">=3",
|
39
39
|
"react-native-svg": ">=12"
|
40
40
|
},
|
41
|
-
"gitHead": "
|
41
|
+
"gitHead": "87a5ae2bd44863bb6eec8b7c956a24d8f66ef0b5"
|
42
42
|
}
|