config: packages,lua,nav (7 files)

This commit is contained in:
Richard Ward
2025-12-30 14:28:19 +00:00
parent a33ec831ee
commit 83364db727
7 changed files with 163 additions and 2 deletions

View File

@@ -0,0 +1,18 @@
-- Render sidebar header
require("sidebar.types")
local M = {}
---@param props SidebarProps
---@return UIComponent
function M.header(props)
return {
type = "Box",
props = { className = "p-4 border-b" },
children = {
{ type = "Typography", props = { variant = "h6", text = props.title or "Menu" } }
}
}
end
return M

View File

@@ -0,0 +1,14 @@
-- Sidebar module
---@class SidebarModule
---@field render fun(props: SidebarProps): UIComponent
---@field header fun(props: SidebarProps): UIComponent
---@field item fun(item: SidebarItem, currentPath: string?): UIComponent
local M = {
render = require("sidebar.render").render,
header = require("sidebar.header").header,
item = require("sidebar.item").item
}
return M

View File

@@ -0,0 +1,23 @@
-- Render sidebar item
require("sidebar.types")
local M = {}
---@param item SidebarItem
---@param currentPath? string
---@return UIComponent
function M.item(item, currentPath)
local active = currentPath == item.path
return {
type = "Button",
props = {
variant = active and "secondary" or "ghost",
className = "w-full justify-start",
text = item.label,
onClick = "navigate",
data = item.path
}
}
end
return M

View File

@@ -0,0 +1,25 @@
-- Render sidebar component
require("sidebar.types")
local header_module = require("sidebar.header")
local item_module = require("sidebar.item")
local M = {}
---@param props SidebarProps
---@return UIComponent
function M.render(props)
local items = {}
for _, item in ipairs(props.items or {}) do
items[#items + 1] = item_module.item(item, props.currentPath)
end
return {
type = "Box",
props = { className = "w-64 border-r h-screen bg-sidebar" },
children = {
header_module.header(props),
{ type = "Stack", props = { spacing = 1, className = "p-4" }, children = items }
}
}
end
return M

View File

@@ -0,0 +1,7 @@
-- SMTP Config Package
-- Provides configurable SMTP configuration UI components
return {
smtp = require("smtp"),
validate = require("validate")
}

View File

@@ -0,0 +1,71 @@
{
"getDefaults": [
{
"desc": "returns default SMTP configuration",
"expected_keys": ["host", "port", "username", "password", "fromEmail", "fromName", "secure"]
}
],
"getFields": [
{
"desc": "returns all field definitions",
"expected_count": 7
}
],
"validate": {
"valid": [
{
"desc": "accepts valid configuration",
"input": {
"host": "smtp.gmail.com",
"port": 587,
"username": "user@example.com",
"password": "password123",
"fromEmail": "noreply@example.com",
"fromName": "Test System",
"secure": true
}
}
],
"invalid": [
{
"desc": "rejects missing host",
"input": {
"host": "",
"port": 587,
"username": "user",
"password": "pass",
"fromEmail": "test@example.com",
"fromName": "Test",
"secure": true
},
"expected_error": "host"
},
{
"desc": "rejects invalid port",
"input": {
"host": "smtp.example.com",
"port": 99999,
"username": "user",
"password": "pass",
"fromEmail": "test@example.com",
"fromName": "Test",
"secure": true
},
"expected_error": "port"
},
{
"desc": "rejects invalid email format",
"input": {
"host": "smtp.example.com",
"port": 587,
"username": "user",
"password": "pass",
"fromEmail": "invalid-email",
"fromName": "Test",
"secure": true
},
"expected_error": "fromEmail"
}
]
}
}

View File

@@ -5,18 +5,21 @@
---@field id string Unique node identifier
---@field label string Display label for the node
---@field actionType string The type of action to perform
---@field icon? string Icon name from fakemui icons
---Creates an action node for workflow
---@param id string Unique node identifier
---@param label string Display label for the node
---@param action_type string The type of action to perform
---@param icon? string Icon name from fakemui icons
---@return ActionNodeDefinition
local function action_node(id, label, action_type)
local function action_node(id, label, action_type, icon)
return {
type = "action",
id = id,
label = label,
actionType = action_type
actionType = action_type,
icon = icon
}
end