@notis_ai/cli 0.2.5 → 0.2.7
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 +33 -9
- package/dist/scaffolds/notis-affiliate-prospects/CHANGELOG.md +7 -0
- package/dist/scaffolds/notis-affiliate-prospects/README.md +20 -0
- package/dist/scaffolds/notis-affiliate-prospects/app/globals.css +42 -0
- package/dist/scaffolds/notis-affiliate-prospects/app/layout.tsx +7 -0
- package/dist/scaffolds/notis-affiliate-prospects/app/page.tsx +248 -0
- package/dist/scaffolds/notis-affiliate-prospects/app/prospects/page.tsx +134 -0
- package/dist/scaffolds/notis-affiliate-prospects/app/segments/page.tsx +108 -0
- package/dist/scaffolds/notis-affiliate-prospects/components/ui/card.tsx +35 -0
- package/dist/scaffolds/notis-affiliate-prospects/components.json +20 -0
- package/dist/scaffolds/notis-affiliate-prospects/index.html +12 -0
- package/dist/scaffolds/notis-affiliate-prospects/lib/affiliate-data.ts +218 -0
- package/dist/scaffolds/notis-affiliate-prospects/lib/demo-prospects.ts +52 -0
- package/dist/scaffolds/notis-affiliate-prospects/lib/notis-tools.ts +100 -0
- package/dist/scaffolds/notis-affiliate-prospects/lib/utils.ts +25 -0
- package/dist/scaffolds/notis-affiliate-prospects/metadata/screenshot-1.png +0 -0
- package/dist/scaffolds/notis-affiliate-prospects/metadata/screenshot-2.png +0 -0
- package/dist/scaffolds/notis-affiliate-prospects/metadata/screenshot-3.png +0 -0
- package/dist/scaffolds/notis-affiliate-prospects/metadata/screenshot-fixtures.json +187 -0
- package/dist/scaffolds/notis-affiliate-prospects/notis.config.ts +65 -0
- package/dist/scaffolds/notis-affiliate-prospects/package.json +32 -0
- package/dist/scaffolds/notis-affiliate-prospects/packages/sdk/package.json +32 -0
- package/dist/scaffolds/notis-affiliate-prospects/packages/sdk/src/components/MultiSelectActionBar.tsx +273 -0
- package/dist/scaffolds/notis-affiliate-prospects/packages/sdk/src/components/MultiSelectCheckbox.tsx +91 -0
- package/dist/scaffolds/notis-affiliate-prospects/packages/sdk/src/components/MultiSelectDragOverlay.tsx +39 -0
- package/dist/scaffolds/notis-affiliate-prospects/packages/sdk/src/config.ts +90 -0
- package/dist/scaffolds/notis-affiliate-prospects/packages/sdk/src/hooks/useBackend.ts +41 -0
- package/dist/scaffolds/notis-affiliate-prospects/packages/sdk/src/hooks/useMultiSelect.ts +503 -0
- package/dist/scaffolds/notis-affiliate-prospects/packages/sdk/src/hooks/useNotis.ts +34 -0
- package/dist/scaffolds/notis-affiliate-prospects/packages/sdk/src/hooks/useNotisNavigation.ts +49 -0
- package/dist/scaffolds/notis-affiliate-prospects/packages/sdk/src/hooks/useTool.ts +64 -0
- package/dist/scaffolds/notis-affiliate-prospects/packages/sdk/src/hooks/useTools.ts +56 -0
- package/dist/scaffolds/notis-affiliate-prospects/packages/sdk/src/hooks/useTopBarSearch.ts +73 -0
- package/dist/scaffolds/notis-affiliate-prospects/packages/sdk/src/hooks/useUpsertDocument.ts +50 -0
- package/dist/scaffolds/notis-affiliate-prospects/packages/sdk/src/index.ts +54 -0
- package/dist/scaffolds/notis-affiliate-prospects/packages/sdk/src/provider.tsx +43 -0
- package/dist/scaffolds/notis-affiliate-prospects/packages/sdk/src/runtime.ts +161 -0
- package/dist/scaffolds/notis-affiliate-prospects/packages/sdk/src/styles.css +38 -0
- package/dist/scaffolds/notis-affiliate-prospects/packages/sdk/src/ui.ts +15 -0
- package/dist/scaffolds/notis-affiliate-prospects/packages/sdk/src/vite.ts +56 -0
- package/dist/scaffolds/notis-affiliate-prospects/packages/sdk/tsconfig.json +15 -0
- package/dist/scaffolds/notis-affiliate-prospects/postcss.config.mjs +6 -0
- package/dist/scaffolds/notis-affiliate-prospects/src/dev-main.tsx +72 -0
- package/dist/scaffolds/notis-affiliate-prospects/src/mock-runtime.ts +242 -0
- package/dist/scaffolds/notis-affiliate-prospects/tailwind.config.ts +51 -0
- package/dist/scaffolds/notis-affiliate-prospects/tsconfig.json +23 -0
- package/dist/scaffolds/notis-affiliate-prospects/vite.config.ts +11 -0
- package/dist/scaffolds/notis-database/CHANGELOG.md +5 -0
- package/dist/scaffolds/notis-database/notis.config.ts +0 -1
- package/dist/scaffolds/notis-database/src/mock-runtime.ts +1 -0
- package/dist/scaffolds/notis-journal/CHANGELOG.md +25 -0
- package/dist/scaffolds/notis-journal/app/globals.css +37 -0
- package/dist/scaffolds/notis-journal/app/insights/page.tsx +513 -0
- package/dist/scaffolds/notis-journal/app/journal-core.tsx +362 -0
- package/dist/scaffolds/notis-journal/app/journal-ui.tsx +337 -0
- package/dist/scaffolds/notis-journal/app/layout.tsx +6 -0
- package/dist/scaffolds/notis-journal/app/page.tsx +485 -0
- package/dist/scaffolds/notis-journal/components/ui/badge.tsx +28 -0
- package/dist/scaffolds/notis-journal/components/ui/button.tsx +53 -0
- package/dist/scaffolds/notis-journal/components/ui/card.tsx +56 -0
- package/dist/scaffolds/notis-journal/components.json +20 -0
- package/dist/scaffolds/notis-journal/index.html +12 -0
- package/dist/scaffolds/notis-journal/lib/utils.ts +6 -0
- package/dist/scaffolds/notis-journal/metadata/screenshot-1.png +0 -0
- package/dist/scaffolds/notis-journal/metadata/screenshot-2.png +0 -0
- package/dist/scaffolds/notis-journal/metadata/screenshot-3.png +0 -0
- package/dist/scaffolds/notis-journal/metadata/screenshot-4.png +0 -0
- package/dist/scaffolds/notis-journal/metadata/screenshot-5.png +0 -0
- package/dist/scaffolds/notis-journal/metadata/screenshot-6.png +0 -0
- package/dist/scaffolds/notis-journal/metadata/screenshot-fixtures.json +132 -0
- package/dist/scaffolds/notis-journal/notis.config.ts +93 -0
- package/dist/scaffolds/notis-journal/package.json +34 -0
- package/dist/scaffolds/notis-journal/packages/sdk/package.json +36 -0
- package/dist/scaffolds/notis-journal/packages/sdk/src/components/DocumentEditor.tsx +93 -0
- package/dist/scaffolds/notis-journal/packages/sdk/src/components/Markdown.tsx +60 -0
- package/dist/scaffolds/notis-journal/packages/sdk/src/components/MultiSelectActionBar.tsx +278 -0
- package/dist/scaffolds/notis-journal/packages/sdk/src/components/MultiSelectCheckbox.tsx +91 -0
- package/dist/scaffolds/notis-journal/packages/sdk/src/components/MultiSelectDragOverlay.tsx +39 -0
- package/dist/scaffolds/notis-journal/packages/sdk/src/config.ts +145 -0
- package/dist/scaffolds/notis-journal/packages/sdk/src/documents.ts +229 -0
- package/dist/scaffolds/notis-journal/packages/sdk/src/hooks/useBackend.ts +41 -0
- package/dist/scaffolds/notis-journal/packages/sdk/src/hooks/useDatabaseSchema.ts +85 -0
- package/dist/scaffolds/notis-journal/packages/sdk/src/hooks/useDocument.ts +78 -0
- package/dist/scaffolds/notis-journal/packages/sdk/src/hooks/useDocuments.ts +121 -0
- package/dist/scaffolds/notis-journal/packages/sdk/src/hooks/useMultiSelect.ts +539 -0
- package/dist/scaffolds/notis-journal/packages/sdk/src/hooks/useNotis.ts +34 -0
- package/dist/scaffolds/notis-journal/packages/sdk/src/hooks/useNotisNavigation.ts +49 -0
- package/dist/scaffolds/notis-journal/packages/sdk/src/hooks/useTool.ts +64 -0
- package/dist/scaffolds/notis-journal/packages/sdk/src/hooks/useTools.ts +56 -0
- package/dist/scaffolds/notis-journal/packages/sdk/src/hooks/useTopBarSearch.ts +73 -0
- package/dist/scaffolds/notis-journal/packages/sdk/src/hooks/useUpsertDocument.ts +95 -0
- package/dist/scaffolds/notis-journal/packages/sdk/src/index.ts +83 -0
- package/dist/scaffolds/notis-journal/packages/sdk/src/provider.tsx +43 -0
- package/dist/scaffolds/notis-journal/packages/sdk/src/runtime.ts +220 -0
- package/dist/scaffolds/notis-journal/packages/sdk/src/styles.css +186 -0
- package/dist/scaffolds/notis-journal/packages/sdk/src/ui.ts +15 -0
- package/dist/scaffolds/notis-journal/packages/sdk/src/vite.ts +56 -0
- package/dist/scaffolds/notis-journal/packages/sdk/tsconfig.json +15 -0
- package/dist/scaffolds/notis-journal/postcss.config.mjs +8 -0
- package/dist/scaffolds/notis-journal/skills/journal-onboarding/SKILL.md +120 -0
- package/dist/scaffolds/notis-journal/src/dev-main.tsx +58 -0
- package/dist/scaffolds/notis-journal/src/mock-runtime.ts +197 -0
- package/dist/scaffolds/notis-journal/tailwind.config.ts +58 -0
- package/dist/scaffolds/notis-journal/tsconfig.json +23 -0
- package/dist/scaffolds/notis-journal/vite.config.ts +10 -0
- package/dist/scaffolds/notis-notes/CHANGELOG.md +5 -0
- package/dist/scaffolds/notis-notes/app/page.tsx +17 -373
- package/dist/scaffolds/notis-notes/notis.config.ts +0 -1
- package/dist/scaffolds/notis-random/CHANGELOG.md +5 -0
- package/dist/scaffolds/notis-random/notis.config.ts +0 -1
- package/dist/scaffolds/notis-random/src/mock-runtime.ts +1 -0
- package/dist/scaffolds.json +22 -0
- package/package.json +3 -3
- package/skills/notis-apps/SKILL.md +43 -5
- package/skills/notis-apps/cli.md +22 -6
- package/skills/notis-cli/SKILL.md +20 -2
- package/skills/notis-query/cli.md +1 -1
- package/src/cli.js +8 -1
- package/src/command-specs/apps.js +307 -36
- package/src/command-specs/diagnostics.js +674 -0
- package/src/command-specs/helpers.js +4 -1
- package/src/command-specs/index.js +7 -1
- package/src/command-specs/meta.js +8 -2
- package/src/command-specs/smoke.js +386 -0
- package/src/command-specs/tools.js +237 -44
- package/src/runtime/agent-browser.js +204 -21
- package/src/runtime/app-changelog.js +79 -0
- package/src/runtime/app-dev-server.js +21 -4
- package/src/runtime/app-dev-sessions.js +99 -1
- package/src/runtime/app-platform.js +197 -18
- package/src/runtime/assets/store-screenshot-dark.png +0 -0
- package/src/runtime/desktop-auth.js +93 -0
- package/src/runtime/output.js +12 -1
- package/src/runtime/profiles.js +72 -16
- package/src/runtime/store-screenshot.js +138 -0
- package/src/runtime/transport.js +24 -82
- package/template/.harness/index.html.tmpl +128 -6
- package/template/CHANGELOG.md +5 -0
- package/template/app/page.tsx +11 -41
- package/template/notis.config.ts +0 -1
- package/template/package-lock.json +4137 -0
- package/template/package.json +1 -0
- package/template/packages/sdk/package.json +4 -0
- package/template/packages/sdk/src/components/DocumentEditor.tsx +93 -0
- package/template/packages/sdk/src/components/Markdown.tsx +60 -0
- package/template/packages/sdk/src/components/MultiSelectActionBar.tsx +7 -2
- package/template/packages/sdk/src/config.ts +74 -0
- package/template/packages/sdk/src/documents.ts +229 -0
- package/template/packages/sdk/src/hooks/useDatabaseSchema.ts +85 -0
- package/template/packages/sdk/src/hooks/useDocument.ts +78 -0
- package/template/packages/sdk/src/hooks/useDocuments.ts +121 -0
- package/template/packages/sdk/src/hooks/useMultiSelect.ts +38 -2
- package/template/packages/sdk/src/hooks/useUpsertDocument.ts +54 -9
- package/template/packages/sdk/src/index.ts +30 -1
- package/template/packages/sdk/src/runtime.ts +76 -17
- package/template/packages/sdk/src/styles.css +148 -0
- /package/{template → dist/scaffolds/notis-affiliate-prospects}/packages/sdk/src/hooks/useDatabase.ts +0 -0
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
useEffect,
|
|
5
|
+
useMemo,
|
|
6
|
+
useRef,
|
|
7
|
+
useState,
|
|
8
|
+
type CSSProperties,
|
|
9
|
+
type ReactElement,
|
|
10
|
+
type ReactNode,
|
|
11
|
+
} from 'react';
|
|
12
|
+
|
|
13
|
+
export interface MultiSelectAction {
|
|
14
|
+
id: string;
|
|
15
|
+
label: string;
|
|
16
|
+
icon: ReactNode;
|
|
17
|
+
/** Single-key (e.g. "E", "#") or "Mod+K" shortcut. Bound while the bar is mounted with count > 0. */
|
|
18
|
+
shortcut?: string;
|
|
19
|
+
onRun: () => void | Promise<void>;
|
|
20
|
+
/** Hint for future destructive styling. Currently unused visually. */
|
|
21
|
+
destructive?: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface MultiSelectActionBarProps {
|
|
25
|
+
selectedCount: number;
|
|
26
|
+
actions: MultiSelectAction[];
|
|
27
|
+
/** Override the "{count} selected" label units. Default: "selected" with no item word. */
|
|
28
|
+
itemLabel?: { singular: string; plural: string };
|
|
29
|
+
/** Optional extra class on the outer container (composed alongside the inline styles). */
|
|
30
|
+
className?: string;
|
|
31
|
+
/** Optional override for the bar's positioning style. Defaults to bottom-center floating. */
|
|
32
|
+
style?: CSSProperties;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface ParsedShortcut {
|
|
36
|
+
key: string;
|
|
37
|
+
needsMod: boolean;
|
|
38
|
+
needsShift: boolean;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function parseShortcut(raw: string): ParsedShortcut | null {
|
|
42
|
+
const parts = raw.split('+').map((p) => p.trim()).filter(Boolean);
|
|
43
|
+
if (parts.length === 0) return null;
|
|
44
|
+
let needsMod = false;
|
|
45
|
+
let needsShift = false;
|
|
46
|
+
let key = '';
|
|
47
|
+
for (const part of parts) {
|
|
48
|
+
const lower = part.toLowerCase();
|
|
49
|
+
if (lower === 'mod' || lower === 'cmd' || lower === 'ctrl' || lower === 'meta') {
|
|
50
|
+
needsMod = true;
|
|
51
|
+
} else if (lower === 'shift') {
|
|
52
|
+
needsShift = true;
|
|
53
|
+
} else {
|
|
54
|
+
key = lower;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (!key) return null;
|
|
58
|
+
return { key, needsMod, needsShift };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function shortcutMatches(shortcut: ParsedShortcut, event: KeyboardEvent): boolean {
|
|
62
|
+
const eventKey = event.key.toLowerCase();
|
|
63
|
+
// Special-case "#" so Shift+3 matches without the consumer specifying Shift.
|
|
64
|
+
if (shortcut.key === '#') {
|
|
65
|
+
if (eventKey === '#') return true;
|
|
66
|
+
if (event.shiftKey && eventKey === '3') return true;
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
if (eventKey !== shortcut.key) return false;
|
|
70
|
+
if (shortcut.needsMod !== Boolean(event.metaKey || event.ctrlKey)) return false;
|
|
71
|
+
if (shortcut.needsShift !== event.shiftKey) return false;
|
|
72
|
+
if (event.altKey) return false;
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function isEditableEvent(event: Event): boolean {
|
|
77
|
+
// Notis apps mount inside a Shadow DOM, so a document-level listener sees
|
|
78
|
+
// `event.target` retargeted to the shadow host. `composedPath()[0]` pierces
|
|
79
|
+
// the shadow boundary to the real focused element, so action-bar shortcuts
|
|
80
|
+
// don't fire while the user is typing in an app input.
|
|
81
|
+
const target = event.composedPath?.()[0] ?? event.target;
|
|
82
|
+
if (!(target instanceof HTMLElement)) return false;
|
|
83
|
+
if (target.isContentEditable) return true;
|
|
84
|
+
const tag = target.tagName;
|
|
85
|
+
return tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT';
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function shortcutDisplay(raw: string): string {
|
|
89
|
+
const parts = raw.split('+').map((p) => p.trim()).filter(Boolean);
|
|
90
|
+
return parts
|
|
91
|
+
.map((part) => {
|
|
92
|
+
const lower = part.toLowerCase();
|
|
93
|
+
if (lower === 'mod' || lower === 'cmd' || lower === 'meta') return '⌘';
|
|
94
|
+
if (lower === 'ctrl') return '⌃';
|
|
95
|
+
if (lower === 'shift') return '⇧';
|
|
96
|
+
if (lower === 'alt' || lower === 'option') return '⌥';
|
|
97
|
+
return part.length === 1 ? part.toUpperCase() : part;
|
|
98
|
+
})
|
|
99
|
+
.join('');
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const containerBaseStyle: CSSProperties = {
|
|
103
|
+
position: 'fixed',
|
|
104
|
+
bottom: '1rem',
|
|
105
|
+
left: '50%',
|
|
106
|
+
transform: 'translateX(-50%)',
|
|
107
|
+
zIndex: 60,
|
|
108
|
+
display: 'flex',
|
|
109
|
+
alignItems: 'center',
|
|
110
|
+
gap: '0.25rem',
|
|
111
|
+
padding: '0.375rem 0.5rem',
|
|
112
|
+
borderRadius: '0.5rem',
|
|
113
|
+
background: 'color-mix(in srgb, hsl(var(--foreground)) 95%, transparent)',
|
|
114
|
+
color: 'hsl(var(--background))',
|
|
115
|
+
boxShadow: '0 10px 25px -10px rgba(0,0,0,0.35), 0 0 0 1px rgba(0,0,0,0.08)',
|
|
116
|
+
backdropFilter: 'blur(6px)',
|
|
117
|
+
WebkitBackdropFilter: 'blur(6px)',
|
|
118
|
+
pointerEvents: 'auto',
|
|
119
|
+
fontSize: '13px',
|
|
120
|
+
lineHeight: 1.2,
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const countStyle: CSSProperties = {
|
|
124
|
+
padding: '0 0.5rem',
|
|
125
|
+
fontSize: '12px',
|
|
126
|
+
fontWeight: 500,
|
|
127
|
+
fontVariantNumeric: 'tabular-nums',
|
|
128
|
+
color: 'color-mix(in srgb, hsl(var(--background)) 70%, transparent)',
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const dividerStyle: CSSProperties = {
|
|
132
|
+
width: '1px',
|
|
133
|
+
height: '1rem',
|
|
134
|
+
margin: '0 0.125rem',
|
|
135
|
+
background: 'color-mix(in srgb, hsl(var(--background)) 20%, transparent)',
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const baseButtonStyle: CSSProperties = {
|
|
139
|
+
display: 'inline-flex',
|
|
140
|
+
alignItems: 'center',
|
|
141
|
+
gap: '0.375rem',
|
|
142
|
+
padding: '0.25rem 0.5rem',
|
|
143
|
+
border: 0,
|
|
144
|
+
background: 'transparent',
|
|
145
|
+
color: 'color-mix(in srgb, hsl(var(--background)) 90%, transparent)',
|
|
146
|
+
borderRadius: '0.375rem',
|
|
147
|
+
cursor: 'pointer',
|
|
148
|
+
fontSize: '13px',
|
|
149
|
+
fontFamily: 'inherit',
|
|
150
|
+
transition: 'background-color 120ms ease, color 120ms ease',
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
const keycapStyle: CSSProperties = {
|
|
154
|
+
display: 'inline-flex',
|
|
155
|
+
alignItems: 'center',
|
|
156
|
+
justifyContent: 'center',
|
|
157
|
+
minWidth: '20px',
|
|
158
|
+
height: '20px',
|
|
159
|
+
padding: '0 4px',
|
|
160
|
+
borderRadius: '4px',
|
|
161
|
+
border: '1px solid color-mix(in srgb, hsl(var(--background)) 20%, transparent)',
|
|
162
|
+
background: 'color-mix(in srgb, hsl(var(--background)) 15%, transparent)',
|
|
163
|
+
color: 'inherit',
|
|
164
|
+
fontSize: '11px',
|
|
165
|
+
fontWeight: 500,
|
|
166
|
+
lineHeight: 1,
|
|
167
|
+
fontFamily: 'inherit',
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
const iconSlotStyle: CSSProperties = {
|
|
171
|
+
display: 'inline-flex',
|
|
172
|
+
alignItems: 'center',
|
|
173
|
+
justifyContent: 'center',
|
|
174
|
+
opacity: 0.8,
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
export function MultiSelectActionBar({
|
|
178
|
+
selectedCount,
|
|
179
|
+
actions,
|
|
180
|
+
itemLabel,
|
|
181
|
+
className,
|
|
182
|
+
style,
|
|
183
|
+
}: MultiSelectActionBarProps): ReactElement | null {
|
|
184
|
+
const actionsRef = useRef(actions);
|
|
185
|
+
actionsRef.current = actions;
|
|
186
|
+
|
|
187
|
+
const parsedShortcuts = useMemo(() => {
|
|
188
|
+
return actions
|
|
189
|
+
.map((action) => {
|
|
190
|
+
if (!action.shortcut) return null;
|
|
191
|
+
const parsed = parseShortcut(action.shortcut);
|
|
192
|
+
return parsed ? { action, parsed } : null;
|
|
193
|
+
})
|
|
194
|
+
.filter((entry): entry is { action: MultiSelectAction; parsed: ParsedShortcut } => entry !== null);
|
|
195
|
+
}, [actions]);
|
|
196
|
+
|
|
197
|
+
useEffect(() => {
|
|
198
|
+
if (selectedCount === 0 || parsedShortcuts.length === 0) return;
|
|
199
|
+
|
|
200
|
+
const handleKeyDown = (event: KeyboardEvent) => {
|
|
201
|
+
if (isEditableEvent(event)) return;
|
|
202
|
+
for (const { action, parsed } of parsedShortcuts) {
|
|
203
|
+
if (shortcutMatches(parsed, event)) {
|
|
204
|
+
event.preventDefault();
|
|
205
|
+
event.stopPropagation();
|
|
206
|
+
if (typeof event.stopImmediatePropagation === 'function') {
|
|
207
|
+
event.stopImmediatePropagation();
|
|
208
|
+
}
|
|
209
|
+
void action.onRun();
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
document.addEventListener('keydown', handleKeyDown, true);
|
|
216
|
+
return () => {
|
|
217
|
+
document.removeEventListener('keydown', handleKeyDown, true);
|
|
218
|
+
};
|
|
219
|
+
}, [parsedShortcuts, selectedCount]);
|
|
220
|
+
|
|
221
|
+
if (selectedCount === 0) return null;
|
|
222
|
+
|
|
223
|
+
const countWord = itemLabel
|
|
224
|
+
? selectedCount === 1
|
|
225
|
+
? itemLabel.singular
|
|
226
|
+
: itemLabel.plural
|
|
227
|
+
: 'selected';
|
|
228
|
+
const countLabel = itemLabel
|
|
229
|
+
? `${selectedCount} ${countWord} selected`
|
|
230
|
+
: `${selectedCount} selected`;
|
|
231
|
+
|
|
232
|
+
const composedStyle: CSSProperties = { ...containerBaseStyle, ...(style || {}) };
|
|
233
|
+
|
|
234
|
+
return (
|
|
235
|
+
<div
|
|
236
|
+
role="toolbar"
|
|
237
|
+
aria-label={`Bulk actions for ${selectedCount} selected ${countWord}`}
|
|
238
|
+
className={className}
|
|
239
|
+
style={composedStyle}
|
|
240
|
+
>
|
|
241
|
+
<span style={countStyle}>{countLabel}</span>
|
|
242
|
+
{actions.length > 0 ? <span aria-hidden style={dividerStyle} /> : null}
|
|
243
|
+
{actions.map((action) => (
|
|
244
|
+
<ActionButton key={action.id} action={action} />
|
|
245
|
+
))}
|
|
246
|
+
</div>
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function ActionButton({ action }: { action: MultiSelectAction }) {
|
|
251
|
+
const [hover, setHover] = useState(false);
|
|
252
|
+
const display = action.shortcut ? shortcutDisplay(action.shortcut) : null;
|
|
253
|
+
const buttonStyle: CSSProperties = {
|
|
254
|
+
...baseButtonStyle,
|
|
255
|
+
background: hover
|
|
256
|
+
? 'color-mix(in srgb, hsl(var(--background)) 12%, transparent)'
|
|
257
|
+
: 'transparent',
|
|
258
|
+
color: hover
|
|
259
|
+
? 'hsl(var(--background))'
|
|
260
|
+
: baseButtonStyle.color,
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
return (
|
|
264
|
+
<button
|
|
265
|
+
type="button"
|
|
266
|
+
onClick={() => void action.onRun()}
|
|
267
|
+
onMouseEnter={() => setHover(true)}
|
|
268
|
+
onMouseLeave={() => setHover(false)}
|
|
269
|
+
onFocus={() => setHover(true)}
|
|
270
|
+
onBlur={() => setHover(false)}
|
|
271
|
+
style={buttonStyle}
|
|
272
|
+
>
|
|
273
|
+
<span aria-hidden style={iconSlotStyle}>{action.icon}</span>
|
|
274
|
+
{display ? <kbd aria-hidden style={keycapStyle}>{display}</kbd> : null}
|
|
275
|
+
<span>{action.label}</span>
|
|
276
|
+
</button>
|
|
277
|
+
);
|
|
278
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { type CSSProperties, type MouseEvent as ReactMouseEvent, type ReactElement } from 'react';
|
|
4
|
+
|
|
5
|
+
export interface MultiSelectCheckboxProps {
|
|
6
|
+
isSelected: boolean;
|
|
7
|
+
onClick: (event: ReactMouseEvent) => void;
|
|
8
|
+
/** When true, the checkbox is always visible. Default false (hover/focus reveal via the parent's :hover state). */
|
|
9
|
+
alwaysVisible?: boolean;
|
|
10
|
+
/** Optional aria-label override. Defaults to "Select item" / "Deselect item". */
|
|
11
|
+
ariaLabel?: string;
|
|
12
|
+
className?: string;
|
|
13
|
+
/** Optional inline-style override merged with the defaults. */
|
|
14
|
+
style?: CSSProperties;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const baseStyle: CSSProperties = {
|
|
18
|
+
flexShrink: 0,
|
|
19
|
+
display: 'inline-flex',
|
|
20
|
+
alignItems: 'center',
|
|
21
|
+
justifyContent: 'center',
|
|
22
|
+
width: '16px',
|
|
23
|
+
height: '16px',
|
|
24
|
+
borderRadius: '4px',
|
|
25
|
+
border: '1px solid hsl(var(--border))',
|
|
26
|
+
background: 'transparent',
|
|
27
|
+
color: 'hsl(var(--primary-foreground))',
|
|
28
|
+
cursor: 'pointer',
|
|
29
|
+
padding: 0,
|
|
30
|
+
transition: 'background-color 120ms ease, border-color 120ms ease, opacity 150ms ease',
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const selectedStyle: CSSProperties = {
|
|
34
|
+
background: 'hsl(var(--primary))',
|
|
35
|
+
borderColor: 'hsl(var(--primary))',
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const checkPath = 'M3.5 7.5l2.5 2.5 6.5-6.5';
|
|
39
|
+
|
|
40
|
+
export function MultiSelectCheckbox({
|
|
41
|
+
isSelected,
|
|
42
|
+
onClick,
|
|
43
|
+
alwaysVisible = false,
|
|
44
|
+
ariaLabel,
|
|
45
|
+
className,
|
|
46
|
+
style,
|
|
47
|
+
}: MultiSelectCheckboxProps): ReactElement {
|
|
48
|
+
const merged: CSSProperties = {
|
|
49
|
+
...baseStyle,
|
|
50
|
+
...(isSelected ? selectedStyle : null),
|
|
51
|
+
...(alwaysVisible || isSelected ? { opacity: 1 } : null),
|
|
52
|
+
...(style || null),
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// When alwaysVisible is false and the row isn't selected, defer the
|
|
56
|
+
// hover-reveal to the parent — consumers wrap the checkbox in a `.group`
|
|
57
|
+
// hover scope and pass `data-notis-hover-reveal` styles via className.
|
|
58
|
+
// Out of the box, we render the checkbox at full opacity if selected,
|
|
59
|
+
// otherwise inherit the parent's reveal state.
|
|
60
|
+
return (
|
|
61
|
+
<button
|
|
62
|
+
type="button"
|
|
63
|
+
role="checkbox"
|
|
64
|
+
aria-checked={isSelected}
|
|
65
|
+
aria-label={ariaLabel ?? (isSelected ? 'Deselect item' : 'Select item')}
|
|
66
|
+
onClick={onClick}
|
|
67
|
+
onMouseDown={(e) => e.stopPropagation()}
|
|
68
|
+
data-notis-multiselect-checkbox=""
|
|
69
|
+
data-selected={isSelected ? 'true' : 'false'}
|
|
70
|
+
className={className}
|
|
71
|
+
style={merged}
|
|
72
|
+
>
|
|
73
|
+
{isSelected ? (
|
|
74
|
+
<svg
|
|
75
|
+
width="10"
|
|
76
|
+
height="10"
|
|
77
|
+
viewBox="0 0 16 16"
|
|
78
|
+
fill="none"
|
|
79
|
+
stroke="currentColor"
|
|
80
|
+
strokeWidth={3}
|
|
81
|
+
strokeLinecap="round"
|
|
82
|
+
strokeLinejoin="round"
|
|
83
|
+
aria-hidden
|
|
84
|
+
focusable="false"
|
|
85
|
+
>
|
|
86
|
+
<path d={checkPath} />
|
|
87
|
+
</svg>
|
|
88
|
+
) : null}
|
|
89
|
+
</button>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { type CSSProperties, type ReactElement } from 'react';
|
|
4
|
+
import type { DragRect } from '../hooks/useMultiSelect';
|
|
5
|
+
|
|
6
|
+
export interface MultiSelectDragOverlayProps {
|
|
7
|
+
rect: DragRect | null;
|
|
8
|
+
className?: string;
|
|
9
|
+
style?: CSSProperties;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const overlayBaseStyle: CSSProperties = {
|
|
13
|
+
position: 'fixed',
|
|
14
|
+
borderRadius: '3px',
|
|
15
|
+
border: '1px solid rgba(35, 131, 226, 0.3)',
|
|
16
|
+
background: 'rgba(35, 131, 226, 0.08)',
|
|
17
|
+
pointerEvents: 'none',
|
|
18
|
+
zIndex: 50,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export function MultiSelectDragOverlay({
|
|
22
|
+
rect,
|
|
23
|
+
className,
|
|
24
|
+
style,
|
|
25
|
+
}: MultiSelectDragOverlayProps): ReactElement | null {
|
|
26
|
+
if (!rect) return null;
|
|
27
|
+
if (rect.width === 0 && rect.height === 0) return null;
|
|
28
|
+
|
|
29
|
+
const merged: CSSProperties = {
|
|
30
|
+
...overlayBaseStyle,
|
|
31
|
+
left: rect.left,
|
|
32
|
+
top: rect.top,
|
|
33
|
+
width: rect.width,
|
|
34
|
+
height: rect.height,
|
|
35
|
+
...(style || null),
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
return <div aria-hidden className={className} style={merged} />;
|
|
39
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration utilities for notis.config.ts.
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* ```ts
|
|
6
|
+
* // notis.config.ts
|
|
7
|
+
* import { defineNotisApp } from '@notis/sdk/config';
|
|
8
|
+
*
|
|
9
|
+
* export default defineNotisApp({
|
|
10
|
+
* name: 'My App',
|
|
11
|
+
* description: 'Does things',
|
|
12
|
+
* icon: 'phosphor:squares-four',
|
|
13
|
+
* databases: ['tasks'],
|
|
14
|
+
* routes: [
|
|
15
|
+
* {
|
|
16
|
+
* path: '/',
|
|
17
|
+
* slug: 'notes',
|
|
18
|
+
* name: 'Notes',
|
|
19
|
+
* default: true,
|
|
20
|
+
* collection: {
|
|
21
|
+
* database: 'notes',
|
|
22
|
+
* titleProperty: 'Name',
|
|
23
|
+
* parentProperty: 'Parent',
|
|
24
|
+
* sidebar: {
|
|
25
|
+
* mode: 'tree',
|
|
26
|
+
* allowCreate: true,
|
|
27
|
+
* },
|
|
28
|
+
* },
|
|
29
|
+
* },
|
|
30
|
+
* ],
|
|
31
|
+
* tools: [...],
|
|
32
|
+
* });
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
export interface NotisRouteConfig {
|
|
37
|
+
path: string;
|
|
38
|
+
slug: string;
|
|
39
|
+
name: string;
|
|
40
|
+
icon?: string;
|
|
41
|
+
parentSlug?: string | null;
|
|
42
|
+
default?: boolean;
|
|
43
|
+
exportName?: string;
|
|
44
|
+
collection?: {
|
|
45
|
+
database: string;
|
|
46
|
+
titleProperty: string;
|
|
47
|
+
parentProperty?: string | null;
|
|
48
|
+
sidebar?: {
|
|
49
|
+
mode: 'flat-list' | 'tree';
|
|
50
|
+
allowCreate: boolean;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export const NOTIS_APP_CATEGORIES = [
|
|
56
|
+
'Productivity',
|
|
57
|
+
'Sales & Marketing',
|
|
58
|
+
'Operations',
|
|
59
|
+
'Product & Engineering',
|
|
60
|
+
'Personal',
|
|
61
|
+
] as const;
|
|
62
|
+
|
|
63
|
+
export type NotisAppCategory = typeof NOTIS_APP_CATEGORIES[number];
|
|
64
|
+
|
|
65
|
+
export interface NotisAppAuthor {
|
|
66
|
+
name: string;
|
|
67
|
+
handle?: string;
|
|
68
|
+
url?: string;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface NotisAppSkillConfig {
|
|
72
|
+
key: string;
|
|
73
|
+
path: string;
|
|
74
|
+
name: string;
|
|
75
|
+
description?: string;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface NotisAppOnboardingConfig {
|
|
79
|
+
skill: string;
|
|
80
|
+
prompt: string;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface NotisAppScreenshotConfig {
|
|
84
|
+
path: string;
|
|
85
|
+
alt: string;
|
|
86
|
+
route?: string;
|
|
87
|
+
scenario?: string;
|
|
88
|
+
focus?: string;
|
|
89
|
+
theme?: 'light' | 'dark';
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Named accent tokens for an app's avatar. Keep in sync with the portal
|
|
94
|
+
* `ACCENT_NAMES` and the server `ACCENT_TOKENS`.
|
|
95
|
+
*/
|
|
96
|
+
export const NOTIS_APP_ACCENTS = [
|
|
97
|
+
'blue',
|
|
98
|
+
'violet',
|
|
99
|
+
'emerald',
|
|
100
|
+
'amber',
|
|
101
|
+
'rose',
|
|
102
|
+
'sky',
|
|
103
|
+
'fuchsia',
|
|
104
|
+
'teal',
|
|
105
|
+
] as const;
|
|
106
|
+
|
|
107
|
+
export type NotisAppAccent = typeof NOTIS_APP_ACCENTS[number];
|
|
108
|
+
|
|
109
|
+
export interface NotisAppConfig {
|
|
110
|
+
/** URL-safe app slug. Existing apps may still use a display name here. */
|
|
111
|
+
name: string;
|
|
112
|
+
/** Human display title, Raycast-style. Falls back to `name`. */
|
|
113
|
+
title?: string;
|
|
114
|
+
description?: string;
|
|
115
|
+
/**
|
|
116
|
+
* App icon. A `phosphor:<name>` value (e.g. `phosphor:dice-five`) or
|
|
117
|
+
* `metadata/icon.png`. When unset, the app shows its two-letter initials.
|
|
118
|
+
*/
|
|
119
|
+
icon?: string;
|
|
120
|
+
/**
|
|
121
|
+
* Optional accent color for the app avatar. One of {@link NOTIS_APP_ACCENTS}.
|
|
122
|
+
* When unset, a stable accent is derived automatically from the app id.
|
|
123
|
+
*/
|
|
124
|
+
accent?: NotisAppAccent;
|
|
125
|
+
author?: NotisAppAuthor;
|
|
126
|
+
categories?: NotisAppCategory[];
|
|
127
|
+
tagline?: string;
|
|
128
|
+
/** @deprecated Add release entries to the root CHANGELOG.md instead. */
|
|
129
|
+
versionNotes?: string;
|
|
130
|
+
screenshots?: NotisAppScreenshotConfig[];
|
|
131
|
+
databases?: string[];
|
|
132
|
+
routes?: NotisRouteConfig[];
|
|
133
|
+
tools?: string[];
|
|
134
|
+
skills?: NotisAppSkillConfig[];
|
|
135
|
+
onboarding?: NotisAppOnboardingConfig;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Identity function that provides type checking and autocomplete for the
|
|
140
|
+
* Notis app configuration. The returned object is read at build time by
|
|
141
|
+
* `notis apps build` to generate the manifest.
|
|
142
|
+
*/
|
|
143
|
+
export function defineNotisApp(config: NotisAppConfig): NotisAppConfig {
|
|
144
|
+
return config;
|
|
145
|
+
}
|