{
  "format": "flow-studio-project-export/v1",
  "metadata": {
    "title": "页面与交互组件",
    "description": "通用页面区域、集合、导航、弹层与反馈的可点击示例"
  },
  "manifest": {
    "format": "flow-studio-project/v1",
    "adapter": "generic",
    "source": "flow.json",
    "defaultGroup": "patterns",
    "defaultScenario": "default"
  },
  "flow": {
    "schemaVersion": 2,
    "version": "PATTERNS-01",
    "entry": "library",
    "status": "新建项目草稿，等待 AI 补充真实需求",
    "defaults": {
      "state": {
        "items": [
          {
            "id": "a",
            "title": "清晨的山径",
            "category": "旅行",
            "date": 3
          },
          {
            "id": "b",
            "title": "城市观察",
            "category": "日常",
            "date": 2
          },
          {
            "id": "c",
            "title": "周末手记",
            "category": "旅行",
            "date": 1
          }
        ],
        "selectedId": "a",
        "query": "",
        "sort": "new",
        "category": "",
        "view": "grid",
        "page": 0,
        "expanded": false,
        "draftId": "d",
        "draftTitle": "",
        "sync": "ready",
        "progress": 40,
        "toast": false,
        "tab": "library"
      }
    },
    "conditions": {
      "grid": "网格视图",
      "carousel": "轮播视图",
      "saved": "已保存",
      "loading": "正在加载",
      "progressing": "正在同步",
      "failed": "同步失败",
      "libraryTab": "资料库已选",
      "settingsTab": "设置已选"
    },
    "effects": {
      "selectLibrary": "selectLibrary",
      "selectSettings": "selectSettings",
      "clearFilter": "clearFilter",
      "clearToast": "clearToast",
      "startLoading": "startLoading",
      "progressSync": "progressSync",
      "finishSync": "finishSync",
      "failSync": "failSync",
      "appendItem": "appendItem",
      "removeItem": "removeItem"
    },
    "conditionValues": {
      "grid": {
        "key": "view",
        "equals": "grid"
      },
      "carousel": {
        "key": "view",
        "equals": "carousel"
      },
      "saved": {
        "key": "toast",
        "equals": true
      },
      "loading": {
        "key": "sync",
        "equals": "loading"
      },
      "progressing": {
        "key": "sync",
        "equals": "progress"
      },
      "failed": {
        "key": "sync",
        "equals": "error"
      },
      "libraryTab": {
        "key": "tab",
        "equals": "library"
      },
      "settingsTab": {
        "key": "tab",
        "equals": "settings"
      }
    },
    "effectValues": {
      "selectLibrary": {
        "tab": "library"
      },
      "selectSettings": {
        "tab": "settings"
      },
      "clearFilter": {
        "query": "",
        "category": "",
        "sort": "new",
        "page": 0
      },
      "clearToast": {
        "toast": false
      },
      "startLoading": {
        "sync": "loading"
      },
      "progressSync": {
        "sync": "progress",
        "progress": 40
      },
      "finishSync": {
        "sync": "ready",
        "progress": 100,
        "toast": true
      },
      "failSync": {
        "sync": "error"
      },
      "appendItem": {
        "toast": true
      },
      "removeItem": {
        "toast": true
      }
    },
    "actions": {
      "openFilters": {
        "present": "filters"
      },
      "openMenu": {
        "present": "menu"
      },
      "openDelete": {
        "present": "deleteDialog"
      },
      "openNew": {
        "present": "newSheet"
      },
      "dismiss": {
        "dismiss": true
      },
      "showDetail": {
        "to": "detail"
      },
      "library": {
        "to": "library",
        "effect": "selectLibrary"
      },
      "settings": {
        "to": "settings",
        "effect": "selectSettings"
      },
      "applyFilters": {
        "dismiss": true
      },
      "clearFilters": {
        "stay": true,
        "effect": "clearFilter"
      },
      "hideToast": {
        "stay": true,
        "effect": "clearToast"
      },
      "startSync": {
        "stay": true,
        "effect": "startLoading"
      },
      "startProgress": {
        "stay": true,
        "effect": "progressSync"
      },
      "finishSync": {
        "stay": true,
        "effect": "finishSync"
      },
      "failSync": {
        "stay": true,
        "effect": "failSync"
      },
      "createItem": {
        "dismiss": true,
        "validate": true,
        "effect": "appendItem"
      },
      "deleteItem": {
        "to": "library",
        "effect": "removeItem"
      }
    },
    "fixed": {},
    "groups": [
      {
        "id": "patterns",
        "title": "页面与交互组件",
        "description": "固定区域、内容组织和状态变化的通用示例。",
        "screens": [
          "library",
          "detail",
          "filters",
          "menu",
          "deleteDialog",
          "newSheet",
          "settings"
        ],
        "main": [
          "library",
          "detail",
          "settings"
        ]
      }
    ],
    "scenarios": [
      {
        "id": "default",
        "title": "初始资料库",
        "entry": "library",
        "state": {}
      },
      {
        "id": "empty",
        "title": "空资料库",
        "entry": "library",
        "state": {
          "items": []
        }
      },
      {
        "id": "error",
        "title": "同步失败",
        "entry": "settings",
        "state": {
          "sync": "error",
          "tab": "settings"
        }
      }
    ],
    "uncovered": [
      "示例图片为比例占位；操作均为本地会话，不接入真实上传或同步服务。"
    ],
    "deferred": [],
    "screens": {
      "library": {
        "title": "资料库",
        "hideBack": true,
        "regions": {
          "top": {
            "placement": "fixed",
            "blocks": [
              {
                "id": "nav",
                "type": "navigation",
                "text": "资料库",
                "label": "顶部导航",
                "children": [
                  {
                    "id": "filter",
                    "type": "action",
                    "text": "筛选",
                    "action": "openFilters",
                    "icon": "filter",
                    "labelDisplay": "icon"
                  }
                ]
              }
            ]
          },
          "bottom": {
            "placement": "fixed",
            "blocks": [
              {
                "id": "actions",
                "type": "toolbar",
                "label": "资料操作",
                "children": [
                  {
                    "id": "new",
                    "type": "action",
                    "text": "新建资料",
                    "action": "openNew",
                    "icon": "add",
                    "emphasis": "primary"
                  }
                ]
              },
              {
                "id": "tabs",
                "type": "tabbar",
                "label": "主导航",
                "children": [
                  {
                    "id": "tab-library",
                    "type": "action",
                    "text": "资料库",
                    "action": "library",
                    "icon": "grid",
                    "labelDisplay": "both",
                    "selectedWhen": "libraryTab"
                  },
                  {
                    "id": "tab-settings",
                    "type": "action",
                    "text": "设置",
                    "action": "settings",
                    "icon": "settings",
                    "labelDisplay": "both",
                    "selectedWhen": "settingsTab"
                  }
                ]
              }
            ]
          }
        },
        "blocks": [
          {
            "id": "intro",
            "type": "text",
            "text": "把资料整理成可翻阅的卡片。"
          },
          {
            "id": "search",
            "type": "field",
            "label": "查找资料",
            "field": "query",
            "placeholder": "标题或分类"
          },
          {
            "id": "view",
            "type": "segmented",
            "label": "展示方式",
            "field": "view",
            "options": [
              {
                "value": "grid",
                "label": "网格"
              },
              {
                "value": "carousel",
                "label": "轮播"
              }
            ]
          },
          {
            "id": "grid-items",
            "type": "repeat",
            "itemsField": "items",
            "itemKey": "id",
            "selectedField": "selectedId",
            "onSelect": "showDetail",
            "label": "资料列表",
            "mode": "grid",
            "when": "grid",
            "filterField": "query",
            "searchFields": [
              "title",
              "category"
            ],
            "filterBy": {
              "stateField": "category",
              "itemField": "category"
            },
            "sortField": "sort",
            "sorts": [
              {
                "value": "new",
                "key": "date",
                "direction": "desc"
              },
              {
                "value": "old",
                "key": "date",
                "direction": "asc"
              }
            ],
            "pageField": "page",
            "pageSize": 2,
            "emptyText": "没有匹配的资料，试试其他关键词。",
            "children": [
              {
                "id": "grid-items-image",
                "type": "image",
                "alt": "{item.title}",
                "aspect": "landscape"
              },
              {
                "id": "grid-items-title",
                "type": "heading",
                "text": "{item.title}"
              },
              {
                "id": "grid-items-category",
                "type": "text",
                "text": "{item.category}"
              }
            ]
          },
          {
            "id": "carousel-items",
            "type": "repeat",
            "itemsField": "items",
            "itemKey": "id",
            "selectedField": "selectedId",
            "onSelect": "showDetail",
            "label": "资料列表",
            "mode": "carousel",
            "when": "carousel",
            "filterField": "query",
            "searchFields": [
              "title",
              "category"
            ],
            "filterBy": {
              "stateField": "category",
              "itemField": "category"
            },
            "sortField": "sort",
            "sorts": [
              {
                "value": "new",
                "key": "date",
                "direction": "desc"
              },
              {
                "value": "old",
                "key": "date",
                "direction": "asc"
              }
            ],
            "pageField": "page",
            "pageSize": 2,
            "emptyText": "没有匹配的资料，试试其他关键词。",
            "children": [
              {
                "id": "carousel-items-image",
                "type": "image",
                "alt": "{item.title}",
                "aspect": "landscape"
              },
              {
                "id": "carousel-items-title",
                "type": "heading",
                "text": "{item.title}"
              },
              {
                "id": "carousel-items-category",
                "type": "text",
                "text": "{item.category}"
              }
            ]
          },
          {
            "id": "tips",
            "type": "accordion",
            "text": "整理建议",
            "expandedField": "expanded",
            "children": [
              {
                "id": "tips-card",
                "type": "card",
                "children": [
                  {
                    "id": "tip",
                    "type": "text",
                    "text": "先给资料一个清晰的名称，再选择合适的分类。"
                  }
                ]
              }
            ]
          },
          {
            "id": "saved-toast",
            "type": "feedback",
            "variant": "toast",
            "text": "资料已更新",
            "when": "saved",
            "children": [
              {
                "id": "close-toast",
                "type": "action",
                "text": "关闭提示",
                "action": "hideToast"
              }
            ]
          }
        ]
      },
      "detail": {
        "title": "资料详情",
        "back": {
          "to": "library"
        },
        "regions": {
          "top": {
            "blocks": [
              {
                "id": "nav",
                "type": "navigation",
                "text": "资料详情",
                "label": "顶部导航",
                "children": [
                  {
                    "id": "back",
                    "type": "action",
                    "text": "返回",
                    "action": "library",
                    "icon": "back",
                    "labelDisplay": "icon",
                    "slot": "leading"
                  },
                  {
                    "id": "more",
                    "type": "action",
                    "text": "更多操作",
                    "action": "openMenu",
                    "icon": "more",
                    "labelDisplay": "icon"
                  }
                ]
              }
            ]
          },
          "bottom": {
            "blocks": [
              {
                "id": "detail-actions",
                "type": "toolbar",
                "label": "详情操作",
                "children": [
                  {
                    "id": "detail-delete",
                    "type": "action",
                    "text": "删除资料",
                    "action": "openDelete",
                    "icon": "trash",
                    "emphasis": "danger"
                  },
                  {
                    "id": "back-library",
                    "type": "action",
                    "text": "返回资料库",
                    "action": "library"
                  }
                ]
              }
            ]
          }
        },
        "blocks": [
          {
            "id": "cover",
            "type": "image",
            "alt": "{selectedId.title}",
            "aspect": "portrait",
            "action": "openMenu"
          },
          {
            "id": "title",
            "type": "heading",
            "text": "{selectedId.title}"
          },
          {
            "id": "meta",
            "type": "list",
            "children": [
              {
                "id": "category-row",
                "type": "list-row",
                "children": [
                  {
                    "id": "category-label",
                    "type": "text",
                    "text": "分类"
                  },
                  {
                    "id": "category-value",
                    "type": "text",
                    "text": "{selectedId.category}"
                  }
                ]
              },
              {
                "id": "note-row",
                "type": "list-row",
                "children": [
                  {
                    "id": "note-label",
                    "type": "text",
                    "text": "状态"
                  },
                  {
                    "id": "note-value",
                    "type": "text",
                    "text": "已整理"
                  }
                ]
              }
            ]
          }
        ]
      },
      "filters": {
        "title": "筛选与排序",
        "presentation": "sheet",
        "blocks": [
          {
            "id": "category",
            "type": "select",
            "label": "分类",
            "field": "category",
            "options": [
              {
                "value": "",
                "label": "全部"
              },
              {
                "value": "旅行",
                "label": "旅行"
              },
              {
                "value": "日常",
                "label": "日常"
              }
            ]
          },
          {
            "id": "sort",
            "type": "choice",
            "label": "排列顺序",
            "field": "sort",
            "options": [
              {
                "value": "new",
                "label": "最新在前"
              },
              {
                "value": "old",
                "label": "最早在前"
              }
            ]
          },
          {
            "id": "filter-actions",
            "type": "row",
            "children": [
              {
                "id": "clear",
                "type": "action",
                "text": "重置",
                "action": "clearFilters"
              },
              {
                "id": "apply",
                "type": "action",
                "text": "完成",
                "action": "applyFilters",
                "emphasis": "primary"
              }
            ]
          }
        ]
      },
      "menu": {
        "title": "资料操作",
        "presentation": "menu",
        "blocks": [
          {
            "id": "menu-delete",
            "type": "action",
            "text": "删除资料",
            "action": "openDelete",
            "icon": "trash",
            "emphasis": "danger"
          },
          {
            "id": "menu-close",
            "type": "action",
            "text": "取消",
            "action": "dismiss"
          }
        ]
      },
      "deleteDialog": {
        "title": "删除这份资料？",
        "presentation": "dialog",
        "dismissible": false,
        "blocks": [
          {
            "id": "explain",
            "type": "text",
            "text": "删除后会从当前资料库移除。"
          },
          {
            "id": "confirm-actions",
            "type": "row",
            "children": [
              {
                "id": "cancel",
                "type": "action",
                "text": "取消",
                "action": "dismiss"
              },
              {
                "id": "delete",
                "type": "action",
                "text": "删除",
                "action": "deleteItem",
                "emphasis": "danger"
              }
            ]
          }
        ]
      },
      "newSheet": {
        "title": "新建资料",
        "presentation": "sheet",
        "regions": {
          "bottom": {
            "blocks": [
              {
                "id": "save-toolbar",
                "type": "toolbar",
                "label": "保存资料",
                "children": [
                  {
                    "id": "cancel-new",
                    "type": "action",
                    "text": "取消",
                    "action": "dismiss"
                  },
                  {
                    "id": "save-new",
                    "type": "action",
                    "text": "保存",
                    "action": "createItem",
                    "emphasis": "primary"
                  }
                ]
              }
            ]
          }
        },
        "blocks": [
          {
            "id": "new-id",
            "type": "field",
            "label": "唯一编号",
            "field": "draftId",
            "required": true
          },
          {
            "id": "new-title",
            "type": "field",
            "label": "资料名称",
            "field": "draftTitle",
            "required": true
          },
          {
            "id": "new-hint",
            "type": "text",
            "text": "取消后保留当前填写内容，方便下次继续。"
          }
        ]
      },
      "settings": {
        "title": "设置",
        "regions": {
          "top": {
            "blocks": [
              {
                "id": "nav",
                "type": "navigation",
                "text": "设置",
                "label": "顶部导航",
                "children": []
              }
            ]
          },
          "bottom": {
            "blocks": [
              {
                "id": "tabs",
                "type": "tabbar",
                "label": "主导航",
                "children": [
                  {
                    "id": "tab-library",
                    "type": "action",
                    "text": "资料库",
                    "action": "library",
                    "icon": "grid",
                    "labelDisplay": "both",
                    "selectedWhen": "libraryTab"
                  },
                  {
                    "id": "tab-settings",
                    "type": "action",
                    "text": "设置",
                    "action": "settings",
                    "icon": "settings",
                    "labelDisplay": "both",
                    "selectedWhen": "settingsTab"
                  }
                ]
              }
            ]
          }
        },
        "blocks": [
          {
            "id": "sync-card",
            "type": "card",
            "text": "资料同步",
            "children": [
              {
                "id": "sync-copy",
                "type": "text",
                "text": "查看加载、进度与失败恢复的状态。"
              },
              {
                "id": "sync",
                "type": "action",
                "text": "开始同步",
                "action": "startSync",
                "emphasis": "primary"
              }
            ]
          },
          {
            "id": "loading-feedback",
            "type": "feedback",
            "variant": "loading",
            "when": "loading",
            "blocking": true,
            "text": "正在准备同步",
            "children": [
              {
                "id": "loading-next",
                "type": "action",
                "text": "开始传输",
                "action": "startProgress"
              },
              {
                "id": "loading-fail",
                "type": "action",
                "text": "模拟失败",
                "action": "failSync"
              }
            ]
          },
          {
            "id": "progress-feedback",
            "type": "feedback",
            "variant": "progress",
            "progressField": "progress",
            "when": "progressing",
            "blocking": true,
            "text": "正在同步资料",
            "children": [
              {
                "id": "complete-sync",
                "type": "action",
                "text": "完成同步",
                "action": "finishSync"
              },
              {
                "id": "fail-sync",
                "type": "action",
                "text": "模拟失败",
                "action": "failSync"
              }
            ]
          },
          {
            "id": "error-feedback",
            "type": "feedback",
            "variant": "error",
            "when": "failed",
            "text": "同步失败，请重试",
            "children": [
              {
                "id": "retry",
                "type": "action",
                "text": "重试",
                "action": "startSync"
              },
              {
                "id": "return",
                "type": "action",
                "text": "返回资料库",
                "action": "library"
              }
            ]
          },
          {
            "id": "empty-example",
            "type": "feedback",
            "variant": "empty",
            "text": "暂时没有其他设备",
            "children": [
              {
                "id": "empty-return",
                "type": "action",
                "text": "浏览资料库",
                "action": "library"
              }
            ]
          },
          {
            "id": "settings-toast",
            "type": "feedback",
            "variant": "toast",
            "text": "同步已完成",
            "when": "saved",
            "children": [
              {
                "id": "dismiss-settings-toast",
                "type": "action",
                "text": "关闭提示",
                "action": "hideToast"
              }
            ]
          }
        ]
      }
    },
    "effectLists": {
      "appendItem": [
        {
          "field": "items",
          "operation": "append",
          "item": {
            "id": {
              "from": "draftId"
            },
            "title": {
              "from": "draftTitle"
            },
            "category": "日常",
            "date": 4
          }
        }
      ],
      "removeItem": [
        {
          "field": "items",
          "operation": "remove",
          "key": "id",
          "selectedField": "selectedId"
        }
      ]
    }
  }
}
