mirror of
https://github.com/hanzoai/o11y-components.git
synced 2026-10-30 14:54:15 +00:00
A version written into a manifest is written into every manifest that wants it, which is how eslint came to exist in a hundred and four forms across this estate and how a package came to resolve twice at run time. The catalog moves the number out of the manifest: a manifest names the package, the workspace names the version. Four are held below their latest because the newer release cannot be used, and the reason is recorded rather than the version alone: @noble/hashes 2 renamed every subpath the web3 stack imports, @splinetool/runtime 2 depends on a package that was never published, @dynamic-labs 5.4.1 the same, and react-resizable-panels 3 points its types condition at the bundle.
144 lines
3.6 KiB
TypeScript
144 lines
3.6 KiB
TypeScript
import { Select, SelectContent, SelectItem, SelectTrigger } from '@signozhq/ui';
|
|
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
import { useState } from 'react';
|
|
|
|
const meta: Meta<typeof SelectTrigger> = {
|
|
title: 'Primitive Components/Select/SelectTrigger',
|
|
component: SelectTrigger,
|
|
argTypes: {
|
|
placeholder: {
|
|
control: 'text',
|
|
description: 'Text shown when no value is selected.',
|
|
table: { category: 'Content', type: { summary: 'React.ReactNode' } },
|
|
},
|
|
children: {
|
|
control: false,
|
|
description: 'Custom trigger content. Overrides the default value/placeholder display.',
|
|
table: { category: 'Content', type: { summary: 'React.ReactNode' } },
|
|
},
|
|
renderValue: {
|
|
control: false,
|
|
description: 'Custom render function for the selected value(s).',
|
|
table: { category: 'Content', type: { summary: '(values: string[]) => React.ReactNode' } },
|
|
},
|
|
disabled: {
|
|
control: 'boolean',
|
|
description: 'When true, disables the trigger.',
|
|
table: { category: 'State', type: { summary: 'boolean' } },
|
|
},
|
|
className: {
|
|
control: 'text',
|
|
description: 'Additional CSS classes.',
|
|
table: { category: 'Styling', type: { summary: 'string' } },
|
|
},
|
|
},
|
|
parameters: {
|
|
layout: 'fullscreen',
|
|
},
|
|
tags: ['autodocs'],
|
|
};
|
|
|
|
export default meta;
|
|
type Story = StoryObj<typeof SelectTrigger>;
|
|
|
|
const frameworks = [
|
|
{ value: 'react', label: 'React' },
|
|
{ value: 'vue', label: 'Vue' },
|
|
{ value: 'angular', label: 'Angular' },
|
|
];
|
|
|
|
export const Default: Story = {
|
|
args: {
|
|
placeholder: 'Select a framework...',
|
|
disabled: false,
|
|
},
|
|
render: (args) => {
|
|
const [value, setValue] = useState('');
|
|
|
|
return (
|
|
<div style={{ padding: 32, width: '100%', maxWidth: 384 }}>
|
|
<Select value={value} onChange={(v) => setValue(v as string)}>
|
|
<SelectTrigger {...args} />
|
|
<SelectContent>
|
|
{frameworks.map((f) => (
|
|
<SelectItem key={f.value} value={f.value}>
|
|
{f.label}
|
|
</SelectItem>
|
|
))}
|
|
</SelectContent>
|
|
</Select>
|
|
</div>
|
|
);
|
|
},
|
|
};
|
|
|
|
export const WithValue: Story = {
|
|
args: {
|
|
placeholder: 'Select a framework...',
|
|
},
|
|
render: (args) => (
|
|
<div style={{ padding: 32, width: '100%', maxWidth: 384 }}>
|
|
<Select defaultValue="react">
|
|
<SelectTrigger {...args} />
|
|
<SelectContent>
|
|
{frameworks.map((f) => (
|
|
<SelectItem key={f.value} value={f.value}>
|
|
{f.label}
|
|
</SelectItem>
|
|
))}
|
|
</SelectContent>
|
|
</Select>
|
|
</div>
|
|
),
|
|
};
|
|
|
|
export const Disabled: Story = {
|
|
args: {
|
|
placeholder: 'Select a framework...',
|
|
disabled: true,
|
|
},
|
|
render: (args) => (
|
|
<div style={{ padding: 32, width: '100%', maxWidth: 384 }}>
|
|
<Select>
|
|
<SelectTrigger {...args} />
|
|
<SelectContent>
|
|
{frameworks.map((f) => (
|
|
<SelectItem key={f.value} value={f.value}>
|
|
{f.label}
|
|
</SelectItem>
|
|
))}
|
|
</SelectContent>
|
|
</Select>
|
|
</div>
|
|
),
|
|
};
|
|
|
|
export const WithCustomRenderValue: Story = {
|
|
render: () => {
|
|
const [value, setValue] = useState('');
|
|
const selectedLabel = frameworks.find((f) => f.value === value)?.label;
|
|
|
|
return (
|
|
<div style={{ padding: 32, width: '100%', maxWidth: 384 }}>
|
|
<Select value={value} onChange={(v) => setValue(v as string)}>
|
|
<SelectTrigger
|
|
placeholder="Select a framework..."
|
|
renderValue={() =>
|
|
selectedLabel ? (
|
|
<span style={{ fontWeight: 600, color: 'var(--primary)' }}>{selectedLabel}</span>
|
|
) : null
|
|
}
|
|
/>
|
|
<SelectContent>
|
|
{frameworks.map((f) => (
|
|
<SelectItem key={f.value} value={f.value}>
|
|
{f.label}
|
|
</SelectItem>
|
|
))}
|
|
</SelectContent>
|
|
</Select>
|
|
</div>
|
|
);
|
|
},
|
|
};
|