@ea-lab/reactive-json-docs 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README-npm.md +49 -0
- package/README.md +86 -0
- package/package.json +79 -0
- package/public/rjbuild/component-doc/chartjs/components.yaml +252 -0
- package/public/rjbuild/component-doc/chartjs/overview.yaml +51 -0
- package/public/rjbuild/component-doc/core/action/HashChangeListener.md +90 -0
- package/public/rjbuild/component-doc/core/action/HashChangeListener.yaml +124 -0
- package/public/rjbuild/component-doc/core/action/Hide.md +22 -0
- package/public/rjbuild/component-doc/core/action/Hide.yaml +60 -0
- package/public/rjbuild/component-doc/core/action/MessageListener.md +93 -0
- package/public/rjbuild/component-doc/core/action/MessageListener.yaml +153 -0
- package/public/rjbuild/component-doc/core/action/Popover.md +26 -0
- package/public/rjbuild/component-doc/core/action/Popover.yaml +100 -0
- package/public/rjbuild/component-doc/core/action/ReactOnEvent.md +81 -0
- package/public/rjbuild/component-doc/core/action/ReactOnEvent.yaml +133 -0
- package/public/rjbuild/component-doc/core/action/Redirect.md +20 -0
- package/public/rjbuild/component-doc/core/action/Redirect.yaml +68 -0
- package/public/rjbuild/component-doc/core/action/Tooltip.md +22 -0
- package/public/rjbuild/component-doc/core/action/Tooltip.yaml +90 -0
- package/public/rjbuild/component-doc/core/action/VisuallyHide.md +21 -0
- package/public/rjbuild/component-doc/core/action/VisuallyHide.yaml +62 -0
- package/public/rjbuild/component-doc/core/action/index.md +214 -0
- package/public/rjbuild/component-doc/core/action/index.yaml +278 -0
- package/public/rjbuild/component-doc/core/element/form/CheckBoxField.md +276 -0
- package/public/rjbuild/component-doc/core/element/form/CheckBoxField.yaml +338 -0
- package/public/rjbuild/component-doc/core/element/form/DateField.md +189 -0
- package/public/rjbuild/component-doc/core/element/form/DateField.yaml +264 -0
- package/public/rjbuild/component-doc/core/element/form/NumberField.md +136 -0
- package/public/rjbuild/component-doc/core/element/form/NumberField.yaml +103 -0
- package/public/rjbuild/component-doc/core/element/form/SelectField.md +304 -0
- package/public/rjbuild/component-doc/core/element/form/SelectField.yaml +360 -0
- package/public/rjbuild/component-doc/core/element/form/TextAreaField.md +134 -0
- package/public/rjbuild/component-doc/core/element/form/TextAreaField.yaml +146 -0
- package/public/rjbuild/component-doc/core/element/form/TextField.md +129 -0
- package/public/rjbuild/component-doc/core/element/form/TextField.yaml +147 -0
- package/public/rjbuild/component-doc/core/element/form/formElementsCommon.md +106 -0
- package/public/rjbuild/component-doc/core/element/form/index.md +50 -0
- package/public/rjbuild/component-doc/core/element/form/index.yaml +96 -0
- package/public/rjbuild/component-doc/core/element/html/AccordionItem.yaml +47 -0
- package/public/rjbuild/component-doc/core/element/html/FolderSortableTree.yaml +81 -0
- package/public/rjbuild/component-doc/core/element/html/FormatNumeral.yaml +58 -0
- package/public/rjbuild/component-doc/core/element/html/Html.yaml +67 -0
- package/public/rjbuild/component-doc/core/element/html/LabelFromValue.yaml +54 -0
- package/public/rjbuild/component-doc/core/element/html/Modal.yaml +93 -0
- package/public/rjbuild/component-doc/core/element/html/PreformattedMarkup.yaml +37 -0
- package/public/rjbuild/component-doc/core/element/html/SortableTreeItemCollapseButton.yaml +92 -0
- package/public/rjbuild/component-doc/core/element/html/Tabs.yaml +57 -0
- package/public/rjbuild/component-doc/core/element/special/BootstrapElement.md +17 -0
- package/public/rjbuild/component-doc/core/element/special/BootstrapElement.yaml +18 -0
- package/public/rjbuild/component-doc/core/element/special/Count.md +37 -0
- package/public/rjbuild/component-doc/core/element/special/Count.yaml +325 -0
- package/public/rjbuild/component-doc/core/element/special/DataFilter.md +149 -0
- package/public/rjbuild/component-doc/core/element/special/DataFilter.yaml +315 -0
- package/public/rjbuild/component-doc/core/element/special/DelayedActions.md +51 -0
- package/public/rjbuild/component-doc/core/element/special/DelayedActions.yaml +55 -0
- package/public/rjbuild/component-doc/core/element/special/PageControls.md +126 -0
- package/public/rjbuild/component-doc/core/element/special/PageControls.yaml +133 -0
- package/public/rjbuild/component-doc/core/element/special/Phantom.md +31 -0
- package/public/rjbuild/component-doc/core/element/special/Phantom.yaml +34 -0
- package/public/rjbuild/component-doc/core/element/special/ReactiveJsonSubroot.md +27 -0
- package/public/rjbuild/component-doc/core/element/special/ReactiveJsonSubroot.yaml +51 -0
- package/public/rjbuild/component-doc/core/element/special/Switch.md +262 -0
- package/public/rjbuild/component-doc/core/element/special/Switch.yaml +348 -0
- package/public/rjbuild/component-doc/core/example/accordion.md +96 -0
- package/public/rjbuild/component-doc/core/example/accordion.yaml +64 -0
- package/public/rjbuild/component-doc/core/example/dynamic-content.md +197 -0
- package/public/rjbuild/component-doc/core/example/dynamic-content.yaml +237 -0
- package/public/rjbuild/component-doc/core/example/html.md +66 -0
- package/public/rjbuild/component-doc/core/example/html.yaml +83 -0
- package/public/rjbuild/component-doc/core/example/website.yaml +1663 -0
- package/public/rjbuild/component-doc/core/reaction/addData.md +96 -0
- package/public/rjbuild/component-doc/core/reaction/addData.yaml +133 -0
- package/public/rjbuild/component-doc/core/reaction/fetchData.md +60 -0
- package/public/rjbuild/component-doc/core/reaction/fetchData.yaml +156 -0
- package/public/rjbuild/component-doc/core/reaction/index.md +236 -0
- package/public/rjbuild/component-doc/core/reaction/index.yaml +254 -0
- package/public/rjbuild/component-doc/core/reaction/moveData.md +68 -0
- package/public/rjbuild/component-doc/core/reaction/moveData.yaml +71 -0
- package/public/rjbuild/component-doc/core/reaction/postMessage.md +63 -0
- package/public/rjbuild/component-doc/core/reaction/postMessage.yaml +68 -0
- package/public/rjbuild/component-doc/core/reaction/redirectNow.md +37 -0
- package/public/rjbuild/component-doc/core/reaction/redirectNow.yaml +37 -0
- package/public/rjbuild/component-doc/core/reaction/removeData.md +78 -0
- package/public/rjbuild/component-doc/core/reaction/removeData.yaml +56 -0
- package/public/rjbuild/component-doc/core/reaction/setClipboardData.md +44 -0
- package/public/rjbuild/component-doc/core/reaction/setClipboardData.yaml +41 -0
- package/public/rjbuild/component-doc/core/reaction/setData.md +93 -0
- package/public/rjbuild/component-doc/core/reaction/setData.yaml +85 -0
- package/public/rjbuild/component-doc/core/reaction/submitData.md +138 -0
- package/public/rjbuild/component-doc/core/reaction/submitData.yaml +141 -0
- package/public/rjbuild/component-doc/core/reaction/triggerEvent.md +59 -0
- package/public/rjbuild/component-doc/core/reaction/triggerEvent.yaml +59 -0
- package/public/rjbuild/component-doc/index.yaml +13 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Phantom
|
|
2
|
+
|
|
3
|
+
## Introduction
|
|
4
|
+
|
|
5
|
+
The `Phantom` component allows you to define actions or logic in your rjbuild without rendering any DOM element. It is useful for triggering actions, conditions, or data manipulations invisibly, without affecting the visual structure of your application.
|
|
6
|
+
|
|
7
|
+
## Properties
|
|
8
|
+
- `content` (object/array/string, optional): Content to evaluate or trigger (actions, conditions, etc.)
|
|
9
|
+
- `actions` (array, optional): Actions to attach to the phantom logic (e.g., Tooltip)
|
|
10
|
+
|
|
11
|
+
## Behavior
|
|
12
|
+
- Does not render any visible DOM element
|
|
13
|
+
- Can be used to attach actions, conditions, or data manipulations without UI
|
|
14
|
+
- The `content` property can include any valid Reactive-JSON view, action, or string
|
|
15
|
+
- The `actions` property allows you to attach logic such as tooltips or data updates
|
|
16
|
+
|
|
17
|
+
## Example
|
|
18
|
+
```yaml
|
|
19
|
+
renderView:
|
|
20
|
+
- type: Phantom
|
|
21
|
+
content: "Hover me"
|
|
22
|
+
actions:
|
|
23
|
+
- what: tooltip
|
|
24
|
+
content: "This tooltip is attached via an action, not a visible wrapper."
|
|
25
|
+
placement: right
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Limitations
|
|
29
|
+
- Does not produce any visible output in the DOM
|
|
30
|
+
- Only useful for logic, actions, or invisible data manipulations
|
|
31
|
+
- Not intended for displaying content to the user
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
renderView:
|
|
2
|
+
- type: Markdown
|
|
3
|
+
content: |
|
|
4
|
+
# Phantom
|
|
5
|
+
|
|
6
|
+
The `Phantom` component allows you to define actions or logic in your rjbuild without rendering any DOM element. It is useful for triggering actions, conditions, or data manipulations invisibly, without affecting the visual structure of your application.
|
|
7
|
+
|
|
8
|
+
## Properties
|
|
9
|
+
- `content` (object/array/string, optional): Content to evaluate or trigger (actions, conditions, etc.)
|
|
10
|
+
- `actions` (array, optional): Actions to attach to the phantom logic (e.g., Tooltip)
|
|
11
|
+
|
|
12
|
+
## Behavior
|
|
13
|
+
- Does not render any visible DOM element
|
|
14
|
+
- Can be used to attach actions, conditions, or data manipulations without UI
|
|
15
|
+
- The `content` property can include any valid Reactive-JSON view, action, or string
|
|
16
|
+
- The `actions` property allows you to attach logic such as tooltips or data updates
|
|
17
|
+
|
|
18
|
+
- type: RjBuildDescriber
|
|
19
|
+
title: Example
|
|
20
|
+
toDescribe:
|
|
21
|
+
renderView:
|
|
22
|
+
- type: Phantom
|
|
23
|
+
content: "Hover me"
|
|
24
|
+
actions:
|
|
25
|
+
- what: tooltip
|
|
26
|
+
content: "This tooltip is attached via an action, not a visible wrapper."
|
|
27
|
+
placement: right
|
|
28
|
+
|
|
29
|
+
- type: Markdown
|
|
30
|
+
content: |
|
|
31
|
+
## Limitations
|
|
32
|
+
- Does not produce any visible output in the DOM
|
|
33
|
+
- Only useful for logic, actions, or invisible data manipulations
|
|
34
|
+
- Not intended for displaying content to the user
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# ReactiveJsonSubroot
|
|
2
|
+
|
|
3
|
+
## Introduction
|
|
4
|
+
|
|
5
|
+
The `ReactiveJsonSubroot` component allows you to render a new Reactive-JSON root inside an existing application. It is useful for embedding a sub-application, isolating a part of the data tree, or rendering a separate rjbuild with its own options.
|
|
6
|
+
|
|
7
|
+
## Properties
|
|
8
|
+
- `rjOptions` (object, required): Options to pass to the subroot (such as `dataUrl`, `data`, `renderView`, etc.)
|
|
9
|
+
- Other properties are passed to the underlying `ReactiveJsonRoot`
|
|
10
|
+
|
|
11
|
+
## Behavior
|
|
12
|
+
- Renders a new `ReactiveJsonRoot` with the provided options
|
|
13
|
+
- The subroot is isolated from the parent for data, templates, and rendering
|
|
14
|
+
- Plugins from the parent are reused in the subroot
|
|
15
|
+
- If `rjOptions` is not a valid object, nothing is rendered
|
|
16
|
+
|
|
17
|
+
## Example
|
|
18
|
+
```yaml
|
|
19
|
+
renderView:
|
|
20
|
+
- type: ReactiveJsonSubroot
|
|
21
|
+
rjOptions:
|
|
22
|
+
dataUrl: "/rjs-build/home.yaml"
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Limitations
|
|
26
|
+
- The subroot is isolated from the parent; data and state are not shared
|
|
27
|
+
- No built-in communication between parent and subroot (except via plugins or explicit data passing)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
renderView:
|
|
2
|
+
- type: Markdown
|
|
3
|
+
content: |
|
|
4
|
+
# ReactiveJsonSubroot
|
|
5
|
+
|
|
6
|
+
The `ReactiveJsonSubroot` component allows you to render a new Reactive-JSON root inside an existing application. It is useful for embedding a sub-application, isolating a part of the data tree, or rendering a separate rjbuild with its own options.
|
|
7
|
+
|
|
8
|
+
## Properties
|
|
9
|
+
- `rjOptions` (object, required): Options to pass to the subroot (such as `dataUrl`, `data`, `renderView`, etc.)
|
|
10
|
+
- Other properties are passed to the underlying `ReactiveJsonRoot`
|
|
11
|
+
|
|
12
|
+
## Behavior
|
|
13
|
+
- Renders a new `ReactiveJsonRoot` with the provided options
|
|
14
|
+
- The subroot is isolated from the parent for data, templates, and rendering
|
|
15
|
+
- Plugins from the parent are reused in the subroot
|
|
16
|
+
- If `rjOptions` is not a valid object, nothing is rendered
|
|
17
|
+
|
|
18
|
+
- type: RjBuildDescriber
|
|
19
|
+
title: Example
|
|
20
|
+
description: This example demonstrates how to embed a separate Reactive-JSON application using ReactiveJsonSubroot. The component loads and renders an independent rjbuild file, creating an isolated sub-application within the current view.
|
|
21
|
+
toDescribe:
|
|
22
|
+
renderView:
|
|
23
|
+
- type: ReactiveJsonSubroot
|
|
24
|
+
rjOptions:
|
|
25
|
+
dataUrl: "/rjbuild/component/message.yaml"
|
|
26
|
+
|
|
27
|
+
- type: RjBuildDescriber
|
|
28
|
+
title: Example with inline JSON data
|
|
29
|
+
description: This example demonstrates two approaches for using ReactiveJsonSubroot with inline data. The first shows passing JSON data directly as a string via maybeRawAppData. The second shows loading subroot options dynamically from the main RjBuild's data using template interpolation. Both approaches are useful for embedding sub-applications without external files.
|
|
30
|
+
toDescribe:
|
|
31
|
+
renderView:
|
|
32
|
+
- type: ReactiveJsonSubroot
|
|
33
|
+
rjOptions:
|
|
34
|
+
maybeRawAppData: '{"data":{"userName":"Alice","messageCount":3},"renderView":[{"type":"div","attributes":{"style":{"padding":"1rem","border":"1px solid #ddd","borderRadius":"8px","backgroundColor":"#f9f9f9"}},"content":[{"type":"h3","content":"~~.userName"},{"type":"p","content":["You have ","~~.messageCount"," new messages."]},{"type":"button","content":"Mark as read","attributes":{"style":{"backgroundColor":"#007bff","color":"white","border":"none","padding":"0.5rem 1rem","borderRadius":"4px"}}}]}]}'
|
|
35
|
+
|
|
36
|
+
- type: hr
|
|
37
|
+
|
|
38
|
+
- type: ReactiveJsonSubroot
|
|
39
|
+
rjOptions: ~~.subrootToLoad
|
|
40
|
+
data:
|
|
41
|
+
subrootToLoad:
|
|
42
|
+
maybeRawAppData:
|
|
43
|
+
renderView:
|
|
44
|
+
- type: div
|
|
45
|
+
content: This second subroot is loaded from the "data" key of the main root.
|
|
46
|
+
|
|
47
|
+
- type: Markdown
|
|
48
|
+
content: |
|
|
49
|
+
## Limitations
|
|
50
|
+
- The subroot is isolated from the parent; data and state are not shared
|
|
51
|
+
- No built-in communication between parent and subroot (except via plugins or explicit data passing)
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
# Switch
|
|
2
|
+
|
|
3
|
+
## Introduction
|
|
4
|
+
|
|
5
|
+
The `Switch` component allows you to render a list or collection of items using a template, with support for dynamic data, options, and pagination. It is useful for displaying arrays, lists, or collections where each item can be rendered with a specific template or configuration.
|
|
6
|
+
|
|
7
|
+
## Properties
|
|
8
|
+
- `content` (array/object, required): The data or path to the data to iterate over
|
|
9
|
+
- `options` (object, optional): Mapping of keys to templates for rendering each item (referenced by `load`)
|
|
10
|
+
- `singleOption` (object, optional): Template to use for each item when all items share the same structure (referenced by `load`)
|
|
11
|
+
- `cardinality` (number, optional): Maximum number of items to render (default: unlimited)
|
|
12
|
+
- `paginated` (boolean, optional): Whether to enable pagination (default: false)
|
|
13
|
+
- `paginationProps` (object, optional): Pagination configuration (page size, etc.)
|
|
14
|
+
- `before` (object, optional): Content to render before the list
|
|
15
|
+
- `after` (object, optional): Content to render after the list
|
|
16
|
+
- `contentWrapper` (object, optional): HTML element configuration to wrap the main content (items only, not before/after)
|
|
17
|
+
- `tag` (string, optional): HTML tag name (default: "div")
|
|
18
|
+
- `attributes` (object, optional): HTML attributes to apply to the wrapper element (supports template evaluation)
|
|
19
|
+
- `templates` (object, optional): Named templates referenced by `load` in `singleOption` or `options`
|
|
20
|
+
|
|
21
|
+
## Behavior
|
|
22
|
+
- Iterates over the provided data and renders each item using the specified template(s)
|
|
23
|
+
- If `options` is provided, uses the corresponding template for each key (with `load`)
|
|
24
|
+
- If `singleOption` is provided, uses the template referenced by `load` for all items
|
|
25
|
+
- Supports limiting the number of items with `cardinality`
|
|
26
|
+
- Supports pagination if `paginated` is true
|
|
27
|
+
- Renders optional `before` and `after` content
|
|
28
|
+
- Can wrap the main content (items) with a custom HTML element using `contentWrapper`
|
|
29
|
+
- Templates are defined in the `templates` object and referenced by name
|
|
30
|
+
|
|
31
|
+
## Content Wrapper Feature
|
|
32
|
+
|
|
33
|
+
The `contentWrapper` property allows you to wrap the rendered items in a custom HTML element without affecting the `before` and `after` content. This is particularly useful for applying CSS layouts like Grid or Flexbox to the items.
|
|
34
|
+
|
|
35
|
+
**Note**: The `attributes` property of `contentWrapper` supports template evaluation, allowing you to create dynamic wrapper configurations based on your data.
|
|
36
|
+
|
|
37
|
+
### Structure
|
|
38
|
+
```
|
|
39
|
+
before (optional)
|
|
40
|
+
└── contentWrapper (optional)
|
|
41
|
+
└── rendered items
|
|
42
|
+
after (optional)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The wrapper only affects the main content items and does not interfere with pagination or other Switch features.
|
|
46
|
+
|
|
47
|
+
## Examples
|
|
48
|
+
|
|
49
|
+
### 1. Simple usage with `singleOption` (no pagination)
|
|
50
|
+
```yaml
|
|
51
|
+
renderView:
|
|
52
|
+
- type: Switch
|
|
53
|
+
content: ~.users
|
|
54
|
+
singleOption:
|
|
55
|
+
load: opt
|
|
56
|
+
templates:
|
|
57
|
+
opt:
|
|
58
|
+
type: div
|
|
59
|
+
content: ~.name
|
|
60
|
+
|
|
61
|
+
data:
|
|
62
|
+
users:
|
|
63
|
+
- name: "Alice"
|
|
64
|
+
- name: "Bob"
|
|
65
|
+
- name: "Charlie"
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### 2. Usage with `options` (different templates per key)
|
|
69
|
+
```yaml
|
|
70
|
+
renderView:
|
|
71
|
+
- type: Switch
|
|
72
|
+
content: ~.items
|
|
73
|
+
options:
|
|
74
|
+
name:
|
|
75
|
+
load: name
|
|
76
|
+
age:
|
|
77
|
+
load: age
|
|
78
|
+
templates:
|
|
79
|
+
name:
|
|
80
|
+
type: div
|
|
81
|
+
content: ["Name: ", ~.value]
|
|
82
|
+
age:
|
|
83
|
+
type: div
|
|
84
|
+
content: ["Age: ", ~.value]
|
|
85
|
+
data:
|
|
86
|
+
items:
|
|
87
|
+
- name:
|
|
88
|
+
value: "Alice"
|
|
89
|
+
- age:
|
|
90
|
+
value: 30
|
|
91
|
+
- name:
|
|
92
|
+
value: "Bob"
|
|
93
|
+
- age:
|
|
94
|
+
value: 25
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### 3. Usage with `singleOption`, pagination, before/after, and PageControls
|
|
98
|
+
```yaml
|
|
99
|
+
renderView:
|
|
100
|
+
- type: Switch
|
|
101
|
+
content: ~.numbers
|
|
102
|
+
singleOption:
|
|
103
|
+
load: opt
|
|
104
|
+
paginated: true
|
|
105
|
+
paginationProps:
|
|
106
|
+
pageMaxItemCount: 4
|
|
107
|
+
before:
|
|
108
|
+
type: div
|
|
109
|
+
content: "User list:"
|
|
110
|
+
after:
|
|
111
|
+
type: PageControls
|
|
112
|
+
templates:
|
|
113
|
+
opt:
|
|
114
|
+
type: div
|
|
115
|
+
content: ["Number: ", ~.value]
|
|
116
|
+
data:
|
|
117
|
+
numbers:
|
|
118
|
+
- value: 1
|
|
119
|
+
- value: 2
|
|
120
|
+
- value: 3
|
|
121
|
+
- value: 4
|
|
122
|
+
- value: 5
|
|
123
|
+
- value: 6
|
|
124
|
+
- value: 7
|
|
125
|
+
- value: 8
|
|
126
|
+
- value: 9
|
|
127
|
+
- value: 10
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### 4. Usage with `contentWrapper` for CSS Grid Layout
|
|
131
|
+
```yaml
|
|
132
|
+
renderView:
|
|
133
|
+
- type: Switch
|
|
134
|
+
content: ~.products
|
|
135
|
+
singleOption:
|
|
136
|
+
load: productCard
|
|
137
|
+
contentWrapper:
|
|
138
|
+
tag: div
|
|
139
|
+
attributes:
|
|
140
|
+
style:
|
|
141
|
+
display: grid
|
|
142
|
+
gridTemplateColumns: "repeat(auto-fill, minmax(300px, 1fr))"
|
|
143
|
+
gap: 1rem
|
|
144
|
+
padding: 1rem
|
|
145
|
+
after:
|
|
146
|
+
type: div
|
|
147
|
+
content: "End of products"
|
|
148
|
+
templates:
|
|
149
|
+
productCard:
|
|
150
|
+
type: div
|
|
151
|
+
attributes:
|
|
152
|
+
style:
|
|
153
|
+
border: "1px solid #ccc"
|
|
154
|
+
borderRadius: 8px
|
|
155
|
+
padding: 1rem
|
|
156
|
+
content:
|
|
157
|
+
- type: h3
|
|
158
|
+
content: ~.name
|
|
159
|
+
- type: p
|
|
160
|
+
content: ~.description
|
|
161
|
+
data:
|
|
162
|
+
products:
|
|
163
|
+
- name: "Product A"
|
|
164
|
+
description: "Description of product A"
|
|
165
|
+
- name: "Product B"
|
|
166
|
+
description: "Description of product B"
|
|
167
|
+
- name: "Product C"
|
|
168
|
+
description: "Description of product C"
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### 5. Usage with `contentWrapper` for Flexbox Layout
|
|
172
|
+
```yaml
|
|
173
|
+
renderView:
|
|
174
|
+
- type: Switch
|
|
175
|
+
content: ~.items
|
|
176
|
+
singleOption:
|
|
177
|
+
load: flexItem
|
|
178
|
+
contentWrapper:
|
|
179
|
+
tag: section
|
|
180
|
+
attributes:
|
|
181
|
+
class: "flex-container"
|
|
182
|
+
style:
|
|
183
|
+
display: flex
|
|
184
|
+
flexWrap: wrap
|
|
185
|
+
justifyContent: space-between
|
|
186
|
+
alignItems: center
|
|
187
|
+
templates:
|
|
188
|
+
flexItem:
|
|
189
|
+
type: div
|
|
190
|
+
attributes:
|
|
191
|
+
style:
|
|
192
|
+
flex: "1 1 200px"
|
|
193
|
+
margin: 0.5rem
|
|
194
|
+
padding: 1rem
|
|
195
|
+
backgroundColor: "#f0f0f0"
|
|
196
|
+
content: ~.text
|
|
197
|
+
data:
|
|
198
|
+
items:
|
|
199
|
+
- text: "Item 1"
|
|
200
|
+
- text: "Item 2"
|
|
201
|
+
- text: "Item 3"
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### 6. Dynamic `contentWrapper` with Template Evaluation
|
|
205
|
+
```yaml
|
|
206
|
+
renderView:
|
|
207
|
+
- type: Switch
|
|
208
|
+
content: ~.galleries
|
|
209
|
+
singleOption:
|
|
210
|
+
load: imageItem
|
|
211
|
+
contentWrapper:
|
|
212
|
+
tag: div
|
|
213
|
+
attributes:
|
|
214
|
+
class: ~.layoutClass
|
|
215
|
+
style:
|
|
216
|
+
display: grid
|
|
217
|
+
gridTemplateColumns: ~.gridColumns
|
|
218
|
+
gap: ~.spacing
|
|
219
|
+
backgroundColor: ~.theme.backgroundColor
|
|
220
|
+
templates:
|
|
221
|
+
imageItem:
|
|
222
|
+
type: div
|
|
223
|
+
attributes:
|
|
224
|
+
style:
|
|
225
|
+
padding: 1rem
|
|
226
|
+
border: "1px solid #ddd"
|
|
227
|
+
content: ~.title
|
|
228
|
+
data:
|
|
229
|
+
layoutClass: "photo-gallery"
|
|
230
|
+
gridColumns: "repeat(3, 1fr)"
|
|
231
|
+
spacing: "2rem"
|
|
232
|
+
theme:
|
|
233
|
+
backgroundColor: "#f5f5f5"
|
|
234
|
+
galleries:
|
|
235
|
+
- title: "Photo 1"
|
|
236
|
+
- title: "Photo 2"
|
|
237
|
+
- title: "Photo 3"
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Limitations
|
|
241
|
+
- The data must be an array or object; strings and numbers are not supported
|
|
242
|
+
- If both `options` and `singleOption` are provided, `singleOption` takes precedence
|
|
243
|
+
- No built-in support for filtering or sorting (use DataFilter or custom logic)
|
|
244
|
+
- Pagination requires the `paginated` property to be set to true
|
|
245
|
+
- Templates must be defined in the `templates` object and referenced by `load`
|
|
246
|
+
|
|
247
|
+
### Data Structure Requirements
|
|
248
|
+
Switch requires each item in the data to be an object, not a primitive value:
|
|
249
|
+
|
|
250
|
+
```yaml
|
|
251
|
+
# ❌ This will NOT work:
|
|
252
|
+
data:
|
|
253
|
+
items: ["string1", "string2", "string3"]
|
|
254
|
+
|
|
255
|
+
# ✅ This will work:
|
|
256
|
+
data:
|
|
257
|
+
items:
|
|
258
|
+
- name: "string1"
|
|
259
|
+
- name: "string2"
|
|
260
|
+
- name: "string3"
|
|
261
|
+
```
|
|
262
|
+
|