Documentation navigation

Published API · 0.1.0-rc.1

themes · components/radio-group

Published themes API declarations for components/radio-group.

./components/radio-group

@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/radio-group'

Exported declarations

Bundle

export type Bundle<Value extends string> = Readonly<{
    Model: typeof RadioGroupUi.Model;
    Message: typeof RadioGroupUi.Message;
    OutMessage: typeof RadioGroupUi.OutMessage;
    init: typeof RadioGroupUi.init;
    update: (model: Model, message: Message) => Update.ReturnWithOutMessage<Model, Message, OutMessage<Value>>;
    view(model: Model, inputs: ViewInputs<Value>, h: HtmlBuilder<Message>): Html;
    fold<ParentModel, ParentMessage, ParentOutMessage>(config: Omit<Update.ChildFoldWithDerivedParentOutMessage<ParentModel, ParentMessage, Model, Message, Message, OutMessage<Value>, ParentOutMessage>, 'update'>): Update.FoldWithOutMessage<ParentModel, ParentMessage, Message, ParentOutMessage>;
    embed<ParentMessage>(h: HtmlBuilder<ParentMessage>, config: EmbedConfig<Value, ParentMessage>): Html;
}>;

create

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

EmbedConfig

export type EmbedConfig<Value extends string, ParentMessage> = Readonly<{
    slotId: string;
    model: Model;
    toParentMessage(message: Message): ParentMessage;
    viewInputs: ViewInputs<Value>;
}>;

Message

export type Message = RadioGroupUi.Message;

Model

export type Model = RadioGroupUi.Model;

Option

export type Option<Value extends string> = Readonly<{
    value: Value;
    label?: Html;
    isDisabled?: boolean;
}>;

OutMessage

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

Props

export type Props = typeof Props.Type;

Props

Props: Schema.Struct<{
    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", "soft"]>>;
    readonly color: Schema.optional<Schema.Literals<readonly ["gray", "gold", "bronze", "brown", "yellow", "amber", "orange", "tomato", "red", "ruby", "crimson", "pink", "plum", "purple", "violet", "iris", "indigo", "blue", "cyan", "teal", "jade", "green", "grass", "lime", "mint", "sky", "custom"]>>;
    readonly highContrast: Schema.optional<Schema.Boolean>;
}>

ViewInputs

export type ViewInputs<Value extends string> = Omit<UiInputs<Value>, 'toView' | 'options' | 'isOptionDisabled'> & Readonly<{
    options: ReadonlyArray<Option<Value>>;
    optionToLabel?: (value: Value) => Html;
    props?: Props & {
        rootClass?: string;
        rootStyle?: Readonly<Record<string, string>>;
        rootRadius?: string;
        rootAccentColor?: string;
        segmented?: boolean;
        cards?: boolean;
        itemClass?: string;
        itemInnerClass?: string;
    };
}>;

Props

Props exported by @wsagency/wseffect-themes/components/radio-group · Props · source
NameTypeRequiredChoicesDescription
size"1" | "2" | "3" | Responsive<"1" | "2" | "3">No——
variant"classic" | "surface" | "soft"No"classic", "surface", "soft"—
color"gray" | "gold" | "bronze" | "brown" | "yellow" | "amber" | "orange" | "tomato" | "red" | "ruby" | "crimson" | "pink" | "plum" | "purple" | "violet" | "iris" | "indigo" | "blue" | "cyan" | "teal" | "jade" | "green" | "grass" | "lime" | "mint" | "sky" | "custom"No"gray", "gold", "bronze", "brown", "yellow", "amber", "orange", "tomato", "red", "ruby", "crimson", "pink", "plum", "purple", "violet", "iris", "indigo", "blue", "cyan", "teal", "jade", "green", "grass", "lime", "mint", "sky", "custom"—
highContrastbooleanNo——

Rendered component example

RadioGroup
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 group = Themes.RadioGroup.create<'monthly' | 'annual'>(); const model = group.init({ id: 'billing-cycle-example' }); return group.embed(h, { slotId: 'billing-cycle-example', model, toParentMessage: (message) => message, viewInputs: { options: [{ value: 'monthly', label: h.span([], ['Monthly']) }, { value: 'annual', label: h.span([], ['Annual']) }], selectedValue: Option.some('annual'), ariaLabel: 'Billing cycle' } }) })()