react-dockable-desktop 2.1.0 → 3.1.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/README.md +269 -69
- package/dist/index.cjs +24 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +315 -59
- package/dist/index.d.ts +315 -59
- package/dist/index.js +24 -3
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1092 -52
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import React$1, { ComponentType, Context, Provider, ReactNode } from 'react';
|
|
2
|
+
import { ContextMenuItem } from 'replace-react-contexify';
|
|
3
|
+
export { ContextMenuItem, ContextMenuSeparator, ContextMenuSimpleItem, ContextMenuSubMenu } from 'replace-react-contexify';
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* @file WindowManager.tsx
|
|
@@ -10,6 +12,7 @@ import React$1, { ComponentType, Context, Provider, ReactNode } from 'react';
|
|
|
10
12
|
interface WindowManagerProps {
|
|
11
13
|
skin?: string;
|
|
12
14
|
defaultPanelIcon?: React$1.ReactNode;
|
|
15
|
+
taskbarVisibility?: 'always' | 'compact' | 'autohide';
|
|
13
16
|
}
|
|
14
17
|
declare const WindowManager: React$1.FC<WindowManagerProps>;
|
|
15
18
|
|
|
@@ -628,25 +631,8 @@ interface WindowManagerProviderProps {
|
|
|
628
631
|
windowBodyClass?: string;
|
|
629
632
|
}
|
|
630
633
|
declare const WindowManagerProvider: React$1.FC<WindowManagerProviderProps>;
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
* The component re-renders whenever the state changes.
|
|
634
|
-
*
|
|
635
|
-
* For imperative reads without a subscription, use {@link WorkspaceClient} methods
|
|
636
|
-
* like `isOpen()` and `getOpenPanelIds()` instead.
|
|
637
|
-
*
|
|
638
|
-
* @group Hooks
|
|
639
|
-
* @returns The current workspace state tree.
|
|
640
|
-
* @throws Error if used outside of a {@link WindowManagerProvider}.
|
|
641
|
-
* @example
|
|
642
|
-
* ```tsx
|
|
643
|
-
* function PanelList() {
|
|
644
|
-
* const { panels } = useWindowManagerState();
|
|
645
|
-
* return <ul>{Object.keys(panels).map(id => <li key={id}>{id}</li>)}</ul>;
|
|
646
|
-
* }
|
|
647
|
-
* ```
|
|
648
|
-
*/
|
|
649
|
-
declare const useWindowManagerState: () => WindowState;
|
|
634
|
+
declare function useWindowManagerState(): WindowState;
|
|
635
|
+
declare function useWindowManagerState<T>(selector: (state: WindowState) => T): T;
|
|
650
636
|
/**
|
|
651
637
|
* React hook to retrieve all layout mutation actions.
|
|
652
638
|
* Returns the public {@link WindowActions} interface.
|
|
@@ -681,7 +667,61 @@ declare const usePanelContext: () => Pick<WindowActions, "publish" | "subscribe"
|
|
|
681
667
|
* React hook to fetch the localizable predefined message map catalog.
|
|
682
668
|
*/
|
|
683
669
|
declare const usePredefinedMessages: () => Record<PredefinedMessageKey, ContextMenuPredefinedMessage>;
|
|
670
|
+
/**
|
|
671
|
+
* React hook to retrieve the panel instance ID for the component currently rendered inside
|
|
672
|
+
* the dockable desktop. Works for docked, floating, modal, and side-panel containers.
|
|
673
|
+
* Opt-in — components that don't need the ID require no changes.
|
|
674
|
+
*
|
|
675
|
+
* @group Hooks
|
|
676
|
+
* @returns The unique panel instance ID string.
|
|
677
|
+
* @example
|
|
678
|
+
* ```tsx
|
|
679
|
+
* function MyPanel() {
|
|
680
|
+
* const panelId = usePanelId();
|
|
681
|
+
* const { closePanel } = useWindowManagerActions();
|
|
682
|
+
* return <button onClick={() => closePanel(panelId)}>Close</button>;
|
|
683
|
+
* }
|
|
684
|
+
* ```
|
|
685
|
+
*/
|
|
686
|
+
declare const usePanelId: () => string;
|
|
687
|
+
/**
|
|
688
|
+
* React hook for injecting custom context menu items into a panel's context menu from inside the panel component.
|
|
689
|
+
* Items are dynamic — the array is re-read each time the menu opens, so state-driven changes (enable/disable, add/remove) work automatically.
|
|
690
|
+
* The hook reads the panel ID internally via {@link usePanelId} — no prop needed.
|
|
691
|
+
*
|
|
692
|
+
* @param items - Array of `ContextMenuItem` entries (simple items, separators, submenus).
|
|
693
|
+
* @example
|
|
694
|
+
* ```tsx
|
|
695
|
+
* import { usePanelContextMenu } from 'dockable-windows';
|
|
696
|
+
*
|
|
697
|
+
* function MyPanel() {
|
|
698
|
+
* const [dirty, setDirty] = useState(false);
|
|
699
|
+
* usePanelContextMenu([
|
|
700
|
+
* { label: 'Save', action: () => save() },
|
|
701
|
+
* { label: 'Revert', action: () => revert() },
|
|
702
|
+
* ]);
|
|
703
|
+
* return <Editor onChange={() => setDirty(true)} />;
|
|
704
|
+
* }
|
|
705
|
+
* ```
|
|
706
|
+
*/
|
|
707
|
+
declare function usePanelContextMenu(items: ContextMenuItem[]): void;
|
|
684
708
|
|
|
709
|
+
/** Built-in lifecycle events always available on the WorkspaceClient event bus. */
|
|
710
|
+
interface BuiltInPanelEvents {
|
|
711
|
+
'panel:opened': {
|
|
712
|
+
id: string;
|
|
713
|
+
component: string;
|
|
714
|
+
};
|
|
715
|
+
'panel:closed': {
|
|
716
|
+
id: string;
|
|
717
|
+
};
|
|
718
|
+
'panel:minimized': {
|
|
719
|
+
id: string;
|
|
720
|
+
};
|
|
721
|
+
'panel:restored': {
|
|
722
|
+
id: string;
|
|
723
|
+
};
|
|
724
|
+
}
|
|
685
725
|
/** Per-panel definition supplied to WorkspaceClient constructor. */
|
|
686
726
|
interface PanelDefinition {
|
|
687
727
|
component: ComponentType<any>;
|
|
@@ -716,15 +756,12 @@ interface WorkspaceClientConfig {
|
|
|
716
756
|
*
|
|
717
757
|
* @remarks
|
|
718
758
|
* Calls made before the provider mounts are queued and replayed automatically
|
|
719
|
-
* in order once `_connect()` fires.
|
|
720
|
-
*
|
|
721
|
-
*
|
|
722
|
-
*
|
|
723
|
-
* `subscribe()` and `saveLayout()` return values immediately and cannot be
|
|
724
|
-
* queued — they return safe defaults (`() => {}` and `''`) when disconnected.
|
|
759
|
+
* in order once `_connect()` fires. Duplicate `openPanel` calls for the same
|
|
760
|
+
* ID are deduplicated while queued. Subscriptions made before mount are
|
|
761
|
+
* buffered and re-registered on each connect/reconnect.
|
|
725
762
|
*
|
|
726
763
|
* @example
|
|
727
|
-
* const workspace = new WorkspaceClient({
|
|
764
|
+
* const workspace = new WorkspaceClient<MyEvents>({
|
|
728
765
|
* panels: {
|
|
729
766
|
* map: { component: MapPanel },
|
|
730
767
|
* editor: { component: EditorPanel, defaultOptions: { title: 'Code Editor' } },
|
|
@@ -741,7 +778,7 @@ interface WorkspaceClientConfig {
|
|
|
741
778
|
* workspace.openPanel('map-1', 'map');
|
|
742
779
|
* workspace.focusPanel('map-1');
|
|
743
780
|
*/
|
|
744
|
-
declare class WorkspaceClient {
|
|
781
|
+
declare class WorkspaceClient<TUserEvents extends Record<string, unknown> = Record<string, unknown>> {
|
|
745
782
|
/** Scoped panel registry — fully independent from the global singleton. */
|
|
746
783
|
readonly registry: PanelRegistryClass;
|
|
747
784
|
/** Serialised layout to restore on mount, or null to start with an empty canvas. */
|
|
@@ -749,9 +786,14 @@ declare class WorkspaceClient {
|
|
|
749
786
|
/** Non-rendering configuration forwarded to the provider. */
|
|
750
787
|
readonly config: Pick<WorkspaceClientConfig, 'formatMessage' | 'predefinedMessages' | 'dir'>;
|
|
751
788
|
private _actions;
|
|
789
|
+
private _initialized;
|
|
752
790
|
/** Calls queued before _connect() fires — replayed in order on first connect. */
|
|
753
791
|
private _pendingCalls;
|
|
754
|
-
/**
|
|
792
|
+
/** Tracks openPanel IDs in the pending queue to prevent duplicates before mount. */
|
|
793
|
+
private _pendingOpenPanelIds;
|
|
794
|
+
/** Subscriptions buffered before connect — re-registered on every connect/reconnect. */
|
|
795
|
+
private _pendingSubscriptions;
|
|
796
|
+
/** Timer that emits an error if _connect() is never called with pending work. */
|
|
755
797
|
private _disconnectedWarnTimer;
|
|
756
798
|
constructor(config?: WorkspaceClientConfig);
|
|
757
799
|
/** @internal Called by WindowManagerProvider after mount. */
|
|
@@ -760,11 +802,9 @@ declare class WorkspaceClient {
|
|
|
760
802
|
_disconnect(): void;
|
|
761
803
|
/** True while the provider is mounted and React state is accessible. */
|
|
762
804
|
get isConnected(): boolean;
|
|
763
|
-
|
|
764
|
-
* Dispatches a void action immediately if connected, or queues it for replay.
|
|
765
|
-
* In development, warns if the client is still not connected after 1 second.
|
|
766
|
-
*/
|
|
805
|
+
private _startWarnTimer;
|
|
767
806
|
private _dispatch;
|
|
807
|
+
private _subscribeRaw;
|
|
768
808
|
openPanel(...args: Parameters<WindowActions['openPanel']>): void;
|
|
769
809
|
closePanel(id: string): void;
|
|
770
810
|
minimizePanel(id: string): void;
|
|
@@ -785,10 +825,35 @@ declare class WorkspaceClient {
|
|
|
785
825
|
saveLayout(): string;
|
|
786
826
|
loadLayout(json: string): boolean;
|
|
787
827
|
setDirection(dir: 'ltr' | 'rtl'): void;
|
|
788
|
-
publish(event:
|
|
789
|
-
subscribe(event:
|
|
828
|
+
publish<K extends keyof (TUserEvents & BuiltInPanelEvents)>(event: K, data: (TUserEvents & BuiltInPanelEvents)[K]): void;
|
|
829
|
+
subscribe<K extends keyof (TUserEvents & BuiltInPanelEvents)>(event: K, callback: (data: (TUserEvents & BuiltInPanelEvents)[K]) => void): () => void;
|
|
830
|
+
/** Subscribe to panel open events. Fires only for newly created panels. */
|
|
831
|
+
onPanelOpen(callback: (id: string, component: string) => void): () => void;
|
|
832
|
+
/** Subscribe to panel close events. */
|
|
833
|
+
onPanelClose(callback: (id: string) => void): () => void;
|
|
834
|
+
/** Subscribe to panel minimize events. */
|
|
835
|
+
onPanelMinimize(callback: (id: string) => void): () => void;
|
|
836
|
+
/** Subscribe to panel restore events. */
|
|
837
|
+
onPanelRestore(callback: (id: string) => void): () => void;
|
|
790
838
|
}
|
|
791
839
|
|
|
840
|
+
/**
|
|
841
|
+
* Composite provider that wraps both `WindowManagerProvider` and `PanelProvider`
|
|
842
|
+
* in the correct order. Drop-in replacement for manually nesting both providers.
|
|
843
|
+
*
|
|
844
|
+
* `WindowManagerProvider` and `PanelProvider` remain independently exported
|
|
845
|
+
* for cases that require custom nesting or separate configuration.
|
|
846
|
+
*
|
|
847
|
+
* @example
|
|
848
|
+
* ```tsx
|
|
849
|
+
* <DockableDesktopProvider client={workspace}>
|
|
850
|
+
* <WindowManager />
|
|
851
|
+
* <ModalStackRenderer />
|
|
852
|
+
* </DockableDesktopProvider>
|
|
853
|
+
* ```
|
|
854
|
+
*/
|
|
855
|
+
declare const DockableDesktopProvider: React$1.FC<WindowManagerProviderProps>;
|
|
856
|
+
|
|
792
857
|
/**
|
|
793
858
|
* Options used when requesting to close a container.
|
|
794
859
|
*/
|
|
@@ -1010,8 +1075,10 @@ declare const ConfirmationForm: React$1.FC<ConfirmationFormProps>;
|
|
|
1010
1075
|
|
|
1011
1076
|
/**
|
|
1012
1077
|
* @file Sidebar.tsx
|
|
1013
|
-
* @description Sidebar
|
|
1014
|
-
*
|
|
1078
|
+
* @description Sidebar activity bar (strip) and resizable content drawer.
|
|
1079
|
+
* The strip and drawer are independently controllable via `visible` and
|
|
1080
|
+
* `stripVisible`. Drawer width is pixel-based and user-draggable using the
|
|
1081
|
+
* same pointer-capture interaction as the panel grid resizer.
|
|
1015
1082
|
*/
|
|
1016
1083
|
|
|
1017
1084
|
/**
|
|
@@ -1024,16 +1091,12 @@ interface SidebarTab {
|
|
|
1024
1091
|
/**
|
|
1025
1092
|
* Mount immediately when the Sidebar first renders, not on first user click.
|
|
1026
1093
|
* Implies `preserveState: true`.
|
|
1027
|
-
* Use when other parts of the app need to interact with the panel before
|
|
1028
|
-
* the user has opened it (e.g. push data into a context, warm up a WebGL map).
|
|
1029
1094
|
* Default: false
|
|
1030
1095
|
*/
|
|
1031
1096
|
eagerMount?: boolean;
|
|
1032
1097
|
/**
|
|
1033
|
-
*
|
|
1034
|
-
*
|
|
1035
|
-
* Use for panels with expensive local state (long forms, WebGL scenes, etc.).
|
|
1036
|
-
* Ignored when `eagerMount` is true (eagerly mounted panels are always preserved).
|
|
1098
|
+
* Keep the component alive behind `display: none` when closed instead of
|
|
1099
|
+
* unmounting it. Use for panels with expensive local state.
|
|
1037
1100
|
* Default: false
|
|
1038
1101
|
*/
|
|
1039
1102
|
preserveState?: boolean;
|
|
@@ -1041,41 +1104,234 @@ interface SidebarTab {
|
|
|
1041
1104
|
* Called to obtain the drawer content for this tab.
|
|
1042
1105
|
* @param tabId - the id of this tab
|
|
1043
1106
|
* @param onClose - call to collapse the sidebar drawer
|
|
1044
|
-
* @param onOpen - call to expand the drawer and select this tab
|
|
1045
|
-
* (useful when the panel itself detects it has new data to show)
|
|
1107
|
+
* @param onOpen - call to expand the drawer and select this tab
|
|
1046
1108
|
*/
|
|
1047
1109
|
renderContent: (tabId: string, onClose: () => void, onOpen: () => void) => React$1.ReactNode;
|
|
1048
1110
|
}
|
|
1049
1111
|
interface SidebarProps {
|
|
1050
|
-
/** Which side the
|
|
1112
|
+
/** Which side the activity bar and drawer appear on. Default: 'right' */
|
|
1051
1113
|
position?: 'left' | 'right';
|
|
1052
1114
|
tabs: SidebarTab[];
|
|
1053
|
-
/**
|
|
1054
|
-
|
|
1055
|
-
/**
|
|
1115
|
+
/** Initial drawer width in pixels. Default: 220 */
|
|
1116
|
+
defaultWidth?: number;
|
|
1117
|
+
/** Minimum drawer width in pixels during drag-resize. Default: 150 */
|
|
1118
|
+
minWidth?: number;
|
|
1119
|
+
/** Maximum drawer width in pixels during drag-resize. Default: 600 */
|
|
1120
|
+
maxWidth?: number;
|
|
1121
|
+
/** Called during drag resize and on setWidth() with the new pixel width. */
|
|
1122
|
+
onWidthChange?: (px: number) => void;
|
|
1123
|
+
/** Controlled active tab id. Omit to use internal state. */
|
|
1056
1124
|
activeTabId?: string | null;
|
|
1057
|
-
/** Called when the active tab changes
|
|
1125
|
+
/** Called when the active tab changes. */
|
|
1058
1126
|
onActiveTabChange?: (tabId: string | null) => void;
|
|
1059
|
-
/**
|
|
1127
|
+
/** Collapse the entire sidebar (strip + drawer). Default: true */
|
|
1128
|
+
visible?: boolean;
|
|
1129
|
+
/** Called when show/hide/toggle is invoked on the imperative handle. */
|
|
1130
|
+
onVisibilityChange?: (visible: boolean) => void;
|
|
1131
|
+
/** Collapse only the activity bar strip, leaving the drawer unaffected. Default: true */
|
|
1132
|
+
stripVisible?: boolean;
|
|
1133
|
+
/** Called when showStrip/hideStrip is invoked on the imperative handle. */
|
|
1134
|
+
onStripVisibilityChange?: (visible: boolean) => void;
|
|
1135
|
+
/** Main workspace content rendered alongside the sidebar. */
|
|
1060
1136
|
children?: React$1.ReactNode;
|
|
1137
|
+
/** @deprecated Use defaultWidth (number, pixels) instead. */
|
|
1138
|
+
drawerWidth?: string;
|
|
1061
1139
|
}
|
|
1062
1140
|
/**
|
|
1063
|
-
* Imperative handle exposed by `<Sidebar ref={...}
|
|
1064
|
-
* Allows external components (outside the sidebar tree) to control
|
|
1065
|
-
* which tab is open without prop drilling.
|
|
1141
|
+
* Imperative handle exposed by `<Sidebar ref={...}>`.
|
|
1066
1142
|
*/
|
|
1067
1143
|
interface SidebarHandle {
|
|
1068
|
-
/** Expand the drawer and activate the tab with the given id. */
|
|
1069
1144
|
openTab: (tabId: string) => void;
|
|
1070
|
-
/** Collapse the drawer (equivalent to clicking the active tab icon). */
|
|
1071
1145
|
closeDrawer: () => void;
|
|
1072
|
-
|
|
1146
|
+
getActiveTab: () => string | null;
|
|
1147
|
+
show: () => void;
|
|
1148
|
+
hide: () => void;
|
|
1149
|
+
toggle: () => void;
|
|
1150
|
+
showStrip: () => void;
|
|
1151
|
+
hideStrip: () => void;
|
|
1152
|
+
setWidth: (px: number) => void;
|
|
1153
|
+
getWidth: () => number;
|
|
1154
|
+
}
|
|
1155
|
+
/**
|
|
1156
|
+
* Value provided by `useSidebar()`. Available to any component inside the
|
|
1157
|
+
* `<Sidebar>` React tree, including panels rendered via `{children}`.
|
|
1158
|
+
*/
|
|
1159
|
+
interface SidebarContextValue {
|
|
1160
|
+
openTab: (tabId: string) => void;
|
|
1161
|
+
closeDrawer: () => void;
|
|
1073
1162
|
getActiveTab: () => string | null;
|
|
1074
1163
|
}
|
|
1075
1164
|
/**
|
|
1076
|
-
*
|
|
1077
|
-
*
|
|
1165
|
+
* Value provided by `useSidebarTab()`. Available only to components rendered
|
|
1166
|
+
* inside a sidebar tab's `renderContent` tree.
|
|
1078
1167
|
*/
|
|
1168
|
+
interface SidebarTabContextValue {
|
|
1169
|
+
tabId: string;
|
|
1170
|
+
onOpen: () => void;
|
|
1171
|
+
onClose: () => void;
|
|
1172
|
+
openTab: (tabId: string) => void;
|
|
1173
|
+
}
|
|
1079
1174
|
declare const Sidebar: React$1.ForwardRefExoticComponent<SidebarProps & React$1.RefAttributes<SidebarHandle>>;
|
|
1175
|
+
/**
|
|
1176
|
+
* Returns sidebar control functions from anywhere inside a `<Sidebar>` tree,
|
|
1177
|
+
* including floating panels rendered via `{children}`.
|
|
1178
|
+
*
|
|
1179
|
+
* Returns a no-op object with a console warning when called outside a Sidebar.
|
|
1180
|
+
*/
|
|
1181
|
+
declare function useSidebar(): SidebarContextValue;
|
|
1182
|
+
/**
|
|
1183
|
+
* Returns tab-specific control functions for components rendered inside a
|
|
1184
|
+
* sidebar tab's `renderContent` tree.
|
|
1185
|
+
*
|
|
1186
|
+
* Returns a no-op object with a console warning when called outside tab content.
|
|
1187
|
+
*/
|
|
1188
|
+
declare function useSidebarTab(): SidebarTabContextValue;
|
|
1189
|
+
|
|
1190
|
+
/**
|
|
1191
|
+
* @file ToolbarContext.tsx
|
|
1192
|
+
* @description Toolbar state context — radio group selection and toggle modifier state.
|
|
1193
|
+
* Provided by DockableDesktopProvider; consumed via useToolbar() from anywhere in the tree.
|
|
1194
|
+
*/
|
|
1195
|
+
|
|
1196
|
+
interface ToolbarContextValue {
|
|
1197
|
+
/** Returns the active item id in a radio group, or null if none. */
|
|
1198
|
+
getActiveInGroup: (group: string) => string | null;
|
|
1199
|
+
/** Set the active item in a radio group (pass null to deselect all). */
|
|
1200
|
+
setActiveInGroup: (group: string, id: string | null) => void;
|
|
1201
|
+
/** Returns whether a toggle modifier is currently active. */
|
|
1202
|
+
isModifierActive: (id: string) => boolean;
|
|
1203
|
+
/** Explicitly set a toggle modifier's active state. */
|
|
1204
|
+
setModifierActive: (id: string, active: boolean) => void;
|
|
1205
|
+
/** Flip a toggle modifier between active and inactive. */
|
|
1206
|
+
toggleModifier: (id: string) => void;
|
|
1207
|
+
}
|
|
1208
|
+
declare const ToolbarProvider: React$1.FC<{
|
|
1209
|
+
children: React$1.ReactNode;
|
|
1210
|
+
}>;
|
|
1211
|
+
/**
|
|
1212
|
+
* Returns toolbar state and control functions from anywhere inside
|
|
1213
|
+
* a `<DockableDesktopProvider>` tree.
|
|
1214
|
+
*
|
|
1215
|
+
* Returns a no-op object with a console warning when called outside the provider.
|
|
1216
|
+
*/
|
|
1217
|
+
declare function useToolbar(): ToolbarContextValue;
|
|
1218
|
+
|
|
1219
|
+
/**
|
|
1220
|
+
* @file Toolbar.tsx
|
|
1221
|
+
* @description Vertical or horizontal toolbar strip hosting action buttons,
|
|
1222
|
+
* mutually-exclusive radio tool groups, independent toggle modifiers,
|
|
1223
|
+
* and collapsible sub-tool group flyouts.
|
|
1224
|
+
* State is library-wide via DockableDesktopProvider / ToolbarContext.
|
|
1225
|
+
*/
|
|
1226
|
+
|
|
1227
|
+
/** A one-shot action button. */
|
|
1228
|
+
interface ToolbarActionItem {
|
|
1229
|
+
type: 'action';
|
|
1230
|
+
id: string;
|
|
1231
|
+
label: string;
|
|
1232
|
+
icon: React$1.ReactNode;
|
|
1233
|
+
onClick: () => void;
|
|
1234
|
+
disabled?: boolean;
|
|
1235
|
+
}
|
|
1236
|
+
/** A mutually-exclusive radio button within a named group. */
|
|
1237
|
+
interface ToolbarRadioItem {
|
|
1238
|
+
type: 'radio';
|
|
1239
|
+
id: string;
|
|
1240
|
+
group: string;
|
|
1241
|
+
label: string;
|
|
1242
|
+
icon: React$1.ReactNode;
|
|
1243
|
+
/** Keyboard shortcut hint — displayed in the group flyout; reserved for future custom tooltip. */
|
|
1244
|
+
shortcut?: string;
|
|
1245
|
+
/** Called when this item becomes active. */
|
|
1246
|
+
onActivate?: (id: string) => void;
|
|
1247
|
+
disabled?: boolean;
|
|
1248
|
+
}
|
|
1249
|
+
/** An independent on/off toggle modifier (e.g. snap-to-grid). */
|
|
1250
|
+
interface ToolbarToggleItem {
|
|
1251
|
+
type: 'toggle';
|
|
1252
|
+
id: string;
|
|
1253
|
+
label: string;
|
|
1254
|
+
icon: React$1.ReactNode;
|
|
1255
|
+
/** Keyboard shortcut hint — reserved for future custom tooltip. */
|
|
1256
|
+
shortcut?: string;
|
|
1257
|
+
/** Called after the toggle flips; receives the new active state. */
|
|
1258
|
+
onToggle?: (active: boolean) => void;
|
|
1259
|
+
disabled?: boolean;
|
|
1260
|
+
}
|
|
1261
|
+
/** A visual divider between button groups. */
|
|
1262
|
+
interface ToolbarSeparator {
|
|
1263
|
+
type: 'separator';
|
|
1264
|
+
}
|
|
1265
|
+
/**
|
|
1266
|
+
* A single selectable sub-tool inside a group flyout.
|
|
1267
|
+
* All sub-items in the same ToolbarGroupItem share one radio group
|
|
1268
|
+
* keyed by the parent ToolbarGroupItem's `id`.
|
|
1269
|
+
*/
|
|
1270
|
+
interface ToolbarGroupSubItem {
|
|
1271
|
+
id: string;
|
|
1272
|
+
label: string;
|
|
1273
|
+
icon: React$1.ReactNode;
|
|
1274
|
+
/** Keyboard shortcut displayed in the flyout panel. */
|
|
1275
|
+
shortcut?: string;
|
|
1276
|
+
disabled?: boolean;
|
|
1277
|
+
/** Called when this sub-item is selected. */
|
|
1278
|
+
onActivate?: (id: string) => void;
|
|
1279
|
+
}
|
|
1280
|
+
/** An entry inside a group flyout — either a sub-item or a separator. */
|
|
1281
|
+
type ToolbarGroupEntry = ToolbarGroupSubItem | {
|
|
1282
|
+
type: 'separator';
|
|
1283
|
+
};
|
|
1284
|
+
/**
|
|
1285
|
+
* A collapsed tool-family button that opens a flyout panel listing all
|
|
1286
|
+
* sub-tools. Only one sub-tool may be active at a time (radio semantics).
|
|
1287
|
+
* The parent button's icon morphs to show the currently active sub-tool.
|
|
1288
|
+
*
|
|
1289
|
+
* Supports both uncontrolled mode (omit activeItemId — state lives in
|
|
1290
|
+
* ToolbarContext) and controlled mode (provide activeItemId — the caller
|
|
1291
|
+
* is the single source of truth and must update the prop in response to
|
|
1292
|
+
* onActiveItemChange).
|
|
1293
|
+
*/
|
|
1294
|
+
interface ToolbarGroupItem {
|
|
1295
|
+
type: 'group';
|
|
1296
|
+
/** Serves as both the button ID and the radio group key in ToolbarContext. */
|
|
1297
|
+
id: string;
|
|
1298
|
+
/** Tooltip / aria-label shown when no sub-item is active. */
|
|
1299
|
+
label: string;
|
|
1300
|
+
/** Icon shown when no sub-item is active. */
|
|
1301
|
+
defaultIcon: React$1.ReactNode;
|
|
1302
|
+
items: ToolbarGroupEntry[];
|
|
1303
|
+
disabled?: boolean;
|
|
1304
|
+
/**
|
|
1305
|
+
* Controlled active sub-item id. When provided (even as null), the
|
|
1306
|
+
* component reads this prop instead of ToolbarContext and fires
|
|
1307
|
+
* onActiveItemChange on click instead of updating context.
|
|
1308
|
+
* Omit (undefined) for uncontrolled behaviour.
|
|
1309
|
+
*/
|
|
1310
|
+
activeItemId?: string | null;
|
|
1311
|
+
/**
|
|
1312
|
+
* Called when the user selects a sub-item in controlled mode.
|
|
1313
|
+
* The toolbar does not update itself — the caller must update activeItemId.
|
|
1314
|
+
*/
|
|
1315
|
+
onActiveItemChange?: (id: string) => void;
|
|
1316
|
+
}
|
|
1317
|
+
type ToolbarItem = ToolbarActionItem | ToolbarRadioItem | ToolbarToggleItem | ToolbarGroupItem | ToolbarSeparator;
|
|
1318
|
+
interface ToolbarProps {
|
|
1319
|
+
/** Side the strip is attached to. Controls strip orientation. Default: 'left' */
|
|
1320
|
+
position?: 'left' | 'right' | 'top' | 'bottom';
|
|
1321
|
+
/** Ordered list of items to render. */
|
|
1322
|
+
items: ToolbarItem[];
|
|
1323
|
+
/** Collapse the strip to zero width/height. State is preserved — no unmount. */
|
|
1324
|
+
visible?: boolean;
|
|
1325
|
+
/** Called when show/hide/toggle is invoked on the imperative handle. */
|
|
1326
|
+
onVisibilityChange?: (visible: boolean) => void;
|
|
1327
|
+
className?: string;
|
|
1328
|
+
style?: React$1.CSSProperties;
|
|
1329
|
+
}
|
|
1330
|
+
interface ToolbarHandle {
|
|
1331
|
+
show(): void;
|
|
1332
|
+
hide(): void;
|
|
1333
|
+
toggle(): void;
|
|
1334
|
+
}
|
|
1335
|
+
declare const Toolbar: React$1.ForwardRefExoticComponent<ToolbarProps & React$1.RefAttributes<ToolbarHandle>>;
|
|
1080
1336
|
|
|
1081
|
-
export { type CloseOptions, ConfirmationForm, type ConfirmationFormProps, type ContextMenuPredefinedMessage, type DropPosition, type DropTarget, type FloatingWindow, FormContainerContext, type FormContainerContract, FormContainerProvider, type LayoutGridNode, type LayoutLeafNode, type LayoutNode, LeftPanelRenderer, type MessageFormatter, type ModalOptions, ModalStackRenderer, type PanelActions, type PanelDefinition, type PanelInfo, type PanelInstance, type PanelInstanceId, PanelProvider, PanelRegistry, PanelRegistryClass, type PanelRegistryEntry, type PanelState, type PanelTitle, type PredefinedMessageKey, RightPanelRenderer, type SidePanelOptions, SidePanelRenderer, type SidePanelRendererProps, Sidebar, type SidebarHandle, type SidebarProps, type SidebarTab, type SplitDirection, type SplitOrientation, type StyleClasses, type WindowActions, WindowManager, WindowManagerProvider, type WindowState, WorkspaceClient, type WorkspaceClientConfig, defaultPredefinedMessages, formatLabel, useFormContainer, useFormatMessage, usePanelActions, usePanelContext, usePanelState, usePredefinedMessages, useRegistry, useStyleClasses, useWindowManagerActions, useWindowManagerState };
|
|
1337
|
+
export { type BuiltInPanelEvents, type CloseOptions, ConfirmationForm, type ConfirmationFormProps, type ContextMenuPredefinedMessage, DockableDesktopProvider, type DropPosition, type DropTarget, type FloatingWindow, FormContainerContext, type FormContainerContract, FormContainerProvider, type LayoutGridNode, type LayoutLeafNode, type LayoutNode, LeftPanelRenderer, type MessageFormatter, type ModalOptions, ModalStackRenderer, type PanelActions, type PanelDefinition, type PanelInfo, type PanelInstance, type PanelInstanceId, PanelProvider, PanelRegistry, PanelRegistryClass, type PanelRegistryEntry, type PanelState, type PanelTitle, type PredefinedMessageKey, RightPanelRenderer, type SidePanelOptions, SidePanelRenderer, type SidePanelRendererProps, Sidebar, type SidebarContextValue, type SidebarHandle, type SidebarProps, type SidebarTab, type SidebarTabContextValue, type SplitDirection, type SplitOrientation, type StyleClasses, Toolbar, type ToolbarActionItem, type ToolbarContextValue, type ToolbarGroupEntry, type ToolbarGroupItem, type ToolbarGroupSubItem, type ToolbarHandle, type ToolbarItem, type ToolbarProps, ToolbarProvider, type ToolbarRadioItem, type ToolbarSeparator, type ToolbarToggleItem, type WindowActions, WindowManager, WindowManagerProvider, type WindowState, WorkspaceClient, type WorkspaceClientConfig, defaultPredefinedMessages, formatLabel, useFormContainer, useFormatMessage, usePanelActions, usePanelContext, usePanelContextMenu, usePanelId, usePanelState, usePredefinedMessages, useRegistry, useSidebar, useSidebarTab, useStyleClasses, useToolbar, useWindowManagerActions, useWindowManagerState };
|