@blorkfield/blork-tabs 0.2.6 → 0.3.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/README.md CHANGED
@@ -8,6 +8,7 @@ A framework-agnostic tab/panel management system with snapping and docking capab
8
8
  - **Anchor Docking** - Dock panels to predefined screen positions
9
9
  - **Drag Modes** - Drag entire groups or detach individual panels
10
10
  - **Collapse/Expand** - Panels can be collapsed with automatic repositioning
11
+ - **Auto-Hide** - Panels can hide after inactivity and show on interaction
11
12
  - **Event System** - Subscribe to drag, snap, and collapse events
12
13
  - **Fully Typed** - Complete TypeScript support
13
14
  - **Framework Agnostic** - Works with plain DOM or any framework
@@ -89,6 +90,12 @@ const manager = new TabManager({
89
90
 
90
91
  // CSS class prefix (default: 'blork-tabs')
91
92
  classPrefix: 'blork-tabs',
93
+
94
+ // Whether panels start hidden (default: false)
95
+ startHidden: false,
96
+
97
+ // Milliseconds before auto-hiding on inactivity (default: undefined = no auto-hide)
98
+ autoHideDelay: undefined,
92
99
  });
93
100
  ```
94
101
 
@@ -98,6 +105,7 @@ const manager = new TabManager({
98
105
 
99
106
  #### Panel Management
100
107
  - `addPanel(config)` - Create a new panel
108
+ - `addDebugPanel(config)` - Create a debug panel with logging interface
101
109
  - `registerPanel(id, element, options)` - Register existing DOM element
102
110
  - `removePanel(id)` - Remove a panel
103
111
  - `getPanel(id)` - Get panel by ID
@@ -120,6 +128,11 @@ const manager = new TabManager({
120
128
  - `removeAnchor(id)` - Remove anchor
121
129
  - `getAnchors()` - Get all anchors
122
130
 
131
+ #### Auto-Hide
132
+ - `show(panelId)` - Show a hidden panel
133
+ - `hide(panelId)` - Hide a panel
134
+ - `isHidden(panelId)` - Check if panel is hidden
135
+
123
136
  #### Events
124
137
  - `on(event, listener)` - Subscribe to event
125
138
  - `off(event, listener)` - Unsubscribe from event
@@ -137,6 +150,8 @@ const manager = new TabManager({
137
150
  | `snap:anchor` | Panels snapped to anchor |
138
151
  | `panel:detached` | Panel detached from chain |
139
152
  | `panel:collapse` | Panel collapsed/expanded |
153
+ | `panel:show` | Panel became visible (auto-hide) |
154
+ | `panel:hide` | Panel became hidden (auto-hide) |
140
155
 
141
156
  ## Multi-Section Panel Content
142
157
 
@@ -172,6 +187,191 @@ manager.addPanel({
172
187
 
173
188
  The panel content area has a max-height (default `20vh`) with `overflow-y: auto`, so long content scrolls properly. Splitting sections across multiple content wrappers defeats this behavior.
174
189
 
190
+ ## Auto-Hide
191
+
192
+ Panels can automatically hide after a period of inactivity and reappear when the user interacts with the page. This is useful for OBS overlays or any interface where you want panels to get out of the way.
193
+
194
+ ### Configuration
195
+
196
+ Auto-hide has two independent options:
197
+
198
+ - **`startHidden`** - Whether the panel starts invisible (default: `false`)
199
+ - **`autoHideDelay`** - Milliseconds before hiding after inactivity (default: `undefined` = no auto-hide)
200
+
201
+ These can be set globally on the TabManager or per-panel:
202
+
203
+ ```typescript
204
+ // Global: all panels hide after 3 seconds of inactivity
205
+ const manager = new TabManager({
206
+ autoHideDelay: 3000,
207
+ startHidden: true,
208
+ });
209
+
210
+ // Per-panel overrides
211
+ manager.addPanel({
212
+ id: 'always-visible',
213
+ title: 'Always Visible',
214
+ autoHideDelay: 0, // Disable auto-hide for this panel
215
+ });
216
+
217
+ manager.addPanel({
218
+ id: 'quick-hide',
219
+ title: 'Quick Hide',
220
+ autoHideDelay: 1000, // This panel hides faster
221
+ startHidden: false, // But starts visible
222
+ });
223
+ ```
224
+
225
+ ### Behavior Matrix
226
+
227
+ | startHidden | autoHideDelay | Behavior |
228
+ |-------------|---------------|----------|
229
+ | `false` | `undefined` | Normal - always visible |
230
+ | `true` | `undefined` | Starts hidden, shows on activity, never hides again |
231
+ | `false` | `3000` | Starts visible, hides after 3s of inactivity |
232
+ | `true` | `3000` | Starts hidden, shows on activity, hides after 3s of inactivity |
233
+
234
+ ### Events
235
+
236
+ ```typescript
237
+ manager.on('panel:show', ({ panel, trigger }) => {
238
+ // trigger: 'activity' (user interaction) or 'api' (programmatic)
239
+ console.log(`${panel.id} is now visible`);
240
+ });
241
+
242
+ manager.on('panel:hide', ({ panel, trigger }) => {
243
+ // trigger: 'timeout' (auto-hide delay) or 'api' (programmatic)
244
+ console.log(`${panel.id} is now hidden`);
245
+ });
246
+ ```
247
+
248
+ ### Programmatic Control
249
+
250
+ ```typescript
251
+ manager.hide('my-panel'); // Hide immediately
252
+ manager.show('my-panel'); // Show immediately
253
+ manager.isHidden('my-panel'); // Check visibility
254
+ ```
255
+
256
+ ## Debug Panel
257
+
258
+ A plug-and-play debug panel for in-browser event logging—useful for OBS browser sources and other environments without console access.
259
+
260
+ ### Creating a Debug Panel
261
+
262
+ ```typescript
263
+ import { TabManager } from '@blorkfield/blork-tabs';
264
+
265
+ const manager = new TabManager();
266
+
267
+ // Create a debug panel
268
+ const debug = manager.addDebugPanel({
269
+ id: 'debug',
270
+ title: 'Event Log', // optional, default: 'Debug'
271
+ width: 300, // optional, default: 300
272
+ maxEntries: 50, // optional, default: 50
273
+ showTimestamps: true, // optional, default: false
274
+ showClearButton: true, // optional, default: true
275
+ startCollapsed: true, // optional, default: true
276
+ initialPosition: { x: 16, y: 16 },
277
+ });
278
+ ```
279
+
280
+ ### Logging Events
281
+
282
+ Log events with different severity levels, each with distinct color coding:
283
+
284
+ ```typescript
285
+ // Info/Log level - blue (accent color)
286
+ debug.log('event-name', { some: 'data' });
287
+ debug.info('connection', { status: 'connected' });
288
+
289
+ // Warning level - yellow
290
+ debug.warn('cache', { message: 'Cache expired, refreshing...' });
291
+
292
+ // Error level - red
293
+ debug.error('request', { code: 500, message: 'Server error' });
294
+
295
+ // Clear all entries
296
+ debug.clear();
297
+ ```
298
+
299
+ ### Features
300
+
301
+ - **Pre-styled monospace container** - Optimized for log readability
302
+ - **Color-coded log levels** - Blue for info, yellow for warnings, red for errors
303
+ - **Auto-scroll** - Automatically scrolls to show latest entries
304
+ - **Entry limit** - Configurable max entries with FIFO removal of oldest
305
+ - **Timestamps** - Optional timestamp display for each entry
306
+ - **Hover glow effect** - Border lights up with accent color on hover
307
+ - **Enlarge on hover** - Hover for 5 seconds to expand to 75% of screen with 2x text size
308
+ - **Modal backdrop** - Enlarged view has a backdrop; click × or backdrop to close
309
+ - **Standard panel features** - Drag, snap, collapse, auto-hide all work
310
+
311
+ ### Enlarged View Behavior
312
+
313
+ The debug panel has a special "focus mode" for reading logs:
314
+
315
+ 1. **Hover for configurable delay** → Panel enlarges to 75% of screen with doubled text size (default: 5 seconds, configurable via `hoverDelay`)
316
+ 2. **Mouse can move freely** → Panel stays enlarged, won't close on mouse leave
317
+ 3. **Click × or backdrop** → Returns to normal size
318
+
319
+ The × button is only visible when enlarged. Set `hoverDelay: 0` to disable the enlarge feature entirely.
320
+
321
+ **Auto-hide interaction:** When hovering a debug panel that has auto-hide enabled, the auto-hide timer is paused so the panel won't disappear before the hover-to-enlarge triggers.
322
+
323
+ ### Configuration Options
324
+
325
+ | Option | Type | Default | Description |
326
+ |--------|------|---------|-------------|
327
+ | `maxEntries` | `number` | `50` | Maximum log entries before oldest are removed |
328
+ | `showTimestamps` | `boolean` | `false` | Show timestamps on each entry |
329
+ | `hoverDelay` | `number` | `5000` | Milliseconds to hover before enlarging (0 = disable) |
330
+
331
+ Plus all standard `PanelConfig` options (`id`, `title`, `width`, `initialPosition`, `startCollapsed`, etc.)
332
+
333
+ ### Accessing the Underlying Panel
334
+
335
+ ```typescript
336
+ // The debug panel interface includes access to the panel state
337
+ debug.panel; // PanelState - for advanced manipulation
338
+ ```
339
+
340
+ ### Embeddable Debug Log
341
+
342
+ You can embed a debug log inside any panel or container element using `createDebugLog()`:
343
+
344
+ ```typescript
345
+ const manager = new TabManager();
346
+
347
+ // Create a panel with custom content
348
+ const panel = manager.addPanel({
349
+ id: 'my-panel',
350
+ title: 'My Panel',
351
+ content: '<div id="my-content">Some content</div>',
352
+ });
353
+
354
+ // Add a debug log section to the panel
355
+ const logSection = document.createElement('div');
356
+ panel.contentWrapper.appendChild(logSection);
357
+
358
+ // Create the embedded debug log (shares hover-to-enlarge with standalone panels)
359
+ const embeddedLog = manager.createDebugLog(logSection, {
360
+ maxEntries: 20,
361
+ showTimestamps: true,
362
+ hoverDelay: 3000, // 3 second hover delay (0 to disable, default: 5000)
363
+ });
364
+
365
+ // Use it like a regular debug panel
366
+ embeddedLog.log('event', { data: 'value' });
367
+ embeddedLog.info('status', { connected: true });
368
+ embeddedLog.warn('warning', { message: 'Low memory' });
369
+ embeddedLog.error('error', { code: 500 });
370
+ embeddedLog.clear();
371
+ ```
372
+
373
+ The embedded log supports the same hover-to-enlarge behavior as the standalone debug panel.
374
+
175
375
  ## CSS Customization
176
376
 
177
377
  Override CSS variables to customize appearance: