@fluentui-react-native/menu 0.3.0 → 0.4.0

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.
Files changed (63) hide show
  1. package/CHANGELOG.json +70 -1
  2. package/CHANGELOG.md +30 -2
  3. package/lib/Menu/Menu.types.d.ts +1 -0
  4. package/lib/Menu/Menu.types.d.ts.map +1 -1
  5. package/lib/Menu/useMenu.d.ts.map +1 -1
  6. package/lib/Menu/useMenu.js +4 -0
  7. package/lib/Menu/useMenu.js.map +1 -1
  8. package/lib/Menu/useMenuContextValue.js +1 -1
  9. package/lib/Menu/useMenuContextValue.js.map +1 -1
  10. package/lib/MenuItem/MenuItem.d.ts +3 -0
  11. package/lib/MenuItem/MenuItem.d.ts.map +1 -0
  12. package/lib/MenuItem/MenuItem.js +38 -0
  13. package/lib/MenuItem/MenuItem.js.map +1 -0
  14. package/lib/MenuItem/MenuItem.types.d.ts +41 -0
  15. package/lib/MenuItem/MenuItem.types.d.ts.map +1 -0
  16. package/lib/MenuItem/MenuItem.types.js +2 -0
  17. package/lib/MenuItem/MenuItem.types.js.map +1 -0
  18. package/lib/MenuItem/useMenuItem.d.ts +3 -0
  19. package/lib/MenuItem/useMenuItem.d.ts.map +1 -0
  20. package/lib/MenuItem/useMenuItem.js +25 -0
  21. package/lib/MenuItem/useMenuItem.js.map +1 -0
  22. package/lib/context/menuContext.d.ts.map +1 -1
  23. package/lib/context/menuContext.js +1 -0
  24. package/lib/context/menuContext.js.map +1 -1
  25. package/lib/index.d.ts +1 -0
  26. package/lib/index.d.ts.map +1 -1
  27. package/lib/index.js +1 -0
  28. package/lib/index.js.map +1 -1
  29. package/lib-commonjs/Menu/Menu.types.d.ts +1 -0
  30. package/lib-commonjs/Menu/Menu.types.d.ts.map +1 -1
  31. package/lib-commonjs/Menu/useMenu.d.ts.map +1 -1
  32. package/lib-commonjs/Menu/useMenu.js +4 -0
  33. package/lib-commonjs/Menu/useMenu.js.map +1 -1
  34. package/lib-commonjs/Menu/useMenuContextValue.js +1 -1
  35. package/lib-commonjs/Menu/useMenuContextValue.js.map +1 -1
  36. package/lib-commonjs/MenuItem/MenuItem.d.ts +3 -0
  37. package/lib-commonjs/MenuItem/MenuItem.d.ts.map +1 -0
  38. package/lib-commonjs/MenuItem/MenuItem.js +41 -0
  39. package/lib-commonjs/MenuItem/MenuItem.js.map +1 -0
  40. package/lib-commonjs/MenuItem/MenuItem.types.d.ts +41 -0
  41. package/lib-commonjs/MenuItem/MenuItem.types.d.ts.map +1 -0
  42. package/lib-commonjs/MenuItem/MenuItem.types.js +5 -0
  43. package/lib-commonjs/MenuItem/MenuItem.types.js.map +1 -0
  44. package/lib-commonjs/MenuItem/useMenuItem.d.ts +3 -0
  45. package/lib-commonjs/MenuItem/useMenuItem.d.ts.map +1 -0
  46. package/lib-commonjs/MenuItem/useMenuItem.js +29 -0
  47. package/lib-commonjs/MenuItem/useMenuItem.js.map +1 -0
  48. package/lib-commonjs/context/menuContext.d.ts.map +1 -1
  49. package/lib-commonjs/context/menuContext.js +1 -0
  50. package/lib-commonjs/context/menuContext.js.map +1 -1
  51. package/lib-commonjs/index.d.ts +1 -0
  52. package/lib-commonjs/index.d.ts.map +1 -1
  53. package/lib-commonjs/index.js +3 -1
  54. package/lib-commonjs/index.js.map +1 -1
  55. package/package.json +7 -4
  56. package/src/Menu/Menu.types.ts +1 -0
  57. package/src/Menu/useMenu.ts +4 -0
  58. package/src/Menu/useMenuContextValue.ts +1 -1
  59. package/src/MenuItem/MenuItem.tsx +45 -0
  60. package/src/MenuItem/MenuItem.types.ts +49 -0
  61. package/src/MenuItem/useMenuItem.ts +40 -0
  62. package/src/context/menuContext.ts +1 -0
  63. package/src/index.ts +1 -0
package/CHANGELOG.json CHANGED
@@ -2,7 +2,76 @@
2
2
  "name": "@fluentui-react-native/menu",
3
3
  "entries": [
4
4
  {
5
- "date": "Mon, 25 Apr 2022 18:30:53 GMT",
5
+ "date": "Mon, 02 May 2022 22:14:24 GMT",
6
+ "tag": "@fluentui-react-native/menu_v0.4.0",
7
+ "version": "0.4.0",
8
+ "comments": {
9
+ "minor": [
10
+ {
11
+ "author": "ruaraki@microsoft.com",
12
+ "package": "@fluentui-react-native/menu",
13
+ "commit": "bca261a9003512f213abaea80fe3f18a3368157a",
14
+ "comment": "Implement submenu proto"
15
+ }
16
+ ]
17
+ }
18
+ },
19
+ {
20
+ "date": "Thu, 28 Apr 2022 19:09:51 GMT",
21
+ "tag": "@fluentui-react-native/menu_v0.3.2",
22
+ "version": "0.3.2",
23
+ "comments": {
24
+ "patch": [
25
+ {
26
+ "author": "beachball",
27
+ "package": "@fluentui-react-native/menu",
28
+ "comment": "Bump @fluentui-react-native/callout to v0.19.45",
29
+ "commit": "8cff404ca31eaa61017551a1d73fd3fdae7da132"
30
+ },
31
+ {
32
+ "author": "beachball",
33
+ "package": "@fluentui-react-native/menu",
34
+ "comment": "Bump @fluentui-react-native/framework to v0.7.25",
35
+ "commit": "8cff404ca31eaa61017551a1d73fd3fdae7da132"
36
+ },
37
+ {
38
+ "author": "beachball",
39
+ "package": "@fluentui-react-native/menu",
40
+ "comment": "Bump @fluentui-react-native/interactive-hooks to v0.15.5",
41
+ "commit": "8cff404ca31eaa61017551a1d73fd3fdae7da132"
42
+ }
43
+ ]
44
+ }
45
+ },
46
+ {
47
+ "date": "Wed, 27 Apr 2022 19:30:38 GMT",
48
+ "tag": "@fluentui-react-native/menu_v0.3.1",
49
+ "version": "0.3.1",
50
+ "comments": {
51
+ "patch": [
52
+ {
53
+ "author": "beachball",
54
+ "package": "@fluentui-react-native/menu",
55
+ "comment": "Bump @fluentui-react-native/callout to v0.19.44",
56
+ "commit": "f3481f50e20c6ab33f7f3ffca63e9f1e424fe2c1"
57
+ },
58
+ {
59
+ "author": "beachball",
60
+ "package": "@fluentui-react-native/menu",
61
+ "comment": "Bump @fluentui-react-native/framework to v0.7.24",
62
+ "commit": "f3481f50e20c6ab33f7f3ffca63e9f1e424fe2c1"
63
+ },
64
+ {
65
+ "author": "beachball",
66
+ "package": "@fluentui-react-native/menu",
67
+ "comment": "Bump @fluentui-react-native/interactive-hooks to v0.15.4",
68
+ "commit": "f3481f50e20c6ab33f7f3ffca63e9f1e424fe2c1"
69
+ }
70
+ ]
71
+ }
72
+ },
73
+ {
74
+ "date": "Mon, 25 Apr 2022 18:31:09 GMT",
6
75
  "tag": "@fluentui-react-native/menu_v0.3.0",
7
76
  "version": "0.3.0",
8
77
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,40 @@
1
1
  # Change Log - @fluentui-react-native/menu
2
2
 
3
- This log was last generated on Mon, 25 Apr 2022 18:30:53 GMT and should not be manually modified.
3
+ This log was last generated on Mon, 02 May 2022 22:14:24 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 0.4.0
8
+
9
+ Mon, 02 May 2022 22:14:24 GMT
10
+
11
+ ### Minor changes
12
+
13
+ - Implement submenu proto (ruaraki@microsoft.com)
14
+
15
+ ## 0.3.2
16
+
17
+ Thu, 28 Apr 2022 19:09:51 GMT
18
+
19
+ ### Patches
20
+
21
+ - Bump @fluentui-react-native/callout to v0.19.45
22
+ - Bump @fluentui-react-native/framework to v0.7.25
23
+ - Bump @fluentui-react-native/interactive-hooks to v0.15.5
24
+
25
+ ## 0.3.1
26
+
27
+ Wed, 27 Apr 2022 19:30:38 GMT
28
+
29
+ ### Patches
30
+
31
+ - Bump @fluentui-react-native/callout to v0.19.44
32
+ - Bump @fluentui-react-native/framework to v0.7.24
33
+ - Bump @fluentui-react-native/interactive-hooks to v0.15.4
34
+
7
35
  ## 0.3.0
8
36
 
9
- Mon, 25 Apr 2022 18:30:53 GMT
37
+ Mon, 25 Apr 2022 18:31:09 GMT
10
38
 
11
39
  ### Minor changes
12
40
 
@@ -5,6 +5,7 @@ export interface MenuProps extends Omit<IViewProps, 'onPress'> {
5
5
  open?: boolean;
6
6
  }
7
7
  export interface MenuState extends MenuProps {
8
+ isSubmenu: boolean;
8
9
  setOpen: (isOpen: boolean) => void;
9
10
  triggerRef: React.RefObject<React.Component>;
10
11
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Menu.types.d.ts","sourceRoot":"","sources":["../../src/Menu/Menu.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,eAAO,MAAM,QAAQ,SAAS,CAAC;AAE/B,MAAM,WAAW,SAAU,SAAQ,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC;IAC5D,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,SAAU,SAAQ,SAAS;IAC1C,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IACnC,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;CAC9C"}
1
+ {"version":3,"file":"Menu.types.d.ts","sourceRoot":"","sources":["../../src/Menu/Menu.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,eAAO,MAAM,QAAQ,SAAS,CAAC;AAE/B,MAAM,WAAW,SAAU,SAAQ,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC;IAC5D,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,SAAU,SAAQ,SAAS;IAC1C,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IACnC,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;CAC9C"}
@@ -1 +1 @@
1
- {"version":3,"file":"useMenu.d.ts","sourceRoot":"","sources":["../../src/Menu/useMenu.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEpD,eAAO,MAAM,OAAO,UAAW,SAAS,KAAG,SAS1C,CAAC"}
1
+ {"version":3,"file":"useMenu.d.ts","sourceRoot":"","sources":["../../src/Menu/useMenu.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEpD,eAAO,MAAM,OAAO,UAAW,SAAS,KAAG,SAY1C,CAAC"}
@@ -1,11 +1,15 @@
1
1
  import React from 'react';
2
+ import { useMenuContext } from '../context/menuContext';
2
3
  export var useMenu = function (props) {
3
4
  var _a = useMenuOpenState(props), open = _a[0], setOpen = _a[1];
4
5
  var triggerRef = React.useRef(null);
6
+ var context = useMenuContext();
7
+ var isSubmenu = context.triggerRef !== null;
5
8
  return {
6
9
  open: open,
7
10
  setOpen: setOpen,
8
11
  triggerRef: triggerRef,
12
+ isSubmenu: isSubmenu,
9
13
  };
10
14
  };
11
15
  var useMenuOpenState = function (props) {
@@ -1 +1 @@
1
- {"version":3,"file":"useMenu.js","sourceRoot":"","sources":["../../src/Menu/useMenu.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,MAAM,CAAC,IAAM,OAAO,GAAG,UAAC,KAAgB;IAChC,IAAA,KAAkB,gBAAgB,CAAC,KAAK,CAAC,EAAxC,IAAI,QAAA,EAAE,OAAO,QAA2B,CAAC;IAChD,IAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAEtC,OAAO;QACL,IAAI,MAAA;QACJ,OAAO,SAAA;QACP,UAAU,YAAA;KACX,CAAC;AACJ,CAAC,CAAC;AAEF,IAAM,gBAAgB,GAAG,UAAC,KAAgB;IACxC,OAAO,KAAK,CAAC,QAAQ,CAAU,KAAK,CAAC,IAAI,CAAC,CAAC;AAC7C,CAAC,CAAC"}
1
+ {"version":3,"file":"useMenu.js","sourceRoot":"","sources":["../../src/Menu/useMenu.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAGxD,MAAM,CAAC,IAAM,OAAO,GAAG,UAAC,KAAgB;IAChC,IAAA,KAAkB,gBAAgB,CAAC,KAAK,CAAC,EAAxC,IAAI,QAAA,EAAE,OAAO,QAA2B,CAAC;IAChD,IAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACtC,IAAM,OAAO,GAAG,cAAc,EAAE,CAAC;IACjC,IAAM,SAAS,GAAG,OAAO,CAAC,UAAU,KAAK,IAAI,CAAC;IAE9C,OAAO;QACL,IAAI,MAAA;QACJ,OAAO,SAAA;QACP,UAAU,YAAA;QACV,SAAS,WAAA;KACV,CAAC;AACJ,CAAC,CAAC;AAEF,IAAM,gBAAgB,GAAG,UAAC,KAAgB;IACxC,OAAO,KAAK,CAAC,QAAQ,CAAU,KAAK,CAAC,IAAI,CAAC,CAAC;AAC7C,CAAC,CAAC"}
@@ -1,4 +1,4 @@
1
1
  export var useMenuContextValue = function (state) {
2
- return { open: state.open, setOpen: state.setOpen, triggerRef: state.triggerRef };
2
+ return { open: state.open, setOpen: state.setOpen, triggerRef: state.triggerRef, isSubmenu: state.isSubmenu };
3
3
  };
4
4
  //# sourceMappingURL=useMenuContextValue.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useMenuContextValue.js","sourceRoot":"","sources":["../../src/Menu/useMenuContextValue.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,IAAM,mBAAmB,GAAG,UAAC,KAAgB;IAClD,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC;AACpF,CAAC,CAAC"}
1
+ {"version":3,"file":"useMenuContextValue.js","sourceRoot":"","sources":["../../src/Menu/useMenuContextValue.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,IAAM,mBAAmB,GAAG,UAAC,KAAgB;IAClD,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC;AAChH,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { MenuItemProps } from './MenuItem.types';
2
+ export declare const MenuItem: import("@fluentui-react-native/framework").ComposableComponent<MenuItemProps, import("./MenuItem.types").MenuItemSlotProps, import("./MenuItem.types").MenuItemTokens, object>;
3
+ //# sourceMappingURL=MenuItem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MenuItem.d.ts","sourceRoot":"","sources":["../../src/MenuItem/MenuItem.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAgB,aAAa,EAAgB,MAAM,kBAAkB,CAAC;AAG7E,eAAO,MAAM,QAAQ,gLAoCnB,CAAC"}
@@ -0,0 +1,38 @@
1
+ import { __assign } from "tslib";
2
+ /** @jsx withSlots */
3
+ import { View } from 'react-native';
4
+ import { SvgXml } from 'react-native-svg';
5
+ import { compose, mergeProps, withSlots } from '@fluentui-react-native/framework';
6
+ import { Text } from '@fluentui-react-native/experimental-text';
7
+ import { menuItemName } from './MenuItem.types';
8
+ import { useMenuItem } from './useMenuItem';
9
+ export var MenuItem = compose({
10
+ displayName: menuItemName,
11
+ tokens: [],
12
+ slotProps: {
13
+ root: {
14
+ style: { height: 48, width: 200, flexDirection: 'row', alignItems: 'center', backgroundColor: 'transparent' },
15
+ },
16
+ content: {
17
+ color: 'white',
18
+ },
19
+ },
20
+ slots: {
21
+ root: View,
22
+ content: Text,
23
+ submenuIndicator: SvgXml,
24
+ },
25
+ useRender: function (userProps, useSlots) {
26
+ var menuItem = useMenuItem(userProps);
27
+ // grab the styled slots
28
+ var Slots = useSlots(userProps);
29
+ return function (final) {
30
+ var mergedProps = mergeProps(menuItem.props, final);
31
+ var chevronXml = "\n <svg width=\"12\" height=\"16\" viewBox=\"0 0 11 6\">\n <path fill='white' d='M0.646447 0.646447C0.841709 0.451184 1.15829 0.451184 1.35355 0.646447L5.5 4.79289L9.64645 0.646447C9.84171 0.451185 10.1583 0.451185 10.3536 0.646447C10.5488 0.841709 10.5488 1.15829 10.3536 1.35355L5.85355 5.85355C5.65829 6.04882 5.34171 6.04882 5.14645 5.85355L0.646447 1.35355C0.451184 1.15829 0.451184 0.841709 0.646447 0.646447Z' />\n </svg>";
32
+ return (withSlots(Slots.root, __assign({}, mergedProps),
33
+ mergedProps.content && withSlots(Slots.content, null, mergedProps.content),
34
+ mergedProps.hasSubmenu && withSlots(Slots.submenuIndicator, { xml: chevronXml })));
35
+ };
36
+ },
37
+ });
38
+ //# sourceMappingURL=MenuItem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MenuItem.js","sourceRoot":"","sources":["../../src/MenuItem/MenuItem.tsx"],"names":[],"mappings":";AAAA,qBAAqB;AACrB,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,UAAU,EAAY,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC5F,OAAO,EAAE,IAAI,EAAE,MAAM,0CAA0C,CAAC;AAChE,OAAO,EAAE,YAAY,EAA+B,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,CAAC,IAAM,QAAQ,GAAG,OAAO,CAAe;IAC5C,WAAW,EAAE,YAAY;IACzB,MAAM,EAAE,EAAE;IACV,SAAS,EAAE;QACT,IAAI,EAAE;YACJ,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,eAAe,EAAE,aAAa,EAAE;SAC9G;QACD,OAAO,EAAE;YACP,KAAK,EAAE,OAAO;SACf;KACF;IACD,KAAK,EAAE;QACL,IAAI,EAAE,IAAI;QACV,OAAO,EAAE,IAAI;QACb,gBAAgB,EAAE,MAAM;KACzB;IACD,SAAS,EAAE,UAAC,SAAwB,EAAE,QAAgC;QACpE,IAAM,QAAQ,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;QACxC,wBAAwB;QACxB,IAAM,KAAK,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;QAElC,OAAO,UAAC,KAAoB;YAC1B,IAAM,WAAW,GAAG,UAAU,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YACtD,IAAM,UAAU,GAAG,+bAGZ,CAAC;YAER,OAAO,CACL,UAAC,KAAK,CAAC,IAAI,eAAK,WAAW;gBACxB,WAAW,CAAC,OAAO,IAAI,UAAC,KAAK,CAAC,OAAO,QAAE,WAAW,CAAC,OAAO,CAAiB;gBAC3E,WAAW,CAAC,UAAU,IAAI,UAAC,KAAK,CAAC,gBAAgB,IAAC,GAAG,EAAE,UAAU,GAAI,CAC3D,CACd,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,41 @@
1
+ import * as React from 'react';
2
+ import { ViewProps } from 'react-native';
3
+ import { SvgProps, XmlProps } from 'react-native-svg';
4
+ import type { IViewProps } from '@fluentui-react-native/adapters';
5
+ import { TextProps } from '@fluentui-react-native/experimental-text';
6
+ import { IFocusable, InteractionEvent, IPressableHooks, IWithPressableOptions } from '@fluentui-react-native/interactive-hooks';
7
+ import { FontTokens, IBorderTokens, IColorTokens, IShadowTokens, LayoutTokens } from '@fluentui-react-native/tokens';
8
+ export declare const menuItemName = "MenuItem";
9
+ export interface MenuItemTokens extends LayoutTokens, FontTokens, IBorderTokens, IShadowTokens, IColorTokens {
10
+ }
11
+ export interface MenuItemProps extends Omit<IWithPressableOptions<ViewProps>, 'onPress'> {
12
+ content: string;
13
+ /**
14
+ * Applies disabled styles to menu item but remains focusable
15
+ */
16
+ disabled?: boolean;
17
+ /**
18
+ * A RefObject to access the IButton interface. Use this to access the public methods and properties of the component.
19
+ */
20
+ componentRef?: React.RefObject<IFocusable>;
21
+ /**
22
+ * If the menu item is a trigger for a submenu
23
+ */
24
+ hasSubmenu?: boolean;
25
+ /**
26
+ * A callback to call on button click event
27
+ */
28
+ onClick?: (e: InteractionEvent) => void;
29
+ }
30
+ export declare type MenuItemState = IPressableHooks<MenuItemProps & React.ComponentPropsWithRef<any>>;
31
+ export interface MenuItemSlotProps {
32
+ root: React.PropsWithRef<IViewProps>;
33
+ content?: TextProps;
34
+ submenuIndicator?: SvgProps | XmlProps;
35
+ }
36
+ export interface MenuItemType {
37
+ props: MenuItemProps;
38
+ tokens: MenuItemTokens;
39
+ slotProps: MenuItemSlotProps;
40
+ }
41
+ //# sourceMappingURL=MenuItem.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MenuItem.types.d.ts","sourceRoot":"","sources":["../../src/MenuItem/MenuItem.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AAChI,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAErH,eAAO,MAAM,YAAY,aAAa,CAAC;AAEvC,MAAM,WAAW,cAAe,SAAQ,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY;CAAG;AAE/G,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,qBAAqB,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtF,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;OAEG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IAE3C;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,gBAAgB,KAAK,IAAI,CAAC;CACzC;AAED,oBAAY,aAAa,GAAG,eAAe,CAAC,aAAa,GAAG,KAAK,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,CAAC;AAE9F,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,KAAK,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;IACrC,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,gBAAgB,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;CACxC;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,aAAa,CAAC;IACrB,MAAM,EAAE,cAAc,CAAC;IACvB,SAAS,EAAE,iBAAiB,CAAC;CAC9B"}
@@ -0,0 +1,2 @@
1
+ export var menuItemName = 'MenuItem';
2
+ //# sourceMappingURL=MenuItem.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MenuItem.types.js","sourceRoot":"","sources":["../../src/MenuItem/MenuItem.types.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,IAAM,YAAY,GAAG,UAAU,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { MenuItemProps, MenuItemState } from './MenuItem.types';
2
+ export declare const useMenuItem: (props: MenuItemProps) => MenuItemState;
3
+ //# sourceMappingURL=useMenuItem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMenuItem.d.ts","sourceRoot":"","sources":["../../src/MenuItem/useMenuItem.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAKhE,eAAO,MAAM,WAAW,UAAW,aAAa,KAAG,aAwBlD,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { __assign, __rest } from "tslib";
2
+ import * as React from 'react';
3
+ import { memoize } from '@fluentui-react-native/framework';
4
+ import { useAsPressable, useKeyProps } from '@fluentui-react-native/interactive-hooks';
5
+ import { useMenuContext } from '../context/menuContext';
6
+ export var useMenuItem = function (props) {
7
+ // attach the pressable state handlers
8
+ var defaultComponentRef = React.useRef(null);
9
+ var onClick = props.onClick, accessibilityState = props.accessibilityState, _a = props.componentRef, componentRef = _a === void 0 ? defaultComponentRef : _a, disabled = props.disabled, rest = __rest(props, ["onClick", "accessibilityState", "componentRef", "disabled"]);
10
+ var pressable = useAsPressable(__assign(__assign({}, rest), { disabled: disabled, onPress: onClick }));
11
+ var onKeyProps = useKeyProps(onClick, ' ', 'Enter');
12
+ var hasSubmenu = useMenuContext().isSubmenu;
13
+ return {
14
+ props: __assign(__assign(__assign({}, pressable.props), { accessible: true, accessibilityRole: 'button', onAccessibilityTap: props.onAccessibilityTap || props.onClick, accessibilityLabel: props.accessibilityLabel, accessibilityState: getAccessibilityState(disabled, accessibilityState), enableFocusRing: true, focusable: !disabled, hasSubmenu: hasSubmenu, ref: componentRef }), onKeyProps),
15
+ state: pressable.state,
16
+ };
17
+ };
18
+ var getAccessibilityState = memoize(getAccessibilityStateWorker);
19
+ function getAccessibilityStateWorker(disabled, accessibilityState) {
20
+ if (accessibilityState) {
21
+ return __assign({ disabled: disabled }, accessibilityState);
22
+ }
23
+ return { disabled: disabled };
24
+ }
25
+ //# sourceMappingURL=useMenuItem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMenuItem.js","sourceRoot":"","sources":["../../src/MenuItem/useMenuItem.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AACvF,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,MAAM,CAAC,IAAM,WAAW,GAAG,UAAC,KAAoB;IAC9C,sCAAsC;IACtC,IAAM,mBAAmB,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACvC,IAAA,OAAO,GAAgF,KAAK,QAArF,EAAE,kBAAkB,GAA4D,KAAK,mBAAjE,EAAE,KAA0D,KAAK,aAA7B,EAAlC,YAAY,mBAAG,mBAAmB,KAAA,EAAE,QAAQ,GAAc,KAAK,SAAnB,EAAK,IAAI,UAAK,KAAK,EAA9F,6DAAsF,CAAF,CAAW;IACrG,IAAM,SAAS,GAAG,cAAc,uBAAM,IAAI,KAAE,QAAQ,UAAA,EAAE,OAAO,EAAE,OAAO,IAAG,CAAC;IAC1E,IAAM,UAAU,GAAG,WAAW,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IACtD,IAAM,UAAU,GAAG,cAAc,EAAE,CAAC,SAAS,CAAC;IAE9C,OAAO;QACL,KAAK,iCACA,SAAS,CAAC,KAAK,KAClB,UAAU,EAAE,IAAI,EAChB,iBAAiB,EAAE,QAAQ,EAC3B,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,IAAI,KAAK,CAAC,OAAO,EAC7D,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,EAC5C,kBAAkB,EAAE,qBAAqB,CAAC,QAAQ,EAAE,kBAAkB,CAAC,EACvE,eAAe,EAAE,IAAI,EACrB,SAAS,EAAE,CAAC,QAAQ,EACpB,UAAU,YAAA,EACV,GAAG,EAAE,YAAY,KACd,UAAU,CACd;QACD,KAAK,EAAE,SAAS,CAAC,KAAK;KACvB,CAAC;AACJ,CAAC,CAAC;AAEF,IAAM,qBAAqB,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAC;AACnE,SAAS,2BAA2B,CAAC,QAAiB,EAAE,kBAAuC;IAC7F,IAAI,kBAAkB,EAAE;QACtB,kBAAS,QAAQ,UAAA,IAAK,kBAAkB,EAAG;KAC5C;IACD,OAAO,EAAE,QAAQ,UAAA,EAAE,CAAC;AACtB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"menuContext.d.ts","sourceRoot":"","sources":["../../src/context/menuContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD;;GAEG;AACH,oBAAY,gBAAgB,GAAG,SAAS,CAAC;AAEzC,eAAO,MAAM,WAAW,0BAItB,CAAC;AAEH,eAAO,MAAM,YAAY,2BAAuB,CAAC;AACjD,eAAO,MAAM,cAAc,iBAAsC,CAAC"}
1
+ {"version":3,"file":"menuContext.d.ts","sourceRoot":"","sources":["../../src/context/menuContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD;;GAEG;AACH,oBAAY,gBAAgB,GAAG,SAAS,CAAC;AAEzC,eAAO,MAAM,WAAW,0BAKtB,CAAC;AAEH,eAAO,MAAM,YAAY,2BAAuB,CAAC;AACjD,eAAO,MAAM,cAAc,iBAAsC,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import * as React from 'react';
2
2
  export var MenuContext = React.createContext({
3
+ isSubmenu: false,
3
4
  open: false,
4
5
  setOpen: function () { return false; },
5
6
  triggerRef: null,
@@ -1 +1 @@
1
- {"version":3,"file":"menuContext.js","sourceRoot":"","sources":["../../src/context/menuContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAQ/B,MAAM,CAAC,IAAM,WAAW,GAAG,KAAK,CAAC,aAAa,CAAmB;IAC/D,IAAI,EAAE,KAAK;IACX,OAAO,EAAE,cAAM,OAAA,KAAK,EAAL,CAAK;IACpB,UAAU,EAAE,IAAI;CACjB,CAAC,CAAC;AAEH,MAAM,CAAC,IAAM,YAAY,GAAG,WAAW,CAAC,QAAQ,CAAC;AACjD,MAAM,CAAC,IAAM,cAAc,GAAG,cAAM,OAAA,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,EAA7B,CAA6B,CAAC"}
1
+ {"version":3,"file":"menuContext.js","sourceRoot":"","sources":["../../src/context/menuContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAQ/B,MAAM,CAAC,IAAM,WAAW,GAAG,KAAK,CAAC,aAAa,CAAmB;IAC/D,SAAS,EAAE,KAAK;IAChB,IAAI,EAAE,KAAK;IACX,OAAO,EAAE,cAAM,OAAA,KAAK,EAAL,CAAK;IACpB,UAAU,EAAE,IAAI;CACjB,CAAC,CAAC;AAEH,MAAM,CAAC,IAAM,YAAY,GAAG,WAAW,CAAC,QAAQ,CAAC;AACjD,MAAM,CAAC,IAAM,cAAc,GAAG,cAAM,OAAA,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,EAA7B,CAA6B,CAAC"}
package/lib/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { Menu } from './Menu/Menu';
2
2
  export { MenuTrigger } from './MenuTrigger/MenuTrigger';
3
3
  export { MenuPopover } from './MenuPopover/MenuPopover';
4
+ export { MenuItem } from './MenuItem/MenuItem';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC"}
package/lib/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export { Menu } from './Menu/Menu';
2
2
  export { MenuTrigger } from './MenuTrigger/MenuTrigger';
3
3
  export { MenuPopover } from './MenuPopover/MenuPopover';
4
+ export { MenuItem } from './MenuItem/MenuItem';
4
5
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC"}
@@ -5,6 +5,7 @@ export interface MenuProps extends Omit<IViewProps, 'onPress'> {
5
5
  open?: boolean;
6
6
  }
7
7
  export interface MenuState extends MenuProps {
8
+ isSubmenu: boolean;
8
9
  setOpen: (isOpen: boolean) => void;
9
10
  triggerRef: React.RefObject<React.Component>;
10
11
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Menu.types.d.ts","sourceRoot":"","sources":["../../src/Menu/Menu.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,eAAO,MAAM,QAAQ,SAAS,CAAC;AAE/B,MAAM,WAAW,SAAU,SAAQ,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC;IAC5D,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,SAAU,SAAQ,SAAS;IAC1C,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IACnC,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;CAC9C"}
1
+ {"version":3,"file":"Menu.types.d.ts","sourceRoot":"","sources":["../../src/Menu/Menu.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,eAAO,MAAM,QAAQ,SAAS,CAAC;AAE/B,MAAM,WAAW,SAAU,SAAQ,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC;IAC5D,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,SAAU,SAAQ,SAAS;IAC1C,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IACnC,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;CAC9C"}
@@ -1 +1 @@
1
- {"version":3,"file":"useMenu.d.ts","sourceRoot":"","sources":["../../src/Menu/useMenu.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEpD,eAAO,MAAM,OAAO,UAAW,SAAS,KAAG,SAS1C,CAAC"}
1
+ {"version":3,"file":"useMenu.d.ts","sourceRoot":"","sources":["../../src/Menu/useMenu.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEpD,eAAO,MAAM,OAAO,UAAW,SAAS,KAAG,SAY1C,CAAC"}
@@ -3,13 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useMenu = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var react_1 = (0, tslib_1.__importDefault)(require("react"));
6
+ var menuContext_1 = require("../context/menuContext");
6
7
  var useMenu = function (props) {
7
8
  var _a = useMenuOpenState(props), open = _a[0], setOpen = _a[1];
8
9
  var triggerRef = react_1.default.useRef(null);
10
+ var context = (0, menuContext_1.useMenuContext)();
11
+ var isSubmenu = context.triggerRef !== null;
9
12
  return {
10
13
  open: open,
11
14
  setOpen: setOpen,
12
15
  triggerRef: triggerRef,
16
+ isSubmenu: isSubmenu,
13
17
  };
14
18
  };
15
19
  exports.useMenu = useMenu;
@@ -1 +1 @@
1
- {"version":3,"file":"useMenu.js","sourceRoot":"","sources":["../../src/Menu/useMenu.ts"],"names":[],"mappings":";;;;AAAA,6DAA0B;AAGnB,IAAM,OAAO,GAAG,UAAC,KAAgB;IAChC,IAAA,KAAkB,gBAAgB,CAAC,KAAK,CAAC,EAAxC,IAAI,QAAA,EAAE,OAAO,QAA2B,CAAC;IAChD,IAAM,UAAU,GAAG,eAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAEtC,OAAO;QACL,IAAI,MAAA;QACJ,OAAO,SAAA;QACP,UAAU,YAAA;KACX,CAAC;AACJ,CAAC,CAAC;AATW,QAAA,OAAO,WASlB;AAEF,IAAM,gBAAgB,GAAG,UAAC,KAAgB;IACxC,OAAO,eAAK,CAAC,QAAQ,CAAU,KAAK,CAAC,IAAI,CAAC,CAAC;AAC7C,CAAC,CAAC"}
1
+ {"version":3,"file":"useMenu.js","sourceRoot":"","sources":["../../src/Menu/useMenu.ts"],"names":[],"mappings":";;;;AAAA,6DAA0B;AAC1B,sDAAwD;AAGjD,IAAM,OAAO,GAAG,UAAC,KAAgB;IAChC,IAAA,KAAkB,gBAAgB,CAAC,KAAK,CAAC,EAAxC,IAAI,QAAA,EAAE,OAAO,QAA2B,CAAC;IAChD,IAAM,UAAU,GAAG,eAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACtC,IAAM,OAAO,GAAG,IAAA,4BAAc,GAAE,CAAC;IACjC,IAAM,SAAS,GAAG,OAAO,CAAC,UAAU,KAAK,IAAI,CAAC;IAE9C,OAAO;QACL,IAAI,MAAA;QACJ,OAAO,SAAA;QACP,UAAU,YAAA;QACV,SAAS,WAAA;KACV,CAAC;AACJ,CAAC,CAAC;AAZW,QAAA,OAAO,WAYlB;AAEF,IAAM,gBAAgB,GAAG,UAAC,KAAgB;IACxC,OAAO,eAAK,CAAC,QAAQ,CAAU,KAAK,CAAC,IAAI,CAAC,CAAC;AAC7C,CAAC,CAAC"}
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useMenuContextValue = void 0;
4
4
  var useMenuContextValue = function (state) {
5
- return { open: state.open, setOpen: state.setOpen, triggerRef: state.triggerRef };
5
+ return { open: state.open, setOpen: state.setOpen, triggerRef: state.triggerRef, isSubmenu: state.isSubmenu };
6
6
  };
7
7
  exports.useMenuContextValue = useMenuContextValue;
8
8
  //# sourceMappingURL=useMenuContextValue.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useMenuContextValue.js","sourceRoot":"","sources":["../../src/Menu/useMenuContextValue.ts"],"names":[],"mappings":";;;AAGO,IAAM,mBAAmB,GAAG,UAAC,KAAgB;IAClD,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC;AACpF,CAAC,CAAC;AAFW,QAAA,mBAAmB,uBAE9B"}
1
+ {"version":3,"file":"useMenuContextValue.js","sourceRoot":"","sources":["../../src/Menu/useMenuContextValue.ts"],"names":[],"mappings":";;;AAGO,IAAM,mBAAmB,GAAG,UAAC,KAAgB;IAClD,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC;AAChH,CAAC,CAAC;AAFW,QAAA,mBAAmB,uBAE9B"}
@@ -0,0 +1,3 @@
1
+ import { MenuItemProps } from './MenuItem.types';
2
+ export declare const MenuItem: import("@fluentui-react-native/framework").ComposableComponent<MenuItemProps, import("./MenuItem.types").MenuItemSlotProps, import("./MenuItem.types").MenuItemTokens, object>;
3
+ //# sourceMappingURL=MenuItem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MenuItem.d.ts","sourceRoot":"","sources":["../../src/MenuItem/MenuItem.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAgB,aAAa,EAAgB,MAAM,kBAAkB,CAAC;AAG7E,eAAO,MAAM,QAAQ,gLAoCnB,CAAC"}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MenuItem = void 0;
4
+ var tslib_1 = require("tslib");
5
+ /** @jsx withSlots */
6
+ var react_native_1 = require("react-native");
7
+ var react_native_svg_1 = require("react-native-svg");
8
+ var framework_1 = require("@fluentui-react-native/framework");
9
+ var experimental_text_1 = require("@fluentui-react-native/experimental-text");
10
+ var MenuItem_types_1 = require("./MenuItem.types");
11
+ var useMenuItem_1 = require("./useMenuItem");
12
+ exports.MenuItem = (0, framework_1.compose)({
13
+ displayName: MenuItem_types_1.menuItemName,
14
+ tokens: [],
15
+ slotProps: {
16
+ root: {
17
+ style: { height: 48, width: 200, flexDirection: 'row', alignItems: 'center', backgroundColor: 'transparent' },
18
+ },
19
+ content: {
20
+ color: 'white',
21
+ },
22
+ },
23
+ slots: {
24
+ root: react_native_1.View,
25
+ content: experimental_text_1.Text,
26
+ submenuIndicator: react_native_svg_1.SvgXml,
27
+ },
28
+ useRender: function (userProps, useSlots) {
29
+ var menuItem = (0, useMenuItem_1.useMenuItem)(userProps);
30
+ // grab the styled slots
31
+ var Slots = useSlots(userProps);
32
+ return function (final) {
33
+ var mergedProps = (0, framework_1.mergeProps)(menuItem.props, final);
34
+ var chevronXml = "\n <svg width=\"12\" height=\"16\" viewBox=\"0 0 11 6\">\n <path fill='white' d='M0.646447 0.646447C0.841709 0.451184 1.15829 0.451184 1.35355 0.646447L5.5 4.79289L9.64645 0.646447C9.84171 0.451185 10.1583 0.451185 10.3536 0.646447C10.5488 0.841709 10.5488 1.15829 10.3536 1.35355L5.85355 5.85355C5.65829 6.04882 5.34171 6.04882 5.14645 5.85355L0.646447 1.35355C0.451184 1.15829 0.451184 0.841709 0.646447 0.646447Z' />\n </svg>";
35
+ return ((0, framework_1.withSlots)(Slots.root, (0, tslib_1.__assign)({}, mergedProps),
36
+ mergedProps.content && (0, framework_1.withSlots)(Slots.content, null, mergedProps.content),
37
+ mergedProps.hasSubmenu && (0, framework_1.withSlots)(Slots.submenuIndicator, { xml: chevronXml })));
38
+ };
39
+ },
40
+ });
41
+ //# sourceMappingURL=MenuItem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MenuItem.js","sourceRoot":"","sources":["../../src/MenuItem/MenuItem.tsx"],"names":[],"mappings":";;;;AAAA,qBAAqB;AACrB,6CAAoC;AACpC,qDAA0C;AAC1C,8DAA4F;AAC5F,8EAAgE;AAChE,mDAA6E;AAC7E,6CAA4C;AAE/B,QAAA,QAAQ,GAAG,IAAA,mBAAO,EAAe;IAC5C,WAAW,EAAE,6BAAY;IACzB,MAAM,EAAE,EAAE;IACV,SAAS,EAAE;QACT,IAAI,EAAE;YACJ,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,eAAe,EAAE,aAAa,EAAE;SAC9G;QACD,OAAO,EAAE;YACP,KAAK,EAAE,OAAO;SACf;KACF;IACD,KAAK,EAAE;QACL,IAAI,EAAE,mBAAI;QACV,OAAO,EAAE,wBAAI;QACb,gBAAgB,EAAE,yBAAM;KACzB;IACD,SAAS,EAAE,UAAC,SAAwB,EAAE,QAAgC;QACpE,IAAM,QAAQ,GAAG,IAAA,yBAAW,EAAC,SAAS,CAAC,CAAC;QACxC,wBAAwB;QACxB,IAAM,KAAK,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;QAElC,OAAO,UAAC,KAAoB;YAC1B,IAAM,WAAW,GAAG,IAAA,sBAAU,EAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YACtD,IAAM,UAAU,GAAG,+bAGZ,CAAC;YAER,OAAO,CACL,2BAAC,KAAK,CAAC,IAAI,4BAAK,WAAW;gBACxB,WAAW,CAAC,OAAO,IAAI,2BAAC,KAAK,CAAC,OAAO,QAAE,WAAW,CAAC,OAAO,CAAiB;gBAC3E,WAAW,CAAC,UAAU,IAAI,2BAAC,KAAK,CAAC,gBAAgB,IAAC,GAAG,EAAE,UAAU,GAAI,CAC3D,CACd,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,41 @@
1
+ import * as React from 'react';
2
+ import { ViewProps } from 'react-native';
3
+ import { SvgProps, XmlProps } from 'react-native-svg';
4
+ import type { IViewProps } from '@fluentui-react-native/adapters';
5
+ import { TextProps } from '@fluentui-react-native/experimental-text';
6
+ import { IFocusable, InteractionEvent, IPressableHooks, IWithPressableOptions } from '@fluentui-react-native/interactive-hooks';
7
+ import { FontTokens, IBorderTokens, IColorTokens, IShadowTokens, LayoutTokens } from '@fluentui-react-native/tokens';
8
+ export declare const menuItemName = "MenuItem";
9
+ export interface MenuItemTokens extends LayoutTokens, FontTokens, IBorderTokens, IShadowTokens, IColorTokens {
10
+ }
11
+ export interface MenuItemProps extends Omit<IWithPressableOptions<ViewProps>, 'onPress'> {
12
+ content: string;
13
+ /**
14
+ * Applies disabled styles to menu item but remains focusable
15
+ */
16
+ disabled?: boolean;
17
+ /**
18
+ * A RefObject to access the IButton interface. Use this to access the public methods and properties of the component.
19
+ */
20
+ componentRef?: React.RefObject<IFocusable>;
21
+ /**
22
+ * If the menu item is a trigger for a submenu
23
+ */
24
+ hasSubmenu?: boolean;
25
+ /**
26
+ * A callback to call on button click event
27
+ */
28
+ onClick?: (e: InteractionEvent) => void;
29
+ }
30
+ export declare type MenuItemState = IPressableHooks<MenuItemProps & React.ComponentPropsWithRef<any>>;
31
+ export interface MenuItemSlotProps {
32
+ root: React.PropsWithRef<IViewProps>;
33
+ content?: TextProps;
34
+ submenuIndicator?: SvgProps | XmlProps;
35
+ }
36
+ export interface MenuItemType {
37
+ props: MenuItemProps;
38
+ tokens: MenuItemTokens;
39
+ slotProps: MenuItemSlotProps;
40
+ }
41
+ //# sourceMappingURL=MenuItem.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MenuItem.types.d.ts","sourceRoot":"","sources":["../../src/MenuItem/MenuItem.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AAChI,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAErH,eAAO,MAAM,YAAY,aAAa,CAAC;AAEvC,MAAM,WAAW,cAAe,SAAQ,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY;CAAG;AAE/G,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,qBAAqB,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtF,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;OAEG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IAE3C;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,gBAAgB,KAAK,IAAI,CAAC;CACzC;AAED,oBAAY,aAAa,GAAG,eAAe,CAAC,aAAa,GAAG,KAAK,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,CAAC;AAE9F,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,KAAK,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;IACrC,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,gBAAgB,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;CACxC;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,aAAa,CAAC;IACrB,MAAM,EAAE,cAAc,CAAC;IACvB,SAAS,EAAE,iBAAiB,CAAC;CAC9B"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.menuItemName = void 0;
4
+ exports.menuItemName = 'MenuItem';
5
+ //# sourceMappingURL=MenuItem.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MenuItem.types.js","sourceRoot":"","sources":["../../src/MenuItem/MenuItem.types.ts"],"names":[],"mappings":";;;AAQa,QAAA,YAAY,GAAG,UAAU,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { MenuItemProps, MenuItemState } from './MenuItem.types';
2
+ export declare const useMenuItem: (props: MenuItemProps) => MenuItemState;
3
+ //# sourceMappingURL=useMenuItem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMenuItem.d.ts","sourceRoot":"","sources":["../../src/MenuItem/useMenuItem.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAKhE,eAAO,MAAM,WAAW,UAAW,aAAa,KAAG,aAwBlD,CAAC"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useMenuItem = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var React = (0, tslib_1.__importStar)(require("react"));
6
+ var framework_1 = require("@fluentui-react-native/framework");
7
+ var interactive_hooks_1 = require("@fluentui-react-native/interactive-hooks");
8
+ var menuContext_1 = require("../context/menuContext");
9
+ var useMenuItem = function (props) {
10
+ // attach the pressable state handlers
11
+ var defaultComponentRef = React.useRef(null);
12
+ var onClick = props.onClick, accessibilityState = props.accessibilityState, _a = props.componentRef, componentRef = _a === void 0 ? defaultComponentRef : _a, disabled = props.disabled, rest = (0, tslib_1.__rest)(props, ["onClick", "accessibilityState", "componentRef", "disabled"]);
13
+ var pressable = (0, interactive_hooks_1.useAsPressable)((0, tslib_1.__assign)((0, tslib_1.__assign)({}, rest), { disabled: disabled, onPress: onClick }));
14
+ var onKeyProps = (0, interactive_hooks_1.useKeyProps)(onClick, ' ', 'Enter');
15
+ var hasSubmenu = (0, menuContext_1.useMenuContext)().isSubmenu;
16
+ return {
17
+ props: (0, tslib_1.__assign)((0, tslib_1.__assign)((0, tslib_1.__assign)({}, pressable.props), { accessible: true, accessibilityRole: 'button', onAccessibilityTap: props.onAccessibilityTap || props.onClick, accessibilityLabel: props.accessibilityLabel, accessibilityState: getAccessibilityState(disabled, accessibilityState), enableFocusRing: true, focusable: !disabled, hasSubmenu: hasSubmenu, ref: componentRef }), onKeyProps),
18
+ state: pressable.state,
19
+ };
20
+ };
21
+ exports.useMenuItem = useMenuItem;
22
+ var getAccessibilityState = (0, framework_1.memoize)(getAccessibilityStateWorker);
23
+ function getAccessibilityStateWorker(disabled, accessibilityState) {
24
+ if (accessibilityState) {
25
+ return (0, tslib_1.__assign)({ disabled: disabled }, accessibilityState);
26
+ }
27
+ return { disabled: disabled };
28
+ }
29
+ //# sourceMappingURL=useMenuItem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMenuItem.js","sourceRoot":"","sources":["../../src/MenuItem/useMenuItem.ts"],"names":[],"mappings":";;;;AAAA,wDAA+B;AAG/B,8DAA2D;AAC3D,8EAAuF;AACvF,sDAAwD;AAEjD,IAAM,WAAW,GAAG,UAAC,KAAoB;IAC9C,sCAAsC;IACtC,IAAM,mBAAmB,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACvC,IAAA,OAAO,GAAgF,KAAK,QAArF,EAAE,kBAAkB,GAA4D,KAAK,mBAAjE,EAAE,KAA0D,KAAK,aAA7B,EAAlC,YAAY,mBAAG,mBAAmB,KAAA,EAAE,QAAQ,GAAc,KAAK,SAAnB,EAAK,IAAI,uBAAK,KAAK,EAA9F,6DAAsF,CAAF,CAAW;IACrG,IAAM,SAAS,GAAG,IAAA,kCAAc,kDAAM,IAAI,KAAE,QAAQ,UAAA,EAAE,OAAO,EAAE,OAAO,IAAG,CAAC;IAC1E,IAAM,UAAU,GAAG,IAAA,+BAAW,EAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IACtD,IAAM,UAAU,GAAG,IAAA,4BAAc,GAAE,CAAC,SAAS,CAAC;IAE9C,OAAO;QACL,KAAK,wEACA,SAAS,CAAC,KAAK,KAClB,UAAU,EAAE,IAAI,EAChB,iBAAiB,EAAE,QAAQ,EAC3B,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,IAAI,KAAK,CAAC,OAAO,EAC7D,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,EAC5C,kBAAkB,EAAE,qBAAqB,CAAC,QAAQ,EAAE,kBAAkB,CAAC,EACvE,eAAe,EAAE,IAAI,EACrB,SAAS,EAAE,CAAC,QAAQ,EACpB,UAAU,YAAA,EACV,GAAG,EAAE,YAAY,KACd,UAAU,CACd;QACD,KAAK,EAAE,SAAS,CAAC,KAAK;KACvB,CAAC;AACJ,CAAC,CAAC;AAxBW,QAAA,WAAW,eAwBtB;AAEF,IAAM,qBAAqB,GAAG,IAAA,mBAAO,EAAC,2BAA2B,CAAC,CAAC;AACnE,SAAS,2BAA2B,CAAC,QAAiB,EAAE,kBAAuC;IAC7F,IAAI,kBAAkB,EAAE;QACtB,+BAAS,QAAQ,UAAA,IAAK,kBAAkB,EAAG;KAC5C;IACD,OAAO,EAAE,QAAQ,UAAA,EAAE,CAAC;AACtB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"menuContext.d.ts","sourceRoot":"","sources":["../../src/context/menuContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD;;GAEG;AACH,oBAAY,gBAAgB,GAAG,SAAS,CAAC;AAEzC,eAAO,MAAM,WAAW,0BAItB,CAAC;AAEH,eAAO,MAAM,YAAY,2BAAuB,CAAC;AACjD,eAAO,MAAM,cAAc,iBAAsC,CAAC"}
1
+ {"version":3,"file":"menuContext.d.ts","sourceRoot":"","sources":["../../src/context/menuContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD;;GAEG;AACH,oBAAY,gBAAgB,GAAG,SAAS,CAAC;AAEzC,eAAO,MAAM,WAAW,0BAKtB,CAAC;AAEH,eAAO,MAAM,YAAY,2BAAuB,CAAC;AACjD,eAAO,MAAM,cAAc,iBAAsC,CAAC"}
@@ -4,6 +4,7 @@ exports.useMenuContext = exports.MenuProvider = exports.MenuContext = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var React = (0, tslib_1.__importStar)(require("react"));
6
6
  exports.MenuContext = React.createContext({
7
+ isSubmenu: false,
7
8
  open: false,
8
9
  setOpen: function () { return false; },
9
10
  triggerRef: null,
@@ -1 +1 @@
1
- {"version":3,"file":"menuContext.js","sourceRoot":"","sources":["../../src/context/menuContext.ts"],"names":[],"mappings":";;;;AAAA,wDAA+B;AAQlB,QAAA,WAAW,GAAG,KAAK,CAAC,aAAa,CAAmB;IAC/D,IAAI,EAAE,KAAK;IACX,OAAO,EAAE,cAAM,OAAA,KAAK,EAAL,CAAK;IACpB,UAAU,EAAE,IAAI;CACjB,CAAC,CAAC;AAEU,QAAA,YAAY,GAAG,mBAAW,CAAC,QAAQ,CAAC;AAC1C,IAAM,cAAc,GAAG,cAAM,OAAA,KAAK,CAAC,UAAU,CAAC,mBAAW,CAAC,EAA7B,CAA6B,CAAC;AAArD,QAAA,cAAc,kBAAuC"}
1
+ {"version":3,"file":"menuContext.js","sourceRoot":"","sources":["../../src/context/menuContext.ts"],"names":[],"mappings":";;;;AAAA,wDAA+B;AAQlB,QAAA,WAAW,GAAG,KAAK,CAAC,aAAa,CAAmB;IAC/D,SAAS,EAAE,KAAK;IAChB,IAAI,EAAE,KAAK;IACX,OAAO,EAAE,cAAM,OAAA,KAAK,EAAL,CAAK;IACpB,UAAU,EAAE,IAAI;CACjB,CAAC,CAAC;AAEU,QAAA,YAAY,GAAG,mBAAW,CAAC,QAAQ,CAAC;AAC1C,IAAM,cAAc,GAAG,cAAM,OAAA,KAAK,CAAC,UAAU,CAAC,mBAAW,CAAC,EAA7B,CAA6B,CAAC;AAArD,QAAA,cAAc,kBAAuC"}
@@ -1,4 +1,5 @@
1
1
  export { Menu } from './Menu/Menu';
2
2
  export { MenuTrigger } from './MenuTrigger/MenuTrigger';
3
3
  export { MenuPopover } from './MenuPopover/MenuPopover';
4
+ export { MenuItem } from './MenuItem/MenuItem';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC"}
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MenuPopover = exports.MenuTrigger = exports.Menu = void 0;
3
+ exports.MenuItem = exports.MenuPopover = exports.MenuTrigger = exports.Menu = void 0;
4
4
  var Menu_1 = require("./Menu/Menu");
5
5
  Object.defineProperty(exports, "Menu", { enumerable: true, get: function () { return Menu_1.Menu; } });
6
6
  var MenuTrigger_1 = require("./MenuTrigger/MenuTrigger");
7
7
  Object.defineProperty(exports, "MenuTrigger", { enumerable: true, get: function () { return MenuTrigger_1.MenuTrigger; } });
8
8
  var MenuPopover_1 = require("./MenuPopover/MenuPopover");
9
9
  Object.defineProperty(exports, "MenuPopover", { enumerable: true, get: function () { return MenuPopover_1.MenuPopover; } });
10
+ var MenuItem_1 = require("./MenuItem/MenuItem");
11
+ Object.defineProperty(exports, "MenuItem", { enumerable: true, get: function () { return MenuItem_1.MenuItem; } });
10
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,oCAAmC;AAA1B,4FAAA,IAAI,OAAA;AACb,yDAAwD;AAA/C,0GAAA,WAAW,OAAA;AACpB,yDAAwD;AAA/C,0GAAA,WAAW,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,oCAAmC;AAA1B,4FAAA,IAAI,OAAA;AACb,yDAAwD;AAA/C,0GAAA,WAAW,OAAA;AACpB,yDAAwD;AAA/C,0GAAA,WAAW,OAAA;AACpB,gDAA+C;AAAtC,oGAAA,QAAQ,OAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui-react-native/menu",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "A cross-platform Menu component using the Fluent Design System",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -23,9 +23,12 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@fluentui-react-native/adapters": ">=0.8.5 <1.0.0",
26
- "@fluentui-react-native/callout": ">=0.19.43 <1.0.0",
27
- "@fluentui-react-native/framework": "0.7.23",
28
- "@fluentui-react-native/interactive-hooks": ">=0.15.3 <1.0.0",
26
+ "@fluentui-react-native/callout": ">=0.19.45 <1.0.0",
27
+ "@fluentui-react-native/experimental-text": ">=0.7.25 <1.0.0",
28
+ "@fluentui-react-native/framework": "0.7.25",
29
+ "@fluentui-react-native/interactive-hooks": ">=0.15.5 <1.0.0",
30
+ "@fluentui-react-native/tokens": ">=0.11.11 <1.0.0",
31
+ "react-native-svg": "^12.3.0",
29
32
  "tslib": "^2.3.1"
30
33
  },
31
34
  "devDependencies": {
@@ -8,6 +8,7 @@ export interface MenuProps extends Omit<IViewProps, 'onPress'> {
8
8
  }
9
9
 
10
10
  export interface MenuState extends MenuProps {
11
+ isSubmenu: boolean;
11
12
  setOpen: (isOpen: boolean) => void;
12
13
  triggerRef: React.RefObject<React.Component>;
13
14
  }
@@ -1,14 +1,18 @@
1
1
  import React from 'react';
2
+ import { useMenuContext } from '../context/menuContext';
2
3
  import { MenuProps, MenuState } from './Menu.types';
3
4
 
4
5
  export const useMenu = (props: MenuProps): MenuState => {
5
6
  const [open, setOpen] = useMenuOpenState(props);
6
7
  const triggerRef = React.useRef(null);
8
+ const context = useMenuContext();
9
+ const isSubmenu = context.triggerRef !== null;
7
10
 
8
11
  return {
9
12
  open,
10
13
  setOpen,
11
14
  triggerRef,
15
+ isSubmenu,
12
16
  };
13
17
  };
14
18
 
@@ -2,5 +2,5 @@ import { MenuContextValue } from '../context/menuContext';
2
2
  import { MenuState } from './Menu.types';
3
3
 
4
4
  export const useMenuContextValue = (state: MenuState): MenuContextValue => {
5
- return { open: state.open, setOpen: state.setOpen, triggerRef: state.triggerRef };
5
+ return { open: state.open, setOpen: state.setOpen, triggerRef: state.triggerRef, isSubmenu: state.isSubmenu };
6
6
  };
@@ -0,0 +1,45 @@
1
+ /** @jsx withSlots */
2
+ import { View } from 'react-native';
3
+ import { SvgXml } from 'react-native-svg';
4
+ import { compose, mergeProps, UseSlots, withSlots } from '@fluentui-react-native/framework';
5
+ import { Text } from '@fluentui-react-native/experimental-text';
6
+ import { menuItemName, MenuItemProps, MenuItemType } from './MenuItem.types';
7
+ import { useMenuItem } from './useMenuItem';
8
+
9
+ export const MenuItem = compose<MenuItemType>({
10
+ displayName: menuItemName,
11
+ tokens: [],
12
+ slotProps: {
13
+ root: {
14
+ style: { height: 48, width: 200, flexDirection: 'row', alignItems: 'center', backgroundColor: 'transparent' },
15
+ },
16
+ content: {
17
+ color: 'white',
18
+ },
19
+ },
20
+ slots: {
21
+ root: View,
22
+ content: Text,
23
+ submenuIndicator: SvgXml,
24
+ },
25
+ useRender: (userProps: MenuItemProps, useSlots: UseSlots<MenuItemType>) => {
26
+ const menuItem = useMenuItem(userProps);
27
+ // grab the styled slots
28
+ const Slots = useSlots(userProps);
29
+
30
+ return (final: MenuItemProps) => {
31
+ const mergedProps = mergeProps(menuItem.props, final);
32
+ const chevronXml = `
33
+ <svg width="12" height="16" viewBox="0 0 11 6">
34
+ <path fill='white' d='M0.646447 0.646447C0.841709 0.451184 1.15829 0.451184 1.35355 0.646447L5.5 4.79289L9.64645 0.646447C9.84171 0.451185 10.1583 0.451185 10.3536 0.646447C10.5488 0.841709 10.5488 1.15829 10.3536 1.35355L5.85355 5.85355C5.65829 6.04882 5.34171 6.04882 5.14645 5.85355L0.646447 1.35355C0.451184 1.15829 0.451184 0.841709 0.646447 0.646447Z' />
35
+ </svg>`;
36
+
37
+ return (
38
+ <Slots.root {...mergedProps}>
39
+ {mergedProps.content && <Slots.content>{mergedProps.content}</Slots.content>}
40
+ {mergedProps.hasSubmenu && <Slots.submenuIndicator xml={chevronXml} />}
41
+ </Slots.root>
42
+ );
43
+ };
44
+ },
45
+ });
@@ -0,0 +1,49 @@
1
+ import * as React from 'react';
2
+ import { ViewProps } from 'react-native';
3
+ import { SvgProps, XmlProps } from 'react-native-svg';
4
+ import type { IViewProps } from '@fluentui-react-native/adapters';
5
+ import { TextProps } from '@fluentui-react-native/experimental-text';
6
+ import { IFocusable, InteractionEvent, IPressableHooks, IWithPressableOptions } from '@fluentui-react-native/interactive-hooks';
7
+ import { FontTokens, IBorderTokens, IColorTokens, IShadowTokens, LayoutTokens } from '@fluentui-react-native/tokens';
8
+
9
+ export const menuItemName = 'MenuItem';
10
+
11
+ export interface MenuItemTokens extends LayoutTokens, FontTokens, IBorderTokens, IShadowTokens, IColorTokens {}
12
+
13
+ export interface MenuItemProps extends Omit<IWithPressableOptions<ViewProps>, 'onPress'> {
14
+ content: string;
15
+
16
+ /**
17
+ * Applies disabled styles to menu item but remains focusable
18
+ */
19
+ disabled?: boolean;
20
+
21
+ /**
22
+ * A RefObject to access the IButton interface. Use this to access the public methods and properties of the component.
23
+ */
24
+ componentRef?: React.RefObject<IFocusable>;
25
+
26
+ /**
27
+ * If the menu item is a trigger for a submenu
28
+ */
29
+ hasSubmenu?: boolean;
30
+
31
+ /**
32
+ * A callback to call on button click event
33
+ */
34
+ onClick?: (e: InteractionEvent) => void;
35
+ }
36
+
37
+ export type MenuItemState = IPressableHooks<MenuItemProps & React.ComponentPropsWithRef<any>>;
38
+
39
+ export interface MenuItemSlotProps {
40
+ root: React.PropsWithRef<IViewProps>;
41
+ content?: TextProps;
42
+ submenuIndicator?: SvgProps | XmlProps;
43
+ }
44
+
45
+ export interface MenuItemType {
46
+ props: MenuItemProps;
47
+ tokens: MenuItemTokens;
48
+ slotProps: MenuItemSlotProps;
49
+ }
@@ -0,0 +1,40 @@
1
+ import * as React from 'react';
2
+ import { AccessibilityState } from 'react-native';
3
+ import { MenuItemProps, MenuItemState } from './MenuItem.types';
4
+ import { memoize } from '@fluentui-react-native/framework';
5
+ import { useAsPressable, useKeyProps } from '@fluentui-react-native/interactive-hooks';
6
+ import { useMenuContext } from '../context/menuContext';
7
+
8
+ export const useMenuItem = (props: MenuItemProps): MenuItemState => {
9
+ // attach the pressable state handlers
10
+ const defaultComponentRef = React.useRef(null);
11
+ const { onClick, accessibilityState, componentRef = defaultComponentRef, disabled, ...rest } = props;
12
+ const pressable = useAsPressable({ ...rest, disabled, onPress: onClick });
13
+ const onKeyProps = useKeyProps(onClick, ' ', 'Enter');
14
+ const hasSubmenu = useMenuContext().isSubmenu;
15
+
16
+ return {
17
+ props: {
18
+ ...pressable.props,
19
+ accessible: true,
20
+ accessibilityRole: 'button',
21
+ onAccessibilityTap: props.onAccessibilityTap || props.onClick,
22
+ accessibilityLabel: props.accessibilityLabel,
23
+ accessibilityState: getAccessibilityState(disabled, accessibilityState),
24
+ enableFocusRing: true,
25
+ focusable: !disabled,
26
+ hasSubmenu,
27
+ ref: componentRef,
28
+ ...onKeyProps,
29
+ },
30
+ state: pressable.state,
31
+ };
32
+ };
33
+
34
+ const getAccessibilityState = memoize(getAccessibilityStateWorker);
35
+ function getAccessibilityStateWorker(disabled: boolean, accessibilityState?: AccessibilityState) {
36
+ if (accessibilityState) {
37
+ return { disabled, ...accessibilityState };
38
+ }
39
+ return { disabled };
40
+ }
@@ -7,6 +7,7 @@ import type { MenuState } from '../Menu/Menu.types';
7
7
  export type MenuContextValue = MenuState;
8
8
 
9
9
  export const MenuContext = React.createContext<MenuContextValue>({
10
+ isSubmenu: false,
10
11
  open: false,
11
12
  setOpen: () => false,
12
13
  triggerRef: null,
package/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { Menu } from './Menu/Menu';
2
2
  export { MenuTrigger } from './MenuTrigger/MenuTrigger';
3
3
  export { MenuPopover } from './MenuPopover/MenuPopover';
4
+ export { MenuItem } from './MenuItem/MenuItem';