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-fieldset-element">&lt;fieldset&gt;</a>
023 * element.
024 *
025 * <p>
026 * The fieldset element groups related form controls together. It provides a visual and semantic
027 * grouping mechanism that helps organize complex forms and improves accessibility. The legend
028 * element is typically used as the first child to provide a caption for the fieldset.
029 *
030 * <h5 class='section'>Examples:</h5>
031 * <p class='bcode w800'>
032 *    <jk>import static</jk> org.apache.juneau.bean.html5.HtmlBuilder.*;
033 *
034 *    <jc>// Simple fieldset with legend</jc>
035 *    Fieldset <jv>fieldset1</jv> = <jsm>fieldset</jsm>(
036 *       <jsm>legend</jsm>(<js>"Personal Information"</js>),
037 *       <jsm>input</jsm>(<js>"text"</js>).name(<js>"firstName"</js>).placeholder(<js>"First Name"</js>),
038 *       <jsm>input</jsm>(<js>"text"</js>).name(<js>"lastName"</js>).placeholder(<js>"Last Name"</js>)
039 *    );
040 *
041 *    <jc>// Disabled fieldset</jc>
042 *    Fieldset <jv>fieldset2</jv> = <jsm>fieldset</jsm>(
043 *       <jsm>legend</jsm>(<js>"Disabled Section"</js>),
044 *       <jsm>input</jsm>(<js>"text"</js>).name(<js>"disabledField"</js>).value(<js>"Cannot edit"</js>)
045 *    ).disabled(<jk>true</jk>);
046 *
047 *    <jc>// Fieldset with custom styling</jc>
048 *    Fieldset <jv>fieldset3</jv> = <jsm>fieldset</jsm>(
049 *       <jsm>legend</jsm>(<js>"Contact Details"</js>),
050 *       <jsm>input</jsm>(<js>"email"</js>).name(<js>"email"</js>).placeholder(<js>"Email"</js>),
051 *       <jsm>input</jsm>(<js>"tel"</js>).name(<js>"phone"</js>).placeholder(<js>"Phone"</js>)
052 *    ).class_(<js>"form-group"</js>);
053 * </p>
054 *
055 * <p>
056 * The following convenience methods are provided for constructing instances of this bean:
057 * <ul class='javatree'>
058 *    <li class='jc'>{@link HtmlBuilder}
059 *    <ul class='javatree'>
060 *       <li class='jm'>{@link HtmlBuilder#fieldset() fieldset()}
061 *       <li class='jm'>{@link HtmlBuilder#fieldset(Object...) fieldset(Object...)}
062 *    </ul>
063 * </ul>
064 * </p>
065 *
066 * <h5 class='section'>See Also:</h5><ul>
067 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauBeanHtml5">juneau-bean-html5</a>
068 * </ul>
069 */
070@Marshalled(typeName = "fieldset")
071public class Fieldset extends HtmlElementMixed<Fieldset> {
072
073   /**
074    * Creates an empty {@link Fieldset} element.
075    */
076   public Fieldset() {}
077
078   /**
079    * Creates a {@link Fieldset} element with the specified child nodes.
080    *
081    * @param children The child nodes. Must not be <jk>null</jk>.
082    */
083   public Fieldset(Object...children) {
084      children(children);
085   }
086
087   /**
088    * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-fieldset-disabled">disabled</a> attribute.
089    *
090    * <p>
091    * Whether the form control is disabled.
092    *
093    * <p>
094    * This attribute uses deminimized values:
095    * <ul>
096    *    <li><jk>false</jk> - Attribute is not added</li>
097    *    <li><jk>true</jk> - Attribute is added as <js>"disabled"</js></li>
098    *    <li>Other values - Passed through as-is</li>
099    * </ul>
100    *
101    * @param value
102    *    The new value for this attribute.
103    *    Typically a {@link Boolean} or {@link String}.
104    *    Can be <jk>null</jk> to unset the attribute.
105    * @return This object.
106    */
107   public Fieldset disabled(Object value) {
108      attr("disabled", deminimize(value, "disabled"));
109      return this;
110   }
111
112   /**
113    * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-fae-form">form</a> attribute.
114    *
115    * <p>
116    * Associates the fieldset with a form element by specifying the form's ID. This allows the fieldset
117    * to be placed outside the form element while still being part of the form.
118    *
119    * <p>
120    * The value should match the ID of a form element in the same document.
121    *
122    * @param value The ID of the form element to associate with this fieldset. Can be <jk>null</jk> to unset the attribute.
123    * @return This object.
124    */
125   public Fieldset form(String value) {
126      attr("form", value);
127      return this;
128   }
129
130   /**
131    * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-fe-name">name</a> attribute.
132    *
133    * <p>
134    * Specifies the name of the fieldset. This name can be used to access the fieldset
135    * via the form.elements API and for form submission.
136    *
137    * <p>
138    * The name should be unique within the form and should not contain spaces or special characters.
139    *
140    * @param value The name of the fieldset for API access and submission. Can be <jk>null</jk> to unset the attribute.
141    * @return This object.
142    */
143   public Fieldset name(String value) {
144      attr("name", value);
145      return this;
146   }
147
148}