@notis_ai/cli 0.2.0 → 0.2.2

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.
Files changed (81) hide show
  1. package/README.md +122 -158
  2. package/dist/scaffolds/notes/app/globals.css +3 -0
  3. package/dist/scaffolds/notes/app/layout.tsx +6 -0
  4. package/dist/scaffolds/notes/app/page.tsx +1465 -0
  5. package/dist/scaffolds/notes/components/ui/badge.tsx +28 -0
  6. package/dist/scaffolds/notes/components/ui/button.tsx +53 -0
  7. package/dist/scaffolds/notes/components/ui/card.tsx +56 -0
  8. package/dist/scaffolds/notes/components.json +20 -0
  9. package/dist/scaffolds/notes/lib/utils.ts +6 -0
  10. package/dist/scaffolds/notes/notis.config.ts +31 -0
  11. package/dist/scaffolds/notes/package.json +31 -0
  12. package/dist/scaffolds/notes/postcss.config.mjs +8 -0
  13. package/dist/scaffolds/notes/tailwind.config.ts +58 -0
  14. package/dist/scaffolds/notes/tsconfig.json +22 -0
  15. package/dist/scaffolds/notes/vite.config.ts +10 -0
  16. package/dist/scaffolds.json +13 -0
  17. package/package.json +12 -2
  18. package/skills/notis-apps/SKILL.md +162 -0
  19. package/skills/notis-apps/cli.md +208 -0
  20. package/skills/notis-cli/SKILL.md +258 -0
  21. package/skills/notis-query/cli.md +40 -0
  22. package/src/cli.js +1 -1
  23. package/src/command-specs/apps.js +1029 -59
  24. package/src/command-specs/helpers.js +6 -41
  25. package/src/command-specs/index.js +1 -7
  26. package/src/command-specs/meta.js +7 -6
  27. package/src/command-specs/tools.js +29 -34
  28. package/src/runtime/agent-browser.js +192 -0
  29. package/src/runtime/app-boundary-validator.js +132 -0
  30. package/src/runtime/app-dev-server.js +605 -0
  31. package/src/runtime/app-dev-sessions.js +87 -0
  32. package/src/runtime/app-platform.js +1037 -82
  33. package/src/runtime/cli-mode.generated.js +4 -0
  34. package/src/runtime/cli-mode.js +29 -0
  35. package/src/runtime/output.js +2 -2
  36. package/src/runtime/ports.js +15 -0
  37. package/src/runtime/profiles.js +36 -5
  38. package/src/runtime/transport.js +131 -6
  39. package/template/.harness/index.html.tmpl +211 -0
  40. package/template/app/globals.css +3 -0
  41. package/template/app/layout.tsx +6 -0
  42. package/template/app/page.tsx +90 -0
  43. package/template/components/ui/badge.tsx +28 -0
  44. package/template/components/ui/button.tsx +53 -0
  45. package/template/components/ui/card.tsx +56 -0
  46. package/template/components.json +20 -0
  47. package/template/lib/utils.ts +6 -0
  48. package/template/metadata/cover.png +0 -0
  49. package/template/metadata/screenshot-1.png +0 -0
  50. package/template/metadata/screenshot-2.png +0 -0
  51. package/template/metadata/screenshot-3.png +0 -0
  52. package/template/notis.config.ts +37 -0
  53. package/template/package.json +31 -0
  54. package/template/packages/sdk/package.json +32 -0
  55. package/template/packages/sdk/src/components/MultiSelectActionBar.tsx +273 -0
  56. package/template/packages/sdk/src/components/MultiSelectCheckbox.tsx +91 -0
  57. package/template/packages/sdk/src/components/MultiSelectDragOverlay.tsx +39 -0
  58. package/template/packages/sdk/src/config.ts +71 -0
  59. package/template/packages/sdk/src/hooks/useBackend.ts +41 -0
  60. package/template/packages/sdk/src/hooks/useDatabase.ts +76 -0
  61. package/template/packages/sdk/src/hooks/useMultiSelect.ts +503 -0
  62. package/template/packages/sdk/src/hooks/useNotis.ts +34 -0
  63. package/template/packages/sdk/src/hooks/useNotisNavigation.ts +49 -0
  64. package/template/packages/sdk/src/hooks/useTool.ts +64 -0
  65. package/template/packages/sdk/src/hooks/useTools.ts +56 -0
  66. package/template/packages/sdk/src/hooks/useTopBarSearch.ts +73 -0
  67. package/template/packages/sdk/src/hooks/useUpsertDocument.ts +50 -0
  68. package/template/packages/sdk/src/index.ts +54 -0
  69. package/template/packages/sdk/src/provider.tsx +43 -0
  70. package/template/packages/sdk/src/runtime.ts +161 -0
  71. package/template/packages/sdk/src/styles.css +38 -0
  72. package/template/packages/sdk/src/ui.ts +15 -0
  73. package/template/packages/sdk/src/vite.ts +56 -0
  74. package/template/packages/sdk/tsconfig.json +15 -0
  75. package/template/postcss.config.mjs +8 -0
  76. package/template/tailwind.config.ts +58 -0
  77. package/template/tsconfig.json +22 -0
  78. package/template/vite.config.ts +10 -0
  79. package/src/command-specs/auth.js +0 -178
  80. package/src/command-specs/db.js +0 -163
  81. package/src/runtime/app-preview-server.js +0 -272
@@ -0,0 +1,28 @@
1
+ import * as React from 'react';
2
+ import { cva, type VariantProps } from 'class-variance-authority';
3
+
4
+ import { cn } from '@/lib/utils';
5
+
6
+ const badgeVariants = cva(
7
+ 'inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2',
8
+ {
9
+ variants: {
10
+ variant: {
11
+ default: 'border-transparent bg-primary/10 text-primary',
12
+ secondary: 'border-transparent bg-secondary text-secondary-foreground',
13
+ outline: 'text-foreground',
14
+ },
15
+ },
16
+ defaultVariants: {
17
+ variant: 'default',
18
+ },
19
+ },
20
+ );
21
+
22
+ export interface BadgeProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof badgeVariants> {}
23
+
24
+ function Badge({ className, variant, ...props }: BadgeProps) {
25
+ return <div className={cn(badgeVariants({ variant }), className)} {...props} />;
26
+ }
27
+
28
+ export { Badge, badgeVariants };
@@ -0,0 +1,53 @@
1
+ import * as React from 'react';
2
+ import { Slot } from '@radix-ui/react-slot';
3
+ import { cva, type VariantProps } from 'class-variance-authority';
4
+
5
+ import { cn } from '@/lib/utils';
6
+
7
+ const buttonVariants = cva(
8
+ 'inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50',
9
+ {
10
+ variants: {
11
+ variant: {
12
+ default: 'bg-primary text-primary-foreground hover:bg-primary/90',
13
+ destructive: 'bg-destructive text-destructive-foreground hover:bg-destructive/90',
14
+ outline: 'border border-input bg-background hover:bg-accent hover:text-accent-foreground',
15
+ secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80',
16
+ ghost: 'hover:bg-accent hover:text-accent-foreground',
17
+ link: 'text-primary underline-offset-4 hover:underline',
18
+ },
19
+ size: {
20
+ default: 'h-10 px-4 py-2',
21
+ sm: 'h-9 rounded-md px-3',
22
+ lg: 'h-11 rounded-md px-8',
23
+ icon: 'h-10 w-10',
24
+ },
25
+ },
26
+ defaultVariants: {
27
+ variant: 'default',
28
+ size: 'default',
29
+ },
30
+ },
31
+ );
32
+
33
+ export interface ButtonProps
34
+ extends React.ButtonHTMLAttributes<HTMLButtonElement>,
35
+ VariantProps<typeof buttonVariants> {
36
+ asChild?: boolean;
37
+ }
38
+
39
+ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
40
+ ({ className, variant, size, asChild = false, ...props }, ref) => {
41
+ const Comp = asChild ? Slot : 'button';
42
+ return (
43
+ <Comp
44
+ className={cn(buttonVariants({ variant, size, className }))}
45
+ ref={ref}
46
+ {...props}
47
+ />
48
+ );
49
+ },
50
+ );
51
+ Button.displayName = 'Button';
52
+
53
+ export { Button, buttonVariants };
@@ -0,0 +1,56 @@
1
+ import * as React from 'react';
2
+
3
+ import { cn } from '@/lib/utils';
4
+
5
+ const Card = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
6
+ ({ className, ...props }, ref) => (
7
+ <div
8
+ ref={ref}
9
+ className={cn('rounded-2xl border bg-card text-card-foreground shadow-sm', className)}
10
+ {...props}
11
+ />
12
+ ),
13
+ );
14
+ Card.displayName = 'Card';
15
+
16
+ const CardHeader = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
17
+ ({ className, ...props }, ref) => (
18
+ <div ref={ref} className={cn('flex flex-col space-y-1.5 p-6', className)} {...props} />
19
+ ),
20
+ );
21
+ CardHeader.displayName = 'CardHeader';
22
+
23
+ const CardTitle = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLHeadingElement>>(
24
+ ({ className, ...props }, ref) => (
25
+ <h3
26
+ ref={ref}
27
+ className={cn('text-xl font-semibold leading-none tracking-tight', className)}
28
+ {...props}
29
+ />
30
+ ),
31
+ );
32
+ CardTitle.displayName = 'CardTitle';
33
+
34
+ const CardDescription = React.forwardRef<
35
+ HTMLParagraphElement,
36
+ React.HTMLAttributes<HTMLParagraphElement>
37
+ >(({ className, ...props }, ref) => (
38
+ <p ref={ref} className={cn('text-sm text-muted-foreground', className)} {...props} />
39
+ ));
40
+ CardDescription.displayName = 'CardDescription';
41
+
42
+ const CardContent = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
43
+ ({ className, ...props }, ref) => (
44
+ <div ref={ref} className={cn('p-6 pt-0', className)} {...props} />
45
+ ),
46
+ );
47
+ CardContent.displayName = 'CardContent';
48
+
49
+ const CardFooter = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
50
+ ({ className, ...props }, ref) => (
51
+ <div ref={ref} className={cn('flex items-center p-6 pt-0', className)} {...props} />
52
+ ),
53
+ );
54
+ CardFooter.displayName = 'CardFooter';
55
+
56
+ export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent };
@@ -0,0 +1,20 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema.json",
3
+ "style": "new-york",
4
+ "rsc": false,
5
+ "tsx": true,
6
+ "tailwind": {
7
+ "config": "tailwind.config.ts",
8
+ "css": "app/globals.css",
9
+ "baseColor": "zinc",
10
+ "cssVariables": true,
11
+ "prefix": ""
12
+ },
13
+ "aliases": {
14
+ "components": "@/components",
15
+ "utils": "@/lib/utils",
16
+ "ui": "@/components/ui",
17
+ "lib": "@/lib",
18
+ "hooks": "@/hooks"
19
+ }
20
+ }
@@ -0,0 +1,6 @@
1
+ import { type ClassValue, clsx } from 'clsx';
2
+ import { twMerge } from 'tailwind-merge';
3
+
4
+ export function cn(...inputs: ClassValue[]) {
5
+ return twMerge(clsx(inputs));
6
+ }
Binary file
@@ -0,0 +1,37 @@
1
+ import { defineNotisApp } from '@notis/sdk/config';
2
+
3
+ export default defineNotisApp({
4
+ name: 'my-notis-app',
5
+ title: 'My Notis App',
6
+ description: 'A focused Notis app with one route and one database-backed workflow.',
7
+ icon: 'phosphor:squares-four',
8
+ author: { name: 'Notis User' },
9
+ categories: ['Productivity'],
10
+ tagline: 'A clean starting point for a focused workflow.',
11
+ versionNotes: 'Initial release.',
12
+
13
+ databases: ['items'],
14
+
15
+ routes: [
16
+ { path: '/', slug: 'home', name: 'Home', icon: 'phosphor:house', default: true },
17
+ // Example collection tree route:
18
+ // {
19
+ // path: '/notes',
20
+ // slug: 'notes',
21
+ // name: 'Notes',
22
+ // collection: {
23
+ // database: 'notes',
24
+ // titleProperty: 'Name',
25
+ // parentProperty: 'Parent',
26
+ // sidebar: {
27
+ // mode: 'tree',
28
+ // allowCreate: true,
29
+ // },
30
+ // },
31
+ // },
32
+ ],
33
+
34
+ tools: [
35
+ 'notis-default-query',
36
+ ],
37
+ });
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "my-notis-app",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "vite build"
9
+ },
10
+ "dependencies": {
11
+ "@notis/sdk": "file:./packages/sdk",
12
+ "@phosphor-icons/react": "^2.1.10",
13
+ "@radix-ui/react-slot": "^1.1.0",
14
+ "class-variance-authority": "^0.7.0",
15
+ "clsx": "^2.1.1",
16
+ "react": "^19.0.0",
17
+ "react-dom": "^19.0.0",
18
+ "tailwind-merge": "^2.6.0",
19
+ "tailwindcss-animate": "^1.0.7"
20
+ },
21
+ "devDependencies": {
22
+ "@types/node": "^22.0.0",
23
+ "@types/react": "^19.0.0",
24
+ "@types/react-dom": "^19.0.0",
25
+ "@vitejs/plugin-react": "^4.0.0",
26
+ "postcss": "^8.0.0",
27
+ "tailwindcss": "^3.4.0",
28
+ "typescript": "^5.0.0",
29
+ "vite": "^6.0.0"
30
+ }
31
+ }
@@ -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
+ }
@@ -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
+ }