@prefix : <#> .
@prefix ui: <http://www.w3.org/ns/ui#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema: <http://schema.org/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

# Class for the menu-item-type dropdown. solid-ui's ui:Choice enumerates
# instances of `ui:from <Class>`, so we declare the three valid item-type
# URIs as instances of :MenuItemType. The rdfs:label on each is what the
# user sees in the dropdown; the URI is what gets stored as rdf:type on
# the item. These triples are scoped to this form file — they don't
# rewrite ui:Link/Component/Menu's "real" definitions.
:MenuItemType a rdfs:Class ;
  rdfs:label "Menu Item Type" .

ui:Link      a :MenuItemType ; rdfs:label "Link" .
ui:Component a :MenuItemType ; rdfs:label "Component" .
ui:Menu      a :MenuItemType ; rdfs:label "Sub-menu" .

ui:Horizontal a ui:Orientation ; rdfs:label "Horizontal" .
ui:Vertical   a ui:Orientation ; rdfs:label "Vertical"   .

:MenuForm a ui:Form ;
  ui:label "Menu Editor" ;
  ui:parts ( :labelField :orientationField :partsMultiple ) .

:labelField a ui:SingleLineTextField ;
  ui:property ui:label ;
  ui:label "Menu Label" ;
  ui:required true .

:orientationField a ui:Choice ;
  ui:property ui:orientation ;
  ui:from ui:Orientation ;
  ui:label "Orientation" ;
  ui:default ui:Horizontal .

:partsMultiple a ui:Multiple ;
  ui:property ui:parts ;
  ui:label "Menu Items" ;
  ui:ordered true ;
  ui:part :menuItemForm .

:menuItemForm a ui:Form ;
  ui:parts ( :itemTypeField :itemOptions ) .

# Dropdown of the three valid item types. solid-ui's ui:Choice uses
# `ui:from` to enumerate instances of :MenuItemType (declared above) and
# `rdfs:label` for display, so the user sees "Link / Component / Sub-menu"
# but the stored value is the corresponding ui:* URI.
:itemTypeField a ui:Choice ;
  ui:property rdf:type ;
  ui:label "Item Type" ;
  ui:from :MenuItemType ;
  ui:default ui:Link .

:itemOptions a ui:Options ;
  ui:dependingOn rdf:type ;
  ui:case
    [ ui:for ui:Link ;      ui:use :linkForm ] ,
    [ ui:for ui:Component ; ui:use :componentForm ] ,
    [ ui:for ui:Menu ;      ui:use :subMenuForm ] .

# ── Link ──

:linkForm a ui:Group ;
  ui:parts ( :linkLabelField :hrefField :contentsField :linkIconField ) .

:linkLabelField a ui:SingleLineTextField ;
  ui:property ui:label ;
  ui:label "Label" ;
  ui:required true .

:hrefField a ui:SingleLineTextField ;
  ui:property schema:url ;
  ui:label "URL" .

:contentsField a ui:MultiLineTextField ;
  ui:property ui:contents ;
  ui:label "Inline HTML (contents)" .

:linkIconField a ui:SingleLineTextField ;
  ui:property ui:icon ;
  ui:label "Icon URL" .

# ── Component ──

:componentForm a ui:Group ;
  ui:parts ( :compLabelField :compNameField :compIconField :attributesMultiple ) .

:compLabelField a ui:SingleLineTextField ;
  ui:property ui:label ;
  ui:label "Label" ;
  ui:required true .

:compNameField a ui:SingleLineTextField ;
  ui:property schema:url ;
  ui:label "Module URL (its filename is the element tag)" ;
  ui:required true .

:compIconField a ui:SingleLineTextField ;
  ui:property ui:icon ;
  ui:label "Icon URL" .

:attributesMultiple a ui:Multiple ;
  ui:property schema:additionalProperty ;
  ui:label "Attributes" ;
  ui:part :attrForm .

:attrForm a ui:Group ;
  ui:parts ( :attrNameField :attrValueField ) .

:attrNameField a ui:SingleLineTextField ;
  ui:property schema:name ;
  ui:label "Name" ;
  ui:required true .

:attrValueField a ui:SingleLineTextField ;
  ui:property schema:value ;
  ui:label "Value" ;
  ui:required true .

# ── Sub-menu ──

:subMenuForm a ui:Group ;
  ui:parts ( :subLabelField :subOrientationField :subPartsMultiple ) .

:subLabelField a ui:SingleLineTextField ;
  ui:property ui:label ;
  ui:label "Label" ;
  ui:required true .

:subOrientationField a ui:Choice ;
  ui:property ui:orientation ;
  ui:from ui:Orientation ;
  ui:label "Orientation" ;
  ui:default ui:Vertical .

:subPartsMultiple a ui:Multiple ;
  ui:property ui:parts ;
  ui:label "Sub-menu Items" ;
  ui:ordered true ;
  ui:part :menuItemForm .
