import { FuncCallback } from "./funcBase.js"; import { Func } from "./func.js"; import { Member } from "./member.js"; import { ClientData } from "./clientData.js"; import { EventTarget } from "./event.js"; import { Field } from "./field.js"; import { FieldBase } from "./fieldBase.js"; import { Text, InputRef } from "./text.js"; import * as Message from "./message.js"; export declare const viewComponentTypes: { readonly text: 0; readonly newLine: 1; readonly button: 2; readonly textInput: 3; readonly decimalInput: 4; readonly numberInput: 5; readonly toggleInput: 6; readonly selectInput: 7; readonly sliderInput: 8; readonly checkInput: 9; }; export declare const viewColor: { readonly inherit: 0; readonly black: 1; readonly white: 2; readonly gray: 4; readonly red: 8; readonly orange: 9; readonly yellow: 11; readonly green: 13; readonly teal: 15; readonly cyan: 16; readonly blue: 18; readonly indigo: 19; readonly purple: 21; readonly pink: 23; }; export declare function getDiff(current: T[], prev: T[]): { [x: string]: T; }; export declare function mergeDiff(diff: { [key in string]: T; }, size: number, prev: T[]): void; export declare const viewComponents: { /** * newLineコンポーネント */ readonly newLine: (options?: ViewComponentOption) => ViewComponent; /** * textコンポーネント */ readonly text: (t: string, options?: ViewComponentOption) => ViewComponent; /** * buttonコンポーネント */ readonly button: (t: string, f: Func | FuncCallback, options?: ViewComponentOption) => ViewComponent; readonly textInput: (options?: ViewComponentOption) => ViewComponent; readonly decimalInput: (options?: ViewComponentOption) => ViewComponent; readonly numberInput: (options?: ViewComponentOption) => ViewComponent; readonly selectInput: (options?: ViewComponentOption) => ViewComponent; readonly toggleInput: (options?: ViewComponentOption) => ViewComponent; readonly sliderInput: (options?: ViewComponentOption) => ViewComponent; readonly checkInput: (options?: ViewComponentOption) => ViewComponent; }; interface ViewComponentOption { text?: string; onClick?: Func | FuncCallback; onChange?: FuncCallback; bind?: InputRef; textColor?: number; bgColor?: number; init?: string | number | boolean; min?: number; max?: number; step?: number; option?: string[] | number[]; width?: number; height?: number; } /** * ViewComponent, Canvas2DComponentのid管理 */ export declare class IdBase { private idxForType; initIdx(idxNext: Map, type: number): void; get type(): number; get id(): string; } /** * Viewのコンポーネントを表すクラス */ export declare class ViewComponent extends IdBase { type_: number; text_: string; on_click_: FieldBase | null; on_click_tmp_: FuncCallback | null; on_change_tmp_: FuncCallback | null; text_ref_: FieldBase | null; text_ref_tmp_: InputRef | null; text_color_: number; bg_color_: number; init_: string | number | boolean | null; min_: number | null; max_: number | null; step_: number | null; option_: string[] | number[]; width_: number; height_: number; data: ClientData | null; /** * 引数に文字列を入れるとtextコンポーネントを作成できる * * それ以外の場合、viewComponents にある各コンポーネントの生成関数を使用してください * * @param arg numberのときtype, stringのときtextになる Message.ViewComponentの場合展開 * @param data ClientDataが参照できる場合は指定 * @param options その他のプロパティ */ constructor(arg: number | string | Message.ViewComponent, data?: ClientData | null, options?: ViewComponentOption, idxNext?: Map); /** * AnonymousFuncをFuncオブジェクトにロックする * * funcIdIncは呼ぶたびに1増加 */ lockTmp(data: ClientData, viewName: string, idxNext: Map): this; /** * Messageに変換 */ toMessage(): Message.ViewComponent; /** * コンポーネントの種類 * * viewComponentTypesに定義されている定数を使う */ get type(): number; /** * 表示する文字列 */ get text(): string; /** * クリック時に実行する関数 */ get onClick(): Func | null; /** * 文字の色 * * viewColorに定義されている定数を使う */ get textColor(): number; /** * 背景の色 * * viewColorに定義されている定数を使う */ get bgColor(): number; /** * バインドされたinputの値 * * bind.getAny() で値を取得したり、 * bind.on(...) で値が変化したときのコールバックを設定して使う。 */ get bind(): Text | null; /** * 値の変化時に実行する関数を取得 * * 取得してそれを呼び出すには onChange?.runAsync(値) のようにする * * 内部データとしてはonClickと共通 */ get onChange(): Func | null; /** * inputの最小値 or 最小文字数 */ get min(): number | null; /** * inputの最大値 or 最大文字数 */ get max(): number | null; /** * inputの刻み幅 */ get step(): number | null; /** * inputの選択肢 */ get option(): string[] | number[]; /** * 要素の幅 * @since ver1.10 */ get width(): number; /** * 要素の高さ * @since ver1.10 */ get height(): number; } /** * Viewを指すクラス * * 詳細は {@link https://na-trium-144.github.io/webcface/md_13__view.html Viewのドキュメント} * を参照 */ export declare class View extends EventTarget { base_: Field; /** * このコンストラクタは直接使わず、 * Member.view(), Member.views(), Member.onViewEntry などを使うこと */ constructor(base: Field, field?: string); /** * Memberを返す */ get member(): Member; /** * field名を返す */ get name(): string; /** * 「(thisのフィールド名).(追加の名前)」をフィールド名とするView */ child(field: string): View; /** * 値をリクエストする。 */ request(): void; /** * Viewを返す */ tryGet(): ViewComponent[] | null; /** * Viewを返す */ get(): ViewComponent[]; /** * このフィールドにデータが存在すればtrueを返す * @since ver1.8 * * tryGet() とは違って、実際のデータを受信しない。 * (リクエストも送信しない) */ exists(): boolean; /** * Memberのsyncの時刻を返す * * @deprecated ver1.6〜 Member.syncTime() に移行 */ time(): Date; /** * ViewComponentのリストをセットする */ set(data: (ViewComponent | string | number | boolean)[]): void; } export {};