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 * <h2 class='section'>Examples:</h2>
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 *
065 * <h2 class='section'>See Also:</h2><ul>
066 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauBeanHtml5">juneau-bean-html5</a>
067 * </ul>
068 */
069@Marshalled(typeName = "fieldset")
070public class Fieldset extends HtmlElementMixed<Fieldset> {
071
072   /**
073    * Creates an empty {@link Fieldset} element.
074    */
075   public Fieldset() {}
076
077   /**
078    * Creates a {@link Fieldset} element with the specified child nodes.
079    *
080    * @param children The child nodes. Must not be <jk>null</jk>.
081    */
082   public Fieldset(Object...children) {
083      children(children);
084   }
085
086   /**
087    * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-fieldset-disabled">disabled</a> attribute.
088    *
089    * <p>
090    * Whether the form control is disabled.
091    *
092    * <p>
093    * This attribute uses deminimized values:
094    * <ul>
095    *    <li><jk>false</jk> - Attribute is not added</li>
096    *    <li><jk>true</jk> - Attribute is added as <js>"disabled"</js></li>
097    *    <li>Other values - Passed through as-is</li>
098    * </ul>
099    *
100    * @param value
101    *    The new value for this attribute.
102    *    Typically a {@link Boolean} or {@link String}.
103    *    Can be <jk>null</jk> to unset the attribute.
104    * @return This object.
105    */
106   public Fieldset disabled(Object value) {
107      attr("disabled", deminimize(value, "disabled"));
108      return this;
109   }
110
111   /**
112    * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-fae-form">form</a> attribute.
113    *
114    * <p>
115    * Associates the fieldset with a form element by specifying the form's ID. This allows the fieldset
116    * to be placed outside the form element while still being part of the form.
117    *
118    * <p>
119    * The value should match the ID of a form element in the same document.
120    *
121    * @param value The ID of the form element to associate with this fieldset. Can be <jk>null</jk> to unset the attribute.
122    * @return This object.
123    */
124   public Fieldset form(String value) {
125      attr("form", value);
126      return this;
127   }
128
129   /**
130    * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-fe-name">name</a> attribute.
131    *
132    * <p>
133    * Specifies the name of the fieldset. This name can be used to access the fieldset
134    * via the form.elements API and for form submission.
135    *
136    * <p>
137    * The name should be unique within the form and should not contain spaces or special characters.
138    *
139    * @param value The name of the fieldset for API access and submission. Can be <jk>null</jk> to unset the attribute.
140    * @return This object.
141    */
142   public Fieldset name(String value) {
143      attr("name", value);
144      return this;
145   }
146
147}