Skip to content

Commit d2ae9e9

Browse files
committed
More stuff
1 parent df24478 commit d2ae9e9

13 files changed

Lines changed: 456 additions & 16 deletions

homedocs/meta/CONTENT.md

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ Category / Group / Page
2222
- Data Binding
2323
- Controllers
2424
- Formatting
25+
- Core Components
26+
- HtmlElement
27+
- PureContainer
28+
- ContentResolver
2529
- Authoring Widgets
2630
- Functional Components
2731
- Custom Components
@@ -58,9 +62,25 @@ Category / Group / Page
5862
- Advanced
5963
- Keyboard Shortcuts
6064
- Localization
65+
- DetachedScope
66+
- IsolatedScope
6167

6268
### Layout
6369

70+
- General Purpose
71+
- Button
72+
- LinkButton
73+
- Link
74+
- Icon
75+
- Heading
76+
- Text
77+
- Label
78+
- ProgressBar
79+
- Tabs
80+
- Resizer
81+
- HScroller
82+
- FlexBox
83+
- Section
6484
- App Layout
6585
- Outer Layouts
6686
- ContentPlaceholder
@@ -77,26 +97,11 @@ Category / Group / Page
7797
- Tooltip
7898
- Toast
7999
- MsgBox
100+
- FlyweightTooltipTracker
80101
- Menus
81102
- Menu
82103
- ContextMenu
83104
- Dropdown
84-
- Content
85-
- Tabs
86-
- Text
87-
- Label
88-
- Heading
89-
- Icon
90-
- Link
91-
- Button
92-
- LinkButton
93-
- ProgressBar
94-
- Scrolling
95-
- Resizer
96-
- HScroller
97-
- Containers
98-
- FlexBox
99-
- Section
100105

101106
### Forms
102107

@@ -105,14 +110,17 @@ Category / Group / Page
105110
- NumberField
106111
- TextArea
107112
- DateField
113+
- Calendar
108114
- DateTimeField
109115
- MonthField
116+
- MonthPicker
110117
- SelectField
111118
- LookupField
112119
- Checkbox
113120
- Radio
114121
- Switch
115122
- ColorField
123+
- ColorPicker
116124
- UploadButton
117125
- List
118126
- Slider
@@ -207,3 +215,4 @@ Category / Group / Page
207215
- Date
208216
- DOM
209217
- Misc
218+

homedocs/src/data/navigation.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ export const navigation = [
3030
{ title: "Formatting", slug: "formatting" },
3131
],
3232
},
33+
{
34+
title: "Core Components",
35+
items: [
36+
{ title: "HtmlElement", slug: "html-element" },
37+
{ title: "PureContainer", slug: "pure-container" },
38+
{ title: "ContentResolver", slug: "content-resolver" },
39+
],
40+
},
3341
{
3442
title: "Authoring Widgets",
3543
items: [
@@ -95,6 +103,8 @@ export const navigation = [
95103
items: [
96104
{ title: "Keyboard Shortcuts", slug: "keyboard-shortcuts" },
97105
{ title: "Localization", slug: "localization" },
106+
{ title: "DetachedScope", slug: "detached-scope" },
107+
{ title: "IsolatedScope", slug: "isolated-scope" },
98108
],
99109
},
100110
],
@@ -171,14 +181,17 @@ export const navigation = [
171181
{ title: "NumberField", slug: "number-field" },
172182
{ title: "TextArea", slug: "text-area" },
173183
{ title: "DateField", slug: "date-field" },
184+
{ title: "Calendar", slug: "calendar" },
174185
{ title: "DateTimeField", slug: "date-time-field" },
175186
{ title: "MonthField", slug: "month-field" },
187+
{ title: "MonthPicker", slug: "month-picker" },
176188
{ title: "SelectField", slug: "select-field" },
177189
{ title: "LookupField", slug: "lookup-field" },
178190
{ title: "Checkbox", slug: "checkbox" },
179191
{ title: "Radio", slug: "radio" },
180192
{ title: "Switch", slug: "switch" },
181193
{ title: "ColorField", slug: "color-field" },
194+
{ title: "ColorPicker", slug: "color-picker" },
182195
{ title: "UploadButton", slug: "upload-button" },
183196
{ title: "List", slug: "list" },
184197
{ title: "Slider", slug: "slider" },
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { createAccessorModelProxy } from "cx/data";
2+
import { DetachedScope } from "cx/widgets";
3+
4+
interface Model {
5+
scope1: { count: number };
6+
scope2: { count: number };
7+
}
8+
9+
const m = createAccessorModelProxy<Model>();
10+
11+
// @model
12+
export const model = {
13+
scope1: { count: 0 },
14+
scope2: { count: 0 },
15+
};
16+
// @model-end
17+
18+
// @index
19+
export default () => (
20+
<div className="flex gap-4">
21+
<DetachedScope bind={m.scope1}>
22+
<div className="p-4 bg-gray-100 rounded">
23+
<p>Detached Scope 1</p>
24+
<p text={m.scope1.count} />
25+
</div>
26+
</DetachedScope>
27+
28+
<DetachedScope bind={m.scope2}>
29+
<div className="p-4 bg-gray-100 rounded">
30+
<p>Detached Scope 2</p>
31+
<p text={m.scope2.count} />
32+
</div>
33+
</DetachedScope>
34+
</div>
35+
);
36+
// @index-end
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { createAccessorModelProxy } from "cx/data";
2+
import { IsolatedScope } from "cx/widgets";
3+
4+
interface Model {
5+
scope1: { count: number };
6+
scope2: { count: number };
7+
}
8+
9+
const m = createAccessorModelProxy<Model>();
10+
11+
// @model
12+
export const model = {
13+
scope1: { count: 0 },
14+
scope2: { count: 0 },
15+
};
16+
// @model-end
17+
18+
// @index
19+
export default () => (
20+
<div className="flex gap-4">
21+
<IsolatedScope bind={m.scope1}>
22+
<div className="p-4 bg-gray-100 rounded">
23+
<p>Isolated Scope 1</p>
24+
<p text={m.scope1.count} />
25+
</div>
26+
</IsolatedScope>
27+
28+
<IsolatedScope bind={m.scope2}>
29+
<div className="p-4 bg-gray-100 rounded">
30+
<p>Isolated Scope 2</p>
31+
<p text={m.scope2.count} />
32+
</div>
33+
</IsolatedScope>
34+
</div>
35+
);
36+
// @index-end
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { createAccessorModelProxy } from "cx/data";
2+
import {
3+
Checkbox,
4+
ContentResolver,
5+
DateField,
6+
LookupField,
7+
Switch,
8+
TextField,
9+
} from "cx/widgets";
10+
11+
// @model
12+
13+
interface Model {
14+
fieldType: string;
15+
text: string;
16+
date: string;
17+
checked: boolean;
18+
}
19+
20+
const m = createAccessorModelProxy<Model>();
21+
22+
const fieldTypes = [
23+
{ id: "textfield", text: "TextField" },
24+
{ id: "datefield", text: "DateField" },
25+
{ id: "checkbox", text: "Checkbox" },
26+
{ id: "switch", text: "Switch" },
27+
];
28+
29+
// @model-end
30+
// @index
31+
export default () => (
32+
<div className="flex items-center gap-4">
33+
<LookupField value={m.fieldType} options={fieldTypes} label="Field Type" />
34+
<ContentResolver
35+
params={m.fieldType}
36+
onResolve={(type) => {
37+
switch (type) {
38+
case "textfield":
39+
return <TextField value={m.text} />;
40+
case "datefield":
41+
return <DateField value={m.date} />;
42+
case "checkbox":
43+
return <Checkbox value={m.checked}>Checked</Checkbox>;
44+
case "switch":
45+
return <Switch value={m.checked} />;
46+
default:
47+
return null;
48+
}
49+
}}
50+
/>
51+
</div>
52+
);
53+
// @index-end
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { createAccessorModelProxy } from "cx/data";
2+
import { tpl } from "cx/ui";
3+
import { HtmlElement, TextField } from "cx/widgets";
4+
5+
interface Model {
6+
name: string;
7+
}
8+
9+
const m = createAccessorModelProxy<Model>();
10+
11+
// @model
12+
export const model = {
13+
name: "World",
14+
};
15+
// @model-end
16+
17+
// @index
18+
export default () => (
19+
<div>
20+
<h4 class="font-bold text-2xl">Heading</h4>
21+
<p>Paragraph with some text.</p>
22+
<HtmlElement tag="span">Using HtmlElement directly</HtmlElement>
23+
<hr />
24+
<TextField value={m.name} label="Name" />
25+
<p text={tpl(m.name, "Hello, {0|Stranger}!")} />
26+
</div>
27+
);
28+
// @index-end
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { createAccessorModelProxy } from "cx/data";
2+
import { LabelsTopLayout, PureContainer } from "cx/ui";
3+
import { Checkbox, TextField } from "cx/widgets";
4+
5+
interface Model {
6+
showContactInfo: boolean;
7+
email: string;
8+
phone: string;
9+
}
10+
11+
const m = createAccessorModelProxy<Model>();
12+
13+
// @model
14+
export const model = {
15+
showContactInfo: true,
16+
email: "",
17+
phone: "",
18+
};
19+
// @model-end
20+
21+
// @index
22+
export default () => (
23+
<div>
24+
<Checkbox value={m.showContactInfo}>Show contact information</Checkbox>
25+
<PureContainer visible={m.showContactInfo}>
26+
<div class="mt-2 font-bold">Contact Information</div>
27+
<LabelsTopLayout>
28+
<TextField value={m.email} label="Email" />
29+
<TextField value={m.phone} label="Phone" />
30+
</LabelsTopLayout>
31+
<p className="text-gray-500 text-sm mt-4">
32+
We'll never share your contact information.
33+
</p>
34+
</PureContainer>
35+
</div>
36+
);
37+
// @index-end
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
layout: ../../../layouts/DocsLayout.astro
3+
title: DetachedScope
4+
---
5+
6+
import ImportPath from "../../../components/ImportPath.astro";
7+
import CodeExample from "../../../components/CodeExample.astro";
8+
import Note from "../../../components/Note.astro";
9+
10+
import DetachedScopeExample from "../../../examples/concepts/DetachedScopeExample.tsx";
11+
import DetachedScopeExampleCode from "../../../examples/concepts/DetachedScopeExample.tsx?raw";
12+
13+
# DetachedScope
14+
15+
<ImportPath path="import { DetachedScope } from 'cx/widgets';" />
16+
17+
<Note type="info">
18+
For most performance optimization scenarios, consider using [PrivateStore](/docs/concepts/private-store) instead, which is more commonly used and easier to work with.
19+
</Note>
20+
21+
`DetachedScope` improves performance by detaching certain areas from the main render loop. Detached contents render in their own render loop and use a data declaration to specify which changes can flow in or out.
22+
23+
Use this for heavy components like grids, charts, or rich popups that might be negatively affected by other elements on the page.
24+
25+
<CodeExample code={DetachedScopeExampleCode}>
26+
<DetachedScopeExample client:load />
27+
</CodeExample>
28+
29+
## How It Works
30+
31+
1. The `bind` prop specifies the data paths this scope depends on
32+
2. The scope renders independently from the rest of the page
33+
3. Only changes to the bound data trigger re-renders inside the scope
34+
4. Changes inside the scope don't trigger re-renders outside
35+
36+
## Configuration
37+
38+
| Property | Type | Description |
39+
| -------- | ---- | ----------- |
40+
| `bind` | `string \| array` | Binding path(s) to monitor for changes. Shorthand for `data`. |
41+
| `data` | `object` | Data selector object. Children update only when this data changes. |
42+
| `exclusive` | `string \| array` | Paths for exclusive data that only affects this scope. |
43+
| `exclusiveData` | `object` | Exclusive data selector for data used only within this scope. |
44+
| `name` | `string` | Name of the scope for debugging purposes. |

0 commit comments

Comments
 (0)