diff --git a/design-system/AGENTS.md b/design-system/AGENTS.md index 1ad64768dd..1edd2fb097 100644 --- a/design-system/AGENTS.md +++ b/design-system/AGENTS.md @@ -56,3 +56,12 @@ For SplitView geometry, drag cancellation, and cached resize bounds: pnpm --dir design-system run build:ui && node --test design-system/packages/ui/tests/split-view.test.mjs pnpm --dir src/web-ui exec vitest run src/shared/ui/SplitView.test.tsx ``` + +For Select presentation, compact/expanded labels, native form participation and keyboard selection: + +```bash +pnpm --dir design-system run build:ui && node --test design-system/packages/ui/tests/select.test.mjs design-system/packages/ui/tests/registry.test.mjs +pnpm --dir src/web-ui exec vitest run src/shared/ui/Select.test.tsx +``` + +These package and DOM checks do not establish native rendering or live remote behavior. diff --git a/design-system/packages/ui/README.md b/design-system/packages/ui/README.md index 95d2221463..3cc10abf85 100644 --- a/design-system/packages/ui/README.md +++ b/design-system/packages/ui/README.md @@ -591,7 +591,11 @@ Use `Select` for simple options; its hidden native control preserves form participation. `width="content"` fits the collapsed control to the selected label; `popupWidth="content"` independently fits the expanded surface to its options, within the viewport. The defaults remain a full-width control and a popup that -matches the trigger. `Combobox` adds searchable single +matches the trigger. `variant="pill"` uses badge typography, spacing and rounded +ends while retaining the selected control size. An option's `selectedLabel` +shortens only the closed trigger; the expanded header, listbox and native form +option retain its full `label`. Combine these with content widths for compact +inline platform or scope selectors. `Combobox` adds searchable single selection, grouped options, explicit custom-value creation and async loading states. `MultiSelect` owns multiple selection, removable tags and select-all. Controlled values are authoritative; option discovery remains host-owned. diff --git a/design-system/packages/ui/src/components/Select/Select.meta.ts b/design-system/packages/ui/src/components/Select/Select.meta.ts index a96dc69609..29069e8e88 100644 --- a/design-system/packages/ui/src/components/Select/Select.meta.ts +++ b/design-system/packages/ui/src/components/Select/Select.meta.ts @@ -6,12 +6,13 @@ export const selectMeta = { maturity: "stable", name: "Select", props: [ - { name: "options", type: "readonly SelectOption[] (supports tooltip, testId and data-* attributes)" }, + { name: "options", type: "readonly SelectOption[] (supports selectedLabel, tooltip, testId and data-* attributes)" }, { name: "value", type: "SelectValue" }, { name: "defaultValue", type: "SelectValue" }, { name: "placeholder", type: "string" }, { name: "leading", type: "ReactNode" }, { defaultValue: "md", name: "size", type: "sm | md | lg" }, + { defaultValue: "field", name: "variant", type: "field | pill" }, { defaultValue: "bottom", name: "placement", type: "top | bottom" }, { defaultValue: "full", name: "width", type: "full | content" }, { defaultValue: "trigger", name: "popupWidth", type: "trigger | content" }, @@ -51,6 +52,14 @@ export const selectMeta = { "control.select.contentGap", "control.select.indicatorSize", "control.select.radius", + "control.statusPill.gap", + "control.statusPill.paddingInline", + "control.statusPill.radius", + "type.meta.fontFamily", + "type.meta.fontSize", + "type.meta.fontWeight", + "type.meta.letterSpacing", + "type.statusPill.lineHeight", "overlay.menu.inlineSize", "overlay.menu.maxBlockSize", "overlay.menu.surfacePadding", diff --git a/design-system/packages/ui/src/components/Select/Select.module.css b/design-system/packages/ui/src/components/Select/Select.module.css index 70a31ce43b..a87a2a596e 100644 --- a/design-system/packages/ui/src/components/Select/Select.module.css +++ b/design-system/packages/ui/src/components/Select/Select.module.css @@ -85,6 +85,18 @@ box-shadow var(--openbitfun-motion-duration-fast) var(--openbitfun-motion-easing-standard); } + .root[data-variant="pill"] > .trigger { + gap: var(--openbitfun-control-status-pill-gap); + padding-inline: var(--openbitfun-control-status-pill-padding-inline); + border-radius: var(--openbitfun-control-status-pill-radius); + background: var(--openbitfun-color-action-neutral-surface); + font-family: var(--openbitfun-type-meta-font-family); + font-size: var(--openbitfun-type-meta-font-size); + font-weight: var(--openbitfun-type-meta-font-weight); + line-height: var(--openbitfun-type-status-pill-line-height); + letter-spacing: var(--openbitfun-type-meta-letter-spacing); + } + .trigger:is(:hover, [data-openbitfun-preview-state="hover"]):not(:disabled) { border-color: var(--openbitfun-color-field-border-hover); background: var(--openbitfun-color-field-background-hover); @@ -293,6 +305,7 @@ @media (forced-colors: active) { .trigger, + .root[data-variant="pill"] > .trigger, .popover, .root[data-invalid="true"] .trigger { border-color: ButtonText; @@ -303,7 +316,8 @@ border: 0; } - .trigger:focus-visible { + .trigger:focus-visible, + .root[data-variant="pill"] > .trigger:focus-visible { border-color: Highlight; box-shadow: 0 0 0 var(--openbitfun-focus-width) Highlight; } diff --git a/design-system/packages/ui/src/components/Select/Select.tsx b/design-system/packages/ui/src/components/Select/Select.tsx index 980c66ef62..17c3674a54 100644 --- a/design-system/packages/ui/src/components/Select/Select.tsx +++ b/design-system/packages/ui/src/components/Select/Select.tsx @@ -42,6 +42,8 @@ export interface SelectOption { disabled?: boolean; group?: string; label: string; + /** Optional compact label for the closed trigger; options keep the full label. */ + selectedLabel?: string; /** Optional help shown on hover for the option and selected value. */ tooltip?: string; testAttributes?: Record<`data-${string}`, string | number | boolean | undefined>; @@ -68,6 +70,8 @@ export interface SelectProps popupWidth?: "trigger" | "content"; size?: SelectSize; value?: SelectValue; + /** A compact visual treatment using the system's badge typography and radius. */ + variant?: "field" | "pill"; /** Fill the available field width or fit the currently selected label. */ width?: "full" | "content"; } @@ -155,6 +159,7 @@ export const Select = forwardRef(function Select tabIndex, title, value, + variant = "field", width = "full", ...nativeProps }, forwardedRef) { @@ -360,7 +365,7 @@ export const Select = forwardRef(function Select ) : row; }; - const renderTriggerContent = () => ( + const renderTriggerContent = (expanded = false) => ( <> {leading !== undefined && leading !== null && (