Skip to main content
Version: v1 (Current)

Component patterns

The dashboard uses existing Mod components alongside v2 elements, visual-builder definitions and layout helpers. The Developer Hub and portal toolkit have their own components and context. Choose the actual consumer before copying a component/configuration example: a type registry, TypeScript interface or placeholder component is not proof of a working runtime feature.

For page composition and saves, start with ModUI page configuration. This guide explains how to inspect and extend the v2 component paths without assuming that every renderer shares one contract.

Source organization​

Under resources/js/Components/Mod/v2:

AreaResponsibility
CardElement.vueElement dispatch, model binding, visibility, snippet resolution and selected event forwarding
DisplayCard.vueA separate container dispatch implementation; inspect its completeness before using it
CardElements/Input, Boolean, option, picker, display, action, file/editor, configuration-block and builder implementations
DisplayCards/Container components with different implementation maturity
Definitions/Element/card interfaces, defaults and editor configuration objects
Composables/useCardElementLoader.tsElement component/default/edit-configuration mappings
Composables/useDisplayCardLoader.tsCard component/default/edit-configuration mappings
Store/Feature stores such as card-model and asset-picker state

Use actual files and mappings as the catalog. Do not rely on the previous guide's counts of components, composables or stores, or assume that a filename listed in a proposal exists.

Element dispatch​

CardElement accepts an element configuration and optional explicit overrides such as type and style. Its component lookup uses explicit type/style when truthy, otherwise those values from element. Common categories include input, boolean, display and option-select; styles select the concrete branch.

The dispatcher obtains a card-model store from injection or its default store. It derives render bindings for the selected element, handles visibility/conditions and forwards only configured event paths. A bare type string does not supply all resource bindings, state or required element values.

A schema fragment for a text element is:

{
"id": "first-name",
"type": "input",
"style": "text",
"name": "first_name",
"label": "First name",
"columns": 12
}

Place it through the supported builder/layout consumer with the required store context. name, ID, model value and stored form location are distinct concerns. Verify the actual rendered input and persisted data path rather than treating JSON presence as field initialization.

The dispatcher resolves snippet elements through the config-snippet store and can render the resolved element recursively. Missing or invalid snippet definitions need their own handling; a snippet placement does not import arbitrary code. See the page-configuration guide.

Direct component binding​

Concrete components can expose different contracts from the dispatcher. CardElements/Input/TextInput.vue uses a TypeScript TextInput definition/defaults and defineModel<string | number>(). An internal dashboard component can bind directly:

<template>
<TextInput v-model="firstName" id="example-first-name"
name="first_name" label="First name">
<template #label><label for="example-first-name">First name</label></template>
</TextInput>
</template>

<script setup>
import { ref } from 'vue'
import TextInput from '@/Components/Mod/v2/CardElements/Input/TextInput.vue'
const firstName = ref('')
</script>

This requires the platform's normal dependency/plugin environment; it is not a standalone public-page bundle. It changes local state, not a backend record. Direct TextInput use supplies its label through the label slot; the dispatcher normally provides that surrounding label UI. The component's labels, readonly handling, prefix/copy actions and internal value synchronization follow its implementation; verify the specific feature you enable.

defineModel() is a pattern used by these components, not a prohibition on explicit props/events elsewhere. Existing Mod components and action events still use their actual update:* or custom-event contracts. Follow the selected component rather than replacing working event APIs with a universal model rule.

Definitions, defaults and editor controls​

The real base interface is Definitions/CardElements/BaseElement.ts; input definitions build on InputElement and specific types such as Input/TextInput. The old InputType/BaseElementProps example was not the current source contract.

Definitions can contain identity, type/style, classes, columns, tooltip, preview and condition fields. Specific components add their own fields. Interface/default/editor-configuration objects serve different purposes: a field shown in an editor is not proof that every renderer consumes it, and a TypeScript declaration does not validate saved JSON or server input at runtime.

When adding an element, inspect all relevant mappings:

  1. Definition, defaults and editor controls.
  2. Concrete component props/model/events.
  3. useCardElementLoader component/default/edit mapping.
  4. CardElement render bindings and event forwarding.
  5. Builder/converter/serializer support and the installed consumer.

Adding only a Vue file or only a type option leaves other paths unimplemented. Verify unknown type/style behavior instead of relying on a default branch to validate the configuration.

Card dispatch is not v1 card schema​

The v2 display-card loader recognizes card-list, tab-list, element-list, element-display, datatable, info-card and grid-view. These are not the v1 fields_list, data_table or tabs_list examples from the previous guide. Defaults/edit mappings and component mappings are separate lookups.

In the reviewed source, DisplayCards/CardListCard.vue and ElementListCard.vue render empty placeholder containers. A registry mapping to those files therefore does not establish a functional nested-card or field layout. DisplayCard.vue also has its own dispatch/binding path; do not treat it as a drop-in replacement for the working builder/layout consumer without mounted verification.

Use the owning builder/layout implementation and page-builder reference for an actual page. For existing Mod cards, use the FormCard schema. Test a representative configured layout before migrating from v1 to a similarly named v2 type.

Conditions and permission-aware UI​

Conditions and permission checks decide presentation in particular consumers. CardElement uses the v2 display-condition helper, while the reviewed DisplayCard imports another condition helper. Do not assume every condition shape/operator is interchangeable.

The v2 helper treats a missing referenced field as visible for design mode. Its equality/array/order/blank checks have specific conversion rules. A field hidden in an editor, or visible because context is missing, is not a backend authorization boundary. Test populated and missing context, blank values, numeric/string values and actual denied principals separately.

Shared state and icons​

Use storeToRefs for reactive store state/getters; keep actions on the store. The asset-picker store under v2/Store/assetPickerStore.js exposes state such as assets and loading—the previous example's generic data property was not that store's contract. Its configured dashboard routes and resource cache do not establish portal access or arbitrary project isolation. Verify initialization/current project and clear/reload behavior when switching context.

For the reviewed v2 input/dispatcher paths, the icon import is:

import { lookupIcon } from '@/Composables/useAwesomeIcons'
const icon = lookupIcon('user', 'fas')

The helper resolves the configured Font Awesome sets and returns an empty object for an unresolved icon. Not every UI component must use this helper, and a glyph name does not install another icon package.

The codebase mixes scoped component CSS, framework utilities and theme variables. Check the consuming app's styles; classes and Developer Hub tokens are not universally portable to every portal or component package. Test responsive sizing, focus/keyboard behavior and actual labels after styling changes.

Stories and validation​

The platform package defines storybook (development port 6006), build-storybook, test:storybook and test:storybook:ci. Use the current local environment and testing guide for dependencies and browser setup. Script presence is not proof that Storybook or visual checks have run successfully.

Test the specific contract changed: props/model updates, missing/default values, conditional display, forwarded events and store/context changes. Compile-checking a Vue example proves syntax, not mounting, accessibility, network behavior or persistence. A condition-helper unit test also does not certify every dispatcher/card renderer.

Troubleshooting​

SymptomInspect
New type is listed but renders nothingConcrete implementation, placeholder containers, loader and dispatcher mappings
Field displays but model does not updateSelected component's model/event API, store injection and actual render bindings
Event never reaches pageConcrete emit name, dispatcher forwarding and parent listener
Saved configuration differs from previewConsumer/version, defaults, conversion and runtime support
Missing context unexpectedly shows an elementDesign-mode condition fallback, separately from endpoint authorization
Asset/icon example failsActual store property/import path, initialized context and available icon set

Related references: field schema, field types, DataTable, composables and page authoring.