You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/components/form-input.md
+17-8Lines changed: 17 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
---
2
-
title: <FormInput* />
2
+
title: <Forms.Input* />
3
3
---
4
4
5
5
# Form input components
@@ -8,8 +8,10 @@ Reactodia provides basic built-in components to edit entity or relation properti
8
8
9
9
| Form input component | Description |
10
10
|----------------------|-------------|
11
-
|[`<FormInputList />`](/docs/api/workspace/variables/FormInputList.md)| Form input to edit multiple values in a list of specified single value inputs. |
12
-
|[`<FormInputText />`](/docs/api/workspace/functions/FormInputText.md)| Form input to edit a single value as a plain string with an optional language. |
11
+
|[`<Forms.InputList />`](/docs/api/forms/functions/InputList.md)| Form input to edit multiple values in a list of specified single value inputs. |
12
+
|[`<Forms.InputText />`](/docs/api/forms/functions/InputText.md)| Form input to edit a single value as a plain string with an optional language. |
13
+
|[`<Forms.InputSelect />`](/docs/api/forms/functions/InputSelect.md)| Form input to select a value from a predefined list of variants. |
14
+
|[`<Forms.InputFile />`](/docs/api/forms/functions/InputFile.md)| Form input to upload files and display previously uploaded files. |
13
15
14
16
:::warning
15
17
Currently form input components are considered **unstable** so there might be breaking changes in their API in the future.
Copy file name to clipboardExpand all lines: docs/concepts/data-provider.md
+155Lines changed: 155 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -139,3 +139,158 @@ function ExampleRdfProviderProvisionFromJGF() {
139
139
);
140
140
}
141
141
```
142
+
143
+
## Loading data from a data provider
144
+
145
+
When exploring the graph data, Reactodia components track which data needs to be loaded and requests to fetch it based on currently displayed [diagram content](/docs/concepts/graph-model#diagram-content). For example, when an [`EntityElement`](/docs/api/workspace/classes/EntityElement.md) is added to the canvas and rendered with the[default template](/docs/components/canvas.md#customization), the library will load corresponding entity types to display correct labels.
146
+
147
+
The library includes a number of hooks and methods to simplify data loading from a custom component which are listed below.
148
+
149
+
### Request data for entities and/or relations on the canvas
150
+
151
+
After adding one or more [`EntityElement`](/docs/api/workspace/classes/EntityElement.md) elements to the canvas e.g. with [`model.createElement()`](/docs/api/workspace/classes/DataDiagramModel.md#createelement) (see [Manipulating the diagram](/docs/concepts/graph-model.md#manipulating-the-diagram)), it is necessary to call one or several of the following methods to initiate loading entity data and relations between them:
152
+
153
+
| Method | Description |
154
+
|-----------------|-------------|
155
+
|[`model.requestData()`](/docs/api/workspace/classes/DataDiagramModel.md#requestdata)| Requests to load all non-loaded ([placeholder](/docs/api/workspace/classes/EntityElement.md#isplaceholderdata)) entity elements and links connected to them. |
156
+
|[`model.requestElementData()`](/docs/api/workspace/classes/DataDiagramModel.md#requestelementdata)| Requests to load (or reload) data for the specified set of entities. |
157
+
|[`model.requestLinks()`](/docs/api/workspace/classes/DataDiagramModel.md#requestlinks)| Requests to load (or reload) all relations connected to the specified sets of entities. |
158
+
159
+
It is also possible to use [`requestElementData()`](/docs/api/workspace/functions/requestElementData.md) and [`restoreLinksBetweenElements()`](/docs/api/workspace/functions/restoreLinksBetweenElements.md) command effects to re-request the data on [undo/redo](/docs/concepts/command-history.md) if needed.
160
+
161
+
### Manually request data for entity, relation or property types
162
+
163
+
In some cases it is easier to manually trigger a request to load data for an entity, relation or property type:
164
+
165
+
| Method | Description |
166
+
|-----------------|-------------|
167
+
|[`model.createElementType()`](/docs/api/workspace/classes/DataDiagramModel.md#createelementtype)| Requests to load an entity type if it has not been loaded yet. <br/> [`model.getElementType()`](/docs/api/workspace/classes/DataDiagramModel.md#getelementtype) can be used to get the placeholder or loaded data. |
168
+
|[`model.createLinkType()`](/docs/api/workspace/classes/DataDiagramModel.md#createlinktype)| Requests to load a relation type if it has not been loaded yet. <br/> [`model.getLinkType()`](/docs/api/workspace/classes/DataDiagramModel.md#getlinktype) can be used to get the placeholder or loaded data. |
169
+
|[`model.createPropertyType()`](/docs/api/workspace/classes/DataDiagramModel.md#createpropertytype)| Requests to load a property type if it has not been loaded yet. <br/> [`model.getPropertyType()`](/docs/api/workspace/classes/DataDiagramModel.md#getpropertytype) can be used to get the placeholder or loaded data. |
170
+
171
+
#### Example: manual request and subscription for an entity type
172
+
173
+
```ts
174
+
function MyElementTypeBadge(props: { elementTypeIri }) {
When requesting the data manually, make sure to subscribe to created instances to re-render when the data loads via [`useObservedProperty()`](/docs/api/workspace/functions/useObservedProperty.md), [`useEventStore()`](/docs/api/workspace/functions/useEventStore.md) or manual [event subscription](/docs/concepts/event-system.md).
201
+
:::
202
+
203
+
### `useKeyedSyncStore()`
204
+
205
+
[`useKeyedSyncStore`](/docs/api/workspace/functions/useKeyedSyncStore.md) hook allows to subscribe to a set of targets and fetch the data for each:
206
+
207
+
| Store | Description |
208
+
|-----------------|-------------|
209
+
|[`subscribeElementTypes`](/docs/api/workspace/variables/subscribeElementTypes.md)| Subscribe and fetch entity types. |
210
+
|[`subscribeLinkTypes`](/docs/api/workspace/variables/subscribeLinkTypes.md)| Subscribe and fetch relation types. |
211
+
|[`subscribeElementTypes`](/docs/api/workspace/variables/subscribePropertyTypes.md)| Subscribe and fetch property types. |
212
+
213
+
#### Example: subscribe to property types from an [element template](/docs/components/canvas.md#customization)
214
+
215
+
```ts
216
+
function MyElement(props:Reactodia.TemplateProps) {
[`useProvidedEntities`](/docs/api/workspace/functions/useProvidedEntities.md) hook allows to loads entity data for a target set of IRIs even when the entities are not displayed on the canvas at all.
255
+
256
+
#### Example: load entity variants for a [select input](/docs/components/form-input.md)
257
+
258
+
```ts
259
+
function MyInputForShape(props:Forms.InputSingleProps) {
It is possible to customize how library components display graph data by supplying a custom [`DataLocaleProvider`](/docs/api/workspace/interfaces/DataLocaleProvider.md) when calling [model.importLayout()](/docs/api/workspace/classes/DataDiagramModel.md#importlayout).
287
+
288
+
Data locale provider can be used to alter the following behavior:
289
+
-[locale.selectEntityLabel()](/docs/api/workspace/interfaces/DataLocaleProvider.md#selectentitylabel) and [locale.formatEntityLabel()](/docs/api/workspace/interfaces/DataLocaleProvider.md#formatentitylabel) to select or format default entity label from its properties (by default it looks for `rdfs:label` property values);
290
+
-[locale.selectEntityImageUrl()](/docs/api/workspace/interfaces/DataLocaleProvider.md#selectentityimageurl) to select default entity thumbnail image IRI from its properties (by default it looks for `schema:thumbnailUrl` property value);
291
+
-[locale.prepareAnchor()](/docs/api/workspace/interfaces/DataLocaleProvider.md#prepareanchor) to provide props for an anchor (`<a>` link) to a resource IRI;
292
+
-[locale.resolveAssetUrl()](/docs/api/workspace/interfaces/DataLocaleProvider.md#resolveasseturl) to resolve an IRI/URL to referenced data asset for display or download, e.g. an image (thumbnail) or a downloadable file.
293
+
294
+
:::tip
295
+
It is possible to extend [`DefaultDataLocaleProvider`](/docs/api/workspace/classes/DefaultDataLocaleProvider.md) to slightly alter its behavior instead of implementing the full [`DataLocaleProvider`](/docs/api/workspace/interfaces/DataLocaleProvider.md) interface.
0 commit comments