@trypattern/sdk 0.0.0-stage → 0.1.0

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 (247) hide show
  1. package/README.md +127 -2
  2. package/dist/access.d.ts +31 -0
  3. package/dist/access.js +72 -0
  4. package/dist/actions.d.ts +57 -0
  5. package/dist/actions.js +198 -0
  6. package/dist/api.d.ts +20 -0
  7. package/dist/api.js +34 -0
  8. package/dist/app.d.ts +106 -0
  9. package/dist/app.js +224 -0
  10. package/dist/appearance.d.ts +7 -0
  11. package/dist/appearance.js +2 -0
  12. package/dist/auth/sessionApi.d.ts +41 -0
  13. package/dist/auth/sessionApi.js +158 -0
  14. package/dist/auth/sessionStore.d.ts +20 -0
  15. package/dist/auth/sessionStore.js +40 -0
  16. package/dist/auth/user.d.ts +11 -0
  17. package/dist/auth/user.js +9 -0
  18. package/dist/builtins/Account.d.ts +25 -0
  19. package/dist/builtins/Account.js +15 -0
  20. package/dist/builtins/Palette.d.ts +29 -0
  21. package/dist/builtins/Palette.js +63 -0
  22. package/dist/builtins/SignIn.d.ts +28 -0
  23. package/dist/builtins/SignIn.js +60 -0
  24. package/dist/builtins/Toasts.d.ts +32 -0
  25. package/dist/builtins/Toasts.js +24 -0
  26. package/dist/builtins/actions.d.ts +2 -0
  27. package/dist/builtins/actions.js +45 -0
  28. package/dist/cache.d.ts +24 -0
  29. package/dist/cache.js +112 -0
  30. package/dist/cli/app.d.ts +2 -0
  31. package/dist/cli/app.js +1329 -0
  32. package/dist/cli/screenshot.d.ts +1 -0
  33. package/dist/cli/screenshot.js +96 -0
  34. package/dist/cli/tools.d.ts +12 -0
  35. package/dist/cli/tools.js +35 -0
  36. package/dist/components/AppFrame.d.ts +14 -0
  37. package/dist/components/AppFrame.js +64 -0
  38. package/dist/components/AppearancePicker.d.ts +1 -0
  39. package/dist/components/AppearancePicker.js +12 -0
  40. package/dist/components/Avatar.d.ts +9 -0
  41. package/dist/components/Avatar.js +63 -0
  42. package/dist/components/Badge.d.ts +11 -0
  43. package/dist/components/Badge.js +87 -0
  44. package/dist/components/Button.d.ts +23 -0
  45. package/dist/components/Button.js +249 -0
  46. package/dist/components/Card.d.ts +12 -0
  47. package/dist/components/Card.js +38 -0
  48. package/dist/components/CommandMenu.d.ts +23 -0
  49. package/dist/components/CommandMenu.js +214 -0
  50. package/dist/components/CommandPalette.d.ts +1 -0
  51. package/dist/components/CommandPalette.js +7 -0
  52. package/dist/components/Content.d.ts +7 -0
  53. package/dist/components/Content.js +24 -0
  54. package/dist/components/ContextMenu.d.ts +8 -0
  55. package/dist/components/ContextMenu.js +23 -0
  56. package/dist/components/Dialog.d.ts +11 -0
  57. package/dist/components/Dialog.js +81 -0
  58. package/dist/components/Divider.d.ts +6 -0
  59. package/dist/components/Divider.js +15 -0
  60. package/dist/components/EmptyState.d.ts +8 -0
  61. package/dist/components/EmptyState.js +24 -0
  62. package/dist/components/Form.d.ts +9 -0
  63. package/dist/components/Form.js +23 -0
  64. package/dist/components/Icon.d.ts +10 -0
  65. package/dist/components/Icon.js +22 -0
  66. package/dist/components/IconButton.d.ts +14 -0
  67. package/dist/components/IconButton.js +53 -0
  68. package/dist/components/Kbd.d.ts +6 -0
  69. package/dist/components/Kbd.js +67 -0
  70. package/dist/components/Link.d.ts +9 -0
  71. package/dist/components/Link.js +35 -0
  72. package/dist/components/ListRow.d.ts +12 -0
  73. package/dist/components/ListRow.js +62 -0
  74. package/dist/components/LoadingRows.d.ts +5 -0
  75. package/dist/components/LoadingRows.js +6 -0
  76. package/dist/components/Menu.d.ts +12 -0
  77. package/dist/components/Menu.js +33 -0
  78. package/dist/components/MenuItems.d.ts +21 -0
  79. package/dist/components/MenuItems.js +32 -0
  80. package/dist/components/Placement.d.ts +21 -0
  81. package/dist/components/Placement.js +1 -0
  82. package/dist/components/Popup.d.ts +8 -0
  83. package/dist/components/Popup.js +43 -0
  84. package/dist/components/PopupItem.d.ts +8 -0
  85. package/dist/components/PopupItem.js +51 -0
  86. package/dist/components/PropertyRow.d.ts +7 -0
  87. package/dist/components/PropertyRow.js +23 -0
  88. package/dist/components/Row.d.ts +16 -0
  89. package/dist/components/Row.js +27 -0
  90. package/dist/components/Screen.d.ts +13 -0
  91. package/dist/components/Screen.js +56 -0
  92. package/dist/components/Scrim.d.ts +8 -0
  93. package/dist/components/Scrim.js +40 -0
  94. package/dist/components/ScrollArea.d.ts +15 -0
  95. package/dist/components/ScrollArea.js +13 -0
  96. package/dist/components/SegmentedControl.d.ts +17 -0
  97. package/dist/components/SegmentedControl.js +68 -0
  98. package/dist/components/Select.d.ts +17 -0
  99. package/dist/components/Select.js +107 -0
  100. package/dist/components/SettingsRow.d.ts +8 -0
  101. package/dist/components/SettingsRow.js +32 -0
  102. package/dist/components/Sidebar.d.ts +20 -0
  103. package/dist/components/Sidebar.js +138 -0
  104. package/dist/components/SignInScreen.d.ts +1 -0
  105. package/dist/components/SignInScreen.js +40 -0
  106. package/dist/components/Size.d.ts +1 -0
  107. package/dist/components/Size.js +1 -0
  108. package/dist/components/Skeleton.d.ts +8 -0
  109. package/dist/components/Skeleton.js +48 -0
  110. package/dist/components/Spinner.d.ts +6 -0
  111. package/dist/components/Spinner.js +54 -0
  112. package/dist/components/Stack.d.ts +14 -0
  113. package/dist/components/Stack.js +19 -0
  114. package/dist/components/Switch.d.ts +10 -0
  115. package/dist/components/Switch.js +71 -0
  116. package/dist/components/Text.d.ts +21 -0
  117. package/dist/components/Text.js +77 -0
  118. package/dist/components/TextField.d.ts +25 -0
  119. package/dist/components/TextField.js +68 -0
  120. package/dist/components/Toaster.d.ts +1 -0
  121. package/dist/components/Toaster.js +83 -0
  122. package/dist/components/Tooltip.d.ts +8 -0
  123. package/dist/components/Tooltip.js +43 -0
  124. package/dist/components/controlLook.d.ts +60 -0
  125. package/dist/components/controlLook.js +67 -0
  126. package/dist/components/frame.d.ts +4 -0
  127. package/dist/components/frame.js +2 -0
  128. package/dist/components/icons.d.ts +58 -0
  129. package/dist/components/icons.js +105 -0
  130. package/dist/components/interaction.d.ts +12 -0
  131. package/dist/components/interaction.js +22 -0
  132. package/dist/components/spacing.d.ts +118 -0
  133. package/dist/components/spacing.js +46 -0
  134. package/dist/components/tones.d.ts +28 -0
  135. package/dist/components/tones.js +12 -0
  136. package/dist/entityStore.d.ts +46 -0
  137. package/dist/entityStore.js +160 -0
  138. package/dist/flows/accessFlows.d.ts +9 -0
  139. package/dist/flows/accessFlows.js +151 -0
  140. package/dist/flows/browser.d.ts +32 -0
  141. package/dist/flows/browser.js +164 -0
  142. package/dist/flows/contactSheet.d.ts +1 -0
  143. package/dist/flows/contactSheet.js +63 -0
  144. package/dist/flows/flowBrowser.d.ts +23 -0
  145. package/dist/flows/flowBrowser.js +21 -0
  146. package/dist/flows/flowSetup.d.ts +3 -0
  147. package/dist/flows/flowSetup.js +35 -0
  148. package/dist/flows/flows.d.ts +41 -0
  149. package/dist/flows/flows.js +148 -0
  150. package/dist/flows/screenshotName.d.ts +1 -0
  151. package/dist/flows/screenshotName.js +6 -0
  152. package/dist/gate.d.ts +8 -0
  153. package/dist/gate.js +52 -0
  154. package/dist/hooks/appContext.d.ts +14 -0
  155. package/dist/hooks/appContext.js +5 -0
  156. package/dist/hooks/appHooks.d.ts +21 -0
  157. package/dist/hooks/appHooks.js +24 -0
  158. package/dist/hooks/useAnimatesOnChange.d.ts +1 -0
  159. package/dist/hooks/useAnimatesOnChange.js +14 -0
  160. package/dist/hooks/useStoreState.d.ts +6 -0
  161. package/dist/hooks/useStoreState.js +5 -0
  162. package/dist/index.d.ts +40 -0
  163. package/dist/index.js +19 -0
  164. package/dist/memoryApi.d.ts +19 -0
  165. package/dist/memoryApi.js +42 -0
  166. package/dist/model.d.ts +94 -0
  167. package/dist/model.js +243 -0
  168. package/dist/page.d.ts +11 -0
  169. package/dist/page.js +9 -0
  170. package/dist/platform.d.ts +1 -0
  171. package/dist/platform.js +5 -0
  172. package/dist/react.d.ts +46 -0
  173. package/dist/react.js +38 -0
  174. package/dist/registered.d.ts +54 -0
  175. package/dist/registered.js +17 -0
  176. package/dist/routes.d.ts +38 -0
  177. package/dist/routes.js +21 -0
  178. package/dist/rules/checkAllFiles.d.ts +1 -0
  179. package/dist/rules/checkAllFiles.js +741 -0
  180. package/dist/rules/checkApiRouting.d.ts +1 -0
  181. package/dist/rules/checkApiRouting.js +112 -0
  182. package/dist/rules/lintPlugin.d.ts +252 -0
  183. package/dist/rules/lintPlugin.js +1157 -0
  184. package/dist/rules/messages.d.ts +48 -0
  185. package/dist/rules/messages.js +48 -0
  186. package/dist/rules/themeTokens.d.ts +6 -0
  187. package/dist/rules/themeTokens.js +64 -0
  188. package/dist/schema.d.ts +2 -0
  189. package/dist/schema.js +1 -0
  190. package/dist/server/auth.d.ts +115 -0
  191. package/dist/server/auth.js +131 -0
  192. package/dist/server/authService.d.ts +9 -0
  193. package/dist/server/authService.js +50 -0
  194. package/dist/server/createServer.d.ts +357 -0
  195. package/dist/server/createServer.js +62 -0
  196. package/dist/server/env.d.ts +15 -0
  197. package/dist/server/env.js +1 -0
  198. package/dist/server/index.d.ts +8 -0
  199. package/dist/server/index.js +5 -0
  200. package/dist/server/session.d.ts +28 -0
  201. package/dist/server/session.js +54 -0
  202. package/dist/server/sessions.d.ts +92 -0
  203. package/dist/server/sessions.js +47 -0
  204. package/dist/server/signInWire.d.ts +52 -0
  205. package/dist/server/signInWire.js +22 -0
  206. package/dist/server/tables.d.ts +242 -0
  207. package/dist/server/tables.js +246 -0
  208. package/dist/server/users.d.ts +189 -0
  209. package/dist/server/users.js +49 -0
  210. package/dist/shortcuts.d.ts +3 -0
  211. package/dist/shortcuts.js +40 -0
  212. package/dist/start.d.ts +20 -0
  213. package/dist/start.js +121 -0
  214. package/dist/state.d.ts +14 -0
  215. package/dist/state.js +17 -0
  216. package/dist/store.d.ts +43 -0
  217. package/dist/store.js +198 -0
  218. package/dist/subscribers.d.ts +5 -0
  219. package/dist/subscribers.js +13 -0
  220. package/dist/table.d.ts +143 -0
  221. package/dist/table.js +91 -0
  222. package/dist/tables.d.ts +77 -0
  223. package/dist/tables.js +216 -0
  224. package/dist/theme/reset.css +84 -0
  225. package/dist/theme/scales.d.ts +76 -0
  226. package/dist/theme/scales.js +82 -0
  227. package/dist/theme/tokens.stylex.d.ts +218 -0
  228. package/dist/theme/tokens.stylex.js +233 -0
  229. package/dist/vite/commandBridge.d.ts +2 -0
  230. package/dist/vite/commandBridge.js +46 -0
  231. package/dist/vite/designManifest.d.ts +25 -0
  232. package/dist/vite/designManifest.js +191 -0
  233. package/dist/vite/localWorker.d.ts +4 -0
  234. package/dist/vite/localWorker.js +59 -0
  235. package/dist/vite/rootAlias.d.ts +2 -0
  236. package/dist/vite/rootAlias.js +15 -0
  237. package/dist/vite/vite.d.ts +7 -0
  238. package/dist/vite/vite.js +88 -0
  239. package/dist/wire.d.ts +7 -0
  240. package/dist/wire.js +1 -0
  241. package/package.json +99 -3
  242. package/presets/lintPlugin.js +7 -0
  243. package/presets/oxlint.json +167 -0
  244. package/presets/register.d.ts +19 -0
  245. package/presets/server.d.ts +2 -0
  246. package/presets/tsconfig.app.json +29 -0
  247. package/presets/tsconfig.server.json +27 -0
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,96 @@
1
+ import { mkdirSync, writeFileSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { launchChrome, openApp, viewportNames, viewports } from "../flows/browser.js";
4
+ const ROOT = process.cwd();
5
+ const SCREENSHOTS_DIRECTORY = join(ROOT, '.dev', 'screenshots');
6
+ function readRequest() {
7
+ const parsed = JSON.parse(process.argv[2] ?? '');
8
+ if (typeof parsed !== 'object' ||
9
+ parsed === null ||
10
+ !('url' in parsed) ||
11
+ !('path' in parsed) ||
12
+ !('name' in parsed) ||
13
+ !('commands' in parsed) ||
14
+ !('signedInAs' in parsed) ||
15
+ (typeof parsed.signedInAs !== 'string' && parsed.signedInAs !== null) ||
16
+ typeof parsed.url !== 'string' ||
17
+ typeof parsed.path !== 'string' ||
18
+ typeof parsed.name !== 'string' ||
19
+ !Array.isArray(parsed.commands)) {
20
+ throw new Error('screenshot.ts expects {url, path, name, commands, signedInAs} JSON');
21
+ }
22
+ return {
23
+ url: parsed.url,
24
+ path: parsed.path,
25
+ name: parsed.name,
26
+ commands: parsed.commands,
27
+ signedInAs: parsed.signedInAs
28
+ };
29
+ }
30
+ async function captureAll(browser, request) {
31
+ const [first = 'desktop'] = viewportNames;
32
+ const app = await openApp(browser, request.url, request.path, first, request.signedInAs);
33
+ try {
34
+ let snapshot = await app.snapshot();
35
+ let commandError;
36
+ for (const command of request.commands) {
37
+ try {
38
+ snapshot = await app.send(command);
39
+ }
40
+ catch (error) {
41
+ commandError = `command ${JSON.stringify(command)} failed: ${error instanceof Error ? error.message : String(error)}`;
42
+ break;
43
+ }
44
+ }
45
+ const shots = [];
46
+ for (const viewport of viewportNames) {
47
+ const seenBefore = app.problems.length;
48
+ const file = join(SCREENSHOTS_DIRECTORY, `${request.name}-${viewport}.png`);
49
+ writeFileSync(file, Buffer.from(await app.captureAt(viewport), 'base64'));
50
+ const problems = [
51
+ ...(commandError === undefined ? [] : [commandError]),
52
+ ...(viewport === first ? app.problems : app.problems.slice(seenBefore))
53
+ ];
54
+ shots.push({ viewport, ...viewports[viewport], file, snapshot, problems });
55
+ }
56
+ return shots;
57
+ }
58
+ finally {
59
+ await app.close();
60
+ }
61
+ }
62
+ async function main() {
63
+ try {
64
+ const request = readRequest();
65
+ mkdirSync(SCREENSHOTS_DIRECTORY, { recursive: true });
66
+ const browser = await launchChrome();
67
+ const shots = await captureAll(browser, request).finally(() => browser.close());
68
+ const viewportsByProblem = new Map();
69
+ for (const shot of shots) {
70
+ for (const problem of shot.problems) {
71
+ viewportsByProblem.set(problem, [
72
+ ...(viewportsByProblem.get(problem) ?? []),
73
+ shot.viewport
74
+ ]);
75
+ }
76
+ }
77
+ const result = {
78
+ screenshots: shots.map(({ viewport, width, height, file }) => ({
79
+ viewport,
80
+ width,
81
+ height,
82
+ file
83
+ })),
84
+ snapshot: shots[0]?.snapshot ?? null,
85
+ problems: [...viewportsByProblem].map(([message, seenIn]) => ({
86
+ message,
87
+ viewports: seenIn
88
+ }))
89
+ };
90
+ process.stdout.write(`${JSON.stringify(result)}\n`);
91
+ }
92
+ catch (error) {
93
+ process.stdout.write(`${JSON.stringify({ error: error instanceof Error ? error.message : String(error) })}\n`);
94
+ }
95
+ }
96
+ await main();
@@ -0,0 +1,12 @@
1
+ declare const TOOLS: {
2
+ readonly tsc: readonly ["typescript", "tsc"];
3
+ readonly oxlint: readonly ["oxlint", "oxlint"];
4
+ readonly prettier: readonly ["prettier", "prettier"];
5
+ readonly vite: readonly ["vite", "vite"];
6
+ readonly vitest: readonly ["vitest", "vitest"];
7
+ readonly wrangler: readonly ["wrangler", "wrangler"];
8
+ readonly 'drizzle-kit': readonly ["drizzle-kit", "drizzle-kit"];
9
+ };
10
+ export type Tool = keyof typeof TOOLS;
11
+ export declare function toolBin(tool: Tool): string;
12
+ export {};
@@ -0,0 +1,35 @@
1
+ import { existsSync, readFileSync } from 'node:fs';
2
+ import { createRequire } from 'node:module';
3
+ import { dirname, join } from 'node:path';
4
+ const require = createRequire(import.meta.url);
5
+ const TOOLS = {
6
+ tsc: ['typescript', 'tsc'],
7
+ oxlint: ['oxlint', 'oxlint'],
8
+ prettier: ['prettier', 'prettier'],
9
+ vite: ['vite', 'vite'],
10
+ vitest: ['vitest', 'vitest'],
11
+ wrangler: ['wrangler', 'wrangler'],
12
+ 'drizzle-kit': ['drizzle-kit', 'drizzle-kit']
13
+ };
14
+ export function toolBin(tool) {
15
+ const [name, bin] = TOOLS[tool];
16
+ const manifest = (require.resolve.paths(name) ?? [])
17
+ .map((directory) => join(directory, name, 'package.json'))
18
+ .find((path) => existsSync(path));
19
+ if (manifest === undefined) {
20
+ throw new Error(`${name} is not installed`);
21
+ }
22
+ const parsed = JSON.parse(readFileSync(manifest, 'utf8'));
23
+ const bins = typeof parsed === 'object' && parsed !== null && 'bin' in parsed
24
+ ? parsed.bin
25
+ : undefined;
26
+ const path = typeof bins === 'string'
27
+ ? bins
28
+ : typeof bins === 'object' && bins !== null
29
+ ? Reflect.get(bins, bin)
30
+ : undefined;
31
+ if (typeof path !== 'string') {
32
+ throw new Error(`${name} has no ${bin} command`);
33
+ }
34
+ return join(dirname(manifest), path);
35
+ }
@@ -0,0 +1,14 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { MenuEntry } from './MenuItems.tsx';
3
+ import type { SidebarLink } from './Sidebar.tsx';
4
+ type AppFrameProps = {
5
+ links: readonly SidebarLink[];
6
+ workspaceMenu?: readonly MenuEntry[];
7
+ isSidebarToggled: boolean;
8
+ onToggleSidebar: () => void;
9
+ onCloseSidebar: () => void;
10
+ onSearch?: () => void;
11
+ children: ReactNode;
12
+ };
13
+ export declare function AppFrame({ links, workspaceMenu, isSidebarToggled, onToggleSidebar, onCloseSidebar, onSearch, children }: AppFrameProps): import("react").JSX.Element;
14
+ export {};
@@ -0,0 +1,64 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as stylex from '@stylexjs/stylex';
3
+ import { breakpoints, colors, radii, shadows, space } from "../theme/tokens.stylex.js";
4
+ import { useApp, useModel } from "../hooks/appContext.js";
5
+ import { FrameContext } from "./frame.js";
6
+ import { Scrim } from "./Scrim.js";
7
+ import { Sidebar } from "./Sidebar.js";
8
+ import { useAnimatesOnChange } from "../hooks/useAnimatesOnChange.js";
9
+ export function AppFrame({ links, workspaceMenu = [], isSidebarToggled, onToggleSidebar, onCloseSidebar, onSearch, children }) {
10
+ const app = useApp();
11
+ const account = useModel('account');
12
+ const menu = account.user === null
13
+ ? workspaceMenu
14
+ : [
15
+ ...workspaceMenu,
16
+ ...(workspaceMenu.length > 0 ? ['separator'] : []),
17
+ { id: 'signOut', label: 'Log out', onSelect: account.signOut }
18
+ ];
19
+ const isSidebarAnimating = useAnimatesOnChange(isSidebarToggled, SIDEBAR_ANIMATION_MS);
20
+ return (_jsx(FrameContext, { value: { onToggleSidebar }, children: _jsxs("div", { ...stylex.props(styles.frame), children: [_jsx(Sidebar, { workspace: app.name, workspaceMenu: menu, links: links, isToggled: isSidebarToggled, isAnimating: isSidebarAnimating, onFollowLink: onCloseSidebar, onSearch: onSearch === undefined
21
+ ? undefined
22
+ : () => {
23
+ onCloseSidebar();
24
+ onSearch();
25
+ } }), _jsx(Scrim, { label: "Close sidebar", isOpen: isSidebarToggled, isAnimating: isSidebarAnimating, onClose: onCloseSidebar }), _jsx("main", { ...stylex.props(styles.panel, isSidebarToggled && styles.panelAlone), children: children })] }) }));
26
+ }
27
+ const SIDEBAR_ANIMATION_MS = 400;
28
+ const styles = stylex.create({
29
+ frame: {
30
+ display: 'flex',
31
+ height: '100%',
32
+ backgroundColor: colors.shell
33
+ },
34
+ panel: {
35
+ display: 'flex',
36
+ flexGrow: 1,
37
+ flexDirection: 'column',
38
+ minWidth: 0,
39
+ marginBlock: {
40
+ default: space.xs,
41
+ [breakpoints.compact]: 0
42
+ },
43
+ marginInlineEnd: {
44
+ default: space.xs,
45
+ [breakpoints.compact]: 0
46
+ },
47
+ overflow: 'hidden',
48
+ backgroundColor: colors.containerRecessed,
49
+ borderRadius: {
50
+ default: radii.xxxl,
51
+ [breakpoints.compact]: 0
52
+ },
53
+ boxShadow: {
54
+ default: shadows.default,
55
+ [breakpoints.compact]: null
56
+ }
57
+ },
58
+ panelAlone: {
59
+ marginInlineStart: {
60
+ default: space.xs,
61
+ [breakpoints.compact]: 0
62
+ }
63
+ }
64
+ });
@@ -0,0 +1 @@
1
+ export declare function AppearancePicker(): import("react").JSX.Element;
@@ -0,0 +1,12 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useModel } from "../hooks/appContext.js";
3
+ import { SegmentedControl } from "./SegmentedControl.js";
4
+ export function AppearancePicker() {
5
+ const account = useModel('account');
6
+ return (_jsx(SegmentedControl, { label: "Appearance", value: account.appearance, options: options, onChange: (appearance) => account.setAppearance({ appearance }) }));
7
+ }
8
+ const options = [
9
+ { value: 'system', label: 'System' },
10
+ { value: 'light', label: 'Light' },
11
+ { value: 'dark', label: 'Dark' }
12
+ ];
@@ -0,0 +1,9 @@
1
+ import type { Placement } from './Placement.ts';
2
+ type AvatarProps = {
3
+ name: string;
4
+ imageUrl?: string | null;
5
+ size?: 'sm' | 'md' | 'lg';
6
+ style?: Placement;
7
+ };
8
+ export declare function Avatar({ name, imageUrl, size, style }: AvatarProps): import("react").JSX.Element;
9
+ export {};
@@ -0,0 +1,63 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Avatar as BaseAvatar } from '@base-ui/react/avatar';
3
+ import * as stylex from '@stylexjs/stylex';
4
+ import { borders, colors, fontSizes, fontWeights, lineHeights, radii } from "../theme/tokens.stylex.js";
5
+ export function Avatar({ name, imageUrl = null, size = 'md', style }) {
6
+ return (_jsxs(BaseAvatar.Root, { className: stylex.props(styles.avatar, sizes[size], style).className, children: [imageUrl === null ? null : (_jsx(BaseAvatar.Image, { src: imageUrl, alt: "", className: stylex.props(styles.image).className })), _jsx(BaseAvatar.Fallback, { className: stylex.props(styles.fallback).className, children: initialsOf(name) })] }));
7
+ }
8
+ function initialsOf(name) {
9
+ return name
10
+ .split(/\s+/)
11
+ .filter((word) => word !== '')
12
+ .slice(0, 2)
13
+ .map((word) => word.charAt(0).toUpperCase())
14
+ .join('');
15
+ }
16
+ const styles = stylex.create({
17
+ avatar: {
18
+ position: 'relative',
19
+ display: 'flex',
20
+ flexShrink: 0,
21
+ overflow: 'hidden',
22
+ fontWeight: fontWeights.semimedium,
23
+ outlineWidth: borders.hairline,
24
+ outlineStyle: 'solid',
25
+ outlineColor: colors.borderDefault,
26
+ outlineOffset: `calc(-1 * ${borders.hairline})`,
27
+ backgroundColor: colors.component,
28
+ borderRadius: radii.full
29
+ },
30
+ image: {
31
+ width: '100%',
32
+ height: '100%',
33
+ objectFit: 'cover'
34
+ },
35
+ fallback: {
36
+ display: 'flex',
37
+ alignItems: 'center',
38
+ justifyContent: 'center',
39
+ width: '100%',
40
+ height: '100%',
41
+ color: colors.secondaryForeground
42
+ }
43
+ });
44
+ const sizes = stylex.create({
45
+ sm: {
46
+ width: lineHeights.caption,
47
+ height: lineHeights.caption,
48
+ fontSize: fontSizes.captionXs,
49
+ lineHeight: lineHeights.captionXs
50
+ },
51
+ md: {
52
+ width: lineHeights.bodySm,
53
+ height: lineHeights.bodySm,
54
+ fontSize: fontSizes.captionXs,
55
+ lineHeight: lineHeights.captionXs
56
+ },
57
+ lg: {
58
+ width: lineHeights.body,
59
+ height: lineHeights.body,
60
+ fontSize: fontSizes.bodySm,
61
+ lineHeight: lineHeights.caption
62
+ }
63
+ });
@@ -0,0 +1,11 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { Placement } from './Placement.ts';
3
+ type BadgeProps = {
4
+ children: ReactNode;
5
+ variant?: 'primary' | 'tertiary' | 'outline' | 'transparent';
6
+ tone?: 'neutral' | 'brand' | 'danger';
7
+ size?: 'sm' | 'md';
8
+ style?: Placement;
9
+ };
10
+ export declare function Badge({ children, variant, tone, size, style }: BadgeProps): import("react").JSX.Element;
11
+ export {};
@@ -0,0 +1,87 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import * as stylex from '@stylexjs/stylex';
3
+ import { borders, colors, controls, fontSizes, lineHeights, radii, space } from "../theme/tokens.stylex.js";
4
+ export function Badge({ children, variant = 'tertiary', tone = 'neutral', size = 'md', style }) {
5
+ return (_jsx("span", { ...stylex.props(styles.badge, sizes[size], looks[`${variant}${toneKeys[tone]}`], style), children: children }));
6
+ }
7
+ const toneKeys = {
8
+ neutral: 'Neutral',
9
+ brand: 'Brand',
10
+ danger: 'Danger'
11
+ };
12
+ const styles = stylex.create({
13
+ badge: {
14
+ display: 'inline-flex',
15
+ flexShrink: 0,
16
+ gap: space.xs,
17
+ alignItems: 'center',
18
+ justifyContent: 'center',
19
+ paddingInline: controls.paddingXs,
20
+ borderRadius: radii.sm
21
+ }
22
+ });
23
+ const sizes = stylex.create({
24
+ sm: {
25
+ height: lineHeights.caption,
26
+ fontSize: fontSizes.captionBase,
27
+ lineHeight: lineHeights.caption
28
+ },
29
+ md: {
30
+ height: lineHeights.bodySm,
31
+ fontSize: fontSizes.captionLg,
32
+ lineHeight: lineHeights.caption
33
+ }
34
+ });
35
+ const looks = stylex.create({
36
+ primaryNeutral: {
37
+ color: colors.onInvertedForeground,
38
+ backgroundColor: colors.invertedSolid
39
+ },
40
+ primaryBrand: {
41
+ color: colors.onBrandSolidForeground,
42
+ backgroundColor: colors.brandSolid
43
+ },
44
+ primaryDanger: {
45
+ color: colors.onDangerSolidForeground,
46
+ backgroundColor: colors.dangerSolid
47
+ },
48
+ tertiaryNeutral: {
49
+ color: colors.secondaryForeground,
50
+ backgroundColor: colors.component
51
+ },
52
+ tertiaryBrand: {
53
+ color: colors.onBrandSubtleForeground,
54
+ backgroundColor: colors.brandSubtle
55
+ },
56
+ tertiaryDanger: {
57
+ color: colors.dangerText,
58
+ backgroundColor: colors.dangerSubtleHover
59
+ },
60
+ outlineNeutral: {
61
+ color: colors.secondaryForeground,
62
+ backgroundColor: 'transparent',
63
+ boxShadow: `inset 0 0 0 ${borders.thin} ${colors.borderDefault}`
64
+ },
65
+ outlineBrand: {
66
+ color: colors.brandForeground,
67
+ backgroundColor: 'transparent',
68
+ boxShadow: `inset 0 0 0 ${borders.thin} ${colors.brandBorderDefault}`
69
+ },
70
+ outlineDanger: {
71
+ color: colors.dangerForeground,
72
+ backgroundColor: 'transparent',
73
+ boxShadow: `inset 0 0 0 ${borders.thin} ${colors.dangerBorderDefault}`
74
+ },
75
+ transparentNeutral: {
76
+ color: colors.secondaryForeground,
77
+ backgroundColor: 'transparent'
78
+ },
79
+ transparentBrand: {
80
+ color: colors.brandForeground,
81
+ backgroundColor: 'transparent'
82
+ },
83
+ transparentDanger: {
84
+ color: colors.dangerForeground,
85
+ backgroundColor: 'transparent'
86
+ }
87
+ });
@@ -0,0 +1,23 @@
1
+ import type { AppPath } from '../registered.ts';
2
+ import type { ReactNode } from 'react';
3
+ import type { IconName } from './icons.ts';
4
+ import type { Placement } from './Placement.ts';
5
+ import type { Size } from './Size.ts';
6
+ type ButtonProps = {
7
+ children: ReactNode;
8
+ variant?: 'primary' | 'secondary' | 'tertiary' | 'transparent';
9
+ tone?: 'neutral' | 'brand' | 'danger';
10
+ size?: Size;
11
+ to?: AppPath;
12
+ icon?: IconName;
13
+ trailingIcon?: IconName;
14
+ shortcut?: readonly string[];
15
+ type?: 'button' | 'submit';
16
+ disabled?: boolean;
17
+ isPending?: boolean;
18
+ isFullWidth?: boolean;
19
+ onClick?: () => void;
20
+ style?: Placement;
21
+ };
22
+ export declare function Button({ children, variant, tone, size, to, icon, trailingIcon, shortcut, type, disabled, isPending, isFullWidth, onClick, style }: ButtonProps): import("react").JSX.Element;
23
+ export {};