{
  "$schema": "https://shadcn-vue.com/schema/registry-item.json",
  "name": "sync-status",
  "type": "registry:block",
  "title": "Sync status",
  "description": "Where the user’s changes are: saved on this device, on their way, or on the server.",
  "author": "spotstrap (https://kodentuzo.com/spotstrap)",
  "dependencies": [
    "@kodentuzo/spotstrap@^0.3.1"
  ],
  "registryDependencies": [],
  "files": [
    {
      "path": "components/SyncStatus.vue",
      "type": "registry:component",
      "content": "<script setup lang=\"ts\">\n// Where the user's changes are: saved on this device, on their way, or on the server. Feed it\n// from the app's outbox (pending count), `navigator.onLine` and whether the last sync failed.\nimport { en, type Messages, syncStatus } from '@kodentuzo/spotstrap/blocks'\nimport { computed } from 'vue'\n\n// The same fields as SyncInput, written out: Vue can't resolve an imported type here.\n// Vue reads a missing boolean prop as false, so `remote` defaults to true here.\nconst props = withDefaults(defineProps<{\n  /** Changes saved on this device that the server hasn't confirmed yet. */\n  pending: number\n  /** Whether the browser is online. */\n  online: boolean\n  /** False when the data stays on the device only. */\n  remote?: boolean\n  /** The last sync failed and won't retry by itself. */\n  failed?: boolean\n  messages?: Messages\n}>(), { remote: true, failed: false })\nconst emit = defineEmits<{ retry: [] }>()\n\nconst t = computed(() => (props.messages ?? en).sync)\nconst status = computed(() =>\n  syncStatus(\n    { pending: props.pending, online: props.online, remote: props.remote, failed: props.failed },\n    props.messages ?? en,\n  ),\n)\nconst dot = computed(\n  () =>\n    ({\n      'saved-here': 'bg-muted-foreground',\n      syncing: 'bg-primary animate-pulse',\n      synced: 'bg-primary',\n      offline: 'bg-muted-foreground',\n      failed: 'bg-destructive',\n    })[status.value.state],\n)\n</script>\n\n<template>\n  <p class=\"inline-flex items-center gap-2 text-sm text-muted-foreground\" :title=\"status.help\">\n    <span class=\"size-2 shrink-0 rounded-full\" :class=\"dot\" aria-hidden=\"true\" />\n    <span role=\"status\" aria-live=\"polite\">{{ status.text }}</span>\n    <button\n      v-if=\"status.state === 'failed'\"\n      type=\"button\"\n      class=\"font-medium text-foreground underline underline-offset-4\"\n      @click=\"emit('retry')\"\n    >\n      {{ t.retry }}\n    </button>\n  </p>\n</template>\n"
    }
  ]
}
