mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-26 14:54:55 +00:00
27 lines
656 B
Lua
27 lines
656 B
Lua
-- Text field component
|
|
|
|
---@class UIComponent
|
|
---@field type string
|
|
---@field props? table
|
|
---@field children? UIComponent[]
|
|
|
|
---@class TextFieldProps
|
|
---@field name string
|
|
---@field label? string
|
|
---@field placeholder? string
|
|
---@field required? boolean
|
|
|
|
---@param props TextFieldProps
|
|
---@return UIComponent
|
|
local function text(props)
|
|
return {
|
|
type = "Box",
|
|
children = {
|
|
props.label and { type = "Label", props = { text = props.label, htmlFor = props.name } } or nil,
|
|
{ type = "Input", props = { name = props.name, placeholder = props.placeholder, required = props.required } }
|
|
}
|
|
}
|
|
end
|
|
|
|
return text
|