Preskoči na vsebino

Standard Library

93 reusable behaviors organized as atoms, molecules, and organisms.


Overview

The Standard Library provides 93 reusable behaviors for Orb applications, organized in three tiers:

TierCountRoleExamples
Atoms50Self-contained, irreducible state machinesstd-browse, std-modal, std-search, std-filter, std-timer
Molecules18Compose atoms via shared event busstd-list, std-cart, std-detail, std-messaging
Organisms25Compose molecules into full applicationsstd-ecommerce, std-crm, std-lms, std-helpdesk

Each behavior is a reusable orbital unit. Import it with uses, rebind the entity with -> YourEntity, override specific event effects with on EVENT { ... }, and bind it to a page.

ProductBrowseCreateEditViewProductListPage

Composition Model

Atoms: Building Blocks

Atoms are irreducible. Each is a single trait with a single state machine. They don't know about each other.

std-browse: Browsing ──INIT──► Browsing (fetch + render list)
std-modal: Closed ──OPEN──► Open ──CLOSE──► Closed
std-search: Idle ──SEARCH──► Searching ──RESULTS──► Idle
std-filter: Idle ──FILTER──► Filtered ──CLEAR──► Idle

Molecules: Composed Atoms

Molecules combine atoms via wired events. A molecule is NOT a new behavior. It's atoms wired together.

std-list = std-browse + std-modal(create) + std-modal(edit) + std-modal(view)
└─ browse emits SELECT ──► view listens
└─ create emits SAVED ──► browse listens (refresh)
└─ edit emits SAVED ──► browse listens (refresh)

When you write uses List from "std/behaviors/std-list", the entire composition above is resolved at compile time.

Organisms: Full Applications

Organisms compose molecules into multi-page applications with cross-entity wiring.

std-ecommerce = std-list(Product) + std-cart(CartItem) + std-wizard(Checkout)
└─ Product browse emits ADD_TO_CART ──► Cart listens
└─ Cart emits CHECKOUT ──► Checkout listens
└─ Checkout emits ORDER_PLACED ──► Cart listens (clear)

Behavior Catalog

Atoms (50)

UI Interaction

BehaviorDescription
std-browseEntity list with fetch, render as data-grid or entity-cards
std-modalOpen/close overlay for create, edit, or view
std-drawerSlide-in panel from edge of screen
std-tabsTab switching with content panels
std-wizardMulti-step form with next/back navigation
std-confirmationYes/no dialog before destructive actions
std-displayRead-only entity detail view
std-inputForm input with validation
std-uploadFile upload with progress
std-galleryImage gallery with lightbox
std-flip-cardCard with front/back flip animation
std-ratingStar or numeric rating input
std-text-effectsAnimated text (typewriter, fade, etc.)
std-themeTheme switching (light/dark/custom)

Data Management

BehaviorDescription
std-searchSearch input with debounced query + filtered results
std-filterFilter controls that narrow a dataset
std-sortSort controls for column ordering
std-paginationPage navigation for large datasets
std-selectionMulti-select with checkboxes
std-undoUndo/redo stack for reversible actions
std-calendarDate picker / calendar view

Async + State

BehaviorDescription
std-asyncLoading/success/error state machine for async operations
std-loadingLoading spinner with timeout
std-timerCountdown or stopwatch
std-notificationToast notifications with auto-dismiss
std-cache-asideCache-aside pattern (check cache, fetch if miss)
std-circuit-breakerCircuit breaker for failing external calls
std-rate-limiterRate limiting for API calls

Game Core

BehaviorDescription
std-combatTurn-based or real-time combat system
std-movementGrid or free movement on a map
std-collisionCollision detection between game objects
std-physics2d2D physics simulation (gravity, velocity)
std-questQuest/mission tracking with objectives
std-overworldWorld map with location selection
std-gameflowGame state machine (menu, playing, paused, game-over)
std-spriteSprite animation with frame sequences
std-scoreScore tracking with multipliers

Game UI

BehaviorDescription
std-game-hudHeads-up display (health, mana, minimap)
std-score-boardLeaderboard / high scores
std-game-menuMain menu, settings, credits
std-game-over-screenGame over with retry/quit
std-dialogue-boxNPC dialogue with choices
std-inventory-panelInventory grid with drag-and-drop
std-combat-logScrolling combat event log
std-game-audioMusic and sound effect management

Game Canvas

BehaviorDescription
std-game-canvas2d2D canvas rendering loop
std-game-canvas3d3D canvas with Three.js integration
std-isometric-canvasIsometric tile-based game canvas
std-platformer-canvasSide-scrolling platformer canvas
std-simulation-canvasPhysics/particle simulation canvas

Molecules (18)

BehaviorComposed FromDescription
std-listbrowse + modal(create/edit/view)Full CRUD list with create, edit, view modals
std-detaildisplay + modal(edit)Detail view with inline editing
std-cartbrowse + selection + confirmationShopping cart with add/remove/checkout
std-inventorybrowse + selection + modalInventory management with stock tracking
std-messagingbrowse + input + asyncReal-time message list with send
std-geospatialbrowse + modal + mapLocation-based data with map markers
std-form-advancedwizard + input + validationMulti-section form with conditional fields
std-quizwizard + score + timerTimed quiz with scoring
std-turn-based-battlecombat + score + game-hudTurn-based battle system
std-platformer-gamemovement + collision + physics2dSide-scrolling platformer mechanics
std-puzzle-gameselection + score + timerPuzzle game with move counting
std-builder-gameselection + inventory + canvasBuilder/crafting game mechanics
std-classifier-gameselection + score + timerSorting/classification game
std-sequencer-gametimer + score + inputSequence memorization game
std-debugger-gamebrowse + selection + scoreBug-finding debugging game
std-negotiator-gamedialogue + score + timerNegotiation/dialogue game
std-simulator-gamesimulation-canvas + timer + scorePhysics simulation game
std-event-handler-gametimer + score + inputEvent-driven reaction game

Organisms (25)

BehaviorDomainDescription
std-ecommerceCommerceProduct catalog + cart + checkout
std-crmSalesContact/deal/pipeline management
std-lmsEducationCourse/lesson/progress tracking
std-cmsContentArticle/page/media management
std-helpdeskSupportTicket triage, investigation, resolution
std-hr-portalHREmployee/leave/review management
std-social-feedSocialPost/comment/like feed
std-project-managerPMTask/sprint/board management
std-booking-systemHospitalityRoom/slot/reservation management
std-finance-trackerFinanceTransaction/budget/report tracking
std-healthcareMedicalPatient/appointment/record management
std-realtime-chatCommunicationChat rooms with real-time messages
std-trading-dashboardFinanceMarket data + order execution
std-iot-dashboardIoTDevice monitoring + alerts
std-devops-dashboardDevOpsService health + deployment tracking
std-cicd-pipelineDevOpsBuild/test/deploy pipeline
std-api-gatewayInfrastructureRoute/rate-limit/auth management
std-coding-academyEducationInteractive coding lessons
std-stem-labEducationScience experiment simulations
std-logic-trainingEducationLogic puzzle training
std-rpg-gameGamingRole-playing game with quests + combat
std-platformer-appGamingFull platformer game application
std-puzzle-appGamingPuzzle game collection
std-strategy-gameGamingTurn-based strategy game
std-arcade-gameGamingClassic arcade game mechanics

Using Behaviors

Import a behavior with uses, rebind it to your entity with ->, and override specific event effects with on EVENT { ... }. The rest of the atom's state machine is inherited as-is.

Atom: Browse Only

orbital TaskOrbital {
uses Browse from "std/behaviors/std-browse"

entity Task [persistent: tasks] {
id : string!
title : string!
status : string
}

trait TaskBrowse = Browse.traits.BrowseItemBrowse -> Task {
on INIT {
(fetch Task)
(render-ui main {
type: "stack", direction: "vertical", gap: "lg",
children: [
{ type: "typography", content: "Tasks", variant: "h2" },
{ type: "entity-table", entity: "Task", fields: ["title", "status"] }
]
})
}
}

page "/tasks" -> TaskBrowse
}

Atoms Composed: Browse + Create

orbital TaskOrbital {
uses Browse from "std/behaviors/std-browse"
uses Modal from "std/behaviors/std-modal"

entity Task [persistent: tasks] {
id : string!
title : string!
status : string
}

trait TaskBrowse = Browse.traits.BrowseItemBrowse -> Task {
on INIT {
(fetch Task)
(render-ui main {
type: "stack", direction: "vertical", gap: "lg",
children: [
{ type: "typography", content: "Tasks", variant: "h2" },
{ type: "entity-table", entity: "Task", fields: ["title", "status"] }
]
})
}
}

trait TaskCreate = Modal.traits.ModalRecordModal -> Task {
events { OPEN: CREATE }
emitsScope internal
on CREATE {
(render-ui modal {
type: "modal", isOpen: true, title: "Create Task",
children: [{ type: "form-section", entity: "Task", fields: ["title", "status"], mode: "create" }]
})
}
on SAVE {
(persist create Task @payload.data)
(render-ui modal null)
(fetch Task)
(render-ui main {
type: "stack", direction: "vertical", gap: "lg",
children: [
{ type: "typography", content: "Tasks", variant: "h2" },
{ type: "entity-table", entity: "Task", fields: ["title", "status"] }
]
})
}
}

page "/tasks" -> TaskBrowse, TaskCreate
}

Pattern Integration

Behaviors use patterns from the pattern registry (233 patterns) for their render-ui effects. Each pattern maps to a React component:

Pattern CategoryExamplesUsed By
Data displaydata-grid, entity-table, entity-cards, data-liststd-browse
Formsform-section, form-field, form-wizardstd-modal, std-wizard
Navigationpage-header, breadcrumb, tabsstd-tabs, pages
Feedbackalert, toast, modal-dialogstd-notification, std-confirmation
Layoutstack, grid, sidebar-layoutAll organisms
Gamegame-canvas, game-hud, score-displayGame behaviors

Next Steps