@notis_ai/cli 0.2.6 → 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 +2 -0
- 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/useDatabase.ts +76 -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.json +11 -0
- package/package.json +1 -1
- package/src/cli.js +8 -1
- package/src/command-specs/diagnostics.js +674 -0
- package/src/command-specs/helpers.js +4 -1
- package/src/command-specs/index.js +6 -0
- package/src/command-specs/smoke.js +386 -0
- package/src/command-specs/tools.js +187 -7
- package/src/runtime/output.js +12 -1
- package/src/runtime/profiles.js +35 -1
- package/src/runtime/transport.js +3 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "affiliate-prospects",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"notisAppVersion": "0.1.0",
|
|
5
|
+
"private": true,
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "vite build",
|
|
9
|
+
"dev": "vite",
|
|
10
|
+
"typecheck": "tsc --noEmit"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@notis/sdk": "file:./packages/sdk",
|
|
14
|
+
"@phosphor-icons/react": "^2.1.10",
|
|
15
|
+
"clsx": "^2.1.1",
|
|
16
|
+
"react": "^19.0.0",
|
|
17
|
+
"react-dom": "^19.0.0",
|
|
18
|
+
"tailwind-merge": "^2.6.0"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/node": "^22.0.0",
|
|
22
|
+
"@types/react": "^19.0.0",
|
|
23
|
+
"@types/react-dom": "^19.0.0",
|
|
24
|
+
"@vitejs/plugin-react": "^4.3.0",
|
|
25
|
+
"autoprefixer": "^10.4.0",
|
|
26
|
+
"postcss": "^8.4.0",
|
|
27
|
+
"tailwindcss": "^3.4.0",
|
|
28
|
+
"tailwindcss-animate": "^1.0.7",
|
|
29
|
+
"typescript": "^5.5.0",
|
|
30
|
+
"vite": "^6.0.0"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@notis/sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./src/index.ts",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./src/index.ts",
|
|
8
|
+
"./config": "./src/config.ts",
|
|
9
|
+
"./vite": "./src/vite.ts",
|
|
10
|
+
"./ui": "./src/ui.ts",
|
|
11
|
+
"./styles.css": "./src/styles.css"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"src",
|
|
15
|
+
"template"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"type-check": "tsc --noEmit"
|
|
19
|
+
},
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"react": ">=18.0.0",
|
|
22
|
+
"react-dom": ">=18.0.0",
|
|
23
|
+
"vite": ">=5.0.0",
|
|
24
|
+
"@vitejs/plugin-react": ">=4.0.0"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/node": "^20.0.0",
|
|
28
|
+
"@types/react": "^19.0.0",
|
|
29
|
+
"@types/react-dom": "^19.0.0",
|
|
30
|
+
"typescript": "^5.0.0"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,273 @@
|
|
|
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 isEditableTarget(target: EventTarget | null): boolean {
|
|
77
|
+
if (!(target instanceof HTMLElement)) return false;
|
|
78
|
+
if (target.isContentEditable) return true;
|
|
79
|
+
const tag = target.tagName;
|
|
80
|
+
return tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT';
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function shortcutDisplay(raw: string): string {
|
|
84
|
+
const parts = raw.split('+').map((p) => p.trim()).filter(Boolean);
|
|
85
|
+
return parts
|
|
86
|
+
.map((part) => {
|
|
87
|
+
const lower = part.toLowerCase();
|
|
88
|
+
if (lower === 'mod' || lower === 'cmd' || lower === 'meta') return '⌘';
|
|
89
|
+
if (lower === 'ctrl') return '⌃';
|
|
90
|
+
if (lower === 'shift') return '⇧';
|
|
91
|
+
if (lower === 'alt' || lower === 'option') return '⌥';
|
|
92
|
+
return part.length === 1 ? part.toUpperCase() : part;
|
|
93
|
+
})
|
|
94
|
+
.join('');
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const containerBaseStyle: CSSProperties = {
|
|
98
|
+
position: 'fixed',
|
|
99
|
+
bottom: '1rem',
|
|
100
|
+
left: '50%',
|
|
101
|
+
transform: 'translateX(-50%)',
|
|
102
|
+
zIndex: 60,
|
|
103
|
+
display: 'flex',
|
|
104
|
+
alignItems: 'center',
|
|
105
|
+
gap: '0.25rem',
|
|
106
|
+
padding: '0.375rem 0.5rem',
|
|
107
|
+
borderRadius: '0.5rem',
|
|
108
|
+
background: 'color-mix(in srgb, hsl(var(--foreground)) 95%, transparent)',
|
|
109
|
+
color: 'hsl(var(--background))',
|
|
110
|
+
boxShadow: '0 10px 25px -10px rgba(0,0,0,0.35), 0 0 0 1px rgba(0,0,0,0.08)',
|
|
111
|
+
backdropFilter: 'blur(6px)',
|
|
112
|
+
WebkitBackdropFilter: 'blur(6px)',
|
|
113
|
+
pointerEvents: 'auto',
|
|
114
|
+
fontSize: '13px',
|
|
115
|
+
lineHeight: 1.2,
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const countStyle: CSSProperties = {
|
|
119
|
+
padding: '0 0.5rem',
|
|
120
|
+
fontSize: '12px',
|
|
121
|
+
fontWeight: 500,
|
|
122
|
+
fontVariantNumeric: 'tabular-nums',
|
|
123
|
+
color: 'color-mix(in srgb, hsl(var(--background)) 70%, transparent)',
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const dividerStyle: CSSProperties = {
|
|
127
|
+
width: '1px',
|
|
128
|
+
height: '1rem',
|
|
129
|
+
margin: '0 0.125rem',
|
|
130
|
+
background: 'color-mix(in srgb, hsl(var(--background)) 20%, transparent)',
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const baseButtonStyle: CSSProperties = {
|
|
134
|
+
display: 'inline-flex',
|
|
135
|
+
alignItems: 'center',
|
|
136
|
+
gap: '0.375rem',
|
|
137
|
+
padding: '0.25rem 0.5rem',
|
|
138
|
+
border: 0,
|
|
139
|
+
background: 'transparent',
|
|
140
|
+
color: 'color-mix(in srgb, hsl(var(--background)) 90%, transparent)',
|
|
141
|
+
borderRadius: '0.375rem',
|
|
142
|
+
cursor: 'pointer',
|
|
143
|
+
fontSize: '13px',
|
|
144
|
+
fontFamily: 'inherit',
|
|
145
|
+
transition: 'background-color 120ms ease, color 120ms ease',
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const keycapStyle: CSSProperties = {
|
|
149
|
+
display: 'inline-flex',
|
|
150
|
+
alignItems: 'center',
|
|
151
|
+
justifyContent: 'center',
|
|
152
|
+
minWidth: '20px',
|
|
153
|
+
height: '20px',
|
|
154
|
+
padding: '0 4px',
|
|
155
|
+
borderRadius: '4px',
|
|
156
|
+
border: '1px solid color-mix(in srgb, hsl(var(--background)) 20%, transparent)',
|
|
157
|
+
background: 'color-mix(in srgb, hsl(var(--background)) 15%, transparent)',
|
|
158
|
+
color: 'inherit',
|
|
159
|
+
fontSize: '11px',
|
|
160
|
+
fontWeight: 500,
|
|
161
|
+
lineHeight: 1,
|
|
162
|
+
fontFamily: 'inherit',
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
const iconSlotStyle: CSSProperties = {
|
|
166
|
+
display: 'inline-flex',
|
|
167
|
+
alignItems: 'center',
|
|
168
|
+
justifyContent: 'center',
|
|
169
|
+
opacity: 0.8,
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
export function MultiSelectActionBar({
|
|
173
|
+
selectedCount,
|
|
174
|
+
actions,
|
|
175
|
+
itemLabel,
|
|
176
|
+
className,
|
|
177
|
+
style,
|
|
178
|
+
}: MultiSelectActionBarProps): ReactElement | null {
|
|
179
|
+
const actionsRef = useRef(actions);
|
|
180
|
+
actionsRef.current = actions;
|
|
181
|
+
|
|
182
|
+
const parsedShortcuts = useMemo(() => {
|
|
183
|
+
return actions
|
|
184
|
+
.map((action) => {
|
|
185
|
+
if (!action.shortcut) return null;
|
|
186
|
+
const parsed = parseShortcut(action.shortcut);
|
|
187
|
+
return parsed ? { action, parsed } : null;
|
|
188
|
+
})
|
|
189
|
+
.filter((entry): entry is { action: MultiSelectAction; parsed: ParsedShortcut } => entry !== null);
|
|
190
|
+
}, [actions]);
|
|
191
|
+
|
|
192
|
+
useEffect(() => {
|
|
193
|
+
if (selectedCount === 0 || parsedShortcuts.length === 0) return;
|
|
194
|
+
|
|
195
|
+
const handleKeyDown = (event: KeyboardEvent) => {
|
|
196
|
+
if (isEditableTarget(event.target)) return;
|
|
197
|
+
for (const { action, parsed } of parsedShortcuts) {
|
|
198
|
+
if (shortcutMatches(parsed, event)) {
|
|
199
|
+
event.preventDefault();
|
|
200
|
+
event.stopPropagation();
|
|
201
|
+
if (typeof event.stopImmediatePropagation === 'function') {
|
|
202
|
+
event.stopImmediatePropagation();
|
|
203
|
+
}
|
|
204
|
+
void action.onRun();
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
document.addEventListener('keydown', handleKeyDown, true);
|
|
211
|
+
return () => {
|
|
212
|
+
document.removeEventListener('keydown', handleKeyDown, true);
|
|
213
|
+
};
|
|
214
|
+
}, [parsedShortcuts, selectedCount]);
|
|
215
|
+
|
|
216
|
+
if (selectedCount === 0) return null;
|
|
217
|
+
|
|
218
|
+
const countWord = itemLabel
|
|
219
|
+
? selectedCount === 1
|
|
220
|
+
? itemLabel.singular
|
|
221
|
+
: itemLabel.plural
|
|
222
|
+
: 'selected';
|
|
223
|
+
const countLabel = itemLabel
|
|
224
|
+
? `${selectedCount} ${countWord} selected`
|
|
225
|
+
: `${selectedCount} selected`;
|
|
226
|
+
|
|
227
|
+
const composedStyle: CSSProperties = { ...containerBaseStyle, ...(style || {}) };
|
|
228
|
+
|
|
229
|
+
return (
|
|
230
|
+
<div
|
|
231
|
+
role="toolbar"
|
|
232
|
+
aria-label={`Bulk actions for ${selectedCount} selected ${countWord}`}
|
|
233
|
+
className={className}
|
|
234
|
+
style={composedStyle}
|
|
235
|
+
>
|
|
236
|
+
<span style={countStyle}>{countLabel}</span>
|
|
237
|
+
{actions.length > 0 ? <span aria-hidden style={dividerStyle} /> : null}
|
|
238
|
+
{actions.map((action) => (
|
|
239
|
+
<ActionButton key={action.id} action={action} />
|
|
240
|
+
))}
|
|
241
|
+
</div>
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function ActionButton({ action }: { action: MultiSelectAction }) {
|
|
246
|
+
const [hover, setHover] = useState(false);
|
|
247
|
+
const display = action.shortcut ? shortcutDisplay(action.shortcut) : null;
|
|
248
|
+
const buttonStyle: CSSProperties = {
|
|
249
|
+
...baseButtonStyle,
|
|
250
|
+
background: hover
|
|
251
|
+
? 'color-mix(in srgb, hsl(var(--background)) 12%, transparent)'
|
|
252
|
+
: 'transparent',
|
|
253
|
+
color: hover
|
|
254
|
+
? 'hsl(var(--background))'
|
|
255
|
+
: baseButtonStyle.color,
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
return (
|
|
259
|
+
<button
|
|
260
|
+
type="button"
|
|
261
|
+
onClick={() => void action.onRun()}
|
|
262
|
+
onMouseEnter={() => setHover(true)}
|
|
263
|
+
onMouseLeave={() => setHover(false)}
|
|
264
|
+
onFocus={() => setHover(true)}
|
|
265
|
+
onBlur={() => setHover(false)}
|
|
266
|
+
style={buttonStyle}
|
|
267
|
+
>
|
|
268
|
+
<span aria-hidden style={iconSlotStyle}>{action.icon}</span>
|
|
269
|
+
{display ? <kbd aria-hidden style={keycapStyle}>{display}</kbd> : null}
|
|
270
|
+
<span>{action.label}</span>
|
|
271
|
+
</button>
|
|
272
|
+
);
|
|
273
|
+
}
|
package/dist/scaffolds/notis-affiliate-prospects/packages/sdk/src/components/MultiSelectCheckbox.tsx
ADDED
|
@@ -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,90 @@
|
|
|
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 interface NotisAppConfig {
|
|
56
|
+
name: string;
|
|
57
|
+
title?: string;
|
|
58
|
+
description?: string;
|
|
59
|
+
icon?: string;
|
|
60
|
+
accent?: 'blue' | 'violet' | 'emerald' | 'amber' | 'rose' | 'sky' | 'fuchsia' | 'teal';
|
|
61
|
+
author?: {
|
|
62
|
+
name: string;
|
|
63
|
+
handle?: string;
|
|
64
|
+
url?: string;
|
|
65
|
+
};
|
|
66
|
+
categories?: Array<
|
|
67
|
+
'Productivity' | 'Sales & Marketing' | 'Operations' | 'Product & Engineering' | 'Personal'
|
|
68
|
+
>;
|
|
69
|
+
tagline?: string;
|
|
70
|
+
screenshots?: Array<{
|
|
71
|
+
path: string;
|
|
72
|
+
alt: string;
|
|
73
|
+
route?: string;
|
|
74
|
+
scenario?: string;
|
|
75
|
+
focus?: string;
|
|
76
|
+
theme?: 'light' | 'dark';
|
|
77
|
+
}>;
|
|
78
|
+
databases?: string[];
|
|
79
|
+
routes?: NotisRouteConfig[];
|
|
80
|
+
tools?: string[];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Identity function that provides type checking and autocomplete for the
|
|
85
|
+
* Notis app configuration. The returned object is read at build time by
|
|
86
|
+
* `notis apps build` to generate the manifest.
|
|
87
|
+
*/
|
|
88
|
+
export function defineNotisApp(config: NotisAppConfig): NotisAppConfig {
|
|
89
|
+
return config;
|
|
90
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
import { useNotisRuntime } from '../provider';
|
|
5
|
+
|
|
6
|
+
interface UseBackendResult {
|
|
7
|
+
/**
|
|
8
|
+
* Make an authenticated request to the Notis backend.
|
|
9
|
+
* The path should be an absolute backend path (e.g. `/portal_composio/actions`).
|
|
10
|
+
*/
|
|
11
|
+
request: (path: string, options?: {
|
|
12
|
+
method?: string;
|
|
13
|
+
headers?: Record<string, string>;
|
|
14
|
+
body?: unknown;
|
|
15
|
+
}) => Promise<unknown>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Raw backend request proxy. Use this for custom server endpoints or
|
|
20
|
+
* integration APIs not covered by the typed hooks.
|
|
21
|
+
*
|
|
22
|
+
* ```tsx
|
|
23
|
+
* const { request } = useBackend();
|
|
24
|
+
* const data = await request('/portal_composio/actions', { method: 'POST', body: { ... } });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export function useBackend(): UseBackendResult {
|
|
28
|
+
const runtime = useNotisRuntime();
|
|
29
|
+
|
|
30
|
+
const request = useCallback(
|
|
31
|
+
async (path: string, options?: { method?: string; headers?: Record<string, string>; body?: unknown }) => {
|
|
32
|
+
if (!runtime) {
|
|
33
|
+
throw new Error('Notis runtime not available. Ensure NotisProvider is mounted.');
|
|
34
|
+
}
|
|
35
|
+
return runtime.request(path, options);
|
|
36
|
+
},
|
|
37
|
+
[runtime],
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
return { request };
|
|
41
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
4
|
+
import { useNotisRuntime } from '../provider';
|
|
5
|
+
import type { DocumentRecord, QueryFilter } from '../runtime';
|
|
6
|
+
|
|
7
|
+
interface UseDatabaseOptions {
|
|
8
|
+
filter?: QueryFilter;
|
|
9
|
+
pageSize?: number;
|
|
10
|
+
offset?: number;
|
|
11
|
+
enabled?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface UseDatabaseResult {
|
|
15
|
+
documents: DocumentRecord[];
|
|
16
|
+
loading: boolean;
|
|
17
|
+
error: Error | null;
|
|
18
|
+
refetch: () => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function useDatabase(
|
|
22
|
+
databaseSlug: string,
|
|
23
|
+
options: UseDatabaseOptions = {},
|
|
24
|
+
): UseDatabaseResult {
|
|
25
|
+
const runtime = useNotisRuntime();
|
|
26
|
+
const [documents, setDocuments] = useState<DocumentRecord[]>([]);
|
|
27
|
+
const [loading, setLoading] = useState(true);
|
|
28
|
+
const [error, setError] = useState<Error | null>(null);
|
|
29
|
+
const [fetchKey, setFetchKey] = useState(0);
|
|
30
|
+
|
|
31
|
+
const enabled = options.enabled !== false;
|
|
32
|
+
const filterKey = JSON.stringify(options.filter ?? null);
|
|
33
|
+
|
|
34
|
+
const refetch = useCallback(() => {
|
|
35
|
+
setFetchKey((key) => key + 1);
|
|
36
|
+
}, []);
|
|
37
|
+
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (!runtime || !enabled) {
|
|
40
|
+
setLoading(false);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let cancelled = false;
|
|
45
|
+
setLoading(true);
|
|
46
|
+
setError(null);
|
|
47
|
+
|
|
48
|
+
runtime
|
|
49
|
+
.queryDatabase({
|
|
50
|
+
databaseSlug,
|
|
51
|
+
query: {
|
|
52
|
+
...options.filter,
|
|
53
|
+
page_size: options.pageSize,
|
|
54
|
+
},
|
|
55
|
+
offset: options.offset,
|
|
56
|
+
})
|
|
57
|
+
.then((result) => {
|
|
58
|
+
if (!cancelled) {
|
|
59
|
+
setDocuments(result.documents);
|
|
60
|
+
setLoading(false);
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
.catch((err) => {
|
|
64
|
+
if (!cancelled) {
|
|
65
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
66
|
+
setLoading(false);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
return () => {
|
|
71
|
+
cancelled = true;
|
|
72
|
+
};
|
|
73
|
+
}, [runtime, databaseSlug, fetchKey, enabled, filterKey, options.offset, options.pageSize]);
|
|
74
|
+
|
|
75
|
+
return { documents, loading, error, refetch };
|
|
76
|
+
}
|