@fluentui-react-native/menu 0.7.0 → 0.9.1
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/CHANGELOG.json +76 -1
- package/CHANGELOG.md +31 -2
- package/lib/MenuDivider/MenuDivider.d.ts +2 -0
- package/lib/MenuDivider/MenuDivider.d.ts.map +1 -0
- package/lib/MenuDivider/MenuDivider.js +15 -0
- package/lib/MenuDivider/MenuDivider.js.map +1 -0
- package/lib/MenuDivider/MenuDivider.styling.d.ts +4 -0
- package/lib/MenuDivider/MenuDivider.styling.d.ts.map +1 -0
- package/lib/MenuDivider/MenuDivider.styling.js +19 -0
- package/lib/MenuDivider/MenuDivider.styling.js.map +1 -0
- package/lib/MenuDivider/MenuDivider.types.d.ts +21 -0
- package/lib/MenuDivider/MenuDivider.types.d.ts.map +1 -0
- package/lib/MenuDivider/MenuDivider.types.js +2 -0
- package/lib/MenuDivider/MenuDivider.types.js.map +1 -0
- package/lib/MenuDivider/MenuDividerTokens.d.ts +5 -0
- package/lib/MenuDivider/MenuDividerTokens.d.ts.map +1 -0
- package/lib/MenuDivider/MenuDividerTokens.js +7 -0
- package/lib/MenuDivider/MenuDividerTokens.js.map +1 -0
- package/lib/MenuDivider/MenuDividerTokens.win32.d.ts +5 -0
- package/lib/MenuDivider/MenuDividerTokens.win32.d.ts.map +1 -0
- package/lib/MenuDivider/MenuDividerTokens.win32.js +7 -0
- package/lib/MenuDivider/MenuDividerTokens.win32.js.map +1 -0
- package/lib/MenuItem/useMenuItem.d.ts.map +1 -1
- package/lib/MenuItem/useMenuItem.js +3 -2
- package/lib/MenuItem/useMenuItem.js.map +1 -1
- package/lib/MenuItemCheckbox/MenuItemCheckbox.styling.d.ts.map +1 -1
- package/lib/MenuItemCheckbox/MenuItemCheckbox.styling.js +1 -0
- package/lib/MenuItemCheckbox/MenuItemCheckbox.styling.js.map +1 -1
- package/lib/MenuItemCheckbox/MenuItemCheckbox.types.d.ts +3 -4
- package/lib/MenuItemCheckbox/MenuItemCheckbox.types.d.ts.map +1 -1
- package/lib/MenuItemCheckbox/useMenuItemCheckbox.d.ts.map +1 -1
- package/lib/MenuItemCheckbox/useMenuItemCheckbox.js +31 -13
- package/lib/MenuItemCheckbox/useMenuItemCheckbox.js.map +1 -1
- package/lib/MenuList/MenuList.d.ts.map +1 -1
- package/lib/MenuList/MenuList.js +8 -2
- package/lib/MenuList/MenuList.js.map +1 -1
- package/lib/MenuList/MenuList.types.d.ts +7 -0
- package/lib/MenuList/MenuList.types.d.ts.map +1 -1
- package/lib/MenuList/MenuList.types.js.map +1 -1
- package/lib/MenuList/useMenuContextValue.d.ts +4 -0
- package/lib/MenuList/useMenuContextValue.d.ts.map +1 -0
- package/lib/MenuList/useMenuContextValue.js +5 -0
- package/lib/MenuList/useMenuContextValue.js.map +1 -0
- package/lib/MenuList/useMenuList.d.ts +3 -0
- package/lib/MenuList/useMenuList.d.ts.map +1 -0
- package/lib/MenuList/useMenuList.js +31 -0
- package/lib/MenuList/useMenuList.js.map +1 -0
- package/lib/context/menuContext.d.ts.map +1 -1
- package/lib/context/menuContext.js +4 -0
- package/lib/context/menuContext.js.map +1 -1
- package/lib/context/menuListContext.d.ts +9 -0
- package/lib/context/menuListContext.d.ts.map +1 -1
- package/lib/context/menuListContext.js +10 -1
- package/lib/context/menuListContext.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib-commonjs/MenuDivider/MenuDivider.d.ts +2 -0
- package/lib-commonjs/MenuDivider/MenuDivider.d.ts.map +1 -0
- package/lib-commonjs/MenuDivider/MenuDivider.js +18 -0
- package/lib-commonjs/MenuDivider/MenuDivider.js.map +1 -0
- package/lib-commonjs/MenuDivider/MenuDivider.styling.d.ts +4 -0
- package/lib-commonjs/MenuDivider/MenuDivider.styling.d.ts.map +1 -0
- package/lib-commonjs/MenuDivider/MenuDivider.styling.js +22 -0
- package/lib-commonjs/MenuDivider/MenuDivider.styling.js.map +1 -0
- package/lib-commonjs/MenuDivider/MenuDivider.types.d.ts +21 -0
- package/lib-commonjs/MenuDivider/MenuDivider.types.d.ts.map +1 -0
- package/lib-commonjs/MenuDivider/MenuDivider.types.js +5 -0
- package/lib-commonjs/MenuDivider/MenuDivider.types.js.map +1 -0
- package/lib-commonjs/MenuDivider/MenuDividerTokens.d.ts +5 -0
- package/lib-commonjs/MenuDivider/MenuDividerTokens.d.ts.map +1 -0
- package/lib-commonjs/MenuDivider/MenuDividerTokens.js +11 -0
- package/lib-commonjs/MenuDivider/MenuDividerTokens.js.map +1 -0
- package/lib-commonjs/MenuDivider/MenuDividerTokens.win32.d.ts +5 -0
- package/lib-commonjs/MenuDivider/MenuDividerTokens.win32.d.ts.map +1 -0
- package/lib-commonjs/MenuDivider/MenuDividerTokens.win32.js +11 -0
- package/lib-commonjs/MenuDivider/MenuDividerTokens.win32.js.map +1 -0
- package/lib-commonjs/MenuItem/useMenuItem.d.ts.map +1 -1
- package/lib-commonjs/MenuItem/useMenuItem.js +3 -2
- package/lib-commonjs/MenuItem/useMenuItem.js.map +1 -1
- package/lib-commonjs/MenuItemCheckbox/MenuItemCheckbox.styling.d.ts.map +1 -1
- package/lib-commonjs/MenuItemCheckbox/MenuItemCheckbox.styling.js +1 -0
- package/lib-commonjs/MenuItemCheckbox/MenuItemCheckbox.styling.js.map +1 -1
- package/lib-commonjs/MenuItemCheckbox/MenuItemCheckbox.types.d.ts +3 -4
- package/lib-commonjs/MenuItemCheckbox/MenuItemCheckbox.types.d.ts.map +1 -1
- package/lib-commonjs/MenuItemCheckbox/useMenuItemCheckbox.d.ts.map +1 -1
- package/lib-commonjs/MenuItemCheckbox/useMenuItemCheckbox.js +29 -11
- package/lib-commonjs/MenuItemCheckbox/useMenuItemCheckbox.js.map +1 -1
- package/lib-commonjs/MenuList/MenuList.d.ts.map +1 -1
- package/lib-commonjs/MenuList/MenuList.js +8 -2
- package/lib-commonjs/MenuList/MenuList.js.map +1 -1
- package/lib-commonjs/MenuList/MenuList.types.d.ts +7 -0
- package/lib-commonjs/MenuList/MenuList.types.d.ts.map +1 -1
- package/lib-commonjs/MenuList/MenuList.types.js.map +1 -1
- package/lib-commonjs/MenuList/useMenuContextValue.d.ts +4 -0
- package/lib-commonjs/MenuList/useMenuContextValue.d.ts.map +1 -0
- package/lib-commonjs/MenuList/useMenuContextValue.js +9 -0
- package/lib-commonjs/MenuList/useMenuContextValue.js.map +1 -0
- package/lib-commonjs/MenuList/useMenuList.d.ts +3 -0
- package/lib-commonjs/MenuList/useMenuList.d.ts.map +1 -0
- package/lib-commonjs/MenuList/useMenuList.js +35 -0
- package/lib-commonjs/MenuList/useMenuList.js.map +1 -0
- package/lib-commonjs/context/menuContext.d.ts.map +1 -1
- package/lib-commonjs/context/menuContext.js +4 -0
- package/lib-commonjs/context/menuContext.js.map +1 -1
- package/lib-commonjs/context/menuListContext.d.ts +9 -0
- package/lib-commonjs/context/menuListContext.d.ts.map +1 -1
- package/lib-commonjs/context/menuListContext.js +14 -0
- package/lib-commonjs/context/menuListContext.js.map +1 -1
- package/lib-commonjs/index.d.ts +1 -0
- package/lib-commonjs/index.d.ts.map +1 -1
- package/lib-commonjs/index.js +3 -1
- package/lib-commonjs/index.js.map +1 -1
- package/package.json +7 -7
- package/src/MenuDivider/MenuDivider.styling.ts +22 -0
- package/src/MenuDivider/MenuDivider.tsx +20 -0
- package/src/MenuDivider/MenuDivider.types.ts +25 -0
- package/src/MenuDivider/MenuDividerTokens.ts +10 -0
- package/src/MenuDivider/MenuDividerTokens.win32.ts +10 -0
- package/src/MenuItem/useMenuItem.ts +3 -2
- package/src/MenuItemCheckbox/MenuItemCheckbox.styling.ts +1 -0
- package/src/MenuItemCheckbox/MenuItemCheckbox.types.ts +4 -6
- package/src/MenuItemCheckbox/useMenuItemCheckbox.ts +64 -16
- package/src/MenuList/MenuList.tsx +11 -2
- package/src/MenuList/MenuList.types.ts +8 -0
- package/src/MenuList/useMenuContextValue.ts +6 -0
- package/src/MenuList/useMenuList.ts +49 -0
- package/src/context/menuContext.ts +4 -0
- package/src/context/menuListContext.ts +18 -0
- package/src/index.ts +1 -0
|
@@ -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,YAAY,EAAE,KAAK;IACnB,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
|
+
{"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,YAAY,EAAE,KAAK;IACnB,OAAO,EAAE,EAAE;IACX,cAAc,EAAE,EAAE;IAClB,aAAa,EAAE,KAAK;IACpB,SAAS,EAAE,KAAK;IAChB,IAAI,EAAE,KAAK;IACX,eAAe,EAAE,cAAM,OAAA,KAAK,EAAL,CAAK;IAC5B,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 +1,10 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { MenuListState } from '../MenuList/MenuList.types';
|
|
3
|
+
/**
|
|
4
|
+
* Context shared between Menu and its child components
|
|
5
|
+
*/
|
|
6
|
+
export declare type MenuListContextValue = MenuListState;
|
|
7
|
+
export declare const MenuListContext: React.Context<MenuListState>;
|
|
8
|
+
export declare const MenuListProvider: React.Provider<MenuListState>;
|
|
9
|
+
export declare const useMenuListContext: () => MenuListState;
|
|
1
10
|
//# sourceMappingURL=menuListContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menuListContext.d.ts","sourceRoot":"","sources":["../../src/context/menuListContext.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"menuListContext.d.ts","sourceRoot":"","sources":["../../src/context/menuListContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAEhE;;GAEG;AACH,oBAAY,oBAAoB,GAAG,aAAa,CAAC;AAEjD,eAAO,MAAM,eAAe,8BAM1B,CAAC;AAEH,eAAO,MAAM,gBAAgB,+BAA2B,CAAC;AACzD,eAAO,MAAM,kBAAkB,qBAA0C,CAAC"}
|
|
@@ -1,2 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useMenuListContext = exports.MenuListProvider = exports.MenuListContext = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var React = (0, tslib_1.__importStar)(require("react"));
|
|
6
|
+
exports.MenuListContext = React.createContext({
|
|
7
|
+
isCheckedControlled: false,
|
|
8
|
+
checked: {},
|
|
9
|
+
defaultChecked: {},
|
|
10
|
+
hasCheckmarks: false,
|
|
11
|
+
onCheckedChange: function () { return false; },
|
|
12
|
+
});
|
|
13
|
+
exports.MenuListProvider = exports.MenuListContext.Provider;
|
|
14
|
+
var useMenuListContext = function () { return React.useContext(exports.MenuListContext); };
|
|
15
|
+
exports.useMenuListContext = useMenuListContext;
|
|
2
16
|
//# sourceMappingURL=menuListContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menuListContext.js","sourceRoot":"","sources":["../../src/context/menuListContext.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"menuListContext.js","sourceRoot":"","sources":["../../src/context/menuListContext.ts"],"names":[],"mappings":";;;;AAAA,wDAA+B;AAQlB,QAAA,eAAe,GAAG,KAAK,CAAC,aAAa,CAAuB;IACvE,mBAAmB,EAAE,KAAK;IAC1B,OAAO,EAAE,EAAE;IACX,cAAc,EAAE,EAAE;IAClB,aAAa,EAAE,KAAK;IACpB,eAAe,EAAE,cAAM,OAAA,KAAK,EAAL,CAAK;CAC7B,CAAC,CAAC;AAEU,QAAA,gBAAgB,GAAG,uBAAe,CAAC,QAAQ,CAAC;AAClD,IAAM,kBAAkB,GAAG,cAAM,OAAA,KAAK,CAAC,UAAU,CAAC,uBAAe,CAAC,EAAjC,CAAiC,CAAC;AAA7D,QAAA,kBAAkB,sBAA2C"}
|
package/lib-commonjs/index.d.ts
CHANGED
|
@@ -4,4 +4,5 @@ export { MenuPopover } from './MenuPopover/MenuPopover';
|
|
|
4
4
|
export { MenuItem } from './MenuItem/MenuItem';
|
|
5
5
|
export { MenuItemCheckbox } from './MenuItemCheckbox/MenuItemCheckbox';
|
|
6
6
|
export { MenuList } from './MenuList/MenuList';
|
|
7
|
+
export { MenuDivider } from './MenuDivider/MenuDivider';
|
|
7
8
|
//# 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;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,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;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC"}
|
package/lib-commonjs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MenuList = exports.MenuItemCheckbox = exports.MenuItem = exports.MenuPopover = exports.MenuTrigger = exports.Menu = void 0;
|
|
3
|
+
exports.MenuDivider = exports.MenuList = exports.MenuItemCheckbox = 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");
|
|
@@ -13,4 +13,6 @@ var MenuItemCheckbox_1 = require("./MenuItemCheckbox/MenuItemCheckbox");
|
|
|
13
13
|
Object.defineProperty(exports, "MenuItemCheckbox", { enumerable: true, get: function () { return MenuItemCheckbox_1.MenuItemCheckbox; } });
|
|
14
14
|
var MenuList_1 = require("./MenuList/MenuList");
|
|
15
15
|
Object.defineProperty(exports, "MenuList", { enumerable: true, get: function () { return MenuList_1.MenuList; } });
|
|
16
|
+
var MenuDivider_1 = require("./MenuDivider/MenuDivider");
|
|
17
|
+
Object.defineProperty(exports, "MenuDivider", { enumerable: true, get: function () { return MenuDivider_1.MenuDivider; } });
|
|
16
18
|
//# 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;AACpB,gDAA+C;AAAtC,oGAAA,QAAQ,OAAA;AACjB,wEAAuE;AAA9D,oHAAA,gBAAgB,OAAA;AACzB,gDAA+C;AAAtC,oGAAA,QAAQ,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;AACjB,wEAAuE;AAA9D,oHAAA,gBAAgB,OAAA;AACzB,gDAA+C;AAAtC,oGAAA,QAAQ,OAAA;AACjB,yDAAwD;AAA/C,0GAAA,WAAW,OAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluentui-react-native/menu",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
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,12 +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.20.
|
|
27
|
-
"@fluentui-react-native/experimental-text": ">=0.7.
|
|
28
|
-
"@fluentui-react-native/framework": "0.7.
|
|
29
|
-
"@fluentui-react-native/interactive-hooks": ">=0.15.
|
|
30
|
-
"@fluentui-react-native/theme-tokens": ">=0.16.
|
|
31
|
-
"@fluentui-react-native/tokens": ">=0.12.
|
|
26
|
+
"@fluentui-react-native/callout": ">=0.20.1 <1.0.0",
|
|
27
|
+
"@fluentui-react-native/experimental-text": ">=0.7.27 <1.0.0",
|
|
28
|
+
"@fluentui-react-native/framework": "0.7.27",
|
|
29
|
+
"@fluentui-react-native/interactive-hooks": ">=0.15.7 <1.0.0",
|
|
30
|
+
"@fluentui-react-native/theme-tokens": ">=0.16.3 <1.0.0",
|
|
31
|
+
"@fluentui-react-native/tokens": ">=0.12.1 <1.0.0",
|
|
32
32
|
"@fluentui-react-native/use-styling": ">=0.8.3 <1.0.0",
|
|
33
33
|
"react-native-svg": "^12.3.0",
|
|
34
34
|
"tslib": "^2.3.1"
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { UseStylingOptions, buildProps } from '@fluentui-react-native/framework';
|
|
2
|
+
import { defaultMenuDividerTokens } from './MenuDividerTokens.win32';
|
|
3
|
+
import { menuDividerName, MenuDividerProps, MenuDividerTokens, MenuDividerSlotProps } from './MenuDivider.types';
|
|
4
|
+
|
|
5
|
+
export const stylingSettings: UseStylingOptions<MenuDividerProps, MenuDividerSlotProps, MenuDividerTokens> = {
|
|
6
|
+
tokens: [defaultMenuDividerTokens, menuDividerName],
|
|
7
|
+
slotProps: {
|
|
8
|
+
root: buildProps(
|
|
9
|
+
(tokens: MenuDividerTokens) => ({
|
|
10
|
+
style: {
|
|
11
|
+
height: tokens.height,
|
|
12
|
+
width: tokens.width,
|
|
13
|
+
backgroundColor: tokens.backgroundColor,
|
|
14
|
+
margin: tokens.margin,
|
|
15
|
+
marginVertical: tokens.marginVertical,
|
|
16
|
+
display: 'flex',
|
|
17
|
+
},
|
|
18
|
+
}),
|
|
19
|
+
['backgroundColor', 'height', 'margin', 'marginVertical', 'width'],
|
|
20
|
+
),
|
|
21
|
+
},
|
|
22
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** @jsx withSlots */
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { compose, UseSlots, withSlots } from '@fluentui-react-native/framework';
|
|
4
|
+
import { menuDividerName, MenuDividerProps, MenuDividerType } from './MenuDivider.types';
|
|
5
|
+
import { stylingSettings } from './MenuDivider.styling';
|
|
6
|
+
|
|
7
|
+
export const MenuDivider = compose<MenuDividerType>({
|
|
8
|
+
displayName: menuDividerName,
|
|
9
|
+
...stylingSettings,
|
|
10
|
+
slots: {
|
|
11
|
+
root: View,
|
|
12
|
+
},
|
|
13
|
+
useRender: (userProps: MenuDividerProps, useSlots: UseSlots<MenuDividerType>) => {
|
|
14
|
+
const Slots = useSlots(userProps);
|
|
15
|
+
|
|
16
|
+
return (final: MenuDividerProps) => {
|
|
17
|
+
return <Slots.root {...final} />;
|
|
18
|
+
};
|
|
19
|
+
},
|
|
20
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ViewStyle } from 'react-native';
|
|
3
|
+
import type { IViewProps } from '@fluentui-react-native/adapters';
|
|
4
|
+
import { IBackgroundColorTokens } from '@fluentui-react-native/tokens';
|
|
5
|
+
|
|
6
|
+
export const menuDividerName = 'MenuDivider';
|
|
7
|
+
|
|
8
|
+
export type MenuDividerTokens = IBackgroundColorTokens & {
|
|
9
|
+
height?: number;
|
|
10
|
+
margin?: number;
|
|
11
|
+
marginVertical?: number;
|
|
12
|
+
width?: ViewStyle['width'];
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type MenuDividerProps = IViewProps;
|
|
16
|
+
|
|
17
|
+
export interface MenuDividerSlotProps {
|
|
18
|
+
root: React.PropsWithRef<IViewProps>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface MenuDividerType {
|
|
22
|
+
props: MenuDividerProps;
|
|
23
|
+
tokens: MenuDividerTokens;
|
|
24
|
+
slotProps: MenuDividerSlotProps;
|
|
25
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Theme } from '@fluentui-react-native/framework';
|
|
2
|
+
import { globalTokens } from '@fluentui-react-native/theme-tokens';
|
|
3
|
+
import { TokenSettings } from '@fluentui-react-native/use-styling';
|
|
4
|
+
import { MenuDividerTokens } from './MenuDivider.types';
|
|
5
|
+
|
|
6
|
+
export const defaultMenuDividerTokens: TokenSettings<MenuDividerTokens, Theme> = (t: Theme): MenuDividerTokens => ({
|
|
7
|
+
backgroundColor: t.colors.neutralStroke2,
|
|
8
|
+
height: globalTokens.stroke.width.thin,
|
|
9
|
+
marginVertical: globalTokens.spacing.xs,
|
|
10
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Theme } from '@fluentui-react-native/framework';
|
|
2
|
+
import { globalTokens } from '@fluentui-react-native/theme-tokens';
|
|
3
|
+
import { TokenSettings } from '@fluentui-react-native/use-styling';
|
|
4
|
+
import { MenuDividerTokens } from './MenuDivider.types';
|
|
5
|
+
|
|
6
|
+
export const defaultMenuDividerTokens: TokenSettings<MenuDividerTokens, Theme> = (t: Theme): MenuDividerTokens => ({
|
|
7
|
+
backgroundColor: t.colors.neutralStroke1,
|
|
8
|
+
height: globalTokens.stroke.width.thin,
|
|
9
|
+
margin: globalTokens.spacing.xxs,
|
|
10
|
+
});
|
|
@@ -4,6 +4,7 @@ import { MenuItemProps, MenuItemState } from './MenuItem.types';
|
|
|
4
4
|
import { memoize } from '@fluentui-react-native/framework';
|
|
5
5
|
import { useAsPressable, useKeyProps } from '@fluentui-react-native/interactive-hooks';
|
|
6
6
|
import { useMenuContext } from '../context/menuContext';
|
|
7
|
+
import { useMenuListContext } from '../context/menuListContext';
|
|
7
8
|
|
|
8
9
|
export const useMenuItem = (props: MenuItemProps): MenuItemState => {
|
|
9
10
|
// attach the pressable state handlers
|
|
@@ -12,13 +13,13 @@ export const useMenuItem = (props: MenuItemProps): MenuItemState => {
|
|
|
12
13
|
const pressable = useAsPressable({ ...rest, disabled, onPress: onClick });
|
|
13
14
|
const onKeyProps = useKeyProps(onClick, ' ', 'Enter');
|
|
14
15
|
const hasSubmenu = useMenuContext().isSubmenu;
|
|
15
|
-
const hasCheckmarks =
|
|
16
|
+
const hasCheckmarks = useMenuListContext().hasCheckmarks;
|
|
16
17
|
|
|
17
18
|
return {
|
|
18
19
|
props: {
|
|
19
20
|
...pressable.props,
|
|
20
21
|
accessible: true,
|
|
21
|
-
accessibilityRole: '
|
|
22
|
+
accessibilityRole: 'menuitem',
|
|
22
23
|
onAccessibilityTap: props.onAccessibilityTap || props.onClick,
|
|
23
24
|
accessibilityLabel: props.accessibilityLabel,
|
|
24
25
|
accessibilityState: getAccessibilityState(disabled, accessibilityState),
|
|
@@ -23,6 +23,7 @@ export const stylingSettings: UseStylingOptions<MenuItemCheckboxProps, MenuItemC
|
|
|
23
23
|
),
|
|
24
24
|
checkmark: buildProps(
|
|
25
25
|
(tokens: MenuItemCheckboxTokens) => ({
|
|
26
|
+
opacity: tokens.checkmarkVisibility,
|
|
26
27
|
color: tokens.color,
|
|
27
28
|
height: tokens.checkmarkSize,
|
|
28
29
|
width: tokens.checkmarkSize,
|
|
@@ -3,7 +3,7 @@ import { ColorValue, ViewProps } from 'react-native';
|
|
|
3
3
|
import { XmlProps } from 'react-native-svg';
|
|
4
4
|
import type { IViewProps } from '@fluentui-react-native/adapters';
|
|
5
5
|
import { TextProps } from '@fluentui-react-native/experimental-text';
|
|
6
|
-
import { IFocusable,
|
|
6
|
+
import { IFocusable, IPressableHooks, IWithPressableOptions } from '@fluentui-react-native/interactive-hooks';
|
|
7
7
|
import { FontTokens, IBorderTokens, IColorTokens, LayoutTokens } from '@fluentui-react-native/tokens';
|
|
8
8
|
|
|
9
9
|
export const menuItemCheckboxName = 'MenuItemCheckbox';
|
|
@@ -36,14 +36,12 @@ export interface MenuItemCheckboxProps extends Omit<IWithPressableOptions<ViewPr
|
|
|
36
36
|
componentRef?: React.RefObject<IFocusable>;
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
39
|
+
* Identifier for the control
|
|
40
40
|
*/
|
|
41
|
-
|
|
41
|
+
name: string;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
export interface MenuItemCheckboxState extends IPressableHooks<MenuItemCheckboxProps & React.ComponentPropsWithRef<any>> {
|
|
45
|
-
hasCheckmarks?: boolean;
|
|
46
|
-
}
|
|
44
|
+
export interface MenuItemCheckboxState extends IPressableHooks<MenuItemCheckboxProps & React.ComponentPropsWithRef<any>> {}
|
|
47
45
|
|
|
48
46
|
export interface MenuItemCheckboxSlotProps {
|
|
49
47
|
root: React.PropsWithRef<IViewProps>;
|
|
@@ -1,40 +1,88 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { AccessibilityState } from 'react-native';
|
|
2
|
+
import { AccessibilityActionEvent, AccessibilityState } from 'react-native';
|
|
3
3
|
import { MenuItemCheckboxProps, MenuItemCheckboxState } from './MenuItemCheckbox.types';
|
|
4
4
|
import { memoize } from '@fluentui-react-native/framework';
|
|
5
|
-
import {
|
|
6
|
-
|
|
5
|
+
import {
|
|
6
|
+
InteractionEvent,
|
|
7
|
+
useAsPressable,
|
|
8
|
+
useKeyProps,
|
|
9
|
+
useOnPressWithFocus,
|
|
10
|
+
useViewCommandFocus,
|
|
11
|
+
} from '@fluentui-react-native/interactive-hooks';
|
|
12
|
+
import { useMenuListContext } from '../context/menuListContext';
|
|
13
|
+
|
|
14
|
+
const defaultAccessibilityActions = [{ name: 'Toggle' }];
|
|
7
15
|
|
|
8
16
|
export const useMenuItemCheckbox = (props: MenuItemCheckboxProps): MenuItemCheckboxState => {
|
|
9
17
|
// attach the pressable state handlers
|
|
10
18
|
const defaultComponentRef = React.useRef(null);
|
|
11
|
-
const {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
19
|
+
const {
|
|
20
|
+
accessibilityActions,
|
|
21
|
+
accessibilityState,
|
|
22
|
+
componentRef = defaultComponentRef,
|
|
23
|
+
disabled,
|
|
24
|
+
name,
|
|
25
|
+
onAccessibilityAction,
|
|
26
|
+
...rest
|
|
27
|
+
} = props;
|
|
28
|
+
const context = useMenuListContext();
|
|
29
|
+
const checked = context.checked?.[name];
|
|
30
|
+
const onCheckedChange = context.onCheckedChange;
|
|
31
|
+
|
|
32
|
+
const toggleChecked = React.useCallback(
|
|
33
|
+
(e: InteractionEvent) => {
|
|
34
|
+
onCheckedChange(e, name, !checked);
|
|
35
|
+
},
|
|
36
|
+
[checked, name, onCheckedChange],
|
|
37
|
+
);
|
|
38
|
+
// Ensure focus is placed on checkbox after click
|
|
39
|
+
const toggleCheckedWithFocus = useOnPressWithFocus(componentRef, toggleChecked);
|
|
40
|
+
|
|
41
|
+
const pressable = useAsPressable({ onPress: toggleCheckedWithFocus, ...rest });
|
|
42
|
+
const buttonRef = useViewCommandFocus(componentRef);
|
|
43
|
+
|
|
44
|
+
const onKeyProps = useKeyProps(toggleChecked, ' ');
|
|
45
|
+
const accessibilityActionsProp = accessibilityActions
|
|
46
|
+
? [...defaultAccessibilityActions, ...accessibilityActions]
|
|
47
|
+
: defaultAccessibilityActions;
|
|
48
|
+
const onAccessibilityActionProp = React.useCallback(
|
|
49
|
+
(event: AccessibilityActionEvent) => {
|
|
50
|
+
if (event.nativeEvent.actionName === 'Toggle') {
|
|
51
|
+
toggleChecked(event);
|
|
52
|
+
}
|
|
53
|
+
onAccessibilityAction && onAccessibilityAction(event);
|
|
54
|
+
},
|
|
55
|
+
[toggleChecked, onAccessibilityAction],
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const state = {
|
|
59
|
+
...pressable.state,
|
|
60
|
+
disabled: !!props.disabled,
|
|
61
|
+
checked: checked,
|
|
62
|
+
};
|
|
15
63
|
|
|
16
64
|
return {
|
|
17
65
|
props: {
|
|
18
66
|
...pressable.props,
|
|
19
67
|
accessible: true,
|
|
20
|
-
|
|
21
|
-
onAccessibilityTap: props.onAccessibilityTap || props.onClick,
|
|
68
|
+
accessibilityActions: accessibilityActionsProp,
|
|
22
69
|
accessibilityLabel: props.accessibilityLabel,
|
|
23
|
-
|
|
70
|
+
accessibilityRole: 'menuitem',
|
|
71
|
+
accessibilityState: getAccessibilityState(disabled, state.checked, accessibilityState),
|
|
24
72
|
enableFocusRing: true,
|
|
25
73
|
focusable: !disabled,
|
|
26
|
-
|
|
74
|
+
onAccessibilityAction: onAccessibilityActionProp,
|
|
75
|
+
ref: buttonRef,
|
|
27
76
|
...onKeyProps,
|
|
28
77
|
},
|
|
29
|
-
state:
|
|
30
|
-
hasCheckmarks,
|
|
78
|
+
state: state,
|
|
31
79
|
};
|
|
32
80
|
};
|
|
33
81
|
|
|
34
82
|
const getAccessibilityState = memoize(getAccessibilityStateWorker);
|
|
35
|
-
function getAccessibilityStateWorker(disabled: boolean, accessibilityState?: AccessibilityState) {
|
|
83
|
+
function getAccessibilityStateWorker(disabled: boolean, checked: boolean, accessibilityState?: AccessibilityState) {
|
|
36
84
|
if (accessibilityState) {
|
|
37
|
-
return { disabled, ...accessibilityState };
|
|
85
|
+
return { disabled, checked, ...accessibilityState };
|
|
38
86
|
}
|
|
39
|
-
return { disabled };
|
|
87
|
+
return { disabled, checked };
|
|
40
88
|
}
|
|
@@ -4,6 +4,9 @@ import { View } from 'react-native';
|
|
|
4
4
|
import { compose, UseSlots, withSlots } from '@fluentui-react-native/framework';
|
|
5
5
|
import { menuListName, MenuListProps, MenuListType } from './MenuList.types';
|
|
6
6
|
import { stylingSettings } from './MenuList.styling';
|
|
7
|
+
import { MenuListProvider } from '../context/menuListContext';
|
|
8
|
+
import { useMenuList } from './useMenuList';
|
|
9
|
+
import { useMenuListContextValue } from './useMenuContextValue';
|
|
7
10
|
|
|
8
11
|
export const MenuList = compose<MenuListType>({
|
|
9
12
|
displayName: menuListName,
|
|
@@ -12,10 +15,16 @@ export const MenuList = compose<MenuListType>({
|
|
|
12
15
|
root: View,
|
|
13
16
|
},
|
|
14
17
|
useRender: (userProps: MenuListProps, useSlots: UseSlots<MenuListType>) => {
|
|
15
|
-
const
|
|
18
|
+
const menuList = useMenuList(userProps);
|
|
19
|
+
const contextValue = useMenuListContextValue(menuList);
|
|
20
|
+
const Slots = useSlots(menuList);
|
|
16
21
|
|
|
17
22
|
return (_final: MenuListProps, children: React.ReactNode) => {
|
|
18
|
-
return
|
|
23
|
+
return (
|
|
24
|
+
<MenuListProvider value={contextValue}>
|
|
25
|
+
<Slots.root>{children}</Slots.root>
|
|
26
|
+
</MenuListProvider>
|
|
27
|
+
);
|
|
19
28
|
};
|
|
20
29
|
},
|
|
21
30
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { IViewProps } from '@fluentui-react-native/adapters';
|
|
2
|
+
import { InteractionEvent } from '@fluentui-react-native/interactive-hooks';
|
|
2
3
|
import { IBackgroundColorTokens, LayoutTokens } from '@fluentui-react-native/tokens';
|
|
3
4
|
|
|
4
5
|
export const menuListName = 'MenuList';
|
|
@@ -6,7 +7,14 @@ export const menuListName = 'MenuList';
|
|
|
6
7
|
export interface MenuListTokens extends LayoutTokens, IBackgroundColorTokens {}
|
|
7
8
|
|
|
8
9
|
export interface MenuListProps extends Omit<IViewProps, 'onPress'> {
|
|
10
|
+
checked?: Record<string, boolean>;
|
|
11
|
+
defaultChecked?: Record<string, boolean>;
|
|
9
12
|
hasCheckmarks?: boolean;
|
|
13
|
+
onCheckedChange?: (e: InteractionEvent, name: string, isChecked: boolean) => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface MenuListState extends MenuListProps {
|
|
17
|
+
isCheckedControlled: boolean;
|
|
10
18
|
}
|
|
11
19
|
|
|
12
20
|
export interface MenuListSlotProps {
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { InteractionEvent } from '@fluentui-react-native/interactive-hooks';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { useMenuContext } from '../context/menuContext';
|
|
4
|
+
import { MenuListProps, MenuListState } from './MenuList.types';
|
|
5
|
+
|
|
6
|
+
export const useMenuList = (_props: MenuListProps): MenuListState => {
|
|
7
|
+
const context = useMenuContext();
|
|
8
|
+
|
|
9
|
+
// MenuList v2 needs to be able to be standalone, but this is not in scope for v1
|
|
10
|
+
// Assuming that checked information will come from parent Menu
|
|
11
|
+
const isCheckedControlled = typeof context.checked !== 'undefined';
|
|
12
|
+
const [checked, onCheckedChange] = useMenuCheckedState(isCheckedControlled, context);
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
...context,
|
|
16
|
+
isCheckedControlled,
|
|
17
|
+
checked,
|
|
18
|
+
onCheckedChange,
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const useMenuCheckedState = (
|
|
23
|
+
isControlled: boolean,
|
|
24
|
+
props: MenuListProps,
|
|
25
|
+
): [Record<string, boolean>, (e: InteractionEvent, name: string, isChecked: boolean) => void] => {
|
|
26
|
+
const { defaultChecked, onCheckedChange, checked } = props;
|
|
27
|
+
const initialState = defaultChecked ?? checked ?? {};
|
|
28
|
+
const [checkedInternal, setCheckedInternal] = React.useState<Record<string, boolean>>(initialState);
|
|
29
|
+
|
|
30
|
+
const state = isControlled ? checked : checkedInternal;
|
|
31
|
+
|
|
32
|
+
const setChecked = React.useCallback(
|
|
33
|
+
(e: InteractionEvent, name: string, isChecked: boolean) => {
|
|
34
|
+
if (!isControlled) {
|
|
35
|
+
const curChecked = state;
|
|
36
|
+
curChecked[name] = isChecked;
|
|
37
|
+
const updatedChecked = { ...curChecked };
|
|
38
|
+
setCheckedInternal(updatedChecked);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (onCheckedChange) {
|
|
42
|
+
onCheckedChange(e, name, isChecked);
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
[isControlled, state, onCheckedChange, setCheckedInternal],
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
return [state, setChecked];
|
|
49
|
+
};
|
|
@@ -8,8 +8,12 @@ export type MenuContextValue = MenuState;
|
|
|
8
8
|
|
|
9
9
|
export const MenuContext = React.createContext<MenuContextValue>({
|
|
10
10
|
isControlled: false,
|
|
11
|
+
checked: {},
|
|
12
|
+
defaultChecked: {},
|
|
13
|
+
hasCheckmarks: false,
|
|
11
14
|
isSubmenu: false,
|
|
12
15
|
open: false,
|
|
16
|
+
onCheckedChange: () => false,
|
|
13
17
|
setOpen: () => false,
|
|
14
18
|
triggerRef: null,
|
|
15
19
|
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { MenuListState } from '../MenuList/MenuList.types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Context shared between Menu and its child components
|
|
6
|
+
*/
|
|
7
|
+
export type MenuListContextValue = MenuListState;
|
|
8
|
+
|
|
9
|
+
export const MenuListContext = React.createContext<MenuListContextValue>({
|
|
10
|
+
isCheckedControlled: false,
|
|
11
|
+
checked: {},
|
|
12
|
+
defaultChecked: {},
|
|
13
|
+
hasCheckmarks: false,
|
|
14
|
+
onCheckedChange: () => false,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export const MenuListProvider = MenuListContext.Provider;
|
|
18
|
+
export const useMenuListContext = () => React.useContext(MenuListContext);
|
package/src/index.ts
CHANGED
|
@@ -4,3 +4,4 @@ export { MenuPopover } from './MenuPopover/MenuPopover';
|
|
|
4
4
|
export { MenuItem } from './MenuItem/MenuItem';
|
|
5
5
|
export { MenuItemCheckbox } from './MenuItemCheckbox/MenuItemCheckbox';
|
|
6
6
|
export { MenuList } from './MenuList/MenuList';
|
|
7
|
+
export { MenuDivider } from './MenuDivider/MenuDivider';
|