<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:f="http://xmlns.jcp.org/jsf/core"
                xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
                xmlns:p="http://primefaces.org/ui">
    
    <!-- 
        Composant champ sélection réutilisable (WOU/DRY)
        Usage: <ui:include src="/templates/components/forms/form-field-select.xhtml">
                  <ui:param name="id" value="fieldId" />
                  <ui:param name="label" value="Label du champ" />
                  <ui:param name="value" value="#{bean.property}" />
                  <ui:param name="items" value="#{bean.options}" />
                  <ui:param name="required" value="true" />
                  <ui:param name="var" value="item" />
                  <ui:param name="itemLabel" value="#{item.label}" />
                  <ui:param name="itemValue" value="#{item.value}" />
                  <ui:param name="update" value="componentId" />
                  <ui:param name="ajaxEvent" value="change" />
                  <ui:define name="items">
                      <f:selectItem itemLabel="Option 1" itemValue="1" />
                  </ui:define>
                </ui:include>
    -->
    
    <div class="field">
        <p:outputLabel for="#{id}" value="#{label}" />
        <p:selectOneMenu id="#{id}" 
                        value="#{value}" 
                        required="#{not empty required and required}"
                        disabled="#{not empty readonly and readonly}"
                        styleClass="w-full">
            <f:selectItem itemLabel="Sélectionner..." itemValue="" noSelectionOption="true" rendered="#{not empty required and required}" />
            <ui:insert name="items">
                <ui:fragment rendered="#{not empty var and not empty itemLabel and not empty itemValue}">
                    <f:selectItems value="#{items}" 
                                 var="#{var}" 
                                 itemLabel="#{itemLabel}" 
                                 itemValue="#{itemValue}" />
                </ui:fragment>
                <ui:fragment rendered="#{empty var}">
                    <f:selectItems value="#{items}" />
                </ui:fragment>
            </ui:insert>
            <ui:insert name="ajax">
                <!-- AJAX peut être ajouté ici via ui:define -->
            </ui:insert>
        </p:selectOneMenu>
    </div>
</ui:composition>

