@polderlabs/bizar 6.3.0 → 7.0.1
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/.claude/hooks/sessionend-recall.mjs +3 -3
- package/.claude/hooks/worker-suggest.mjs +110 -0
- package/.claude/settings.json +9 -0
- package/README.md +125 -47
- package/bizar-dash/dist/assets/{EnvVarsSection-B58aiJiE.js → EnvVarsSection-weVnLz3Z.js} +3 -3
- package/bizar-dash/dist/assets/EnvVarsSection-weVnLz3Z.js.map +1 -0
- package/bizar-dash/dist/assets/MobileChat-BRFjer8p.js +1 -0
- package/bizar-dash/dist/assets/{MobileChat-BJrqwVDd.js.map → MobileChat-BRFjer8p.js.map} +1 -1
- package/bizar-dash/dist/assets/MobileSettings-Dw5jyJWi.js +1 -0
- package/bizar-dash/dist/assets/MobileSettings-Dw5jyJWi.js.map +1 -0
- package/bizar-dash/dist/assets/{Toast-Cpl6-E63.js → Toast-WTxc3m2g.js} +1 -1
- package/bizar-dash/dist/assets/{Toast-Cpl6-E63.js.map → Toast-WTxc3m2g.js.map} +1 -1
- package/bizar-dash/dist/assets/flow-BpU0-gK2.js +1 -0
- package/bizar-dash/dist/assets/flow-BpU0-gK2.js.map +1 -0
- package/bizar-dash/dist/assets/fuzzy-l0sNRNKZ.js +1 -0
- package/bizar-dash/dist/assets/fuzzy-l0sNRNKZ.js.map +1 -0
- package/bizar-dash/dist/assets/{icons-Do5N2jmX.js → icons-B0AKnYI3.js} +98 -103
- package/bizar-dash/dist/assets/icons-B0AKnYI3.js.map +1 -0
- package/bizar-dash/dist/assets/main-BE4Uh9im.css +1 -0
- package/bizar-dash/dist/assets/main-DqC58FEZ.js +18 -0
- package/bizar-dash/dist/assets/main-DqC58FEZ.js.map +1 -0
- package/bizar-dash/dist/assets/markdown-w2bDDkAH.js +1 -0
- package/bizar-dash/dist/assets/markdown-w2bDDkAH.js.map +1 -0
- package/bizar-dash/dist/assets/mobile-DRZsK3ic.js +1 -0
- package/bizar-dash/dist/assets/{mobile-DYCHcUpq.js.map → mobile-DRZsK3ic.js.map} +1 -1
- package/bizar-dash/dist/assets/mobile-layout-BWLtwtfQ.css +1 -0
- package/bizar-dash/dist/assets/mobile-layout-Ckru3HKJ.js +2 -0
- package/bizar-dash/dist/assets/mobile-layout-Ckru3HKJ.js.map +1 -0
- package/bizar-dash/dist/assets/react-vendor-BnuhLJ6X.css +1 -0
- package/bizar-dash/dist/assets/react-vendor-D3pra6w-.js +46 -0
- package/bizar-dash/dist/assets/react-vendor-D3pra6w-.js.map +1 -0
- package/bizar-dash/dist/assets/useSlashCommands-BAxVOU_a.js +2 -0
- package/bizar-dash/dist/assets/useSlashCommands-BAxVOU_a.js.map +1 -0
- package/bizar-dash/dist/assets/vendor-Di7Cp-rw.js +45 -0
- package/bizar-dash/dist/assets/vendor-Di7Cp-rw.js.map +1 -0
- package/bizar-dash/dist/index.html +13 -11
- package/bizar-dash/dist/mobile.html +8 -5
- package/bizar-dash/src/server/api.mjs +11 -0
- package/bizar-dash/src/server/memory-consolidator.mjs +225 -0
- package/bizar-dash/src/server/memory-distillation.mjs +296 -0
- package/bizar-dash/src/server/routes/distill.mjs +129 -0
- package/bizar-dash/src/server/routes/goal-planner.mjs +236 -0
- package/bizar-dash/src/web/App.tsx +4 -0
- package/bizar-dash/src/web/components/Tag.tsx +18 -5
- package/bizar-dash/src/web/components/Topbar.tsx +3 -0
- package/bizar-dash/src/web/components/agents/CommunicationLog.tsx +126 -0
- package/bizar-dash/src/web/components/agents/DependencyGraph.tsx +163 -0
- package/bizar-dash/src/web/components/agents/QualityGates.tsx +123 -0
- package/bizar-dash/src/web/components/agents/RealTimeEventLog.tsx +127 -0
- package/bizar-dash/src/web/components/agents/RoutingDecisions.test.tsx +148 -0
- package/bizar-dash/src/web/components/agents/RoutingDecisions.tsx +160 -0
- package/bizar-dash/src/web/components/goals/GoalInput.tsx +86 -0
- package/bizar-dash/src/web/components/goals/PlanVisualization.tsx +111 -0
- package/bizar-dash/src/web/lib/goapPlanner.ts +614 -0
- package/bizar-dash/src/web/lib/types.ts +25 -0
- package/bizar-dash/src/web/mobile/MobileApp.tsx +33 -2
- package/bizar-dash/src/web/mobile/MobileBottomNav.tsx +2 -2
- package/bizar-dash/src/web/mobile/MobileEval.tsx +4 -4
- package/bizar-dash/src/web/mobile/MobileMemory.tsx +2 -2
- package/bizar-dash/src/web/mobile/MobileSettings.tsx +3 -3
- package/bizar-dash/src/web/mobile/MobileTasks.tsx +2 -2
- package/bizar-dash/src/web/mobile/components/MobileListItem.tsx +3 -3
- package/bizar-dash/src/web/styles/agents-redesign.css +311 -0
- package/bizar-dash/src/web/styles/main.css +251 -0
- package/bizar-dash/src/web/styles/mobile.css +41 -0
- package/bizar-dash/src/web/styles/tasks-redesign.css +253 -0
- package/bizar-dash/src/web/ui/controls/Button.tsx +77 -0
- package/bizar-dash/src/web/ui/controls/Checkbox.tsx +95 -0
- package/bizar-dash/src/web/ui/controls/IconButton.tsx +66 -0
- package/bizar-dash/src/web/ui/controls/Kbd.tsx +24 -0
- package/bizar-dash/src/web/ui/controls/NumberInput.tsx +77 -0
- package/bizar-dash/src/web/ui/controls/RadioGroup.tsx +109 -0
- package/bizar-dash/src/web/ui/controls/SearchInput.tsx +91 -0
- package/bizar-dash/src/web/ui/controls/Select.tsx +92 -0
- package/bizar-dash/src/web/ui/controls/Slider.tsx +70 -0
- package/bizar-dash/src/web/ui/controls/TextInput.tsx +67 -0
- package/bizar-dash/src/web/ui/controls/Textarea.tsx +56 -0
- package/bizar-dash/src/web/ui/controls/Toggle.tsx +79 -0
- package/bizar-dash/src/web/ui/controls/controls.css +476 -0
- package/bizar-dash/src/web/ui/controls/index.ts +35 -0
- package/bizar-dash/src/web/ui/data/BarChart.tsx +60 -0
- package/bizar-dash/src/web/ui/data/DataTable.tsx +216 -0
- package/bizar-dash/src/web/ui/data/EmptyState.tsx +60 -0
- package/bizar-dash/src/web/ui/data/ErrorState.tsx +56 -0
- package/bizar-dash/src/web/ui/data/KeyValueList.tsx +106 -0
- package/bizar-dash/src/web/ui/data/LoadingState.tsx +65 -0
- package/bizar-dash/src/web/ui/data/Sparkline.tsx +87 -0
- package/bizar-dash/src/web/ui/data/StatTile.tsx +87 -0
- package/bizar-dash/src/web/ui/data/data.css +535 -0
- package/bizar-dash/src/web/ui/data/index.ts +31 -0
- package/bizar-dash/src/web/ui/feedback/Badge.tsx +49 -0
- package/bizar-dash/src/web/ui/feedback/Dialog.tsx +209 -0
- package/bizar-dash/src/web/ui/feedback/ProgressBar.tsx +69 -0
- package/bizar-dash/src/web/ui/feedback/StatusDot.tsx +50 -0
- package/bizar-dash/src/web/ui/feedback/Toast.tsx +200 -0
- package/bizar-dash/src/web/ui/feedback/Tooltip.tsx +126 -0
- package/bizar-dash/src/web/ui/feedback/feedback.css +314 -0
- package/bizar-dash/src/web/ui/feedback/index.ts +43 -0
- package/bizar-dash/src/web/ui/index.ts +56 -0
- package/bizar-dash/src/web/ui/layout/AppShell.tsx +51 -0
- package/bizar-dash/src/web/ui/layout/Breadcrumbs.tsx +97 -0
- package/bizar-dash/src/web/ui/layout/Panel.tsx +73 -0
- package/bizar-dash/src/web/ui/layout/PanelHeader.tsx +39 -0
- package/bizar-dash/src/web/ui/layout/Sidebar.tsx +131 -0
- package/bizar-dash/src/web/ui/layout/Tabs.tsx +133 -0
- package/bizar-dash/src/web/ui/layout/Topbar.tsx +42 -0
- package/bizar-dash/src/web/ui/layout/ViewHeader.tsx +48 -0
- package/bizar-dash/src/web/ui/layout/index.ts +34 -0
- package/bizar-dash/src/web/ui/layout/layout.css +464 -0
- package/bizar-dash/src/web/ui/navigation/CommandPalette.tsx +199 -0
- package/bizar-dash/src/web/ui/navigation/NavGroup.tsx +95 -0
- package/bizar-dash/src/web/ui/navigation/NavLink.tsx +93 -0
- package/bizar-dash/src/web/ui/navigation/index.ts +17 -0
- package/bizar-dash/src/web/ui/navigation/navigation.css +343 -0
- package/bizar-dash/src/web/ui/primitives/Box.tsx +91 -0
- package/bizar-dash/src/web/ui/primitives/Grid.tsx +49 -0
- package/bizar-dash/src/web/ui/primitives/Inline.tsx +55 -0
- package/bizar-dash/src/web/ui/primitives/Separator.tsx +46 -0
- package/bizar-dash/src/web/ui/primitives/Stack.tsx +54 -0
- package/bizar-dash/src/web/ui/primitives/VisuallyHidden.tsx +26 -0
- package/bizar-dash/src/web/ui/primitives/index.ts +23 -0
- package/bizar-dash/src/web/ui/primitives/primitives.css +183 -0
- package/bizar-dash/src/web/ui/styles/globals.css +86 -0
- package/bizar-dash/src/web/ui/styles/reset.css +125 -0
- package/bizar-dash/src/web/ui/styles/tokens.css +208 -0
- package/bizar-dash/src/web/ui/theme/ThemeProvider.tsx +142 -0
- package/bizar-dash/src/web/ui/theme/tokens.ts +131 -0
- package/bizar-dash/src/web/ui/theme/useTheme.ts +22 -0
- package/bizar-dash/src/web/ui/utils/cx.ts +42 -0
- package/bizar-dash/src/web/views/Agents.tsx +516 -268
- package/bizar-dash/src/web/views/GoalPlanner.tsx +158 -0
- package/bizar-dash/src/web/views/Overview.tsx +985 -448
- package/bizar-dash/src/web/views/Tasks.tsx +271 -273
- package/bizar-dash/tests/communication-log.test.tsx +67 -0
- package/bizar-dash/tests/dep-graph.test.tsx +40 -0
- package/bizar-dash/tests/event-log.test.tsx +61 -0
- package/bizar-dash/tests/goal-input.test.tsx +72 -0
- package/bizar-dash/tests/goap-planner.test.ts +68 -0
- package/bizar-dash/tests/quality-gates.test.tsx +59 -0
- package/bizar-dash/tests/setup.ts +31 -1
- package/bizar-dash/tests/ui/controls/Button.test.tsx +50 -0
- package/bizar-dash/tests/ui/controls/Checkbox.test.tsx +44 -0
- package/bizar-dash/tests/ui/controls/IconButton.test.tsx +37 -0
- package/bizar-dash/tests/ui/controls/Kbd.test.tsx +39 -0
- package/bizar-dash/tests/ui/controls/NumberInput.test.tsx +56 -0
- package/bizar-dash/tests/ui/controls/RadioGroup.test.tsx +58 -0
- package/bizar-dash/tests/ui/controls/SearchInput.test.tsx +52 -0
- package/bizar-dash/tests/ui/controls/Select.test.tsx +66 -0
- package/bizar-dash/tests/ui/controls/Slider.test.tsx +41 -0
- package/bizar-dash/tests/ui/controls/TextInput.test.tsx +44 -0
- package/bizar-dash/tests/ui/controls/Textarea.test.tsx +56 -0
- package/bizar-dash/tests/ui/controls/Toggle.test.tsx +39 -0
- package/bizar-dash/tests/ui/data/BarChart.test.tsx +55 -0
- package/bizar-dash/tests/ui/data/DataTable.test.tsx +112 -0
- package/bizar-dash/tests/ui/data/EmptyState.test.tsx +57 -0
- package/bizar-dash/tests/ui/data/ErrorState.test.tsx +47 -0
- package/bizar-dash/tests/ui/data/KeyValueList.test.tsx +59 -0
- package/bizar-dash/tests/ui/data/LoadingState.test.tsx +37 -0
- package/bizar-dash/tests/ui/data/Sparkline.test.tsx +56 -0
- package/bizar-dash/tests/ui/data/StatTile.test.tsx +69 -0
- package/bizar-dash/tests/ui/feedback/Badge.test.tsx +41 -0
- package/bizar-dash/tests/ui/feedback/Dialog.test.tsx +99 -0
- package/bizar-dash/tests/ui/feedback/ProgressBar.test.tsx +66 -0
- package/bizar-dash/tests/ui/feedback/StatusDot.test.tsx +41 -0
- package/bizar-dash/tests/ui/feedback/Toast.test.tsx +124 -0
- package/bizar-dash/tests/ui/feedback/Tooltip.test.tsx +102 -0
- package/bizar-dash/tests/ui/layout/AppShell.test.tsx +50 -0
- package/bizar-dash/tests/ui/layout/Breadcrumbs.test.tsx +85 -0
- package/bizar-dash/tests/ui/layout/Panel.test.tsx +52 -0
- package/bizar-dash/tests/ui/layout/PanelHeader.test.tsx +32 -0
- package/bizar-dash/tests/ui/layout/Sidebar.test.tsx +95 -0
- package/bizar-dash/tests/ui/layout/Tabs.test.tsx +87 -0
- package/bizar-dash/tests/ui/layout/Topbar.test.tsx +41 -0
- package/bizar-dash/tests/ui/layout/ViewHeader.test.tsx +47 -0
- package/bizar-dash/tests/ui/navigation/CommandPalette.test.tsx +105 -0
- package/bizar-dash/tests/ui/navigation/NavGroup.test.tsx +55 -0
- package/bizar-dash/tests/ui/navigation/NavLink.test.tsx +61 -0
- package/bizar-dash/tests/ui/primitives/Box.test.tsx +49 -0
- package/bizar-dash/tests/ui/primitives/Grid.test.tsx +37 -0
- package/bizar-dash/tests/ui/primitives/Inline.test.tsx +33 -0
- package/bizar-dash/tests/ui/primitives/Separator.test.tsx +34 -0
- package/bizar-dash/tests/ui/primitives/Stack.test.tsx +45 -0
- package/bizar-dash/tests/ui/primitives/VisuallyHidden.test.tsx +27 -0
- package/bizar-dash/tests/views/Agents.test.tsx +359 -0
- package/bizar-dash/tests/views/Overview.test.tsx +413 -0
- package/bizar-dash/tests/views/Tasks.test.tsx +250 -0
- package/bizar-dash/vitest.config.ts +3 -1
- package/cli/__tests__/cost-gate.test.mjs +301 -0
- package/cli/__tests__/feature-list-bridge.test.mjs +371 -0
- package/cli/bin.mjs +38 -0
- package/cli/commands/claim.mjs +282 -0
- package/cli/commands/cost.mjs +279 -0
- package/cli/cost-gate.mjs +501 -0
- package/cli/feature-list-bridge.mjs +400 -0
- package/cli/memory-constants.mjs +17 -0
- package/cli/provision-claude.mjs +94 -0
- package/cli/worker-dispatcher.mjs +259 -0
- package/cli/worker-dispatcher.test.mjs +204 -0
- package/config/trigger-patterns.json +186 -0
- package/package.json +2 -2
- package/packages/sdk/package.json +1 -1
- package/packages/sdk/src/agent-registry.ts +304 -0
- package/packages/sdk/src/consensus/byzantine.ts +587 -0
- package/packages/sdk/src/consensus/index.ts +147 -0
- package/packages/sdk/src/consensus/queen.ts +173 -0
- package/packages/sdk/src/consensus/types.ts +199 -0
- package/packages/sdk/src/federation/audit.ts +156 -0
- package/packages/sdk/src/federation/budget.ts +269 -0
- package/packages/sdk/src/federation/envelope.ts +144 -0
- package/packages/sdk/src/federation/hmac.ts +160 -0
- package/packages/sdk/src/federation/index.ts +443 -0
- package/packages/sdk/src/federation/pii.ts +241 -0
- package/packages/sdk/src/federation/policy.ts +112 -0
- package/packages/sdk/src/federation/trust.ts +146 -0
- package/packages/sdk/src/index.ts +67 -0
- package/packages/sdk/src/mcp/server.ts +351 -1
- package/packages/sdk/src/router/codemod-intent.ts +125 -0
- package/packages/sdk/src/router/index.ts +247 -0
- package/packages/sdk/src/router/memory-distillation-shim.mjs +18 -0
- package/packages/sdk/src/router/memory-distillation.ts +249 -0
- package/packages/sdk/src/router/model-router.ts +235 -0
- package/packages/sdk/src/router/q-learning-router.ts +304 -0
- package/packages/sdk/src/swarm-topology.ts +279 -0
- package/packages/sdk/tests/agent-registry.test.ts +285 -0
- package/packages/sdk/tests/consensus.test.ts +376 -0
- package/packages/sdk/tests/federation/audit.test.ts +164 -0
- package/packages/sdk/tests/federation/budget.test.ts +189 -0
- package/packages/sdk/tests/federation/envelope.test.ts +120 -0
- package/packages/sdk/tests/federation/hmac.test.ts +194 -0
- package/packages/sdk/tests/federation/orchestrator.test.ts +176 -0
- package/packages/sdk/tests/federation/pii.test.ts +106 -0
- package/packages/sdk/tests/federation/policy.test.ts +140 -0
- package/packages/sdk/tests/federation/trust.test.ts +124 -0
- package/packages/sdk/tests/mcp-tools.test.ts +204 -0
- package/packages/sdk/tests/memory-distillation.test.mjs +186 -0
- package/packages/sdk/tests/model-router.test.mjs +108 -0
- package/packages/sdk/tests/q-learning-router.test.mjs +100 -0
- package/packages/sdk/tests/router-orchestrator.test.mjs +172 -0
- package/packages/sdk/tests/router.test.mjs +91 -0
- package/packages/sdk/tests/sdk.test.mjs +26 -2
- package/packages/sdk/tests/swarm-topology.test.ts +258 -0
- package/scripts/bh-full-e2e.mjs +11 -15
- package/bizar-dash/dist/assets/EnvVarsSection-B58aiJiE.js.map +0 -1
- package/bizar-dash/dist/assets/MobileChat-BJrqwVDd.js +0 -1
- package/bizar-dash/dist/assets/MobileSettings-CEQNJNLJ.js +0 -1
- package/bizar-dash/dist/assets/MobileSettings-CEQNJNLJ.js.map +0 -1
- package/bizar-dash/dist/assets/icons-Do5N2jmX.js.map +0 -1
- package/bizar-dash/dist/assets/main-IvfQAOfy.js +0 -18
- package/bizar-dash/dist/assets/main-IvfQAOfy.js.map +0 -1
- package/bizar-dash/dist/assets/main-ietCEg_R.css +0 -1
- package/bizar-dash/dist/assets/markdown-tOLaD6nm.js +0 -1
- package/bizar-dash/dist/assets/markdown-tOLaD6nm.js.map +0 -1
- package/bizar-dash/dist/assets/mobile-DYCHcUpq.js +0 -1
- package/bizar-dash/dist/assets/mobile-layout-CBHjpwsb.js +0 -2
- package/bizar-dash/dist/assets/mobile-layout-CBHjpwsb.js.map +0 -1
- package/bizar-dash/dist/assets/mobile-layout-CJnZNLy3.css +0 -1
- package/bizar-dash/dist/assets/react-vendor-Dn4wqh4Z.js +0 -40
- package/bizar-dash/dist/assets/react-vendor-Dn4wqh4Z.js.map +0 -1
- package/bizar-dash/dist/assets/useSlashCommands-Bd7_FA6U.js +0 -2
- package/bizar-dash/dist/assets/useSlashCommands-Bd7_FA6U.js.map +0 -1
- package/bizar-dash/dist/assets/vendor-C843201K.js +0 -29
- package/bizar-dash/dist/assets/vendor-C843201K.js.map +0 -1
- package/bizar-dash/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
- package/packages/sdk/package-lock.json +0 -32
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* NavGroup.tsx — Collapsible group of NavLinks (Wave 2B).
|
|
3
|
+
*
|
|
4
|
+
* Header is a labelled bar that toggles the open state on click. When
|
|
5
|
+
* `collapsible={false}` the header becomes a static label (no chevron, no
|
|
6
|
+
* click, no pointer-events). Open/closed is uncontrolled by default
|
|
7
|
+
* (`defaultOpen`) but switches to controlled when `open` is passed. The
|
|
8
|
+
* children are rendered via a wrapped <NavGroup.Items> approach — to keep
|
|
9
|
+
* the public surface simple we accept `items` as NavLinkProps[] and project
|
|
10
|
+
* them through NavLink internally.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { useState, type ReactNode } from 'react';
|
|
14
|
+
import { ChevronRight } from 'lucide-react';
|
|
15
|
+
import type { LucideIcon } from 'lucide-react';
|
|
16
|
+
import { cx } from '../utils/cx';
|
|
17
|
+
import { NavLink, type NavLinkProps } from './NavLink';
|
|
18
|
+
|
|
19
|
+
export type NavGroupProps = {
|
|
20
|
+
label: string;
|
|
21
|
+
icon?: LucideIcon;
|
|
22
|
+
items: NavLinkProps[];
|
|
23
|
+
defaultOpen?: boolean;
|
|
24
|
+
open?: boolean;
|
|
25
|
+
onOpenChange?: (open: boolean) => void;
|
|
26
|
+
collapsible?: boolean;
|
|
27
|
+
children?: ReactNode;
|
|
28
|
+
className?: string;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export function NavGroup({
|
|
32
|
+
label,
|
|
33
|
+
icon: Icon,
|
|
34
|
+
items,
|
|
35
|
+
defaultOpen = true,
|
|
36
|
+
open: controlledOpen,
|
|
37
|
+
onOpenChange,
|
|
38
|
+
collapsible = true,
|
|
39
|
+
children,
|
|
40
|
+
className,
|
|
41
|
+
}: NavGroupProps): React.JSX.Element {
|
|
42
|
+
const [internalOpen, setInternalOpen] = useState(defaultOpen);
|
|
43
|
+
const isControlled = controlledOpen !== undefined;
|
|
44
|
+
const isOpen = isControlled ? controlledOpen! : internalOpen;
|
|
45
|
+
|
|
46
|
+
const toggle = (): void => {
|
|
47
|
+
if (!collapsible) return;
|
|
48
|
+
const next = !isOpen;
|
|
49
|
+
if (!isControlled) setInternalOpen(next);
|
|
50
|
+
onOpenChange?.(next);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<section
|
|
55
|
+
className={cx(
|
|
56
|
+
'bd-nav-group',
|
|
57
|
+
isOpen && 'bd-nav-group--open',
|
|
58
|
+
!collapsible && 'bd-nav-group--non-collapsible',
|
|
59
|
+
className,
|
|
60
|
+
)}
|
|
61
|
+
>
|
|
62
|
+
<button
|
|
63
|
+
type="button"
|
|
64
|
+
className="bd-nav-group__header"
|
|
65
|
+
onClick={toggle}
|
|
66
|
+
aria-expanded={collapsible ? isOpen : undefined}
|
|
67
|
+
>
|
|
68
|
+
{Icon && (
|
|
69
|
+
<span className="bd-nav-group__header-icon" aria-hidden="true">
|
|
70
|
+
<Icon size={14} />
|
|
71
|
+
</span>
|
|
72
|
+
)}
|
|
73
|
+
<span className="bd-nav-group__label">{label}</span>
|
|
74
|
+
{collapsible && (
|
|
75
|
+
<ChevronRight
|
|
76
|
+
size={12}
|
|
77
|
+
className="bd-nav-group__chevron"
|
|
78
|
+
aria-hidden="true"
|
|
79
|
+
/>
|
|
80
|
+
)}
|
|
81
|
+
</button>
|
|
82
|
+
<div className="bd-nav-group__items" role="group">
|
|
83
|
+
{items.map((item, i) => (
|
|
84
|
+
<NavLink key={`${item.label}-${i}`} {...item} />
|
|
85
|
+
))}
|
|
86
|
+
{/*
|
|
87
|
+
Reserved escape hatch for callers that want to inject custom
|
|
88
|
+
content (e.g. a divider or a footer link) below the auto
|
|
89
|
+
-projected items.
|
|
90
|
+
*/}
|
|
91
|
+
{typeof children !== 'undefined' && <>{children}</>}
|
|
92
|
+
</div>
|
|
93
|
+
</section>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* NavLink.tsx — Single sidebar nav item (Wave 2B).
|
|
3
|
+
*
|
|
4
|
+
* Renders as <a>, <button> or <div> depending on whether the caller wired
|
|
5
|
+
* `href`, `onClick`, or neither. This matches the three affordances callers
|
|
6
|
+
* actually need: a real navigation link, a click-triggered action (e.g. open
|
|
7
|
+
* a modal) and a decorative marker (sub-item shown but not interactive).
|
|
8
|
+
* The active row gets a 2px accent left-border + subtle background tint.
|
|
9
|
+
*
|
|
10
|
+
* The `to` prop is reserved for future client-side router wiring
|
|
11
|
+
* (e.g. react-router) — left on the prop type so call-sites can pass
|
|
12
|
+
* `to={...}` without TypeScript errors when the router is introduced. The
|
|
13
|
+
* `_ = to` assignment immediately below is the no-op placeholder that
|
|
14
|
+
* silences `noUnusedParameters` without touching the runtime.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import type { LucideIcon } from 'lucide-react';
|
|
18
|
+
import { cx } from '../utils/cx';
|
|
19
|
+
|
|
20
|
+
export type NavLinkProps = {
|
|
21
|
+
href?: string;
|
|
22
|
+
to?: string;
|
|
23
|
+
icon?: LucideIcon;
|
|
24
|
+
label: string;
|
|
25
|
+
badge?: string | number;
|
|
26
|
+
active?: boolean;
|
|
27
|
+
onClick?: () => void;
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
className?: string;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export function NavLink({
|
|
33
|
+
href,
|
|
34
|
+
to,
|
|
35
|
+
icon: Icon,
|
|
36
|
+
label,
|
|
37
|
+
badge,
|
|
38
|
+
active = false,
|
|
39
|
+
onClick,
|
|
40
|
+
disabled = false,
|
|
41
|
+
className,
|
|
42
|
+
}: NavLinkProps): React.JSX.Element {
|
|
43
|
+
const _ = to; // reserved for future router; see file header.
|
|
44
|
+
void _;
|
|
45
|
+
const classes = cx(
|
|
46
|
+
'bd-nav-link',
|
|
47
|
+
active && 'bd-nav-link--active',
|
|
48
|
+
disabled && 'bd-nav-link--disabled',
|
|
49
|
+
className,
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const content = (
|
|
53
|
+
<>
|
|
54
|
+
{Icon && (
|
|
55
|
+
<span className="bd-nav-link__icon" aria-hidden="true">
|
|
56
|
+
<Icon size={16} />
|
|
57
|
+
</span>
|
|
58
|
+
)}
|
|
59
|
+
<span className="bd-nav-link__label">{label}</span>
|
|
60
|
+
{badge !== undefined && badge !== null && (
|
|
61
|
+
<span className="bd-nav-link__badge">{badge}</span>
|
|
62
|
+
)}
|
|
63
|
+
</>
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
if (href !== undefined) {
|
|
67
|
+
return (
|
|
68
|
+
<a
|
|
69
|
+
href={disabled ? undefined : href}
|
|
70
|
+
className={classes}
|
|
71
|
+
aria-current={active ? 'page' : undefined}
|
|
72
|
+
onClick={onClick}
|
|
73
|
+
aria-disabled={disabled || undefined}
|
|
74
|
+
>
|
|
75
|
+
{content}
|
|
76
|
+
</a>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
if (onClick) {
|
|
80
|
+
return (
|
|
81
|
+
<button
|
|
82
|
+
type="button"
|
|
83
|
+
className={classes}
|
|
84
|
+
onClick={onClick}
|
|
85
|
+
disabled={disabled}
|
|
86
|
+
aria-current={active ? 'page' : undefined}
|
|
87
|
+
>
|
|
88
|
+
{content}
|
|
89
|
+
</button>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
return <div className={classes}>{content}</div>;
|
|
93
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* index.ts — Barrel for the Navigation component family (Wave 2B).
|
|
3
|
+
*
|
|
4
|
+
* Imports navigation.css as a side-effect so consumers only need a single
|
|
5
|
+
* `import { NavLink } from '../ui/navigation'` to ship the styles.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import './navigation.css';
|
|
9
|
+
|
|
10
|
+
export { NavLink, type NavLinkProps } from './NavLink';
|
|
11
|
+
export { NavGroup, type NavGroupProps } from './NavGroup';
|
|
12
|
+
export {
|
|
13
|
+
CommandPalette,
|
|
14
|
+
type CommandPaletteProps,
|
|
15
|
+
type CommandPaletteItem,
|
|
16
|
+
type CommandPaletteItemType,
|
|
17
|
+
} from './CommandPalette';
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* navigation.css — Styles for the Navigation component family (Wave 2B).
|
|
3
|
+
*
|
|
4
|
+
* One file for NavLink, NavGroup and CommandPalette. Tokens come from
|
|
5
|
+
* ui/styles/tokens.css — every colour, spacing, radius and shadow below is
|
|
6
|
+
* a `var(--...)` reference. Sidebar nav uses a subtle accent left-border to
|
|
7
|
+
* signal the active route (matches Supabase's nav visual language).
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/* ============ NavLink ============ */
|
|
11
|
+
|
|
12
|
+
.bd-nav-link {
|
|
13
|
+
display: flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
gap: var(--space-3);
|
|
16
|
+
padding: var(--space-2) var(--space-4);
|
|
17
|
+
font-size: var(--text-base);
|
|
18
|
+
font-weight: var(--weight-medium);
|
|
19
|
+
color: var(--text-secondary);
|
|
20
|
+
background: transparent;
|
|
21
|
+
border: 0;
|
|
22
|
+
border-left: 2px solid transparent;
|
|
23
|
+
border-radius: 0;
|
|
24
|
+
cursor: pointer;
|
|
25
|
+
text-decoration: none;
|
|
26
|
+
user-select: none;
|
|
27
|
+
width: 100%;
|
|
28
|
+
text-align: left;
|
|
29
|
+
transition: background-color var(--duration-fast) var(--ease-out),
|
|
30
|
+
color var(--duration-fast) var(--ease-out);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.bd-nav-link:hover:not(.bd-nav-link--disabled):not(.bd-nav-link--active) {
|
|
34
|
+
background: var(--surface-overlay);
|
|
35
|
+
color: var(--text-primary);
|
|
36
|
+
text-decoration: none;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.bd-nav-link:focus-visible {
|
|
40
|
+
outline: 2px solid var(--border-focus);
|
|
41
|
+
outline-offset: -2px;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.bd-nav-link--active {
|
|
45
|
+
background: var(--accent-subtle);
|
|
46
|
+
color: var(--text-primary);
|
|
47
|
+
border-left-color: var(--accent);
|
|
48
|
+
font-weight: var(--weight-semibold);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.bd-nav-link--disabled {
|
|
52
|
+
opacity: 0.5;
|
|
53
|
+
cursor: not-allowed;
|
|
54
|
+
pointer-events: none;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.bd-nav-link__icon {
|
|
58
|
+
flex-shrink: 0;
|
|
59
|
+
display: flex;
|
|
60
|
+
align-items: center;
|
|
61
|
+
justify-content: center;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.bd-nav-link__label {
|
|
65
|
+
flex: 1;
|
|
66
|
+
min-width: 0;
|
|
67
|
+
overflow: hidden;
|
|
68
|
+
text-overflow: ellipsis;
|
|
69
|
+
white-space: nowrap;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.bd-nav-link__badge {
|
|
73
|
+
flex-shrink: 0;
|
|
74
|
+
display: inline-flex;
|
|
75
|
+
align-items: center;
|
|
76
|
+
justify-content: center;
|
|
77
|
+
min-width: 20px;
|
|
78
|
+
height: 18px;
|
|
79
|
+
padding: 0 var(--space-2);
|
|
80
|
+
font-family: var(--font-mono);
|
|
81
|
+
font-size: var(--text-xs);
|
|
82
|
+
font-weight: var(--weight-semibold);
|
|
83
|
+
font-variant-numeric: tabular-nums;
|
|
84
|
+
background: var(--surface-3);
|
|
85
|
+
color: var(--text-primary);
|
|
86
|
+
border-radius: var(--radius-full);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.bd-nav-link--active .bd-nav-link__badge {
|
|
90
|
+
background: var(--accent);
|
|
91
|
+
color: var(--accent-fg);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/* ============ NavGroup ============ */
|
|
95
|
+
|
|
96
|
+
.bd-nav-group {
|
|
97
|
+
display: flex;
|
|
98
|
+
flex-direction: column;
|
|
99
|
+
margin-top: var(--space-3);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.bd-nav-group__header {
|
|
103
|
+
display: flex;
|
|
104
|
+
align-items: center;
|
|
105
|
+
gap: var(--space-3);
|
|
106
|
+
padding: var(--space-2) var(--space-4);
|
|
107
|
+
font-size: var(--text-xs);
|
|
108
|
+
font-weight: var(--weight-semibold);
|
|
109
|
+
color: var(--text-tertiary);
|
|
110
|
+
text-transform: uppercase;
|
|
111
|
+
letter-spacing: 0.06em;
|
|
112
|
+
background: transparent;
|
|
113
|
+
border: 0;
|
|
114
|
+
width: 100%;
|
|
115
|
+
text-align: left;
|
|
116
|
+
cursor: pointer;
|
|
117
|
+
border-radius: 0;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.bd-nav-group__header:hover {
|
|
121
|
+
color: var(--text-secondary);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.bd-nav-group__header:focus-visible {
|
|
125
|
+
outline: 2px solid var(--border-focus);
|
|
126
|
+
outline-offset: -2px;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.bd-nav-group--non-collapsible .bd-nav-group__header {
|
|
130
|
+
cursor: default;
|
|
131
|
+
pointer-events: none;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.bd-nav-group__header-icon {
|
|
135
|
+
flex-shrink: 0;
|
|
136
|
+
display: flex;
|
|
137
|
+
align-items: center;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.bd-nav-group__label {
|
|
141
|
+
flex: 1;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.bd-nav-group__chevron {
|
|
145
|
+
flex-shrink: 0;
|
|
146
|
+
transition: transform var(--duration-fast) var(--ease-out);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.bd-nav-group--open .bd-nav-group__chevron {
|
|
150
|
+
transform: rotate(90deg);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.bd-nav-group__items {
|
|
154
|
+
display: flex;
|
|
155
|
+
flex-direction: column;
|
|
156
|
+
overflow: hidden;
|
|
157
|
+
max-height: 0;
|
|
158
|
+
opacity: 0;
|
|
159
|
+
transition: max-height var(--duration-normal) var(--ease-out),
|
|
160
|
+
opacity var(--duration-fast) var(--ease-out);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.bd-nav-group--open .bd-nav-group__items {
|
|
164
|
+
max-height: 1000px;
|
|
165
|
+
opacity: 1;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/* ============ CommandPalette ============ */
|
|
169
|
+
|
|
170
|
+
.bd-cmdk-overlay {
|
|
171
|
+
position: fixed;
|
|
172
|
+
inset: 0;
|
|
173
|
+
background: rgba(0, 0, 0, 0.32);
|
|
174
|
+
display: flex;
|
|
175
|
+
align-items: flex-start;
|
|
176
|
+
justify-content: center;
|
|
177
|
+
padding-top: 12vh;
|
|
178
|
+
z-index: var(--z-modal);
|
|
179
|
+
animation: bd-cmdk-fade-in var(--duration-fast) var(--ease-out);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.bd-cmdk {
|
|
183
|
+
width: min(640px, calc(100vw - var(--space-7)));
|
|
184
|
+
max-height: 70vh;
|
|
185
|
+
background: var(--surface-0);
|
|
186
|
+
border: 1px solid var(--border-default);
|
|
187
|
+
border-radius: var(--radius-lg);
|
|
188
|
+
box-shadow: var(--shadow-overlay);
|
|
189
|
+
display: flex;
|
|
190
|
+
flex-direction: column;
|
|
191
|
+
font-family: var(--font-sans);
|
|
192
|
+
overflow: hidden;
|
|
193
|
+
animation: bd-cmdk-slide-in var(--duration-normal) var(--ease-out);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.bd-cmdk__input-wrap {
|
|
197
|
+
display: flex;
|
|
198
|
+
align-items: center;
|
|
199
|
+
gap: var(--space-3);
|
|
200
|
+
padding: var(--space-3) var(--space-4);
|
|
201
|
+
border-bottom: 1px solid var(--border-subtle);
|
|
202
|
+
color: var(--text-tertiary);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.bd-cmdk__input {
|
|
206
|
+
flex: 1;
|
|
207
|
+
background: transparent;
|
|
208
|
+
border: 0;
|
|
209
|
+
outline: 0;
|
|
210
|
+
font-size: var(--text-md);
|
|
211
|
+
color: var(--text-primary);
|
|
212
|
+
font-family: inherit;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
.bd-cmdk__input::placeholder {
|
|
216
|
+
color: var(--text-tertiary);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
.bd-cmdk__kbd-hint {
|
|
220
|
+
font-size: var(--text-xs);
|
|
221
|
+
font-family: var(--font-mono);
|
|
222
|
+
color: var(--text-tertiary);
|
|
223
|
+
background: var(--surface-2);
|
|
224
|
+
padding: 2px 6px;
|
|
225
|
+
border-radius: var(--radius-sm);
|
|
226
|
+
border: 1px solid var(--border-subtle);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.bd-cmdk__results {
|
|
230
|
+
flex: 1;
|
|
231
|
+
overflow-y: auto;
|
|
232
|
+
padding: var(--space-2) 0;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.bd-cmdk__empty {
|
|
236
|
+
padding: var(--space-7);
|
|
237
|
+
text-align: center;
|
|
238
|
+
color: var(--text-tertiary);
|
|
239
|
+
font-size: var(--text-sm);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
.bd-cmdk__group {
|
|
243
|
+
padding: var(--space-2) 0;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.bd-cmdk__group-header {
|
|
247
|
+
padding: var(--space-2) var(--space-4);
|
|
248
|
+
font-size: var(--text-xs);
|
|
249
|
+
font-weight: var(--weight-semibold);
|
|
250
|
+
text-transform: uppercase;
|
|
251
|
+
letter-spacing: 0.06em;
|
|
252
|
+
color: var(--text-tertiary);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
.bd-cmdk__item {
|
|
256
|
+
display: flex;
|
|
257
|
+
align-items: center;
|
|
258
|
+
gap: var(--space-3);
|
|
259
|
+
padding: var(--space-3) var(--space-4);
|
|
260
|
+
cursor: pointer;
|
|
261
|
+
color: var(--text-primary);
|
|
262
|
+
background: transparent;
|
|
263
|
+
border: 0;
|
|
264
|
+
width: 100%;
|
|
265
|
+
text-align: left;
|
|
266
|
+
font-family: inherit;
|
|
267
|
+
font-size: var(--text-base);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.bd-cmdk__item:hover {
|
|
271
|
+
background: var(--surface-overlay);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
.bd-cmdk__item--active {
|
|
275
|
+
background: var(--accent-subtle);
|
|
276
|
+
color: var(--text-primary);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
.bd-cmdk__item-icon {
|
|
280
|
+
flex-shrink: 0;
|
|
281
|
+
color: var(--text-secondary);
|
|
282
|
+
display: flex;
|
|
283
|
+
align-items: center;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.bd-cmdk__item--active .bd-cmdk__item-icon {
|
|
287
|
+
color: var(--accent);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
.bd-cmdk__item-body {
|
|
291
|
+
flex: 1;
|
|
292
|
+
min-width: 0;
|
|
293
|
+
display: flex;
|
|
294
|
+
flex-direction: column;
|
|
295
|
+
gap: 2px;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
.bd-cmdk__item-label {
|
|
299
|
+
font-weight: var(--weight-medium);
|
|
300
|
+
overflow: hidden;
|
|
301
|
+
text-overflow: ellipsis;
|
|
302
|
+
white-space: nowrap;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
.bd-cmdk__item-description {
|
|
306
|
+
font-size: var(--text-xs);
|
|
307
|
+
color: var(--text-secondary);
|
|
308
|
+
overflow: hidden;
|
|
309
|
+
text-overflow: ellipsis;
|
|
310
|
+
white-space: nowrap;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
.bd-cmdk__item-shortcut {
|
|
314
|
+
flex-shrink: 0;
|
|
315
|
+
display: inline-flex;
|
|
316
|
+
gap: 2px;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
.bd-cmdk__item-shortcut kbd {
|
|
320
|
+
font-family: var(--font-mono);
|
|
321
|
+
font-size: var(--text-xs);
|
|
322
|
+
padding: 2px 6px;
|
|
323
|
+
border-radius: var(--radius-sm);
|
|
324
|
+
background: var(--surface-2);
|
|
325
|
+
border: 1px solid var(--border-subtle);
|
|
326
|
+
color: var(--text-secondary);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
.bd-cmdk__item--active .bd-cmdk__item-shortcut kbd {
|
|
330
|
+
background: var(--surface-0);
|
|
331
|
+
border-color: var(--accent);
|
|
332
|
+
color: var(--text-primary);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
@keyframes bd-cmdk-fade-in {
|
|
336
|
+
from { opacity: 0; }
|
|
337
|
+
to { opacity: 1; }
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
@keyframes bd-cmdk-slide-in {
|
|
341
|
+
from { transform: translateY(-8px); opacity: 0; }
|
|
342
|
+
to { transform: translateY(0); opacity: 1; }
|
|
343
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Box.tsx — polymorphic layout primitive (Wave 2A).
|
|
3
|
+
*
|
|
4
|
+
* The single source of truth for "I just want a div with padding / margin /
|
|
5
|
+
* background / border / radius / shadow / display / position." Renders one of
|
|
6
|
+
* eight semantic tags (div/section/article/aside/header/footer/main/nav) via
|
|
7
|
+
* the `as` prop and composes utility classes from primitives.css. Every prop
|
|
8
|
+
* maps 1:1 to a CSS class (e.g. `p={3}` → `box-p-3`), keeping styles in CSS
|
|
9
|
+
* and the component surface narrow. `0` is a valid value — use explicit
|
|
10
|
+
* `undefined` checks so falsy zero is not skipped.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { createElement, type HTMLAttributes, type ReactNode } from 'react';
|
|
14
|
+
import { cx } from '../utils/cx';
|
|
15
|
+
|
|
16
|
+
export type BoxAs =
|
|
17
|
+
| 'div'
|
|
18
|
+
| 'section'
|
|
19
|
+
| 'article'
|
|
20
|
+
| 'aside'
|
|
21
|
+
| 'header'
|
|
22
|
+
| 'footer'
|
|
23
|
+
| 'main'
|
|
24
|
+
| 'nav';
|
|
25
|
+
export type BoxSpace = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
|
|
26
|
+
export type BoxBg = '0' | '1' | '2' | '3' | 'overlay';
|
|
27
|
+
export type BoxBorder = 'none' | 'subtle' | 'default' | 'strong';
|
|
28
|
+
export type BoxRounded = 'none' | 'sm' | 'md' | 'lg' | 'full';
|
|
29
|
+
export type BoxShadow = 'none' | 'hairline' | 'overlay' | 'tooltip';
|
|
30
|
+
export type BoxDisplay = 'block' | 'flex' | 'inline-flex' | 'grid' | 'inline-block' | 'none';
|
|
31
|
+
export type BoxPosition = 'static' | 'relative' | 'absolute' | 'fixed' | 'sticky';
|
|
32
|
+
|
|
33
|
+
export type BoxProps = Omit<HTMLAttributes<HTMLElement>, 'children'> & {
|
|
34
|
+
as?: BoxAs;
|
|
35
|
+
p?: BoxSpace;
|
|
36
|
+
px?: BoxSpace;
|
|
37
|
+
py?: BoxSpace;
|
|
38
|
+
m?: BoxSpace;
|
|
39
|
+
mx?: BoxSpace;
|
|
40
|
+
my?: BoxSpace;
|
|
41
|
+
bg?: BoxBg;
|
|
42
|
+
border?: BoxBorder;
|
|
43
|
+
rounded?: BoxRounded;
|
|
44
|
+
shadow?: BoxShadow;
|
|
45
|
+
display?: BoxDisplay;
|
|
46
|
+
position?: BoxPosition;
|
|
47
|
+
children?: ReactNode;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export function Box({
|
|
51
|
+
as = 'div',
|
|
52
|
+
p,
|
|
53
|
+
px,
|
|
54
|
+
py,
|
|
55
|
+
m,
|
|
56
|
+
mx,
|
|
57
|
+
my,
|
|
58
|
+
bg,
|
|
59
|
+
border,
|
|
60
|
+
rounded,
|
|
61
|
+
shadow,
|
|
62
|
+
display,
|
|
63
|
+
position,
|
|
64
|
+
className,
|
|
65
|
+
children,
|
|
66
|
+
...rest
|
|
67
|
+
}: BoxProps): React.JSX.Element {
|
|
68
|
+
return createElement(
|
|
69
|
+
as,
|
|
70
|
+
{
|
|
71
|
+
...rest,
|
|
72
|
+
className: cx(
|
|
73
|
+
'box',
|
|
74
|
+
p !== undefined && `box-p-${p}`,
|
|
75
|
+
px !== undefined && `box-px-${px}`,
|
|
76
|
+
py !== undefined && `box-py-${py}`,
|
|
77
|
+
m !== undefined && `box-m-${m}`,
|
|
78
|
+
mx !== undefined && `box-mx-${mx}`,
|
|
79
|
+
my !== undefined && `box-my-${my}`,
|
|
80
|
+
bg && `box-bg-${bg}`,
|
|
81
|
+
border && `box-border-${border}`,
|
|
82
|
+
rounded && `box-rounded-${rounded}`,
|
|
83
|
+
shadow && `box-shadow-${shadow}`,
|
|
84
|
+
display && `box-d-${display}`,
|
|
85
|
+
position && `box-pos-${position}`,
|
|
86
|
+
className,
|
|
87
|
+
),
|
|
88
|
+
},
|
|
89
|
+
children,
|
|
90
|
+
);
|
|
91
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Grid.tsx — CSS grid primitive (Wave 2A).
|
|
3
|
+
*
|
|
4
|
+
* Use the explicit `cols` prop (1..12) for fixed-column layouts, or set
|
|
5
|
+
* `autoFit` to flow as many `minmax(180px, 1fr)` columns as fit the
|
|
6
|
+
* container — useful for responsive card walls. `gap` follows the same
|
|
7
|
+
* 0..8 spacing scale as Stack/Inline. `style` is reserved for free-form
|
|
8
|
+
* custom-property overrides (e.g. per-instance --cols-token) — no
|
|
9
|
+
* inline numerics.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type { CSSProperties, HTMLAttributes, ReactNode } from 'react';
|
|
13
|
+
import { cx } from '../utils/cx';
|
|
14
|
+
|
|
15
|
+
export type GridSpace = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
|
|
16
|
+
|
|
17
|
+
export type GridProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
|
|
18
|
+
cols?: number;
|
|
19
|
+
gap?: GridSpace;
|
|
20
|
+
autoFit?: boolean;
|
|
21
|
+
children?: ReactNode;
|
|
22
|
+
style?: CSSProperties;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export function Grid({
|
|
26
|
+
cols = 1,
|
|
27
|
+
gap = 3,
|
|
28
|
+
autoFit = false,
|
|
29
|
+
className,
|
|
30
|
+
children,
|
|
31
|
+
style,
|
|
32
|
+
...rest
|
|
33
|
+
}: GridProps): React.JSX.Element {
|
|
34
|
+
return (
|
|
35
|
+
<div
|
|
36
|
+
{...rest}
|
|
37
|
+
className={cx(
|
|
38
|
+
'grid',
|
|
39
|
+
!autoFit && `cols-${cols}`,
|
|
40
|
+
autoFit && 'grid-autofit',
|
|
41
|
+
`gap-${gap}`,
|
|
42
|
+
className,
|
|
43
|
+
)}
|
|
44
|
+
style={style}
|
|
45
|
+
>
|
|
46
|
+
{children}
|
|
47
|
+
</div>
|
|
48
|
+
);
|
|
49
|
+
}
|