Skip to content

SmythOS Studio: Open-Source Visual AI Agent Builder and deployable runtime stack from SmythOS. Start with an intuitive drag-and-drop workspace, extend with custom code, and deploy your agents anywhere — local, cloud, or edge — with full governance and control.

7.6 KB
Raw Blame
<li title="<%= label %>">
    <%
    let cssstyle = '';
    let svgstyle = '';
    if (typeof color == 'string' && color) {
        cssstyle += `color:${color};`;
        svgstyle += `fill:${color};`;
    }
    if (typeof children !== 'undefined' && Array.isArray(children)) {
        let sanitizedId = name.replace(/[^a-zA-Z0-9]/g, '');
        %>
    <div class="items-group-container px-2 <%=(!visible || children.length < 1)?'hidden':''%>" x-data="{ open: false }"
        x-init="open = localStorage.getItem('toggle<%= sanitizedId %>') === 'true'">

        <button @click="open = !open; localStorage.setItem('toggle<%= sanitizedId %>', open)"
            class="group-btn group flex w-full max-w-[232px] items-center px-2 py-2 text-sm text-black rounded-md bg-gray-100"
            :aria-expanded="open.toString()" aria-controls="<%= sanitizedId %>">

            <span class="icon" style="<%= cssstyle %>">
                <% if (icon.startsWith('fa-')) { %>
                <i class="<%= icon %>"></i>
                <% } else if (icon.trim().startsWith('<svg')) { %>
                <span class="svg-icon w-6 h-6">
                    <%- icon.match(/<path(?=.*?\sfill="[^"]*")[^>]*>/gm) ? icon : icon.replace(/<path /gm, '<path style="'+svgstyle+'"') %>
                </span>
                <% } else { %>
                <span class="svg-icon <%= icon %> w-6 h-6"></span>
                <% } %>
            </span>

            <span class="flex-1 ml-2 whitespace-nowrap text-left select-none truncate" data-label="<%= label %>" data-group="true"
                sidebar-toggle-item><span class="name"><%= label %></span></span>

            <span class="expand-btn cursor-pointer items-center justify-center
                w-3.5 h-3.5 p-1 ml-2 text-xs font-semibold border
                border-solid border-gray-800 text-gray-800 rounded-full inline-flex" x-text="open ? '-' : '+'"></span>
        </button>

        <ul id="<%= sanitizedId %>" x-show="open" x-cloak class="items-group py-2 space-y-2">
            <% children.forEach((item, index) => { %>
            <%- include('left-sidebar-cptItem', { name: item.name, level:2, description: item.description, visible: (typeof item.visible === 'undefined') || item.visible, color:item.color||color, label:item.label||item.name, icon:item.icon||icon||item.name, attributes:item.attributes||{}, children:item.children }) %>
            <% }) %>
        </ul>
    </div>
    <% } else {
        if (visible || isSmythStaff) {
            %>
    <div class="h-9" data-visible="<%= visible%>">
        <% if (typeof externalLink !== 'undefined') { %>
            <a href="<%= externalLink %>" target="_blank" rel="noopener noreferrer"
                class="group flex items-center justify-between h-full pr-2 text-sm rounded-md bg-white <%=level==1 ? 'mx-2 pl-2': 'pl-1'%> text-black">
                <span class="flex items-center gap-2">
                    <% if (icon) { %>
                        <span class="icon" style="<%= cssstyle %>">
                            <% if (icon.startsWith('fa')) { %>
                                <i class="<%= icon %>"></i>
                            <% } else if (icon.trim().startsWith('<svg')) { %>
                                <span class="svg-icon w-6 h-6">
                                    <%- icon.match(/<path(?=.*?\sfill="[^"]*")[^>]*>/gm) ? icon : icon.replace(/<path /gm, '<path style="'+svgstyle+'"') %>
                                </span>
                            <% } else { %>
                                <span class="svg-icon <%= icon %> w-6 h-6"></span>
                            <% } %>
                        </span>
                    <% } %>
                    <span class="name flex-1 whitespace-nowrap truncate"><%= label %></span>
                </span>
                <span class="external-link-icon">
                    <svg class="w-4 h-4" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
                        <path d="M3.5 3C3.22386 3 3 3.22386 3 3.5C3 3.77614 3.22386 4 3.5 4H7.29289L2.64645 8.64645C2.45118 8.84171 2.45118 9.15829 2.64645 9.35355C2.84171 9.54882 3.15829 9.54882 3.35355 9.35355L8 4.70711V8.5C8 8.77614 8.22386 9 8.5 9C8.77614 9 9 8.77614 9 8.5V3.5C9 3.22386 8.77614 3 8.5 3H3.5Z" fill="currentColor"/>
                    </svg>
                </span>
            </a>
        <% } else { %>
            <a href="#" data-label="<%= label %>"
                class="group flex items-center justify-between h-full pr-2 text-sm rounded-md bg-white <%=level==1 ? 'mx-2 pl-2': 'pl-1'%> <%= visible ? 'text-black' : 'text-red-600' %>"
                smt-component="<%= name %>" <% for (const attr in attributes) { %><%= attr %>="<%= attributes[attr] %>"
                <% } %>>

                <span class="flex items-center gap-2">

                    <span class="icon" style="<%= cssstyle %>">
                        <% if (icon?.startsWith('fa')) { %>
                            <i class="<%= icon %>"></i>
                            <% } else if (icon?.trim()?.startsWith('<svg')) { %>
                            <span class="svg-icon w-6 h-6">
                                <%- icon?.match(/<path(?=.*?\sfill="[^"]*")[^>]*>/gm) ? icon : icon?.replace(/<path /gm, '<path style="'+svgstyle+'"') %>
                            </span>
                            <% } else { %>
                                <span class="svg-icon <%= icon %> w-6 h-6"></span>
                            <% } %>
                        </span>
                            
                        <span class="name flex-1 whitespace-nowrap truncate"><%= label %></span>
                </span>

                <span class="cursor-grab [.dragging_&]:hidden">
                    <svg width="24" height="25" viewBox="0 0 24 25" fill="none" xmlns="http://www.w3.org/2000/svg">
                        <path fill-rule="evenodd" clip-rule="evenodd" d="M9.26468 18.2891C9.82267 18.2891 10.2754 18.7413 10.2754 19.2998C10.2754 19.8576 9.82326 20.3106 9.26468 20.3106C8.70609 20.3106 8.25391 19.8576 8.25391 19.2998C8.25391 18.7413 8.70669 18.2891 9.26468 18.2891Z" fill="#797979"/>
                        <path fill-rule="evenodd" clip-rule="evenodd" d="M9.26468 12.2656C9.82267 12.2656 10.2754 12.7179 10.2754 13.2763C10.2754 13.8342 9.82326 14.2872 9.26468 14.2872C8.70609 14.2872 8.25391 13.8342 8.25391 13.2763C8.25391 12.7179 8.70669 12.2656 9.26468 12.2656Z" fill="#797979"/>
                        <path fill-rule="evenodd" clip-rule="evenodd" d="M9.26468 6.24609C9.82267 6.24609 10.2754 6.69833 10.2754 7.25679C10.2754 7.81467 9.82326 8.26765 9.26468 8.26765C8.70609 8.26765 8.25391 7.81467 8.25391 7.25679C8.25391 6.69832 8.70669 6.24609 9.26468 6.24609Z" fill="#797979"/>
                        <path fill-rule="evenodd" clip-rule="evenodd" d="M15.7334 18.2891C16.2914 18.2891 16.7442 18.7413 16.7442 19.2998C16.7442 19.8576 16.292 20.3106 15.7334 20.3106C15.1748 20.3106 14.7227 19.8576 14.7227 19.2998C14.7227 18.7413 15.1754 18.2891 15.7334 18.2891Z" fill="#797979"/>
                        <path fill-rule="evenodd" clip-rule="evenodd" d="M15.7334 12.2656C16.2914 12.2656 16.7442 12.7179 16.7442 13.2763C16.7442 13.8342 16.292 14.2872 15.7334 14.2872C15.1748 14.2872 14.7227 13.8342 14.7227 13.2763C14.7227 12.7179 15.1754 12.2656 15.7334 12.2656Z" fill="#797979"/>
                        <path fill-rule="evenodd" clip-rule="evenodd" d="M15.7334 6.24609C16.2914 6.24609 16.7442 6.69833 16.7442 7.25679C16.7442 7.81467 16.292 8.26765 15.7334 8.26765C15.1748 8.26765 14.7227 7.81467 14.7227 7.25679C14.7227 6.69832 15.1754 6.24609 15.7334 6.24609Z" fill="#797979"/>
                    </svg>
                </span>
            </a>
        <% } %>
    </div>
    <%
        }
    } %>

</li>