agentleFS
otavioserraotavioserra/conn2flow-ai-workspace/.claude/skills/c2f-widget-development/SKILL.md

c2f-widget-development

Skill4 starsChanged 33 days agoMITView on GitHub

LEIA ANTES de desenvolver ou alterar widgets do sistema e seus renderizadores. Se não ler: widgets quebram o isolamento de escopo, duplicam IDs no DOM e falham na renderização pública.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    No frontend envie ajaxOpcao.

    line 18

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Desenvolvimento de widgets Conn2Flow

⚡ Gatilho Obrigatório

  • TRIGGER: Criar ou modificar widgets (*.widget.php, *.widget.js), tags @[[widgets#...]]@ ou controladores de renderização de widgets.
  • SKIP APENAS SE: Componentes visuais estáticos que não possuem ciclo de vida autônomo de widget.
  • CONSEQUÊNCIA DE IGNORAR: Colisão de identificadores no DOM ao instanciar múltiplos widgets, perda de dados na injeção de parâmetros dinâmicos e quebra de renderização no site final.

  1. Injete CSS, head e JavaScript por gestor_pagina_recursos_incluir([...]); centralize a inclusão e preserve a deduplicação do helper.
  2. Não chame novamente controladores de recursos que o render do widget já inclui.
  3. No frontend envie ajaxOpcao; no backend trate a mesma ação em $_GESTOR['ajax-opcao'] e evite nomes reservados pelo fechamento AJAX genérico.
  4. Para tokens de item, aceite wrappers opcionais com /@?\[\[item#([a-zA-Z0-9_\-]+)\]\]@?/ e substitua todas as ocorrências.
  5. Mantenha blocos de repetição, vazio e controles compatíveis com o contrato do AI mode/template do widget.
  6. Valide duas renderizações na mesma página para detectar duplicação de assets, além do caminho AJAX feliz e de erro.

7. Contrato Modular de Grid (Dimensões Dinâmicas e Drag-and-Drop)

Todo widget que participa de painéis modulares, dashboards ou layouts customizáveis deve obedecer ao contrato de grid modular:

7.1 Dimensões Dinâmicas (width e height)

  • Os widgets devem ser declarados com suporte a redimensionamento em unidades de grid (colunas e linhas):
    • grid_w (largura em colunas, ex: 1 a 12).
    • grid_h (altura em linhas/unidades de altura, ex: 1 a 6).
  • Limites Estritos de Redimensionamento:
    • min_w: largura mínima para renderização legível sem truncamento de controles.
    • max_w: largura máxima permitida no container.
    • min_h: altura mínima que garante exibição do conteúdo essencial sem overflow vertical quebrado.
    • max_h: altura máxima recomendada para evitar distorção de proporção.
  • O HTML e CSS do widget devem utilizar containers flexíveis (w-full h-full) e respeitar overflow interno com scrollbars sutis (overflow-y-auto overflow-x-hidden) quando o conteúdo exceder a área útil.

7.2 Drag-and-Drop e Preservação de Estado

  • Ao mover ou redimensionar widgets em um layout interativo, a biblioteca cliente emite eventos de layout.
  • O widget deve manter seletores com atributos de dados isolados (ex: data-widget-id="<id>", data-widget-instance="<hash>") para evitar que clones ou múltiplos widgets na mesma tela colidam event listeners ou propriedades de estilo.

8. Ciclo de Vida e Re-renderização AJAX (ajaxOpcao: 'widget-render')

Widgets dinâmicos que atualizam seu conteúdo assincronamente (filtros, paginação interna, polling ou atualização pós-redimensionamento) devem adotar o endpoint padronizado:

8.1 Chamada Frontend

gestorAjax(state, 'widget-render', {
    widget_id: 'meu-widget',
    instance_id: instanceId,
    width: currentGridWidth,
    height: currentGridHeight,
    params: { /* parâmetros específicos do widget */ }
}).then(function(response) {
    if (response.status === 'Ok' && response.data.html) {
        container.innerHTML = response.data.html;
        if (response.data.css) {
            // Injeção dinâmica ou atualização de estilos
        }
        // Reinicializar listeners específicos da instância
        widgetInit(container, response.data);
    }
});

8.2 Manipulador Backend no Módulo/Controlador

if (!empty($_GESTOR['ajax'])) {
    interface_ajax_iniciar();

    switch ($_GESTOR['ajax-opcao']) {
        case 'widget-render':
            $widget_id = $_REQUEST['widget_id'] ?? '';
            $width = (int)($_REQUEST['width'] ?? 1);
            $height = (int)($_REQUEST['height'] ?? 1);
            $params = $_REQUEST['params'] ?? [];

            $render = widget_renderizar([
                'id' => $widget_id,
                'width' => $width,
                'height' => $height,
                'params' => $params,
                'return_css' => true
            ]);

            $_GESTOR['ajax-json'] = [
                'status' => 'Ok',
                'data' => [
                    'html' => $render['html'] ?? '',
                    'css' => $render['css'] ?? ''
                ]
            ];
            break;
    }

    interface_ajax_finalizar();
    return;
}

[!IMPORTANT] A re-renderização via ajaxOpcao: 'widget-render' não deve reinjetar dependências de scripts globais (<script> no head) já carregadas; use gestor_pagina_recursos_incluir() com deduplicação nativa.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.