Skip to content

Commit 8b24e2a

Browse files
Copilothotlong
andcommitted
Add comprehensive UI showcase examples with FormView, PageSchema, and enhanced component properties
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 83379b1 commit 8b24e2a

15 files changed

Lines changed: 1710 additions & 14 deletions

File tree

examples/ui-showcase/README.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# UI Showcase Examples
2+
3+
This example demonstrates the comprehensive UI capabilities of ObjectStack, including:
4+
5+
## 📋 FormView Examples
6+
7+
Demonstrates all 6 form layout types with advanced features:
8+
9+
- **Simple**: Basic sectioned forms with collapsible sections and 1-4 column layouts
10+
- **Tabbed**: Multi-tab forms for organizing complex data
11+
- **Wizard**: Step-by-step guided processes
12+
- **Split**: Master-detail split view
13+
- **Drawer**: Side panel forms
14+
- **Modal**: Dialog-based forms
15+
16+
### Form Features Showcased
17+
18+
- **Section Configuration**: Collapsible sections with 1-4 column layouts
19+
- **Field-Level Controls**:
20+
- `readonly` - Read-only fields
21+
- `required` - Required field validation
22+
- `hidden` - Conditionally hide fields
23+
- `colSpan` - Multi-column spanning (1-4)
24+
- `visibleOn` - Conditional visibility expressions
25+
- `dependsOn` - Cascading field dependencies
26+
- Custom `widget` - Custom field renderers
27+
- **Multiple Named Views**: Switch between different form layouts per scenario
28+
29+
## 📄 PageSchema Examples
30+
31+
Demonstrates component-based page layouts similar to Salesforce Lightning:
32+
33+
- **Record Pages**: Detail pages for individual records
34+
- **Home Pages**: Dashboard-style landing pages
35+
- **App Pages**: Application launcher pages
36+
- **Utility Pages**: Utility bar components
37+
38+
### Page Features Showcased
39+
40+
- **Template-Based Layouts**: Regions-based component composition
41+
- **Rich Component Types**:
42+
- `record:details` - Record detail view with 1-4 columns
43+
- `record:highlights` - Key field highlights (1-7 fields)
44+
- `record:related_list` - Related records list
45+
- `page:tabs` - Tabbed content areas
46+
- `page:accordion` - Collapsible panels
47+
- `ai:chat_window` - AI assistant integration
48+
- **Visibility Rules**: Component-level conditional visibility
49+
- **Profile Assignment**: Assign pages to specific user profiles
50+
51+
## 🧩 Component Properties
52+
53+
Comprehensive component property schemas:
54+
55+
- `RecordDetailsProps`: 1-4 columns, auto/custom layout modes
56+
- `RecordHighlightsProps`: 1-7 key fields highlighted
57+
- `RecordRelatedListProps`: Related object, columns, sorting, limits
58+
59+
## 📁 Structure
60+
61+
```
62+
ui-showcase/
63+
├── README.md (this file)
64+
└── src/
65+
├── objects/
66+
│ └── lead.object.ts (sample object for UI examples)
67+
├── views/
68+
│ └── lead.view.ts (all 6 form types + multiple list views)
69+
└── pages/
70+
├── lead_detail.page.ts (record page)
71+
├── home.page.ts (home page)
72+
├── app_launcher.page.ts (app page)
73+
└── utility_bar.page.ts (utility page)
74+
```
75+
76+
## 🚀 Usage
77+
78+
These examples serve as reference implementations demonstrating best practices for:
79+
80+
1. **Salesforce Developers**: Familiar patterns like Page Layouts and FlexiPages
81+
2. **Low-Code Builders**: Visual form and page composition
82+
3. **AI Agents**: Structured metadata for code generation
83+
84+
All examples follow ObjectStack naming conventions:
85+
- Configuration properties: `camelCase`
86+
- Machine names/identifiers: `snake_case`

examples/ui-showcase/package.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "@objectstack/example-ui-showcase",
3+
"version": "3.0.0",
4+
"private": true,
5+
"description": "Comprehensive UI examples showcasing FormView, PageSchema, and component capabilities",
6+
"type": "module",
7+
"main": "src/index.ts",
8+
"scripts": {
9+
"type-check": "tsc --noEmit"
10+
},
11+
"keywords": [
12+
"objectstack",
13+
"ui",
14+
"examples",
15+
"formview",
16+
"page",
17+
"components"
18+
],
19+
"author": "ObjectStack",
20+
"license": "Apache-2.0",
21+
"dependencies": {
22+
"@objectstack/spec": "workspace:*"
23+
},
24+
"devDependencies": {
25+
"typescript": "^5.9.0"
26+
}
27+
}

examples/ui-showcase/src/index.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* UI Showcase Examples
5+
*
6+
* Comprehensive examples demonstrating ObjectStack UI capabilities:
7+
* - FormView: All 6 layout types (simple, tabbed, wizard, split, drawer, modal)
8+
* - PageSchema: Component-based page layouts (record, home, app, utility)
9+
* - Component Properties: Rich component configuration
10+
*/
11+
12+
export * from './objects';
13+
export * from './views';
14+
export * from './pages';
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
export { Lead } from './lead.object';
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
import { ObjectSchema, Field } from '@objectstack/spec/data';
4+
5+
/**
6+
* Lead Object Definition
7+
*
8+
* A simplified Lead object used to demonstrate UI capabilities.
9+
* This object serves as the foundation for view and page examples.
10+
*/
11+
export const Lead = ObjectSchema.create({
12+
name: 'lead',
13+
label: 'Lead',
14+
pluralLabel: 'Leads',
15+
icon: 'user-plus',
16+
description: 'Potential customers not yet qualified',
17+
18+
fields: {
19+
// Basic Information
20+
salutation: Field.select(['Mr.', 'Ms.', 'Mrs.', 'Dr.'], {
21+
label: 'Salutation',
22+
}),
23+
24+
first_name: Field.text({
25+
label: 'First Name',
26+
required: true,
27+
searchable: true,
28+
}),
29+
30+
last_name: Field.text({
31+
label: 'Last Name',
32+
required: true,
33+
searchable: true,
34+
}),
35+
36+
company: Field.text({
37+
label: 'Company',
38+
required: true,
39+
searchable: true,
40+
}),
41+
42+
title: Field.text({
43+
label: 'Job Title',
44+
}),
45+
46+
// Contact Information
47+
email: Field.email({
48+
label: 'Email',
49+
required: true,
50+
unique: true,
51+
}),
52+
53+
phone: Field.text({
54+
label: 'Phone',
55+
format: 'phone',
56+
}),
57+
58+
mobile: Field.text({
59+
label: 'Mobile',
60+
format: 'phone',
61+
}),
62+
63+
website: Field.url({
64+
label: 'Website',
65+
}),
66+
67+
// Lead Classification
68+
status: Field.select({
69+
label: 'Lead Status',
70+
required: true,
71+
options: [
72+
{ label: 'New', value: 'new', color: '#808080', default: true },
73+
{ label: 'Contacted', value: 'contacted', color: '#FFA500' },
74+
{ label: 'Qualified', value: 'qualified', color: '#4169E1' },
75+
{ label: 'Unqualified', value: 'unqualified', color: '#FF0000' },
76+
]
77+
}),
78+
79+
rating: Field.rating(5, {
80+
label: 'Lead Score',
81+
description: 'Lead quality score (1-5 stars)',
82+
allowHalf: true,
83+
}),
84+
85+
lead_source: Field.select(['Web', 'Referral', 'Event', 'Partner', 'Advertisement'], {
86+
label: 'Lead Source',
87+
}),
88+
89+
industry: Field.select(['Technology', 'Finance', 'Healthcare', 'Retail', 'Manufacturing'], {
90+
label: 'Industry',
91+
}),
92+
93+
// Financial
94+
annual_revenue: Field.currency({
95+
label: 'Annual Revenue',
96+
scale: 2,
97+
}),
98+
99+
number_of_employees: Field.number({
100+
label: 'Number of Employees',
101+
}),
102+
103+
// Address
104+
street: Field.text({
105+
label: 'Street',
106+
}),
107+
108+
city: Field.text({
109+
label: 'City',
110+
}),
111+
112+
state: Field.text({
113+
label: 'State/Province',
114+
}),
115+
116+
postal_code: Field.text({
117+
label: 'Postal Code',
118+
}),
119+
120+
country: Field.select(['United States', 'Canada', 'United Kingdom', 'Germany', 'France', 'China', 'Japan'], {
121+
label: 'Country',
122+
}),
123+
124+
// Additional Information
125+
description: Field.markdown({
126+
label: 'Description',
127+
}),
128+
129+
notes: Field.richtext({
130+
label: 'Notes',
131+
description: 'Rich text notes with formatting',
132+
}),
133+
134+
// Assignment
135+
owner: Field.lookup('user', {
136+
label: 'Lead Owner',
137+
required: true,
138+
}),
139+
140+
// Privacy
141+
do_not_call: Field.boolean({
142+
label: 'Do Not Call',
143+
defaultValue: false,
144+
}),
145+
146+
email_opt_out: Field.boolean({
147+
label: 'Email Opt Out',
148+
defaultValue: false,
149+
}),
150+
},
151+
152+
enable: {
153+
trackHistory: true,
154+
searchable: true,
155+
apiEnabled: true,
156+
files: true,
157+
feeds: true,
158+
activities: true,
159+
trash: true,
160+
mru: true,
161+
},
162+
163+
titleFormat: '{first_name} {last_name} - {company}',
164+
compactLayout: ['first_name', 'last_name', 'company', 'email', 'status', 'owner'],
165+
});
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
import { Page } from '@objectstack/spec/ui';
4+
5+
/**
6+
* App Launcher Page
7+
*
8+
* Demonstrates an application launcher page similar to Salesforce App Launcher.
9+
*
10+
* Features:
11+
* - Grid-based app icon layout
12+
* - Global search
13+
* - Quick access to all apps
14+
*/
15+
export const AppLauncherPage: Page = {
16+
name: 'app_launcher_page',
17+
label: 'App Launcher',
18+
description: 'Central hub for accessing all applications',
19+
20+
type: 'app',
21+
22+
template: 'centered',
23+
24+
regions: [
25+
{
26+
name: 'header',
27+
width: 'full',
28+
components: [
29+
{
30+
type: 'global:search',
31+
id: 'app_search',
32+
label: 'Search Apps',
33+
properties: {},
34+
},
35+
],
36+
},
37+
38+
{
39+
name: 'main',
40+
width: 'large',
41+
components: [
42+
{
43+
type: 'page:header',
44+
id: 'launcher_header',
45+
label: 'App Launcher Header',
46+
properties: {
47+
title: 'App Launcher',
48+
subtitle: 'Select an app to get started',
49+
icon: 'th',
50+
breadcrumb: false,
51+
},
52+
},
53+
{
54+
type: 'app:launcher',
55+
id: 'app_grid',
56+
label: 'Application Grid',
57+
properties: {},
58+
},
59+
],
60+
},
61+
],
62+
63+
isDefault: false,
64+
assignedProfiles: ['sales_user', 'sales_manager', 'service_user', 'system_administrator'],
65+
66+
aria: {
67+
label: 'App Launcher Page',
68+
description: 'Central application launcher for accessing all apps',
69+
},
70+
};

0 commit comments

Comments
 (0)