-
-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathdevtools-store.ts
More file actions
115 lines (109 loc) · 2.95 KB
/
devtools-store.ts
File metadata and controls
115 lines (109 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import type { Hotkey } from '@tanstack/solid-hotkeys'
import type { TabName } from '../tabs'
import type { TanStackDevtoolsPlugin } from './devtools-context'
type TriggerPosition =
| 'top-left'
| 'top-right'
| 'bottom-left'
| 'bottom-right'
| 'middle-left'
| 'middle-right'
type TriggerProps = {
theme: 'light' | 'dark'
}
export type DevtoolsStore = {
settings: {
/**
* Whether the dev tools should be open by default
* @default false
*/
defaultOpen: boolean
/**
* Whether the dev tools trigger should be hidden until the user hovers over it
* @default false
*/
hideUntilHover: boolean
/**
* The position of the trigger button
* @default "bottom-right"
*/
position: TriggerPosition
/**
* The location of the panel once it is open
* @default "bottom"
*/
panelLocation: 'top' | 'bottom'
/**
* The hotkey to open the dev tools.
* Uses TanStack Hotkeys string format (e.g. "Mod+S", "Control+`").
* "Mod" maps to Command on macOS and Control on Windows/Linux.
* @default "Control+`"
*/
openHotkey: Hotkey
/**
* The hotkey to open the source inspector.
* Uses TanStack Hotkeys string format (e.g. "Mod+Shift").
* "Mod" maps to Command on macOS and Control on Windows/Linux.
* @default "Mod+Alt+Shift"
*/
inspectHotkey: string
/**
* Whether to require the URL flag to open the dev tools
* @default false
*/
requireUrlFlag: boolean
/**
* The URL flag to open the dev tools, used in conjunction with requireUrlFlag (if set to true)
* @default "tanstack-devtools"
*/
urlFlag: string
/**
* The theme of the dev tools
* @default "dark"
*/
theme: 'light' | 'dark'
/**
* Whether the trigger should be completely hidden or not (you can still open with the hotkey)
*/
triggerHidden?: boolean
/**
* An optional custom function to render the dev tools trigger component.
* If provided, it replaces the default trigger button.
* @default undefined
*/
customTrigger?: (el: HTMLElement, props: TriggerProps) => void
}
state: {
activeTab: TabName
height: number
activePlugins: Array<string>
persistOpen: boolean
}
plugins?: Array<TanStackDevtoolsPlugin>
}
export const initialState: DevtoolsStore = {
settings: {
defaultOpen: false,
hideUntilHover: false,
position: 'bottom-right',
panelLocation: 'bottom',
openHotkey: 'Control+`',
inspectHotkey: 'Mod+Alt+Shift',
requireUrlFlag: false,
urlFlag: 'tanstack-devtools',
theme:
typeof window !== 'undefined' &&
typeof window.matchMedia !== 'undefined' &&
window.matchMedia('(prefers-color-scheme: dark)').matches
? 'dark'
: 'light',
triggerHidden: false,
customTrigger: undefined,
},
state: {
activeTab: 'plugins',
height: 400,
activePlugins: [],
persistOpen: false,
},
}