@viamrobotics/test-widgets 0.15.1 → 0.16.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 +15 -1
- package/dist/api-docs-href.d.ts +2 -2
- package/dist/api-docs-href.js +0 -1
- package/dist/components/api-section.svelte +7 -6
- package/dist/components/api-section.svelte.d.ts +4 -3
- package/dist/components/boundary.svelte +51 -0
- package/dist/components/boundary.svelte.d.ts +5 -0
- package/dist/components/connection-status.svelte +57 -61
- package/dist/components/connection-status.svelte.d.ts +5 -5
- package/dist/components/content-rect.svelte +4 -5
- package/dist/components/content-rect.svelte.d.ts +2 -1
- package/dist/components/error.svelte +6 -5
- package/dist/components/error.svelte.d.ts +2 -1
- package/dist/components/index.d.ts +0 -1
- package/dist/components/index.js +0 -1
- package/dist/components/is-moving.svelte +4 -2
- package/dist/components/is-moving.svelte.d.ts +2 -1
- package/dist/components/maplibre/index.svelte +5 -6
- package/dist/components/maplibre/index.svelte.d.ts +3 -1
- package/dist/components/mutation-section.svelte +7 -5
- package/dist/components/mutation-section.svelte.d.ts +4 -2
- package/dist/components/pose-editor.svelte +83 -15
- package/dist/components/pose-editor.svelte.d.ts +11 -4
- package/dist/components/queries.svelte +7 -4
- package/dist/components/queries.svelte.d.ts +2 -1
- package/dist/components/query.svelte +4 -3
- package/dist/components/query.svelte.d.ts +2 -1
- package/dist/components/section/error-key.d.ts +2 -0
- package/dist/components/section/error-key.js +2 -0
- package/dist/components/section/index.d.ts +19 -0
- package/dist/components/section/index.js +19 -0
- package/dist/components/section/section-body.svelte +36 -0
- package/dist/components/section/section-body.svelte.d.ts +13 -0
- package/dist/components/section/section-errors.svelte +18 -0
- package/dist/components/section/section-errors.svelte.d.ts +6 -0
- package/dist/components/section/section-heading.svelte +21 -0
- package/dist/components/section/section-heading.svelte.d.ts +9 -0
- package/dist/components/section/section-loading.d.ts +4 -0
- package/dist/components/section/section-loading.js +10 -0
- package/dist/components/section/section-method.svelte +29 -0
- package/dist/components/section/section-method.svelte.d.ts +9 -0
- package/dist/components/section/section-placeholder.svelte +29 -0
- package/dist/components/section/section-placeholder.svelte.d.ts +7 -0
- package/dist/components/section/section-text.svelte +17 -0
- package/dist/components/section/section-text.svelte.d.ts +8 -0
- package/dist/components/section/section-tooltip.svelte +25 -0
- package/dist/components/section/section-tooltip.svelte.d.ts +7 -0
- package/dist/components/section/section.svelte +17 -0
- package/dist/components/section/section.svelte.d.ts +8 -0
- package/dist/components/section/use-section-errors.svelte.d.ts +18 -0
- package/dist/components/section/use-section-errors.svelte.js +39 -0
- package/dist/components/section-title.svelte +3 -1
- package/dist/components/section-title.svelte.d.ts +2 -1
- package/dist/components/stop.svelte +31 -14
- package/dist/components/stop.svelte.d.ts +6 -1
- package/dist/components/widgets/arm/arm.svelte +22 -11
- package/dist/components/widgets/arm/get-joint-positions-widget.svelte +1 -1
- package/dist/components/widgets/arm/joint-position-editor.svelte +105 -27
- package/dist/components/widgets/arm/joint-position-editor.svelte.d.ts +4 -3
- package/dist/components/widgets/arm/joint-position-slider.svelte +6 -2
- package/dist/components/widgets/arm/joint-position-slider.svelte.d.ts +2 -1
- package/dist/components/widgets/arm/manual-mode-widget.svelte +3 -2
- package/dist/components/widgets/arm/move-to-joint-positions-widget.svelte +12 -4
- package/dist/components/widgets/arm/move-to-joint-positions.svelte +14 -6
- package/dist/components/widgets/arm/move-to-position-control.svelte +25 -17
- package/dist/components/widgets/arm/move-to-position.svelte +97 -30
- package/dist/components/widgets/arm/move-to-position.svelte.d.ts +3 -1
- package/dist/components/widgets/arm/use-arm-motion-tracking.svelte.d.ts +16 -0
- package/dist/components/widgets/arm/use-arm-motion-tracking.svelte.js +37 -0
- package/dist/components/widgets/arm/use-edited-targets.svelte.d.ts +9 -0
- package/dist/components/widgets/arm/use-edited-targets.svelte.js +24 -0
- package/dist/components/widgets/audio-input/audio-input.svelte +5 -4
- package/dist/components/widgets/audio-input/get-properties-widget.svelte +2 -2
- package/dist/components/widgets/audio-output/audio-output.svelte +5 -4
- package/dist/components/widgets/audio-output/get-properties-widget.svelte +2 -2
- package/dist/components/widgets/base/base.svelte +8 -6
- package/dist/components/widgets/base/quick-move.svelte +5 -6
- package/dist/components/widgets/base/set-power.svelte +6 -4
- package/dist/components/widgets/base/set-velocity.svelte +6 -4
- package/dist/components/widgets/base/vec3-builder.svelte +3 -2
- package/dist/components/widgets/base/vec3-builder.svelte.d.ts +2 -1
- package/dist/components/widgets/board/analog-read.svelte +2 -4
- package/dist/components/widgets/board/analog-write.svelte +2 -4
- package/dist/components/widgets/board/gpio-read.svelte +2 -1
- package/dist/components/widgets/board/gpio-write.svelte +2 -1
- package/dist/components/widgets/board/pin-section.svelte +5 -6
- package/dist/components/widgets/board/pin-section.svelte.d.ts +3 -2
- package/dist/components/widgets/camera/camera.svelte +4 -3
- package/dist/components/widgets/camera/live-or-polling-video.svelte +22 -22
- package/dist/components/widgets/discovery/discovery.svelte +4 -3
- package/dist/components/widgets/encoder/encoder.svelte +5 -3
- package/dist/components/widgets/encoder/get-position-widget.svelte +1 -1
- package/dist/components/widgets/gantry/gantry.svelte +13 -7
- package/dist/components/widgets/gantry/get-position-widget.svelte +1 -1
- package/dist/components/widgets/gantry/quick-move-widget.svelte +1 -1
- package/dist/components/widgets/generic/generic.svelte +4 -1
- package/dist/components/widgets/gripper/gripper.svelte +8 -6
- package/dist/components/widgets/gripper/is-holding-something.svelte +3 -2
- package/dist/components/widgets/input-controller/input-controller.svelte +4 -3
- package/dist/components/widgets/ml-model-service/ml-model-service.svelte +1 -1
- package/dist/components/widgets/motion/frame-select.svelte +4 -2
- package/dist/components/widgets/motion/frame-select.svelte.d.ts +2 -1
- package/dist/components/widgets/motion/motion.svelte +9 -5
- package/dist/components/widgets/motion/move.svelte +5 -3
- package/dist/components/widgets/motor/motor.svelte +12 -10
- package/dist/components/widgets/movement-sensor/get-accuracy-widget.svelte +2 -2
- package/dist/components/widgets/movement-sensor/get-compass-heading-widget.svelte +2 -2
- package/dist/components/widgets/movement-sensor/get-orientation-widget.svelte +2 -2
- package/dist/components/widgets/movement-sensor/get-position-widget.svelte +2 -2
- package/dist/components/widgets/movement-sensor/movement-sensor.svelte +17 -18
- package/dist/components/widgets/power-sensor/get-current-widget.svelte +2 -2
- package/dist/components/widgets/power-sensor/get-power-widget.svelte +2 -2
- package/dist/components/widgets/power-sensor/get-voltage-widget.svelte +2 -2
- package/dist/components/widgets/power-sensor/power-sensor.svelte +13 -11
- package/dist/components/widgets/sensor/sensor.svelte +4 -3
- package/dist/components/widgets/servo/servo.svelte +9 -4
- package/dist/components/widgets/slam/get-position-widget.svelte +2 -2
- package/dist/components/widgets/slam/move-on-map.svelte +3 -1
- package/dist/components/widgets/slam/slam.svelte +10 -5
- package/dist/components/widgets/switch/position-view.svelte +1 -1
- package/dist/components/widgets/switch/switch.svelte +1 -1
- package/dist/components/widgets/vision-service/detection-row.svelte +4 -2
- package/dist/components/widgets/vision-service/detection-row.svelte.d.ts +2 -1
- package/dist/components/widgets/vision-service/fonts/public-sans.json +1 -0
- package/dist/components/widgets/vision-service/fonts/public-sans.png +0 -0
- package/dist/components/widgets/vision-service/image.svelte +4 -4
- package/dist/components/widgets/vision-service/legend.svelte +4 -4
- package/dist/components/widgets/vision-service/public-sans-font.d.ts +5 -0
- package/dist/components/widgets/vision-service/public-sans-font.js +14 -0
- package/dist/components/widgets/vision-service/vision-service.svelte +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +0 -1
- package/package.json +17 -4
- package/dist/components/board/pin-section.svelte +0 -28
- package/dist/components/board/pin-section.svelte.d.ts +0 -9
- package/dist/components/section-group.svelte +0 -64
- package/dist/components/section-group.svelte.d.ts +0 -14
|
@@ -13,10 +13,19 @@
|
|
|
13
13
|
['oZ', 'OZ'],
|
|
14
14
|
['theta', 'θ'],
|
|
15
15
|
]
|
|
16
|
+
|
|
17
|
+
export interface PoseFieldStatus {
|
|
18
|
+
current: number
|
|
19
|
+
isEdited: boolean
|
|
20
|
+
drift: number | undefined
|
|
21
|
+
isMoving: boolean
|
|
22
|
+
}
|
|
16
23
|
</script>
|
|
17
24
|
|
|
18
25
|
<script lang="ts">
|
|
19
|
-
import {
|
|
26
|
+
import type { Snippet } from 'svelte'
|
|
27
|
+
|
|
28
|
+
import { Icon, IconButton, NumericInput, Tooltip } from '@viamrobotics/prime-core'
|
|
20
29
|
|
|
21
30
|
import AngleUnitToggle from './angle-unit-toggle.svelte'
|
|
22
31
|
import CopyButton from './copy-button.svelte'
|
|
@@ -28,14 +37,14 @@
|
|
|
28
37
|
|
|
29
38
|
interface Props {
|
|
30
39
|
pose: Pose
|
|
40
|
+
heading: Snippet
|
|
31
41
|
onPoseChange: (pose: Pose) => void
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
description?: string
|
|
42
|
+
description?: Snippet
|
|
43
|
+
fieldStatus?: (key: keyof Pose) => PoseFieldStatus
|
|
44
|
+
onFieldReset?: (key: keyof Pose) => void
|
|
36
45
|
}
|
|
37
46
|
|
|
38
|
-
const { pose,
|
|
47
|
+
const { pose, heading, description, fieldStatus, onFieldReset, onPoseChange }: Props = $props()
|
|
39
48
|
|
|
40
49
|
let useRadians = $state(false)
|
|
41
50
|
|
|
@@ -71,12 +80,36 @@
|
|
|
71
80
|
oZ: '',
|
|
72
81
|
theta: useRadians ? 'rad' : 'deg',
|
|
73
82
|
})
|
|
83
|
+
|
|
84
|
+
const toDisplay = (key: keyof Pose, value: number) =>
|
|
85
|
+
key === 'theta' && useRadians ? degreesToRadians(value) : value
|
|
86
|
+
|
|
87
|
+
interface StatusIndicator {
|
|
88
|
+
status: 'info' | 'warn'
|
|
89
|
+
message: string
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const statusIndicator = (
|
|
93
|
+
key: keyof Pose,
|
|
94
|
+
label: string,
|
|
95
|
+
status: PoseFieldStatus | undefined
|
|
96
|
+
): StatusIndicator | undefined => {
|
|
97
|
+
if (status?.drift !== undefined) {
|
|
98
|
+
const unit = poseUnits[key] ? ` ${poseUnits[key]}` : ''
|
|
99
|
+
const amount = formatNumeric(toDisplay(key, status.drift))
|
|
100
|
+
return { status: 'warn', message: `Arm moved ${amount}${unit} since you edited ${label}.` }
|
|
101
|
+
}
|
|
102
|
+
if (status?.isEdited && status.isMoving) {
|
|
103
|
+
return { status: 'info', message: 'The arm is moving. Your edit is kept.' }
|
|
104
|
+
}
|
|
105
|
+
return undefined
|
|
106
|
+
}
|
|
74
107
|
</script>
|
|
75
108
|
|
|
76
109
|
<div class="flex min-w-0 flex-col gap-4">
|
|
77
110
|
<div class="flex items-center justify-between">
|
|
78
111
|
<span class="flex flex-row items-center gap-1 text-sm">
|
|
79
|
-
{
|
|
112
|
+
{@render heading()}
|
|
80
113
|
{#if description}
|
|
81
114
|
<Tooltip>
|
|
82
115
|
<Icon
|
|
@@ -84,7 +117,7 @@
|
|
|
84
117
|
cx="text-gray-6"
|
|
85
118
|
/>
|
|
86
119
|
|
|
87
|
-
<span slot="description">{description}</span>
|
|
120
|
+
<span slot="description">{@render description()}</span>
|
|
88
121
|
</Tooltip>
|
|
89
122
|
{/if}
|
|
90
123
|
</span>
|
|
@@ -111,6 +144,8 @@
|
|
|
111
144
|
{#each poseLabelsList as labelList (labelList)}
|
|
112
145
|
{@const [key, label] = labelList}
|
|
113
146
|
{@const value = Number.parseFloat(formatNumeric(displayPose[key]))}
|
|
147
|
+
{@const status = fieldStatus?.(key)}
|
|
148
|
+
{@const indicator = statusIndicator(key, label, status)}
|
|
114
149
|
<tr>
|
|
115
150
|
<th>
|
|
116
151
|
<span class="relative inline-flex justify-center">
|
|
@@ -119,13 +154,46 @@
|
|
|
119
154
|
</span>
|
|
120
155
|
</th>
|
|
121
156
|
<th>
|
|
122
|
-
<
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
157
|
+
<div class="flex flex-col items-center gap-1 pt-2">
|
|
158
|
+
<div class="relative w-24">
|
|
159
|
+
<Tooltip
|
|
160
|
+
state={indicator ? undefined : 'invisible'}
|
|
161
|
+
targetClass="block"
|
|
162
|
+
let:tooltipID
|
|
163
|
+
>
|
|
164
|
+
<NumericInput
|
|
165
|
+
cx={['max-w-24', indicator && 'pr-7']}
|
|
166
|
+
{value}
|
|
167
|
+
state={indicator?.status}
|
|
168
|
+
aria-label="{label} target"
|
|
169
|
+
aria-describedby={indicator ? tooltipID : undefined}
|
|
170
|
+
on:change={(event) => {
|
|
171
|
+
handleValueChange(key, numberValueFromEvent(event) ?? 0)
|
|
172
|
+
}}
|
|
173
|
+
/>
|
|
174
|
+
<span slot="description">{indicator?.message}</span>
|
|
175
|
+
</Tooltip>
|
|
176
|
+
{#if status?.isEdited && onFieldReset}
|
|
177
|
+
<span class="absolute top-1/2 left-full ml-1 -translate-y-1/2">
|
|
178
|
+
<Tooltip>
|
|
179
|
+
<IconButton
|
|
180
|
+
icon="backup-restore"
|
|
181
|
+
label="Reset {label} to current"
|
|
182
|
+
onclick={() => {
|
|
183
|
+
onFieldReset(key)
|
|
184
|
+
}}
|
|
185
|
+
/>
|
|
186
|
+
<span slot="description">Reset {label} to its current value</span>
|
|
187
|
+
</Tooltip>
|
|
188
|
+
</span>
|
|
189
|
+
{/if}
|
|
190
|
+
</div>
|
|
191
|
+
{#if status}
|
|
192
|
+
<span class="text-subtle-2 font-roboto-mono text-xs font-normal">
|
|
193
|
+
Current {formatNumeric(toDisplay(key, status.current))}
|
|
194
|
+
</span>
|
|
195
|
+
{/if}
|
|
196
|
+
</div>
|
|
129
197
|
</th>
|
|
130
198
|
</tr>
|
|
131
199
|
{/each}
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import type { Pose } from '@viamrobotics/sdk';
|
|
2
|
+
export interface PoseFieldStatus {
|
|
3
|
+
current: number;
|
|
4
|
+
isEdited: boolean;
|
|
5
|
+
drift: number | undefined;
|
|
6
|
+
isMoving: boolean;
|
|
7
|
+
}
|
|
8
|
+
import type { Snippet } from 'svelte';
|
|
2
9
|
interface Props {
|
|
3
10
|
pose: Pose;
|
|
11
|
+
heading: Snippet;
|
|
4
12
|
onPoseChange: (pose: Pose) => void;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
description?: string;
|
|
13
|
+
description?: Snippet;
|
|
14
|
+
fieldStatus?: (key: keyof Pose) => PoseFieldStatus;
|
|
15
|
+
onFieldReset?: (key: keyof Pose) => void;
|
|
9
16
|
}
|
|
10
17
|
declare const PoseEditor: import("svelte").Component<Props, {}, "">;
|
|
11
18
|
type PoseEditor = ReturnType<typeof PoseEditor>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { QueryObserverResult } from '@tanstack/svelte-query'
|
|
3
3
|
import type { Snippet } from 'svelte'
|
|
4
|
+
import type { ClassValue } from 'svelte/elements'
|
|
4
5
|
|
|
5
6
|
import { useResizeObserver } from 'runed'
|
|
6
7
|
|
|
@@ -10,11 +11,11 @@
|
|
|
10
11
|
|
|
11
12
|
interface Props {
|
|
12
13
|
queries: QueryObserverResult[]
|
|
13
|
-
|
|
14
|
+
class?: ClassValue
|
|
14
15
|
children?: Snippet<[{ data: unknown[] }]>
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
const { queries,
|
|
18
|
+
const { queries, class: classNames, children }: Props = $props()
|
|
18
19
|
|
|
19
20
|
let el = $state.raw<HTMLDivElement>()
|
|
20
21
|
let contentRect = $state.raw<DOMRect>()
|
|
@@ -59,12 +60,14 @@
|
|
|
59
60
|
})
|
|
60
61
|
|
|
61
62
|
const isLoading = $derived(queries.some((query) => query.isLoading))
|
|
63
|
+
// A caller's class sets the placeholder height, so it replaces ContentRect's default `h-full`.
|
|
64
|
+
const contentRectClass = $derived(['w-full', classNames ?? 'h-full'])
|
|
62
65
|
</script>
|
|
63
66
|
|
|
64
67
|
{#if errors.length > 0}
|
|
65
68
|
<ContentRect
|
|
66
69
|
{contentRect}
|
|
67
|
-
|
|
70
|
+
class={contentRectClass}
|
|
68
71
|
>
|
|
69
72
|
{#each errors as error (errorKey(error))}
|
|
70
73
|
<ErrorDisplay lastError={error} />
|
|
@@ -73,7 +76,7 @@
|
|
|
73
76
|
{:else if isLoading}
|
|
74
77
|
<ContentRect
|
|
75
78
|
{contentRect}
|
|
76
|
-
|
|
79
|
+
class={contentRectClass}
|
|
77
80
|
>
|
|
78
81
|
<Progress />
|
|
79
82
|
</ContentRect>
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { QueryObserverResult } from '@tanstack/svelte-query';
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { ClassValue } from 'svelte/elements';
|
|
3
4
|
interface Props {
|
|
4
5
|
queries: QueryObserverResult[];
|
|
5
|
-
|
|
6
|
+
class?: ClassValue;
|
|
6
7
|
children?: Snippet<[{
|
|
7
8
|
data: unknown[];
|
|
8
9
|
}]>;
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { QueryObserverResult } from '@tanstack/svelte-query'
|
|
3
3
|
import type { Snippet } from 'svelte'
|
|
4
|
+
import type { ClassValue } from 'svelte/elements'
|
|
4
5
|
|
|
5
6
|
import Queries from './queries.svelte'
|
|
6
7
|
|
|
7
8
|
interface Props {
|
|
8
9
|
query: QueryObserverResult
|
|
9
|
-
|
|
10
|
+
class?: ClassValue
|
|
10
11
|
children?: Snippet
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
const { query,
|
|
14
|
+
const { query, class: classNames, children }: Props = $props()
|
|
14
15
|
</script>
|
|
15
16
|
|
|
16
17
|
<Queries
|
|
17
18
|
queries={[query]}
|
|
18
|
-
{
|
|
19
|
+
class={classNames}
|
|
19
20
|
>
|
|
20
21
|
{@render children?.()}
|
|
21
22
|
</Queries>
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { QueryObserverResult } from '@tanstack/svelte-query';
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { ClassValue } from 'svelte/elements';
|
|
3
4
|
interface Props {
|
|
4
5
|
query: QueryObserverResult;
|
|
5
|
-
|
|
6
|
+
class?: ClassValue;
|
|
6
7
|
children?: Snippet;
|
|
7
8
|
}
|
|
8
9
|
declare const Query: import("svelte").Component<Props, {}, "">;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import SectionBody from './section-body.svelte';
|
|
2
|
+
import SectionErrors from './section-errors.svelte';
|
|
3
|
+
import SectionHeading from './section-heading.svelte';
|
|
4
|
+
import SectionMethod from './section-method.svelte';
|
|
5
|
+
import SectionPlaceholder from './section-placeholder.svelte';
|
|
6
|
+
import SectionText from './section-text.svelte';
|
|
7
|
+
import SectionTooltip from './section-tooltip.svelte';
|
|
8
|
+
import Root from './section.svelte';
|
|
9
|
+
export { useSectionLoading } from './section-loading';
|
|
10
|
+
export { dedupeErrors, useSectionErrors, type SectionMutation, type SectionQuery, type SectionSources, } from './use-section-errors.svelte';
|
|
11
|
+
export declare const Section: typeof Root & {
|
|
12
|
+
Body: typeof SectionBody;
|
|
13
|
+
Errors: typeof SectionErrors;
|
|
14
|
+
Heading: typeof SectionHeading;
|
|
15
|
+
Method: typeof SectionMethod;
|
|
16
|
+
Placeholder: typeof SectionPlaceholder;
|
|
17
|
+
Text: typeof SectionText;
|
|
18
|
+
Tooltip: typeof SectionTooltip;
|
|
19
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import SectionBody from './section-body.svelte';
|
|
2
|
+
import SectionErrors from './section-errors.svelte';
|
|
3
|
+
import SectionHeading from './section-heading.svelte';
|
|
4
|
+
import SectionMethod from './section-method.svelte';
|
|
5
|
+
import SectionPlaceholder from './section-placeholder.svelte';
|
|
6
|
+
import SectionText from './section-text.svelte';
|
|
7
|
+
import SectionTooltip from './section-tooltip.svelte';
|
|
8
|
+
import Root from './section.svelte';
|
|
9
|
+
export { useSectionLoading } from './section-loading';
|
|
10
|
+
export { dedupeErrors, useSectionErrors, } from './use-section-errors.svelte';
|
|
11
|
+
export const Section = Object.assign(Root, {
|
|
12
|
+
Body: SectionBody,
|
|
13
|
+
Errors: SectionErrors,
|
|
14
|
+
Heading: SectionHeading,
|
|
15
|
+
Method: SectionMethod,
|
|
16
|
+
Placeholder: SectionPlaceholder,
|
|
17
|
+
Text: SectionText,
|
|
18
|
+
Tooltip: SectionTooltip,
|
|
19
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte'
|
|
3
|
+
|
|
4
|
+
import Boundary from '../boundary.svelte'
|
|
5
|
+
import Progress from '../progress.svelte'
|
|
6
|
+
import { provideSectionLoading } from './section-loading'
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
children: Snippet
|
|
10
|
+
isLoading?: boolean
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Exists only for the migration. Once every section passes it, skeleton becomes
|
|
13
|
+
* the only behavior and this prop and the progress-bar swap are removed.
|
|
14
|
+
*/
|
|
15
|
+
skeleton?: boolean
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const { isLoading = false, skeleton = false, children }: Props = $props()
|
|
19
|
+
|
|
20
|
+
provideSectionLoading(() => skeleton && isLoading)
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
{#if skeleton}
|
|
24
|
+
<div
|
|
25
|
+
class="contents"
|
|
26
|
+
aria-busy={isLoading}
|
|
27
|
+
>
|
|
28
|
+
<Boundary {children} />
|
|
29
|
+
</div>
|
|
30
|
+
{:else if isLoading}
|
|
31
|
+
<div class="h-6">
|
|
32
|
+
<Progress />
|
|
33
|
+
</div>
|
|
34
|
+
{:else}
|
|
35
|
+
<Boundary {children} />
|
|
36
|
+
{/if}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
interface Props {
|
|
3
|
+
children: Snippet;
|
|
4
|
+
isLoading?: boolean;
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Exists only for the migration. Once every section passes it, skeleton becomes
|
|
7
|
+
* the only behavior and this prop and the progress-bar swap are removed.
|
|
8
|
+
*/
|
|
9
|
+
skeleton?: boolean;
|
|
10
|
+
}
|
|
11
|
+
declare const SectionBody: import("svelte").Component<Props, {}, "">;
|
|
12
|
+
type SectionBody = ReturnType<typeof SectionBody>;
|
|
13
|
+
export default SectionBody;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import ErrorDisplay from '../error.svelte'
|
|
3
|
+
import { errorKey } from './error-key'
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
errors: Error[]
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const { errors }: Props = $props()
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
{#if errors.length > 0}
|
|
13
|
+
<div class="flex w-full flex-col gap-1">
|
|
14
|
+
{#each errors as error (errorKey(error))}
|
|
15
|
+
<ErrorDisplay lastError={error} />
|
|
16
|
+
{/each}
|
|
17
|
+
</div>
|
|
18
|
+
{/if}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte'
|
|
3
|
+
import type { HTMLAttributes } from 'svelte/elements'
|
|
4
|
+
|
|
5
|
+
interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
children: Snippet
|
|
7
|
+
aside?: Snippet
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const { children, aside, class: className, ...rest }: Props = $props()
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<div
|
|
14
|
+
class={['flex flex-row items-center gap-1', className]}
|
|
15
|
+
{...rest}
|
|
16
|
+
>
|
|
17
|
+
<h3 class="flex flex-row items-center gap-1 text-sm font-semibold">
|
|
18
|
+
{@render children()}
|
|
19
|
+
</h3>
|
|
20
|
+
{@render aside?.()}
|
|
21
|
+
</div>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
children: Snippet;
|
|
5
|
+
aside?: Snippet;
|
|
6
|
+
}
|
|
7
|
+
declare const SectionHeading: import("svelte").Component<Props, {}, "">;
|
|
8
|
+
type SectionHeading = ReturnType<typeof SectionHeading>;
|
|
9
|
+
export default SectionHeading;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { getContext, setContext } from 'svelte';
|
|
2
|
+
const SECTION_LOADING_KEY = Symbol('section-loading');
|
|
3
|
+
export const provideSectionLoading = (isLoading) => {
|
|
4
|
+
return setContext(SECTION_LOADING_KEY, {
|
|
5
|
+
get isLoading() {
|
|
6
|
+
return isLoading();
|
|
7
|
+
},
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
export const useSectionLoading = () => getContext(SECTION_LOADING_KEY) ?? { isLoading: false };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ResourceTriplet } from '../../resource-triplet'
|
|
3
|
+
|
|
4
|
+
import { apiDocsHref } from '../../api-docs-href'
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
/** RDK method name in PascalCase. */
|
|
8
|
+
method: string
|
|
9
|
+
api: ResourceTriplet
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const { method, api }: Props = $props()
|
|
13
|
+
|
|
14
|
+
// Method names are the camelCase form of the PascalCase heading (GetPosition → getPosition).
|
|
15
|
+
const href = $derived(apiDocsHref(api, method.charAt(0).toLowerCase() + method.slice(1)))
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
{#if href}
|
|
19
|
+
<a
|
|
20
|
+
{href}
|
|
21
|
+
target="_blank"
|
|
22
|
+
rel="noopener noreferrer external"
|
|
23
|
+
class="decoration-gray-5 hover:decoration-default font-mono underline underline-offset-3"
|
|
24
|
+
>
|
|
25
|
+
{method}
|
|
26
|
+
</a>
|
|
27
|
+
{:else}
|
|
28
|
+
<span class="font-mono">{method}</span>
|
|
29
|
+
{/if}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ResourceTriplet } from '../../resource-triplet';
|
|
2
|
+
interface Props {
|
|
3
|
+
/** RDK method name in PascalCase. */
|
|
4
|
+
method: string;
|
|
5
|
+
api: ResourceTriplet;
|
|
6
|
+
}
|
|
7
|
+
declare const SectionMethod: import("svelte").Component<Props, {}, "">;
|
|
8
|
+
type SectionMethod = ReturnType<typeof SectionMethod>;
|
|
9
|
+
export default SectionMethod;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ClassValue } from 'svelte/elements'
|
|
3
|
+
|
|
4
|
+
import { useSectionLoading } from './section-loading'
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
class?: ClassValue
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const { class: className = 'w-12' }: Props = $props()
|
|
11
|
+
|
|
12
|
+
const loading = useSectionLoading()
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
{#if loading.isLoading}
|
|
16
|
+
<span
|
|
17
|
+
aria-hidden="true"
|
|
18
|
+
data-testid="section-placeholder-loading"
|
|
19
|
+
class={[
|
|
20
|
+
'bg-light inline-block h-2.5 animate-pulse align-middle motion-reduce:animate-none',
|
|
21
|
+
className,
|
|
22
|
+
]}
|
|
23
|
+
></span>
|
|
24
|
+
{:else}
|
|
25
|
+
<span class="text-subtle-2">
|
|
26
|
+
<span aria-hidden="true">—</span>
|
|
27
|
+
<span class="sr-only">No data</span>
|
|
28
|
+
</span>
|
|
29
|
+
{/if}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ClassValue } from 'svelte/elements';
|
|
2
|
+
interface Props {
|
|
3
|
+
class?: ClassValue;
|
|
4
|
+
}
|
|
5
|
+
declare const SectionPlaceholder: import("svelte").Component<Props, {}, "">;
|
|
6
|
+
type SectionPlaceholder = ReturnType<typeof SectionPlaceholder>;
|
|
7
|
+
export default SectionPlaceholder;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte'
|
|
3
|
+
import type { HTMLAttributes } from 'svelte/elements'
|
|
4
|
+
|
|
5
|
+
interface Props extends HTMLAttributes<HTMLParagraphElement> {
|
|
6
|
+
children: Snippet
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const { children, class: className, ...rest }: Props = $props()
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<p
|
|
13
|
+
class={['text-subtle-2 text-xs', className]}
|
|
14
|
+
{...rest}
|
|
15
|
+
>
|
|
16
|
+
{@render children()}
|
|
17
|
+
</p>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
interface Props extends HTMLAttributes<HTMLParagraphElement> {
|
|
4
|
+
children: Snippet;
|
|
5
|
+
}
|
|
6
|
+
declare const SectionText: import("svelte").Component<Props, {}, "">;
|
|
7
|
+
type SectionText = ReturnType<typeof SectionText>;
|
|
8
|
+
export default SectionText;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte'
|
|
3
|
+
|
|
4
|
+
import { Icon, Tooltip } from '@viamrobotics/prime-core'
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
children: Snippet
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const { children }: Props = $props()
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<Tooltip>
|
|
14
|
+
<Icon
|
|
15
|
+
name="information-outline"
|
|
16
|
+
cx="text-gray-6"
|
|
17
|
+
/>
|
|
18
|
+
|
|
19
|
+
<p
|
|
20
|
+
slot="description"
|
|
21
|
+
class="text-xs whitespace-pre-line"
|
|
22
|
+
>
|
|
23
|
+
{@render children()}
|
|
24
|
+
</p>
|
|
25
|
+
</Tooltip>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte'
|
|
3
|
+
import type { HTMLAttributes } from 'svelte/elements'
|
|
4
|
+
|
|
5
|
+
interface Props extends HTMLAttributes<HTMLElement> {
|
|
6
|
+
children: Snippet
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const { children, class: className, ...rest }: Props = $props()
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<section
|
|
13
|
+
class={['flex p-4', className]}
|
|
14
|
+
{...rest}
|
|
15
|
+
>
|
|
16
|
+
{@render children()}
|
|
17
|
+
</section>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
interface Props extends HTMLAttributes<HTMLElement> {
|
|
4
|
+
children: Snippet;
|
|
5
|
+
}
|
|
6
|
+
declare const Section: import("svelte").Component<Props, {}, "">;
|
|
7
|
+
type Section = ReturnType<typeof Section>;
|
|
8
|
+
export default Section;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { QueryObserverResult } from '@tanstack/svelte-query';
|
|
2
|
+
export type SectionQuery = Pick<QueryObserverResult, 'error' | 'fetchStatus' | 'isLoading' | 'isSuccess'>;
|
|
3
|
+
export interface SectionMutation {
|
|
4
|
+
error: Error | null;
|
|
5
|
+
}
|
|
6
|
+
export interface SectionSources {
|
|
7
|
+
queries?: SectionQuery[];
|
|
8
|
+
mutations?: SectionMutation[];
|
|
9
|
+
}
|
|
10
|
+
export declare const dedupeErrors: (errors: (Error | null)[]) => Error[];
|
|
11
|
+
/**
|
|
12
|
+
* A section's distinct errors across its queries and mutations, and whether its first load is
|
|
13
|
+
* still running.
|
|
14
|
+
*/
|
|
15
|
+
export declare const useSectionErrors: (getSources: () => SectionSources) => {
|
|
16
|
+
readonly errors: Error[];
|
|
17
|
+
readonly isLoading: boolean;
|
|
18
|
+
};
|