Skip to content
ccmjsPublic

About

An embeddable ccmjs component for real-time team formation. Participants can join, leave, switch, and rename teams. Organizers can set team sizes and lock membership.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

21 Commits

Folders and files

Repository files navigation

Teambuild

A ccmjs v29 component for collaborative team formation, with optional authentication, configurable team rules, responsive team cards and safe concurrent updates. Component logic and incremental UI updates live in ccm.teambuild.mjs; HTML templates live in resources/views.mjs, and labels and icons in resources/content.mjs. These resources, the stylesheet and the bundled, versioned ccm-ui module are loaded through ccm.load dependencies. No build step is required. See the changelog for release notes and migration instructions.

Embedding

From the CDN (v2.0.0)

Paste this snippet into your page and replace https://your-ccm-server.example with your CCM server URL. Teambuild and User share ccmjs v29.1.0. Each URL and its SHA-384 integrity value refer to a specific release.

<script src="https://cdn.jsdelivr.net/gh/ccmjs/framework@v29.1.0/ccm-29.1.0.min.js"
        integrity="sha384-+Ra3mH+gwP++yhMqYTOSnzIpDlhdMQINbkbEI8POBy4y7CYFng/c+KxtSJXiLsJA"
        crossorigin="anonymous"></script>
<div id="teams"></div>
<script type="module">
  const teambuild = "https://cdn.jsdelivr.net/gh/ccmjs/teambuild@v2.0.0/ccm.teambuild-2.0.0.min.mjs#sha384-ofRNyvUlTqpTL6LWlyfAsWDVi1f/b+MOhwwwuP8USUpwWoRyZ1myZydkja/G6Yzg";
  const user = "https://cdn.jsdelivr.net/gh/ccmjs/user@v1.2.0/ccm.user-1.2.0.min.mjs#sha384-N32UlGOG7Y4YaHbgnuRMpia9fzSqdJV+TpuuX2nmUEKZT8nYYAGTg30rMi/wjHpJ";
  const url = "https://your-ccm-server.example";
  const key = "seminar";

  await ccm.start(teambuild, {
    data: { store: ["ccm.store", { name: "teambuild", url, observe: { key } }], key },
    user: ["ccm.instance", user, {
      url, realm: "ccm"
    }],
    maxMembers: 4
  }, document.querySelector("#teams"));
</script>

From a local checkout

<script src="./libs/framework/ccm-29.1.0.min.js"></script>
<div id="teams"></div>
<script type="module">
  await ccm.start("./ccm.teambuild.mjs", {
    data: {
      store: ["ccm.store", {
        name: "teambuild",
        url: "https://your-ccm-server.example",
        observe: { key: "seminar" }
      }],
      key: "seminar"
    },
    user: ["ccm.instance", "./libs/user/ccm.user-1.2.0.min.mjs", {
      url: "https://your-ccm-server.example",
      realm: "ccm"
    }],
    maxTeams: 6,
    maxMembers: 4,
    teamNames: ["Idea Workshop", "New Perspectives", "Future Lab"]
  }, document.querySelector("#teams"));
</script>

The server must support the ifMatch write option described below. Deploy the accompanying extension in ccm-server/lib/data.mjs on the server. The bundled ccmjs v29 framework forwards this option. The component never falls back to unconditional overwrites.

index.html provides an interactive demo using the English demo preset. Open the page through an HTTP server. The demo uses CCM accounts only. Participants can register a new account or sign in with their CCM username and password. Authentication and team data use https://kless.inf.h-brs.de/api/. Teams are stored in the teambuild datastore under the demo key and survive page reloads. WebSocket observation is enabled: joins, departures and name changes appear automatically in every open demo instance. Without an existing dataset, the demo starts with one empty team; the first join creates the dataset on the server. Once signed in, users can join, switch teams, leave and rename their own team.

Load the preset with ["ccm.load", "./resources/configs.mjs#demo"]. Keep the observation key equal to data.key and point authentication and data access at the same backend.

When user is configured, the User component renders its own sign-in button and, after authentication, profile and sign-out controls at the top right of the toolbar. Its dialog remains mounted while teams refresh. Without user, there is no login area and the team formation is read-only.

Configuration

Property Default Description
data.store ["ccm.store"] Dedicated CCM accessor per instance; defaults to isolated in-memory storage
data.key "teambuild" One dataset per formation; compound CCM keys are also supported
data.permissions See below Access metadata applied when creating the dataset; null omits it
user Not set Optional User component; login controls on the right of the toolbar
avatarSize 96 Maximum thumbnail edge in pixels for a copied private profile upload
maxTeams 0 Maximum number of teams; 0 means unlimited
maxMembers 0 Maximum members per team; 0 means unlimited
teamNames [] Preset names in team order
joinable true Users may join teams
leavable true Members may leave their current team
allowSwitch true Direct team switching; checks both departure and joining rules
editable true Members may rename their own team
nameMaxLength 60 Maximum length of an edited team name, using JavaScript string length
teamOverrides [] Per-team rules; index 0 applies to team 1
refreshInterval 30000 Background reconciliation interval in milliseconds when observation is enabled; 0 disables the timer
retryLimit 12 Maximum conditional-write attempts per action, including the initial attempt
ui Bundled ccm-ui 1.0.0 HTML templates, trusted SVG interpolation and declarative event binding
views ["ccm.load", "././resources/views.mjs"] Template module for the shell, team, member, free seat, button, image and editor; partial overrides are merged
css Stylesheet dependency Replace or extend the styling through ccm.load
root (ccmjs) Open shadow root Set to false for light DOM and supply a stylesheet scoped to your embedding container
theme {} CSS custom-property overrides without the --tb- prefix
onchange Not set Callback after a successful local join, leave or rename action
onerror Not set Callback for loading, saving, observation, profile-image and extension errors
icons ["ccm.load", "././resources/content.mjs#icons"] Button icons as trusted inline SVG markup, text symbols or empty strings; partial overrides are merged
labels ["ccm.load", "././resources/content.mjs#labels.en"] English interface text, accessible names, hints and error messages; use #labels.de for German; partial overrides are merged

Every configuration property is documented in the component's config, including nested permissions, team override fields, theme keys, units and optional callback arguments. resources/content.mjs documents each label, its placeholders and each icon beside its default value. Partial overrides are supported for labels, icons, theme and views. Functions are needed for optional callbacks and custom templates; ordinary text, icon and theme changes use plain configuration values.

{
  theme: { accent: "#6045a0", "accent-hover": "#49327f", radius: "14px" },
  icons: { join: "+", leave: "↗", refresh: "↻" },
  labels: { join: "Join", leave: "Leave team", refresh: "Refresh" }
}

content.mjs exports complete language maps as labels.en and labels.de, plus the shared icons object. To switch from the default English labels to German:

labels: ["ccm.load", "././resources/content.mjs#labels.de"]

A custom content module may export a flat label map and icons, loaded through labels: ["ccm.load", "./resources/my-content.mjs#labels"] and icons: ["ccm.load", "./resources/my-content.mjs#icons"]. In init(), omitted entries are filled from the English labels and default icons. Supplied values take precedence, including empty strings. Each instance receives independent label and icon maps. The browser reuses the imported module; content is not loaded during UI updates.

The default layout uses the ccmjs tiles in the toolbar and rename dialog. Blue marks primary actions, green marks live updates and membership, and yellow marks empty teams. Set theme.logo to a CSS image such as url("/assets/logo.svg"). Use positive and highlight for the green and yellow accents. Additional theme keys are background, surface, text, muted, border and font. Supported label placeholders are {number} in team and teamNumber, {team} in joined, and {max} in invalidName. Team names and member names are always rendered as text.

Team slots and rules

Team numbering starts at 1. Exactly one additional empty team slot appears after the last occupied team, unless maxTeams has been reached. Joining that slot makes the next one visible. Empty slots between occupied teams remain available; multiple empty slots at the end are collapsed into one visible slot. Their stored names are preserved. Preset names alone do not create additional team cards.

When team capacity is limited, the member list includes an entry for each empty seat. Customize its text through labels.emptyMember. Unlimited teams (maxMembers: 0) do not show empty seats. These placeholders are neither counted as members nor stored in the dataset.

A person can belong to only one team at a time. Switching teams is saved as one atomic change. It requires leavable on the current team and joinable on the target team. Lowering limits never removes existing members or occupied teams; it restricts subsequent joins.

{
  joinable: false,
  leavable: false,
  editable: false,
  teamOverrides: [
    { joinable: true, leavable: true }
  ]
}

This closes team formation except for joining and leaving the first team. That team's name remains locked. Each explicit per-team rule overrides its global setting; omitted rules inherit the global value.

Without user, the component is read-only. With a User component, participants must sign in before making changes. Any member may rename their own team when editable allows it. Identity is based on realm:key, so identical display names do not cause collisions. Authentication tokens are never stored in the team data.

Changes to a published app configuration apply to newly loaded instances. Already open instances do not reload their configuration automatically. An embedding application can also update rules on the instance and then call app.start().

Data and permissions

The component stores one complete dataset:

{
  key: "seminar",
  schema: 1,
  revision: 3,
  mutation: "unique-id-of-the-last-change",
  teams: [
    { name: "Idea Workshop", members: [
      { id: "ccm:account_key", name: "Lea Sommer", picture: "https://example.org/lea.jpg" }
    ] }
  ],
  _: {
    owner: "ccm:teacher_key",
    access: { get: "all", set: "realm", del: "owner" }
  }
}

name: null uses the configured name or the fallback Team {number}. A team's array index is its stable team number minus one. revision records the sequence of changes; conflict detection compares the entire dataset. mutation identifies a completed write even if its HTTP response was lost. Opening the page alone does not create a dataset. Unknown data formats are never replaced automatically.

When joining or switching teams, the display name is copied from user.getState().user, falling back to the account key. An available picture URL is also stored and displayed as the member's avatar. Missing or failed images fall back to initials. These values are snapshots taken when joining; existing member records are not automatically synchronized with later profile changes. HTTP(S) image URLs and raster image data URLs are supported.

For local CCM accounts with user.profilePicture enabled, a private uploaded image is retrieved through the account and download APIs and copied into the member record as a thumbnail data URL. This copy is visible to everyone allowed to read the formation; the original file retains its private permissions. Tokens and tab-local blob URLs are never stored. A missing or unavailable image does not prevent joining; the component uses initials instead.

By default, the first join applies data.permissions with { access: { get: "all", set: "realm", del: "owner" } }, and the first creator becomes the owner. For a teacher-owned formation, the teacher should first create an empty dataset through their authenticated datastore:

await teacherStore.set({
  key: "seminar", schema: 1, revision: 0, teams: [],
  _: { access: { get: "all", set: "realm", del: "owner" } }
}, undefined, { ifMatch: null });

The backend supplies the owner's identity. Existing permissions are preserved during subsequent changes. To restrict participation, set can reference a CCM group instead of "realm".

editable, joinable, leavable and team limits are component UI rules, not server-enforced field permissions. Clients with write access could submit other changes through the general datastore API. To enforce a final formation, the owner must also restrict write access on the server, for example with set: "owner" or a CCM schedule. The backend's general dataset permissions cannot enforce individual team rules as a security boundary.

Realtime updates and safe concurrent writes

observe: { key: "seminar" } enables WebSocket observation in the remote datastore. The server address remains an HTTP(S) URL: ccmjs writes through HTTP and uses the WebSocket for notifications. Without observe, use the refresh button to load changes. With server-confirmed live observation, the button appears as an icon with a tooltip and accessible name. Its text remains visible without realtime, while connecting or when the connection has problems. Clicking it reloads the current dataset and restarts an interrupted or incomplete live connection. Once the server acknowledges observation, missed changes are reloaded and subsequent changes arrive automatically again.

The bundled ccmjs v29.1.0 framework exposes the observation state through getConnectionState() and onconnectionchange. With a framework that does not provide this interface, the button text remains visible. It also remains visible when icons.refresh is empty.

Window focus and network recovery also trigger reconciliation. In realtime mode, refreshInterval supplements notifications with periodic reads so that changes missed during an interruption can be recovered.

Notifications schedule a fresh dataset read; bursts are combined with a 40 ms debounce. Their payloads are not used as replacement state because CCM deletion notifications can contain the old dataset. Read responses that predate a local mutation are discarded. A notification arriving during a read or write schedules a subsequent read. The login area and an open team-name draft remain mounted during updates.

Rendering reuses team cards by their stable team number and member rows by their realm:key identity, including when a member switches teams. Only changed text, icons, images, button states and list positions are updated. When data and UI state are unchanged, refreshes leave the DOM untouched. Unchanged avatar URLs are not reassigned. Empty seats, team slots and member rows are inserted or removed as needed. Counters and connection controls are updated independently. Reconciliation still scans all visible teams and members, including their current UI rules; it updates only changed DOM values while preserving the full dataset read.

Safe writes use an atomic comparison condition:

const before = await store.get("seminar");
const after = structuredClone(before);
// Apply the intended change to after.
await store.set(after, undefined, { ifMatch: before });

The server first checks the current read and write permissions. Within its write queue, it compares before with the current dataset. If they match, the change is saved. Otherwise, it returns HTTP 409 without modifying data or notifying observers. ifMatch: null means: create only if no dataset with this key exists.

Two concurrent joins therefore cannot overwrite each other based on the same old member list. After a 409 response, the second client rereads the dataset, rechecks the rules and available seats, and applies its join to the latest state. If the last seat has already been taken, it displays the corresponding message. Conflicting edits to the same team name are reported explicitly; the local draft is preserved so the user can review and retry deliberately.

The actor's original team and the name seen when editing began remain fixed across automatic retries. An HTTP 409 may be retried; membershipConflict, nameConflict or teamFull require the user to review the new state. If a write's response is lost, the component looks for its action ID in mutation. A later action may already have replaced that ID, so an unmatched ID cannot confirm success or failure. The component reports the uncertainty, marks the view stale and disables UI actions until a successful read. It does not automatically resend that uncertain write.

Comparison and saving are serialized together. This guarantee applies to the CCM backend's supported operation with one server process per database, with all writes passing through that server. Multiple server processes or direct database writes require an additional database-level mechanism. All participating team formation clients must use conditional writes.

For local IndexedDB storage, the Web Locks API coordinates changes across tabs of the same origin. IndexedDB writes are rejected if that API is unavailable. Unnamed in-memory stores are isolated per instance and do not provide collaboration across devices. Use the CCM server for collaboration between remote clients.

Each Teambuild instance requires its own datastore accessor. Prefer configuring data.store with a ccm.store dependency, which creates an accessor for each instance. An existing accessor must be dedicated to that instance; sharing one store object between Teambuild instances is unsupported, even for different keys. Separate accessors may use the same remote datastore and dataset key: each receives its own realtime notifications, while server-side ifMatch checks protect concurrent writes. IndexedDB accessors using the same store/key remain coordinated by Web Locks. In-memory writes are serialized only within the owning instance by its busy flag.

Instance API

Method Effect
start() Mount the UI or reload the current state
refresh() Reload the dataset
refresh({ silent: true }) Reload without the normal success announcement; errors and recovery remain visible
refresh({ reconnect: true }) Also rebuild an interrupted or stalled live connection
getValue() Return a detached copy of the current dataset
getTeams() Return visible teams, including the empty slot and their effective rules
join(1) Join team 1 or switch to it
leave() Leave the current team
rename(1, "New name") Rename the user's own team
rename(1, "New name", "Original name") Also require the name seen when editing began; useful for an external form
destroy() Remove owned timers and listeners and unmount the UI

Mutation methods are asynchronous, enforce the same rules as the UI and reject on errors; they resolve without returning a dataset. Use getValue() after an action to inspect its local snapshot. onchange({ app, type, value }) receives join (including switches), leave or rename; incoming notifications do not invoke it. onerror({ app, error }) receives errors. Returned datasets and team lists are detached copies. An externally supplied, dedicated accessor remains owned by the embedding application; its callbacks are restored when the instance is destroyed.

An already satisfied action does not write: joining the current team, leaving when already outside all teams, or saving the current name resolves without a revision increment. Domain conflicts reject with error.code; HTTP failures may carry error.status.

Calling refresh() during a local action queues a later read; that call resolves without waiting for the queued read. Overlapping refreshes share the active read and request a subsequent one. gui exposes diagnostics for consumers to read: busy indicates an active local action, stale marks a failed read or uncertain write, and connection is disconnected, connecting or connected. A successful HTTP read alone does not imply a working live subscription.

Developer guide

Start with ccm.teambuild.mjs. Its config documents the public options; the Instance constructor owns the lifecycle, I/O and private helpers. Only component is exported; all component logic is encapsulated within it. The following entry points explain the main flows:

Responsibility Entry points and invariant
Lifecycle init() normalizes options; ready() attaches listeners; start() mounts once and reads; destroy() detaches owned resources
Incoming changes scheduleRefresh() → refresh() → render(); the datastore remains authoritative
User actions join() / leave() / rename() → mutate() → applyAction() → conditional write
Domain rules visibleTeams(), memberTeam(), teamName() and applyAction() derive team slots and enforce membership rules without I/O
Templates resources/views.mjs exports HTML factories loaded through config.views; createView() caches their data-ref elements and binds their data-on-* events once
Rendering render() reuses records from teamViews / memberViews; renderTeam() and renderMember() patch them; reconcileChildren() retains and orders nodes
Datastore lifecycle mutate() locks IndexedDB writes; ready() attaches to the dedicated accessor; life.abort() restores callbacks during destruction

state holds the latest accepted dataset. The saved revision counts changes; the instance-local readVersion invalidates outdated responses. Keep these separate: concurrent writes compare the entire snapshot through ifMatch, not either counter alone.

Team numbers are stable array positions plus one. Keep empty stored teams so their names and identities survive later reuse. Member rows are keyed globally by realm:key, allowing the same element to move between teams. Remove obsolete member views only after processing all teams. Retained event handlers must read current action/view state rather than capture outdated permissions or names.

The private domain helpers require validated input and complete options, including defaults. applyAction() returns a new dataset with one revision increment, returns null when the intent is already satisfied, or throws an error with a domain code. It does not authenticate, lock or save; embedding applications should normally use the instance methods for those responsibilities.

Each constructor owns its callbacks and state; there is no shared accessor registry. ready() preserves existing external callbacks and replaces CCM's automatic parent.start callback with a debounced read. The life AbortController removes browser and User listeners and restores datastore callbacks on destruction. It restores only callbacks that still belong to this instance. A component-created accessor is closed on destruction; an externally supplied accessor stays open and remains the embedding app's responsibility.

resources/styles.css groups styles by the toolbar, cards, members, buttons and editor. The CCM content element (.root) holds the theme variables, typography, outer spacing and named query container. All component styles are nested under .root and scoped by the instance's shadow root. In DevTools, data-ccm-component="teambuild" identifies the outer host. The toolbar switches to a compact layout at 620 px of available content width.

With root: false, the component and the page share the same CSS scope. For example, when mounting in <div id="seminar-teams"></div>, set css: ["ccm.load", "./seminar-teams.css"] alongside root: false. To keep the bundled layout, copy resources/styles.css into that file and change its outer selector from .root to #seminar-teams > div > .root. The intermediate div is the host element created by ccmjs.

index.html loads the demo preset from resources/configs.mjs through CCM. The libs/ directory contains bundled dependencies. Component behavior belongs in the component source, HTML structure in resources/views.mjs, styling in the stylesheet, text and icons in resources/content.mjs, and theme overrides in config.theme.

HTML templates

When updating a dependency in libs/, include its versioned readable and minified files, source map and license together. For ccm-ui, config.ui loads ccm-ui-1.0.0.min.mjs through CCM. config.views loads resources/views.mjs, which exports each default factory by name. Every factory receives the instance as app and returns one fresh detached Element synchronously through app.ui.html. Do not return a Promise, multiple roots or a previously used element. Ordinary label, icon and color changes belong in labels, icons and theme; override a template to change its markup.

Creation and updates

The component uses two separate operations:

  1. createView(name, data, required) calls the factory, finds the required data-ref descendants and binds data-on-* events. Its result is a view record such as { root, title, list, ... } containing references to actual DOM elements.
  2. The internal render() calls renderTeam() and renderMember(), which look up their retained records and create views only when missing. These functions and updateButton() compare current values before writing text, attributes or properties. reconcileChildren() inserts, removes or moves existing elements to match the required child order.

ccm-ui supplies HTML creation and event binding; the component implements the incremental updates. In particular, ui.render(content, target) replaces the target's children. It is used to mount the shell, install a newly opened editor form and replace changed icon content. The internal render() never uses it to replace the team grid.

Cards, members, buttons and free seats all use the same { root, ...refs } record shape. A card owns its button and seat records directly; no separate button registry is needed. Derived team descriptors borrow member arrays internally; getTeams() returns a detached copy so public callers cannot change the accepted snapshot.

The shell is created on the first start(). Cards are cached by team number; member rows are cached across each instance's teams by realm:key, allowing the same row and avatar to move between teams. Each card retains its buttons and free seats. Cards and member rows absent from the complete visible team list are released; a later reappearance creates a new view. Optional badges and edit buttons stay cached while detached from a retained card. A changed valid picture URL creates a new image, while an unchanged URL preserves the existing image. The editor form is created on each opening inside the persistent dialog; incoming updates leave its draft value intact. Calling start() again refreshes the existing UI rather than rebuilding its templates.

For example, a remote rename follows this path:

notification → scheduleRefresh() → refresh() → full store.get(data.key)
             → validate and accept state → render()
             → renderTeam(latestTeam, ...) → reuse teamViews.get(number)
             → setProperty(view.title, "textContent", latestTeam.name)

This updates the existing title without calling the team factory or rebinding its buttons. A team switch similarly moves the existing member row. All visible teams and members are still scanned, even when no DOM value changes. Changes to login, connection, busy or stale state also trigger render() without new team data.

When adding a live field, add its template anchor, include it in the owning createView() call's required references and patch it in renderTeam(), renderMember() or updateButton(). Template interpolation runs only at creation. Use the comparison helpers for leaf values and reconcileChildren() for ordered child lists. Do not skip rendering solely because the dataset revision is unchanged: configuration, authentication and connection state may have changed independently.

Template interpolations run only at creation. For example, a custom ${member.name} outside the managed name anchor would become stale after a metadata change. Use the existing anchors for dynamic content. Adding a new dynamic field requires a corresponding update in the relevant render function; there is no automatic binding between interpolations and later snapshots.

Template contract

Factory Second argument Required descendant data-ref anchors
main(app) None content, grid, status, dialog, sync, syncMode, teamCount, teamLabel, peopleCount, peopleLabel; also user when authentication is configured
team(app, { number }) Stable 1-based team number top, caption, badge, heading, title, list, empty, emptyText, emptyHint, footer
member(app, member) Public member snapshot avatar, name, you
seat(app) None label
button(app) None icon, label
image(app) None None; return an img element
editor(app, team) Current visible-team descriptor name, error, actions

Treat the second argument as read-only. A member has id, name and optional picture; the editor's team has number, resolved name, members, editable, joinable and leavable. These arguments may reference accepted state; factories create DOM elements and must not change membership or saved metadata.

Each required anchor must occur exactly once inside its view. Missing or duplicate anchors produce a descriptive error. Names are scoped to the view, so name in a member and name in the editor do not conflict. The root itself is not searched for anchors. References are captured before optional elements are detached; keep all required anchors in the initial template, even an initially hidden badge or you marker. The renderer decides when to attach them.

The element types and nesting below are part of the contract, but are not checked by anchor validation. Keep the default semantic elements, including the dialog, editor form and input, buttons and list items, together with their accessibility attributes.

  • The renderer owns these entire direct child lists: grid contains team cards; each card contains top, heading, list or empty, and footer; top contains caption and the optional badge; heading contains title and the optional edit button; list contains member and seat rows; a member row contains avatar, name and the optional you marker. Extra children or wrappers in these lists are removed by reconcileChildren(), including whitespace text nodes.
  • Text anchors such as title, name and label receive textContent updates; nested markup inside them is replaced. A button's icon contents are replaced when its configured icon changes. Keep member avatar anchors empty initially: the component inserts initials and an optional image.
  • Keep grid, user, footer, dialog and editor actions empty for component-owned content. The refresh button is appended to sync. Static additions may live in unmodified areas such as inside empty, alongside its retained text anchors. Preserve the standard CSS classes with the bundled stylesheet; additional card and button classes are retained.

Keep data-on-click="action" on button roots. It binds to instance.events.action once; the handler reads the current data-action and nearest card's data-team. For example, a retained switch button becomes a leave button through updateButton() without changing its listener. The component assigns these data attributes; keep team actions inside their card. The editor form uses data-on-submit="saveName" (including Enter submission); the dialog uses data-on-cancel="cancelEditor" and data-on-close="closedEditor"; avatar images use data-on-error="imageError". Save remains a native submit button.

createView() binds each new view before it is inserted. The User host is inserted after the shell is bound, keeping its own handlers independent. Do not rebind the whole shell on refresh or replace instance.events: existing views keep their bindings. Use data-ref for cached element references and data-on-* for events; neither makes template text reactive.

Overriding a template

For example, replace only the free-seat template:

views: {
  seat: app => app.ui.html`
    <li class="member member-empty">
      <span class="avatar" aria-hidden="true">○</span>
      <span class="member-name" data-ref="label"></span>
    </li>
  `
}

Alternatively, load a module with the matching named exports using views: ["ccm.load", "./resources/my-views.mjs"]. Omitted factories retain their defaults: init() loads the standard module through ccm.load when a supplied object or module is incomplete, then merges the overrides over those defaults. The normal default configuration and complete custom modules need no extra load. Supply overrides when creating the instance; replacing a factory later does not rebuild existing views, even after start() or refresh(). Normal interpolations escape text and quoted attributes. ui.raw() is reserved for trusted configuration SVGs, never team names or other user input.

About

An embeddable ccmjs component for real-time team formation. Participants can join, leave, switch, and rename teams. Organizers can set team sizes and lock membership.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages