@blorkfield/blork-tabs 0.1.3

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Blorkfield
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,166 @@
1
+ # @blorkfield/blork-tabs
2
+
3
+ A framework-agnostic tab/panel management system with snapping and docking capabilities.
4
+
5
+ ## Features
6
+
7
+ - **Panel Snapping** - Panels snap together to form linked chains
8
+ - **Anchor Docking** - Dock panels to predefined screen positions
9
+ - **Drag Modes** - Drag entire groups or detach individual panels
10
+ - **Collapse/Expand** - Panels can be collapsed with automatic repositioning
11
+ - **Event System** - Subscribe to drag, snap, and collapse events
12
+ - **Fully Typed** - Complete TypeScript support
13
+ - **Framework Agnostic** - Works with plain DOM or any framework
14
+ - **Customizable** - CSS variables for easy theming
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ npm install @blorkfield/blork-tabs
20
+ ```
21
+
22
+ ## Quick Start
23
+
24
+ ```typescript
25
+ import { TabManager } from '@blorkfield/blork-tabs';
26
+ import '@blorkfield/blork-tabs/styles.css';
27
+
28
+ // Create the tab manager
29
+ const manager = new TabManager({
30
+ snapThreshold: 50,
31
+ panelGap: 0,
32
+ panelMargin: 16,
33
+ });
34
+
35
+ // Create panels programmatically
36
+ manager.addPanel({
37
+ id: 'settings',
38
+ title: 'Settings',
39
+ content: '<div>Settings content here</div>',
40
+ });
41
+
42
+ manager.addPanel({
43
+ id: 'tools',
44
+ title: 'Tools',
45
+ content: '<div>Tools content here</div>',
46
+ });
47
+
48
+ // Or register existing DOM elements
49
+ manager.registerPanel('my-panel', document.getElementById('my-panel'), {
50
+ dragHandle: document.getElementById('my-panel-header'),
51
+ collapseButton: document.getElementById('my-panel-collapse'),
52
+ contentWrapper: document.getElementById('my-panel-content'),
53
+ });
54
+
55
+ // Position panels and create snap chains
56
+ manager.positionPanelsFromRight(['tools', 'settings']);
57
+ manager.createSnapChain(['settings', 'tools']);
58
+
59
+ // Listen to events
60
+ manager.on('snap:panel', ({ movingPanels, targetPanel, side }) => {
61
+ console.log(`Panels snapped to ${side} of ${targetPanel.id}`);
62
+ });
63
+ ```
64
+
65
+ ## Configuration
66
+
67
+ ```typescript
68
+ const manager = new TabManager({
69
+ // Distance threshold for panel-to-panel snapping (default: 50)
70
+ snapThreshold: 50,
71
+
72
+ // Gap between snapped panels (default: 0)
73
+ panelGap: 0,
74
+
75
+ // Margin from window edges (default: 16)
76
+ panelMargin: 16,
77
+
78
+ // Distance threshold for anchor snapping (default: 80)
79
+ anchorThreshold: 80,
80
+
81
+ // Default panel width for calculations (default: 300)
82
+ defaultPanelWidth: 300,
83
+
84
+ // Container element (default: document.body)
85
+ container: document.body,
86
+
87
+ // Auto-create default anchors (default: true)
88
+ initializeDefaultAnchors: true,
89
+
90
+ // CSS class prefix (default: 'blork-tabs')
91
+ classPrefix: 'blork-tabs',
92
+ });
93
+ ```
94
+
95
+ ## API Reference
96
+
97
+ ### TabManager
98
+
99
+ #### Panel Management
100
+ - `addPanel(config)` - Create a new panel
101
+ - `registerPanel(id, element, options)` - Register existing DOM element
102
+ - `removePanel(id)` - Remove a panel
103
+ - `getPanel(id)` - Get panel by ID
104
+ - `getAllPanels()` - Get all panels
105
+
106
+ #### Snap Chain Management
107
+ - `getSnapChain(panelId)` - Get all panels in same chain
108
+ - `snap(leftPanelId, rightPanelId)` - Manually snap two panels
109
+ - `detach(panelId)` - Detach panel from chain
110
+ - `createSnapChain(panelIds)` - Create chain from panel IDs
111
+ - `updatePositions()` - Recalculate snapped positions
112
+
113
+ #### Positioning
114
+ - `positionPanelsFromRight(panelIds, gap?)` - Position from right edge
115
+ - `positionPanelsFromLeft(panelIds, gap?)` - Position from left edge
116
+
117
+ #### Anchors
118
+ - `addAnchor(config)` - Add custom anchor
119
+ - `addPresetAnchor(preset)` - Add preset anchor
120
+ - `removeAnchor(id)` - Remove anchor
121
+ - `getAnchors()` - Get all anchors
122
+
123
+ #### Events
124
+ - `on(event, listener)` - Subscribe to event
125
+ - `off(event, listener)` - Unsubscribe from event
126
+
127
+ ### Events
128
+
129
+ | Event | Description |
130
+ |-------|-------------|
131
+ | `panel:added` | Panel was added |
132
+ | `panel:removed` | Panel was removed |
133
+ | `drag:start` | Drag operation started |
134
+ | `drag:move` | Panel being dragged |
135
+ | `drag:end` | Drag operation ended |
136
+ | `snap:panel` | Panels snapped together |
137
+ | `snap:anchor` | Panels snapped to anchor |
138
+ | `panel:detached` | Panel detached from chain |
139
+ | `panel:collapse` | Panel collapsed/expanded |
140
+
141
+ ## CSS Customization
142
+
143
+ Override CSS variables to customize appearance:
144
+
145
+ ```css
146
+ :root {
147
+ --blork-tabs-panel-bg: #1a1a2e;
148
+ --blork-tabs-panel-border: 1px solid #2a2a4a;
149
+ --blork-tabs-panel-radius: 8px;
150
+ --blork-tabs-panel-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
151
+ --blork-tabs-header-bg: #2a2a4a;
152
+ --blork-tabs-header-color: #e0e0e0;
153
+ --blork-tabs-content-bg: #1a1a2e;
154
+ --blork-tabs-accent: #4a90d9;
155
+ }
156
+ ```
157
+
158
+ For light theme, add `blork-tabs-light` class to container:
159
+
160
+ ```html
161
+ <body class="blork-tabs-light">
162
+ ```
163
+
164
+ ## License
165
+
166
+ MIT