@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.
Files changed (200) hide show
  1. package/README.md +15 -1
  2. package/dist/api-docs-href.d.ts +2 -2
  3. package/dist/api-docs-href.js +0 -1
  4. package/dist/components/api-section.svelte +58 -49
  5. package/dist/components/api-section.svelte.d.ts +24 -10
  6. package/dist/components/boundary.svelte +51 -0
  7. package/dist/components/boundary.svelte.d.ts +5 -0
  8. package/dist/components/connection-status.svelte +57 -61
  9. package/dist/components/connection-status.svelte.d.ts +5 -5
  10. package/dist/components/content-rect.svelte +10 -5
  11. package/dist/components/content-rect.svelte.d.ts +3 -1
  12. package/dist/components/error.svelte +15 -5
  13. package/dist/components/error.svelte.d.ts +8 -1
  14. package/dist/components/index.d.ts +4 -3
  15. package/dist/components/index.js +4 -3
  16. package/dist/components/is-moving.svelte +29 -35
  17. package/dist/components/is-moving.svelte.d.ts +6 -6
  18. package/dist/components/maplibre/index.svelte +5 -6
  19. package/dist/components/maplibre/index.svelte.d.ts +3 -1
  20. package/dist/components/pose-editor.svelte +83 -15
  21. package/dist/components/pose-editor.svelte.d.ts +11 -4
  22. package/dist/components/progress.svelte +1 -0
  23. package/dist/components/queries.svelte +14 -4
  24. package/dist/components/queries.svelte.d.ts +6 -1
  25. package/dist/components/query.svelte +11 -3
  26. package/dist/components/query.svelte.d.ts +6 -1
  27. package/dist/components/section/error-key.d.ts +2 -0
  28. package/dist/components/section/error-key.js +2 -0
  29. package/dist/components/section/index.d.ts +21 -0
  30. package/dist/components/section/index.js +21 -0
  31. package/dist/components/section/section-body.svelte +36 -0
  32. package/dist/components/section/section-body.svelte.d.ts +13 -0
  33. package/dist/components/section/section-error-reporter.d.ts +8 -0
  34. package/dist/components/section/section-error-reporter.js +7 -0
  35. package/dist/components/section/section-error.svelte +36 -0
  36. package/dist/components/section/section-error.svelte.d.ts +9 -0
  37. package/dist/components/section/section-errors.svelte +145 -0
  38. package/dist/components/section/section-errors.svelte.d.ts +6 -0
  39. package/dist/components/section/section-heading.svelte +21 -0
  40. package/dist/components/section/section-heading.svelte.d.ts +9 -0
  41. package/dist/components/section/section-loading.d.ts +4 -0
  42. package/dist/components/section/section-loading.js +10 -0
  43. package/dist/components/section/section-method.svelte +29 -0
  44. package/dist/components/section/section-method.svelte.d.ts +9 -0
  45. package/dist/components/section/section-placeholder.svelte +29 -0
  46. package/dist/components/section/section-placeholder.svelte.d.ts +7 -0
  47. package/dist/components/section/section-text.svelte +17 -0
  48. package/dist/components/section/section-text.svelte.d.ts +8 -0
  49. package/dist/components/section/section-tooltip.svelte +25 -0
  50. package/dist/components/section/section-tooltip.svelte.d.ts +7 -0
  51. package/dist/components/section/section.svelte +23 -0
  52. package/dist/components/section/section.svelte.d.ts +11 -0
  53. package/dist/components/section/use-section-errors.svelte.d.ts +19 -0
  54. package/dist/components/section/use-section-errors.svelte.js +49 -0
  55. package/dist/components/stop-button.svelte +1 -5
  56. package/dist/components/stop-button.svelte.d.ts +0 -1
  57. package/dist/components/stop.svelte +31 -14
  58. package/dist/components/stop.svelte.d.ts +6 -1
  59. package/dist/components/widgets/arm/arm.svelte +43 -40
  60. package/dist/components/widgets/arm/get-joint-positions-widget.svelte +10 -9
  61. package/dist/components/widgets/arm/joint-position-editor.svelte +105 -27
  62. package/dist/components/widgets/arm/joint-position-editor.svelte.d.ts +4 -3
  63. package/dist/components/widgets/arm/joint-position-slider.svelte +6 -2
  64. package/dist/components/widgets/arm/joint-position-slider.svelte.d.ts +2 -1
  65. package/dist/components/widgets/arm/manual-mode-widget.svelte +16 -6
  66. package/dist/components/widgets/arm/manual-mode.svelte +1 -5
  67. package/dist/components/widgets/arm/manual-mode.svelte.d.ts +0 -1
  68. package/dist/components/widgets/arm/move-to-joint-positions-widget.svelte +22 -8
  69. package/dist/components/widgets/arm/move-to-joint-positions.svelte +15 -17
  70. package/dist/components/widgets/arm/move-to-joint-positions.svelte.d.ts +0 -1
  71. package/dist/components/widgets/arm/move-to-position-control.svelte +45 -33
  72. package/dist/components/widgets/arm/move-to-position.svelte +97 -34
  73. package/dist/components/widgets/arm/move-to-position.svelte.d.ts +3 -2
  74. package/dist/components/widgets/arm/quick-move-widget.svelte +10 -4
  75. package/dist/components/widgets/arm/quick-move.svelte +1 -4
  76. package/dist/components/widgets/arm/quick-move.svelte.d.ts +0 -1
  77. package/dist/components/widgets/arm/use-arm-motion-tracking.svelte.d.ts +16 -0
  78. package/dist/components/widgets/arm/use-arm-motion-tracking.svelte.js +37 -0
  79. package/dist/components/widgets/arm/use-edited-targets.svelte.d.ts +9 -0
  80. package/dist/components/widgets/arm/use-edited-targets.svelte.js +24 -0
  81. package/dist/components/widgets/audio-input/audio-input.svelte +80 -77
  82. package/dist/components/widgets/audio-input/get-properties-widget.svelte +16 -16
  83. package/dist/components/widgets/audio-output/audio-output.svelte +87 -84
  84. package/dist/components/widgets/audio-output/get-properties-widget.svelte +16 -16
  85. package/dist/components/widgets/base/base.svelte +78 -43
  86. package/dist/components/widgets/base/move-straight-widget.svelte +16 -4
  87. package/dist/components/widgets/base/quick-move-widget.svelte +25 -9
  88. package/dist/components/widgets/base/quick-move.svelte +5 -6
  89. package/dist/components/widgets/base/set-power-widget.svelte +20 -8
  90. package/dist/components/widgets/base/set-power.svelte +6 -4
  91. package/dist/components/widgets/base/set-velocity-widget.svelte +20 -8
  92. package/dist/components/widgets/base/set-velocity.svelte +6 -4
  93. package/dist/components/widgets/base/spin-widget.svelte +20 -8
  94. package/dist/components/widgets/base/vec3-builder.svelte +3 -2
  95. package/dist/components/widgets/base/vec3-builder.svelte.d.ts +2 -1
  96. package/dist/components/widgets/board/analog-read.svelte +2 -4
  97. package/dist/components/widgets/board/analog-write.svelte +2 -4
  98. package/dist/components/widgets/board/gpio-read.svelte +2 -1
  99. package/dist/components/widgets/board/gpio-write.svelte +2 -1
  100. package/dist/components/widgets/board/pin-section.svelte +5 -6
  101. package/dist/components/widgets/board/pin-section.svelte.d.ts +3 -2
  102. package/dist/components/widgets/board/read-write-pins.svelte +2 -2
  103. package/dist/components/widgets/button/push.svelte +2 -2
  104. package/dist/components/widgets/camera/camera.svelte +17 -24
  105. package/dist/components/widgets/camera/live-or-polling-video.svelte +33 -30
  106. package/dist/components/widgets/custom-control/__tests__/__fixtures__/with-sibling.svelte +10 -0
  107. package/dist/components/widgets/custom-control/control-frame.svelte +60 -0
  108. package/dist/components/widgets/custom-control/control-frame.svelte.d.ts +10 -0
  109. package/dist/components/widgets/custom-control/create-control-host.svelte.d.ts +19 -0
  110. package/dist/components/widgets/custom-control/create-control-host.svelte.js +26 -0
  111. package/dist/components/widgets/custom-control/custom-control.d.ts +35 -0
  112. package/dist/components/widgets/custom-control/custom-control.js +85 -0
  113. package/dist/components/widgets/custom-control/custom-control.svelte +45 -0
  114. package/dist/components/widgets/custom-control/custom-control.svelte.d.ts +14 -0
  115. package/dist/components/widgets/discovery/discovery.svelte +13 -17
  116. package/dist/components/widgets/encoder/encoder.svelte +25 -21
  117. package/dist/components/widgets/encoder/get-position-widget.svelte +19 -16
  118. package/dist/components/widgets/gantry/gantry.svelte +58 -76
  119. package/dist/components/widgets/gantry/get-position-widget.svelte +15 -14
  120. package/dist/components/widgets/gantry/home.svelte +21 -10
  121. package/dist/components/widgets/gantry/move-to-position-widget.svelte +2 -1
  122. package/dist/components/widgets/gantry/move-to-position.svelte +1 -4
  123. package/dist/components/widgets/gantry/move-to-position.svelte.d.ts +0 -1
  124. package/dist/components/widgets/gantry/quick-move-widget.svelte +3 -2
  125. package/dist/components/widgets/gantry/quick-move.svelte +1 -5
  126. package/dist/components/widgets/gantry/quick-move.svelte.d.ts +0 -1
  127. package/dist/components/widgets/generic/generic.svelte +11 -6
  128. package/dist/components/widgets/gripper/grab-widget.svelte +26 -0
  129. package/dist/components/widgets/gripper/grab-widget.svelte.d.ts +7 -0
  130. package/dist/components/widgets/gripper/grab.svelte +3 -19
  131. package/dist/components/widgets/gripper/grab.svelte.d.ts +1 -2
  132. package/dist/components/widgets/gripper/gripper.svelte +18 -18
  133. package/dist/components/widgets/gripper/is-holding-something.svelte +21 -21
  134. package/dist/components/widgets/gripper/open-widget.svelte +26 -0
  135. package/dist/components/widgets/gripper/open-widget.svelte.d.ts +7 -0
  136. package/dist/components/widgets/gripper/open.svelte +3 -19
  137. package/dist/components/widgets/gripper/open.svelte.d.ts +1 -2
  138. package/dist/components/widgets/input-controller/input-controller.svelte +10 -16
  139. package/dist/components/widgets/input-controller/webgamepad.svelte +2 -2
  140. package/dist/components/widgets/ml-model-service/ml-model-service.svelte +1 -1
  141. package/dist/components/widgets/motion/frame-select.svelte +4 -2
  142. package/dist/components/widgets/motion/frame-select.svelte.d.ts +2 -1
  143. package/dist/components/widgets/motion/motion.svelte +27 -31
  144. package/dist/components/widgets/motion/move-widget.svelte +32 -12
  145. package/dist/components/widgets/motion/move-widget.svelte.d.ts +6 -0
  146. package/dist/components/widgets/motion/move.svelte +6 -16
  147. package/dist/components/widgets/motion/move.svelte.d.ts +0 -1
  148. package/dist/components/widgets/motor/go-for-view.svelte +16 -8
  149. package/dist/components/widgets/motor/go-to-view.svelte +12 -4
  150. package/dist/components/widgets/motor/motor.svelte +100 -64
  151. package/dist/components/widgets/motor/quick-move-widget.svelte +16 -8
  152. package/dist/components/widgets/motor/set-power-widget.svelte +12 -4
  153. package/dist/components/widgets/motor/set-rpm-widget.svelte +12 -4
  154. package/dist/components/widgets/movement-sensor/get-accuracy-widget.svelte +8 -11
  155. package/dist/components/widgets/movement-sensor/get-compass-heading-widget.svelte +8 -11
  156. package/dist/components/widgets/movement-sensor/get-orientation-widget.svelte +8 -11
  157. package/dist/components/widgets/movement-sensor/get-position-widget.svelte +8 -11
  158. package/dist/components/widgets/movement-sensor/movement-sensor.svelte +64 -66
  159. package/dist/components/widgets/operations-and-sessions/operations-and-sessions.svelte +2 -1
  160. package/dist/components/widgets/power-sensor/get-current-widget.svelte +8 -11
  161. package/dist/components/widgets/power-sensor/get-power-widget.svelte +8 -11
  162. package/dist/components/widgets/power-sensor/get-voltage-widget.svelte +8 -11
  163. package/dist/components/widgets/power-sensor/power-sensor.svelte +35 -45
  164. package/dist/components/widgets/sensor/sensor.svelte +8 -12
  165. package/dist/components/widgets/servo/move-widget.svelte +2 -1
  166. package/dist/components/widgets/servo/move.svelte +1 -4
  167. package/dist/components/widgets/servo/move.svelte.d.ts +0 -1
  168. package/dist/components/widgets/servo/quick-move-widget.svelte +2 -1
  169. package/dist/components/widgets/servo/quick-move.svelte +1 -5
  170. package/dist/components/widgets/servo/quick-move.svelte.d.ts +0 -1
  171. package/dist/components/widgets/servo/servo.svelte +53 -37
  172. package/dist/components/widgets/slam/get-position-widget.svelte +8 -11
  173. package/dist/components/widgets/slam/move-on-map.svelte +9 -6
  174. package/dist/components/widgets/slam/move-on-map.svelte.d.ts +2 -1
  175. package/dist/components/widgets/slam/slam.svelte +65 -75
  176. package/dist/components/widgets/switch/position-view.svelte +1 -1
  177. package/dist/components/widgets/switch/position.svelte +2 -2
  178. package/dist/components/widgets/switch/switch.svelte +1 -1
  179. package/dist/components/widgets/vision-service/detection-row.svelte +4 -2
  180. package/dist/components/widgets/vision-service/detection-row.svelte.d.ts +2 -1
  181. package/dist/components/widgets/vision-service/fonts/public-sans.json +1 -0
  182. package/dist/components/widgets/vision-service/fonts/public-sans.png +0 -0
  183. package/dist/components/widgets/vision-service/image.svelte +4 -4
  184. package/dist/components/widgets/vision-service/legend.svelte +4 -4
  185. package/dist/components/widgets/vision-service/public-sans-font.d.ts +5 -0
  186. package/dist/components/widgets/vision-service/public-sans-font.js +14 -0
  187. package/dist/components/widgets/vision-service/vision-service.svelte +2 -2
  188. package/dist/index.d.ts +1 -1
  189. package/dist/index.js +0 -1
  190. package/package.json +19 -5
  191. package/dist/components/board/pin-section.svelte +0 -28
  192. package/dist/components/board/pin-section.svelte.d.ts +0 -9
  193. package/dist/components/mutation-section.svelte +0 -73
  194. package/dist/components/mutation-section.svelte.d.ts +0 -16
  195. package/dist/components/mutation-view.svelte +0 -29
  196. package/dist/components/mutation-view.svelte.d.ts +0 -10
  197. package/dist/components/section-group.svelte +0 -64
  198. package/dist/components/section-group.svelte.d.ts +0 -14
  199. package/dist/components/section-title.svelte +0 -63
  200. package/dist/components/section-title.svelte.d.ts +0 -14
@@ -1,46 +1,43 @@
1
1
  <script lang="ts">
2
- import type {
3
- Arm,
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 Query from './query.svelte'
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: string
37
- children?: Snippet
27
+ api: ResourceTriplet
38
28
  }
39
29
 
40
- const { client: clientClass, partID, resourceName, api, children }: Props = $props()
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<Arm | Base | Gantry | Gripper | Motor | Servo>(
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
- title="IsMoving"
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
- <Query {query}>
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 { ArmClient, BaseClient, GantryClient, GripperClient, MotorClient, ServoClient } from '@viamrobotics/sdk';
2
- import type { Snippet } from 'svelte';
3
- type Client = typeof ArmClient | typeof BaseClient | typeof GantryClient | typeof GripperClient | typeof MotorClient | typeof ServoClient;
4
- interface Props {
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: string;
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 { Icon, NumericInput, Tooltip } from '@viamrobotics/prime-core'
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
- /** Heading shown above the input table. */
33
- title: string
34
- /** Optional info-tooltip text shown next to the title. */
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, onPoseChange, title, description }: Props = $props()
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
- {title}
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
- <NumericInput
123
- cx="max-w-[76px]"
124
- {value}
125
- on:change={(event) => {
126
- handleValueChange(key, numberValueFromEvent(event) ?? 0)
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
- /** Heading shown above the input table. */
6
- title: string;
7
- /** Optional info-tooltip text shown next to the title. */
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,4 +1,5 @@
1
1
  <div
2
2
  role="progressbar"
3
+ aria-label="Loading"
3
4
  class="bg-medium h-full w-full animate-pulse"
4
5
  ></div>
@@ -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
- contentCx?: string
21
+ class?: ClassValue
14
22
  children?: Snippet<[{ data: unknown[] }]>
15
23
  }
16
24
 
17
- const { queries, contentCx = '', children }: Props = $props()
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
- cx={contentCx}
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
- cx={contentCx}
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
- contentCx?: string;
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
- contentCx?: string
17
+ class?: ClassValue
10
18
  children?: Snippet
11
19
  }
12
20
 
13
- const { query, contentCx = '', children }: Props = $props()
21
+ const { query, class: classNames, children }: Props = $props()
14
22
  </script>
15
23
 
16
24
  <Queries
17
25
  queries={[query]}
18
- {contentCx}
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
- contentCx?: string;
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,2 @@
1
+ /** Two errors with the same name and message read as one error. */
2
+ export declare const errorKey: (error: Error) => string;
@@ -0,0 +1,2 @@
1
+ /** Two errors with the same name and message read as one error. */
2
+ export const errorKey = (error) => `${error.name}\0${error.message}`;
@@ -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;