react-semaphor 0.1.385 → 0.1.387
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/DATA_APP_SDK.md +67 -0
- package/dist/data-app-sdk/index.cjs +5 -5
- package/dist/data-app-sdk/index.js +1167 -1122
- package/dist/types/data-app-sdk.d.ts +6 -0
- package/package.json +1 -1
- package/src/data-app-sdk/README.md +67 -0
|
@@ -705,6 +705,9 @@ export declare type SemaphorDataAppSourceHint = {
|
|
|
705
705
|
export declare type SemaphorDataAppTrace = {
|
|
706
706
|
traceId: string;
|
|
707
707
|
viewId?: string;
|
|
708
|
+
viewTitle?: string;
|
|
709
|
+
visualType?: string;
|
|
710
|
+
sectionTitle?: string;
|
|
708
711
|
queryId: string;
|
|
709
712
|
queryLabel?: string;
|
|
710
713
|
queryKind: SemaphorQueryDefinition['queryKind'];
|
|
@@ -1322,6 +1325,9 @@ declare type SemaphorProtocolVersion = 1;
|
|
|
1322
1325
|
|
|
1323
1326
|
export declare type SemaphorQueryDebugOptions = {
|
|
1324
1327
|
viewId?: string;
|
|
1328
|
+
viewTitle?: string;
|
|
1329
|
+
visualType?: string;
|
|
1330
|
+
sectionTitle?: string;
|
|
1325
1331
|
title?: string;
|
|
1326
1332
|
sourceHint?: SemaphorDataAppSourceHint;
|
|
1327
1333
|
sourceHints?: SemaphorDataAppSourceHint[];
|
package/package.json
CHANGED
|
@@ -9,6 +9,7 @@ patterns.
|
|
|
9
9
|
```tsx
|
|
10
10
|
import {
|
|
11
11
|
SemaphorDataAppProvider,
|
|
12
|
+
SemaphorDevtools,
|
|
12
13
|
semaphor,
|
|
13
14
|
useClearInvalidSemaphorInputValue,
|
|
14
15
|
useSemaphorInputs,
|
|
@@ -23,6 +24,47 @@ import type {
|
|
|
23
24
|
} from "react-semaphor/data-app-sdk";
|
|
24
25
|
```
|
|
25
26
|
|
|
27
|
+
## Runtime Provider And DevTools
|
|
28
|
+
|
|
29
|
+
Generated local/dev apps should mount one root DevTools instance and enable the
|
|
30
|
+
debug bridge only outside production embeds.
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
const runtimeToken = import.meta.env.VITE_SEMAPHOR_PROJECT_TOKEN;
|
|
34
|
+
const enableDevtools =
|
|
35
|
+
import.meta.env.DEV ||
|
|
36
|
+
(typeof window !== "undefined" && window.location.hostname === "localhost");
|
|
37
|
+
|
|
38
|
+
export function Root() {
|
|
39
|
+
return (
|
|
40
|
+
<SemaphorDataAppProvider
|
|
41
|
+
token={runtimeToken}
|
|
42
|
+
debug={enableDevtools ? { exposeWindowBridge: true } : false}
|
|
43
|
+
>
|
|
44
|
+
<App />
|
|
45
|
+
<SemaphorDevtools
|
|
46
|
+
initialIsOpen={false}
|
|
47
|
+
buttonPosition="bottom-right"
|
|
48
|
+
panelPosition="right"
|
|
49
|
+
/>
|
|
50
|
+
</SemaphorDataAppProvider>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Add hook-level debug source hints when they are cheap and non-repetitive:
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
const result = useSemaphorQuery(revenueBySegment, {
|
|
59
|
+
debug: {
|
|
60
|
+
sourceHint: {
|
|
61
|
+
file: "src/views/RevenueBySegment.tsx",
|
|
62
|
+
component: "RevenueBySegment",
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
26
68
|
## Source And Fields
|
|
27
69
|
|
|
28
70
|
```tsx
|
|
@@ -149,12 +191,37 @@ function SegmentFilter() {
|
|
|
149
191
|
});
|
|
150
192
|
|
|
151
193
|
useClearInvalidSemaphorInputValue(segmentHandle, optionsResult);
|
|
194
|
+
|
|
195
|
+
const selectedValue = Array.isArray(segmentHandle.value)
|
|
196
|
+
? String(segmentHandle.value[0] ?? "")
|
|
197
|
+
: "";
|
|
198
|
+
|
|
199
|
+
return (
|
|
200
|
+
<select
|
|
201
|
+
value={selectedValue}
|
|
202
|
+
onChange={(event) => {
|
|
203
|
+
const nextValue = event.target.value || null;
|
|
204
|
+
segmentHandle.setValue(nextValue ? [nextValue] : undefined);
|
|
205
|
+
}}
|
|
206
|
+
>
|
|
207
|
+
<option value="">All segments</option>
|
|
208
|
+
{(optionsResult.options ?? []).map((option) => (
|
|
209
|
+
<option key={String(option.value)} value={String(option.value)}>
|
|
210
|
+
{option.label ?? String(option.value)}
|
|
211
|
+
</option>
|
|
212
|
+
))}
|
|
213
|
+
</select>
|
|
214
|
+
);
|
|
152
215
|
}
|
|
153
216
|
```
|
|
154
217
|
|
|
155
218
|
Pass the full `optionsResult` to `useClearInvalidSemaphorInputValue`; do not
|
|
156
219
|
pass only `optionsResult.options`, because idle/loading results can also expose
|
|
157
220
|
an empty options array.
|
|
221
|
+
For shadcn/Base UI style selects, type the change callback as accepting
|
|
222
|
+
`string | null` and call `handle.clear()` or `handle.setValue(undefined)` for
|
|
223
|
+
the empty state. For multi-selects and date ranges, narrow `handle.value` with
|
|
224
|
+
`Array.isArray(...)` before indexing or displaying it.
|
|
158
225
|
|
|
159
226
|
## Shared Inputs With Source-Specific Bindings
|
|
160
227
|
|