Skip to the content

Bushu部首

Choose the parts you can see in a kanji, intersect their matches, and add a radical picker to your page.

Bushu is the Japanese word 部首 for a kanji radical. About the name

Contents

Reference · Native radical picker

BushuMounttype

What mountBushu gives back: methods for everything a button does, and destroy.

Import it

import type { BushuMount } from "@johnmorrisdotca/bushu/picker";

Definition

type BushuMount = {
    toggle(radical: string): void;
    remove(radical: string): void;
    clear(): void;
    select(kanji: string | null): void;
    chosen(): string[];
    matches(): string[];
    set(options: Partial<Pick<BushuMountOptions, "language" | "limit" | "names" | "strokes">>): void;
    destroy(): void;
};

Members

NameTypeDescription
toggle(radical: string): void

Choose a part, by its RADKFILE key or by its shape (氵 for 汁), or take it away if it is chosen. A part that cannot narrow anything, or is not in the index, is left alone.

remove(radical: string): void

Take a part away, by its key or its shape.

clear(): void

Take every part away.

select(kanji: string | null): void

Open the card of a kanji, with its parts; null closes it.

chosen(): string[]

The parts chosen now, in the grid's order.

matches(): string[]

The kanji that match, all of them, in the order drawn.

set(options: Partial<Pick<BushuMountOptions, "language" | "limit" | "names" | "strokes">>): void

Change a setting later: the words, the limit, the names or the strokes.

destroy(): void

Examples

import { RADKFILE } from "@johnmorrisdotca/bushu/radkfile";
import type { BushuMount } from "@johnmorrisdotca/bushu/picker";
import { mountBushu } from "@johnmorrisdotca/bushu/picker";

const radicals = RADKFILE.radicals;
const host=document.createElement("div");
document.body.append(host);
const picker: BushuMount=mountBushu(host,{radicals,language:"ja"});
picker.toggle("汁");
console.log(picker.chosen(),picker.matches().length);
picker.destroy();

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/bushu 1.1.0.