diff --git a/dist/tiny-form-fields.esm.js b/dist/tiny-form-fields.esm.js index a2fa1fd..328d8f0 100644 --- a/dist/tiny-form-fields.esm.js +++ b/dist/tiny-form-fields.esm.js @@ -9337,6 +9337,7 @@ var $elm$html$Html$Events$stopPropagationOn = F2( }); var $elm$html$Html$Attributes$title = $elm$html$Html$Attributes$stringProperty('title'); var $elm$html$Html$Attributes$for = $elm$html$Html$Attributes$stringProperty('htmlFor'); +var $elm$html$Html$Attributes$id = $elm$html$Html$Attributes$stringProperty('id'); var $elm$html$Html$label = _VirtualDom_node('label'); var $author$project$Main$maybeMaxLengthOf = function (formField) { var _v0 = formField.a; @@ -9381,6 +9382,7 @@ var $author$project$Main$requiredData = function (presence) { return true; } }; +var $elm$html$Html$span = _VirtualDom_node('span'); var $elm$json$Json$Encode$bool = _Json_wrap; var $elm$html$Html$Attributes$boolProperty = F2( function (key, bool) { @@ -9511,7 +9513,6 @@ var $author$project$Main$filterChoices = F3( return choices; } }); -var $elm$html$Html$Attributes$id = $elm$html$Html$Attributes$stringProperty('id'); var $elm$html$Html$Attributes$maxlength = function (n) { return A2( _VirtualDom_attribute, @@ -9694,7 +9695,8 @@ var $author$project$Main$viewFormFieldOptionsPreview = F3( $elm$html$Html$Attributes$name(fieldName), $elm$html$Html$Attributes$id(fieldID), $elm$html$Html$Attributes$required( - $author$project$Main$requiredData(formField.p)) + $author$project$Main$requiredData(formField.p)), + A2($elm$html$Html$Attributes$attribute, 'aria-describedby', fieldID + '-description') ]), _Utils_ap( dataListAttrs, @@ -9740,7 +9742,8 @@ var $author$project$Main$viewFormFieldOptionsPreview = F3( $elm$html$Html$Attributes$id(fieldID), $elm$html$Html$Attributes$required( $author$project$Main$requiredData(formField.p)), - $elm$html$Html$Attributes$placeholder(' ') + $elm$html$Html$Attributes$placeholder(' '), + A2($elm$html$Html$Attributes$attribute, 'aria-describedby', fieldID + '-description') ]), _Utils_ap( extraAttrs, @@ -9776,6 +9779,7 @@ var $author$project$Main$viewFormFieldOptionsPreview = F3( [ $elm$html$Html$Attributes$name(fieldName), $elm$html$Html$Attributes$id(fieldID), + A2($elm$html$Html$Attributes$attribute, 'aria-describedby', fieldID + '-description'), disabledMode ? $elm$html$Html$Attributes$class('tff-select-disabled') : $elm$html$Html$Attributes$required( $author$project$Main$requiredData(formField.p)) ]), @@ -9874,7 +9878,8 @@ var $author$project$Main$viewFormFieldOptionsPreview = F3( $elm$html$Html$Attributes$checked( _Utils_eq(valueString, choice.j) || chosenForYou(filteredChoices)), $elm$html$Html$Attributes$required( - $author$project$Main$requiredData(formField.p)) + $author$project$Main$requiredData(formField.p)), + A2($elm$html$Html$Attributes$attribute, 'aria-describedby', fieldID + '-description') ]), _Utils_ap( config.Z, @@ -10021,7 +10026,8 @@ var $author$project$Main$viewFormFieldOptionsPreview = F3( $elm$html$Html$Attributes$name(fieldName), $elm$html$Html$Attributes$value(choice.j), $elm$html$Html$Attributes$checked( - A2($elm$core$List$member, choice.j, values) || chosenForYou(filteredChoices)) + A2($elm$core$List$member, choice.j, values) || chosenForYou(filteredChoices)), + A2($elm$html$Html$Attributes$attribute, 'aria-describedby', fieldID + '-description') ]), _Utils_ap( shouldDisable ? _List_fromArray( @@ -10080,21 +10086,39 @@ var $author$project$Main$viewFormFieldPreview = F3( var _v1 = formField.a; if (_v1.$ === 4) { var minRequired = _v1.a.P; - return (!_Utils_eq(minRequired, $elm$core$Maybe$Nothing)) ? $elm$html$Html$text('') : $elm$html$Html$text(' (optional)'); + return (!_Utils_eq(minRequired, $elm$core$Maybe$Nothing)) ? $elm$html$Html$text('') : A2( + $elm$html$Html$span, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('tff-label-optional') + ]), + _List_fromArray( + [ + $elm$html$Html$text(' (optional)') + ])); } else { - return $elm$html$Html$text(' (optional)'); + return A2( + $elm$html$Html$span, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('tff-label-optional') + ]), + _List_fromArray( + [ + $elm$html$Html$text(' (optional)') + ])); } default: return $elm$html$Html$text(''); } }() ])), - A3($author$project$Main$viewFormFieldOptionsPreview, config, fieldID, formField), A2( $elm$html$Html$div, _List_fromArray( [ - $elm$html$Html$Attributes$class('tff-field-description') + $elm$html$Html$Attributes$class('tff-field-description'), + $elm$html$Html$Attributes$id(fieldID + '-description') ]), _List_fromArray( [ @@ -10122,7 +10146,8 @@ var $author$project$Main$viewFormFieldPreview = F3( return $elm$html$Html$text(''); } }() - ])) + ])), + A3($author$project$Main$viewFormFieldOptionsPreview, config, fieldID, formField) ])) ])); }); diff --git a/dist/tiny-form-fields.js b/dist/tiny-form-fields.js index d275fe0..26316f6 100644 --- a/dist/tiny-form-fields.js +++ b/dist/tiny-form-fields.js @@ -9329,6 +9329,7 @@ var $elm$html$Html$Events$stopPropagationOn = F2( }); var $elm$html$Html$Attributes$title = $elm$html$Html$Attributes$stringProperty('title'); var $elm$html$Html$Attributes$for = $elm$html$Html$Attributes$stringProperty('htmlFor'); +var $elm$html$Html$Attributes$id = $elm$html$Html$Attributes$stringProperty('id'); var $elm$html$Html$label = _VirtualDom_node('label'); var $author$project$Main$maybeMaxLengthOf = function (formField) { var _v0 = formField.a; @@ -9373,6 +9374,7 @@ var $author$project$Main$requiredData = function (presence) { return true; } }; +var $elm$html$Html$span = _VirtualDom_node('span'); var $elm$json$Json$Encode$bool = _Json_wrap; var $elm$html$Html$Attributes$boolProperty = F2( function (key, bool) { @@ -9503,7 +9505,6 @@ var $author$project$Main$filterChoices = F3( return choices; } }); -var $elm$html$Html$Attributes$id = $elm$html$Html$Attributes$stringProperty('id'); var $elm$html$Html$Attributes$maxlength = function (n) { return A2( _VirtualDom_attribute, @@ -9686,7 +9687,8 @@ var $author$project$Main$viewFormFieldOptionsPreview = F3( $elm$html$Html$Attributes$name(fieldName), $elm$html$Html$Attributes$id(fieldID), $elm$html$Html$Attributes$required( - $author$project$Main$requiredData(formField.p)) + $author$project$Main$requiredData(formField.p)), + A2($elm$html$Html$Attributes$attribute, 'aria-describedby', fieldID + '-description') ]), _Utils_ap( dataListAttrs, @@ -9732,7 +9734,8 @@ var $author$project$Main$viewFormFieldOptionsPreview = F3( $elm$html$Html$Attributes$id(fieldID), $elm$html$Html$Attributes$required( $author$project$Main$requiredData(formField.p)), - $elm$html$Html$Attributes$placeholder(' ') + $elm$html$Html$Attributes$placeholder(' '), + A2($elm$html$Html$Attributes$attribute, 'aria-describedby', fieldID + '-description') ]), _Utils_ap( extraAttrs, @@ -9768,6 +9771,7 @@ var $author$project$Main$viewFormFieldOptionsPreview = F3( [ $elm$html$Html$Attributes$name(fieldName), $elm$html$Html$Attributes$id(fieldID), + A2($elm$html$Html$Attributes$attribute, 'aria-describedby', fieldID + '-description'), disabledMode ? $elm$html$Html$Attributes$class('tff-select-disabled') : $elm$html$Html$Attributes$required( $author$project$Main$requiredData(formField.p)) ]), @@ -9866,7 +9870,8 @@ var $author$project$Main$viewFormFieldOptionsPreview = F3( $elm$html$Html$Attributes$checked( _Utils_eq(valueString, choice.j) || chosenForYou(filteredChoices)), $elm$html$Html$Attributes$required( - $author$project$Main$requiredData(formField.p)) + $author$project$Main$requiredData(formField.p)), + A2($elm$html$Html$Attributes$attribute, 'aria-describedby', fieldID + '-description') ]), _Utils_ap( config.Z, @@ -10013,7 +10018,8 @@ var $author$project$Main$viewFormFieldOptionsPreview = F3( $elm$html$Html$Attributes$name(fieldName), $elm$html$Html$Attributes$value(choice.j), $elm$html$Html$Attributes$checked( - A2($elm$core$List$member, choice.j, values) || chosenForYou(filteredChoices)) + A2($elm$core$List$member, choice.j, values) || chosenForYou(filteredChoices)), + A2($elm$html$Html$Attributes$attribute, 'aria-describedby', fieldID + '-description') ]), _Utils_ap( shouldDisable ? _List_fromArray( @@ -10072,21 +10078,39 @@ var $author$project$Main$viewFormFieldPreview = F3( var _v1 = formField.a; if (_v1.$ === 4) { var minRequired = _v1.a.P; - return (!_Utils_eq(minRequired, $elm$core$Maybe$Nothing)) ? $elm$html$Html$text('') : $elm$html$Html$text(' (optional)'); + return (!_Utils_eq(minRequired, $elm$core$Maybe$Nothing)) ? $elm$html$Html$text('') : A2( + $elm$html$Html$span, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('tff-label-optional') + ]), + _List_fromArray( + [ + $elm$html$Html$text(' (optional)') + ])); } else { - return $elm$html$Html$text(' (optional)'); + return A2( + $elm$html$Html$span, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('tff-label-optional') + ]), + _List_fromArray( + [ + $elm$html$Html$text(' (optional)') + ])); } default: return $elm$html$Html$text(''); } }() ])), - A3($author$project$Main$viewFormFieldOptionsPreview, config, fieldID, formField), A2( $elm$html$Html$div, _List_fromArray( [ - $elm$html$Html$Attributes$class('tff-field-description') + $elm$html$Html$Attributes$class('tff-field-description'), + $elm$html$Html$Attributes$id(fieldID + '-description') ]), _List_fromArray( [ @@ -10114,7 +10138,8 @@ var $author$project$Main$viewFormFieldPreview = F3( return $elm$html$Html$text(''); } }() - ])) + ])), + A3($author$project$Main$viewFormFieldOptionsPreview, config, fieldID, formField) ])) ])); }); diff --git a/dist/tiny-form-fields.min.css b/dist/tiny-form-fields.min.css index ec400bd..c9e6a6f 100644 --- a/dist/tiny-form-fields.min.css +++ b/dist/tiny-form-fields.min.css @@ -1,4 +1,4 @@ -*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }/*! tailwindcss v3.4.16 | MIT License | https://tailwindcss.com*/*,:after,:before{box-sizing:border-box;border:0 solid #e5e7eb}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.float-right{float:right}.float-left{float:left}.clear-both{clear:both}.my-8{margin-top:2rem;margin-bottom:2rem}.mb-4{margin-bottom:1rem}.ml-auto{margin-left:auto}.mr-2{margin-right:.5rem}.mr-auto{margin-right:auto}.inline-block{display:inline-block}.hidden{display:none}.min-h-full{min-height:100%}.min-h-screen{min-height:100vh}.cursor-not-allowed{cursor:not-allowed}.rounded{border-radius:.25rem}.border{border-width:1px}.border-gray-300{--tw-border-opacity:1;border-color:rgb(209 213 219/var(--tw-border-opacity,1))}.bg-gray-100{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity,1))}.bg-gray-200{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity,1))}.bg-green-500{--tw-bg-opacity:1;background-color:rgb(34 197 94/var(--tw-bg-opacity,1))}.bg-red-500{--tw-bg-opacity:1;background-color:rgb(239 68 68/var(--tw-bg-opacity,1))}.bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.p-1{padding:.25rem}.px-4{padding-left:1rem;padding-right:1rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.text-right{text-align:right}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.leading-4{line-height:1rem}.text-gray-500{--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity,1))}.text-gray-800{--tw-text-opacity:1;color:rgb(31 41 55/var(--tw-text-opacity,1))}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.opacity-50{opacity:.5}.shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.tff-error h3{font-weight:700;font-size:1.125rem;line-height:1.75rem}.tff-error pre{white-space:pre-wrap}.tff-error pre,.tff-error-text{font-size:.875rem;line-height:1.25rem}.tff-error-text{margin-top:.25rem;--tw-text-opacity:1;color:rgb(220 38 38/var(--tw-text-opacity,1))}.tff-center-panel .tff-field-group,.tff-center-panel .tff-toggle-group,.tff-settings-content .tff-field-group,.tff-settings-content .tff-toggle-group{margin-bottom:1rem}.tff-center-panel .tff-field-group:last-child,.tff-center-panel .tff-toggle-group:last-child,.tff-settings-content .tff-field-group:last-child,.tff-settings-content .tff-toggle-group:last-child{margin-bottom:0}.tff-field-group{position:relative;margin-bottom:3rem}.tff-field-rule{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1));padding:.5rem;border-radius:.25rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(209 213 219/var(--tw-border-opacity,1));margin-bottom:1rem}.tff-field-rule-conditions{padding-left:1rem;margin-bottom:.5rem}.tff-toggle-group{margin-bottom:3rem}.tff-field-group input:not(:-moz-placeholder-shown):invalid,.tff-toggle-group input:not(:-moz-placeholder-shown):invalid{border-color:red}.tff-field-group input:not(:placeholder-shown):invalid,.tff-field-group.tff-required select:invalid,.tff-field-group.tff-required textarea:invalid,.tff-invalid-checkbox .tff-checkbox-group input[type=checkbox],.tff-toggle-group input:not(:placeholder-shown):invalid,.tff-toggle-group textarea:invalid{border-color:red}.tff-invalid-checkbox .tff-checkbox-group input[type=checkbox]{-moz-appearance:none;appearance:none;-webkit-appearance:none;width:1em;height:1em;border:1px solid red;border-radius:.2em;outline:none;cursor:pointer;position:relative}.tff-invalid-checkbox .tff-checkbox-group input[type=checkbox]:checked:after{content:"✓";position:absolute;color:red;font-size:1em;line-height:1;top:50%;left:50%;transform:translate(-50%,-50%)}.tff-radiobuttons-group .tff-field-label input[type=radio]:invalid{-webkit-appearance:none;height:.94em;width:.94em;box-shadow:none;border:1px solid red;border-radius:50%;outline:none}.tff-visually-hidden{position:absolute;left:-9999px;height:1px;width:1px;overflow:hidden}.tff-radiobuttons-group .tff-field-label input[type=radio]:invalid:before{content:"";display:block;width:100%;height:100%;border-radius:50%}.tff-field-label{font-size:.875rem;line-height:1.25rem;vertical-align:middle}.tff-field-description,.tff-field-label{--tw-text-opacity:1;color:rgb(75 85 99/var(--tw-text-opacity,1))}.tff-field-description{margin-top:.25rem;font-size:.75rem;line-height:1rem}.tff-text-field{display:block;border-width:1px;--tw-border-opacity:1;border-color:rgb(209 213 219/var(--tw-border-opacity,1));padding:.5rem;width:100%;border-radius:.25rem}.tff-text-field[type=color]{max-width:2.5rem;height:2.5rem;padding:.25rem}.tff-text-field[type=date],.tff-text-field[type=datetime-local],.tff-text-field[type=time]{-webkit-appearance:none;-moz-appearance:none;background-color:inherit}.tff-text-field::-webkit-date-and-time-value,.tff-text-field::-webkit-date-value,.tff-text-field::-webkit-time-value{min-height:1.5rem;text-align:inherit}.tff-field-group input[type=date]:not(:valid)::-webkit-datetime-edit-day-field,.tff-field-group input[type=date]:not(:valid)::-webkit-datetime-edit-month-field,.tff-field-group input[type=date]:not(:valid)::-webkit-datetime-edit-text,.tff-field-group input[type=date]:not(:valid)::-webkit-datetime-edit-year-field,.tff-field-group input[type=datetime-local]:not(:valid)::-webkit-datetime-edit-day-field,.tff-field-group input[type=datetime-local]:not(:valid)::-webkit-datetime-edit-hour-field,.tff-field-group input[type=datetime-local]:not(:valid)::-webkit-datetime-edit-minute-field,.tff-field-group input[type=datetime-local]:not(:valid)::-webkit-datetime-edit-month-field,.tff-field-group input[type=datetime-local]:not(:valid)::-webkit-datetime-edit-text,.tff-field-group input[type=datetime-local]:not(:valid)::-webkit-datetime-edit-year-field,.tff-field-group input[type=time]:not(:valid)::-webkit-datetime-edit-ampm-field,.tff-field-group input[type=time]:not(:valid)::-webkit-datetime-edit-hour-field,.tff-field-group input[type=time]:not(:valid)::-webkit-datetime-edit-minute-field,.tff-field-group input[type=time]:not(:valid)::-webkit-datetime-edit-second-field,.tff-field-group input[type=time]:not(:valid)::-webkit-datetime-edit-text{color:#f87171;opacity:.7}.tff-field-group +*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }/*! tailwindcss v3.4.16 | MIT License | https://tailwindcss.com*/*,:after,:before{box-sizing:border-box;border:0 solid #e5e7eb}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.float-right{float:right}.float-left{float:left}.clear-both{clear:both}.my-8{margin-top:2rem;margin-bottom:2rem}.mb-4{margin-bottom:1rem}.ml-auto{margin-left:auto}.mr-2{margin-right:.5rem}.mr-auto{margin-right:auto}.inline-block{display:inline-block}.hidden{display:none}.min-h-full{min-height:100%}.min-h-screen{min-height:100vh}.cursor-not-allowed{cursor:not-allowed}.rounded{border-radius:.25rem}.border{border-width:1px}.border-gray-300{--tw-border-opacity:1;border-color:rgb(209 213 219/var(--tw-border-opacity,1))}.bg-gray-100{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity,1))}.bg-gray-200{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity,1))}.bg-green-500{--tw-bg-opacity:1;background-color:rgb(34 197 94/var(--tw-bg-opacity,1))}.bg-red-500{--tw-bg-opacity:1;background-color:rgb(239 68 68/var(--tw-bg-opacity,1))}.bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.p-1{padding:.25rem}.px-4{padding-left:1rem;padding-right:1rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.text-right{text-align:right}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.leading-4{line-height:1rem}.text-gray-500{--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity,1))}.text-gray-800{--tw-text-opacity:1;color:rgb(31 41 55/var(--tw-text-opacity,1))}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.opacity-50{opacity:.5}.shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.tff-error h3{font-weight:700;font-size:1.125rem;line-height:1.75rem}.tff-error pre{white-space:pre-wrap}.tff-error pre,.tff-error-text{font-size:.875rem;line-height:1.25rem}.tff-error-text{margin-top:.25rem;--tw-text-opacity:1;color:rgb(220 38 38/var(--tw-text-opacity,1))}.tff-center-panel .tff-field-group,.tff-center-panel .tff-toggle-group,.tff-settings-content .tff-field-group,.tff-settings-content .tff-toggle-group{margin-bottom:1rem}.tff-center-panel .tff-field-group:last-child,.tff-center-panel .tff-toggle-group:last-child,.tff-settings-content .tff-field-group:last-child,.tff-settings-content .tff-toggle-group:last-child{margin-bottom:0}.tff-field-group{position:relative;margin-bottom:3rem}.tff-field-rule{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1));padding:.5rem;border-radius:.25rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(209 213 219/var(--tw-border-opacity,1));margin-bottom:1rem}.tff-field-rule-conditions{padding-left:1rem;margin-bottom:.5rem}.tff-toggle-group{margin-bottom:3rem}.tff-field-group input:not(:-moz-placeholder-shown):invalid,.tff-toggle-group input:not(:-moz-placeholder-shown):invalid{border-color:red}.tff-field-group input:not(:placeholder-shown):invalid,.tff-field-group.tff-required select:invalid,.tff-field-group.tff-required textarea:invalid,.tff-invalid-checkbox .tff-checkbox-group input[type=checkbox],.tff-toggle-group input:not(:placeholder-shown):invalid,.tff-toggle-group textarea:invalid{border-color:red}.tff-invalid-checkbox .tff-checkbox-group input[type=checkbox]{-moz-appearance:none;appearance:none;-webkit-appearance:none;width:1em;height:1em;border:1px solid red;border-radius:.2em;outline:none;cursor:pointer;position:relative}.tff-invalid-checkbox .tff-checkbox-group input[type=checkbox]:checked:after{content:"✓";position:absolute;color:red;font-size:1em;line-height:1;top:50%;left:50%;transform:translate(-50%,-50%)}.tff-radiobuttons-group .tff-field-label input[type=radio]:invalid{-webkit-appearance:none;height:.94em;width:.94em;box-shadow:none;border:1px solid red;border-radius:50%;outline:none}.tff-visually-hidden{position:absolute;left:-9999px;height:1px;width:1px;overflow:hidden}.tff-radiobuttons-group .tff-field-label input[type=radio]:invalid:before{content:"";display:block;width:100%;height:100%;border-radius:50%}.tff-field-label{font-size:.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(75 85 99/var(--tw-text-opacity,1));vertical-align:middle}.tff-field-group>label.tff-field-label{font-weight:600;font-size:1rem;line-height:1.5rem;--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity,1))}.tff-label-optional{font-weight:400}.tff-field-description,.tff-label-optional{--tw-text-opacity:1;color:rgb(55 65 81/var(--tw-text-opacity,1))}.tff-field-description{margin-top:.25rem;margin-bottom:.5rem;font-size:.875rem;line-height:1.25rem}.tff-text-field{display:block;border-width:1px;--tw-border-opacity:1;border-color:rgb(209 213 219/var(--tw-border-opacity,1));padding:.5rem;width:100%;border-radius:.25rem}.tff-text-field[type=color]{max-width:2.5rem;height:2.5rem;padding:.25rem}.tff-text-field[type=date],.tff-text-field[type=datetime-local],.tff-text-field[type=time]{-webkit-appearance:none;-moz-appearance:none;background-color:inherit}.tff-text-field::-webkit-date-and-time-value,.tff-text-field::-webkit-date-value,.tff-text-field::-webkit-time-value{min-height:1.5rem;text-align:inherit}.tff-field-group input[type=date]:not(:valid)::-webkit-datetime-edit-day-field,.tff-field-group input[type=date]:not(:valid)::-webkit-datetime-edit-month-field,.tff-field-group input[type=date]:not(:valid)::-webkit-datetime-edit-text,.tff-field-group input[type=date]:not(:valid)::-webkit-datetime-edit-year-field,.tff-field-group input[type=datetime-local]:not(:valid)::-webkit-datetime-edit-day-field,.tff-field-group input[type=datetime-local]:not(:valid)::-webkit-datetime-edit-hour-field,.tff-field-group input[type=datetime-local]:not(:valid)::-webkit-datetime-edit-minute-field,.tff-field-group input[type=datetime-local]:not(:valid)::-webkit-datetime-edit-month-field,.tff-field-group input[type=datetime-local]:not(:valid)::-webkit-datetime-edit-text,.tff-field-group input[type=datetime-local]:not(:valid)::-webkit-datetime-edit-year-field,.tff-field-group input[type=time]:not(:valid)::-webkit-datetime-edit-ampm-field,.tff-field-group input[type=time]:not(:valid)::-webkit-datetime-edit-hour-field,.tff-field-group input[type=time]:not(:valid)::-webkit-datetime-edit-minute-field,.tff-field-group input[type=time]:not(:valid)::-webkit-datetime-edit-second-field,.tff-field-group input[type=time]:not(:valid)::-webkit-datetime-edit-text{color:#f87171;opacity:.7}.tff-field-group input[type=datetime-local].tff-empty-optional::-webkit-datetime-edit-minute-field,.tff-field-group input[type=date].tff-empty-optional::-webkit-datetime-edit-day-field,.tff-field-group input[type=date].tff-empty-optional::-webkit-datetime-edit-month-field,.tff-field-group input[type=date].tff-empty-optional::-webkit-datetime-edit-text,.tff-field-group input[type=date].tff-empty-optional::-webkit-datetime-edit-year-field,.tff-field-group input[type=datetime-local].tff-empty-optional::-webkit-datetime-edit-day-field,.tff-field-group input[type=datetime-local].tff-empty-optional::-webkit-datetime-edit-hour-field,.tff-field-group input[type=datetime-local].tff-empty-optional::-webkit-datetime-edit-month-field,.tff-field-group input[type=datetime-local].tff-empty-optional::-webkit-datetime-edit-text,.tff-field-group input[type=datetime-local].tff-empty-optional::-webkit-datetime-edit-year-field,.tff-field-group input[type=time].tff-empty-optional::-webkit-datetime-edit-ampm-field,.tff-field-group input[type=time].tff-empty-optional::-webkit-datetime-edit-hour-field,.tff-field-group input[type=time].tff-empty-optional::-webkit-datetime-edit-minute-field,.tff-field-group input[type=time].tff-empty-optional::-webkit-datetime-edit-second-field,.tff-field-group input[type=time].tff-empty-optional::-webkit-datetime-edit-text{color:#f87171;opacity:.7}.tff-field-group input[type=date]:not(:valid),.tff-field-group input[type=datetime-local]:not(:valid),.tff-field-group input[type=time]:not(:valid){color:#f87171!important;opacity:.7!important}.tff-field-group input[type=date].tff-empty-optional,.tff-field-group input[type=datetime-local].tff-empty-optional,.tff-field-group input[type=time].tff-empty-optional{color:#f87171!important;opacity:.7!important}.tff-editor-layout .tff-center-panel input[type=date].tff-empty-optional::-webkit-datetime-edit-day-field,.tff-editor-layout diff --git a/input.css b/input.css index 945fad5..b554272 100644 --- a/input.css +++ b/input.css @@ -121,10 +121,22 @@ @apply align-middle; } +.tff-field-group > label.tff-field-label { + @apply font-semibold; + @apply text-base; + @apply text-gray-900; +} + +.tff-label-optional { + @apply text-gray-700; + @apply font-normal; +} + .tff-field-description { @apply mt-1; - @apply text-xs; - @apply text-gray-600; + @apply mb-2; + @apply text-sm; + @apply text-gray-700; } .tff-text-field { diff --git a/src/Main.elm b/src/Main.elm index a7c8971..5088558 100644 --- a/src/Main.elm +++ b/src/Main.elm @@ -50,7 +50,7 @@ port module Main exposing import Array exposing (Array) import Browser import Dict exposing (Dict) -import Html exposing (Html, button, div, h2, h3, input, label, option, pre, select, text, ul) +import Html exposing (Html, button, div, h2, h3, input, label, option, pre, select, span, text, ul) import Html.Attributes as Attr exposing (attribute, checked, class, classList, for, id, maxlength, minlength, name, pattern, placeholder, readonly, required, selected, tabindex, title, type_, value) import Html.Events exposing (on, onCheck, onClick, onInput, preventDefaultOn, stopPropagationOn) import Json.Decode @@ -1902,16 +1902,15 @@ viewFormFieldPreview config index formField = text "" else - text " (optional)" + span [ class "tff-label-optional" ] [ text " (optional)" ] _ -> - text " (optional)" + span [ class "tff-label-optional" ] [ text " (optional)" ] System -> text "" ] - , viewFormFieldOptionsPreview config fieldID formField - , div [ class "tff-field-description" ] + , div [ class "tff-field-description", id (fieldID ++ "-description") ] [ text (case formField.description of AttributeNotNeeded _ -> @@ -1930,6 +1929,7 @@ viewFormFieldPreview config index formField = Nothing -> text "" ] + , viewFormFieldOptionsPreview config fieldID formField ] ] @@ -2112,6 +2112,7 @@ viewFormFieldOptionsPreview config fieldID formField = , name fieldName , id fieldID , required (requiredData formField.presence) + , attribute "aria-describedby" (fieldID ++ "-description") ] ++ dataListAttrs ++ shortTextAttrs @@ -2137,6 +2138,7 @@ viewFormFieldOptionsPreview config fieldID formField = , id fieldID , required (requiredData formField.presence) , placeholder " " + , attribute "aria-describedby" (fieldID ++ "-description") ] ++ extraAttrs ++ config.customAttrs @@ -2175,6 +2177,7 @@ viewFormFieldOptionsPreview config fieldID formField = , select ([ name fieldName , id fieldID + , attribute "aria-describedby" (fieldID ++ "-description") -- when we're disabling `