@dxos/react-ui-menu 0.16.0 → 0.17.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.
- package/dist/lib/index.mjs +592 -209
- package/dist/lib/index.mjs.map +1 -1
- package/dist/types/src/builder.d.ts +20 -1
- package/dist/types/src/builder.d.ts.map +1 -1
- package/dist/types/src/components/ActionMenu.d.ts.map +1 -1
- package/dist/types/src/components/ActionMenu.stories.d.ts +2 -0
- package/dist/types/src/components/ActionMenu.stories.d.ts.map +1 -1
- package/dist/types/src/components/ActionToolbar.d.ts +32 -8
- package/dist/types/src/components/ActionToolbar.d.ts.map +1 -1
- package/dist/types/src/components/ActionToolbar.stories.d.ts +32 -3
- package/dist/types/src/components/ActionToolbar.stories.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/util.d.ts +3 -2
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +26 -22
- package/src/builder.test.ts +28 -0
- package/src/builder.ts +71 -6
- package/src/components/ActionMenu.stories.tsx +38 -1
- package/src/components/ActionMenu.tsx +67 -7
- package/src/components/ActionToolbar.stories.tsx +533 -22
- package/src/components/ActionToolbar.tsx +440 -35
- package/src/hooks/useMenuActions.browser.test.tsx +6 -0
- package/src/index.ts +1 -1
|
@@ -1,20 +1,44 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as Atom from 'effect/reactivity/Atom';
|
|
2
|
+
import React from 'react';
|
|
2
3
|
import * as Toolbar from '@dxos/react-ui/Toolbar';
|
|
3
4
|
import { type ClassNameValue } from '@dxos/ui-types';
|
|
4
|
-
import { type
|
|
5
|
-
|
|
5
|
+
import { type ActionGraphProps } from '../hooks/index.ts';
|
|
6
|
+
import { type MenuActions, type MenuItem } from '../types.ts';
|
|
7
|
+
type ItemProps<T> = {
|
|
8
|
+
menu: MenuActions;
|
|
9
|
+
} & T;
|
|
10
|
+
/**
|
|
11
|
+
* One menu item rendered as its toolbar control (button, toggle, switch, dropdown, toggle group or custom); `collapsed`
|
|
12
|
+
* renders its compact form.
|
|
13
|
+
*/
|
|
14
|
+
export declare const MenuToolbarItem: ({ menu, item, collapsed, }: ItemProps<{
|
|
15
|
+
item: MenuItem;
|
|
16
|
+
collapsed?: boolean;
|
|
17
|
+
}>) => React.JSX.Element | null;
|
|
18
|
+
export type ActionToolbarProps = Partial<MenuActions> & Omit<Toolbar.RootProps, 'disabled' | 'children'> & {
|
|
6
19
|
/** The toolbar is dimmed (still operable) while this attendable lacks attention, unless `alwaysActive`. */
|
|
7
20
|
attendableId?: string;
|
|
8
21
|
alwaysActive?: boolean;
|
|
9
|
-
/**
|
|
10
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Items another component adds to this toolbar, merged with its own group by group: root items follow the owner's,
|
|
24
|
+
* and `MenuBuilder.extend(groupId, …)` adds to a named group.
|
|
25
|
+
*/
|
|
26
|
+
customActions?: Atom.Atom<ActionGraphProps>;
|
|
27
|
+
/**
|
|
28
|
+
* The box whose width the toolbar may fill, measured to decide when collapsed items fit again; by default the
|
|
29
|
+
* toolbar's own frame. A toolbar as wide as its content passes the box it sits in, or it never grows back.
|
|
30
|
+
*/
|
|
31
|
+
bounds?: HTMLElement | null;
|
|
11
32
|
};
|
|
12
33
|
/**
|
|
13
|
-
* A
|
|
14
|
-
*
|
|
15
|
-
* `
|
|
34
|
+
* A toolbar driven from a `MenuActions`. Each item's `placement` puts it in the start or end zone of a row; a
|
|
35
|
+
* plain named group renders inline and others extend it (`MenuBuilder.extend`); the overflow menu (⋮,
|
|
36
|
+
* `TOOLBAR_OVERFLOW_ID`) ends the first row and takes collapsible items while a row is too narrow. One row renders as a
|
|
37
|
+
* single `Toolbar.Root` (which takes the props and ref); more stack one per row. Hand-written controls join the graph as
|
|
38
|
+
* `custom` items (`MenuBuilder.custom`), labels as `text` items.
|
|
16
39
|
*/
|
|
17
40
|
export declare const ActionToolbar: React.ForwardRefExoticComponent<Omit<ActionToolbarProps, "className"> & {
|
|
18
41
|
classNames?: ClassNameValue;
|
|
19
42
|
} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>;
|
|
43
|
+
export {};
|
|
20
44
|
//# sourceMappingURL=ActionToolbar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionToolbar.d.ts","sourceRoot":"","sources":["../../../../src/components/ActionToolbar.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ActionToolbar.d.ts","sourceRoot":"","sources":["../../../../src/components/ActionToolbar.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAE/C,OAAO,KAYN,MAAM,OAAO,CAAC;AAQf,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAC;AAGlD,OAAO,EACL,KAAK,cAAc,EAOpB,MAAM,gBAAgB,CAAC;AAKxB,OAAO,EAAE,KAAK,gBAAgB,EAAgC,MAAM,mBAAmB,CAAC;AACxF,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,QAAQ,EAOd,MAAM,aAAa,CAAC;AAUrB,KAAK,SAAS,CAAC,CAAC,IAAI;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GAAG,CAAC,CAAC;AA+R9C;;;GAGG;AACH,eAAO,MAAM,eAAe,+BAIzB,SAAS,CAAC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,6BA2BpD,CAAC;AAkSF,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC,GACnD,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,UAAU,GAAG,UAAU,CAAC,GAAG;IACjD,2GAA2G;IAC3G,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,aAAa,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAC5C;;;OAGG;IACH,MAAM,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;CAC7B,CAAC;AAEJ;;;;;;GAMG;AACH,eAAO,MAAM,aAAa;;6GA2GzB,CAAC"}
|
|
@@ -15,14 +15,17 @@ declare const meta: {
|
|
|
15
15
|
};
|
|
16
16
|
export default meta;
|
|
17
17
|
type Story = StoryObj;
|
|
18
|
-
export declare const DropdownMenu: Story;
|
|
19
18
|
export declare const Default: Story;
|
|
19
|
+
export declare const DropdownMenu: Story;
|
|
20
20
|
/** Reactive toolbar driven by an atom-backed actions hook; the menu structure is data, not JSX. */
|
|
21
21
|
export declare const UseMenuActionsToolbar: Story;
|
|
22
22
|
/** Toolbar with both labeled and tooltip-only (iconOnly) switch items. */
|
|
23
23
|
export declare const SwitchToolbar: Story;
|
|
24
|
-
/**
|
|
25
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Another component extends a toolbar it does not own through `customActions`: a label, its own control (`custom`), an
|
|
26
|
+
* action in the owner's named group, and an item in the overflow menu.
|
|
27
|
+
*/
|
|
28
|
+
export declare const CustomActions: Story;
|
|
26
29
|
/** The other way round: a hand-written `Toolbar.Root` with an `ActionMenu` among its own controls. */
|
|
27
30
|
export declare const EmbeddedMenu: Story;
|
|
28
31
|
/**
|
|
@@ -36,4 +39,30 @@ export declare const Builder: Story;
|
|
|
36
39
|
* toolbar did: its controls stay operable, so the first press on an unattended plank both attends it and acts.
|
|
37
40
|
*/
|
|
38
41
|
export declare const Attention: Story;
|
|
42
|
+
/** The owner's named groups across the start and end zones, with Export in the overflow menu. */
|
|
43
|
+
export declare const Groups: Story;
|
|
44
|
+
/** Other components extend the owner's named groups (interleaved by order), add a second row, and extend ⋮. */
|
|
45
|
+
export declare const Extended: Story;
|
|
46
|
+
/** At a narrow width whole groups move into ⋮ by collapse rank, each as a submenu; unranked groups stay. */
|
|
47
|
+
export declare const Narrow: Story;
|
|
48
|
+
/** Groups that fold do so in place, into a dropdown in the row, before any item moves into ⋮. */
|
|
49
|
+
export declare const Folding: Story;
|
|
50
|
+
/**
|
|
51
|
+
* Collapsing the items between rules leaves none of them: a rule stays only between two items, and of the rules left
|
|
52
|
+
* between two, the gap. The ⋮ menu lists them in the row's order, ruled where the row is.
|
|
53
|
+
*/
|
|
54
|
+
export declare const Separators: Story;
|
|
55
|
+
/** The ⋮ menu keeps the row's order when an item that stays in the row sets the others' fallback order. */
|
|
56
|
+
export declare const OverflowOrder: Story;
|
|
57
|
+
/** The same graph rendered as a menu: named groups are submenus. */
|
|
58
|
+
export declare const AsMenu: Story;
|
|
59
|
+
/** Too narrow for the labels, ranked items take their compact form in place, in rank order, before anything moves. */
|
|
60
|
+
export declare const Compact: Story;
|
|
61
|
+
/** A toolbar as wide as its content takes its full form again once the box it measures has room. */
|
|
62
|
+
export declare const GrowBack: Story;
|
|
63
|
+
/**
|
|
64
|
+
* An item whose content grows past the box it measures makes the items beside it collapse, though menu and box are
|
|
65
|
+
* unchanged; once its content shrinks back, they take their full form again.
|
|
66
|
+
*/
|
|
67
|
+
export declare const ChangingContent: Story;
|
|
39
68
|
//# sourceMappingURL=ActionToolbar.stories.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionToolbar.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/ActionToolbar.stories.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"ActionToolbar.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/ActionToolbar.stories.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAOjE,OAAO,0BAA0B,CAAC;AAmBlC,QAAA,MAAM,IAAI;;;;;;;;;;;;CAMM,CAAC;eAEF,IAAI;AAEnB,KAAK,KAAK,GAAG,QAAQ,CAAC;AAEtB,eAAO,MAAM,OAAO,EAAE,KAOrB,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAmB1B,CAAC;AAEF,mGAAmG;AACnG,eAAO,MAAM,qBAAqB,EAAE,KAOnC,CAAC;AAEF,0EAA0E;AAC1E,eAAO,MAAM,aAAa,EAAE,KAgC3B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,KAiD3B,CAAC;AAEF,sGAAsG;AACtG,eAAO,MAAM,YAAY,EAAE,KA4B1B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,OAAO,EAAE,KA6JrB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,SAAS,EAAE,KAoBvB,CAAC;AA4JF,iGAAiG;AACjG,eAAO,MAAM,MAAM,EAAE,KAmBpB,CAAC;AAEF,+GAA+G;AAC/G,eAAO,MAAM,QAAQ,EAAE,KAwBtB,CAAC;AAEF,4GAA4G;AAC5G,eAAO,MAAM,MAAM,EAAE,KAWpB,CAAC;AAEF,iGAAiG;AACjG,eAAO,MAAM,OAAO,EAAE,KAQrB,CAAC;AA2BF;;;GAGG;AACH,eAAO,MAAM,UAAU,EAAE,KAcxB,CAAC;AAmBF,2GAA2G;AAC3G,eAAO,MAAM,aAAa,EAAE,KAU3B,CAAC;AAEF,oEAAoE;AACpE,eAAO,MAAM,MAAM,EAAE,KAQpB,CAAC;AAuCF,sHAAsH;AACtH,eAAO,MAAM,OAAO,EAAE,KAWrB,CAAC;AAeF,oGAAoG;AACpG,eAAO,MAAM,QAAQ,EAAE,KAUtB,CAAC;AA0DF;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,KAW7B,CAAC"}
|
|
@@ -2,7 +2,7 @@ export * from './components/index.ts';
|
|
|
2
2
|
export * from './hooks/index.ts';
|
|
3
3
|
export * from './types.ts';
|
|
4
4
|
export { createGapSeparator, createLineSeparator, createMenuAction, createMenuItemGroup, executeMenuAction, fallbackIcon, } from './util.ts';
|
|
5
|
-
export { type ActionGroupBuilder, type ActionGroupBuilderFn, MenuBuilder } from './builder.ts';
|
|
5
|
+
export { type ActionGroupBuilder, type ActionGroupBuilderFn, MenuBuilder, TOOLBAR_OVERFLOW_ID } from './builder.ts';
|
|
6
6
|
export { PROMPT_DISPOSITION, TOOLBAR_DISPOSITION, isPromptAction, isToolbarAction } from './toolbar.ts';
|
|
7
7
|
export { applyPresentation } from './presentation.ts';
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,YAAY,GACb,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,oBAAoB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,YAAY,GACb,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,oBAAoB,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACpH,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACxG,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/types/src/util.d.ts
CHANGED
|
@@ -13,10 +13,11 @@ export declare const createMenuAction: <P extends {} = {}>(id: string, invoke: (
|
|
|
13
13
|
id: string;
|
|
14
14
|
type: string;
|
|
15
15
|
properties: P & import("@dxos/ui-types").MenuItemChrome & {
|
|
16
|
-
variant?: 'action' | 'primary' | 'toggle' | 'switch' | 'custom';
|
|
16
|
+
variant?: 'action' | 'primary' | 'toggle' | 'switch' | 'custom' | 'text';
|
|
17
17
|
value?: string;
|
|
18
18
|
checked?: boolean;
|
|
19
|
-
|
|
19
|
+
indent?: number;
|
|
20
|
+
render?: (props: import("@dxos/ui-types").CustomRenderProps) => import("react").ReactNode;
|
|
20
21
|
} & {
|
|
21
22
|
presentation?: Partial<Record<string, Partial<import("@dxos/ui-types").MenuActionChrome>>>;
|
|
22
23
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/util.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,YAAY,MAAM,8BAA8B,CAAC;AAE7D,OAAO,EAAE,KAAK,oBAAoB,EAAE,KAAK,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAGzF,OAAO,EAAE,KAAK,UAAU,EAA0C,MAAM,YAAY,CAAC;AAErF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,WAAkB,UAAU,WAAU,YAAY,CAAC,WAAW,KAAQ,OAAO,CAAC,IAAI,CAS/G,CAAC;AAEF,eAAO,MAAM,WAAW,WAAY,YAAY,CAAC,UAAU,uBAE1D,CAAC;AAEF,eAAO,MAAM,YAAY,+BAA+B,CAAC;AAEzD,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,EAAE,WACvC,MAAM,UACF,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC,WAAW,KAAK,IAAI,cACvC,CAAC,GAAG,oBAAoB
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/util.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,YAAY,MAAM,8BAA8B,CAAC;AAE7D,OAAO,EAAE,KAAK,oBAAoB,EAAE,KAAK,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAGzF,OAAO,EAAE,KAAK,UAAU,EAA0C,MAAM,YAAY,CAAC;AAErF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,WAAkB,UAAU,WAAU,YAAY,CAAC,WAAW,KAAQ,OAAO,CAAC,IAAI,CAS/G,CAAC;AAEF,eAAO,MAAM,WAAW,WAAY,YAAY,CAAC,UAAU,uBAE1D,CAAC;AAEF,eAAO,MAAM,YAAY,+BAA+B,CAAC;AAEzD,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,EAAE,WACvC,MAAM,UACF,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC,WAAW,KAAK,IAAI,cACvC,CAAC,GAAG,oBAAoB;;;;;;;;;;;;oBAMlB,YAAY,CAAC,WAAW;CACnB,CAAC;AAE1B,eAAO,MAAM,mBAAmB,GAAI,CAAC,SAAS,uBAAuB,MAAM,MAAM,cAAc,CAAC;;;;;CAMpE,CAAC;AAE7B,eAAO,MAAM,kBAAkB,QAAQ,MAAM,WAAkB,MAAM;;;;;;;cAM5C,KAAK;;;;;kBAOd,OAAO;;CAGrB,CAAC;AAEH,eAAO,MAAM,mBAAmB,QAAQ,MAAM,WAAmB,MAAM;;;;;;;cAM9C,KAAK;;;;;kBAGY,OAAO;;CAC/C,CAAC"}
|