@inspectorhub/field-ui 0.3.0 → 0.4.0
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.md +8 -1
- package/dist/index.d.ts +3 -6
- package/dist/index.js +1566 -1282
- package/dist/theme.css +12 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ The root entry exports:
|
|
|
24
24
|
|
|
25
25
|
| Group | Exports |
|
|
26
26
|
|---|---|
|
|
27
|
-
| The editor | `FieldEditor` (props: `{ data: EditorData }`) |
|
|
27
|
+
| The editor | `FieldEditor` (props: `{ data: EditorData; readOnly?: boolean }`) |
|
|
28
28
|
| Host contract | `FieldDataSourceProvider`, `useFieldDataSource`, `useFieldCommand`, `useFieldEnsureHuman`, `useFieldSlots`, `isIgnored`, `setFieldLocale`, `bindFieldLocaleSource`, and the TypeScript types of the contract (`FieldDataSource`, `FieldHostSlots`, `FieldUrls`, `FieldResources`, `EditorData`, `SessionInfo`, and so on) |
|
|
29
29
|
| Finding keys | `findingKey`, `findingsForUnit`, `isMetaKey` (the same functions the server uses to address a result) |
|
|
30
30
|
| Photo decoding | `DecodeImageError`, `isDecodeImageError` (matches by error name, so it works across two copies of the package), and the types `DecodeImage`, `DecodeImageOptions`, `DecodedImage` (see `media` below) |
|
|
@@ -46,6 +46,13 @@ setFieldLocale(session.locale); // and keep it in step with the host's own local
|
|
|
46
46
|
</FieldDataSourceProvider>
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
+
Pass `readOnly` to show an inspection for reading only. Nothing in a read-only editor can write: the results document is
|
|
50
|
+
never handed to a write helper, every write on the data source (commands, uploads, the media store, the resource writes)
|
|
51
|
+
is refused with "This inspection is read-only.", and the controls that write (rating row, notes input, add-photo tile,
|
|
52
|
+
publish, sign, finish, structure and template editing, settings, units, cost items, batch and Speed mode) are not
|
|
53
|
+
rendered. Navigation, the section and item lists, the rating as an indicator, notes as text, photos and their viewer, the
|
|
54
|
+
preview and updates from other people keep working. Without `readOnly` nothing changes.
|
|
55
|
+
|
|
49
56
|
What the host has to provide:
|
|
50
57
|
|
|
51
58
|
- A `FieldDataSource` (next section). `editorData` is what its `load()` returns.
|
package/dist/index.d.ts
CHANGED
|
@@ -126,13 +126,10 @@ interface FieldCommandRunner {
|
|
|
126
126
|
*/
|
|
127
127
|
declare function useFieldCommand(inspectionId: string): FieldCommandRunner;
|
|
128
128
|
|
|
129
|
-
/**
|
|
130
|
-
|
|
131
|
-
* slots, so any host (web route, native shell) mounts it the same way. `data` must follow the host's
|
|
132
|
-
* revalidation: units, publish state and the rest are read from it on every render.
|
|
133
|
-
*/
|
|
134
|
-
declare function FieldEditor({ data }: {
|
|
129
|
+
/** The inspection editor page. `readOnly` shows it for reading only: nothing in it can write, and the write controls are not offered. */
|
|
130
|
+
declare function FieldEditor({ data, readOnly }: {
|
|
135
131
|
data: EditorData;
|
|
132
|
+
readOnly?: boolean;
|
|
136
133
|
}): React.JSX.Element;
|
|
137
134
|
|
|
138
135
|
declare function findingKey(unitId: string | null | undefined, sectionId: string, itemId: string): string;
|