@zag-js/menubar 2.0.0-next.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/LICENSE +21 -0
- package/dist/index.d.mts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +39 -0
- package/dist/index.mjs +10 -0
- package/dist/menubar.anatomy.d.mts +6 -0
- package/dist/menubar.anatomy.d.ts +6 -0
- package/dist/menubar.anatomy.js +34 -0
- package/dist/menubar.anatomy.mjs +8 -0
- package/dist/menubar.connect.d.mts +8 -0
- package/dist/menubar.connect.d.ts +8 -0
- package/dist/menubar.connect.js +107 -0
- package/dist/menubar.connect.mjs +72 -0
- package/dist/menubar.dom.d.mts +18 -0
- package/dist/menubar.dom.d.ts +18 -0
- package/dist/menubar.dom.js +78 -0
- package/dist/menubar.dom.mjs +44 -0
- package/dist/menubar.machine.d.mts +8 -0
- package/dist/menubar.machine.d.ts +8 -0
- package/dist/menubar.machine.js +253 -0
- package/dist/menubar.machine.mjs +218 -0
- package/dist/menubar.props.d.mts +9 -0
- package/dist/menubar.props.d.ts +9 -0
- package/dist/menubar.props.js +43 -0
- package/dist/menubar.props.mjs +17 -0
- package/dist/menubar.types.d.mts +106 -0
- package/dist/menubar.types.d.ts +106 -0
- package/dist/menubar.types.js +18 -0
- package/dist/menubar.types.mjs +0 -0
- package/package.json +73 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { Machine, EventObject, Service } from '@zag-js/core';
|
|
2
|
+
import { TypeaheadState } from '@zag-js/dom-query';
|
|
3
|
+
import { PropTypes, Orientation, RequiredBy, DirectionProperty, CommonProperties } from '@zag-js/types';
|
|
4
|
+
export { Orientation } from '@zag-js/types';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The reason a menu within the menubar closed. Used to decide whether the menubar
|
|
8
|
+
* should keep `hasOpenMenu` active (another menu is about to open) or reset it.
|
|
9
|
+
*/
|
|
10
|
+
type MenuCloseReason = "escape" | "click-outside" | "sibling-open" | "item-select" | "list-navigation";
|
|
11
|
+
/**
|
|
12
|
+
* The custom DOM events menus dispatch on the menubar element to coordinate.
|
|
13
|
+
* Coordination is intentionally DOM-based — no imports between the menu and menubar packages.
|
|
14
|
+
*/
|
|
15
|
+
interface MenubarEventMap {
|
|
16
|
+
"menu:open": CustomEvent<{
|
|
17
|
+
menuId: string;
|
|
18
|
+
}>;
|
|
19
|
+
"menu:close": CustomEvent<{
|
|
20
|
+
menuId: string;
|
|
21
|
+
reason: MenuCloseReason;
|
|
22
|
+
}>;
|
|
23
|
+
"menu:focus-next": CustomEvent<void>;
|
|
24
|
+
"menu:focus-prev": CustomEvent<void>;
|
|
25
|
+
}
|
|
26
|
+
type ElementIds = Partial<{
|
|
27
|
+
root: string;
|
|
28
|
+
}>;
|
|
29
|
+
interface MenubarProps extends DirectionProperty, CommonProperties {
|
|
30
|
+
/**
|
|
31
|
+
* The ids of the elements in the menubar. Useful for composition.
|
|
32
|
+
*/
|
|
33
|
+
ids?: ElementIds | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* The orientation of the menubar.
|
|
36
|
+
* @default "horizontal"
|
|
37
|
+
*/
|
|
38
|
+
orientation?: Orientation | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Whether to loop the keyboard navigation across the triggers.
|
|
41
|
+
* @default true
|
|
42
|
+
*/
|
|
43
|
+
loopFocus?: boolean | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Whether the menubar (and all its menu triggers) is disabled.
|
|
46
|
+
* @default false
|
|
47
|
+
*/
|
|
48
|
+
disabled?: boolean | undefined;
|
|
49
|
+
}
|
|
50
|
+
type PropsWithDefault = "orientation" | "loopFocus";
|
|
51
|
+
interface MenubarContext {
|
|
52
|
+
/**
|
|
53
|
+
* The id of the currently focused/tabbable trigger (roving tabindex).
|
|
54
|
+
*/
|
|
55
|
+
activeId: string | null;
|
|
56
|
+
/**
|
|
57
|
+
* Whether any menu within the menubar is currently open.
|
|
58
|
+
*/
|
|
59
|
+
hasOpenMenu: boolean;
|
|
60
|
+
}
|
|
61
|
+
interface MenubarSchema {
|
|
62
|
+
props: RequiredBy<MenubarProps, PropsWithDefault>;
|
|
63
|
+
context: MenubarContext;
|
|
64
|
+
refs: {
|
|
65
|
+
typeaheadState: TypeaheadState;
|
|
66
|
+
};
|
|
67
|
+
state: "idle" | "focused" | "open";
|
|
68
|
+
event: EventObject;
|
|
69
|
+
action: string;
|
|
70
|
+
effect: string;
|
|
71
|
+
guard: string;
|
|
72
|
+
}
|
|
73
|
+
type MenubarService = Service<MenubarSchema>;
|
|
74
|
+
type MenubarMachine = Machine<MenubarSchema>;
|
|
75
|
+
/**
|
|
76
|
+
* Config to pass to a child menu's `menubar` prop so it behaves as a menubar menu.
|
|
77
|
+
* Structurally matches the `MenubarContext` type from `@zag-js/menu`.
|
|
78
|
+
*/
|
|
79
|
+
interface MenubarMenuContext {
|
|
80
|
+
rootId: string;
|
|
81
|
+
disabled: boolean;
|
|
82
|
+
orientation: Orientation;
|
|
83
|
+
activeId: string | null;
|
|
84
|
+
}
|
|
85
|
+
interface MenubarApi<T extends PropTypes = PropTypes> {
|
|
86
|
+
/**
|
|
87
|
+
* Whether any menu within the menubar is open.
|
|
88
|
+
*/
|
|
89
|
+
hasOpenMenu: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* The orientation of the menubar.
|
|
92
|
+
*/
|
|
93
|
+
orientation: Orientation;
|
|
94
|
+
/**
|
|
95
|
+
* Whether the menubar is disabled.
|
|
96
|
+
*/
|
|
97
|
+
disabled: boolean;
|
|
98
|
+
getRootProps: () => T["element"];
|
|
99
|
+
/**
|
|
100
|
+
* Returns the config to pass to each top-level menu's `menubar` prop. Adapters
|
|
101
|
+
* usually expose this via a context so nested `<Menu>`s can read it.
|
|
102
|
+
*/
|
|
103
|
+
getMenuContext: () => MenubarMenuContext;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export type { ElementIds, MenuCloseReason, MenubarApi, MenubarEventMap, MenubarMachine, MenubarMenuContext, MenubarProps, MenubarSchema, MenubarService };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/menubar.types.ts
|
|
17
|
+
var menubar_types_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(menubar_types_exports);
|
|
File without changes
|
package/package.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zag-js/menubar",
|
|
3
|
+
"version": "2.0.0-next.1",
|
|
4
|
+
"description": "Core logic for the menubar widget implemented as a state machine",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"js",
|
|
7
|
+
"machine",
|
|
8
|
+
"xstate",
|
|
9
|
+
"statechart",
|
|
10
|
+
"component",
|
|
11
|
+
"chakra-ui",
|
|
12
|
+
"menubar"
|
|
13
|
+
],
|
|
14
|
+
"author": "Segun Adebayo <sage@adebayosegun.com>",
|
|
15
|
+
"homepage": "https://github.com/chakra-ui/zag#readme",
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/chakra-ui/zag/tree/main/packages/menubar"
|
|
20
|
+
},
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/chakra-ui/zag/issues"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@zag-js/anatomy": "2.0.0-next.1",
|
|
33
|
+
"@zag-js/dom-query": "2.0.0-next.1",
|
|
34
|
+
"@zag-js/utils": "2.0.0-next.1",
|
|
35
|
+
"@zag-js/core": "2.0.0-next.1",
|
|
36
|
+
"@zag-js/types": "2.0.0-next.1"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"clean-package": "2.2.0"
|
|
40
|
+
},
|
|
41
|
+
"clean-package": "./clean-package.config.json",
|
|
42
|
+
"main": "dist/index.js",
|
|
43
|
+
"module": "dist/index.mjs",
|
|
44
|
+
"types": "dist/index.d.ts",
|
|
45
|
+
"exports": {
|
|
46
|
+
".": {
|
|
47
|
+
"import": {
|
|
48
|
+
"types": "./dist/index.d.mts",
|
|
49
|
+
"default": "./dist/index.mjs"
|
|
50
|
+
},
|
|
51
|
+
"require": {
|
|
52
|
+
"types": "./dist/index.d.ts",
|
|
53
|
+
"default": "./dist/index.js"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"./anatomy": {
|
|
57
|
+
"import": {
|
|
58
|
+
"types": "./dist/menubar.anatomy.d.mts",
|
|
59
|
+
"default": "./dist/menubar.anatomy.mjs"
|
|
60
|
+
},
|
|
61
|
+
"require": {
|
|
62
|
+
"types": "./dist/menubar.anatomy.d.ts",
|
|
63
|
+
"default": "./dist/menubar.anatomy.js"
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"./package.json": "./package.json"
|
|
67
|
+
},
|
|
68
|
+
"scripts": {
|
|
69
|
+
"build": "tsup",
|
|
70
|
+
"lint": "eslint src",
|
|
71
|
+
"typecheck": "tsc --noEmit"
|
|
72
|
+
}
|
|
73
|
+
}
|