@react-native-menu/menu
Advanced tools
Comparing version 1.1.3 to 1.1.4
@@ -11,6 +11,6 @@ "use strict"; | ||
var _utils = require("./utils"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _jsxRuntime = require("react/jsx-runtime"); | ||
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
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); } | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
function processAction(action) { | ||
@@ -39,9 +39,10 @@ return { | ||
}, [processedActions]); | ||
return /*#__PURE__*/_react.default.createElement(_UIMenuView.default, _extends({}, props, { | ||
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_UIMenuView.default, { | ||
...props, | ||
hitSlop: hitSlop, | ||
actions: processedActions, | ||
actionsHash: hash | ||
})); | ||
}); | ||
}; | ||
exports.MenuView = MenuView; | ||
//# sourceMappingURL=index.js.map |
@@ -8,3 +8,3 @@ "use strict"; | ||
var _codegenNativeComponent = _interopRequireDefault(require("react-native/Libraries/Utilities/codegenNativeComponent")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } | ||
/* | ||
@@ -11,0 +11,0 @@ Caution, those below are not just typescript types. |
@@ -8,4 +8,4 @@ "use strict"; | ||
var _UIMenuNativeComponent = _interopRequireDefault(require("./NativeModuleSpecs/UIMenuNativeComponent")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } | ||
var _default = exports.default = _UIMenuNativeComponent.default; | ||
//# sourceMappingURL=UIMenuView.ios.js.map |
@@ -9,4 +9,5 @@ "use strict"; | ||
var _reactNative = require("react-native"); | ||
var _jsxRuntime = require("react/jsx-runtime"); | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
/** | ||
@@ -17,9 +18,12 @@ * TODO: implement for Web | ||
style, | ||
children | ||
children, | ||
testID | ||
}) => { | ||
return /*#__PURE__*/React.createElement(_reactNative.View, { | ||
style: style | ||
}, children); | ||
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, { | ||
style: style, | ||
testID: testID, | ||
children: children | ||
}); | ||
}; | ||
var _default = exports.default = MenuView; | ||
//# sourceMappingURL=UIMenuView.js.map |
@@ -1,2 +0,3 @@ | ||
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); } | ||
"use strict"; | ||
import React, { useMemo } from 'react'; | ||
@@ -6,2 +7,3 @@ import { processColor } from 'react-native'; | ||
import { objectHash } from './utils'; | ||
import { jsx as _jsx } from "react/jsx-runtime"; | ||
function processAction(action) { | ||
@@ -30,9 +32,10 @@ return { | ||
}, [processedActions]); | ||
return /*#__PURE__*/React.createElement(UIMenuView, _extends({}, props, { | ||
return /*#__PURE__*/_jsx(UIMenuView, { | ||
...props, | ||
hitSlop: hitSlop, | ||
actions: processedActions, | ||
actionsHash: hash | ||
})); | ||
}); | ||
}; | ||
export { MenuView }; | ||
//# sourceMappingURL=index.js.map |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; | ||
@@ -2,0 +4,0 @@ /* |
@@ -0,2 +1,4 @@ | ||
"use strict"; | ||
export {}; | ||
//# sourceMappingURL=types.js.map |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
import { requireNativeComponent } from 'react-native'; | ||
@@ -2,0 +4,0 @@ const MenuComponent = requireNativeComponent('MenuView'); |
@@ -0,3 +1,5 @@ | ||
"use strict"; | ||
import UIMenuNativeComponent from './NativeModuleSpecs/UIMenuNativeComponent'; | ||
export default UIMenuNativeComponent; | ||
//# sourceMappingURL=UIMenuView.ios.js.map |
@@ -0,3 +1,6 @@ | ||
"use strict"; | ||
import * as React from 'react'; | ||
import { View } from 'react-native'; | ||
import { jsx as _jsx } from "react/jsx-runtime"; | ||
/** | ||
@@ -8,9 +11,12 @@ * TODO: implement for Web | ||
style, | ||
children | ||
children, | ||
testID | ||
}) => { | ||
return /*#__PURE__*/React.createElement(View, { | ||
style: style | ||
}, children); | ||
return /*#__PURE__*/_jsx(View, { | ||
style: style, | ||
testID: testID, | ||
children: children | ||
}); | ||
}; | ||
export default MenuView; | ||
//# sourceMappingURL=UIMenuView.js.map |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
// Function to calculate a simple hash code for a string | ||
@@ -2,0 +4,0 @@ function hashCode(str) { |
@@ -146,2 +146,6 @@ import type { ColorValue, processColor, StyleProp, ViewStyle } from 'react-native'; | ||
}; | ||
/** | ||
* Test ID for testing purposes | ||
*/ | ||
testID?: string; | ||
}; | ||
@@ -161,4 +165,5 @@ export type MenuComponentProps = React.PropsWithChildren<MenuComponentPropsBase>; | ||
hitSlop?: MenuComponentProps['hitSlop']; | ||
testID?: string; | ||
}; | ||
export {}; | ||
//# sourceMappingURL=types.d.ts.map |
{ | ||
"name": "@react-native-menu/menu", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"description": "UIMenu component for react-native", | ||
@@ -5,0 +5,0 @@ "main": "lib/commonjs/index", |
@@ -280,2 +280,41 @@ # @react-native-menu/menu | ||
## Testing with Jest | ||
In some cases, you might want to mock the package to test your components. You can do this by using the `jest.mock` function. | ||
```ts | ||
import type { MenuComponentProps } from '@react-native-menu/menu'; | ||
jest.mock('@react-native-menu/menu', () => ({ | ||
MenuView: jest.fn((props: MenuComponentProps) => { | ||
const React = require('react'); | ||
class MockMenuView extends React.Component { | ||
render() { | ||
return React.createElement( | ||
'View', | ||
{ testID: props.testID }, | ||
// Dynamically mock each action | ||
props.actions.map(action => | ||
React.createElement('Button', { | ||
key: action.id, | ||
title: action.title, | ||
onPress: () => { | ||
if (action.id && props?.onPressAction) { | ||
props.onPressAction({ nativeEvent: { event: action.id } }); | ||
} | ||
}, | ||
testID: action.id | ||
}) | ||
), | ||
this.props.children | ||
); | ||
} | ||
} | ||
return React.createElement(MockMenuView, props); | ||
}) | ||
})); | ||
``` | ||
## Contributing | ||
@@ -282,0 +321,0 @@ |
@@ -157,2 +157,6 @@ import type { | ||
}; | ||
/** | ||
* Test ID for testing purposes | ||
*/ | ||
testID?: string; | ||
}; | ||
@@ -179,2 +183,3 @@ | ||
hitSlop?: MenuComponentProps['hitSlop']; | ||
testID?: string; | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
163694
84
775
330