@andrewcyuan/focusgrid 0.2.1 → 0.3.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.
@@ -2,8 +2,7 @@
2
2
  type PaneId = string;
3
3
  type NodeId = string;
4
4
  type Orientation = "horizontal" | "vertical";
5
- declare const cardinalDirections: readonly ["left", "right", "up", "down"];
6
- type CardinalDirection = (typeof cardinalDirections)[number];
5
+ type CardinalDirection = "left" | "right" | "up" | "down";
7
6
  declare enum PaneCommandCapability {
8
7
  ResizeX = "canResizeX",
9
8
  ResizeY = "canResizeY",
@@ -91,14 +90,13 @@ type PaneEventHandlers = {
91
90
  onPaneLayoutChange?: (event: PaneLayoutChangeEvent) => void;
92
91
  onPaneClose?: (event: PaneCloseEvent) => void;
93
92
  };
94
- type PaneDefaults = PaneCommandCapabilityInput;
95
93
  type FocusGridControllerProps = FocusGridControllerState & {
96
- paneDefaults?: PaneDefaults;
94
+ paneDefaults?: PaneCommandCapabilityInput;
97
95
  minWidth?: number;
98
96
  minHeight?: number;
99
97
  directionalFocusOverflow?: boolean;
100
98
  };
101
- type SplitPaneOptions = Partial<Omit<PaneNode, "kind" | "id" | "paneId">> & {
99
+ type SplitPaneOptions = PaneCommandCapabilityInput & {
102
100
  side: CardinalDirection;
103
101
  newPaneId?: PaneId;
104
102
  newPaneNodeId?: NodeId;
@@ -118,7 +116,7 @@ declare class FocusGridController {
118
116
  private readonly domController;
119
117
  readonly minWidth: number;
120
118
  readonly minHeight: number;
121
- readonly directionalFocusOverflow: boolean;
119
+ private readonly directionalFocusOverflow;
122
120
  private currentState;
123
121
  private cachedLayout;
124
122
  private readonly paneDefaults;
@@ -130,7 +128,6 @@ declare class FocusGridController {
130
128
  directionalFocusOverflow,
131
129
  ...state
132
130
  }: FocusGridControllerProps, domController: DomController);
133
- /** Computed render data; stable until the next committed change. */
134
131
  getLayout(): ComputedLayout;
135
132
  getPane(paneId: PaneId): PaneNode | null;
136
133
  getContainerSize(): {
@@ -143,13 +140,23 @@ declare class FocusGridController {
143
140
  focusAdjacent(direction: CardinalDirection): boolean;
144
141
  swapAdjacent(direction: CardinalDirection): boolean;
145
142
  resizeActive(direction: CardinalDirection, deltaPx: number): boolean;
146
- split(paneNodeId: NodeId, props: SplitPaneOptions): PaneId | null;
143
+ split(paneNodeId: NodeId, {
144
+ side,
145
+ newPaneId,
146
+ newPaneNodeId,
147
+ splitId: requestedSplitId,
148
+ preserveActivePane,
149
+ ...capabilities
150
+ }: SplitPaneOptions): PaneId | null;
147
151
  remove(paneId: PaneId): boolean;
148
152
  swap(firstPaneId: PaneId, secondPaneId: PaneId): boolean;
149
- resize(paneId: PaneId, props: ResizePaneOptions): boolean;
153
+ resize(paneId: PaneId, {
154
+ direction,
155
+ deltaPx
156
+ }: ResizePaneOptions): boolean;
150
157
  resizeHandle(splitId: NodeId, props: ResizeHandleOptions): boolean;
151
158
  focus(paneId: PaneId): boolean;
152
- updatePane(paneId: PaneId, patch: Partial<Omit<PaneNode, "kind" | "id" | "paneId">>): boolean;
159
+ updatePane(paneId: PaneId, patch: PaneCommandCapabilityInput): boolean;
153
160
  setContainerSize(width: number, height: number): boolean;
154
161
  private commit;
155
162
  subscribePaneEvents({
@@ -181,4 +188,4 @@ declare class FocusGridStateValidationException extends Error {
181
188
  }
182
189
  declare function validateFocusGridControllerState(input: unknown): FocusGridStateValidationResult;
183
190
  //#endregion
184
- export { type CardinalDirection, type ComputedHandle, type ComputedLayout, type ComputedNode, type ComputedPane, type DomController, FocusGridController, type FocusGridControllerProps, type FocusGridControllerState, type FocusGridStateValidationError, FocusGridStateValidationException, type FocusGridStateValidationResult, type LayoutNode, type Listener, type NodeId, type PaneCloseEvent, PaneCommandCapability, type PaneCommandCapabilityInput, type PaneDefaults, type PaneEventHandlers, type PaneId, type PaneLayoutChangeEvent, type PaneNode, type Rect, type ResizeHandleOptions, type ResizePaneOptions, type SplitNode, type SplitPaneOptions, cardinalDirections, validateFocusGridControllerState };
191
+ export { type CardinalDirection, type ComputedHandle, type ComputedLayout, type ComputedNode, type ComputedPane, type DomController, FocusGridController, type FocusGridControllerProps, type FocusGridControllerState, type FocusGridStateValidationError, FocusGridStateValidationException, type FocusGridStateValidationResult, type LayoutNode, type Listener, type NodeId, type PaneCloseEvent, PaneCommandCapability, type PaneCommandCapabilityInput, type PaneEventHandlers, type PaneId, type PaneLayoutChangeEvent, type PaneNode, type Rect, type ResizeHandleOptions, type ResizePaneOptions, type SplitNode, type SplitPaneOptions, validateFocusGridControllerState };
@@ -2,8 +2,7 @@
2
2
  type PaneId = string;
3
3
  type NodeId = string;
4
4
  type Orientation = "horizontal" | "vertical";
5
- declare const cardinalDirections: readonly ["left", "right", "up", "down"];
6
- type CardinalDirection = (typeof cardinalDirections)[number];
5
+ type CardinalDirection = "left" | "right" | "up" | "down";
7
6
  declare enum PaneCommandCapability {
8
7
  ResizeX = "canResizeX",
9
8
  ResizeY = "canResizeY",
@@ -91,14 +90,13 @@ type PaneEventHandlers = {
91
90
  onPaneLayoutChange?: (event: PaneLayoutChangeEvent) => void;
92
91
  onPaneClose?: (event: PaneCloseEvent) => void;
93
92
  };
94
- type PaneDefaults = PaneCommandCapabilityInput;
95
93
  type FocusGridControllerProps = FocusGridControllerState & {
96
- paneDefaults?: PaneDefaults;
94
+ paneDefaults?: PaneCommandCapabilityInput;
97
95
  minWidth?: number;
98
96
  minHeight?: number;
99
97
  directionalFocusOverflow?: boolean;
100
98
  };
101
- type SplitPaneOptions = Partial<Omit<PaneNode, "kind" | "id" | "paneId">> & {
99
+ type SplitPaneOptions = PaneCommandCapabilityInput & {
102
100
  side: CardinalDirection;
103
101
  newPaneId?: PaneId;
104
102
  newPaneNodeId?: NodeId;
@@ -118,7 +116,7 @@ declare class FocusGridController {
118
116
  private readonly domController;
119
117
  readonly minWidth: number;
120
118
  readonly minHeight: number;
121
- readonly directionalFocusOverflow: boolean;
119
+ private readonly directionalFocusOverflow;
122
120
  private currentState;
123
121
  private cachedLayout;
124
122
  private readonly paneDefaults;
@@ -130,7 +128,6 @@ declare class FocusGridController {
130
128
  directionalFocusOverflow,
131
129
  ...state
132
130
  }: FocusGridControllerProps, domController: DomController);
133
- /** Computed render data; stable until the next committed change. */
134
131
  getLayout(): ComputedLayout;
135
132
  getPane(paneId: PaneId): PaneNode | null;
136
133
  getContainerSize(): {
@@ -143,13 +140,23 @@ declare class FocusGridController {
143
140
  focusAdjacent(direction: CardinalDirection): boolean;
144
141
  swapAdjacent(direction: CardinalDirection): boolean;
145
142
  resizeActive(direction: CardinalDirection, deltaPx: number): boolean;
146
- split(paneNodeId: NodeId, props: SplitPaneOptions): PaneId | null;
143
+ split(paneNodeId: NodeId, {
144
+ side,
145
+ newPaneId,
146
+ newPaneNodeId,
147
+ splitId: requestedSplitId,
148
+ preserveActivePane,
149
+ ...capabilities
150
+ }: SplitPaneOptions): PaneId | null;
147
151
  remove(paneId: PaneId): boolean;
148
152
  swap(firstPaneId: PaneId, secondPaneId: PaneId): boolean;
149
- resize(paneId: PaneId, props: ResizePaneOptions): boolean;
153
+ resize(paneId: PaneId, {
154
+ direction,
155
+ deltaPx
156
+ }: ResizePaneOptions): boolean;
150
157
  resizeHandle(splitId: NodeId, props: ResizeHandleOptions): boolean;
151
158
  focus(paneId: PaneId): boolean;
152
- updatePane(paneId: PaneId, patch: Partial<Omit<PaneNode, "kind" | "id" | "paneId">>): boolean;
159
+ updatePane(paneId: PaneId, patch: PaneCommandCapabilityInput): boolean;
153
160
  setContainerSize(width: number, height: number): boolean;
154
161
  private commit;
155
162
  subscribePaneEvents({
@@ -181,4 +188,4 @@ declare class FocusGridStateValidationException extends Error {
181
188
  }
182
189
  declare function validateFocusGridControllerState(input: unknown): FocusGridStateValidationResult;
183
190
  //#endregion
184
- export { type CardinalDirection, type ComputedHandle, type ComputedLayout, type ComputedNode, type ComputedPane, type DomController, FocusGridController, type FocusGridControllerProps, type FocusGridControllerState, type FocusGridStateValidationError, FocusGridStateValidationException, type FocusGridStateValidationResult, type LayoutNode, type Listener, type NodeId, type PaneCloseEvent, PaneCommandCapability, type PaneCommandCapabilityInput, type PaneDefaults, type PaneEventHandlers, type PaneId, type PaneLayoutChangeEvent, type PaneNode, type Rect, type ResizeHandleOptions, type ResizePaneOptions, type SplitNode, type SplitPaneOptions, cardinalDirections, validateFocusGridControllerState };
191
+ export { type CardinalDirection, type ComputedHandle, type ComputedLayout, type ComputedNode, type ComputedPane, type DomController, FocusGridController, type FocusGridControllerProps, type FocusGridControllerState, type FocusGridStateValidationError, FocusGridStateValidationException, type FocusGridStateValidationResult, type LayoutNode, type Listener, type NodeId, type PaneCloseEvent, PaneCommandCapability, type PaneCommandCapabilityInput, type PaneEventHandlers, type PaneId, type PaneLayoutChangeEvent, type PaneNode, type Rect, type ResizeHandleOptions, type ResizePaneOptions, type SplitNode, type SplitPaneOptions, validateFocusGridControllerState };