Documentation navigation

Published API · 0.1.0-rc.1

themes · components/context-menu

Published themes API declarations for components/context-menu.

./components/context-menu

@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/context-menu'

Exported declarations

Bundle

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

Config

export type Config<Value extends string> = Omit<ContextMenuConfig<Value>, 'classes' | 'color'> & Props;

create

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

EmbedConfig

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

Group

export type Group<Value extends string> = ContextMenuGroup<Value>;

Item

export type Item<Value extends string> = ContextMenuItem<Value>;

Message

export type Message = UiMenu.Message;

Message

Message: import("@wsagency/wseffect-foldkit/message").MessageUnion<{
    readonly Opened: {
        maybeActiveItemIndex: Schema.Option<Schema.Number>;
    };
    readonly OpenedAt: {
        invocation: Schema.Struct<{
            readonly invocation: Schema.Literals<readonly ["pointer", "keyboard", "touch"]>;
            readonly sourceId: Schema.String;
            readonly sourceToken: Schema.String;
            readonly point: Schema.optional<Schema.Struct<{
                readonly x: Schema.Number;
                readonly y: Schema.Number;
            }>>;
        }>;
    };
    readonly LongPressExpired: {
        version: Schema.Number;
    };
    readonly SourceUnmounted: {
        token: Schema.String;
    };
    readonly Closed: {};
    readonly BlurredItems: {};
    readonly ActivatedItem: {
        index: Schema.Number;
        activationTrigger: Schema.Literals<readonly ["Pointer", "Keyboard"]>;
    };
    readonly DeactivatedItem: {};
    readonly SelectedItem: {
        index: Schema.Number;
        item: Schema.String;
    };
    readonly RequestedItemClick: {
        index: Schema.Number;
    };
    readonly Searched: {
        key: Schema.String;
        maybeTargetIndex: Schema.Option<Schema.Number>;
    };
    readonly CompletedDelayClearSearch: {
        version: Schema.Number;
    };
    readonly MovedPointerOverItem: {
        index: Schema.Number;
        screenX: Schema.Number;
        screenY: Schema.Number;
    };
    readonly CompletedFocusItems: {};
    readonly CompletedFocusButton: {};
    readonly CompletedLockScroll: {};
    readonly CompletedUnlockScroll: {};
    readonly CompletedInertOthers: {};
    readonly CompletedRestoreInert: {};
    readonly CompletedScrollIntoView: {};
    readonly CompletedClickItem: {};
    readonly IgnoredMouseClick: {};
    readonly SuppressedSpaceScroll: {};
    readonly CompletedAnchorMenu: {};
    readonly CompletedPortalMenuBackdrop: {};
    readonly GotAnimationMessage: {
        message: import("@wsagency/wseffect-foldkit/message").MessageUnion<{
            readonly Showed: {};
            readonly Hid: {};
            readonly CompletedWaitForPaint: {
                generation: Schema.Number;
            };
            readonly EndedAnimation: {
                generation: Schema.Number;
            };
        }>;
    };
    readonly PressedPointerOnButton: {
        pointerType: Schema.String;
        button: Schema.Number;
        screenX: Schema.Number;
        screenY: Schema.Number;
        timeStamp: Schema.Number;
    };
    readonly ReleasedPointerOnItems: {
        screenX: Schema.Number;
        screenY: Schema.Number;
        timeStamp: Schema.Number;
    };
}>

Model

export type Model = UiMenu.Model;

Model

Model: Schema.Struct<{
    readonly id: Schema.String;
    readonly isOpen: Schema.Boolean;
    readonly isAnimated: Schema.Boolean;
    readonly isModal: Schema.Boolean;
    readonly animation: Schema.Struct<{
        readonly id: Schema.String;
        readonly isShowing: Schema.Boolean;
        readonly transitionState: Schema.Literals<readonly ["Idle", "EnterStart", "EnterAnimating", "LeaveStart", "LeaveAnimating"]>;
        readonly transitionGeneration: Schema.Number;
    }>;
    readonly maybeActiveItemIndex: Schema.Option<Schema.Number>;
    readonly activationTrigger: Schema.Literals<readonly ["Pointer", "Keyboard"]>;
    readonly searchQuery: Schema.String;
    readonly searchVersion: Schema.Number;
    readonly maybeLastPointerPosition: Schema.Option<Schema.Struct<{
        readonly screenX: Schema.Number;
        readonly screenY: Schema.Number;
    }>>;
    readonly maybeLastButtonPointerType: Schema.Option<Schema.String>;
    readonly maybePointerOrigin: Schema.Option<Schema.Struct<{
        readonly screenX: Schema.Number;
        readonly screenY: Schema.Number;
        readonly timeStamp: Schema.Number;
    }>>;
    readonly maybeContextInvocation: Schema.withDecodingDefaultTypeKey<Schema.Option<Schema.Struct<{
        readonly invocation: Schema.Literals<readonly ["pointer", "keyboard", "touch"]>;
        readonly sourceId: Schema.String;
        readonly sourceToken: Schema.String;
        readonly point: Schema.optional<Schema.Struct<{
            readonly x: Schema.Number;
            readonly y: Schema.Number;
        }>>;
    }>>, never>;
    readonly longPressVersion: Schema.withDecodingDefaultTypeKey<Schema.Number, never>;
}>

OutMessage

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

OutMessage

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

Props

export type Props = typeof Props.Type;

Props

Props: Schema.Struct<{
    readonly variant: Schema.optional<Schema.Literals<readonly ["solid", "soft"]>>;
    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 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>;
}>

Separator

export type Separator = ContextMenuSeparator;

Props

Props exported by @wsagency/wseffect-themes/components/context-menu · Props · source
NameTypeRequiredChoicesDescription
variant"solid" | "soft"No"solid", "soft"—
size"1" | "2" | Responsive<"1" | "2">No——
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

ContextMenu
project-menu-example
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 menu = Themes.ContextMenu.create<'copy'>(); const config: Themes.ContextMenu.Config<'copy'> = { id: 'project-menu-example', sourceId: 'project-row', sourceToken: 'project-row-token', items: [{ value: 'copy', textValue: 'Copy link', isDisabled: false, content: h.span([], ['Copy link']) }] }; return menu.embed(h, { slotId: config.id, model: menu.init(config), config, toParentMessage: (message) => message }) })()