import { Scope } from "./core/reactive.ts"; import { type State, type Derived } from "./core/handle.ts"; import { type AjaxOptions, type AjaxPromise } from "./compat.ts"; import { resource, action, type Resource, type Action } from "./resource.ts"; import { component, componentAttr, mount, unmount, type ComponentSetup } from "./component.ts"; import { type FieldRule, type FormApi, type FormOptions } from "./safe-form.ts"; import { bind, type StateBag, type BindOptions } from "./directives.ts"; export type { State, Derived, Resource, Action, ComponentSetup, FieldRule, FormApi, FormOptions, StateBag, BindOptions, AjaxOptions, AjaxPromise, }; /** "@total" → '[data-brg="total"]' / "@list li" → '[data-brg="list"] li' */ export declare function resolveSelector(selector: string): string; export declare class Bridgey { els: HTMLElement[]; /** 何で引いたか(警告メッセージに出すため)。 */ selector: string | null; /** どこから引いたか(後から足された要素を拾い直すため)。 */ roots: HTMLElement[]; constructor(input?: unknown, selector?: string | null, roots?: HTMLElement[]); get length(): number; get el(): HTMLElement | null; /** * 束縛しようとしたのに0件だった場合に警告する。 * 命令的操作(addClass 等)の0件は無害なことも多いので、そちらでは鳴らさない。 */ _requireElements(method: string): boolean; /** 各要素に effect を張り、要素の片付け単位に登録する。 */ _bind(method: string, run: (el: HTMLElement) => void): this; each(fn: (el: HTMLElement, index: number) => void): this; find(selector: string): Bridgey; closest(selector: string): Bridgey; parent(): Bridgey; children(selector?: string): Bridgey; first(): Bridgey; last(): Bridgey; is(selector: string): boolean; /** * テキスト。引数は「値 → 加工 → 形」の順に足していく。 * * .text(count) → "3" * .text(count, "件") → "3件" 後ろに付く * .text(count, "残り{}件") → "残り3件" {} の位置に入る * .text(count, n => n * 1.1) → "3.3" 加工だけ * .text(count, n => n * 1.1, "円") → "3.3円" 加工してから後ろに付ける * .text(count, n => n * 1.1, "税込{}円") → "税込3.3円" 加工してから {} に入れる * .text(total, $$.money, "円") → "23,800円" 3桁区切り * * これがあるので `() => \`${…}円\`` を書かなくて済む。 */ text(): string; text(value: unknown, format?: TextFormat, template?: string): this; html(): string; html(value: unknown): this; /** * フォーム値。jQuery と完全に同じ振る舞い(普通の文字列を返す)。 * $$("#q").val() … 文字列。=== "" も期待通り動く * $$("#q").state("") … この入力欄に双方向で繋がった state を作る * * 【設計メモ】以前は .val().state("") と書けるよう String のサブクラスを返していたが、 * `.val() === ""` が false になる罠を作るのでやめた。詰まったときに原因が分からない * 種類のバグは、書き味の良さと引き換えにしてはいけない。 */ val(): string; val(value: unknown): this; attr(name: string): string | null; attr(name: string, value: unknown): this; removeAttr(name: string): this; prop(name: string): unknown; prop(name: string, value: unknown): this; css(name: string): string; css(name: string, value: unknown): this; addClass(names: string): this; removeClass(names: string): this; /** * class の付け外し。真偽の state を渡せば追従する。 * $$("@box").toggleClass("is-open", open) ← fadeIn/slideDown を持たない理由がこれ */ toggleClass(names: string, force?: unknown): this; hasClass(name: string): boolean; /** * 排他的な状態を data-mode 属性に出す。CSS 側は [data-mode="…"] で受ける。 * $$("@form").mode(() => sending() ? "sending" : error() ? "error" : "ready"); * →