mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-24 22:04:56 +00:00
- Added type annotations and class definitions in the dashboard layout, stats, and data table modules for improved type safety and documentation. - Introduced new classes for UI components, props, and configuration in the form builder, navigation menu, notification center, and UI dialogs packages. - Implemented detailed type definitions for actions, fields, and pagination components to streamline usage and enhance clarity. - Updated initialization functions in multiple packages to include versioning and installation context. - Improved structure and readability of the codebase by organizing and documenting component properties and methods.
96 lines
2.4 KiB
Lua
96 lines
2.4 KiB
Lua
---@class Fields
|
|
local M = {}
|
|
|
|
---@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
|
|
|
|
---@class EmailFieldProps
|
|
---@field name string
|
|
---@field label? string
|
|
|
|
---@class PasswordFieldProps
|
|
---@field name string
|
|
---@field label? string
|
|
|
|
---@class NumberFieldProps
|
|
---@field name string
|
|
---@field label? string
|
|
---@field min? number
|
|
---@field max? number
|
|
|
|
---@class TextAreaFieldProps
|
|
---@field name string
|
|
---@field label? string
|
|
---@field placeholder? string
|
|
---@field rows? number
|
|
|
|
---@param props TextFieldProps
|
|
---@return UIComponent
|
|
function M.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
|
|
|
|
---@param props EmailFieldProps
|
|
---@return UIComponent
|
|
function M.email(props)
|
|
return {
|
|
type = "Box",
|
|
children = {
|
|
{ type = "Label", props = { text = props.label or "Email", htmlFor = props.name } },
|
|
{ type = "Input", props = { name = props.name, type = "email", placeholder = "you@example.com" } }
|
|
}
|
|
}
|
|
end
|
|
|
|
---@param props PasswordFieldProps
|
|
---@return UIComponent
|
|
function M.password(props)
|
|
return {
|
|
type = "Box",
|
|
children = {
|
|
{ type = "Label", props = { text = props.label or "Password", htmlFor = props.name } },
|
|
{ type = "Input", props = { name = props.name, type = "password", placeholder = "••••••••" } }
|
|
}
|
|
}
|
|
end
|
|
|
|
---@param props NumberFieldProps
|
|
---@return UIComponent
|
|
function M.number(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, type = "number", min = props.min, max = props.max } }
|
|
}
|
|
}
|
|
end
|
|
|
|
---@param props TextAreaFieldProps
|
|
---@return UIComponent
|
|
function M.textarea(props)
|
|
return {
|
|
type = "Box",
|
|
children = {
|
|
props.label and { type = "Label", props = { text = props.label, htmlFor = props.name } } or nil,
|
|
{ type = "TextArea", props = { name = props.name, rows = props.rows or 4, placeholder = props.placeholder } }
|
|
}
|
|
}
|
|
end
|
|
|
|
return M
|