From ba4c8472cb288d42d719cf2e457ca1542e22ab82 Mon Sep 17 00:00:00 2001 From: Adriano Caloiaro Date: Tue, 11 Mar 2025 15:54:06 -0600 Subject: [PATCH] fix: actually support 'data type' form field property --- | 0 handlers/builder.go | 27 +- static/css/styles.css | 286 ++++++++++-- types/formfielddatatype_enumer.go | 20 +- types/types.go | 11 +- ui/builder/builder.templ | 147 +++--- ui/builder/builder_templ.go | 569 ++++++++--------------- ui/builder/builder_templ.txt | 108 ----- ui/collector/collector_templ.txt | 24 - ui/common.templ | 144 ++++++ ui/common_templ.go | 721 +++++++++++++++++++++++++----- ui/common_templ.txt | 36 -- ui/css/tailwind.css | 4 + ui/errors_templ.txt | 3 - ui/fields/fields.templ | 27 +- ui/fields/fields_templ.go | 289 ++++++------ ui/fields/fields_templ.txt | 47 -- ui/fields/single_choice_templ.txt | 28 -- ui/selector/selector_templ.txt | 25 -- ui/trigger_rebuild_templ.txt | 1 - 20 files changed, 1472 insertions(+), 1045 deletions(-) delete mode 100644 delete mode 100644 ui/builder/builder_templ.txt delete mode 100644 ui/collector/collector_templ.txt delete mode 100644 ui/common_templ.txt delete mode 100644 ui/errors_templ.txt delete mode 100644 ui/fields/fields_templ.txt delete mode 100644 ui/fields/single_choice_templ.txt delete mode 100644 ui/selector/selector_templ.txt delete mode 100644 ui/trigger_rebuild_templ.txt diff --git a/ b/ deleted file mode 100644 index e69de29..0000000 diff --git a/handlers/builder.go b/handlers/builder.go index cc5e7f7..6653c00 100644 --- a/handlers/builder.go +++ b/handlers/builder.go @@ -432,22 +432,17 @@ func UpdateFields(w http.ResponseWriter, r *http.Request) { // The PUT /fields endpoint is only called after a field exists. Thus, it is appropriate to use the 'order' // and 'type' of the draft's field when updating, since PUT /fields does not affect order or type field = &types.FormField{ - ID: id, - Order: draft.Fields[fieldID].Order, - Type: draft.Fields[fieldID].Type, - Logic: &types.FieldLogic{}, + ID: id, + Order: draft.Fields[fieldID].Order, + Type: draft.Fields[fieldID].Type, + DataType: draft.Fields[fieldID].DataType, + Logic: &types.FieldLogic{}, } newFields[fieldID] = field } // parse specific field update requests and update the corresponding field accordingly switch { - case fieldName == "required": - required := (len(fieldValues) > 1 && fieldValues[1] == "on") || (len(fieldValues) > 0 && fieldValues[0] == "on") - field.Required = required - case fieldName == "hidden": - hidden := (len(fieldValues) > 1 && fieldValues[1] == "on") || (len(fieldValues) > 0 && fieldValues[0] == "on") - field.Hidden = hidden case fieldName == "label": field.Label = fieldValues[0] case fieldName == "placeholder": @@ -461,7 +456,19 @@ func UpdateFields(w http.ResponseWriter, r *http.Request) { if err != nil { field.OptionOrder = types.OptionOrderNatural } + case fieldName == "data_type": + dt, err := types.FormFieldDataTypeString(fieldValues[0]) + if err != nil { + dt = types.FormFieldDataTypeText + } + field.DataType = dt // field logic, target field chosen + case fieldGroup == builder.FieldGroupSettings && fieldName == "required": + required := (len(fieldValues) > 1 && fieldValues[1] == "on") || (len(fieldValues) > 0 && fieldValues[0] == "on") + field.Required = required + case fieldGroup == builder.FieldGroupSettings && fieldName == "hidden": + hidden := (len(fieldValues) > 1 && fieldValues[1] == "on") || (len(fieldValues) > 0 && fieldValues[0] == "on") + field.Hidden = hidden case fieldGroup == builder.FieldGroupLogic && fieldName == builder.FieldLogicTargetFieldID: targetFieldID, err := uuid.Parse(fieldValues[0]) if err != nil { diff --git a/static/css/styles.css b/static/css/styles.css index e23b148..73d522f 100644 --- a/static/css/styles.css +++ b/static/css/styles.css @@ -1051,12 +1051,34 @@ html { justify-content: center; } -@media (hover:hover) { - .checkbox-primary:hover { - --tw-border-opacity: 1; - border-color: var(--fallback-p,oklch(var(--p)/var(--tw-border-opacity))); - } +.badge { + display: inline-flex; + align-items: center; + justify-content: center; + transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, -webkit-backdrop-filter; + transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter; + transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter, -webkit-backdrop-filter; + transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); + transition-timing-function: cubic-bezier(0, 0, 0.2, 1); + transition-duration: 200ms; + height: 1.25rem; + font-size: 0.875rem; + line-height: 1.25rem; + width: -moz-fit-content; + width: fit-content; + padding-left: 0.563rem; + padding-right: 0.563rem; + border-radius: var(--rounded-badge, 1.9rem); + border-width: 1px; + --tw-border-opacity: 1; + border-color: var(--fallback-b2,oklch(var(--b2)/var(--tw-border-opacity))); + --tw-bg-opacity: 1; + background-color: var(--fallback-b1,oklch(var(--b1)/var(--tw-bg-opacity))); + --tw-text-opacity: 1; + color: var(--fallback-bc,oklch(var(--bc)/var(--tw-text-opacity))); +} +@media (hover:hover) { .label a:hover { --tw-text-opacity: 1; color: var(--fallback-bc,oklch(var(--bc)/var(--tw-text-opacity))); @@ -1423,6 +1445,10 @@ html { color: var(--fallback-bc,oklch(var(--bc)/0.3)); } +:where(.menu li) .badge { + justify-self: end; +} + .mockup-browser { position: relative; overflow: hidden; @@ -1609,6 +1635,19 @@ input.tab:checked + .tab-content, var(--togglehandleborder); } +.badge-info { + border-color: transparent; + --tw-bg-opacity: 1; + background-color: var(--fallback-in,oklch(var(--in)/var(--tw-bg-opacity))); + --tw-text-opacity: 1; + color: var(--fallback-inc,oklch(var(--inc)/var(--tw-text-opacity))); +} + +.badge-outline.badge-info { + --tw-text-opacity: 1; + color: var(--fallback-in,oklch(var(--in)/var(--tw-text-opacity))); +} + .btm-nav > *.disabled, .btm-nav > *[disabled] { pointer-events: none; @@ -1747,27 +1786,6 @@ input.tab:checked + .tab-content, linear-gradient(0deg, var(--chkbg) 43%, var(--chkfg) 43%, var(--chkfg) 57%, var(--chkbg) 57%); } -.checkbox-primary { - --chkbg: var(--fallback-p,oklch(var(--p)/1)); - --chkfg: var(--fallback-pc,oklch(var(--pc)/1)); - --tw-border-opacity: 1; - border-color: var(--fallback-p,oklch(var(--p)/var(--tw-border-opacity))); -} - -.checkbox-primary:focus-visible { - outline-color: var(--fallback-p,oklch(var(--p)/1)); -} - -.checkbox-primary:checked, - .checkbox-primary[aria-checked="true"] { - --tw-border-opacity: 1; - border-color: var(--fallback-p,oklch(var(--p)/var(--tw-border-opacity))); - --tw-bg-opacity: 1; - background-color: var(--fallback-p,oklch(var(--p)/var(--tw-bg-opacity))); - --tw-text-opacity: 1; - color: var(--fallback-pc,oklch(var(--pc)/var(--tw-text-opacity))); -} - @keyframes checkmark { 0% { background-position-y: 5px; @@ -1805,6 +1823,10 @@ input.tab:checked + .tab-content, line-height: 1em; } +.input-bordered { + border-color: var(--fallback-bc,oklch(var(--bc)/0.2)); +} + .input:focus, .input:focus-within { box-shadow: none; @@ -2560,6 +2582,36 @@ input.tab:checked + .tab-content, --tab-padding: 0.5rem; } +.tooltip { + position: relative; + display: inline-block; + --tooltip-offset: calc(100% + 1px + var(--tooltip-tail, 0px)); +} + +.tooltip:before { + position: absolute; + pointer-events: none; + z-index: 1; + content: var(--tw-content); + --tw-content: attr(data-tip); +} + +.tooltip:before, .tooltip-top:before { + transform: translateX(-50%); + top: auto; + left: 50%; + right: auto; + bottom: var(--tooltip-offset); +} + +.tooltip-left:before { + transform: translateY(-50%); + top: 50%; + left: auto; + right: var(--tooltip-offset); + bottom: auto; +} + .join.join-vertical > :where(*:not(:first-child)) { margin-left: 0px; margin-right: 0px; @@ -2581,6 +2633,103 @@ input.tab:checked + .tab-content, margin-top: 0px; } +.tooltip { + position: relative; + display: inline-block; + text-align: center; + --tooltip-tail: 0.1875rem; + --tooltip-color: var(--fallback-n,oklch(var(--n)/1)); + --tooltip-text-color: var(--fallback-nc,oklch(var(--nc)/1)); + --tooltip-tail-offset: calc(100% + 0.0625rem - var(--tooltip-tail)); +} + +.tooltip:before, +.tooltip:after { + opacity: 0; + transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, -webkit-backdrop-filter; + transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter; + transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter, -webkit-backdrop-filter; + transition-delay: 100ms; + transition-duration: 200ms; + transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); +} + +.tooltip:after { + position: absolute; + content: ""; + border-style: solid; + border-width: var(--tooltip-tail, 0); + width: 0; + height: 0; + display: block; +} + +.tooltip:before { + max-width: 20rem; + white-space: normal; + border-radius: 0.25rem; + padding-left: 0.5rem; + padding-right: 0.5rem; + padding-top: 0.25rem; + padding-bottom: 0.25rem; + font-size: 0.875rem; + line-height: 1.25rem; + background-color: var(--tooltip-color); + color: var(--tooltip-text-color); + width: -moz-max-content; + width: max-content; +} + +.tooltip.tooltip-open:before { + opacity: 1; + transition-delay: 75ms; +} + +.tooltip.tooltip-open:after { + opacity: 1; + transition-delay: 75ms; +} + +.tooltip:hover:before { + opacity: 1; + transition-delay: 75ms; +} + +.tooltip:hover:after { + opacity: 1; + transition-delay: 75ms; +} + +.tooltip:has(:focus-visible):after, +.tooltip:has(:focus-visible):before { + opacity: 1; + transition-delay: 75ms; +} + +.tooltip:not([data-tip]):hover:before, +.tooltip:not([data-tip]):hover:after { + visibility: hidden; + opacity: 0; +} + +.tooltip:after, .tooltip-top:after { + transform: translateX(-50%); + border-color: var(--tooltip-color) transparent transparent transparent; + top: auto; + left: 50%; + right: auto; + bottom: var(--tooltip-tail-offset); +} + +.tooltip-left:after { + transform: translateY(-50%); + border-color: transparent transparent transparent var(--tooltip-color); + top: 50%; + left: auto; + right: calc(var(--tooltip-tail-offset) + 0.0625rem); + bottom: auto; +} + .invisible { visibility: hidden; } @@ -2601,6 +2750,11 @@ input.tab:checked + .tab-content, z-index: 50; } +.mx-3 { + margin-left: 0.75rem; + margin-right: 0.75rem; +} + .mx-auto { margin-left: auto; margin-right: auto; @@ -2611,6 +2765,11 @@ input.tab:checked + .tab-content, margin-bottom: 0.375rem; } +.my-4 { + margin-top: 1rem; + margin-bottom: 1rem; +} + .-mt-0\.5 { margin-top: -0.125rem; } @@ -2635,6 +2794,10 @@ input.tab:checked + .tab-content, display: block; } +.inline-block { + display: inline-block; +} + .inline { display: inline; } @@ -2693,6 +2856,11 @@ input.tab:checked + .tab-content, height: auto; } +.h-fit { + height: -moz-fit-content; + height: fit-content; +} + .h-full { height: 100%; } @@ -2879,6 +3047,10 @@ input.tab:checked + .tab-content, border-radius: 0.25rem; } +.rounded-box { + border-radius: var(--rounded-box, 1rem); +} + .rounded-full { border-radius: 9999px; } @@ -2895,10 +3067,30 @@ input.tab:checked + .tab-content, border-radius: 0.75rem; } +.rounded-bl-lg { + border-bottom-left-radius: 0.5rem; +} + +.rounded-br-lg { + border-bottom-right-radius: 0.5rem; +} + +.rounded-tl-lg { + border-top-left-radius: 0.5rem; +} + +.rounded-tr-lg { + border-top-right-radius: 0.5rem; +} + .border { border-width: 1px; } +.border-0 { + border-width: 0px; +} + .border-y-0 { border-top-width: 0px; border-bottom-width: 0px; @@ -2932,6 +3124,11 @@ input.tab:checked + .tab-content, border-color: rgb(255 119 119 / var(--tw-border-opacity, 1)); } +.bg-base-100 { + --tw-bg-opacity: 1; + background-color: var(--fallback-b1,oklch(var(--b1)/var(--tw-bg-opacity, 1))); +} + .bg-base-200 { --tw-bg-opacity: 1; background-color: var(--fallback-b2,oklch(var(--b2)/var(--tw-bg-opacity, 1))); @@ -2952,11 +3149,21 @@ input.tab:checked + .tab-content, background-color: rgb(246 246 246 / var(--tw-bg-opacity, 1)); } +.bg-primary-100 { + --tw-bg-opacity: 1; + background-color: rgb(206 241 255 / var(--tw-bg-opacity, 1)); +} + .bg-primary-500 { --tw-bg-opacity: 1; background-color: rgb(0 159 255 / var(--tw-bg-opacity, 1)); } +.bg-red-500 { + --tw-bg-opacity: 1; + background-color: rgb(255 119 119 / var(--tw-bg-opacity, 1)); +} + .bg-sky-100 { --tw-bg-opacity: 1; background-color: rgb(224 242 254 / var(--tw-bg-opacity, 1)); @@ -2972,6 +3179,11 @@ input.tab:checked + .tab-content, background-color: rgb(240 249 255 / var(--tw-bg-opacity, 1)); } +.bg-slate-100 { + --tw-bg-opacity: 1; + background-color: rgb(241 245 249 / var(--tw-bg-opacity, 1)); +} + .bg-white { --tw-bg-opacity: 1; background-color: rgb(255 255 255 / var(--tw-bg-opacity, 1)); @@ -2997,6 +3209,11 @@ input.tab:checked + .tab-content, padding: 1.5rem; } +.px-0 { + padding-left: 0px; + padding-right: 0px; +} + .px-1 { padding-left: 0.25rem; padding-right: 0.25rem; @@ -3073,6 +3290,10 @@ input.tab:checked + .tab-content, padding-bottom: 1.25rem; } +.pl-3 { + padding-left: 0.75rem; +} + .pr-1 { padding-right: 0.25rem; } @@ -3197,6 +3418,11 @@ input.tab:checked + .tab-content, color: rgb(51 65 85 / var(--tw-text-opacity, 1)); } +.text-success { + --tw-text-opacity: 1; + color: var(--fallback-su,oklch(var(--su)/var(--tw-text-opacity, 1))); +} + .text-white { --tw-text-opacity: 1; color: rgb(255 255 255 / var(--tw-text-opacity, 1)); @@ -3279,6 +3505,10 @@ https://github.com/Choices-js/Choices/issues/449 bottom: 0; } +.choices { + margin-bottom: 0px !important; +} + .first\:border-x-0:first-child { border-left-width: 0px; border-right-width: 0px; @@ -3383,6 +3613,10 @@ https://github.com/Choices-js/Choices/issues/449 opacity: 0.75; } +.group.label-group .group-\[\.label-group\]\:min-w-48 { + min-width: 12rem; +} + .peer:checked ~ .peer-checked\:visible { visibility: visible; } diff --git a/types/formfielddatatype_enumer.go b/types/formfielddatatype_enumer.go index ebed790..fc7d655 100644 --- a/types/formfielddatatype_enumer.go +++ b/types/formfielddatatype_enumer.go @@ -8,11 +8,11 @@ import ( "strings" ) -const _FormFieldDataTypeName = "textnumeric" +const _FormFieldDataTypeName = "textnumericrating" -var _FormFieldDataTypeIndex = [...]uint8{0, 4, 11} +var _FormFieldDataTypeIndex = [...]uint8{0, 4, 11, 17} -const _FormFieldDataTypeLowerName = "textnumeric" +const _FormFieldDataTypeLowerName = "textnumericrating" func (i FormFieldDataType) String() string { if i < 0 || i >= FormFieldDataType(len(_FormFieldDataTypeIndex)-1) { @@ -27,20 +27,24 @@ func _FormFieldDataTypeNoOp() { var x [1]struct{} _ = x[FormFieldDataTypeText-(0)] _ = x[FormFieldDataTypeNumeric-(1)] + _ = x[FormFieldDataTypeRating-(2)] } -var _FormFieldDataTypeValues = []FormFieldDataType{FormFieldDataTypeText, FormFieldDataTypeNumeric} +var _FormFieldDataTypeValues = []FormFieldDataType{FormFieldDataTypeText, FormFieldDataTypeNumeric, FormFieldDataTypeRating} var _FormFieldDataTypeNameToValueMap = map[string]FormFieldDataType{ - _FormFieldDataTypeName[0:4]: FormFieldDataTypeText, - _FormFieldDataTypeLowerName[0:4]: FormFieldDataTypeText, - _FormFieldDataTypeName[4:11]: FormFieldDataTypeNumeric, - _FormFieldDataTypeLowerName[4:11]: FormFieldDataTypeNumeric, + _FormFieldDataTypeName[0:4]: FormFieldDataTypeText, + _FormFieldDataTypeLowerName[0:4]: FormFieldDataTypeText, + _FormFieldDataTypeName[4:11]: FormFieldDataTypeNumeric, + _FormFieldDataTypeLowerName[4:11]: FormFieldDataTypeNumeric, + _FormFieldDataTypeName[11:17]: FormFieldDataTypeRating, + _FormFieldDataTypeLowerName[11:17]: FormFieldDataTypeRating, } var _FormFieldDataTypeNames = []string{ _FormFieldDataTypeName[0:4], _FormFieldDataTypeName[4:11], + _FormFieldDataTypeName[11:17], } // FormFieldDataTypeString retrieves an enum value from the enum constants string name. diff --git a/types/types.go b/types/types.go index df6fa28..de13359 100644 --- a/types/types.go +++ b/types/types.go @@ -37,14 +37,21 @@ const ( // FormFieldDataType enum enumerates all possible data types for form fields // +// This type informs how form field submissions may be used by 'frm' users. +// //go:generate enumer -type FormFieldDataType -trimprefix FormFieldDataType -transform=snake -json type FormFieldDataType int const ( FormFieldDataTypeText FormFieldDataType = iota // textual data FormFieldDataTypeNumeric // numeric data + FormFieldDataTypeRating // chosen values represent a 'rating' ) +func FormFieldDataTypes() []FormFieldDataType { + return []FormFieldDataType{FormFieldDataTypeText, FormFieldDataTypeNumeric, FormFieldDataTypeRating} +} + // FieldLogicComparator enum enumerates all possible form field logic comparators // //go:generate enumer -type FieldLogicComparator -trimprefix FieldLogicComparator -transform=snake -json -text @@ -102,7 +109,7 @@ type FormField struct { Required bool `json:"required"` // whether the field is required Hidden bool `json:"hidden"` // whether the field is hidden Type FormFieldType `json:"type"` // field type - DataType FormFieldDataType `json:"data_type"` // the data type for form submissions to this field + DataType FormFieldDataType `json:"data_type"` // the data type form submissions to this field } // FormFieldSubmission is a form submission for a particular form field. Form submissions consists of one or more form field submission @@ -225,6 +232,7 @@ func (f FormField) MarshalJSON() ([]byte, error) { Required bool `json:"required"` // whether the field is required Hidden bool `json:"hidden"` // whether the field is hidden Type FormFieldType `json:"type"` // field type + DataType FormFieldDataType `json:"data_type"` // field's data type }{ ID: id, @@ -238,6 +246,7 @@ func (f FormField) MarshalJSON() ([]byte, error) { Hidden: f.Hidden, Type: f.Type, Logic: logic, + DataType: f.DataType, } return json.Marshal(d) diff --git a/ui/builder/builder.templ b/ui/builder/builder.templ index 001df87..29cbb1d 100644 --- a/ui/builder/builder.templ +++ b/ui/builder/builder.templ @@ -42,7 +42,8 @@ const ( // Field groups within the the form field configuration screen const ( - FieldGroupLogic = "logic" + FieldGroupLogic = "logic" + FieldGroupSettings = "settings" ) // Builder is the primary form builder UI, surrounded by the app chrome @@ -280,43 +281,32 @@ templ fieldSettingsConfiguration(form frm.Form, field types.FormField) { -
- - @fields.RequiredFieldIndicator() -
- -
- - -
+ @ui.LabeledTextInput(ui.LabeledTextInputArgs{ + ID: fields.FieldName(field, "", "label"), + Name: fields.FieldName(field, "", "label"), + Label: "Field label", + LabelClass: "my-4 text-lg", + Placeholder: "Write some text", + Value: field.Label, + Required: true, + Hyperscript: fmt.Sprintf("on keyup debounced at 600ms trigger '%s'", FieldsFormUpdateEvent), + }) + if field.Type != types.FormFieldTypeSingleChoice && field.Type != types.FormFieldTypeSingleChoiceSpaced { + @ui.LabeledTextInput(ui.LabeledTextInputArgs{ + ID: fields.FieldName(field, "", "placeholder"), + Name: fields.FieldName(field, "", "placeholder"), + Label: "Placeholder", + LabelClass: "my-4 text-lg", + Placeholder: "Choose a placeholder", + Value: field.Placeholder, + Hyperscript: fmt.Sprintf("on keyup debounced at 600ms trigger '%s'", FieldsFormUpdateEvent), + }) + } switch field.Type { case types.FormFieldTypeMultiSelect, types.FormFieldTypeSingleSelect, types.FormFieldTypeSingleChoice, types.FormFieldTypeSingleChoiceSpaced: -
- -
- @selector.Selector(selector.SelectArgs{ + @ui.LabeledSelector(ui.LabeledSelectorArgs{ + Label: "Options", + LabelClass: "my-4 text-lg", ID: fields.FieldName(field, "", "options"), Name: fields.FieldName(field, "", "options"), Placeholder: "Add, remove, or create new options", @@ -325,13 +315,19 @@ templ fieldSettingsConfiguration(form frm.Form, field types.FormField) { Options: fields.ToSelectorOpts(field.Options, true), SelectionChangeEvent: FieldsFormUpdateEvent, }) + @ui.LabeledSelector(ui.LabeledSelectorArgs{ + Label: "Data type", + LabelClass: "my-4 text-lg", + ID: fields.FieldName(field, "settings", "data_type"), + Name: fields.FieldName(field, "settings", "data_type"), + Placeholder: "Choose the data type", + Options: fields.FormFieldDataTypeOptions(field), + SelectionChangeEvent: FieldsFormUpdateEvent, + }) if field.Type == types.FormFieldTypeSingleChoice { -
- -
- @selector.Selector(selector.SelectArgs{ + @ui.LabeledSelector(ui.LabeledSelectorArgs{ + Label: "Option labels", + LabelClass: "my-4 text-lg", ID: fields.FieldName(field, "", "option_labels"), Name: fields.FieldName(field, "", "option_labels"), Placeholder: "Create labels for your options", @@ -341,12 +337,9 @@ templ fieldSettingsConfiguration(form frm.Form, field types.FormField) { SelectionChangeEvent: FieldsFormUpdateEvent, }) } -
- -
- @selector.Selector(selector.SelectArgs{ + @ui.LabeledSelector(ui.LabeledSelectorArgs{ + Label: "Order", + LabelClass: "my-4 text-lg", ID: fields.FieldName(field, "", "option_ordering"), Name: fields.FieldName(field, "", "option_ordering"), Placeholder: "Choose option ordering", @@ -356,54 +349,40 @@ templ fieldSettingsConfiguration(form frm.Form, field types.FormField) { SelectionChangeEvent: FieldsFormUpdateEvent, }) } -
- -
- 's checked to false end - then trigger '%s'`, - fields.FieldName(field, "","hidden"), FieldsFormUpdateEvent) } - /> -
- -
- 's checked to false end - then trigger '%s'`, - fields.FieldName(field, "","required"), FieldsFormUpdateEvent) } - /> -
+ then trigger '%s'`, + fields.FieldName(field, "settings", "required"), FieldsFormUpdateEvent), + }) + } +
- @ui.Button(ui.ButtonArgs{Type: "button", Label: "Delete field"}, templ.Attributes{ + @ui.Button(ui.ButtonArgs{Type: "button", Label: "Delete field", Classes: []string{"bg-red-500"}}, templ.Attributes{ "data-hx-delete": ui.FormUrl[string](ctx, form, fmt.Sprintf("/fields/%s", field.ID)), "data-hx-trigger": "click", "data-hx-confirm": "Are you sure?", diff --git a/ui/builder/builder_templ.go b/ui/builder/builder_templ.go index 1d04119..0b82a6d 100644 --- a/ui/builder/builder_templ.go +++ b/ui/builder/builder_templ.go @@ -50,7 +50,8 @@ const ( // Field groups within the the form field configuration screen const ( - FieldGroupLogic = "logic" + FieldGroupLogic = "logic" + FieldGroupSettings = "settings" ) // Builder is the primary form builder UI, surrounded by the app chrome @@ -162,7 +163,7 @@ func FormBuilderNavTitle(form frm.Form) templ.Component { var templ_7745c5c3_Var4 string templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(form.Name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 69, Col: 14} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 70, Col: 14} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) if templ_7745c5c3_Err != nil { @@ -233,7 +234,7 @@ func FormBuilderNav(form frm.Form) templ.Component { var templ_7745c5c3_Var6 string templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(ui.FormUrl[string](ctx, form, "/publish")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 100, Col: 60} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 101, Col: 60} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6)) if templ_7745c5c3_Err != nil { @@ -276,7 +277,7 @@ func FormSettings(form frm.Form) templ.Component { var templ_7745c5c3_Var8 string templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(ui.FormUrl[string](ctx, form, "/settings")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 117, Col: 59} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 118, Col: 59} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) if templ_7745c5c3_Err != nil { @@ -289,7 +290,7 @@ func FormSettings(form frm.Form) templ.Component { var templ_7745c5c3_Var9 string templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(FormSettingsUpdateEvent) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 118, Col: 44} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 119, Col: 44} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9)) if templ_7745c5c3_Err != nil { @@ -310,7 +311,7 @@ func FormSettings(form frm.Form) templ.Component { var templ_7745c5c3_Var10 string templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(form.Name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 132, Col: 21} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 133, Col: 21} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10)) if templ_7745c5c3_Err != nil { @@ -323,7 +324,7 @@ func FormSettings(form frm.Form) templ.Component { var templ_7745c5c3_Var11 string templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("on keyup debounced at 600ms trigger '%s'", FormSettingsUpdateEvent)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 135, Col: 88} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 136, Col: 88} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11)) if templ_7745c5c3_Err != nil { @@ -477,7 +478,7 @@ func FormFieldsForm(form frm.Form) templ.Component { var templ_7745c5c3_Var16 string templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(ui.FormUrl[string](ctx, form, "/fields/order")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 169, Col: 63} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 170, Col: 63} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16)) if templ_7745c5c3_Err != nil { @@ -495,7 +496,7 @@ func FormFieldsForm(form frm.Form) templ.Component { var templ_7745c5c3_Var17 string templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(field.ID.String()) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 178, Col: 65} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 179, Col: 65} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17)) if templ_7745c5c3_Err != nil { @@ -508,7 +509,7 @@ func FormFieldsForm(form frm.Form) templ.Component { var templ_7745c5c3_Var18 string templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("on click add .hidden to .active-configurator then take .active-configurator from .active-configurator for #configure-%s then remove .hidden from #configure-%s", field.ID.String(), field.ID.String())) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 184, Col: 223} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 185, Col: 223} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18)) if templ_7745c5c3_Err != nil { @@ -521,7 +522,7 @@ func FormFieldsForm(form frm.Form) templ.Component { var templ_7745c5c3_Var19 string templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(field.Label) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 188, Col: 65} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 189, Col: 65} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19)) if templ_7745c5c3_Err != nil { @@ -592,7 +593,7 @@ func builderColumnRight(form frm.Form) templ.Component { var templ_7745c5c3_Var21 string templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprint(i)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 220, Col: 32} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 221, Col: 32} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21)) if templ_7745c5c3_Err != nil { @@ -605,7 +606,7 @@ func builderColumnRight(form frm.Form) templ.Component { var templ_7745c5c3_Var22 string templ_7745c5c3_Var22, templ_7745c5c3_Err = templ.JoinStringErrs(ui.FormUrl[string](ctx, form, "/fields")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 223, Col: 63} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 224, Col: 63} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var22)) if templ_7745c5c3_Err != nil { @@ -618,7 +619,7 @@ func builderColumnRight(form frm.Form) templ.Component { var templ_7745c5c3_Var23 string templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf(`{"field_type": "%s"}`, fieldType)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 225, Col: 69} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 226, Col: 69} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23)) if templ_7745c5c3_Err != nil { @@ -682,7 +683,7 @@ func FormFieldConfigurator(form frm.Form) templ.Component { var templ_7745c5c3_Var25 string templ_7745c5c3_Var25, templ_7745c5c3_Err = templ.JoinStringErrs(ui.FormUrl[string](ctx, form, "/fields")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 243, Col: 56} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 244, Col: 56} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var25)) if templ_7745c5c3_Err != nil { @@ -695,7 +696,7 @@ func FormFieldConfigurator(form frm.Form) templ.Component { var templ_7745c5c3_Var26 string templ_7745c5c3_Var26, templ_7745c5c3_Err = templ.JoinStringErrs(FieldsFormUpdateEvent) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 244, Col: 41} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 245, Col: 41} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var26)) if templ_7745c5c3_Err != nil { @@ -713,7 +714,7 @@ func FormFieldConfigurator(form frm.Form) templ.Component { var templ_7745c5c3_Var27 string templ_7745c5c3_Var27, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("configure-%s", field.ID.String())) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 249, Col: 59} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 250, Col: 59} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var27)) if templ_7745c5c3_Err != nil { @@ -734,7 +735,7 @@ func FormFieldConfigurator(form frm.Form) templ.Component { var templ_7745c5c3_Var28 string templ_7745c5c3_Var28, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("configurator-tabs-%s", field.ID.String())) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 253, Col: 68} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 254, Col: 68} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var28)) if templ_7745c5c3_Err != nil { @@ -819,7 +820,7 @@ func fieldSettingsConfiguration(form frm.Form, field types.FormField) templ.Comp var templ_7745c5c3_Var30 string templ_7745c5c3_Var30, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("field-%s-settings", field.ID.String())) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 279, Col: 62} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 280, Col: 62} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var30)) if templ_7745c5c3_Err != nil { @@ -832,7 +833,7 @@ func fieldSettingsConfiguration(form frm.Form, field types.FormField) templ.Comp var templ_7745c5c3_Var31 string templ_7745c5c3_Var31, templ_7745c5c3_Err = templ.JoinStringErrs(fields.FieldName(field, "", "required")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 280, Col: 55} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 281, Col: 55} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var31)) if templ_7745c5c3_Err != nil { @@ -845,7 +846,7 @@ func fieldSettingsConfiguration(form frm.Form, field types.FormField) templ.Comp var templ_7745c5c3_Var32 string templ_7745c5c3_Var32, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprint(field.Required)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 280, Col: 106} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 281, Col: 106} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var32)) if templ_7745c5c3_Err != nil { @@ -858,7 +859,7 @@ func fieldSettingsConfiguration(form frm.Form, field types.FormField) templ.Comp var templ_7745c5c3_Var33 string templ_7745c5c3_Var33, templ_7745c5c3_Err = templ.JoinStringErrs(fields.FieldName(field, "", "hidden")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 281, Col: 53} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 282, Col: 53} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var33)) if templ_7745c5c3_Err != nil { @@ -871,7 +872,7 @@ func fieldSettingsConfiguration(form frm.Form, field types.FormField) templ.Comp var templ_7745c5c3_Var34 string templ_7745c5c3_Var34, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprint(field.Hidden)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 281, Col: 102} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 282, Col: 102} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var34)) if templ_7745c5c3_Err != nil { @@ -884,7 +885,7 @@ func fieldSettingsConfiguration(form frm.Form, field types.FormField) templ.Comp var templ_7745c5c3_Var35 string templ_7745c5c3_Var35, templ_7745c5c3_Err = templ.JoinStringErrs(fields.FieldName(field, "", "field_type")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 282, Col: 57} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 283, Col: 57} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var35)) if templ_7745c5c3_Err != nil { @@ -897,174 +898,48 @@ func fieldSettingsConfiguration(form frm.Form, field types.FormField) templ.Comp var templ_7745c5c3_Var36 string templ_7745c5c3_Var36, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprint(field.Type)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 282, Col: 104} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 283, Col: 104} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var36)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 59, "\">
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = fields.RequiredFieldIndicator().Render(ctx, templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 61, "
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err + if field.Type != types.FormFieldTypeSingleChoice && field.Type != types.FormFieldTypeSingleChoiceSpaced { + templ_7745c5c3_Err = ui.LabeledTextInput(ui.LabeledTextInputArgs{ + ID: fields.FieldName(field, "", "placeholder"), + Name: fields.FieldName(field, "", "placeholder"), + Label: "Placeholder", + LabelClass: "my-4 text-lg", + Placeholder: "Choose a placeholder", + Value: field.Placeholder, + Hyperscript: fmt.Sprintf("on keyup debounced at 600ms trigger '%s'", FieldsFormUpdateEvent), + }).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } } switch field.Type { case types.FormFieldTypeMultiSelect, types.FormFieldTypeSingleSelect, types.FormFieldTypeSingleChoice, types.FormFieldTypeSingleChoiceSpaced: - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 71, "
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = selector.Selector(selector.SelectArgs{ + templ_7745c5c3_Err = ui.LabeledSelector(ui.LabeledSelectorArgs{ + Label: "Options", + LabelClass: "my-4 text-lg", ID: fields.FieldName(field, "", "options"), Name: fields.FieldName(field, "", "options"), Placeholder: "Add, remove, or create new options", @@ -1076,29 +951,30 @@ func fieldSettingsConfiguration(form frm.Form, field types.FormField) templ.Comp if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 73, " ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 60, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = ui.LabeledSelector(ui.LabeledSelectorArgs{ + Label: "Data type", + LabelClass: "my-4 text-lg", + ID: fields.FieldName(field, "settings", "data_type"), + Name: fields.FieldName(field, "settings", "data_type"), + Placeholder: "Choose the data type", + Options: fields.FormFieldDataTypeOptions(field), + SelectionChangeEvent: FieldsFormUpdateEvent, + }).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 61, " ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if field.Type == types.FormFieldTypeSingleChoice { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 74, "
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = selector.Selector(selector.SelectArgs{ + templ_7745c5c3_Err = ui.LabeledSelector(ui.LabeledSelectorArgs{ + Label: "Option labels", + LabelClass: "my-4 text-lg", ID: fields.FieldName(field, "", "option_labels"), Name: fields.FieldName(field, "", "option_labels"), Placeholder: "Create labels for your options", @@ -1111,24 +987,13 @@ func fieldSettingsConfiguration(form frm.Form, field types.FormField) templ.Comp return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 76, "
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = selector.Selector(selector.SelectArgs{ + templ_7745c5c3_Err = ui.LabeledSelector(ui.LabeledSelectorArgs{ + Label: "Order", + LabelClass: "my-4 text-lg", ID: fields.FieldName(field, "", "option_ordering"), Name: fields.FieldName(field, "", "option_ordering"), Placeholder: "Choose option ordering", @@ -1141,147 +1006,65 @@ func fieldSettingsConfiguration(form frm.Form, field types.FormField) templ.Comp return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 78, "
's checked to false end then trigger '%s'`, - fields.FieldName(field, "", "hidden"), FieldsFormUpdateEvent)) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 378, Col: 66} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var53)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 84, "\">
's checked to false end then trigger '%s'`, - fields.FieldName(field, "", "required"), FieldsFormUpdateEvent)) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 399, Col: 68} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var57)) + fields.FieldName(field, "settings", "required"), FieldsFormUpdateEvent), + }).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) + templ_7745c5c3_Err = ui.FieldSet(ui.FieldsetArgs{Label: "Settings "}).Render(templ.WithChildren(ctx, templ_7745c5c3_Var37), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 90, "\">
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 64, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = ui.Button(ui.ButtonArgs{Type: "button", Label: "Delete field"}, templ.Attributes{ + templ_7745c5c3_Err = ui.Button(ui.ButtonArgs{Type: "button", Label: "Delete field", Classes: []string{"bg-red-500"}}, templ.Attributes{ "data-hx-delete": ui.FormUrl[string](ctx, form, fmt.Sprintf("/fields/%s", field.ID)), "data-hx-trigger": "click", "data-hx-confirm": "Are you sure?", @@ -1289,7 +1072,7 @@ func fieldSettingsConfiguration(form frm.Form, field types.FormField) templ.Comp if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 91, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 65, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -1313,64 +1096,64 @@ func fieldLogicConfiguration(form frm.Form, field types.FormField) templ.Compone }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var58 := templ.GetChildren(ctx) - if templ_7745c5c3_Var58 == nil { - templ_7745c5c3_Var58 = templ.NopComponent + templ_7745c5c3_Var38 := templ.GetChildren(ctx) + if templ_7745c5c3_Var38 == nil { + templ_7745c5c3_Var38 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 92, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 70, "\" data-hx-on:htmx:config-request=\"event.detail.parameters['id'] = event.detail.triggeringEvent.detail.value\">") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -1385,7 +1168,7 @@ func fieldLogicConfiguration(form frm.Form, field types.FormField) templ.Compone if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 97, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 71, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -1400,20 +1183,20 @@ func fieldLogicConfiguration(form frm.Form, field types.FormField) templ.Compone if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 98, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 73, "\">") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -1423,7 +1206,7 @@ func fieldLogicConfiguration(form frm.Form, field types.FormField) templ.Compone return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 100, "

Choose action(s)

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 74, "

Choose action(s)

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -1438,7 +1221,7 @@ func fieldLogicConfiguration(form frm.Form, field types.FormField) templ.Compone if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 101, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 75, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -1541,9 +1324,9 @@ func LogicConfiguratorStepThree(form frm.Form, field types.FormField, targetFiel }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var64 := templ.GetChildren(ctx) - if templ_7745c5c3_Var64 == nil { - templ_7745c5c3_Var64 = templ.NopComponent + templ_7745c5c3_Var44 := templ.GetChildren(ctx) + if templ_7745c5c3_Var44 == nil { + templ_7745c5c3_Var44 = templ.NopComponent } ctx = templ.ClearChildren(ctx) switch targetField.Type { @@ -1560,69 +1343,69 @@ func LogicConfiguratorStepThree(form frm.Form, field types.FormField, targetFiel return templ_7745c5c3_Err } case types.FormFieldTypeTextSingle, types.FormFieldTypeTextMultiple: - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 102, " 0 { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 105, " value=\"") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 79, " value=\"") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var67 string - templ_7745c5c3_Var67, templ_7745c5c3_Err = templ.JoinStringErrs(field.Logic.TriggerValues[0]) + var templ_7745c5c3_Var47 string + templ_7745c5c3_Var47, templ_7745c5c3_Err = templ.JoinStringErrs(field.Logic.TriggerValues[0]) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 565, Col: 41} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 544, Col: 41} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var67)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var47)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 106, "\"") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 80, "\"") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 107, " _=\"") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 81, " _=\"") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var68 string - templ_7745c5c3_Var68, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("on keyup debounced at 600ms trigger '%s'", FieldsFormUpdateEvent)) + var templ_7745c5c3_Var48 string + templ_7745c5c3_Var48, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("on keyup debounced at 600ms trigger '%s'", FieldsFormUpdateEvent)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 567, Col: 86} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/builder/builder.templ`, Line: 546, Col: 86} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var68)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var48)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 108, "\">") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 82, "\">") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/ui/builder/builder_templ.txt b/ui/builder/builder_templ.txt deleted file mode 100644 index 27386b3..0000000 --- a/ui/builder/builder_templ.txt +++ /dev/null @@ -1,108 +0,0 @@ -
-
- - -
-

-

-
-
-
-
-
-
-
-
-
-
-
-

-

-
-
-
-
-
Add field
- -
-
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
-
-
-

Choose action(s)

-
- \ No newline at end of file diff --git a/ui/collector/collector_templ.txt b/ui/collector/collector_templ.txt deleted file mode 100644 index ca0eb64..0000000 --- a/ui/collector/collector_templ.txt +++ /dev/null @@ -1,24 +0,0 @@ -
-
-
https://your-form-domain.com/form
-
-

-

- -
-
-
-
-

Thank you!

-

\ No newline at end of file diff --git a/ui/common.templ b/ui/common.templ index 1442722..f1d8479 100644 --- a/ui/common.templ +++ b/ui/common.templ @@ -42,6 +42,150 @@ func SafePath(ctx context.Context, path string) templ.SafeURL { return templ.SafeURL(frm.CollectorPath(ctx, path)) } +type LabeledCheckboxArgs struct { + Label string // label value + Name string // field name attribute + Title string // field title attribute + ID string // field id attribute + Checked bool // value is checked + Required bool // field is required + Tooltip string // text tooltip + Hyperscript string // hyperscript associated with element +} + +// LabeledCheckbox is a checkbox element with a label +templ LabeledCheckbox(args LabeledCheckboxArgs) { + +} + +type LabeledSelectorArgs struct { + Label string // label value + LabelClass string // CSS class(es) for label + Name string // field name attribute + Title string // field title attribute + ID string // field id attribute + Options []selector.Option // seletor options + Required bool // field is required + Multiple bool // allow multiple + EditItems bool + Placeholder string + SearchDisabled bool + SelectionChangeEvent string // the event fired when a selection changes +} + +// LabeledSelector is a selector with a label +templ LabeledSelector(args LabeledSelectorArgs) { + +} + +type LabeledTextInputArgs struct { + Label string // label value + LabelClass string // CSS class for label + Name string // field name attribute + Title string // field title attribute + ID string // field id attribute + Placeholder string // field placeholder attribute + Value string // field value attribute + Required bool // field is required + Tooltip string // text tooltip + Hyperscript string // hyperscript associated with element +} + +// LabeledTextInput is a text input with the label inside of it +templ LabeledTextInput(args LabeledTextInputArgs) { + +} + +type FieldsetArgs struct { + Label string // the label of the field set +} + +templ FieldSet(args FieldsetArgs) { +
+ { args.Label } + { children... } +
+} + // head simply provides the element templ Head(pageTitle string) { diff --git a/ui/common_templ.go b/ui/common_templ.go index 744997d..2947f63 100644 --- a/ui/common_templ.go +++ b/ui/common_templ.go @@ -218,8 +218,19 @@ func SafePath(ctx context.Context, path string) templ.SafeURL { return templ.SafeURL(frm.CollectorPath(ctx, path)) } -// head simply provides the element -func Head(pageTitle string) templ.Component { +type LabeledCheckboxArgs struct { + Label string // label value + Name string // field name attribute + Title string // field title attribute + ID string // field id attribute + Checked bool // value is checked + Required bool // field is required + Tooltip string // text tooltip + Hyperscript string // hyperscript associated with element +} + +// LabeledCheckbox is a checkbox element with a label +func LabeledCheckbox(args LabeledCheckboxArgs) templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { @@ -240,24 +251,514 @@ func Head(pageTitle string) templ.Component { templ_7745c5c3_Var11 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "<label class=\"fieldset-label\"><input id=\"") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var12 string - templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(pageTitle) + templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(args.ID) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 48, Col: 20} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 60, Col: 15} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "\" name=\"") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Var13 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + var templ_7745c5c3_Var13 string + templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(args.Name) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 61, Col: 19} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "\" type=\"checkbox\"") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if args.Checked { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, " checked=\"checked\"") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + if args.Required { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, " required") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, " class=\"checkbox\"") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if args.Hyperscript != "" { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, " _=\"") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var14 string + templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(args.Hyperscript) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 71, Col: 24} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "\"") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "> ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var15 string + templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(args.Label) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 74, Col: 33} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if args.Tooltip != "" { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + +type LabeledSelectorArgs struct { + Label string // label value + LabelClass string // CSS class(es) for label + Name string // field name attribute + Title string // field title attribute + ID string // field id attribute + Options []selector.Option // seletor options + Required bool // field is required + Multiple bool // allow multiple + EditItems bool + Placeholder string + SearchDisabled bool + SelectionChangeEvent string // the event fired when a selection changes +} + +// LabeledSelector is a selector with a label +func LabeledSelector(args LabeledSelectorArgs) templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var17 := templ.GetChildren(ctx) + if templ_7745c5c3_Var17 == nil { + templ_7745c5c3_Var17 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + var templ_7745c5c3_Var18 = []any{fmt.Sprintf("flex flex-col h-fit w-full input input-bordered flex px-0 %s", args.LabelClass)} + templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var18...) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + +type LabeledTextInputArgs struct { + Label string // label value + LabelClass string // CSS class for label + Name string // field name attribute + Title string // field title attribute + ID string // field id attribute + Placeholder string // field placeholder attribute + Value string // field value attribute + Required bool // field is required + Tooltip string // text tooltip + Hyperscript string // hyperscript associated with element +} + +// LabeledTextInput is a text input with the label inside of it +func LabeledTextInput(args LabeledTextInputArgs) templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var21 := templ.GetChildren(ctx) + if templ_7745c5c3_Var21 == nil { + templ_7745c5c3_Var21 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + var templ_7745c5c3_Var22 = []any{fmt.Sprintf("flex flex-col h-fit w-full %s", args.LabelClass)} + templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var22...) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + +type FieldsetArgs struct { + Label string // the label of the field set +} + +func FieldSet(args FieldsetArgs) templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var31 := templ.GetChildren(ctx) + if templ_7745c5c3_Var31 == nil { + templ_7745c5c3_Var31 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 48, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var32 string + templ_7745c5c3_Var32, templ_7745c5c3_Err = templ.JoinStringErrs(args.Label) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 184, Col: 46} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var32)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 49, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templ_7745c5c3_Var31.Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 50, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + +// head simply provides the element +func Head(pageTitle string) templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var33 := templ.GetChildren(ctx) + if templ_7745c5c3_Var33 == nil { + templ_7745c5c3_Var33 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 51, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var34 string + templ_7745c5c3_Var34, templ_7745c5c3_Err = templ.JoinStringErrs(pageTitle) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 192, Col: 20} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var34)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 52, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Var35 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { @@ -269,212 +770,212 @@ func Head(pageTitle string) templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, " ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 68, "\"> ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) - templ_7745c5c3_Err = loadDependenciesOnce.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var13), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = loadDependenciesOnce.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var35), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 69, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -498,9 +999,9 @@ func footer() templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var29 := templ.GetChildren(ctx) - if templ_7745c5c3_Var29 == nil { - templ_7745c5c3_Var29 = templ.NopComponent + templ_7745c5c3_Var51 := templ.GetChildren(ctx) + if templ_7745c5c3_Var51 == nil { + templ_7745c5c3_Var51 = templ.NopComponent } ctx = templ.ClearChildren(ctx) return nil @@ -524,12 +1025,12 @@ func App(pageTitle string) templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var30 := templ.GetChildren(ctx) - if templ_7745c5c3_Var30 == nil { - templ_7745c5c3_Var30 = templ.NopComponent + templ_7745c5c3_Var52 := templ.GetChildren(ctx) + if templ_7745c5c3_Var52 == nil { + templ_7745c5c3_Var52 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 70, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -537,15 +1038,15 @@ func App(pageTitle string) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 71, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templ_7745c5c3_Var30.Render(ctx, templ_7745c5c3_Buffer) + templ_7745c5c3_Err = templ_7745c5c3_Var52.Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 72, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -553,7 +1054,7 @@ func App(pageTitle string) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 73, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -609,40 +1110,40 @@ func ValidationErrors(errs types.ValidationErrors) templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var31 := templ.GetChildren(ctx) - if templ_7745c5c3_Var31 == nil { - templ_7745c5c3_Var31 = templ.NopComponent + templ_7745c5c3_Var53 := templ.GetChildren(ctx) + if templ_7745c5c3_Var53 == nil { + templ_7745c5c3_Var53 = templ.NopComponent } ctx = templ.ClearChildren(ctx) if len(errs) > 0 { for fieldID, err := range errs { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 75, "\" data-hx-swap-oob=\"true\" class=\"flex flex-col gap-3 py-3\">

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var33 string - templ_7745c5c3_Var33, templ_7745c5c3_Err = templ.JoinStringErrs(err.Error()) + var templ_7745c5c3_Var55 string + templ_7745c5c3_Var55, templ_7745c5c3_Err = templ.JoinStringErrs(err.Error()) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 226, Col: 18} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 370, Col: 18} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var33)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var55)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 76, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/ui/common_templ.txt b/ui/common_templ.txt deleted file mode 100644 index 9ce4eb2..0000000 --- a/ui/common_templ.txt +++ /dev/null @@ -1,36 +0,0 @@ - - -
-
- - - - - -
-
- -

-

\ No newline at end of file diff --git a/ui/css/tailwind.css b/ui/css/tailwind.css index 179bc82..f3caaef 100644 --- a/ui/css/tailwind.css +++ b/ui/css/tailwind.css @@ -29,4 +29,8 @@ https://github.com/Choices-js/Choices/issues/449 position: absolute; left: 0; bottom: 0; +} + +.choices { + margin-bottom: 0px !important; } \ No newline at end of file diff --git a/ui/errors_templ.txt b/ui/errors_templ.txt deleted file mode 100644 index 23f922c..0000000 --- a/ui/errors_templ.txt +++ /dev/null @@ -1,3 +0,0 @@ -
-
\ No newline at end of file diff --git a/ui/fields/fields.templ b/ui/fields/fields.templ index eefcf6d..05e222f 100644 --- a/ui/fields/fields.templ +++ b/ui/fields/fields.templ @@ -9,6 +9,8 @@ import ( "github.com/acaloiaro/frm/ui/selector" "github.com/acaloiaro/frm/types" + "golang.org/x/text/cases" + "golang.org/x/text/language" "github.com/google/uuid" ) @@ -41,6 +43,10 @@ templ LabeledField(field types.FormField) { { children... } +
} templ FieldTypeIcon(fieldType types.FormFieldType) { @@ -148,10 +154,6 @@ templ selectView(field types.FormField) { EditItems: false, Hyperscript: fmt.Sprintf("on change trigger field_change(field_id: '%s', value: my.value)", field.ID.String()), }) -
} } @@ -234,6 +236,23 @@ func FieldsAsSelectorOptions(form frm.Form, fieldID uuid.UUID) (options []select return } +// FormFieldDataTypeOptions returns all known field data types as selector options +func FormFieldDataTypeOptions(field types.FormField) (options []selector.Option) { + for _, dataType := range types.FormFieldDataTypes() { + selected := false + if field.DataType == dataType { + selected = true + } + options = append(options, selector.Option{ + ID: uuid.New(), + Label: cases.Title(language.English, cases.Compact).String(dataType.String()), + Value: dataType.String(), + Selected: selected, + }) + } + return +} + // fieldTypeToDefaultValuesJSON converts field types to their devault values. // This function takes a fieldType and converts it to the default values for that field type, // and encodes it as a JSON string. diff --git a/ui/fields/fields_templ.go b/ui/fields/fields_templ.go index 207bd2f..4cfa12e 100644 --- a/ui/fields/fields_templ.go +++ b/ui/fields/fields_templ.go @@ -18,6 +18,8 @@ import ( "github.com/acaloiaro/frm/ui/selector" "github.com/google/uuid" + "golang.org/x/text/cases" + "golang.org/x/text/language" ) // RequiredFieldIndicator visually indicates that a field is required @@ -79,7 +81,7 @@ func FieldLabel(field types.FormField) templ.Component { var templ_7745c5c3_Var3 string templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(field.ID.String()) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/fields/fields.templ`, Line: 22, Col: 31} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/fields/fields.templ`, Line: 24, Col: 31} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) if templ_7745c5c3_Err != nil { @@ -92,7 +94,7 @@ func FieldLabel(field types.FormField) templ.Component { var templ_7745c5c3_Var4 string templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(field.Label) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/fields/fields.templ`, Line: 23, Col: 15} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/fields/fields.templ`, Line: 25, Col: 15} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) if templ_7745c5c3_Err != nil { @@ -148,7 +150,7 @@ func LabeledField(field types.FormField) templ.Component { var templ_7745c5c3_Var6 string templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(field.ID.String()) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/fields/fields.templ`, Line: 35, Col: 31} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/fields/fields.templ`, Line: 37, Col: 31} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6)) if templ_7745c5c3_Err != nil { @@ -161,7 +163,7 @@ func LabeledField(field types.FormField) templ.Component { var templ_7745c5c3_Var7 string templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(field.Label) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/fields/fields.templ`, Line: 37, Col: 22} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/fields/fields.templ`, Line: 39, Col: 22} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) if templ_7745c5c3_Err != nil { @@ -175,7 +177,20 @@ func LabeledField(field types.FormField) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -199,33 +214,33 @@ func FieldTypeIcon(fieldType types.FormFieldType) templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var8 := templ.GetChildren(ctx) - if templ_7745c5c3_Var8 == nil { - templ_7745c5c3_Var8 = templ.NopComponent + templ_7745c5c3_Var9 := templ.GetChildren(ctx) + if templ_7745c5c3_Var9 == nil { + templ_7745c5c3_Var9 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } switch int(fieldType) { case int(types.FormFieldTypeTextSingle), int(types.FormFieldTypeTextMultiple): - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, " ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, " ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } case int(types.FormFieldTypeSingleSelect), int(types.FormFieldTypeMultiSelect): - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, " ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, " ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } case int(types.FormFieldTypeSingleChoice), int(types.FormFieldTypeSingleChoiceSpaced): - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, " ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, " ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -250,40 +265,40 @@ func View(field types.FormField) templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var9 := templ.GetChildren(ctx) - if templ_7745c5c3_Var9 == nil { - templ_7745c5c3_Var9 = templ.NopComponent + templ_7745c5c3_Var10 := templ.GetChildren(ctx) + if templ_7745c5c3_Var10 == nil { + templ_7745c5c3_Var10 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, ">
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -314,7 +329,7 @@ func View(field types.FormField) templ.Component { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -338,12 +353,12 @@ func singleLineTextView(field types.FormField) templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var11 := templ.GetChildren(ctx) - if templ_7745c5c3_Var11 == nil { - templ_7745c5c3_Var11 = templ.NopComponent + templ_7745c5c3_Var12 := templ.GetChildren(ctx) + if templ_7745c5c3_Var12 == nil { + templ_7745c5c3_Var12 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Var12 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_Var13 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { @@ -355,88 +370,88 @@ func singleLineTextView(field types.FormField) templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "\" class=\"flex-1 appearance-none border border-gray-300 dark:border-gray-600 w-full text-gray-700 dark:bg-notion-dark-light dark:text-gray-300 dark:placeholder-gray-500 placeholder-gray-400 shadow-sm focus:outline-none focus:ring-2 focus:border-2 focus:ring-opacity-100 px-4 py-2 text-base resize-y block rounded-xl bg-sky-50\">
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) - templ_7745c5c3_Err = LabeledField(field).Render(templ.WithChildren(ctx, templ_7745c5c3_Var12), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = LabeledField(field).Render(templ.WithChildren(ctx, templ_7745c5c3_Var13), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -460,12 +475,12 @@ func multiLineTextView(field types.FormField) templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var18 := templ.GetChildren(ctx) - if templ_7745c5c3_Var18 == nil { - templ_7745c5c3_Var18 = templ.NopComponent + templ_7745c5c3_Var19 := templ.GetChildren(ctx) + if templ_7745c5c3_Var19 == nil { + templ_7745c5c3_Var19 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Var19 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_Var20 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { @@ -477,88 +492,88 @@ func multiLineTextView(field types.FormField) templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, "\" rows=\"3\">
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) - templ_7745c5c3_Err = LabeledField(field).Render(templ.WithChildren(ctx, templ_7745c5c3_Var19), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = LabeledField(field).Render(templ.WithChildren(ctx, templ_7745c5c3_Var20), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -582,12 +597,12 @@ func selectView(field types.FormField) templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var25 := templ.GetChildren(ctx) - if templ_7745c5c3_Var25 == nil { - templ_7745c5c3_Var25 = templ.NopComponent + templ_7745c5c3_Var26 := templ.GetChildren(ctx) + if templ_7745c5c3_Var26 == nil { + templ_7745c5c3_Var26 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Var26 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_Var27 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { @@ -615,26 +630,9 @@ func selectView(field types.FormField) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, "
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } return nil }) - templ_7745c5c3_Err = LabeledField(field).Render(templ.WithChildren(ctx, templ_7745c5c3_Var26), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = LabeledField(field).Render(templ.WithChildren(ctx, templ_7745c5c3_Var27), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -664,7 +662,7 @@ func FormFieldTypeLabel(fieldType types.FormFieldType) templ.Component { templ_7745c5c3_Var28 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 38, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -672,43 +670,43 @@ func FormFieldTypeLabel(fieldType types.FormFieldType) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 40, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 46, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -769,6 +767,23 @@ func FieldsAsSelectorOptions(form frm.Form, fieldID uuid.UUID) (options []select return } +// FormFieldDataTypeOptions returns all known field data types as selector options +func FormFieldDataTypeOptions(field types.FormField) (options []selector.Option) { + for _, dataType := range types.FormFieldDataTypes() { + selected := false + if field.DataType == dataType { + selected = true + } + options = append(options, selector.Option{ + ID: uuid.New(), + Label: cases.Title(language.English, cases.Compact).String(dataType.String()), + Value: dataType.String(), + Selected: selected, + }) + } + return +} + // fieldTypeToDefaultValuesJSON converts field types to their devault values. // This function takes a fieldType and converts it to the default values for that field type, // and encodes it as a JSON string. diff --git a/ui/fields/fields_templ.txt b/ui/fields/fields_templ.txt deleted file mode 100644 index 2d83509..0000000 --- a/ui/fields/fields_templ.txt +++ /dev/null @@ -1,47 +0,0 @@ -* - - -
- - - -
-
-
-
-
-
-
-
\ No newline at end of file diff --git a/ui/fields/single_choice_templ.txt b/ui/fields/single_choice_templ.txt deleted file mode 100644 index 3ea4cee..0000000 --- a/ui/fields/single_choice_templ.txt +++ /dev/null @@ -1,28 +0,0 @@ -
- -
-
-
-
-
-
-
- -
\ No newline at end of file diff --git a/ui/selector/selector_templ.txt b/ui/selector/selector_templ.txt deleted file mode 100644 index 36e3ba6..0000000 --- a/ui/selector/selector_templ.txt +++ /dev/null @@ -1,25 +0,0 @@ - -
-
-
-
-
- \ No newline at end of file diff --git a/ui/trigger_rebuild_templ.txt b/ui/trigger_rebuild_templ.txt deleted file mode 100644 index e76b913..0000000 --- a/ui/trigger_rebuild_templ.txt +++ /dev/null @@ -1 +0,0 @@ -
000164
\ No newline at end of file