mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-24 13:54:57 +00:00
config: packages,lua,nav (7 files)
This commit is contained in:
18
packages/nav_menu/seed/scripts/sidebar/header.lua
Normal file
18
packages/nav_menu/seed/scripts/sidebar/header.lua
Normal 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
|
||||
14
packages/nav_menu/seed/scripts/sidebar/init.lua
Normal file
14
packages/nav_menu/seed/scripts/sidebar/init.lua
Normal 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
|
||||
23
packages/nav_menu/seed/scripts/sidebar/item.lua
Normal file
23
packages/nav_menu/seed/scripts/sidebar/item.lua
Normal 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
|
||||
25
packages/nav_menu/seed/scripts/sidebar/render.lua
Normal file
25
packages/nav_menu/seed/scripts/sidebar/render.lua
Normal 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
|
||||
7
packages/smtp_config/seed/scripts/init.lua
Normal file
7
packages/smtp_config/seed/scripts/init.lua
Normal file
@@ -0,0 +1,7 @@
|
||||
-- SMTP Config Package
|
||||
-- Provides configurable SMTP configuration UI components
|
||||
|
||||
return {
|
||||
smtp = require("smtp"),
|
||||
validate = require("validate")
|
||||
}
|
||||
71
packages/smtp_config/seed/scripts/tests/smtp.cases.json
Normal file
71
packages/smtp_config/seed/scripts/tests/smtp.cases.json
Normal 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"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user