Documentation navigation

Published API · 0.1.0-rc.1

themes · components/segmented-control

Published themes API declarations for components/segmented-control.

./components/segmented-control

@wsagency/wseffect-themes · MIT · source · MIT license · WS-AGENCY-NOTICE

This entry point is published in @wsagency/wseffect-themes@0.1.0-rc.1. Import it from the package subpath shown below; the signatures and documentation are read from the installed package declarations.

import * as Wseffect from '@wsagency/wseffect-themes/components/segmented-control'

Exported declarations

Bundle

export type Bundle<Value extends string> = Omit<RadioGroup.Bundle<Value>, 'view'> & Readonly<{
    view(model: Model, inputs: ViewInputs<Value>, h: HtmlBuilder<Message>): Html;
}>;

create

create: <Value extends string>() => Bundle<Value>

FocusOption

FocusOption: import("@wsagency/wseffect-foldkit/command").CommandDefinitionWithArgs<"FocusOption", {
    id: Schema.String;
    index: Schema.Number;
}, import("effect/Effect").Effect<{
    readonly _tag: "CompletedFocusOption";
}, never, never>>

Message

export type Message = typeof Message.Type;

Message

Message: import("@wsagency/wseffect-foldkit/message").MessageUnion<{
    readonly SelectedOption: {
        index: Schema.Number;
        value: Schema.String;
    };
    readonly FocusedOption: {
        index: Schema.Number;
    };
    readonly CompletedFocusOption: {};
}>

Model

export type Model = RadioGroup.Model;

OutMessage

export type OutMessage<Value extends string> = RadioGroup.OutMessage<Value>;

Props

export type Props = typeof Props.Type;

Props

Props: Schema.Struct<{
    readonly m: Schema.optional<Schema.Union<readonly [Schema.Literals<readonly string[]> | Schema.String, Schema.Struct<{
        [k: string]: Schema.optional<Schema.Literals<readonly string[]> | Schema.String>;
    }>]>>;
    readonly mx: Schema.optional<Schema.Union<readonly [Schema.Literals<readonly string[]> | Schema.String, Schema.Struct<{
        [k: string]: Schema.optional<Schema.Literals<readonly string[]> | Schema.String>;
    }>]>>;
    readonly my: Schema.optional<Schema.Union<readonly [Schema.Literals<readonly string[]> | Schema.String, Schema.Struct<{
        [k: string]: Schema.optional<Schema.Literals<readonly string[]> | Schema.String>;
    }>]>>;
    readonly mt: Schema.optional<Schema.Union<readonly [Schema.Literals<readonly string[]> | Schema.String, Schema.Struct<{
        [k: string]: Schema.optional<Schema.Literals<readonly string[]> | Schema.String>;
    }>]>>;
    readonly mr: Schema.optional<Schema.Union<readonly [Schema.Literals<readonly string[]> | Schema.String, Schema.Struct<{
        [k: string]: Schema.optional<Schema.Literals<readonly string[]> | Schema.String>;
    }>]>>;
    readonly mb: Schema.optional<Schema.Union<readonly [Schema.Literals<readonly string[]> | Schema.String, Schema.Struct<{
        [k: string]: Schema.optional<Schema.Literals<readonly string[]> | Schema.String>;
    }>]>>;
    readonly ml: Schema.optional<Schema.Union<readonly [Schema.Literals<readonly string[]> | Schema.String, Schema.Struct<{
        [k: string]: Schema.optional<Schema.Literals<readonly string[]> | Schema.String>;
    }>]>>;
    readonly size: Schema.optional<Schema.Union<readonly [Schema.Literals<readonly string[]> | Schema.String, Schema.Struct<{
        [k: string]: Schema.optional<Schema.Literals<readonly string[]> | Schema.String>;
    }>]>>;
    readonly variant: Schema.optional<Schema.Literals<readonly ["classic", "surface"]>>;
    readonly disabled: Schema.optional<Schema.Boolean>;
    readonly radius: Schema.optional<Schema.Literals<readonly ["none", "small", "medium", "large", "full"]>>;
}>

ViewInputs

export type ViewInputs<Value extends string> = Omit<RadioGroup.ViewInputs<Value>, 'props'> & Readonly<{
    props?: Props;
}>;

Props

Props exported by @wsagency/wseffect-themes/components/segmented-control · Props · source
NameTypeRequiredChoicesDescription
size"1" | "2" | "3" | Responsive<"1" | "2" | "3">No——
variant"classic" | "surface"No"classic", "surface"—
disabledbooleanNo——
radius"none" | "small" | "medium" | "large" | "full"No"none", "small", "medium", "large", "full"—
mstring | Responsive<string>No——
mxstring | Responsive<string>No——
mystring | Responsive<string>No——
mtstring | Responsive<string>No——
mrstring | Responsive<string>No——
mbstring | Responsive<string>No——
mlstring | Responsive<string>No——

Rendered component example

SegmentedControl
Example usage
import * as Themes from '@wsagency/wseffect-themes'
import * as SliderRange from '@wsagency/wseffect-themes/components/slider/range'
import * as Option from 'effect/Option'
import { defineView } from '@wsagency/wseffect-foldkit/submodel'
import { inertHtml, type HtmlBuilder } from '@wsagency/wseffect-foldkit/html'

const example = (h: HtmlBuilder<unknown>) => (() => { const control = Themes.SegmentedControl.create<'day' | 'week'>(); const model = control.init({ id: 'range-example' }); return control.embed(h, { slotId: 'range-example', model, toParentMessage: (message) => message, viewInputs: { options: [{ value: 'day', label: h.span([], ['Day']) }, { value: 'week', label: h.span([], ['Week']) }], selectedValue: Option.some('week'), ariaLabel: 'Date range' } }) })()