@zyro-sec/ui 1.0.0 → 1.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/AGENTS.md +29 -0
- package/bunfig.toml +2 -0
- package/package.json +21 -114
- package/perf/motion.bench.ts +14 -0
- package/perf/motion.ts +16 -0
- package/script/build-oc2-v2-overrides.ts +38 -0
- package/script/colors.txt +288 -0
- package/script/generate-spinner.ts +121 -0
- package/script/pack.ts +5 -0
- package/script/tailwind.ts +24 -0
- package/src/actions/button/button.stories.tsx +158 -0
- package/src/actions/icon-button/icon-button.stories.tsx +122 -0
- package/src/actions/split-button/split-button.stories.tsx +59 -0
- package/src/assets/favicon/apple-touch-icon-v3.png +0 -0
- package/src/assets/favicon/apple-touch-icon.png +0 -0
- package/src/assets/favicon/favicon-96x96-v3.png +0 -0
- package/src/assets/favicon/favicon-96x96.png +0 -0
- package/src/assets/favicon/favicon-v3.ico +0 -0
- package/src/assets/favicon/favicon-v3.svg +7 -0
- package/src/assets/favicon/favicon.ico +0 -0
- package/src/assets/favicon/favicon.svg +7 -0
- package/src/assets/favicon/site.webmanifest +24 -0
- package/src/assets/favicon/web-app-manifest-192x192.png +0 -0
- package/src/assets/favicon/web-app-manifest-512x512.png +0 -0
- package/src/assets/icons/provider/302ai.svg +7 -0
- package/src/assets/icons/provider/abacus.svg +14 -0
- package/src/assets/icons/provider/aihubmix.svg +3 -0
- package/src/assets/icons/provider/alibaba-cn.svg +3 -0
- package/src/assets/icons/provider/alibaba-coding-plan-cn.svg +3 -0
- package/src/assets/icons/provider/alibaba-coding-plan.svg +3 -0
- package/src/assets/icons/provider/alibaba.svg +3 -0
- package/src/assets/icons/provider/amazon-bedrock.svg +3 -0
- package/src/assets/icons/provider/anthropic.svg +3 -0
- package/src/assets/icons/provider/azure-cognitive-services.svg +24 -0
- package/src/assets/icons/provider/azure.svg +3 -0
- package/src/assets/icons/provider/bailing.svg +3 -0
- package/src/assets/icons/provider/baseten.svg +3 -0
- package/src/assets/icons/provider/berget.svg +3 -0
- package/src/assets/icons/provider/cerebras.svg +4 -0
- package/src/assets/icons/provider/chutes.svg +24 -0
- package/src/assets/icons/provider/clarifai.svg +24 -0
- package/src/assets/icons/provider/claude-agent.svg +3 -0
- package/src/assets/icons/provider/cloudferro-sherlock.svg +5 -0
- package/src/assets/icons/provider/cloudflare-ai-gateway.svg +4 -0
- package/src/assets/icons/provider/cloudflare-workers-ai.svg +4 -0
- package/src/assets/icons/provider/cohere.svg +5 -0
- package/src/assets/icons/provider/cortecs.svg +24 -0
- package/src/assets/icons/provider/deepinfra.svg +4 -0
- package/src/assets/icons/provider/deepseek.svg +3 -0
- package/src/assets/icons/provider/digitalocean.svg +6 -0
- package/src/assets/icons/provider/dinference.svg +1 -0
- package/src/assets/icons/provider/drun.svg +8 -0
- package/src/assets/icons/provider/evroc.svg +3 -0
- package/src/assets/icons/provider/fastrouter.svg +3 -0
- package/src/assets/icons/provider/fireworks-ai.svg +3 -0
- package/src/assets/icons/provider/firmware.svg +18 -0
- package/src/assets/icons/provider/friendli.svg +3 -0
- package/src/assets/icons/provider/github-copilot.svg +3 -0
- package/src/assets/icons/provider/github-models.svg +3 -0
- package/src/assets/icons/provider/gitlab.svg +3 -0
- package/src/assets/icons/provider/google-vertex-anthropic.svg +24 -0
- package/src/assets/icons/provider/google-vertex.svg +10 -0
- package/src/assets/icons/provider/google.svg +3 -0
- package/src/assets/icons/provider/groq.svg +3 -0
- package/src/assets/icons/provider/helicone.svg +6 -0
- package/src/assets/icons/provider/huggingface.svg +3 -0
- package/src/assets/icons/provider/iflowcn.svg +3 -0
- package/src/assets/icons/provider/inception.svg +4 -0
- package/src/assets/icons/provider/inference.svg +3 -0
- package/src/assets/icons/provider/io-net.svg +5 -0
- package/src/assets/icons/provider/jiekou.svg +4 -0
- package/src/assets/icons/provider/kilo.svg +4 -0
- package/src/assets/icons/provider/kimi-for-coding.svg +3 -0
- package/src/assets/icons/provider/kuae-cloud-coding-plan.svg +3 -0
- package/src/assets/icons/provider/llama.svg +3 -0
- package/src/assets/icons/provider/lmstudio.svg +24 -0
- package/src/assets/icons/provider/lucidquery.svg +3 -0
- package/src/assets/icons/provider/meganova.svg +3 -0
- package/src/assets/icons/provider/meituan.svg +6 -0
- package/src/assets/icons/provider/meta.svg +3 -0
- package/src/assets/icons/provider/minimax-cn-coding-plan.svg +24 -0
- package/src/assets/icons/provider/minimax-cn.svg +3 -0
- package/src/assets/icons/provider/minimax-coding-plan.svg +24 -0
- package/src/assets/icons/provider/minimax.svg +3 -0
- package/src/assets/icons/provider/mistral.svg +3 -0
- package/src/assets/icons/provider/moark.svg +3 -0
- package/src/assets/icons/provider/modelscope.svg +5 -0
- package/src/assets/icons/provider/moonshotai-cn.svg +3 -0
- package/src/assets/icons/provider/moonshotai.svg +3 -0
- package/src/assets/icons/provider/morph.svg +24 -0
- package/src/assets/icons/provider/nano-gpt.svg +3 -0
- package/src/assets/icons/provider/nebius.svg +4 -0
- package/src/assets/icons/provider/nova.svg +3 -0
- package/src/assets/icons/provider/novita-ai.svg +10 -0
- package/src/assets/icons/provider/nvidia.svg +3 -0
- package/src/assets/icons/provider/ollama-cloud.svg +7 -0
- package/src/assets/icons/provider/openai.svg +3 -0
- package/src/assets/icons/provider/opencode-go.svg +3 -0
- package/src/assets/icons/provider/opencode.svg +3 -0
- package/src/assets/icons/provider/openrouter.svg +3 -0
- package/src/assets/icons/provider/ovhcloud.svg +3 -0
- package/src/assets/icons/provider/perplexity-agent.svg +3 -0
- package/src/assets/icons/provider/perplexity.svg +3 -0
- package/src/assets/icons/provider/poe.svg +7 -0
- package/src/assets/icons/provider/privatemode-ai.svg +5 -0
- package/src/assets/icons/provider/qihang-ai.svg +9 -0
- package/src/assets/icons/provider/qiniu-ai.svg +7 -0
- package/src/assets/icons/provider/reflection.svg +3 -0
- package/src/assets/icons/provider/requesty.svg +24 -0
- package/src/assets/icons/provider/sap-ai-core.svg +24 -0
- package/src/assets/icons/provider/scaleway.svg +5 -0
- package/src/assets/icons/provider/siliconflow-cn.svg +3 -0
- package/src/assets/icons/provider/siliconflow.svg +3 -0
- package/src/assets/icons/provider/stackit.svg +4 -0
- package/src/assets/icons/provider/stepfun.svg +16 -0
- package/src/assets/icons/provider/submodel.svg +3 -0
- package/src/assets/icons/provider/synthetic.svg +24 -0
- package/src/assets/icons/provider/tencent-coding-plan.svg +5 -0
- package/src/assets/icons/provider/tencent.svg +3 -0
- package/src/assets/icons/provider/thinkingmachines.svg +3 -0
- package/src/assets/icons/provider/togetherai.svg +4 -0
- package/src/assets/icons/provider/upstage.svg +24 -0
- package/src/assets/icons/provider/v0.svg +3 -0
- package/src/assets/icons/provider/venice.svg +4 -0
- package/src/assets/icons/provider/vercel.svg +3 -0
- package/src/assets/icons/provider/vivgrid.svg +4 -0
- package/src/assets/icons/provider/vultr.svg +6 -0
- package/src/assets/icons/provider/wandb.svg +24 -0
- package/src/assets/icons/provider/xai.svg +3 -0
- package/src/assets/icons/provider/xiaomi.svg +3 -0
- package/src/assets/icons/provider/zai-coding-plan.svg +3 -0
- package/src/assets/icons/provider/zai.svg +3 -0
- package/src/assets/icons/provider/zenmux.svg +4 -0
- package/src/assets/icons/provider/zhipuai-coding-plan.svg +3 -0
- package/src/assets/icons/provider/zhipuai.svg +3 -0
- package/src/assets/images/social-share-black.png +0 -0
- package/src/assets/images/social-share-zen.png +0 -0
- package/src/assets/images/social-share.png +0 -0
- package/src/components/animated-number-machine.test.ts +140 -0
- package/src/components/animated-number.stories.tsx +35 -0
- package/src/components/app-icon.stories.tsx +73 -0
- package/src/components/card.stories.tsx +101 -0
- package/src/components/collapsible.stories.tsx +76 -0
- package/src/components/context-menu.stories.tsx +150 -0
- package/src/components/diagram-preview.stories.tsx +62 -0
- package/src/components/dock-surface.stories.tsx +26 -0
- package/src/components/document-surface.stories.tsx +42 -0
- package/src/components/error-details.stories.tsx +72 -0
- package/src/components/favicon.stories.tsx +49 -0
- package/src/components/file-icon-machine.test.ts +52 -0
- package/src/components/file-icon.stories.tsx +93 -0
- package/src/components/file-icons/sprite.svg +11707 -0
- package/src/components/font.stories.tsx +48 -0
- package/src/components/hover-card.stories.tsx +79 -0
- package/src/components/image-flight-machine.test.ts +184 -0
- package/src/components/image-flight.test.ts +173 -0
- package/src/components/image-preview.stories.tsx +392 -0
- package/src/components/image-zoom-machine.test.ts +154 -0
- package/src/components/image-zoom.test.ts +96 -0
- package/src/components/list.stories.tsx +221 -0
- package/src/components/logo.stories.tsx +62 -0
- package/src/components/menu-scroll.stories.tsx +73 -0
- package/src/components/popover-machine.test.ts +150 -0
- package/src/components/popover.stories.tsx +84 -0
- package/src/components/preview-controls.stories.tsx +40 -0
- package/src/components/progress.stories.tsx +69 -0
- package/src/components/provider-icon.stories.tsx +75 -0
- package/src/components/resize-handle-machine.test.ts +164 -0
- package/src/components/resize-handle.stories.tsx +81 -0
- package/src/components/rolling-number.stories.tsx +23 -0
- package/src/components/scroll-view-machine.test.ts +141 -0
- package/src/components/scroll-view.stories.tsx +68 -0
- package/src/components/scroll-view.test.ts +114 -0
- package/src/components/spinner-radar.test.ts +61 -0
- package/src/components/spinner.stories.tsx +40 -0
- package/src/components/sticky-accordion-header.stories.tsx +64 -0
- package/src/components/text-field-machine.test.ts +99 -0
- package/src/components/text-field.stories.tsx +132 -0
- package/src/components/text-reveal-machine.test.ts +157 -0
- package/src/components/text-reveal.stories.tsx +363 -0
- package/src/components/text-strikethrough.stories.tsx +296 -0
- package/src/components/thinking-heading.stories.tsx +900 -0
- package/src/components/truncated-text.stories.tsx +37 -0
- package/src/components/typewriter-machine.test.ts +177 -0
- package/src/components/typewriter.stories.tsx +51 -0
- package/src/context/dialog-machine.test.ts +295 -0
- package/src/context/i18n.test.ts +89 -0
- package/src/context/marked-base.test.ts +75 -0
- package/src/context/marked-parser.test.ts +167 -0
- package/src/context/marked-regression.test.ts +12 -0
- package/src/data-display/accordion/accordion.stories.tsx +76 -0
- package/src/data-display/avatar/avatar.stories.tsx +48 -0
- package/src/data-display/badge/badge.stories.tsx +75 -0
- package/src/data-display/diff-changes/diff-changes.stories.tsx +63 -0
- package/src/data-display/keybind/keybind.stories.tsx +77 -0
- package/src/data-display/line-comment/line-comment.stories.tsx +288 -0
- package/src/data-display/line-comment/machine.test.ts +385 -0
- package/src/data-display/project-avatar/animation-machine.test.ts +134 -0
- package/src/data-display/project-avatar/generated.test.ts +50 -0
- package/src/data-display/project-avatar/procedural.test.ts +16 -0
- package/src/data-display/project-avatar/project-avatar.stories.tsx +102 -0
- package/src/data-display/project-avatar/project-avatar.test.ts +21 -0
- package/src/data-display/project-avatar/project-icon-styles.stories.tsx +772 -0
- package/src/feedback/activity-ring/activity-ring.stories.tsx +20 -0
- package/src/feedback/loader/loader.stories.tsx +44 -0
- package/src/feedback/progress-circle/progress-circle.stories.tsx +56 -0
- package/src/feedback/toast/description.test.ts +20 -0
- package/src/feedback/toast/machine.test.ts +106 -0
- package/src/feedback/toast/toast.stories.tsx +186 -0
- package/src/forms/checkbox/checkbox.stories.tsx +104 -0
- package/src/forms/field/field.stories.tsx +129 -0
- package/src/forms/inline-input/inline-input.stories.tsx +37 -0
- package/src/forms/radio/radio.stories.tsx +145 -0
- package/src/forms/redirect-paste/redirect-paste.stories.tsx +101 -0
- package/src/forms/search-list/navigation.test.ts +40 -0
- package/src/forms/search-list/search-list.stories.tsx +108 -0
- package/src/forms/select/machine.test.ts +105 -0
- package/src/forms/select/select.stories.tsx +208 -0
- package/src/forms/switch/switch.stories.tsx +97 -0
- package/src/forms/text-input/text-input.stories.tsx +220 -0
- package/src/forms/textarea/textarea.stories.tsx +137 -0
- package/src/forms/typeahead/machine.test.ts +143 -0
- package/src/forms/typeahead/typeahead.stories.tsx +113 -0
- package/src/hooks/auto-scroll-machine.test.ts +212 -0
- package/src/hooks/list-machine.test.ts +263 -0
- package/src/hooks/spin-phase.test.ts +32 -0
- package/src/hooks/use-filtered-list.test.ts +41 -0
- package/src/icons/icon/icon.stories.tsx +131 -0
- package/src/layout/divider/divider.stories.tsx +38 -0
- package/src/motion/README.md +113 -0
- package/src/motion/core.test.ts +328 -0
- package/src/motion-tuning-features.test.ts +129 -0
- package/src/motion-tuning.test.ts +68 -0
- package/src/navigation/menu/machine.test.ts +85 -0
- package/src/navigation/menu/menu.stories.tsx +328 -0
- package/src/navigation/menu/submenu-machine.test.ts +71 -0
- package/src/navigation/segmented-control/segmented-control.stories.tsx +115 -0
- package/src/navigation/segmented-control/segmented-control.test.ts +123 -0
- package/src/navigation/tab-state-indicator.stories.tsx +24 -0
- package/src/navigation/tabs/tabs.stories.tsx +193 -0
- package/src/overlays/dialog/dialog.stories.tsx +365 -0
- package/src/overlays/mcp-sign-in/machine.test.ts +215 -0
- package/src/overlays/tooltip/machine.test.ts +214 -0
- package/src/overlays/tooltip/tooltip.stories.tsx +155 -0
- package/src/styles/blue-tokens.stories.tsx +215 -0
- package/src/theme/desktop-theme.schema.json +168 -0
- package/src/theme/machine.test.ts +498 -0
- package/src/theme/v2/resolve.test.ts +120 -0
- package/src/typography/slash/slash.stories.tsx +26 -0
- package/src/typography/text-shimmer/machine.test.ts +117 -0
- package/src/typography/text-shimmer/text-shimmer.stories.tsx +64 -0
- package/src/typography/wordmark/wordmark.stories.tsx +19 -0
- package/test/solid-jsx.ts +20 -0
- package/tsconfig.build.json +14 -0
- package/tsconfig.json +23 -0
- package/vite.config.ts +61 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { InlineInput, type InlineInputProps } from "./inline-input"
|
|
2
|
+
|
|
3
|
+
const docs = `### Overview
|
|
4
|
+
Compact inline input for short values.
|
|
5
|
+
|
|
6
|
+
### API
|
|
7
|
+
- Optional: \`width\` to set a fixed width.
|
|
8
|
+
- Accepts standard input props.
|
|
9
|
+
|
|
10
|
+
### Accessibility
|
|
11
|
+
- Provide a label or aria-label when used standalone.
|
|
12
|
+
|
|
13
|
+
### Theming/tokens
|
|
14
|
+
- Uses \`data-component="inline-input"\`.
|
|
15
|
+
`
|
|
16
|
+
|
|
17
|
+
export default {
|
|
18
|
+
title: "UI/InlineInput",
|
|
19
|
+
id: "ui-inline-input",
|
|
20
|
+
component: InlineInput,
|
|
21
|
+
args: {
|
|
22
|
+
"aria-label": "Inline value",
|
|
23
|
+
placeholder: "Type...",
|
|
24
|
+
value: "Inline",
|
|
25
|
+
width: "",
|
|
26
|
+
type: "text",
|
|
27
|
+
disabled: false,
|
|
28
|
+
readOnly: false,
|
|
29
|
+
} satisfies InlineInputProps,
|
|
30
|
+
argTypes: { type: { options: ["text", "search", "email", "password", "url", "tel", "number"] } },
|
|
31
|
+
tags: ["autodocs"],
|
|
32
|
+
parameters: { docs: { description: { component: docs } } },
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const Basic = {}
|
|
36
|
+
|
|
37
|
+
export const FixedWidth = { args: { placeholder: "", value: "80px", width: "80px" } }
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { createSignal } from "solid-js"
|
|
2
|
+
import { RadioGroup, RadioItem, type RadioGroupProps } from "./radio"
|
|
3
|
+
|
|
4
|
+
const docs = `### Overview
|
|
5
|
+
Single-select options using Kobalte RadioGroup.
|
|
6
|
+
|
|
7
|
+
### API
|
|
8
|
+
- \`RadioGroup\` forwards Kobalte RadioGroup props (\`value\`, \`defaultValue\`, \`onChange\`, \`name\`, \`required\`, \`validationState\`, \`disabled\`).
|
|
9
|
+
- \`surface\`: \`base\` (default) or \`layer-1\`, the background of the group's controls.
|
|
10
|
+
- \`RadioItem\` forwards Kobalte item props (\`value\`, \`disabled\`), and adds \`label\` and optional \`description\`.
|
|
11
|
+
|
|
12
|
+
### Behavior
|
|
13
|
+
- Controlled or uncontrolled via \`value\` / \`defaultValue\` on the group (items declare \`value\` only).
|
|
14
|
+
|
|
15
|
+
### Theming/tokens
|
|
16
|
+
- Uses \`data-component="radio-v2"\` and slot attributes.
|
|
17
|
+
`
|
|
18
|
+
|
|
19
|
+
export default {
|
|
20
|
+
title: "UI/Radio",
|
|
21
|
+
id: "ui-radio",
|
|
22
|
+
component: RadioGroup,
|
|
23
|
+
args: {
|
|
24
|
+
label: "Notification frequency",
|
|
25
|
+
description: "",
|
|
26
|
+
hideLabel: false,
|
|
27
|
+
surface: "base",
|
|
28
|
+
disabled: false,
|
|
29
|
+
readOnly: false,
|
|
30
|
+
orientation: "vertical",
|
|
31
|
+
required: false,
|
|
32
|
+
validationState: "valid",
|
|
33
|
+
} satisfies RadioGroupProps,
|
|
34
|
+
argTypes: {
|
|
35
|
+
validationState: { options: ["valid", "invalid"] },
|
|
36
|
+
surface: { options: ["base", "layer-1"] },
|
|
37
|
+
orientation: { options: ["vertical", "horizontal"] },
|
|
38
|
+
},
|
|
39
|
+
tags: ["autodocs"],
|
|
40
|
+
parameters: {
|
|
41
|
+
docs: {
|
|
42
|
+
description: {
|
|
43
|
+
component: docs,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const Basic = {
|
|
50
|
+
render: (args: RadioGroupProps) => (
|
|
51
|
+
<RadioGroup {...args} defaultValue="daily" name="frequency">
|
|
52
|
+
<RadioItem value="daily" label="Daily" description="Once per day at 9am." />
|
|
53
|
+
<RadioItem value="weekly" label="Weekly" description="Every Monday morning." />
|
|
54
|
+
<RadioItem value="never" label="Never" description="No notifications." />
|
|
55
|
+
</RadioGroup>
|
|
56
|
+
),
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const Controlled = {
|
|
60
|
+
args: { label: "Controlled" },
|
|
61
|
+
render: (args: RadioGroupProps) => {
|
|
62
|
+
const [value, setValue] = createSignal("weekly")
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<div style={{ display: "grid", gap: "12px" }}>
|
|
66
|
+
<RadioGroup {...args} value={value()} onChange={setValue} name="controlled-frequency">
|
|
67
|
+
<RadioItem value="daily" label="Daily" />
|
|
68
|
+
<RadioItem value="weekly" label="Weekly" />
|
|
69
|
+
<RadioItem value="never" label="Never" />
|
|
70
|
+
</RadioGroup>
|
|
71
|
+
<div style={{ "font-family": "var(--v2-font-family-sans)", "font-size": "12px", color: "#808080" }}>
|
|
72
|
+
Selected: {value()}
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
)
|
|
76
|
+
},
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export const States = {
|
|
80
|
+
args: { label: "Default" },
|
|
81
|
+
render: (args: RadioGroupProps) => (
|
|
82
|
+
<div style={{ display: "grid", gap: "20px" }}>
|
|
83
|
+
<RadioGroup {...args} defaultValue="a" name="state-default">
|
|
84
|
+
<RadioItem value="a" label="Option A" />
|
|
85
|
+
<RadioItem value="b" label="Option B" description="Has a description." />
|
|
86
|
+
</RadioGroup>
|
|
87
|
+
|
|
88
|
+
<RadioGroup label="Disabled group" defaultValue="a" name="state-disabled" disabled>
|
|
89
|
+
<RadioItem value="a" label="Option A" />
|
|
90
|
+
<RadioItem value="b" label="Option B" />
|
|
91
|
+
</RadioGroup>
|
|
92
|
+
|
|
93
|
+
<RadioGroup label="Disabled item" defaultValue="a" name="state-disabled-item">
|
|
94
|
+
<RadioItem value="a" label="Enabled" />
|
|
95
|
+
<RadioItem value="b" label="Disabled" disabled />
|
|
96
|
+
</RadioGroup>
|
|
97
|
+
|
|
98
|
+
<RadioGroup
|
|
99
|
+
label="Invalid"
|
|
100
|
+
description="Pick one option."
|
|
101
|
+
defaultValue="a"
|
|
102
|
+
name="state-invalid"
|
|
103
|
+
validationState="invalid"
|
|
104
|
+
required
|
|
105
|
+
>
|
|
106
|
+
<RadioItem value="a" label="Option A" />
|
|
107
|
+
<RadioItem value="b" label="Option B" />
|
|
108
|
+
</RadioGroup>
|
|
109
|
+
</div>
|
|
110
|
+
),
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export const HiddenItemLabels = {
|
|
114
|
+
args: { label: "Notification frequency", description: "Daily or weekly" },
|
|
115
|
+
render: (args: RadioGroupProps) => (
|
|
116
|
+
<RadioGroup {...args} name="hidden-labels">
|
|
117
|
+
<RadioItem value="daily" label="Daily" hideLabel />
|
|
118
|
+
<RadioItem value="weekly" label="Weekly" hideLabel />
|
|
119
|
+
</RadioGroup>
|
|
120
|
+
),
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export const Surfaces = {
|
|
124
|
+
render: () => (
|
|
125
|
+
<div style={{ display: "grid", "grid-template-columns": "repeat(2, max-content)", gap: "32px" }}>
|
|
126
|
+
{(["base", "layer-1"] as const).map((surface) => (
|
|
127
|
+
<div style={{ display: "grid", gap: "20px" }}>
|
|
128
|
+
<RadioGroup
|
|
129
|
+
label={surface === "base" ? "Base" : "Layer 1"}
|
|
130
|
+
surface={surface}
|
|
131
|
+
defaultValue="selected"
|
|
132
|
+
name={`surface-${surface}`}
|
|
133
|
+
>
|
|
134
|
+
<RadioItem value="default" label="Default" />
|
|
135
|
+
<RadioItem value="selected" label="Selected" />
|
|
136
|
+
<RadioItem value="disabled" label="Disabled" disabled />
|
|
137
|
+
</RadioGroup>
|
|
138
|
+
<RadioGroup label="Invalid" surface={surface} validationState="invalid" name={`surface-${surface}-invalid`}>
|
|
139
|
+
<RadioItem value="default" label="Invalid" />
|
|
140
|
+
</RadioGroup>
|
|
141
|
+
</div>
|
|
142
|
+
))}
|
|
143
|
+
</div>
|
|
144
|
+
),
|
|
145
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { createEffect, createSignal, on, Show } from "solid-js"
|
|
2
|
+
import { Button } from "@zyro-sec/ui/button"
|
|
3
|
+
import { RedirectPasteForm, type RedirectPasteError } from "./redirect-paste"
|
|
4
|
+
|
|
5
|
+
type Phase = "editing" | "required" | "rejected" | "submitting" | "accepted"
|
|
6
|
+
|
|
7
|
+
type Args = { value: string; phase: Phase; rejection: string }
|
|
8
|
+
|
|
9
|
+
const callback = "http://localhost/callback?code=story-example"
|
|
10
|
+
|
|
11
|
+
function Preview(props: Args) {
|
|
12
|
+
const [phase, setPhase] = createSignal(props.phase)
|
|
13
|
+
|
|
14
|
+
const [value, setValue] = createSignal(props.value)
|
|
15
|
+
|
|
16
|
+
createEffect(
|
|
17
|
+
on([() => props.phase, () => props.value], () => {
|
|
18
|
+
setPhase(props.phase)
|
|
19
|
+
setValue(props.value)
|
|
20
|
+
}),
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
const locked = () => phase() === "submitting" || phase() === "accepted"
|
|
24
|
+
|
|
25
|
+
const error = (): RedirectPasteError | undefined => {
|
|
26
|
+
if (phase() === "required") return { type: "required" }
|
|
27
|
+
|
|
28
|
+
if (phase() === "rejected") return { type: "rejected", message: props.rejection }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<div class="grid w-96 max-w-full gap-4 text-sm">
|
|
33
|
+
<RedirectPasteForm
|
|
34
|
+
value={value()}
|
|
35
|
+
locked={locked()}
|
|
36
|
+
submitting={phase() === "submitting"}
|
|
37
|
+
error={error()}
|
|
38
|
+
onInput={(next) => {
|
|
39
|
+
setValue(next)
|
|
40
|
+
setPhase("editing")
|
|
41
|
+
}}
|
|
42
|
+
onSubmit={() => {
|
|
43
|
+
if (!locked()) setPhase(value().trim() ? "submitting" : "required")
|
|
44
|
+
}}
|
|
45
|
+
/>
|
|
46
|
+
<Show when={phase() === "submitting"}>
|
|
47
|
+
<div class="grid gap-2 border-t border-v2-border-border-base pt-3">
|
|
48
|
+
<p role="status" class="text-xs text-v2-text-text-muted">
|
|
49
|
+
Choose the local callback response.
|
|
50
|
+
</p>
|
|
51
|
+
<div class="flex gap-2">
|
|
52
|
+
<Button size="small" onClick={() => setPhase("accepted")}>
|
|
53
|
+
Accept callback
|
|
54
|
+
</Button>
|
|
55
|
+
<Button size="small" onClick={() => setPhase("rejected")}>
|
|
56
|
+
Reject callback
|
|
57
|
+
</Button>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
</Show>
|
|
61
|
+
<Show when={phase() === "accepted"}>
|
|
62
|
+
<div class="flex items-center gap-3">
|
|
63
|
+
<p role="status">Callback accepted.</p>
|
|
64
|
+
<Button
|
|
65
|
+
size="small"
|
|
66
|
+
onClick={() => {
|
|
67
|
+
setValue("")
|
|
68
|
+
setPhase("editing")
|
|
69
|
+
}}
|
|
70
|
+
>
|
|
71
|
+
Start again
|
|
72
|
+
</Button>
|
|
73
|
+
</div>
|
|
74
|
+
</Show>
|
|
75
|
+
</div>
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export default {
|
|
80
|
+
title: "UI/RedirectPasteForm",
|
|
81
|
+
id: "ui-redirect-paste-form",
|
|
82
|
+
component: Preview,
|
|
83
|
+
args: {
|
|
84
|
+
value: "",
|
|
85
|
+
phase: "editing",
|
|
86
|
+
rejection: "This callback has expired. Paste the new redirect URL.",
|
|
87
|
+
} satisfies Args,
|
|
88
|
+
argTypes: { phase: { control: "select", options: ["editing", "required", "rejected", "submitting", "accepted"] } },
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export const Empty = {}
|
|
92
|
+
|
|
93
|
+
export const ReadyToSubmit = { args: { value: callback } }
|
|
94
|
+
|
|
95
|
+
export const Required = { args: { phase: "required" } }
|
|
96
|
+
|
|
97
|
+
export const Rejected = { args: { value: callback, phase: "rejected" } }
|
|
98
|
+
|
|
99
|
+
export const Submitting = { args: { value: callback, phase: "submitting" } }
|
|
100
|
+
|
|
101
|
+
export const Locked = { args: { value: callback, phase: "accepted" } }
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { expect, test } from "bun:test"
|
|
2
|
+
import { searchListMove, searchListTarget, type SearchListMove } from "./navigation"
|
|
3
|
+
|
|
4
|
+
const key = (key: string, modifiers: { metaKey?: boolean; altKey?: boolean; shiftKey?: boolean } = {}) => ({
|
|
5
|
+
key,
|
|
6
|
+
ctrlKey: false,
|
|
7
|
+
metaKey: false,
|
|
8
|
+
altKey: false,
|
|
9
|
+
shiftKey: false,
|
|
10
|
+
...modifiers,
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
test("⌘ and ⌥ arrows jump sections, Home and End reach the ends, and Shift stays with the input", () => {
|
|
14
|
+
expect(searchListMove(key("ArrowDown"))).toBe("next")
|
|
15
|
+
expect(searchListMove(key("ArrowDown", { metaKey: true }))).toBe("nextSection")
|
|
16
|
+
expect(searchListMove(key("ArrowUp", { altKey: true }))).toBe("previousSection")
|
|
17
|
+
expect(searchListMove(key("Home"))).toBe("first")
|
|
18
|
+
expect(searchListMove(key("End", { shiftKey: true }))).toBeUndefined()
|
|
19
|
+
expect(searchListMove(key("Home", { metaKey: true }))).toBeUndefined()
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
// Sections a a | b | c c c, so rows 0–1, 2 and 3–5.
|
|
23
|
+
const sections = ["a", "a", "b", "c", "c", "c"]
|
|
24
|
+
|
|
25
|
+
test.each<[number, SearchListMove, number]>([
|
|
26
|
+
[0, "nextSection", 2],
|
|
27
|
+
[1, "nextSection", 2],
|
|
28
|
+
[2, "nextSection", 3],
|
|
29
|
+
[4, "nextSection", 0],
|
|
30
|
+
[4, "previousSection", 3],
|
|
31
|
+
[3, "previousSection", 2],
|
|
32
|
+
[2, "previousSection", 0],
|
|
33
|
+
[0, "previousSection", 3],
|
|
34
|
+
[5, "next", 0],
|
|
35
|
+
[0, "previous", 5],
|
|
36
|
+
[3, "first", 0],
|
|
37
|
+
[1, "last", 5],
|
|
38
|
+
])("from row %i, %s lands on row %i", (from, move, to) => {
|
|
39
|
+
expect(searchListTarget(sections, from, move)).toBe(to)
|
|
40
|
+
})
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { createEffect, createMemo } from "solid-js"
|
|
2
|
+
import { createStore } from "solid-js/store"
|
|
3
|
+
import { Keybind } from "@zyro-sec/ui/keybind"
|
|
4
|
+
import { SearchHighlight, SearchList } from "./search-list"
|
|
5
|
+
|
|
6
|
+
type Row = { id: string; section: string; title: string; description: string; keybind?: string[] }
|
|
7
|
+
|
|
8
|
+
const names = ["Sessions", "Commands", "Settings", "Files", "Models", "Projects", "Servers", "Themes"]
|
|
9
|
+
|
|
10
|
+
const words = ["Desktop", "Palette", "Sticky headers", "Command menu", "Session search", "Model selector", "Theme"]
|
|
11
|
+
|
|
12
|
+
const args = {
|
|
13
|
+
sections: 4,
|
|
14
|
+
rows: 6,
|
|
15
|
+
sticky: true,
|
|
16
|
+
query: "",
|
|
17
|
+
open: true,
|
|
18
|
+
popover: false,
|
|
19
|
+
grouped: true,
|
|
20
|
+
compactRows: false,
|
|
21
|
+
footer: "",
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function SearchListStory(props: typeof args) {
|
|
25
|
+
const [store, setStore] = createStore({ query: props.query, selected: "" })
|
|
26
|
+
|
|
27
|
+
createEffect(() => setStore("query", props.query))
|
|
28
|
+
|
|
29
|
+
const rows = createMemo(() =>
|
|
30
|
+
names.slice(0, Math.max(1, props.sections)).flatMap((section, s) =>
|
|
31
|
+
Array.from(
|
|
32
|
+
{ length: Math.max(1, props.rows) },
|
|
33
|
+
(_, index): Row => ({
|
|
34
|
+
id: `${section}-${index}`,
|
|
35
|
+
section,
|
|
36
|
+
title: `${words[(index + s) % words.length]} ${index + 1}`,
|
|
37
|
+
description: section === "Sessions" ? "opencode" : section,
|
|
38
|
+
keybind: section === "Commands" && index < 3 ? ["⌥", index % 2 ? "↓" : "↑"] : undefined,
|
|
39
|
+
}),
|
|
40
|
+
),
|
|
41
|
+
),
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
const visible = createMemo(() => {
|
|
45
|
+
const query = store.query.trim().toLowerCase()
|
|
46
|
+
|
|
47
|
+
return query ? rows().filter((row) => `${row.title} ${row.description}`.toLowerCase().includes(query)) : rows()
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<div
|
|
52
|
+
class="flex w-[640px] max-w-full flex-col rounded-xl bg-v2-background-bg-base shadow-[var(--v2-elevation-floating)]"
|
|
53
|
+
classList={{ "h-[480px] overflow-hidden": props.open && !props.popover }}
|
|
54
|
+
data-static-headers={props.sticky ? undefined : ""}
|
|
55
|
+
>
|
|
56
|
+
<style>{`[data-static-headers] [data-slot="search-list-header"] { position: static; }`}</style>
|
|
57
|
+
<SearchList
|
|
58
|
+
query={store.query}
|
|
59
|
+
onQuery={(query) => setStore("query", query)}
|
|
60
|
+
placeholder="Search files, commands, and sessions"
|
|
61
|
+
items={visible()}
|
|
62
|
+
key={(row) => row.id}
|
|
63
|
+
open={props.open}
|
|
64
|
+
popover={props.popover}
|
|
65
|
+
section={props.grouped ? (row) => row.section : undefined}
|
|
66
|
+
header={props.grouped ? (row) => row.section : undefined}
|
|
67
|
+
footer={[props.footer, store.selected && `Selected: ${store.selected}`].filter(Boolean).join(" · ")}
|
|
68
|
+
empty="No results"
|
|
69
|
+
onSelect={(row) => setStore("selected", row.title)}
|
|
70
|
+
>
|
|
71
|
+
{(row, attrs) => (
|
|
72
|
+
<button type="button" data-size={props.compactRows ? "compact" : undefined} {...attrs}>
|
|
73
|
+
<span class="flex min-w-0 items-center gap-1.5 text-[13px] leading-4 tracking-[-0.04px]">
|
|
74
|
+
<span class="truncate font-[530] text-v2-text-text-base">
|
|
75
|
+
<SearchHighlight text={row().title} />
|
|
76
|
+
</span>
|
|
77
|
+
<span class="truncate text-v2-text-text-muted">
|
|
78
|
+
<SearchHighlight text={row().description} />
|
|
79
|
+
</span>
|
|
80
|
+
</span>
|
|
81
|
+
{row().keybind && <Keybind keys={row().keybind!} variant="neutral" />}
|
|
82
|
+
</button>
|
|
83
|
+
)}
|
|
84
|
+
</SearchList>
|
|
85
|
+
</div>
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export default {
|
|
90
|
+
title: "UI/Search List",
|
|
91
|
+
id: "ui-search-list",
|
|
92
|
+
component: SearchListStory,
|
|
93
|
+
args,
|
|
94
|
+
argTypes: {
|
|
95
|
+
sections: { control: { type: "range", min: 1, max: 8, step: 1 } },
|
|
96
|
+
rows: { control: { type: "range", min: 1, max: 200, step: 1 } },
|
|
97
|
+
},
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export const Palette = {}
|
|
101
|
+
|
|
102
|
+
export const LongLists = { args: { sections: 6, rows: 120 } }
|
|
103
|
+
|
|
104
|
+
export const Searching = { args: { query: "desk" } }
|
|
105
|
+
|
|
106
|
+
export const WithoutStickyHeaders = { args: { sticky: false } }
|
|
107
|
+
|
|
108
|
+
export const Empty = { args: { query: "no matches" } }
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test"
|
|
2
|
+
import {
|
|
3
|
+
createSelectHighlightState,
|
|
4
|
+
transitionSelectHighlight,
|
|
5
|
+
type SelectHighlightEvent,
|
|
6
|
+
type SelectHighlightState,
|
|
7
|
+
type SelectHighlightTransition,
|
|
8
|
+
} from "./machine"
|
|
9
|
+
|
|
10
|
+
const OPEN: SelectHighlightEvent = { type: "open.changed", open: true }
|
|
11
|
+
|
|
12
|
+
const CLOSE: SelectHighlightEvent = { type: "open.changed", open: false }
|
|
13
|
+
|
|
14
|
+
const highlight = (key: string): SelectHighlightEvent => ({ type: "highlight.changed", key, previewable: true })
|
|
15
|
+
|
|
16
|
+
const select = (key: string | undefined, closing = true): SelectHighlightEvent => ({
|
|
17
|
+
type: "option.selected",
|
|
18
|
+
key,
|
|
19
|
+
closing,
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
function run(state: SelectHighlightState, ...events: SelectHighlightEvent[]) {
|
|
23
|
+
const steps: SelectHighlightTransition[] = []
|
|
24
|
+
|
|
25
|
+
events.forEach((event) => steps.push(transitionSelectHighlight(steps.at(-1)?.state ?? state, event)))
|
|
26
|
+
|
|
27
|
+
return steps
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const effects = (steps: SelectHighlightTransition[]) => steps.map((step) => step.effects.map((effect) => effect.type))
|
|
31
|
+
|
|
32
|
+
describe("select highlight preview", () => {
|
|
33
|
+
test("choosing the previewed option keeps its preview through the close", () => {
|
|
34
|
+
// Before: onChange ran the highlighted option's undo after onSelect had committed it.
|
|
35
|
+
const steps = run(createSelectHighlightState(false), OPEN, highlight("b"), select("b"), CLOSE)
|
|
36
|
+
|
|
37
|
+
expect(steps[1]!.effects).toEqual([{ type: "preview.apply", key: "b" }])
|
|
38
|
+
expect(effects(steps).slice(2)).toEqual([[], []])
|
|
39
|
+
expect(steps.at(-1)!.state).toEqual({ status: "closed" })
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
test("choosing another option, or clearing, reverts the preview before the caller commits", () => {
|
|
43
|
+
for (const key of ["b", undefined]) {
|
|
44
|
+
const steps = run(createSelectHighlightState(false), OPEN, highlight("a"), select(key), CLOSE)
|
|
45
|
+
|
|
46
|
+
expect(effects(steps).slice(2)).toEqual([["preview.revert"], []])
|
|
47
|
+
expect(steps.at(-1)!.state).toEqual({ status: "closed" })
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
test("items that highlight while the menu is closing or closed preview nothing, and a reopen previews again", () => {
|
|
52
|
+
// Before: a focus or pointer event during the exit animation applied a preview nothing ever reverted.
|
|
53
|
+
const committed = run(createSelectHighlightState(false), OPEN, highlight("a"), select("a")).at(-1)!.state
|
|
54
|
+
const late = transitionSelectHighlight(committed, highlight("c"))
|
|
55
|
+
|
|
56
|
+
expect(late.state).toBe(committed)
|
|
57
|
+
expect(late.effects).toEqual([])
|
|
58
|
+
const closed = transitionSelectHighlight(committed, CLOSE).state
|
|
59
|
+
expect(transitionSelectHighlight(closed, highlight("c")).state).toBe(closed)
|
|
60
|
+
|
|
61
|
+
const steps = run(closed, OPEN, highlight("c"), CLOSE)
|
|
62
|
+
expect(steps[1]!.effects).toEqual([{ type: "preview.apply", key: "c" }])
|
|
63
|
+
expect(effects(steps)[2]).toEqual(["preview.revert"])
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
test("a controlled close reverts the preview", () => {
|
|
67
|
+
// Before: a parent setting open={false} fired no onOpenChange, so the preview stayed applied while closed.
|
|
68
|
+
const steps = run(createSelectHighlightState(true), highlight("a"), CLOSE)
|
|
69
|
+
|
|
70
|
+
expect(effects(steps)).toEqual([["preview.apply"], ["preview.revert"]])
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
test("moving between options reverts the previous preview first, and the same option does nothing", () => {
|
|
74
|
+
const steps = run(createSelectHighlightState(true), highlight("a"), highlight("a"), highlight("b"))
|
|
75
|
+
|
|
76
|
+
expect(steps[1]!.state).toBe(steps[0]!.state)
|
|
77
|
+
expect(steps[2]!.effects).toEqual([{ type: "preview.revert" }, { type: "preview.apply", key: "b" }])
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
test("a select without onHighlight previews nothing and drops a preview it had", () => {
|
|
81
|
+
const off: SelectHighlightEvent = { type: "highlight.changed", key: "a", previewable: false }
|
|
82
|
+
const idle = createSelectHighlightState(true)
|
|
83
|
+
|
|
84
|
+
expect(transitionSelectHighlight(idle, off).state).toBe(idle)
|
|
85
|
+
expect(effects(run(idle, highlight("b"), off))[1]).toEqual(["preview.revert"])
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
test("a choice that keeps the menu open keeps previewing", () => {
|
|
89
|
+
const steps = run(createSelectHighlightState(true), highlight("a"), select("a", false), highlight("b"))
|
|
90
|
+
|
|
91
|
+
expect(steps[1]!.state).toEqual({ status: "idle" })
|
|
92
|
+
expect(steps[1]!.effects).toEqual([])
|
|
93
|
+
expect(steps[2]!.effects).toEqual([{ type: "preview.apply", key: "b" }])
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
test("disposal reverts an active preview and ignores everything after", () => {
|
|
97
|
+
const steps = run(createSelectHighlightState(true), highlight("a"), { type: "disposed" })
|
|
98
|
+
|
|
99
|
+
expect(effects(steps)[1]).toEqual(["preview.revert"])
|
|
100
|
+
const disposed = steps[1]!.state
|
|
101
|
+
expect(transitionSelectHighlight(disposed, OPEN).state).toBe(disposed)
|
|
102
|
+
expect(transitionSelectHighlight(disposed, highlight("b")).effects).toEqual([])
|
|
103
|
+
expect(transitionSelectHighlight(createSelectHighlightState(false), { type: "disposed" }).effects).toEqual([])
|
|
104
|
+
})
|
|
105
|
+
})
|