Agent Skills by ALSEL
OpenAIソフトウェア開発⭐ リポ 4品質スコア 71/100

vue

Vue 3用のjson-renderレンダラーです。JSONスペックからVue UIを構築する際、@json-render/vueを使用する場合、Vueコンポーネントレジストリを定義する場合、またはAIが生成したスペックをVueでレンダリングする際に使用できます。

description の原文を見る

Vue 3 renderer for json-render. Use when building Vue UIs from JSON specs, working with @json-render/vue, defining Vue component registries, or rendering AI-generated specs in Vue.

SKILL.md 本文

@json-render/vue

JSONスペックをデータバインディング、可視性、アクションを備えたVueコンポーネントツリーに変換するVue 3レンダラーです。

インストール

npm install @json-render/vue @json-render/core zod

ピア依存: vue ^3.5.0zod ^4.0.0

クイックスタート

カタログの作成

import { defineCatalog } from "@json-render/core";
import { schema } from "@json-render/vue/schema";
import { z } from "zod";

export const catalog = defineCatalog(schema, {
  components: {
    Card: {
      props: z.object({ title: z.string(), description: z.string().nullable() }),
      description: "A card container",
    },
    Button: {
      props: z.object({ label: z.string(), action: z.string() }),
      description: "A clickable button",
    },
  },
  actions: {},
});

h() レンダー関数でレジストリを定義

import { h } from "vue";
import { defineRegistry } from "@json-render/vue";
import { catalog } from "./catalog";

export const { registry } = defineRegistry(catalog, {
  components: {
    Card: ({ props, children }) =>
      h("div", { class: "card" }, [
        h("h3", null, props.title),
        props.description ? h("p", null, props.description) : null,
        children,
      ]),
    Button: ({ props, emit }) =>
      h("button", { onClick: () => emit("press") }, props.label),
  },
});

スペックをレンダリング

<script setup lang="ts">
import { StateProvider, ActionProvider, Renderer } from "@json-render/vue";
import { registry } from "./registry";

const spec = { root: "card-1", elements: { /* ... */ } };
</script>

<template>
  <StateProvider :initial-state="{ form: { name: '' } }">
    <ActionProvider :handlers="{ submit: handleSubmit }">
      <Renderer :spec="spec" :registry="registry" />
    </ActionProvider>
  </StateProvider>
</template>

プロバイダー

プロバイダー用途
StateProviderコンポーネント間でステート(JSON PointerパスのステートモデルをStateStoreに格納したもの)を共有します。制御モード用に initialState または store を受け入れます。
ActionProviderイベントシステムを介してディスパッチされたアクションを処理します
VisibilityProviderステートに基づく条件付きレンダリングを有効にします
ValidationProviderフォームフィールドのバリデーション

コンポーザブル

コンポーザブル用途
useStateStore()ステートコンテキストにアクセス(stateShallowRefgetsetupdate
useStateValue(path)ステートから単一の値を取得
useIsVisible(condition)可視性条件が満たされているかを確認
useActions()アクションコンテキストにアクセス
useAction(binding)単一のアクションディスパッチ関数を取得
useFieldValidation(path, config)フィールドバリデーションの状態
useBoundProp(propValue, bindingPath)$bindState/$bindItem の双方向バインディング

注: useStateStore().stateShallowRef<StateModel> を返します。アクセスするには state.value を使用してください。

外部ストア(StateStore)

StateProviderStateStore を渡して、json-renderをPinia、VueUse、またはその他の状態管理に接続します:

import { createStateStore, type StateStore } from "@json-render/vue";

const store = createStateStore({ count: 0 });
<StateProvider :store="store">
  <Renderer :spec="spec" :registry="registry" />
</StateProvider>

動的プロップ式

プロップは $state$bindState$cond$template$computed をサポートしています。双方向バインディング用には、自然な値プロップに { "$bindState": "/path" } を使用します。

可視性条件

{ "$state": "/user/isAdmin" }
{ "$state": "/status", "eq": "active" }
{ "$state": "/maintenance", "not": true }
[ cond1, cond2 ]  // 暗黙的 AND

ビルトインアクション

setStatepushStateremoveStatevalidateForm はVueスキーマに組み込まれており、ActionProvider で処理されます:

{
  "action": "setState",
  "params": { "statePath": "/activeTab", "value": "settings" }
}

イベントシステム

コンポーネントは emit(event) でイベントを発火するか、メタデータ(shouldPreventDefaultbound)用に on(event) を使用します。

ストリーミング

useUIStreamuseChatUI はAPIからのストリーミングスペック用のVue Refを返します。

BaseComponentProps

カタログ非依存の再利用可能なコンポーネント用:

import type { BaseComponentProps } from "@json-render/vue";

const Card = ({ props, children }: BaseComponentProps<{ title?: string }>) =>
  h("div", null, [props.title, children]);

主要なエクスポート

エクスポート用途
defineRegistryカタログからタイプセーフなコンポーネントレジストリを作成
Rendererレジストリを使用してスペックをレンダリング
schemaエレメントツリースキーマ(@json-render/vue/schema から)
StateProviderActionProviderVisibilityProviderValidationProviderコンテキストプロバイダー
useStateStoreuseStateValueuseBoundPropステートコンポーザブル
useActionsuseActionアクションコンポーザブル
useFieldValidationuseIsVisibleバリデーションと可視性
useUIStreamuseChatUIストリーミングコンポーザブル
createStateStoreメモリ内 StateStore を作成
BaseComponentPropsカタログ非依存のコンポーネントプロップ型

ライセンス: MIT(寛容ライセンスのため全文を引用しています) · 原本リポジトリ

詳細情報

作者
brainchimps
リポジトリ
brainchimps/json-render-nuxt-ui
ライセンス
MIT
最終更新
2026/4/14

Source: https://github.com/brainchimps/json-render-nuxt-ui / ライセンス: MIT

本サイトは GitHub 上で公開されているオープンソースの SKILL.md ファイルをクロール・インデックス化したものです。 各スキルの著作権は原作者に帰属します。掲載に問題がある場合は info@alsel.co.jp または /takedown フォームよりご連絡ください。
原作者: brainchimps · brainchimps/json-render-nuxt-ui · ライセンス: MIT