Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

2.4 KB
Raw Blame
import type { Meta, StoryObj } from '@storybook/react'
import { useState } from 'react'

import { mswDecorator } from '~/mocks/browser'

import { TaxonomicFilterGroupType } from '../TaxonomicFilter/types'
import { PropertySelect, PropertySelectProps } from './PropertySelect'

type Story = StoryObj<PropertySelectProps>
const meta: Meta<PropertySelectProps> = {
    title: 'Filters/Property Select',
    component: PropertySelect,
    decorators: [
        mswDecorator({
            get: {
                '/api/environments/:team_id/persons/properties': [
                    { name: 'Property A', count: 10 },
                    { name: 'Property B', count: 20 },
                    { name: 'Property C', count: 30 },

                    { name: 'Property D', count: 40 },
                    { name: 'Property E', count: 50 },
                    { name: 'Property F', count: 60 },

                    { name: 'Property G', count: 70 },
                    { name: 'Property H', count: 80 },
                    { name: 'Property I', count: 90 },
                ],
            },
        }),
    ],
    render: (props) => {
        const [selectedProperties, setSelectProperties] = useState<string[]>([
            '$initial_geoip_postal_code',
            '$initial_geoip_latitude',
            '$initial_geoip_longitude',
            '$geoip_latitude',
            '$geoip_longitude',
            '$geoip_postal_code',
            '$geoip_continent_code',
            '$geoip_continent_name',
            '$initial_geoip_continent_code',
            '$initial_geoip_continent_name',
            '$geoip_time_zone',
            '$geoip_country_code',
            '$geoip_subdivision_1_code',
            '$initial_geoip_subdivision_1_code',
            '$geoip_subdivision_2_code',
            '$initial_geoip_subdivision_2_code',
            '$geoip_subdivision_name',
            '$initial_geoip_subdivision_name',
        ])

        return (
            <PropertySelect
                {...props}
                selectedProperties={selectedProperties}
                onChange={setSelectProperties}
                taxonomicFilterGroup={TaxonomicFilterGroupType.PersonProperties}
                addText="Add"
            />
        )
    },
}
export default meta

export const Default: Story = {
    args: {},
}

export const Sortable: Story = {
    args: {
        sortable: true,
    },
}