@cloudvoyant/helical-svelte 0.20.1 → 0.21.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/dist/Kbd.svelte +86 -0
- package/dist/Kbd.svelte.d.ts +10 -0
- package/dist/Page.svelte +28 -3
- package/dist/Page.svelte.d.ts +2 -1
- package/dist/PageContent.svelte +33 -4
- package/dist/PageContent.svelte.d.ts +2 -1
- package/dist/PageGutter.svelte +34 -3
- package/dist/PageGutter.svelte.d.ts +2 -1
- package/dist/PageSection.svelte +33 -4
- package/dist/PageSection.svelte.d.ts +2 -1
- package/dist/SplitterPanel.svelte +29 -3
- package/dist/SplitterPanel.svelte.d.ts +3 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/listbox/ListboxItemGroup.svelte +17 -0
- package/dist/listbox/ListboxItemGroup.svelte.d.ts +9 -0
- package/dist/listbox/ListboxItemGroupLabel.svelte +17 -0
- package/dist/listbox/ListboxItemGroupLabel.svelte.d.ts +9 -0
- package/dist/listbox/index.d.ts +2 -0
- package/dist/listbox/index.js +2 -0
- package/dist/sidebar/Root.svelte +34 -9
- package/dist/sidebar/Root.svelte.d.ts +2 -1
- package/dist/which-key/Pane.svelte +49 -0
- package/dist/which-key/Pane.svelte.d.ts +10 -0
- package/dist/which-key/WhichKey.svelte +197 -0
- package/dist/which-key/WhichKey.svelte.d.ts +8 -0
- package/dist/which-key/WhichKeyExplorer.svelte +269 -0
- package/dist/which-key/WhichKeyExplorer.svelte.d.ts +8 -0
- package/dist/which-key/WhichKeyMode.svelte +44 -0
- package/dist/which-key/WhichKeyMode.svelte.d.ts +9 -0
- package/dist/which-key/WhichKeyProvider.svelte +136 -0
- package/dist/which-key/WhichKeyProvider.svelte.d.ts +9 -0
- package/dist/which-key/context.svelte.d.ts +57 -0
- package/dist/which-key/context.svelte.js +177 -0
- package/dist/which-key/index.d.ts +7 -0
- package/dist/which-key/index.js +7 -0
- package/dist/window/Window.svelte +30 -4
- package/dist/window/Window.svelte.d.ts +2 -1
- package/package.json +5 -2
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type JumpAction, type KeybindingPreset, type KeymapCommandContext, type KeymapMode, type WhichKeyController, type WhichKeyNode, type WhichKeyState } from '@cloudvoyant/helical-ui';
|
|
2
|
+
export declare const WHICH_KEY_CONTEXT_KEY: unique symbol;
|
|
3
|
+
export interface ReactiveWhichKeyContext {
|
|
4
|
+
readonly controller: WhichKeyController;
|
|
5
|
+
readonly state: WhichKeyState;
|
|
6
|
+
}
|
|
7
|
+
export declare function setWhichKeyContext(ctx: ReactiveWhichKeyContext): void;
|
|
8
|
+
export declare function getOptionalWhichKeyContext(): ReactiveWhichKeyContext | null;
|
|
9
|
+
export declare function useOptionalWhichKeyController(): WhichKeyController | null;
|
|
10
|
+
export declare function useWhichKeyController(): WhichKeyController;
|
|
11
|
+
export interface UseWhichKeyReturn extends WhichKeyState {
|
|
12
|
+
readonly state: WhichKeyState;
|
|
13
|
+
readonly controller: WhichKeyController;
|
|
14
|
+
setPreset: (preset: KeybindingPreset) => void;
|
|
15
|
+
setMode: (mode: KeymapMode) => void;
|
|
16
|
+
setJumpAction: (action: JumpAction) => void;
|
|
17
|
+
openExplorer: () => void;
|
|
18
|
+
closeExplorer: () => void;
|
|
19
|
+
setExplorerQuery: (query: string) => void;
|
|
20
|
+
openPrefix: (path: string[], options?: {
|
|
21
|
+
sticky?: boolean;
|
|
22
|
+
}) => void;
|
|
23
|
+
closePrefix: () => void;
|
|
24
|
+
stepBackPrefix: () => boolean;
|
|
25
|
+
triggerKey: (key: string) => boolean;
|
|
26
|
+
focusPane: (paneIdOrIndex: string | number) => boolean;
|
|
27
|
+
startJumpMode: (action?: JumpAction) => void;
|
|
28
|
+
cancelJumpMode: () => void;
|
|
29
|
+
jumpBack: () => boolean;
|
|
30
|
+
jumpForward: () => boolean;
|
|
31
|
+
executeCommand: (commandId: string, partialCtx?: Partial<KeymapCommandContext>) => boolean;
|
|
32
|
+
}
|
|
33
|
+
export declare function useWhichKey(): UseWhichKeyReturn;
|
|
34
|
+
export declare function useKeymap(nodes: Record<string, WhichKeyNode>, options?: {
|
|
35
|
+
scope?: string;
|
|
36
|
+
enabled?: boolean;
|
|
37
|
+
}): void;
|
|
38
|
+
export declare function useKeymapScope(scopeId: string, nodes: Record<string, WhichKeyNode>, enabled?: boolean): void;
|
|
39
|
+
export interface UsePaneRegistrationOptions {
|
|
40
|
+
paneId?: string;
|
|
41
|
+
paneTitle?: string;
|
|
42
|
+
paneDisabled?: boolean;
|
|
43
|
+
paneOrder?: number;
|
|
44
|
+
defaultTitle: string;
|
|
45
|
+
}
|
|
46
|
+
export interface UsePaneRegistrationResult {
|
|
47
|
+
readonly paneId: string;
|
|
48
|
+
readonly isActive: boolean;
|
|
49
|
+
readonly dataAttributes: {
|
|
50
|
+
'data-pane-id'?: string;
|
|
51
|
+
'data-pane-title'?: string;
|
|
52
|
+
'data-pane-order'?: string;
|
|
53
|
+
'data-pane-active'?: 'true' | 'false';
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export declare function useOptionalPaneRegistration(getElement: () => HTMLElement | null | undefined, getOptions: () => UsePaneRegistrationOptions): UsePaneRegistrationResult;
|
|
57
|
+
export type { JumpAction, KeybindingPreset, KeymapCommandContext, KeymapMode, WhichKeyNode, WhichKeyState };
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
// libs/helical-svelte/src/which-key/context.svelte.ts
|
|
2
|
+
import { getContext, hasContext, setContext } from 'svelte';
|
|
3
|
+
export const WHICH_KEY_CONTEXT_KEY = Symbol('helical-ui.which-key');
|
|
4
|
+
export function setWhichKeyContext(ctx) {
|
|
5
|
+
setContext(WHICH_KEY_CONTEXT_KEY, ctx);
|
|
6
|
+
}
|
|
7
|
+
export function getOptionalWhichKeyContext() {
|
|
8
|
+
if (!hasContext(WHICH_KEY_CONTEXT_KEY))
|
|
9
|
+
return null;
|
|
10
|
+
return getContext(WHICH_KEY_CONTEXT_KEY) ?? null;
|
|
11
|
+
}
|
|
12
|
+
export function useOptionalWhichKeyController() {
|
|
13
|
+
return getOptionalWhichKeyContext()?.controller ?? null;
|
|
14
|
+
}
|
|
15
|
+
export function useWhichKeyController() {
|
|
16
|
+
const controller = useOptionalWhichKeyController();
|
|
17
|
+
if (!controller) {
|
|
18
|
+
throw new Error('useWhichKey must be used within a <WhichKeyProvider>.');
|
|
19
|
+
}
|
|
20
|
+
return controller;
|
|
21
|
+
}
|
|
22
|
+
export function useWhichKey() {
|
|
23
|
+
const ctx = getOptionalWhichKeyContext();
|
|
24
|
+
if (!ctx) {
|
|
25
|
+
throw new Error('useWhichKey must be used within a <WhichKeyProvider>.');
|
|
26
|
+
}
|
|
27
|
+
const { controller } = ctx;
|
|
28
|
+
return {
|
|
29
|
+
get state() {
|
|
30
|
+
return ctx.state;
|
|
31
|
+
},
|
|
32
|
+
get preset() {
|
|
33
|
+
return ctx.state.preset;
|
|
34
|
+
},
|
|
35
|
+
get mode() {
|
|
36
|
+
return ctx.state.mode;
|
|
37
|
+
},
|
|
38
|
+
get leaderKey() {
|
|
39
|
+
return ctx.state.leaderKey;
|
|
40
|
+
},
|
|
41
|
+
get activePath() {
|
|
42
|
+
return ctx.state.activePath;
|
|
43
|
+
},
|
|
44
|
+
get breadcrumb() {
|
|
45
|
+
return ctx.state.breadcrumb;
|
|
46
|
+
},
|
|
47
|
+
get title() {
|
|
48
|
+
return ctx.state.title;
|
|
49
|
+
},
|
|
50
|
+
get items() {
|
|
51
|
+
return ctx.state.items;
|
|
52
|
+
},
|
|
53
|
+
get isOpen() {
|
|
54
|
+
return ctx.state.isOpen;
|
|
55
|
+
},
|
|
56
|
+
get sticky() {
|
|
57
|
+
return ctx.state.sticky;
|
|
58
|
+
},
|
|
59
|
+
get countBuffer() {
|
|
60
|
+
return ctx.state.countBuffer;
|
|
61
|
+
},
|
|
62
|
+
get explorerOpen() {
|
|
63
|
+
return ctx.state.explorerOpen;
|
|
64
|
+
},
|
|
65
|
+
get explorerQuery() {
|
|
66
|
+
return ctx.state.explorerQuery;
|
|
67
|
+
},
|
|
68
|
+
get explorerEntries() {
|
|
69
|
+
return ctx.state.explorerEntries;
|
|
70
|
+
},
|
|
71
|
+
get panes() {
|
|
72
|
+
return ctx.state.panes;
|
|
73
|
+
},
|
|
74
|
+
get activePaneId() {
|
|
75
|
+
return ctx.state.activePaneId;
|
|
76
|
+
},
|
|
77
|
+
get jumpQuery() {
|
|
78
|
+
return ctx.state.jumpQuery;
|
|
79
|
+
},
|
|
80
|
+
get jumpAction() {
|
|
81
|
+
return ctx.state.jumpAction;
|
|
82
|
+
},
|
|
83
|
+
get jumpTargets() {
|
|
84
|
+
return ctx.state.jumpTargets;
|
|
85
|
+
},
|
|
86
|
+
get statusMessage() {
|
|
87
|
+
return ctx.state.statusMessage;
|
|
88
|
+
},
|
|
89
|
+
get controller() {
|
|
90
|
+
return controller;
|
|
91
|
+
},
|
|
92
|
+
setPreset: controller.setPreset,
|
|
93
|
+
setMode: controller.setMode,
|
|
94
|
+
setJumpAction: controller.setJumpAction,
|
|
95
|
+
openExplorer: controller.openExplorer,
|
|
96
|
+
closeExplorer: controller.closeExplorer,
|
|
97
|
+
setExplorerQuery: controller.setExplorerQuery,
|
|
98
|
+
openPrefix: controller.openPrefix,
|
|
99
|
+
closePrefix: controller.closePrefix,
|
|
100
|
+
stepBackPrefix: controller.stepBackPrefix,
|
|
101
|
+
triggerKey: controller.triggerKey,
|
|
102
|
+
focusPane: controller.focusPane,
|
|
103
|
+
startJumpMode: controller.startJumpMode,
|
|
104
|
+
cancelJumpMode: controller.cancelJumpMode,
|
|
105
|
+
jumpBack: controller.jumpBack,
|
|
106
|
+
jumpForward: controller.jumpForward,
|
|
107
|
+
executeCommand: controller.executeCommand,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
let keymapCounter = 0;
|
|
111
|
+
export function useKeymap(nodes, options) {
|
|
112
|
+
const ctx = getOptionalWhichKeyContext();
|
|
113
|
+
const layerId = `svelte-keymap-${++keymapCounter}`;
|
|
114
|
+
$effect(() => {
|
|
115
|
+
if (!ctx || options?.enabled === false)
|
|
116
|
+
return;
|
|
117
|
+
return ctx.controller.registerKeymap(layerId, nodes, options);
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
export function useKeymapScope(scopeId, nodes, enabled = true) {
|
|
121
|
+
useKeymap(nodes, { scope: scopeId, enabled });
|
|
122
|
+
}
|
|
123
|
+
let autoPaneCounter = 0;
|
|
124
|
+
export function useOptionalPaneRegistration(getElement, getOptions) {
|
|
125
|
+
const ctx = getOptionalWhichKeyContext();
|
|
126
|
+
const fallbackId = `pane-svelte-${++autoPaneCounter}`;
|
|
127
|
+
$effect(() => {
|
|
128
|
+
const el = getElement();
|
|
129
|
+
const opts = getOptions();
|
|
130
|
+
if (!ctx || opts.paneDisabled || !el)
|
|
131
|
+
return;
|
|
132
|
+
const resolvedId = opts.paneId ?? fallbackId;
|
|
133
|
+
const resolvedTitle = opts.paneTitle ?? opts.defaultTitle;
|
|
134
|
+
return ctx.controller.registerPane({
|
|
135
|
+
id: resolvedId,
|
|
136
|
+
title: resolvedTitle,
|
|
137
|
+
element: el,
|
|
138
|
+
disabled: opts.paneDisabled,
|
|
139
|
+
order: opts.paneOrder,
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
return {
|
|
143
|
+
get paneId() {
|
|
144
|
+
return getOptions().paneId ?? fallbackId;
|
|
145
|
+
},
|
|
146
|
+
get isActive() {
|
|
147
|
+
const opts = getOptions();
|
|
148
|
+
if (!ctx || opts.paneDisabled)
|
|
149
|
+
return false;
|
|
150
|
+
const resolvedId = opts.paneId ?? fallbackId;
|
|
151
|
+
return ctx.state.activePaneId === resolvedId;
|
|
152
|
+
},
|
|
153
|
+
get dataAttributes() {
|
|
154
|
+
const opts = getOptions();
|
|
155
|
+
if (opts.paneDisabled)
|
|
156
|
+
return {};
|
|
157
|
+
const resolvedId = opts.paneId ?? fallbackId;
|
|
158
|
+
const resolvedTitle = opts.paneTitle ?? opts.defaultTitle;
|
|
159
|
+
if (!ctx) {
|
|
160
|
+
return opts.paneId
|
|
161
|
+
? {
|
|
162
|
+
'data-pane-id': opts.paneId,
|
|
163
|
+
'data-pane-title': resolvedTitle,
|
|
164
|
+
...(opts.paneOrder !== undefined ? { 'data-pane-order': String(opts.paneOrder) } : {}),
|
|
165
|
+
}
|
|
166
|
+
: {};
|
|
167
|
+
}
|
|
168
|
+
const isActive = ctx.state.activePaneId === resolvedId;
|
|
169
|
+
return {
|
|
170
|
+
'data-pane-id': resolvedId,
|
|
171
|
+
'data-pane-title': resolvedTitle,
|
|
172
|
+
...(opts.paneOrder !== undefined ? { 'data-pane-order': String(opts.paneOrder) } : {}),
|
|
173
|
+
'data-pane-active': isActive ? 'true' : 'false',
|
|
174
|
+
};
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { default as WhichKey } from './WhichKey.svelte';
|
|
2
|
+
export { default as WhichKeyMode } from './WhichKeyMode.svelte';
|
|
3
|
+
export { default as WhichKeyExplorer } from './WhichKeyExplorer.svelte';
|
|
4
|
+
export { default as WhichKeyProvider } from './WhichKeyProvider.svelte';
|
|
5
|
+
export { default as Pane } from './Pane.svelte';
|
|
6
|
+
export { WHICH_KEY_CONTEXT_KEY, setWhichKeyContext, getOptionalWhichKeyContext, useOptionalWhichKeyController, useWhichKeyController, useWhichKey, useKeymap, useKeymapScope, useOptionalPaneRegistration, type ReactiveWhichKeyContext, type UseWhichKeyReturn, type UsePaneRegistrationOptions, type UsePaneRegistrationResult, } from './context.svelte';
|
|
7
|
+
export type { JumpAction, JumpTarget, KeybindingPreset, KeymapCommandContext, KeymapExplorerEntry, KeymapHandler, KeymapMode, ModalEditorTarget, PaneProps, PaneRegistration, WhichKeyController, WhichKeyControllerOptions, WhichKeyExplorerProps, WhichKeyModeProps, WhichKeyNode, WhichKeyProps, WhichKeyState, WhichKeyVariant, } from '@cloudvoyant/helical-ui';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// libs/helical-svelte/src/which-key/index.ts
|
|
2
|
+
export { default as WhichKey } from './WhichKey.svelte';
|
|
3
|
+
export { default as WhichKeyMode } from './WhichKeyMode.svelte';
|
|
4
|
+
export { default as WhichKeyExplorer } from './WhichKeyExplorer.svelte';
|
|
5
|
+
export { default as WhichKeyProvider } from './WhichKeyProvider.svelte';
|
|
6
|
+
export { default as Pane } from './Pane.svelte';
|
|
7
|
+
export { WHICH_KEY_CONTEXT_KEY, setWhichKeyContext, getOptionalWhichKeyContext, useOptionalWhichKeyController, useWhichKeyController, useWhichKey, useKeymap, useKeymapScope, useOptionalPaneRegistration, } from './context.svelte';
|
|
@@ -9,15 +9,41 @@
|
|
|
9
9
|
FloatingPanelContent,
|
|
10
10
|
type FloatingPanelRootProps,
|
|
11
11
|
} from '@ark-ui/svelte/floating-panel';
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
windowPositionerBase,
|
|
14
|
+
windowContentBase,
|
|
15
|
+
cn,
|
|
16
|
+
type WindowPaneRegistrationProps,
|
|
17
|
+
} from '@cloudvoyant/helical-ui';
|
|
18
|
+
import { useOptionalPaneRegistration } from '../which-key/context.svelte';
|
|
13
19
|
|
|
14
|
-
interface Props extends FloatingPanelRootProps {
|
|
20
|
+
interface Props extends FloatingPanelRootProps, WindowPaneRegistrationProps {
|
|
15
21
|
class?: string;
|
|
16
22
|
positionerClass?: string;
|
|
17
23
|
children?: Snippet;
|
|
18
24
|
}
|
|
19
25
|
|
|
20
|
-
let {
|
|
26
|
+
let {
|
|
27
|
+
class: className = '',
|
|
28
|
+
positionerClass = '',
|
|
29
|
+
paneId,
|
|
30
|
+
paneTitle,
|
|
31
|
+
paneDisabled,
|
|
32
|
+
children,
|
|
33
|
+
...rest
|
|
34
|
+
}: Props = $props();
|
|
35
|
+
|
|
36
|
+
let contentRef: Element | null = $state(null);
|
|
37
|
+
|
|
38
|
+
const pane = useOptionalPaneRegistration(
|
|
39
|
+
() => (contentRef instanceof HTMLElement ? contentRef : null),
|
|
40
|
+
() => ({
|
|
41
|
+
paneId,
|
|
42
|
+
paneTitle,
|
|
43
|
+
paneDisabled: paneDisabled || rest.open === false,
|
|
44
|
+
defaultTitle: 'Window',
|
|
45
|
+
}),
|
|
46
|
+
);
|
|
21
47
|
|
|
22
48
|
const positionerClasses = $derived(cn(windowPositionerBase, positionerClass));
|
|
23
49
|
const contentClasses = $derived(cn(windowContentBase, className));
|
|
@@ -26,7 +52,7 @@
|
|
|
26
52
|
<FloatingPanelRoot {...rest}>
|
|
27
53
|
<Portal>
|
|
28
54
|
<FloatingPanelPositioner class={positionerClasses}>
|
|
29
|
-
<FloatingPanelContent class={contentClasses}>
|
|
55
|
+
<FloatingPanelContent bind:ref={contentRef} {...pane.dataAttributes} class={contentClasses}>
|
|
30
56
|
{@render children?.()}
|
|
31
57
|
</FloatingPanelContent>
|
|
32
58
|
</FloatingPanelPositioner>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import { type FloatingPanelRootProps } from '@ark-ui/svelte/floating-panel';
|
|
3
|
-
|
|
3
|
+
import { type WindowPaneRegistrationProps } from '@cloudvoyant/helical-ui';
|
|
4
|
+
interface Props extends FloatingPanelRootProps, WindowPaneRegistrationProps {
|
|
4
5
|
class?: string;
|
|
5
6
|
positionerClass?: string;
|
|
6
7
|
children?: Snippet;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudvoyant/helical-svelte",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.1",
|
|
4
4
|
"description": "helical-ui Svelte UI components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -39,12 +39,15 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@ark-ui/svelte": "^5.23.1",
|
|
41
41
|
"@tanstack/charts": "^0.16.0",
|
|
42
|
+
"@tanstack/svelte-hotkeys": "^0.20.0",
|
|
42
43
|
"@tiptap/core": "^3.31.3",
|
|
43
44
|
"@tiptap/suggestion": "^3.31.3",
|
|
45
|
+
"@zag-js/dismissable": "1.43.1",
|
|
46
|
+
"@zag-js/dom-query": "1.43.1",
|
|
44
47
|
"lucide-svelte": "^0.577.0",
|
|
45
48
|
"lowlight": "^3.3.0",
|
|
46
49
|
"svelte-tiptap": "^3.0.1",
|
|
47
|
-
"@cloudvoyant/helical-ui": "0.
|
|
50
|
+
"@cloudvoyant/helical-ui": "0.21.1"
|
|
48
51
|
},
|
|
49
52
|
"devDependencies": {
|
|
50
53
|
"@sveltejs/package": "^2.5.8",
|