# `PhoenixKitWarehouse.Web.Components.RelatedDocuments`
[🔗](https://github.com/BeamLabEU/phoenix_kit_warehouse/blob/0.4.0/lib/phoenix_kit_warehouse/web/components/related_documents.ex#L1)

Shared "related documents" card fragment for warehouse document forms.

Consolidates the upstream/downstream link blocks that were duplicated
inline in `InternalOrderFormLive` and `SupplierOrderFormLive` (§7 list-MVP
of the warehouse traceability model):

  * `upstream` — documents this one was imported from or manually linked
    to via `PhoenixKitWarehouse.SourceKinds`. Always rendered, even when
    empty, because the block also carries the "Attach" control
    (`phx-click="open_link_picker"`) that lets the keeper add the first
    link; each attached ref gets a "remove" button
    (`phx-click="remove_source_ref"`, `phx-value-type`, `phx-value-uuid`).
  * `downstream` — documents created *from* this one (e.g. a Goods Receipt
    spawned from a Supplier Order). Read-only — no attach/remove controls —
    and the whole block is skipped when the list is empty.

Both attrs take the ref-map shape produced by `PhoenixKitWarehouse.DocRefs`:
`%{label:, path:, uuid:, kind:}`. The calling LiveView owns the
`open_link_picker` / `remove_source_ref` event handlers and the
`source_refs` / child-refs assigns that feed this component — this module
only renders.

# `related_documents`

## Attributes

* `upstream` (`:list`) (required) - Editable ref maps, e.g. @source_refs.
* `downstream` (`:list`) (required) - Read-only ref maps; block hidden when empty.
* `upstream_label` (`:string`) (required)
* `downstream_label` (`:string`) (required)

---

*Consult [api-reference.md](api-reference.md) for complete listing*
