torch-glare-mcp 1.4.0 → 1.5.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.
|
@@ -268,7 +268,7 @@ function CustomScreen({ data, fields }: Props) {
|
|
|
268
268
|
|
|
269
269
|
## Accessibility
|
|
270
270
|
|
|
271
|
-
- The view-switcher uses `
|
|
271
|
+
- The view-switcher uses [`TabSwitch`](./tab-switch.md) — a segmented `role="tablist"` control (each view a `role="tab"` button, full keyboard support via Tab/Enter/Space). Installing DataViews pulls in `TabSwitch` automatically.
|
|
272
272
|
- Tree rows expose `role="treeitem"` with `aria-expanded` and `aria-selected`.
|
|
273
273
|
- Filter checkboxes carry labels and `htmlFor` linkage.
|
|
274
274
|
- Settings panel buttons have `aria-pressed` for sort direction.
|
|
@@ -284,4 +284,5 @@ The component uses only `*-presentation-*` design tokens. Wrap with `ThemeProvid
|
|
|
284
284
|
- [`KanbanView`](./kanban-view.md) — standalone kanban
|
|
285
285
|
- [`InboxView`](./inbox-view.md) — standalone inbox
|
|
286
286
|
- [`TreeView`](./tree-view.md) — standalone tree
|
|
287
|
+
- [`TabSwitch`](./tab-switch.md) — the segmented view-switcher in the header (reusable on its own)
|
|
287
288
|
- [How-to: Render a backend response with DataViews](../how-to/data-views-from-backend-response.md) — recipes by data shape.
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: TabSwitch
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
status: stable
|
|
5
|
+
category: components/navigation
|
|
6
|
+
tags: [tab-switch, segmented-control, view-switcher, toggle, list-cards, pills]
|
|
7
|
+
last-reviewed: 2026-06-15
|
|
8
|
+
bundle-size: 2.0kb
|
|
9
|
+
dependencies:
|
|
10
|
+
- "class-variance-authority": "^0.7.0"
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# TabSwitch
|
|
14
|
+
|
|
15
|
+
> A segmented control for picking one option from a small set — the classic List / Cards style pill switcher. The active option renders as a solid raised white pill; thin dividers sit between adjacent inactive options (never flanking the active pill). Controlled, generic over the option value, supports optional per-option icons, three sizes, and theme-aware track/labels. This is the switcher used in the DataViews header to flip between Table / Kanban / Inbox / Tree.
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install torch-glare
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Import
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import { TabSwitch } from 'torch-glare/lib/components/TabSwitch'
|
|
27
|
+
import type { TabSwitchOption } from 'torch-glare/lib/components/TabSwitch'
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Quick Examples
|
|
31
|
+
|
|
32
|
+
### Basic Usage (List / Cards)
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
import { TabSwitch } from 'torch-glare/lib/components/TabSwitch'
|
|
36
|
+
import { useState } from 'react'
|
|
37
|
+
|
|
38
|
+
function Example() {
|
|
39
|
+
const [view, setView] = useState('list')
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<TabSwitch
|
|
43
|
+
value={view}
|
|
44
|
+
onValueChange={setView}
|
|
45
|
+
options={[
|
|
46
|
+
{ value: 'list', label: 'List', icon: <i className="ri-layout-grid-line" /> },
|
|
47
|
+
{ value: 'cards', label: 'Cards', icon: <i className="ri-grid-fill" /> },
|
|
48
|
+
]}
|
|
49
|
+
/>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Sizes
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
<TabSwitch size="S" value={view} onValueChange={setView} options={options} />
|
|
58
|
+
<TabSwitch size="M" value={view} onValueChange={setView} options={options} /> {/* default */}
|
|
59
|
+
<TabSwitch size="L" value={view} onValueChange={setView} options={options} />
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Icons Only
|
|
63
|
+
|
|
64
|
+
Omit `label` to render an icon-only switcher.
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
<TabSwitch
|
|
68
|
+
value={view}
|
|
69
|
+
onValueChange={setView}
|
|
70
|
+
options={[
|
|
71
|
+
{ value: 'list', icon: <i className="ri-layout-grid-line" /> },
|
|
72
|
+
{ value: 'cards', icon: <i className="ri-grid-fill" /> },
|
|
73
|
+
{ value: 'board', icon: <i className="ri-layout-column-line" /> },
|
|
74
|
+
]}
|
|
75
|
+
/>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### On a dark surface
|
|
79
|
+
|
|
80
|
+
The active pill is always a solid white pill with dark text, so it stays visible on dark bars. The track and inactive labels follow the theme — pass `theme="dark"` (or render inside a `data-theme="dark"` scope) so they resolve dark-theme tokens. This is how the DataViews header uses it.
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
<div data-theme="dark" className="bg-black p-2">
|
|
84
|
+
<TabSwitch theme="dark" value={view} onValueChange={setView} options={options} />
|
|
85
|
+
</div>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Disabled
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
{/* whole control */}
|
|
92
|
+
<TabSwitch disabled value={view} onValueChange={setView} options={options} />
|
|
93
|
+
|
|
94
|
+
{/* a single option */}
|
|
95
|
+
<TabSwitch
|
|
96
|
+
value={view}
|
|
97
|
+
onValueChange={setView}
|
|
98
|
+
options={[
|
|
99
|
+
{ value: 'list', label: 'List' },
|
|
100
|
+
{ value: 'cards', label: 'Cards', disabled: true },
|
|
101
|
+
]}
|
|
102
|
+
/>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## API Reference
|
|
106
|
+
|
|
107
|
+
### TabSwitch
|
|
108
|
+
|
|
109
|
+
| Prop | Type | Default | Description |
|
|
110
|
+
|------|------|---------|-------------|
|
|
111
|
+
| `options` | `TabSwitchOption[]` | — (required) | The selectable options rendered as segments. |
|
|
112
|
+
| `value` | `string` | — | The currently selected option value (controlled). |
|
|
113
|
+
| `onValueChange` | `(value: string) => void` | — | Called with the option value when a segment is selected. |
|
|
114
|
+
| `size` | `'S' \| 'M' \| 'L'` | `'M'` | Size of the control. |
|
|
115
|
+
| `disabled` | `boolean` | `false` | Disables the whole control. |
|
|
116
|
+
| `theme` | `'dark' \| 'light' \| 'default'` | — | Applies a fixed theme to the track and inactive labels (the active pill stays white). |
|
|
117
|
+
| `className` | `string` | — | Additional classes merged onto the track. |
|
|
118
|
+
|
|
119
|
+
`TabSwitch` is generic over the option value: `TabSwitch<T extends string>` infers `T` from `options`, so `value` and `onValueChange` are typed to your union (e.g. `'list' | 'cards'`).
|
|
120
|
+
|
|
121
|
+
### TabSwitchOption
|
|
122
|
+
|
|
123
|
+
| Prop | Type | Default | Description |
|
|
124
|
+
|------|------|---------|-------------|
|
|
125
|
+
| `value` | `string` | — | Unique value for the option. |
|
|
126
|
+
| `label` | `ReactNode` | `undefined` | Text or node shown for the option. Omit for an icon-only segment. |
|
|
127
|
+
| `icon` | `ReactNode` | `undefined` | Optional leading icon rendered before the label. |
|
|
128
|
+
| `disabled` | `boolean` | `false` | Disables this individual option. |
|
|
129
|
+
|
|
130
|
+
## Accessibility
|
|
131
|
+
|
|
132
|
+
- The track is a `role="tablist"`; each option is a `role="tab"` with `aria-selected` reflecting the active state.
|
|
133
|
+
- Options are real `<button>` elements, so they are keyboard-focusable and activate on Enter/Space.
|
|
134
|
+
|
|
135
|
+
## Notes
|
|
136
|
+
|
|
137
|
+
- The active pill is intentionally a solid white pill with dark text in every theme (not derived from the per-theme selected-tab tokens), so it reads correctly on the always-dark DataViews header as well as on light surfaces.
|
|
138
|
+
- TabSwitch is a controlled component — always pass both `value` and `onValueChange`.
|
|
139
|
+
|
|
140
|
+
## TypeScript
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
interface TabSwitchOption<T extends string = string> {
|
|
144
|
+
value: T
|
|
145
|
+
label?: React.ReactNode
|
|
146
|
+
icon?: React.ReactNode
|
|
147
|
+
disabled?: boolean
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
interface TabSwitchProps<T extends string = string>
|
|
151
|
+
extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {
|
|
152
|
+
options: TabSwitchOption<T>[]
|
|
153
|
+
value: T
|
|
154
|
+
onValueChange: (value: T) => void
|
|
155
|
+
size?: 'S' | 'M' | 'L'
|
|
156
|
+
theme?: 'dark' | 'light' | 'default'
|
|
157
|
+
disabled?: boolean
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
declare function TabSwitch<T extends string = string>(
|
|
161
|
+
props: TabSwitchProps<T> & { ref?: React.ForwardedRef<HTMLDivElement> }
|
|
162
|
+
): React.ReactElement
|
|
163
|
+
```
|
package/docs/llms-manifest.json
CHANGED
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"statistics": {
|
|
22
|
-
"totalComponents":
|
|
23
|
-
"documentedComponents":
|
|
24
|
-
"coverage":
|
|
22
|
+
"totalComponents": 75,
|
|
23
|
+
"documentedComponents": 72,
|
|
24
|
+
"coverage": 96.0,
|
|
25
25
|
"totalHooks": 4,
|
|
26
26
|
"totalProviders": 1,
|
|
27
27
|
"totalPlugins": 4,
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
]
|
|
65
65
|
},
|
|
66
66
|
"forms": {
|
|
67
|
-
"count":
|
|
67
|
+
"count": 20,
|
|
68
68
|
"items": [
|
|
69
69
|
{
|
|
70
70
|
"name": "SearchableSelect",
|
|
@@ -151,6 +151,11 @@
|
|
|
151
151
|
"version": "1.1.15",
|
|
152
152
|
"documented": true
|
|
153
153
|
},
|
|
154
|
+
{
|
|
155
|
+
"name": "TabSwitch",
|
|
156
|
+
"version": "1.0.0",
|
|
157
|
+
"documented": true
|
|
158
|
+
},
|
|
154
159
|
{
|
|
155
160
|
"name": "FormStepper",
|
|
156
161
|
"version": "2.1.1",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "torch-glare-mcp",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "MCP server for TORCH Glare component library — gives AI assistants full access to component docs, API references, code examples, and design system info",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|