diff --git a/packages/code_editor/seed/scripts/init.lua b/packages/code_editor/seed/scripts/init.lua index 5fb93bf2d..77997d5c3 100644 --- a/packages/code_editor/seed/scripts/init.lua +++ b/packages/code_editor/seed/scripts/init.lua @@ -1,9 +1,19 @@ -- Code Editor initialization + +---@class CodeEditor +---@field name string +---@field version string local M = {} M.name = "code_editor" M.version = "1.0.0" +---@class InitResult +---@field name string +---@field version string +---@field loaded boolean + +---@return InitResult function M.init() return { name = M.name, diff --git a/packages/code_editor/seed/scripts/json.lua b/packages/code_editor/seed/scripts/json.lua index c86985dc3..52743fec8 100644 --- a/packages/code_editor/seed/scripts/json.lua +++ b/packages/code_editor/seed/scripts/json.lua @@ -1,6 +1,27 @@ -- JSON Editor utilities + +---@class JsonEditor local M = {} +---@class EditorOptions +---@field read_only? boolean + +---@class UIComponent +---@field type string +---@field props? table +---@field children? table + +---@class ValidationResult +---@field valid boolean +---@field errors table + +---@class FormatAction +---@field action string +---@field language string + +---@param value? string +---@param options? EditorOptions +---@return UIComponent function M.render(value, options) return { type = "code_editor", @@ -14,6 +35,8 @@ function M.render(value, options) } end +---@param json_string string +---@return ValidationResult function M.validate(json_string) -- JSON validation placeholder return { @@ -22,6 +45,8 @@ function M.validate(json_string) } end +---@param json_string string +---@return FormatAction function M.format(json_string) return { action = "format", diff --git a/packages/code_editor/seed/scripts/lua.lua b/packages/code_editor/seed/scripts/lua.lua index 856cc3039..a9e06ee36 100644 --- a/packages/code_editor/seed/scripts/lua.lua +++ b/packages/code_editor/seed/scripts/lua.lua @@ -1,6 +1,28 @@ -- Lua Editor utilities + +---@class LuaEditor local M = {} +---@class EditorOptions +---@field read_only? boolean + +---@class UIComponent +---@field type string +---@field props? table +---@field children? table + +---@class ValidationResult +---@field valid boolean +---@field errors table + +---@class SandboxAction +---@field action string +---@field sandbox boolean +---@field context table + +---@param value? string +---@param options? EditorOptions +---@return UIComponent function M.render(value, options) return { type = "code_editor", @@ -14,6 +36,8 @@ function M.render(value, options) } end +---@param lua_code string +---@return ValidationResult function M.validate(lua_code) -- Lua syntax validation placeholder return { @@ -22,6 +46,9 @@ function M.validate(lua_code) } end +---@param lua_code string +---@param context? table +---@return SandboxAction function M.run_sandbox(lua_code, context) return { action = "execute", diff --git a/packages/code_editor/seed/scripts/theme.lua b/packages/code_editor/seed/scripts/theme.lua index 59b8639d8..b6514ad70 100644 --- a/packages/code_editor/seed/scripts/theme.lua +++ b/packages/code_editor/seed/scripts/theme.lua @@ -1,6 +1,20 @@ -- Theme Editor utilities + +---@class ThemeEditor local M = {} +---@class Theme +---@field primary? string +---@field secondary? string +---@field mode? string + +---@class UIComponent +---@field type string +---@field props? table +---@field children? table + +---@param theme? Theme +---@return UIComponent function M.render(theme) return { type = "theme_editor", @@ -12,6 +26,9 @@ function M.render(theme) } end +---@param name string +---@param value string +---@return UIComponent function M.color_picker(name, value) return { type = "color_picker", @@ -23,6 +40,7 @@ function M.color_picker(name, value) } end +---@return UIComponent function M.mode_toggle() return { type = "switch", diff --git a/packages/dashboard/seed/scripts/stats/trend.lua b/packages/dashboard/seed/scripts/stats/trend.lua index 904df81ce..65ae3aad8 100644 --- a/packages/dashboard/seed/scripts/stats/trend.lua +++ b/packages/dashboard/seed/scripts/stats/trend.lua @@ -1,4 +1,14 @@ -- Dashboard stat trend indicator + +---@class TrendIndicatorConfig +---@field type string +---@field direction string +---@field value string +---@field color string + +---@param direction string Direction of trend: "up" or "down" +---@param value string Trend value to display +---@return TrendIndicatorConfig local function trend_indicator(direction, value) return { type = "trend", diff --git a/packages/data_table/seed/scripts/columns/date.lua b/packages/data_table/seed/scripts/columns/date.lua index 45c9b52da..1c2c1b100 100644 --- a/packages/data_table/seed/scripts/columns/date.lua +++ b/packages/data_table/seed/scripts/columns/date.lua @@ -1,4 +1,17 @@ -- Date column definition + +---@class DateColumn +---@field type "date" +---@field id string Column identifier +---@field label string Column header label +---@field format string Date format string (e.g., "YYYY-MM-DD") +---@field sortable boolean Whether the column is sortable + +---Create a date column definition +---@param id string Column identifier +---@param label string Column header label +---@param format? string Date format string (default: "YYYY-MM-DD") +---@return DateColumn local function date_column(id, label, format) return { type = "date", diff --git a/packages/data_table/seed/scripts/columns/number.lua b/packages/data_table/seed/scripts/columns/number.lua index a8dfb8d89..98a14303b 100644 --- a/packages/data_table/seed/scripts/columns/number.lua +++ b/packages/data_table/seed/scripts/columns/number.lua @@ -1,4 +1,18 @@ -- Number column definition + +---@class NumberColumn +---@field type "number" +---@field id string Column identifier +---@field label string Column header label +---@field width string Column width (e.g., "100px") +---@field sortable boolean Whether the column is sortable +---@field align "right" Text alignment + +---Create a number column definition +---@param id string Column identifier +---@param label string Column header label +---@param width? string Column width (default: "100px") +---@return NumberColumn local function number_column(id, label, width) return { type = "number", diff --git a/packages/form_builder/seed/scripts/validate.lua b/packages/form_builder/seed/scripts/validate.lua index 8b210ca56..77121773d 100644 --- a/packages/form_builder/seed/scripts/validate.lua +++ b/packages/form_builder/seed/scripts/validate.lua @@ -1,35 +1,69 @@ +---@class Validate local M = {} +---@class ValidationRule +---@field type string +---@field message? string +---@field min? number +---@field max? number +---@field value? any + +---@class ValidationResult +---@field valid boolean +---@field errors string[] + +---@param value string|number|nil +---@return boolean function M.required(value) return value ~= nil and value ~= "" end +---@param value string|nil +---@return boolean function M.email(value) if not value then return false end return string.match(value, "^[^@]+@[^@]+%.[^@]+$") ~= nil end +---@param value string|nil +---@param min number +---@return boolean function M.minLength(value, min) return value and #value >= min end +---@param value string|nil +---@param max number +---@return boolean function M.maxLength(value, max) return not value or #value <= max end +---@param value string|nil +---@param pat string +---@return boolean function M.pattern(value, pat) return value and string.match(value, pat) ~= nil end +---@param value any +---@return boolean function M.number(value) return tonumber(value) ~= nil end +---@param value any +---@param min number +---@param max number +---@return boolean function M.range(value, min, max) local n = tonumber(value) return n and n >= min and n <= max end +---@param value string|number|nil +---@param rules ValidationRule[] +---@return ValidationResult function M.validate_field(value, rules) local errors = {} for _, rule in ipairs(rules) do diff --git a/packages/notification_center/seed/scripts/list/container.lua b/packages/notification_center/seed/scripts/list/container.lua index 8a9e34956..70da68b93 100644 --- a/packages/notification_center/seed/scripts/list/container.lua +++ b/packages/notification_center/seed/scripts/list/container.lua @@ -1,4 +1,12 @@ -- Notification list container + +---@class UIComponent +---@field type string +---@field children? table[] +---@field emptyMessage? string + +---@param notifications? table[] +---@return UIComponent local function list_container(notifications) return { type = "notification_list", diff --git a/packages/notification_center/seed/scripts/list/item.lua b/packages/notification_center/seed/scripts/list/item.lua index 5e1bf7032..ee138dc85 100644 --- a/packages/notification_center/seed/scripts/list/item.lua +++ b/packages/notification_center/seed/scripts/list/item.lua @@ -1,4 +1,19 @@ -- Notification list item component + +---@class UIComponent +---@field type string +---@field id string|number +---@field title string +---@field message string +---@field timestamp string|number +---@field read boolean + +---@param id string|number +---@param title string +---@param message string +---@param timestamp string|number +---@param read? boolean +---@return UIComponent local function list_item(id, title, message, timestamp, read) return { type = "notification_item",