本文へ移動

Kuni国

国、コード、名前、行政区画を調べ、必要なときに国のデータを読み込み、標準の国のカードを表示できます。

「国(くに)」は、国を表す日本語です。 名前について(英語)

目次

リファレンス · 国のカードの要素

KuniCardOptions型

リファレンスの説明と例は英語です。見出しと目次は日本語です。

Host SVG loaders and native map appearance; attributes override drawing defaults.

インポート

import type { KuniCardOptions } from "@johnmorrisdotca/kuni/element";

ほかのエクスポート元: @johnmorrisdotca/kuni/element/define

定義

interface KuniCardOptions {
    flag?: (code: string) => Promise<string | null>;
    map?: (code: string, language: "en" | "ja", drawing?: Pick<KuniCardOptions, "colors" | "capital">) => Promise<string | null>;
    colors?: Readonly<Record<string, string>>;
    capital?: boolean;
}

メンバー

名前型説明
flag (省略可)((code: string) => Promise<string | null>) | undefined

Load a Hata flag or an equivalent SVG for the ISO code; null means unavailable.

map (省略可)((code: string, language: "en" | "ja", drawing?: Pick<KuniCardOptions, "colors" | "capital">) => Promise<string | null>) | undefined

Load trusted SVG for the ISO code/language, honouring optional drawing settings; null means unavailable.

colors (省略可)Readonly<Record<string, string>> | undefined

Per-region CSS colours for the native drawing; code:hex-colour attribute pairs override this map.

capital (省略可)boolean | undefined

Show the capital markers on the map, true by default. This does not remove the capital text field.

例

import { type KuniCardOptions, KUNI_CARD_OPTION_KEYS } from "@johnmorrisdotca/kuni/element";
const options: KuniCardOptions = {};
console.log(Object.keys(options).length); // 0
console.log(KUNI_CARD_OPTION_KEYS.length); // 4
0
4

出力(このページを作ったときに実行した結果)

ソースを見るGitHub で編集@johnmorrisdotca/kuni 1.4.0 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。