@notis_ai/cli 0.2.7 → 0.2.8

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 (177) hide show
  1. package/README.md +15 -0
  2. package/dist/scaffolds/notis-database/app/page.tsx +38 -41
  3. package/dist/scaffolds/notis-database/lib/types.ts +5 -7
  4. package/dist/scaffolds/notis-database/metadata/screenshot-1.png +0 -0
  5. package/dist/scaffolds/notis-database/metadata/screenshot-2.png +0 -0
  6. package/dist/scaffolds/notis-database/metadata/screenshot-3.png +0 -0
  7. package/dist/scaffolds/notis-database/metadata/screenshot-4.png +0 -0
  8. package/dist/scaffolds/notis-database/metadata/screenshot-5.png +0 -0
  9. package/dist/scaffolds/notis-database/metadata/screenshot-fixtures.json +1839 -0
  10. package/dist/scaffolds/notis-database/notis.config.ts +48 -1
  11. package/dist/scaffolds/notis-database/package-lock.json +3935 -0
  12. package/dist/scaffolds/notis-database/package.json +2 -1
  13. package/dist/scaffolds/{notis-affiliate-prospects → notis-database}/packages/sdk/package.json +4 -0
  14. package/dist/scaffolds/notis-database/packages/sdk/src/components/DocumentEditor.tsx +93 -0
  15. package/dist/scaffolds/notis-database/packages/sdk/src/components/Markdown.tsx +60 -0
  16. package/dist/scaffolds/{notis-affiliate-prospects → notis-database}/packages/sdk/src/components/MultiSelectActionBar.tsx +7 -2
  17. package/dist/scaffolds/notis-database/packages/sdk/src/config.ts +196 -0
  18. package/dist/scaffolds/notis-database/packages/sdk/src/documents.ts +229 -0
  19. package/dist/scaffolds/notis-database/packages/sdk/src/hooks/useDatabaseSchema.ts +85 -0
  20. package/dist/scaffolds/notis-database/packages/sdk/src/hooks/useDocument.ts +78 -0
  21. package/dist/scaffolds/notis-database/packages/sdk/src/hooks/useDocuments.ts +121 -0
  22. package/dist/scaffolds/{notis-affiliate-prospects → notis-database}/packages/sdk/src/hooks/useMultiSelect.ts +38 -2
  23. package/dist/scaffolds/notis-database/packages/sdk/src/hooks/useUpsertDocument.ts +95 -0
  24. package/dist/scaffolds/{notis-affiliate-prospects → notis-database}/packages/sdk/src/index.ts +30 -1
  25. package/dist/scaffolds/{notis-affiliate-prospects → notis-database}/packages/sdk/src/runtime.ts +76 -17
  26. package/dist/scaffolds/notis-database/packages/sdk/src/styles.css +186 -0
  27. package/dist/scaffolds/notis-database/src/mock-runtime.ts +4 -1
  28. package/dist/scaffolds/notis-journal/CHANGELOG.md +4 -0
  29. package/dist/scaffolds/notis-journal/app/page.tsx +1 -0
  30. package/dist/scaffolds/notis-journal/package-lock.json +4615 -0
  31. package/dist/scaffolds/notis-journal/package.json +2 -2
  32. package/dist/scaffolds/notis-journal/packages/sdk/src/config.ts +52 -1
  33. package/dist/scaffolds/notis-notes/app/page.tsx +39 -46
  34. package/dist/scaffolds/notis-notes/app/phosphor-icons.ts +596 -0
  35. package/dist/scaffolds/notis-notes/lib/visible-properties.ts +144 -0
  36. package/dist/scaffolds/notis-notes/metadata/screenshot-1.png +0 -0
  37. package/dist/scaffolds/notis-notes/metadata/screenshot-2.png +0 -0
  38. package/dist/scaffolds/notis-notes/metadata/screenshot-3.png +0 -0
  39. package/dist/scaffolds/notis-notes/metadata/screenshot-4.png +0 -0
  40. package/dist/scaffolds/notis-notes/metadata/screenshot-5.png +0 -0
  41. package/dist/scaffolds/notis-notes/metadata/screenshot-fixtures.json +752 -0
  42. package/dist/scaffolds/notis-notes/notis.config.ts +48 -3
  43. package/dist/scaffolds/notis-notes/package-lock.json +4636 -0
  44. package/dist/scaffolds/notis-notes/package.json +7 -3
  45. package/dist/scaffolds/notis-notes/packages/sdk/package.json +36 -0
  46. package/dist/scaffolds/notis-notes/packages/sdk/src/components/DocumentEditor.tsx +93 -0
  47. package/dist/scaffolds/notis-notes/packages/sdk/src/components/Markdown.tsx +60 -0
  48. package/dist/scaffolds/notis-notes/packages/sdk/src/components/MultiSelectActionBar.tsx +278 -0
  49. package/dist/scaffolds/notis-notes/packages/sdk/src/components/MultiSelectCheckbox.tsx +91 -0
  50. package/dist/scaffolds/notis-notes/packages/sdk/src/components/MultiSelectDragOverlay.tsx +39 -0
  51. package/dist/scaffolds/notis-notes/packages/sdk/src/config.ts +196 -0
  52. package/dist/scaffolds/notis-notes/packages/sdk/src/documents.ts +229 -0
  53. package/dist/scaffolds/notis-notes/packages/sdk/src/hooks/useBackend.ts +41 -0
  54. package/dist/scaffolds/notis-notes/packages/sdk/src/hooks/useDatabaseSchema.ts +85 -0
  55. package/dist/scaffolds/notis-notes/packages/sdk/src/hooks/useDocument.ts +78 -0
  56. package/dist/scaffolds/notis-notes/packages/sdk/src/hooks/useDocuments.ts +121 -0
  57. package/dist/scaffolds/notis-notes/packages/sdk/src/hooks/useMultiSelect.ts +539 -0
  58. package/dist/scaffolds/notis-notes/packages/sdk/src/hooks/useNotis.ts +34 -0
  59. package/dist/scaffolds/notis-notes/packages/sdk/src/hooks/useNotisNavigation.ts +49 -0
  60. package/dist/scaffolds/notis-notes/packages/sdk/src/hooks/useTool.ts +64 -0
  61. package/dist/scaffolds/notis-notes/packages/sdk/src/hooks/useTools.ts +56 -0
  62. package/dist/scaffolds/notis-notes/packages/sdk/src/hooks/useTopBarSearch.ts +73 -0
  63. package/dist/scaffolds/notis-notes/packages/sdk/src/hooks/useUpsertDocument.ts +95 -0
  64. package/dist/scaffolds/notis-notes/packages/sdk/src/index.ts +83 -0
  65. package/dist/scaffolds/notis-notes/packages/sdk/src/provider.tsx +43 -0
  66. package/dist/scaffolds/notis-notes/packages/sdk/src/runtime.ts +220 -0
  67. package/dist/scaffolds/notis-notes/packages/sdk/src/styles.css +186 -0
  68. package/dist/scaffolds/notis-notes/packages/sdk/src/ui.ts +15 -0
  69. package/dist/scaffolds/notis-notes/packages/sdk/src/vite.ts +56 -0
  70. package/dist/scaffolds/notis-notes/packages/sdk/tsconfig.json +15 -0
  71. package/dist/scaffolds/notis-random/CHANGELOG.md +12 -2
  72. package/dist/scaffolds/notis-random/app/history/page.tsx +5 -4
  73. package/dist/scaffolds/notis-random/app/page.tsx +141 -74
  74. package/dist/scaffolds/notis-random/components/ui/button.tsx +50 -0
  75. package/dist/scaffolds/notis-random/components/ui/card.tsx +16 -0
  76. package/dist/scaffolds/notis-random/components/ui/input.tsx +23 -0
  77. package/dist/scaffolds/notis-random/lib/notis-tools.ts +26 -7
  78. package/dist/scaffolds/notis-random/lib/rng.ts +179 -19
  79. package/dist/scaffolds/notis-random/lib/roll-record.ts +103 -16
  80. package/dist/scaffolds/notis-random/metadata/screenshot-1.png +0 -0
  81. package/dist/scaffolds/notis-random/metadata/screenshot-2.png +0 -0
  82. package/dist/scaffolds/notis-random/metadata/screenshot-3.png +0 -0
  83. package/dist/scaffolds/notis-random/metadata/screenshot-4.png +0 -0
  84. package/dist/scaffolds/notis-random/metadata/screenshot-5.png +0 -0
  85. package/dist/scaffolds/notis-random/metadata/screenshot-fixtures.json +753 -0
  86. package/dist/scaffolds/notis-random/notis.config.ts +47 -3
  87. package/dist/scaffolds/notis-random/package-lock.json +4513 -0
  88. package/dist/scaffolds/notis-random/package.json +6 -2
  89. package/dist/scaffolds/notis-random/packages/sdk/package.json +36 -0
  90. package/dist/scaffolds/notis-random/packages/sdk/src/components/DocumentEditor.tsx +93 -0
  91. package/dist/scaffolds/notis-random/packages/sdk/src/components/Markdown.tsx +60 -0
  92. package/dist/scaffolds/notis-random/packages/sdk/src/components/MultiSelectActionBar.tsx +278 -0
  93. package/dist/scaffolds/notis-random/packages/sdk/src/components/MultiSelectCheckbox.tsx +91 -0
  94. package/dist/scaffolds/notis-random/packages/sdk/src/components/MultiSelectDragOverlay.tsx +39 -0
  95. package/dist/scaffolds/notis-random/packages/sdk/src/config.ts +196 -0
  96. package/dist/scaffolds/notis-random/packages/sdk/src/documents.ts +229 -0
  97. package/dist/scaffolds/notis-random/packages/sdk/src/hooks/useBackend.ts +41 -0
  98. package/dist/scaffolds/notis-random/packages/sdk/src/hooks/useDatabaseSchema.ts +85 -0
  99. package/dist/scaffolds/notis-random/packages/sdk/src/hooks/useDocument.ts +78 -0
  100. package/dist/scaffolds/notis-random/packages/sdk/src/hooks/useDocuments.ts +121 -0
  101. package/dist/scaffolds/notis-random/packages/sdk/src/hooks/useMultiSelect.ts +539 -0
  102. package/dist/scaffolds/notis-random/packages/sdk/src/hooks/useNotis.ts +34 -0
  103. package/dist/scaffolds/notis-random/packages/sdk/src/hooks/useNotisNavigation.ts +49 -0
  104. package/dist/scaffolds/notis-random/packages/sdk/src/hooks/useTool.ts +64 -0
  105. package/dist/scaffolds/notis-random/packages/sdk/src/hooks/useTools.ts +56 -0
  106. package/dist/scaffolds/notis-random/packages/sdk/src/hooks/useTopBarSearch.ts +73 -0
  107. package/dist/scaffolds/notis-random/packages/sdk/src/hooks/useUpsertDocument.ts +95 -0
  108. package/dist/scaffolds/notis-random/packages/sdk/src/index.ts +83 -0
  109. package/dist/scaffolds/notis-random/packages/sdk/src/provider.tsx +43 -0
  110. package/dist/scaffolds/notis-random/packages/sdk/src/runtime.ts +220 -0
  111. package/dist/scaffolds/notis-random/packages/sdk/src/styles.css +186 -0
  112. package/dist/scaffolds/notis-random/packages/sdk/src/ui.ts +15 -0
  113. package/dist/scaffolds/notis-random/packages/sdk/src/vite.ts +56 -0
  114. package/dist/scaffolds/notis-random/packages/sdk/tsconfig.json +15 -0
  115. package/dist/scaffolds/notis-random/tailwind.config.ts +8 -1
  116. package/dist/scaffolds.json +8 -17
  117. package/package.json +2 -1
  118. package/skills/notis-apps/SKILL.md +449 -144
  119. package/skills/notis-apps/cli.md +15 -0
  120. package/skills/notis-cli/SKILL.md +8 -4
  121. package/skills/notis-onboarding/BRIEF.md +93 -0
  122. package/src/cli.js +50 -12
  123. package/src/command-specs/apps.js +154 -21
  124. package/src/command-specs/index.js +2 -0
  125. package/src/command-specs/onboarding.js +216 -0
  126. package/src/command-specs/tools.js +8 -4
  127. package/src/runtime/app-platform.js +65 -4
  128. package/src/runtime/desktop-auth.js +66 -17
  129. package/src/runtime/errors.js +1 -0
  130. package/src/runtime/output.js +9 -2
  131. package/src/runtime/profiles.js +179 -17
  132. package/src/runtime/telemetry.js +92 -0
  133. package/src/runtime/transport.js +26 -1
  134. package/template/.harness/index.html.tmpl +30 -2
  135. package/template/packages/sdk/src/config.ts +38 -1
  136. package/dist/scaffolds/notis-affiliate-prospects/CHANGELOG.md +0 -7
  137. package/dist/scaffolds/notis-affiliate-prospects/README.md +0 -20
  138. package/dist/scaffolds/notis-affiliate-prospects/app/globals.css +0 -42
  139. package/dist/scaffolds/notis-affiliate-prospects/app/layout.tsx +0 -7
  140. package/dist/scaffolds/notis-affiliate-prospects/app/page.tsx +0 -248
  141. package/dist/scaffolds/notis-affiliate-prospects/app/prospects/page.tsx +0 -134
  142. package/dist/scaffolds/notis-affiliate-prospects/app/segments/page.tsx +0 -108
  143. package/dist/scaffolds/notis-affiliate-prospects/components/ui/card.tsx +0 -35
  144. package/dist/scaffolds/notis-affiliate-prospects/index.html +0 -12
  145. package/dist/scaffolds/notis-affiliate-prospects/lib/affiliate-data.ts +0 -218
  146. package/dist/scaffolds/notis-affiliate-prospects/lib/demo-prospects.ts +0 -52
  147. package/dist/scaffolds/notis-affiliate-prospects/lib/notis-tools.ts +0 -100
  148. package/dist/scaffolds/notis-affiliate-prospects/lib/utils.ts +0 -25
  149. package/dist/scaffolds/notis-affiliate-prospects/metadata/screenshot-1.png +0 -0
  150. package/dist/scaffolds/notis-affiliate-prospects/metadata/screenshot-2.png +0 -0
  151. package/dist/scaffolds/notis-affiliate-prospects/metadata/screenshot-3.png +0 -0
  152. package/dist/scaffolds/notis-affiliate-prospects/metadata/screenshot-fixtures.json +0 -187
  153. package/dist/scaffolds/notis-affiliate-prospects/notis.config.ts +0 -65
  154. package/dist/scaffolds/notis-affiliate-prospects/package.json +0 -32
  155. package/dist/scaffolds/notis-affiliate-prospects/packages/sdk/src/config.ts +0 -90
  156. package/dist/scaffolds/notis-affiliate-prospects/packages/sdk/src/hooks/useDatabase.ts +0 -76
  157. package/dist/scaffolds/notis-affiliate-prospects/packages/sdk/src/hooks/useUpsertDocument.ts +0 -50
  158. package/dist/scaffolds/notis-affiliate-prospects/packages/sdk/src/styles.css +0 -38
  159. package/dist/scaffolds/notis-affiliate-prospects/postcss.config.mjs +0 -6
  160. package/dist/scaffolds/notis-affiliate-prospects/src/dev-main.tsx +0 -72
  161. package/dist/scaffolds/notis-affiliate-prospects/src/mock-runtime.ts +0 -242
  162. package/dist/scaffolds/notis-affiliate-prospects/tailwind.config.ts +0 -51
  163. package/dist/scaffolds/notis-affiliate-prospects/tsconfig.json +0 -23
  164. package/dist/scaffolds/notis-affiliate-prospects/vite.config.ts +0 -11
  165. /package/dist/scaffolds/{notis-affiliate-prospects → notis-database}/packages/sdk/src/components/MultiSelectCheckbox.tsx +0 -0
  166. /package/dist/scaffolds/{notis-affiliate-prospects → notis-database}/packages/sdk/src/components/MultiSelectDragOverlay.tsx +0 -0
  167. /package/dist/scaffolds/{notis-affiliate-prospects → notis-database}/packages/sdk/src/hooks/useBackend.ts +0 -0
  168. /package/dist/scaffolds/{notis-affiliate-prospects → notis-database}/packages/sdk/src/hooks/useNotis.ts +0 -0
  169. /package/dist/scaffolds/{notis-affiliate-prospects → notis-database}/packages/sdk/src/hooks/useNotisNavigation.ts +0 -0
  170. /package/dist/scaffolds/{notis-affiliate-prospects → notis-database}/packages/sdk/src/hooks/useTool.ts +0 -0
  171. /package/dist/scaffolds/{notis-affiliate-prospects → notis-database}/packages/sdk/src/hooks/useTools.ts +0 -0
  172. /package/dist/scaffolds/{notis-affiliate-prospects → notis-database}/packages/sdk/src/hooks/useTopBarSearch.ts +0 -0
  173. /package/dist/scaffolds/{notis-affiliate-prospects → notis-database}/packages/sdk/src/provider.tsx +0 -0
  174. /package/dist/scaffolds/{notis-affiliate-prospects → notis-database}/packages/sdk/src/ui.ts +0 -0
  175. /package/dist/scaffolds/{notis-affiliate-prospects → notis-database}/packages/sdk/src/vite.ts +0 -0
  176. /package/dist/scaffolds/{notis-affiliate-prospects → notis-database}/packages/sdk/tsconfig.json +0 -0
  177. /package/dist/scaffolds/{notis-affiliate-prospects → notis-random}/components.json +0 -0
@@ -1,17 +1,20 @@
1
1
  {
2
2
  "name": "@notis-apps/notis-random",
3
3
  "version": "0.1.0",
4
- "notisAppVersion": "0.1.0",
4
+ "notisAppVersion": "0.2.1",
5
5
  "private": true,
6
6
  "type": "module",
7
7
  "scripts": {
8
8
  "build": "vite build",
9
9
  "dev": "vite",
10
+ "test": "tsx --test lib/rng.test.ts lib/roll-record.test.ts",
10
11
  "typecheck": "tsc --noEmit"
11
12
  },
12
13
  "dependencies": {
13
- "@notis/sdk": "file:../../packages/sdk",
14
+ "@notis/sdk": "file:./packages/sdk",
14
15
  "@phosphor-icons/react": "^2.1.10",
16
+ "@radix-ui/react-slot": "^1.1.0",
17
+ "class-variance-authority": "^0.7.0",
15
18
  "clsx": "^2.1.1",
16
19
  "react": "^19.0.0",
17
20
  "react-dom": "^19.0.0",
@@ -26,6 +29,7 @@
26
29
  "postcss": "^8.4.0",
27
30
  "tailwindcss": "^3.4.0",
28
31
  "tailwindcss-animate": "^1.0.7",
32
+ "tsx": "^4.21.0",
29
33
  "typescript": "^5.5.0",
30
34
  "vite": "^6.0.0"
31
35
  }
@@ -0,0 +1,36 @@
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
+ "dependencies": {
21
+ "react-markdown": "^10.1.0",
22
+ "remark-gfm": "^4.0.1"
23
+ },
24
+ "peerDependencies": {
25
+ "react": ">=18.0.0",
26
+ "react-dom": ">=18.0.0",
27
+ "vite": ">=5.0.0",
28
+ "@vitejs/plugin-react": ">=4.0.0"
29
+ },
30
+ "devDependencies": {
31
+ "@types/node": "^20.0.0",
32
+ "@types/react": "^19.0.0",
33
+ "@types/react-dom": "^19.0.0",
34
+ "typescript": "^5.0.0"
35
+ }
36
+ }
@@ -0,0 +1,93 @@
1
+ 'use client';
2
+
3
+ import type { CSSProperties, ReactElement } from 'react';
4
+ import { useNotisRuntime } from '../provider';
5
+ import { useDocument } from '../hooks/useDocument';
6
+ import { Markdown } from './Markdown';
7
+ import type { NotisDocumentEditorProps } from '../runtime';
8
+
9
+ const fallbackNoticeStyle: CSSProperties = {
10
+ marginTop: '0.75rem',
11
+ fontSize: '12px',
12
+ color: 'hsl(var(--muted-foreground))',
13
+ };
14
+
15
+ const fallbackFrameStyle: CSSProperties = {
16
+ borderRadius: '0.5rem',
17
+ border: '1px dashed hsl(var(--border))',
18
+ padding: '1rem',
19
+ fontSize: '13px',
20
+ color: 'hsl(var(--muted-foreground))',
21
+ };
22
+
23
+ const fallbackTitleStyle: CSSProperties = {
24
+ margin: '0 0 0.75rem',
25
+ fontSize: '1.5rem',
26
+ fontWeight: 700,
27
+ letterSpacing: '-0.01em',
28
+ color: 'hsl(var(--foreground))',
29
+ };
30
+
31
+ /**
32
+ * Read-only stand-in used when no host editor is available (standalone dev
33
+ * harness, snapshots). Markdown content renders via `Markdown`; other content
34
+ * types get a typed placeholder.
35
+ */
36
+ function DocumentEditorFallback({ documentId, variant = 'full', className }: NotisDocumentEditorProps) {
37
+ const runtime = useNotisRuntime();
38
+ const { document, loading, error } = useDocument(documentId);
39
+ // Listing screenshots should show the app as it looks in the portal, so the
40
+ // harness-only editing notice stays out of scenario captures.
41
+ const isScreenshot = Boolean(runtime?.context?.screenshotScenario);
42
+
43
+ if (loading) {
44
+ return <div className={className} style={fallbackFrameStyle}>Loading document…</div>;
45
+ }
46
+ if (error || !document) {
47
+ return (
48
+ <div className={className} style={fallbackFrameStyle}>
49
+ {error?.message ?? 'Document not found.'}
50
+ </div>
51
+ );
52
+ }
53
+
54
+ const isMarkdown = document.contentType !== 'file';
55
+ return (
56
+ <div className={className}>
57
+ {variant === 'full' ? <h1 style={fallbackTitleStyle}>{document.title}</h1> : null}
58
+ {isMarkdown ? (
59
+ <>
60
+ <Markdown value={document.contentMarkdown ?? ''} />
61
+ {isScreenshot ? null : (
62
+ <p style={fallbackNoticeStyle}>Read-only preview — editing is available inside the Notis portal.</p>
63
+ )}
64
+ </>
65
+ ) : (
66
+ <div style={fallbackFrameStyle}>
67
+ {document.fileType ? `${document.fileType.toUpperCase()} document` : 'File document'} — open it in
68
+ the Notis portal to view.
69
+ </div>
70
+ )}
71
+ </div>
72
+ );
73
+ }
74
+
75
+ /**
76
+ * Embeds the document editor for a document anywhere in an app view. The host
77
+ * (portal) provides the implementation through `runtime.ui.DocumentEditor` and
78
+ * dispatches on the document's content type (markdown -> rich text editor,
79
+ * files -> matching viewer). Outside the portal this falls back to a read-only
80
+ * preview.
81
+ *
82
+ * ```tsx
83
+ * <DocumentEditor documentId={entry.id} variant="body" className="min-h-[320px]" />
84
+ * ```
85
+ */
86
+ export function DocumentEditor(props: NotisDocumentEditorProps): ReactElement {
87
+ const runtime = useNotisRuntime();
88
+ const HostEditor = runtime?.ui?.DocumentEditor;
89
+ if (HostEditor) {
90
+ return <HostEditor {...props} />;
91
+ }
92
+ return <DocumentEditorFallback {...props} />;
93
+ }
@@ -0,0 +1,60 @@
1
+ 'use client';
2
+
3
+ import type { AnchorHTMLAttributes, ReactElement } from 'react';
4
+ import ReactMarkdown, { type Components } from 'react-markdown';
5
+ import remarkGfm from 'remark-gfm';
6
+
7
+ export interface MarkdownProps {
8
+ /** Markdown source to render. */
9
+ value: string;
10
+ /** Typography scale. 'sm' suits dense surfaces (cards, list rows). */
11
+ size?: 'sm' | 'base';
12
+ className?: string;
13
+ /** Per-element overrides, passed through to react-markdown. */
14
+ components?: Components;
15
+ }
16
+
17
+ function MarkdownLink({
18
+ href,
19
+ children,
20
+ node: _node,
21
+ ...rest
22
+ }: AnchorHTMLAttributes<HTMLAnchorElement> & { node?: unknown }) {
23
+ const isExternal = typeof href === 'string' && /^https?:\/\//i.test(href);
24
+ return (
25
+ <a
26
+ href={href}
27
+ {...(isExternal ? { target: '_blank', rel: 'noreferrer noopener' } : {})}
28
+ {...rest}
29
+ >
30
+ {children}
31
+ </a>
32
+ );
33
+ }
34
+
35
+ const defaultComponents: Components = {
36
+ a: MarkdownLink,
37
+ };
38
+
39
+ /**
40
+ * Renders a markdown value with Notis typography. Markdown is a value type:
41
+ * use this anywhere markdown appears — document content, database fields,
42
+ * generated text. Styling comes from `.notis-markdown` rules in the SDK
43
+ * stylesheet and follows the portal theme variables.
44
+ */
45
+ export function Markdown({ value, size = 'base', className, components }: MarkdownProps): ReactElement {
46
+ const classes = ['notis-markdown', size === 'sm' ? 'notis-markdown--sm' : null, className]
47
+ .filter(Boolean)
48
+ .join(' ');
49
+
50
+ return (
51
+ <div className={classes}>
52
+ <ReactMarkdown
53
+ remarkPlugins={[remarkGfm]}
54
+ components={components ? { ...defaultComponents, ...components } : defaultComponents}
55
+ >
56
+ {value}
57
+ </ReactMarkdown>
58
+ </div>
59
+ );
60
+ }
@@ -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
+ }