001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.juneau.bean.html5;
018
019import org.apache.juneau.marshall.*;
020
021/**
022 * DTO for an HTML <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#the-datalist-element">&lt;datalist&gt;</a>
023 * element.
024 *
025 * <p>
026 * The datalist element represents a set of option elements that represent predefined options for other
027 * controls. It is used to provide a list of suggested values for input elements, allowing users to
028 * either select from the predefined options or enter their own custom value. The datalist element
029 * is typically associated with an input element through the list attribute, and the options within
030 * the datalist provide autocomplete suggestions.
031 *
032 * <h5 class='section'>Examples:</h5>
033 * <p class='bcode w800'>
034 *    <jk>import static</jk> org.apache.juneau.bean.html5.HtmlBuilder.*;
035 *
036 *    <jc>// Simple datalist</jc>
037 *    Datalist <jv>simple</jv> = <jsm>datalist</jsm>(<js>"colors"</js>,
038 *       <jsm>option</jsm>(<js>"red"</js>, <js>"Red"</js>),
039 *       <jsm>option</jsm>(<js>"green"</js>, <js>"Green"</js>),
040 *       <jsm>option</jsm>(<js>"blue"</js>, <js>"Blue"</js>)
041 *    );
042 *
043 *    <jc>// Datalist with styling</jc>
044 *    Datalist <jv>styled</jv> = <jsm>datalist</jsm>(<js>"countries"</js>,
045 *       <jsm>option</jsm>(<js>"us"</js>, <js>"United States"</js>),
046 *       <jsm>option</jsm>(<js>"ca"</js>, <js>"Canada"</js>),
047 *       <jsm>option</jsm>(<js>"mx"</js>, <js>"Mexico"</js>)
048 *    ).class_(<js>"country-list"</js>);
049 *
050 *    <jc>// Datalist with multiple options</jc>
051 *    Datalist <jv>multiple</jv> = <jsm>datalist</jsm>(<js>"fruits"</js>,
052 *       <jsm>option</jsm>(<js>"apple"</js>, <js>"Apple"</js>),
053 *       <jsm>option</jsm>(<js>"banana"</js>, <js>"Banana"</js>),
054 *       <jsm>option</jsm>(<js>"cherry"</js>, <js>"Cherry"</js>),
055 *       <jsm>option</jsm>(<js>"date"</js>, <js>"Date"</js>),
056 *       <jsm>option</jsm>(<js>"elderberry"</js>, <js>"Elderberry"</js>)
057 *    );
058 *
059 *    <jc>// Datalist with complex options</jc>
060 *    Datalist <jv>complex</jv> = <jsm>datalist</jsm>(<js>"products"</js>,
061 *       <jsm>option</jsm>(<js>"laptop-001"</js>, <js>"Laptop Pro 15\" - $1,299"</js>),
062 *       <jsm>option</jsm>(<js>"laptop-002"</js>, <js>"Laptop Air 13\" - $999"</js>),
063 *       <jsm>option</jsm>(<js>"tablet-001"</js>, <js>"Tablet 10\" - $499"</js>)
064 *    );
065 *
066 *    <jc>// Datalist with ID</jc>
067 *    Datalist <jv>withId</jv> = <jsm>datalist</jsm>(<js>"cities"</js>,
068 *       <jsm>option</jsm>(<js>"new-york"</js>, <js>"New York"</js>),
069 *       <jsm>option</jsm>(<js>"los-angeles"</js>, <js>"Los Angeles"</js>),
070 *       <jsm>option</jsm>(<js>"chicago"</js>, <js>"Chicago"</js>)
071 *    );
072 *
073 *    <jc>// Datalist with styling</jc>
074 *    Datalist <jv>styled2</jv> = <jsm>datalist</jsm>(<js>"sizes"</js>,
075 *       <jsm>option</jsm>(<js>"xs"</js>, <js>"Extra Small"</js>),
076 *       <jsm>option</jsm>(<js>"s"</js>, <js>"Small"</js>),
077 *       <jsm>option</jsm>(<js>"m"</js>, <js>"Medium"</js>),
078 *       <jsm>option</jsm>(<js>"l"</js>, <js>"Large"</js>),
079 *       <jsm>option</jsm>(<js>"xl"</js>, <js>"Extra Large"</js>)
080 *    ).style(<js>"display: none;"</js>);
081 * </p>
082 *
083 * <p>
084 * The following convenience methods are provided for constructing instances of this bean:
085 * <ul class='javatree'>
086 *    <li class='jc'>{@link HtmlBuilder}
087 *    <ul class='javatree'>
088 *       <li class='jm'>{@link HtmlBuilder#datalist() datalist()}
089 *       <li class='jm'>{@link HtmlBuilder#datalist(String, Option...) datalist(String, Option...)}
090 *    </ul>
091 * </ul>
092 * </p>
093 *
094 * <h5 class='section'>See Also:</h5><ul>
095 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauBeanHtml5">juneau-bean-html5</a>
096 * </ul>
097 */
098@Marshalled(typeName = "datalist")
099public class Datalist extends HtmlElementContainer<Datalist> {
100
101   /**
102    * Creates an empty {@link Datalist} element.
103    */
104   public Datalist() {}
105
106   /**
107    * Creates a {@link Datalist} element with the specified {@link Datalist#id(String)} attribute and child nodes.
108    *
109    * @param id The {@link Datalist#id(String)} attribute.
110    * @param children The child nodes.
111    */
112   public Datalist(String id, Option...children) {
113      id(id).children((Object[])children);
114   }
115
116}