@viamrobotics/test-widgets 0.15.1 → 0.17.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 +58 -49
- package/dist/components/api-section.svelte.d.ts +24 -10
- 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 +10 -5
- package/dist/components/content-rect.svelte.d.ts +3 -1
- package/dist/components/error.svelte +15 -5
- package/dist/components/error.svelte.d.ts +8 -1
- package/dist/components/index.d.ts +4 -3
- package/dist/components/index.js +4 -3
- package/dist/components/is-moving.svelte +29 -35
- package/dist/components/is-moving.svelte.d.ts +6 -6
- package/dist/components/maplibre/index.svelte +5 -6
- package/dist/components/maplibre/index.svelte.d.ts +3 -1
- package/dist/components/pose-editor.svelte +83 -15
- package/dist/components/pose-editor.svelte.d.ts +11 -4
- package/dist/components/progress.svelte +1 -0
- package/dist/components/queries.svelte +14 -4
- package/dist/components/queries.svelte.d.ts +6 -1
- package/dist/components/query.svelte +11 -3
- package/dist/components/query.svelte.d.ts +6 -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 +21 -0
- package/dist/components/section/index.js +21 -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-error-reporter.d.ts +8 -0
- package/dist/components/section/section-error-reporter.js +7 -0
- package/dist/components/section/section-error.svelte +36 -0
- package/dist/components/section/section-error.svelte.d.ts +9 -0
- package/dist/components/section/section-errors.svelte +145 -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 +23 -0
- package/dist/components/section/section.svelte.d.ts +11 -0
- package/dist/components/section/use-section-errors.svelte.d.ts +19 -0
- package/dist/components/section/use-section-errors.svelte.js +49 -0
- package/dist/components/stop-button.svelte +1 -5
- package/dist/components/stop-button.svelte.d.ts +0 -1
- package/dist/components/stop.svelte +31 -14
- package/dist/components/stop.svelte.d.ts +6 -1
- package/dist/components/widgets/arm/arm.svelte +43 -40
- package/dist/components/widgets/arm/get-joint-positions-widget.svelte +10 -9
- 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 +16 -6
- package/dist/components/widgets/arm/manual-mode.svelte +1 -5
- package/dist/components/widgets/arm/manual-mode.svelte.d.ts +0 -1
- package/dist/components/widgets/arm/move-to-joint-positions-widget.svelte +22 -8
- package/dist/components/widgets/arm/move-to-joint-positions.svelte +15 -17
- package/dist/components/widgets/arm/move-to-joint-positions.svelte.d.ts +0 -1
- package/dist/components/widgets/arm/move-to-position-control.svelte +45 -33
- package/dist/components/widgets/arm/move-to-position.svelte +97 -34
- package/dist/components/widgets/arm/move-to-position.svelte.d.ts +3 -2
- package/dist/components/widgets/arm/quick-move-widget.svelte +10 -4
- package/dist/components/widgets/arm/quick-move.svelte +1 -4
- package/dist/components/widgets/arm/quick-move.svelte.d.ts +0 -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 +80 -77
- package/dist/components/widgets/audio-input/get-properties-widget.svelte +16 -16
- package/dist/components/widgets/audio-output/audio-output.svelte +87 -84
- package/dist/components/widgets/audio-output/get-properties-widget.svelte +16 -16
- package/dist/components/widgets/base/base.svelte +78 -43
- package/dist/components/widgets/base/move-straight-widget.svelte +16 -4
- package/dist/components/widgets/base/quick-move-widget.svelte +25 -9
- package/dist/components/widgets/base/quick-move.svelte +5 -6
- package/dist/components/widgets/base/set-power-widget.svelte +20 -8
- package/dist/components/widgets/base/set-power.svelte +6 -4
- package/dist/components/widgets/base/set-velocity-widget.svelte +20 -8
- package/dist/components/widgets/base/set-velocity.svelte +6 -4
- package/dist/components/widgets/base/spin-widget.svelte +20 -8
- 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/board/read-write-pins.svelte +2 -2
- package/dist/components/widgets/button/push.svelte +2 -2
- package/dist/components/widgets/camera/camera.svelte +17 -24
- package/dist/components/widgets/camera/live-or-polling-video.svelte +33 -30
- package/dist/components/widgets/custom-control/__tests__/__fixtures__/with-sibling.svelte +10 -0
- package/dist/components/widgets/custom-control/control-frame.svelte +60 -0
- package/dist/components/widgets/custom-control/control-frame.svelte.d.ts +10 -0
- package/dist/components/widgets/custom-control/create-control-host.svelte.d.ts +19 -0
- package/dist/components/widgets/custom-control/create-control-host.svelte.js +26 -0
- package/dist/components/widgets/custom-control/custom-control.d.ts +35 -0
- package/dist/components/widgets/custom-control/custom-control.js +85 -0
- package/dist/components/widgets/custom-control/custom-control.svelte +45 -0
- package/dist/components/widgets/custom-control/custom-control.svelte.d.ts +14 -0
- package/dist/components/widgets/discovery/discovery.svelte +13 -17
- package/dist/components/widgets/encoder/encoder.svelte +25 -21
- package/dist/components/widgets/encoder/get-position-widget.svelte +19 -16
- package/dist/components/widgets/gantry/gantry.svelte +58 -76
- package/dist/components/widgets/gantry/get-position-widget.svelte +15 -14
- package/dist/components/widgets/gantry/home.svelte +21 -10
- package/dist/components/widgets/gantry/move-to-position-widget.svelte +2 -1
- package/dist/components/widgets/gantry/move-to-position.svelte +1 -4
- package/dist/components/widgets/gantry/move-to-position.svelte.d.ts +0 -1
- package/dist/components/widgets/gantry/quick-move-widget.svelte +3 -2
- package/dist/components/widgets/gantry/quick-move.svelte +1 -5
- package/dist/components/widgets/gantry/quick-move.svelte.d.ts +0 -1
- package/dist/components/widgets/generic/generic.svelte +11 -6
- package/dist/components/widgets/gripper/grab-widget.svelte +26 -0
- package/dist/components/widgets/gripper/grab-widget.svelte.d.ts +7 -0
- package/dist/components/widgets/gripper/grab.svelte +3 -19
- package/dist/components/widgets/gripper/grab.svelte.d.ts +1 -2
- package/dist/components/widgets/gripper/gripper.svelte +18 -18
- package/dist/components/widgets/gripper/is-holding-something.svelte +21 -21
- package/dist/components/widgets/gripper/open-widget.svelte +26 -0
- package/dist/components/widgets/gripper/open-widget.svelte.d.ts +7 -0
- package/dist/components/widgets/gripper/open.svelte +3 -19
- package/dist/components/widgets/gripper/open.svelte.d.ts +1 -2
- package/dist/components/widgets/input-controller/input-controller.svelte +10 -16
- package/dist/components/widgets/input-controller/webgamepad.svelte +2 -2
- 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 +27 -31
- package/dist/components/widgets/motion/move-widget.svelte +32 -12
- package/dist/components/widgets/motion/move-widget.svelte.d.ts +6 -0
- package/dist/components/widgets/motion/move.svelte +6 -16
- package/dist/components/widgets/motion/move.svelte.d.ts +0 -1
- package/dist/components/widgets/motor/go-for-view.svelte +16 -8
- package/dist/components/widgets/motor/go-to-view.svelte +12 -4
- package/dist/components/widgets/motor/motor.svelte +100 -64
- package/dist/components/widgets/motor/quick-move-widget.svelte +16 -8
- package/dist/components/widgets/motor/set-power-widget.svelte +12 -4
- package/dist/components/widgets/motor/set-rpm-widget.svelte +12 -4
- package/dist/components/widgets/movement-sensor/get-accuracy-widget.svelte +8 -11
- package/dist/components/widgets/movement-sensor/get-compass-heading-widget.svelte +8 -11
- package/dist/components/widgets/movement-sensor/get-orientation-widget.svelte +8 -11
- package/dist/components/widgets/movement-sensor/get-position-widget.svelte +8 -11
- package/dist/components/widgets/movement-sensor/movement-sensor.svelte +64 -66
- package/dist/components/widgets/operations-and-sessions/operations-and-sessions.svelte +2 -1
- package/dist/components/widgets/power-sensor/get-current-widget.svelte +8 -11
- package/dist/components/widgets/power-sensor/get-power-widget.svelte +8 -11
- package/dist/components/widgets/power-sensor/get-voltage-widget.svelte +8 -11
- package/dist/components/widgets/power-sensor/power-sensor.svelte +35 -45
- package/dist/components/widgets/sensor/sensor.svelte +8 -12
- package/dist/components/widgets/servo/move-widget.svelte +2 -1
- package/dist/components/widgets/servo/move.svelte +1 -4
- package/dist/components/widgets/servo/move.svelte.d.ts +0 -1
- package/dist/components/widgets/servo/quick-move-widget.svelte +2 -1
- package/dist/components/widgets/servo/quick-move.svelte +1 -5
- package/dist/components/widgets/servo/quick-move.svelte.d.ts +0 -1
- package/dist/components/widgets/servo/servo.svelte +53 -37
- package/dist/components/widgets/slam/get-position-widget.svelte +8 -11
- package/dist/components/widgets/slam/move-on-map.svelte +9 -6
- package/dist/components/widgets/slam/move-on-map.svelte.d.ts +2 -1
- package/dist/components/widgets/slam/slam.svelte +65 -75
- package/dist/components/widgets/switch/position-view.svelte +1 -1
- package/dist/components/widgets/switch/position.svelte +2 -2
- 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 +19 -5
- package/dist/components/board/pin-section.svelte +0 -28
- package/dist/components/board/pin-section.svelte.d.ts +0 -9
- package/dist/components/mutation-section.svelte +0 -73
- package/dist/components/mutation-section.svelte.d.ts +0 -16
- package/dist/components/mutation-view.svelte +0 -29
- package/dist/components/mutation-view.svelte.d.ts +0 -10
- package/dist/components/section-group.svelte +0 -64
- package/dist/components/section-group.svelte.d.ts +0 -14
- package/dist/components/section-title.svelte +0 -63
- package/dist/components/section-title.svelte.d.ts +0 -14
|
@@ -1,46 +1,43 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type
|
|
3
|
-
|
|
4
|
-
ArmClient,
|
|
5
|
-
Base,
|
|
6
|
-
BaseClient,
|
|
7
|
-
Gantry,
|
|
8
|
-
GantryClient,
|
|
9
|
-
Gripper,
|
|
10
|
-
GripperClient,
|
|
11
|
-
Motor,
|
|
12
|
-
MotorClient,
|
|
13
|
-
Servo,
|
|
14
|
-
ServoClient,
|
|
15
|
-
} from '@viamrobotics/sdk'
|
|
16
|
-
import type { Snippet } from 'svelte'
|
|
2
|
+
import type * as SDK from '@viamrobotics/sdk'
|
|
3
|
+
import type { HTMLAttributes } from 'svelte/elements'
|
|
17
4
|
|
|
18
5
|
import { createResourceClient, createResourceQuery } from '@viamrobotics/svelte-sdk'
|
|
19
6
|
|
|
7
|
+
import type { ResourceTriplet } from '../resource-triplet'
|
|
8
|
+
|
|
20
9
|
import ApiSection from './api-section.svelte'
|
|
21
|
-
import
|
|
10
|
+
import { Section } from './section'
|
|
22
11
|
import StatusPill from './status-pill.svelte'
|
|
23
12
|
|
|
24
13
|
type Client =
|
|
25
|
-
| typeof ArmClient
|
|
26
|
-
| typeof BaseClient
|
|
27
|
-
| typeof GantryClient
|
|
28
|
-
| typeof GripperClient
|
|
29
|
-
| typeof MotorClient
|
|
30
|
-
| typeof ServoClient
|
|
14
|
+
| typeof SDK.ArmClient
|
|
15
|
+
| typeof SDK.BaseClient
|
|
16
|
+
| typeof SDK.GantryClient
|
|
17
|
+
| typeof SDK.GripperClient
|
|
18
|
+
| typeof SDK.MotorClient
|
|
19
|
+
| typeof SDK.ServoClient
|
|
20
|
+
|
|
21
|
+
type Resource = SDK.Arm | SDK.Base | SDK.Gantry | SDK.Gripper | SDK.Motor | SDK.Servo
|
|
31
22
|
|
|
32
|
-
interface Props {
|
|
23
|
+
interface Props extends HTMLAttributes<HTMLElement> {
|
|
33
24
|
client: Client
|
|
34
25
|
partID: string
|
|
35
26
|
resourceName: string
|
|
36
|
-
api:
|
|
37
|
-
children?: Snippet
|
|
27
|
+
api: ResourceTriplet
|
|
38
28
|
}
|
|
39
29
|
|
|
40
|
-
const {
|
|
30
|
+
const {
|
|
31
|
+
client: clientClass,
|
|
32
|
+
partID,
|
|
33
|
+
resourceName,
|
|
34
|
+
api,
|
|
35
|
+
children,
|
|
36
|
+
class: className,
|
|
37
|
+
}: Props = $props()
|
|
41
38
|
|
|
42
39
|
const client = $derived(
|
|
43
|
-
createResourceClient<
|
|
40
|
+
createResourceClient<Resource>(
|
|
44
41
|
clientClass,
|
|
45
42
|
() => partID,
|
|
46
43
|
() => resourceName
|
|
@@ -51,15 +48,12 @@
|
|
|
51
48
|
</script>
|
|
52
49
|
|
|
53
50
|
<ApiSection
|
|
54
|
-
|
|
51
|
+
class={['grow flex-col gap-4', className]}
|
|
52
|
+
method="IsMoving"
|
|
53
|
+
queries={[query]}
|
|
55
54
|
{api}
|
|
56
|
-
bottomText="Updates automatically"
|
|
57
|
-
class="grow"
|
|
58
55
|
>
|
|
59
|
-
<
|
|
60
|
-
<StatusPill isActive={query.data ?? false} />
|
|
61
|
-
</Query>
|
|
62
|
-
|
|
63
|
-
<!-- slot for additional actuation info Ex: Motor's IsPowered & GetPosition -->
|
|
56
|
+
<StatusPill isActive={query.data ?? false} />
|
|
64
57
|
{@render children?.()}
|
|
58
|
+
<Section.Text class="mt-auto">Updates automatically</Section.Text>
|
|
65
59
|
</ApiSection>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type {
|
|
3
|
-
type
|
|
4
|
-
|
|
1
|
+
import type * as SDK from '@viamrobotics/sdk';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import type { ResourceTriplet } from '../resource-triplet';
|
|
4
|
+
type Client = typeof SDK.ArmClient | typeof SDK.BaseClient | typeof SDK.GantryClient | typeof SDK.GripperClient | typeof SDK.MotorClient | typeof SDK.ServoClient;
|
|
5
|
+
interface Props extends HTMLAttributes<HTMLElement> {
|
|
5
6
|
client: Client;
|
|
6
7
|
partID: string;
|
|
7
8
|
resourceName: string;
|
|
8
|
-
api:
|
|
9
|
-
children?: Snippet;
|
|
9
|
+
api: ResourceTriplet;
|
|
10
10
|
}
|
|
11
11
|
declare const IsMoving: import("svelte").Component<Props, {}, "">;
|
|
12
12
|
type IsMoving = ReturnType<typeof IsMoving>;
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
Creates a maplibre-gl map that will fill its parent.
|
|
5
5
|
|
|
6
|
-
Children will mount once the map is fully loaded.
|
|
6
|
+
Children will mount once the map is fully loaded. They render inside the
|
|
7
|
+
map's own positioned, isolated box, so absolutely positioned overlays sit
|
|
8
|
+
relative to the map and their z-index never competes with the host page.
|
|
7
9
|
|
|
8
10
|
```svelte
|
|
9
11
|
<MapLibre mapProvider="open-street">
|
|
@@ -220,12 +222,8 @@
|
|
|
220
222
|
})
|
|
221
223
|
</script>
|
|
222
224
|
|
|
223
|
-
{#if created}
|
|
224
|
-
{@render children?.()}
|
|
225
|
-
{/if}
|
|
226
|
-
|
|
227
225
|
<div
|
|
228
|
-
class={['h-full', className]}
|
|
226
|
+
class={['relative isolate h-full', className]}
|
|
229
227
|
{...rest}
|
|
230
228
|
>
|
|
231
229
|
<div
|
|
@@ -234,6 +232,7 @@
|
|
|
234
232
|
></div>
|
|
235
233
|
|
|
236
234
|
{#if created}
|
|
235
|
+
{@render children?.()}
|
|
237
236
|
{@render layer?.()}
|
|
238
237
|
{/if}
|
|
239
238
|
</div>
|
|
@@ -56,7 +56,9 @@ interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
|
56
56
|
/**
|
|
57
57
|
* Creates a maplibre-gl map that will fill its parent.
|
|
58
58
|
*
|
|
59
|
-
* Children will mount once the map is fully loaded.
|
|
59
|
+
* Children will mount once the map is fully loaded. They render inside the
|
|
60
|
+
* map's own positioned, isolated box, so absolutely positioned overlays sit
|
|
61
|
+
* relative to the map and their z-index never competes with the host page.
|
|
60
62
|
*
|
|
61
63
|
* ```svelte
|
|
62
64
|
* <MapLibre mapProvider="open-street">
|
|
@@ -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,14 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
|
|
4
|
+
@deprecated A section owns its async state now. Pass the queries to `ApiSection` as `queries`, or to a
|
|
5
|
+
`Section` control's `useSectionErrors` call, and guard `query.data` in the children. Kept for the sectionless files until their resource PRs.
|
|
6
|
+
-->
|
|
7
|
+
|
|
1
8
|
<script lang="ts">
|
|
2
9
|
import type { QueryObserverResult } from '@tanstack/svelte-query'
|
|
3
10
|
import type { Snippet } from 'svelte'
|
|
11
|
+
import type { ClassValue } from 'svelte/elements'
|
|
4
12
|
|
|
5
13
|
import { useResizeObserver } from 'runed'
|
|
6
14
|
|
|
@@ -10,11 +18,11 @@
|
|
|
10
18
|
|
|
11
19
|
interface Props {
|
|
12
20
|
queries: QueryObserverResult[]
|
|
13
|
-
|
|
21
|
+
class?: ClassValue
|
|
14
22
|
children?: Snippet<[{ data: unknown[] }]>
|
|
15
23
|
}
|
|
16
24
|
|
|
17
|
-
const { queries,
|
|
25
|
+
const { queries, class: classNames, children }: Props = $props()
|
|
18
26
|
|
|
19
27
|
let el = $state.raw<HTMLDivElement>()
|
|
20
28
|
let contentRect = $state.raw<DOMRect>()
|
|
@@ -59,12 +67,14 @@
|
|
|
59
67
|
})
|
|
60
68
|
|
|
61
69
|
const isLoading = $derived(queries.some((query) => query.isLoading))
|
|
70
|
+
// A caller's class sets the placeholder height, so it replaces ContentRect's default `h-full`.
|
|
71
|
+
const contentRectClass = $derived(['w-full', classNames ?? 'h-full'])
|
|
62
72
|
</script>
|
|
63
73
|
|
|
64
74
|
{#if errors.length > 0}
|
|
65
75
|
<ContentRect
|
|
66
76
|
{contentRect}
|
|
67
|
-
|
|
77
|
+
class={contentRectClass}
|
|
68
78
|
>
|
|
69
79
|
{#each errors as error (errorKey(error))}
|
|
70
80
|
<ErrorDisplay lastError={error} />
|
|
@@ -73,7 +83,7 @@
|
|
|
73
83
|
{:else if isLoading}
|
|
74
84
|
<ContentRect
|
|
75
85
|
{contentRect}
|
|
76
|
-
|
|
86
|
+
class={contentRectClass}
|
|
77
87
|
>
|
|
78
88
|
<Progress />
|
|
79
89
|
</ContentRect>
|
|
@@ -1,12 +1,17 @@
|
|
|
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
|
}]>;
|
|
9
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated A section owns its async state now. Pass the queries to `ApiSection` as `queries`, or to a
|
|
13
|
+
* `Section` control's `useSectionErrors` call, and guard `query.data` in the children. Kept for the sectionless files until their resource PRs.
|
|
14
|
+
*/
|
|
10
15
|
declare const Queries: import("svelte").Component<Props, {}, "">;
|
|
11
16
|
type Queries = ReturnType<typeof Queries>;
|
|
12
17
|
export default Queries;
|
|
@@ -1,21 +1,29 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
|
|
4
|
+
@deprecated A section owns its async state now. Pass the query to `ApiSection` as `queries`, or to a
|
|
5
|
+
`Section` control's `useSectionErrors` call, and guard `query.data` in the children. Kept for the sectionless files until their resource PRs.
|
|
6
|
+
-->
|
|
7
|
+
|
|
1
8
|
<script lang="ts">
|
|
2
9
|
import type { QueryObserverResult } from '@tanstack/svelte-query'
|
|
3
10
|
import type { Snippet } from 'svelte'
|
|
11
|
+
import type { ClassValue } from 'svelte/elements'
|
|
4
12
|
|
|
5
13
|
import Queries from './queries.svelte'
|
|
6
14
|
|
|
7
15
|
interface Props {
|
|
8
16
|
query: QueryObserverResult
|
|
9
|
-
|
|
17
|
+
class?: ClassValue
|
|
10
18
|
children?: Snippet
|
|
11
19
|
}
|
|
12
20
|
|
|
13
|
-
const { query,
|
|
21
|
+
const { query, class: classNames, children }: Props = $props()
|
|
14
22
|
</script>
|
|
15
23
|
|
|
16
24
|
<Queries
|
|
17
25
|
queries={[query]}
|
|
18
|
-
{
|
|
26
|
+
class={classNames}
|
|
19
27
|
>
|
|
20
28
|
{@render children?.()}
|
|
21
29
|
</Queries>
|
|
@@ -1,10 +1,15 @@
|
|
|
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
|
}
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated A section owns its async state now. Pass the query to `ApiSection` as `queries`, or to a
|
|
11
|
+
* `Section` control's `useSectionErrors` call, and guard `query.data` in the children. Kept for the sectionless files until their resource PRs.
|
|
12
|
+
*/
|
|
8
13
|
declare const Query: import("svelte").Component<Props, {}, "">;
|
|
9
14
|
type Query = ReturnType<typeof Query>;
|
|
10
15
|
export default Query;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import SectionBody from './section-body.svelte';
|
|
2
|
+
import SectionError from './section-error.svelte';
|
|
3
|
+
import SectionErrors from './section-errors.svelte';
|
|
4
|
+
import SectionHeading from './section-heading.svelte';
|
|
5
|
+
import SectionMethod from './section-method.svelte';
|
|
6
|
+
import SectionPlaceholder from './section-placeholder.svelte';
|
|
7
|
+
import SectionText from './section-text.svelte';
|
|
8
|
+
import SectionTooltip from './section-tooltip.svelte';
|
|
9
|
+
import Root from './section.svelte';
|
|
10
|
+
export { useSectionLoading } from './section-loading';
|
|
11
|
+
export { dedupeErrors, useSectionErrors, type SectionMutation, type SectionQuery, type SectionSources, } from './use-section-errors.svelte';
|
|
12
|
+
export declare const Section: typeof Root & {
|
|
13
|
+
Body: typeof SectionBody;
|
|
14
|
+
Error: typeof SectionError;
|
|
15
|
+
Errors: typeof SectionErrors;
|
|
16
|
+
Heading: typeof SectionHeading;
|
|
17
|
+
Method: typeof SectionMethod;
|
|
18
|
+
Placeholder: typeof SectionPlaceholder;
|
|
19
|
+
Text: typeof SectionText;
|
|
20
|
+
Tooltip: typeof SectionTooltip;
|
|
21
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import SectionBody from './section-body.svelte';
|
|
2
|
+
import SectionError from './section-error.svelte';
|
|
3
|
+
import SectionErrors from './section-errors.svelte';
|
|
4
|
+
import SectionHeading from './section-heading.svelte';
|
|
5
|
+
import SectionMethod from './section-method.svelte';
|
|
6
|
+
import SectionPlaceholder from './section-placeholder.svelte';
|
|
7
|
+
import SectionText from './section-text.svelte';
|
|
8
|
+
import SectionTooltip from './section-tooltip.svelte';
|
|
9
|
+
import Root from './section.svelte';
|
|
10
|
+
export { useSectionLoading } from './section-loading';
|
|
11
|
+
export { dedupeErrors, useSectionErrors, } from './use-section-errors.svelte';
|
|
12
|
+
export const Section = Object.assign(Root, {
|
|
13
|
+
Body: SectionBody,
|
|
14
|
+
Error: SectionError,
|
|
15
|
+
Errors: SectionErrors,
|
|
16
|
+
Heading: SectionHeading,
|
|
17
|
+
Method: SectionMethod,
|
|
18
|
+
Placeholder: SectionPlaceholder,
|
|
19
|
+
Text: SectionText,
|
|
20
|
+
Tooltip: SectionTooltip,
|
|
21
|
+
});
|
|
@@ -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,8 @@
|
|
|
1
|
+
/** Lets a part inside a section add an error to the section's indicator. */
|
|
2
|
+
export interface SectionErrorReporter {
|
|
3
|
+
/** Adds the error `getError` returns to the section's errors. Returns a function that removes it. */
|
|
4
|
+
report: (getError: () => Error | null) => () => void;
|
|
5
|
+
}
|
|
6
|
+
export declare const provideSectionErrorReporter: (getReporter: () => SectionErrorReporter | undefined) => void;
|
|
7
|
+
/** The enclosing section's reporter, or undefined outside a section that shows errors. */
|
|
8
|
+
export declare const useSectionErrorReporter: () => (() => SectionErrorReporter | undefined) | undefined;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { getContext, setContext } from 'svelte';
|
|
2
|
+
const SECTION_ERROR_REPORTER_KEY = Symbol('section-error-reporter');
|
|
3
|
+
export const provideSectionErrorReporter = (getReporter) => {
|
|
4
|
+
setContext(SECTION_ERROR_REPORTER_KEY, getReporter);
|
|
5
|
+
};
|
|
6
|
+
/** The enclosing section's reporter, or undefined outside a section that shows errors. */
|
|
7
|
+
export const useSectionErrorReporter = () => getContext(SECTION_ERROR_REPORTER_KEY);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ClassValue } from 'svelte/elements'
|
|
3
|
+
|
|
4
|
+
import { untrack } from 'svelte'
|
|
5
|
+
|
|
6
|
+
import ErrorDisplay from '../error.svelte'
|
|
7
|
+
import { useSectionErrorReporter } from './section-error-reporter'
|
|
8
|
+
|
|
9
|
+
interface Props {
|
|
10
|
+
error: Error | null | undefined
|
|
11
|
+
/** Classes for the inline line rendered outside a section. */
|
|
12
|
+
class?: ClassValue
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const { error, class: className }: Props = $props()
|
|
16
|
+
|
|
17
|
+
const getReporter = useSectionErrorReporter()
|
|
18
|
+
const reporter = $derived(getReporter?.())
|
|
19
|
+
|
|
20
|
+
$effect(() => {
|
|
21
|
+
const current = reporter
|
|
22
|
+
// Registering writes the section's error set, so it must not subscribe this effect to it.
|
|
23
|
+
return untrack(() => current?.report(() => error ?? null))
|
|
24
|
+
})
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<!--
|
|
28
|
+
Adds `error` to the enclosing section's indicator. Outside a section that shows errors, such as
|
|
29
|
+
a form rendered on its own, it falls back to an inline error line.
|
|
30
|
+
-->
|
|
31
|
+
{#if !reporter}
|
|
32
|
+
<ErrorDisplay
|
|
33
|
+
lastError={error}
|
|
34
|
+
class={className}
|
|
35
|
+
/>
|
|
36
|
+
{/if}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ClassValue } from 'svelte/elements';
|
|
2
|
+
interface Props {
|
|
3
|
+
error: Error | null | undefined;
|
|
4
|
+
/** Classes for the inline line rendered outside a section. */
|
|
5
|
+
class?: ClassValue;
|
|
6
|
+
}
|
|
7
|
+
declare const SectionError: import("svelte").Component<Props, {}, "">;
|
|
8
|
+
type SectionError = ReturnType<typeof SectionError>;
|
|
9
|
+
export default SectionError;
|