embed
embed: <ParentMessage>(h: HtmlBuilder<ParentMessage>, config: EmbedConfig<ParentMessage>) => HtmlEffect-native UI toolkit
Interactive demosPublished API · 0.1.0-rc.1
Published themes API declarations for components/tooltip.
@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/tooltip'embedembed: <ParentMessage>(h: HtmlBuilder<ParentMessage>, config: EmbedConfig<ParentMessage>) => HtmlEmbedConfigexport type EmbedConfig<Message> = Readonly<{
slotId: string;
model: UiTooltip.Model;
toParentMessage: (message: UiTooltip.Message) => Message;
viewInputs: ViewInputs<Message>;
}>;foldfold: <ParentModel, ParentMessage, ParentOutMessage>(config: Omit<Update.ChildFoldWithDerivedParentOutMessage<ParentModel, ParentMessage, UiTooltip.Model, UiTooltip.Message, UiTooltip.Message, UiTooltip.OutMessage, ParentOutMessage>, 'update'> & Readonly<{
readGroup?: (parentModel: ParentModel) => TooltipGroup.Model;
}>) => Update.FoldWithOutMessage<ParentModel, ParentMessage, UiTooltip.Message, ParentOutMessage>initinit: (config: UiTooltip.InitConfig) => UiTooltip.ModelMessageexport type Message = typeof Message.Type;MessageUnion of all messages the tooltip component can produce.
Message: import("@wsagency/wseffect-foldkit/message").MessageUnion<{
readonly EnteredTrigger: {};
readonly LeftTrigger: {};
readonly FocusedTrigger: {};
readonly BlurredTrigger: {};
readonly PressedEscape: {};
readonly PressedPointerOnTrigger: {
pointerType: Schema.String;
};
readonly CompletedWaitBeforeShowing: {
version: Schema.Number;
};
readonly CompletedAnchorTooltip: {};
}>Modelexport type Model = typeof Model.Type;ModelSchema for the tooltip component's state. `isOpen` is visibility; `isHovered` tracks pointer on trigger; `isFocused` tracks tooltip-affirming focus on the trigger (focus arriving without a preceding mouse press, like keyboard, touch, or pen; mouse-click-induced focus is excluded since it doesn't affirm the user wants the tooltip visible); `isDismissed` suppresses re-opening after the user dismissed the tooltip (via Escape) until they disengage (leave or blur). `showDelay` is the hover-to-show duration. `maybeLastPointerType` records the most recent pointer type that pressed the trigger, so a mouse-click-induced focus can be distinguished from other focus.
Model: Schema.Struct<{
readonly id: Schema.String;
readonly isOpen: Schema.Boolean;
readonly isHovered: Schema.Boolean;
readonly isFocused: Schema.Boolean;
readonly isDismissed: Schema.Boolean;
readonly showDelay: Schema.DurationFromMillis;
readonly pendingShowVersion: Schema.Number;
readonly maybeLastPointerType: Schema.Option<Schema.String>;
}>OutMessageexport type OutMessage = typeof OutMessage.Type;OutMessageUnion of out-messages the tooltip component can produce.
OutMessage: import("@wsagency/wseffect-foldkit/message").MessageUnion<{
readonly Shown: {};
readonly Hidden: {};
}>reflectShowDelayreflectShowDelay: (model: UiTooltip.Model, group: TooltipGroup.Model) => UiTooltip.ModeltriggerIdReturns the bare DOM id of the tooltip trigger button, derived from the tooltip's base id. Use this to associate an external label with the trigger via a native `<label for={Tooltip.triggerId(id)}>` or an `aria-labelledby` reference.
triggerId: (id: string) => stringupdateProcesses a Tooltip Message and returns the next Model, optional Commands, and an optional OutMessage. `Shown`/`Hidden` fire only on `isOpen` transitions, so consumers don't get spurious events for messages that only update hover/focus/delay state without changing visibility.
update: (model: Model, message: Message) => Update.ReturnWithOutMessage<Model, Message, OutMessage>ViewInputsexport type ViewInputs<Message> = Readonly<{
trigger: ReadonlyArray<Html | string>;
content: ReadonlyArray<Html | string>;
anchor?: AnchorConfig;
isDisabled?: boolean;
ariaLabel?: string;
ariaLabelledBy?: string;
}>;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>) => Themes.Tooltip.embed(h, { slotId: 'save-tooltip-example', model: Themes.Tooltip.init({ id: 'save-tooltip-example' }), toParentMessage: (message) => message, viewInputs: { trigger: [h.span([], ['Save'])], content: ['Save your changes'] } })