@arkitektio/bsx 1.0.1 → 2.0.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 +51 -16
- package/dist/catalogs/html.d.ts +117 -0
- package/dist/catalogs/html.d.ts.map +1 -0
- package/dist/catalogs/html.js +14 -0
- package/dist/catalogs/html.js.map +1 -0
- package/dist/catalogs/index.d.ts +6059 -0
- package/dist/catalogs/index.d.ts.map +1 -0
- package/dist/catalogs/index.js +11 -0
- package/dist/catalogs/index.js.map +1 -0
- package/dist/catalogs/logo.d.ts +214 -0
- package/dist/catalogs/logo.d.ts.map +1 -0
- package/dist/catalogs/logo.js +27 -0
- package/dist/catalogs/logo.js.map +1 -0
- package/dist/catalogs/parts/data.d.ts +408 -0
- package/dist/catalogs/parts/data.d.ts.map +1 -0
- package/dist/catalogs/parts/data.js +206 -0
- package/dist/catalogs/parts/data.js.map +1 -0
- package/dist/catalogs/parts/feedback.d.ts +440 -0
- package/dist/catalogs/parts/feedback.d.ts.map +1 -0
- package/dist/catalogs/parts/feedback.js +70 -0
- package/dist/catalogs/parts/feedback.js.map +1 -0
- package/dist/catalogs/parts/forms.d.ts +874 -0
- package/dist/catalogs/parts/forms.d.ts.map +1 -0
- package/dist/catalogs/parts/forms.js +302 -0
- package/dist/catalogs/parts/forms.js.map +1 -0
- package/dist/catalogs/parts/html.d.ts +93 -0
- package/dist/catalogs/parts/html.d.ts.map +1 -0
- package/dist/catalogs/parts/html.js +45 -0
- package/dist/catalogs/parts/html.js.map +1 -0
- package/dist/catalogs/parts/icons.d.ts +266 -0
- package/dist/catalogs/parts/icons.d.ts.map +1 -0
- package/dist/catalogs/parts/icons.js +149 -0
- package/dist/catalogs/parts/icons.js.map +1 -0
- package/dist/catalogs/parts/index.d.ts +5765 -0
- package/dist/catalogs/parts/index.d.ts.map +1 -0
- package/dist/catalogs/parts/index.js +38 -0
- package/dist/catalogs/parts/index.js.map +1 -0
- package/dist/catalogs/parts/inspector.d.ts +10 -0
- package/dist/catalogs/parts/inspector.d.ts.map +1 -0
- package/dist/catalogs/parts/inspector.js +12 -0
- package/dist/catalogs/parts/inspector.js.map +1 -0
- package/dist/catalogs/parts/layout.d.ts +647 -0
- package/dist/catalogs/parts/layout.d.ts.map +1 -0
- package/dist/catalogs/parts/layout.js +188 -0
- package/dist/catalogs/parts/layout.js.map +1 -0
- package/dist/catalogs/parts/logo.d.ts +321 -0
- package/dist/catalogs/parts/logo.d.ts.map +1 -0
- package/dist/catalogs/parts/logo.js +227 -0
- package/dist/catalogs/parts/logo.js.map +1 -0
- package/dist/catalogs/parts/navigation.d.ts +697 -0
- package/dist/catalogs/parts/navigation.d.ts.map +1 -0
- package/dist/catalogs/parts/navigation.js +194 -0
- package/dist/catalogs/parts/navigation.js.map +1 -0
- package/dist/catalogs/parts/overlays.d.ts +2012 -0
- package/dist/catalogs/parts/overlays.d.ts.map +1 -0
- package/dist/catalogs/parts/overlays.js +191 -0
- package/dist/catalogs/parts/overlays.js.map +1 -0
- package/dist/catalogs/parts/run.d.ts +41 -0
- package/dist/catalogs/parts/run.d.ts.map +1 -0
- package/dist/catalogs/parts/run.js +46 -0
- package/dist/catalogs/parts/run.js.map +1 -0
- package/dist/catalogs/parts/scene.d.ts +326 -0
- package/dist/catalogs/parts/scene.d.ts.map +1 -0
- package/dist/catalogs/parts/scene.js +237 -0
- package/dist/catalogs/parts/scene.js.map +1 -0
- package/dist/catalogs/parts/structure.d.ts +51 -0
- package/dist/catalogs/parts/structure.d.ts.map +1 -0
- package/dist/catalogs/parts/structure.js +66 -0
- package/dist/catalogs/parts/structure.js.map +1 -0
- package/dist/catalogs/parts/toast.d.ts +37 -0
- package/dist/catalogs/parts/toast.d.ts.map +1 -0
- package/dist/catalogs/parts/toast.js +23 -0
- package/dist/catalogs/parts/toast.js.map +1 -0
- package/dist/catalogs/parts/typography.d.ts +174 -0
- package/dist/catalogs/parts/typography.d.ts.map +1 -0
- package/dist/catalogs/parts/typography.js +56 -0
- package/dist/catalogs/parts/typography.js.map +1 -0
- package/dist/{renderer/bloks/shared/schemas.d.ts → catalogs/props.d.ts} +3 -3
- package/dist/catalogs/props.d.ts.map +1 -0
- package/dist/{renderer/bloks/shared/schemas.js → catalogs/props.js} +3 -4
- package/dist/catalogs/props.js.map +1 -0
- package/dist/catalogs/scene.d.ts +250 -0
- package/dist/catalogs/scene.d.ts.map +1 -0
- package/dist/catalogs/scene.js +28 -0
- package/dist/catalogs/scene.js.map +1 -0
- package/dist/catalogs/shadcn.d.ts +2397 -0
- package/dist/catalogs/shadcn.d.ts.map +1 -0
- package/dist/catalogs/shadcn.js +82 -0
- package/dist/catalogs/shadcn.js.map +1 -0
- package/dist/catalogs/structure.d.ts +61 -0
- package/dist/catalogs/structure.d.ts.map +1 -0
- package/dist/catalogs/structure.js +14 -0
- package/dist/catalogs/structure.js.map +1 -0
- package/dist/catalogs/ui.d.ts +3027 -0
- package/dist/catalogs/ui.d.ts.map +1 -0
- package/dist/catalogs/ui.js +91 -0
- package/dist/catalogs/ui.js.map +1 -0
- package/dist/catalogs.d.ts +5 -0
- package/dist/catalogs.d.ts.map +1 -0
- package/dist/catalogs.js +6 -0
- package/dist/catalogs.js.map +1 -0
- package/dist/platform.d.ts +11 -2
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js.map +1 -1
- package/dist/renderer/bloks/control.d.ts.map +1 -1
- package/dist/renderer/bloks/control.js +5 -1
- package/dist/renderer/bloks/control.js.map +1 -1
- package/dist/renderer/bloks/data.d.ts +378 -27
- package/dist/renderer/bloks/data.d.ts.map +1 -1
- package/dist/renderer/bloks/data.js +55 -251
- package/dist/renderer/bloks/data.js.map +1 -1
- package/dist/renderer/bloks/feedback.d.ts +425 -8
- package/dist/renderer/bloks/feedback.d.ts.map +1 -1
- package/dist/renderer/bloks/feedback.js +23 -79
- package/dist/renderer/bloks/feedback.js.map +1 -1
- package/dist/renderer/bloks/forms.d.ts +828 -42
- package/dist/renderer/bloks/forms.d.ts.map +1 -1
- package/dist/renderer/bloks/forms.js +78 -368
- package/dist/renderer/bloks/forms.js.map +1 -1
- package/dist/renderer/bloks/html.d.ts +84 -9
- package/dist/renderer/bloks/html.d.ts.map +1 -1
- package/dist/renderer/bloks/html.js +13 -48
- package/dist/renderer/bloks/html.js.map +1 -1
- package/dist/renderer/bloks/icons.d.ts +133 -130
- package/dist/renderer/bloks/icons.d.ts.map +1 -1
- package/dist/renderer/bloks/icons.js +10 -23
- package/dist/renderer/bloks/icons.js.map +1 -1
- package/dist/renderer/bloks/index.d.ts +5251 -16
- package/dist/renderer/bloks/index.d.ts.map +1 -1
- package/dist/renderer/bloks/index.js +29 -27
- package/dist/renderer/bloks/index.js.map +1 -1
- package/dist/renderer/bloks/inspector/Inspector.d.ts +5 -1
- package/dist/renderer/bloks/inspector/Inspector.d.ts.map +1 -1
- package/dist/renderer/bloks/inspector/Inspector.js +5 -11
- package/dist/renderer/bloks/inspector/Inspector.js.map +1 -1
- package/dist/renderer/bloks/layout.d.ts +432 -15
- package/dist/renderer/bloks/layout.d.ts.map +1 -1
- package/dist/renderer/bloks/layout.js +43 -224
- package/dist/renderer/bloks/layout.js.map +1 -1
- package/dist/renderer/bloks/logo/index.d.ts +172 -24
- package/dist/renderer/bloks/logo/index.d.ts.map +1 -1
- package/dist/renderer/bloks/logo/index.js +42 -236
- package/dist/renderer/bloks/logo/index.js.map +1 -1
- package/dist/renderer/bloks/navigation.d.ts +651 -28
- package/dist/renderer/bloks/navigation.d.ts.map +1 -1
- package/dist/renderer/bloks/navigation.js +65 -249
- package/dist/renderer/bloks/navigation.js.map +1 -1
- package/dist/renderer/bloks/overlays.d.ts +1998 -55
- package/dist/renderer/bloks/overlays.d.ts.map +1 -1
- package/dist/renderer/bloks/overlays.js +87 -265
- package/dist/renderer/bloks/overlays.js.map +1 -1
- package/dist/renderer/bloks/run/components.d.ts +13 -4
- package/dist/renderer/bloks/run/components.d.ts.map +1 -1
- package/dist/renderer/bloks/run/components.js +12 -34
- package/dist/renderer/bloks/run/components.js.map +1 -1
- package/dist/renderer/bloks/run/index.d.ts +1 -1
- package/dist/renderer/bloks/run/index.d.ts.map +1 -1
- package/dist/renderer/bloks/run/index.js +1 -1
- package/dist/renderer/bloks/run/index.js.map +1 -1
- package/dist/renderer/bloks/scene/Model.d.ts +6 -2
- package/dist/renderer/bloks/scene/Model.d.ts.map +1 -1
- package/dist/renderer/bloks/scene/Model.js +4 -48
- package/dist/renderer/bloks/scene/Model.js.map +1 -1
- package/dist/renderer/bloks/scene/Scene.d.ts +4 -1
- package/dist/renderer/bloks/scene/Scene.d.ts.map +1 -1
- package/dist/renderer/bloks/scene/Scene.js +3 -24
- package/dist/renderer/bloks/scene/Scene.js.map +1 -1
- package/dist/renderer/bloks/scene/Transform.d.ts +5 -1
- package/dist/renderer/bloks/scene/Transform.d.ts.map +1 -1
- package/dist/renderer/bloks/scene/Transform.js +3 -25
- package/dist/renderer/bloks/scene/Transform.js.map +1 -1
- package/dist/renderer/bloks/scene/bindings.d.ts +40 -8
- package/dist/renderer/bloks/scene/bindings.d.ts.map +1 -1
- package/dist/renderer/bloks/scene/bindings.js +18 -102
- package/dist/renderer/bloks/scene/bindings.js.map +1 -1
- package/dist/renderer/bloks/scene/index.d.ts +194 -1
- package/dist/renderer/bloks/scene/index.d.ts.map +1 -1
- package/dist/renderer/bloks/scene/index.js +21 -21
- package/dist/renderer/bloks/scene/index.js.map +1 -1
- package/dist/renderer/bloks/scene/interaction.d.ts +6 -2
- package/dist/renderer/bloks/scene/interaction.d.ts.map +1 -1
- package/dist/renderer/bloks/scene/interaction.js +6 -42
- package/dist/renderer/bloks/scene/interaction.js.map +1 -1
- package/dist/renderer/bloks/shared/index.d.ts +0 -1
- package/dist/renderer/bloks/shared/index.d.ts.map +1 -1
- package/dist/renderer/bloks/shared/index.js +0 -1
- package/dist/renderer/bloks/shared/index.js.map +1 -1
- package/dist/renderer/bloks/shared/props.d.ts +1 -1
- package/dist/renderer/bloks/shared/props.d.ts.map +1 -1
- package/dist/renderer/bloks/shared/props.js +1 -1
- package/dist/renderer/bloks/shared/props.js.map +1 -1
- package/dist/renderer/bloks/testing.d.ts +1 -1
- package/dist/renderer/bloks/testing.d.ts.map +1 -1
- package/dist/renderer/bloks/testing.js +5 -5
- package/dist/renderer/bloks/testing.js.map +1 -1
- package/dist/renderer/bloks/toast.d.ts +15 -5
- package/dist/renderer/bloks/toast.d.ts.map +1 -1
- package/dist/renderer/bloks/toast.js +11 -19
- package/dist/renderer/bloks/toast.js.map +1 -1
- package/dist/renderer/bloks/typography.d.ts +166 -24
- package/dist/renderer/bloks/typography.d.ts.map +1 -1
- package/dist/renderer/bloks/typography.js +22 -98
- package/dist/renderer/bloks/typography.js.map +1 -1
- package/dist/renderer/catalog.d.ts +3 -19
- package/dist/renderer/catalog.d.ts.map +1 -1
- package/dist/renderer/catalog.js +12 -29
- package/dist/renderer/catalog.js.map +1 -1
- package/dist/renderer/declare.d.ts +40 -0
- package/dist/renderer/declare.d.ts.map +1 -0
- package/dist/renderer/declare.js +40 -0
- package/dist/renderer/declare.js.map +1 -0
- package/dist/renderer/modules.d.ts +1 -18
- package/dist/renderer/modules.d.ts.map +1 -1
- package/dist/renderer/modules.js +1 -31
- package/dist/renderer/modules.js.map +1 -1
- package/dist/renderer/runtime/catalog.d.ts +63 -0
- package/dist/renderer/runtime/catalog.d.ts.map +1 -0
- package/dist/renderer/runtime/catalog.js +33 -0
- package/dist/renderer/runtime/catalog.js.map +1 -0
- package/dist/renderer/runtime/components.d.ts +27 -1
- package/dist/renderer/runtime/components.d.ts.map +1 -1
- package/dist/renderer/runtime/components.js +3 -0
- package/dist/renderer/runtime/components.js.map +1 -1
- package/dist/renderer/runtime/describe.d.ts +49 -0
- package/dist/renderer/runtime/describe.d.ts.map +1 -0
- package/dist/renderer/runtime/describe.js +127 -0
- package/dist/renderer/runtime/describe.js.map +1 -0
- package/dist/renderer/runtime/functions.d.ts +0 -13
- package/dist/renderer/runtime/functions.d.ts.map +1 -1
- package/dist/renderer/runtime/functions.js +0 -14
- package/dist/renderer/runtime/functions.js.map +1 -1
- package/dist/renderer/runtime/index.d.ts +2 -0
- package/dist/renderer/runtime/index.d.ts.map +1 -1
- package/dist/renderer/runtime/index.js +2 -0
- package/dist/renderer/runtime/index.js.map +1 -1
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +1 -0
- package/dist/runtime.js.map +1 -1
- package/dist/scene.d.ts +2 -0
- package/dist/scene.d.ts.map +1 -1
- package/dist/scene.js +27 -1
- package/dist/scene.js.map +1 -1
- package/dist/shadcn.d.ts +5265 -0
- package/dist/shadcn.d.ts.map +1 -0
- package/dist/shadcn.js +194 -0
- package/dist/shadcn.js.map +1 -0
- package/dist/spec/bsx_v2.json +74 -113
- package/dist/spec/catalogs/logo@1.json +39 -25
- package/dist/spec/catalogs/logo@1.json.js +39 -25
- package/dist/spec/catalogs/scene@1.json +23 -23
- package/dist/spec/catalogs/scene@1.json.js +23 -23
- package/dist/spec/{modules/orkestrator.json → catalogs/shadcn@1.json} +1391 -286
- package/dist/spec/{modules/orkestrator.json.js → catalogs/shadcn@1.json.js} +1391 -286
- package/dist/spec/catalogs/structure@1.json +1 -1
- package/dist/spec/catalogs/structure@1.json.js +1 -1
- package/dist/spec/catalogs/ui@1.json +1690 -37
- package/dist/spec/catalogs/ui@1.json.js +1690 -37
- package/dist/spec/catalogs.d.ts +16 -12
- package/dist/spec/catalogs.d.ts.map +1 -1
- package/dist/spec/catalogs.js +23 -15
- package/dist/spec/catalogs.js.map +1 -1
- package/dist/spec/vocabulary.json +1 -1
- package/dist/spec/vocabulary.json.js +1 -1
- package/dist/vendor/core/ui/button-group.d.ts +1 -1
- package/dist/vendor/core/ui/field.d.ts +1 -1
- package/dist/web.d.ts +0 -3
- package/dist/web.d.ts.map +1 -1
- package/dist/web.js +2 -4
- package/dist/web.js.map +1 -1
- package/package.json +11 -2
- package/src/bsx/infer.test.ts +2 -2
- package/src/bsx/references.test.ts +2 -2
- package/src/catalogs/catalogs.test.ts +28 -0
- package/src/catalogs/html.ts +14 -0
- package/src/catalogs/index.ts +12 -0
- package/src/catalogs/logo.ts +27 -0
- package/src/catalogs/parts/data.ts +228 -0
- package/src/catalogs/parts/feedback.ts +79 -0
- package/src/catalogs/parts/forms.ts +335 -0
- package/src/catalogs/parts/html.ts +51 -0
- package/src/catalogs/parts/icons.ts +154 -0
- package/src/catalogs/parts/index.ts +38 -0
- package/src/catalogs/parts/inspector.ts +14 -0
- package/src/catalogs/parts/layout.ts +217 -0
- package/src/catalogs/parts/logo.ts +254 -0
- package/src/catalogs/parts/navigation.ts +198 -0
- package/src/catalogs/parts/overlays.ts +221 -0
- package/src/catalogs/parts/run.ts +57 -0
- package/src/catalogs/parts/scene.ts +292 -0
- package/src/catalogs/parts/structure.ts +83 -0
- package/src/catalogs/parts/toast.ts +27 -0
- package/src/catalogs/parts/typography.ts +63 -0
- package/src/{renderer/bloks/shared/schemas.ts → catalogs/props.ts} +2 -3
- package/src/catalogs/scene.ts +28 -0
- package/src/catalogs/shadcn.ts +82 -0
- package/src/catalogs/structure.ts +14 -0
- package/src/catalogs/ui.ts +91 -0
- package/src/catalogs.ts +6 -0
- package/src/platform.ts +8 -2
- package/src/preview/CachedBlokPreview.test.tsx +6 -1
- package/src/renderer/addBlokComponents.test.tsx +9 -7
- package/src/renderer/bloks/control.tsx +8 -1
- package/src/renderer/bloks/data.tsx +339 -621
- package/src/renderer/bloks/feedback.tsx +32 -112
- package/src/renderer/bloks/forms.tsx +103 -504
- package/src/renderer/bloks/html.tsx +16 -78
- package/src/renderer/bloks/icons.tsx +14 -31
- package/src/renderer/bloks/index.ts +28 -38
- package/src/renderer/bloks/inspector/Inspector.tsx +9 -11
- package/src/renderer/bloks/layout.tsx +216 -453
- package/src/renderer/bloks/logo/index.tsx +144 -387
- package/src/renderer/bloks/navigation.tsx +87 -343
- package/src/renderer/bloks/overlays.tsx +106 -524
- package/src/renderer/bloks/primitives.test.tsx +3 -1
- package/src/renderer/bloks/run/components.tsx +20 -58
- package/src/renderer/bloks/run/index.ts +1 -1
- package/src/renderer/bloks/scene/Model.tsx +7 -64
- package/src/renderer/bloks/scene/Scene.tsx +12 -38
- package/src/renderer/bloks/scene/Transform.tsx +6 -34
- package/src/renderer/bloks/scene/animate.test.tsx +2 -2
- package/src/renderer/bloks/scene/bindings.tsx +31 -113
- package/src/renderer/bloks/scene/index.ts +21 -21
- package/src/renderer/bloks/scene/interaction.tsx +7 -59
- package/src/renderer/bloks/shared/index.ts +0 -1
- package/src/renderer/bloks/shared/props.ts +1 -1
- package/src/renderer/bloks/testing.tsx +5 -5
- package/src/renderer/bloks/toast.tsx +16 -31
- package/src/renderer/bloks/typography.tsx +28 -141
- package/src/renderer/bloks/unavailable.test.tsx +3 -1
- package/src/renderer/catalog.tsx +13 -36
- package/src/renderer/declare.ts +82 -0
- package/src/renderer/modules.ts +1 -43
- package/src/renderer/runtime/catalog.test.ts +102 -0
- package/src/renderer/runtime/catalog.ts +108 -0
- package/src/renderer/runtime/components.tsx +27 -0
- package/src/renderer/runtime/describe.ts +180 -0
- package/src/renderer/runtime/functions.ts +0 -25
- package/src/renderer/runtime/index.ts +2 -0
- package/src/runtime.ts +1 -0
- package/src/scene.ts +30 -1
- package/src/shadcn.ts +202 -0
- package/src/spec/bsx_v2.json +74 -113
- package/src/spec/catalogs/logo@1.json +39 -25
- package/src/spec/catalogs/scene@1.json +23 -23
- package/src/spec/{modules/orkestrator.json → catalogs/shadcn@1.json} +1391 -286
- package/src/spec/catalogs/structure@1.json +1 -1
- package/src/spec/catalogs/ui@1.json +1690 -37
- package/src/spec/catalogs.ts +25 -16
- package/src/spec/spec.test.ts +1 -1
- package/src/spec/vocabulary.json +1 -1
- package/src/web.ts +2 -4
- package/dist/renderer/bloks/shared/schemas.d.ts.map +0 -1
- package/dist/renderer/bloks/shared/schemas.js.map +0 -1
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
import type {BlokComponentContracts} from '../../renderer/runtime/catalog';
|
|
3
|
+
import {BlokPropSchemas} from '../../renderer/runtime/schemas';
|
|
4
|
+
import {
|
|
5
|
+
actionProp,
|
|
6
|
+
alignmentSchema,
|
|
7
|
+
bindSchema,
|
|
8
|
+
boolSchema,
|
|
9
|
+
childListSchema,
|
|
10
|
+
classNameSchema,
|
|
11
|
+
contentSchema,
|
|
12
|
+
disabledSchema,
|
|
13
|
+
sideSchema,
|
|
14
|
+
} from '../props';
|
|
15
|
+
import {iconNameSchema} from './icons';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Overlay surfaces: dialogs, sheets, popovers, tooltips and menus.
|
|
19
|
+
*
|
|
20
|
+
* Each family is a root plus its parts, and most parts share a shape with
|
|
21
|
+
* their counterparts in other families: one schema factory per shape, called
|
|
22
|
+
* once per member with that member's description.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Open/closed state follows the same rules as a form control's value: `open`
|
|
27
|
+
* wins, then a `bind` path, and with neither the surface keeps its own state.
|
|
28
|
+
*/
|
|
29
|
+
const overlayRootSchema = (description: string) =>
|
|
30
|
+
z
|
|
31
|
+
.object({
|
|
32
|
+
children: childListSchema.describe('The trigger and content parts of this overlay.'),
|
|
33
|
+
open: BlokPropSchemas.DynamicBoolean.optional().describe('Controlled open state.'),
|
|
34
|
+
defaultOpen: boolSchema.describe('Open on mount when uncontrolled.'),
|
|
35
|
+
onOpenChange: actionProp('Runs when the surface opens or closes. May read event.value.'),
|
|
36
|
+
})
|
|
37
|
+
.describe(description);
|
|
38
|
+
|
|
39
|
+
const triggerSchema = (description: string) =>
|
|
40
|
+
z
|
|
41
|
+
.object({
|
|
42
|
+
label: BlokPropSchemas.DynamicString.optional().describe('Trigger text.'),
|
|
43
|
+
icon: iconNameSchema.describe('Icon rendered before the label.'),
|
|
44
|
+
children: contentSchema,
|
|
45
|
+
disabled: disabledSchema,
|
|
46
|
+
className: classNameSchema,
|
|
47
|
+
})
|
|
48
|
+
.describe(description);
|
|
49
|
+
|
|
50
|
+
/** A part that is just "a styled box of children" — headers, footers, bodies. */
|
|
51
|
+
const panelSchema = (description: string) =>
|
|
52
|
+
z
|
|
53
|
+
.object({
|
|
54
|
+
children: childListSchema,
|
|
55
|
+
className: classNameSchema,
|
|
56
|
+
})
|
|
57
|
+
.describe(description);
|
|
58
|
+
|
|
59
|
+
/** A part that carries a single line of text — titles and descriptions. */
|
|
60
|
+
const textPartSchema = (description: string) =>
|
|
61
|
+
z
|
|
62
|
+
.object({
|
|
63
|
+
text: BlokPropSchemas.DynamicString.optional().describe('The text to render.'),
|
|
64
|
+
children: contentSchema,
|
|
65
|
+
className: classNameSchema,
|
|
66
|
+
})
|
|
67
|
+
.describe(description);
|
|
68
|
+
|
|
69
|
+
/** The three anchored surfaces share one content shape. */
|
|
70
|
+
const anchoredContentSchema = (description: string) =>
|
|
71
|
+
z
|
|
72
|
+
.object({
|
|
73
|
+
children: contentSchema,
|
|
74
|
+
side: sideSchema,
|
|
75
|
+
align: alignmentSchema,
|
|
76
|
+
sideOffset: z.number().optional().describe('Distance from the trigger, in pixels.'),
|
|
77
|
+
className: classNameSchema,
|
|
78
|
+
})
|
|
79
|
+
.describe(description);
|
|
80
|
+
|
|
81
|
+
const menuItemSchema = (description: string) =>
|
|
82
|
+
z
|
|
83
|
+
.object({
|
|
84
|
+
label: BlokPropSchemas.DynamicString.optional().describe('Item text.'),
|
|
85
|
+
icon: iconNameSchema.describe('Icon rendered before the label.'),
|
|
86
|
+
children: contentSchema,
|
|
87
|
+
onSelect: actionProp('Runs when the item is chosen.'),
|
|
88
|
+
variant: z
|
|
89
|
+
.enum(['default', 'destructive'])
|
|
90
|
+
.optional()
|
|
91
|
+
.describe('Item appearance.'),
|
|
92
|
+
disabled: disabledSchema,
|
|
93
|
+
className: classNameSchema,
|
|
94
|
+
})
|
|
95
|
+
.describe(description);
|
|
96
|
+
|
|
97
|
+
const menuCheckboxItemSchema = (description: string) =>
|
|
98
|
+
z
|
|
99
|
+
.object({
|
|
100
|
+
label: BlokPropSchemas.DynamicString.optional().describe('Item text.'),
|
|
101
|
+
bind: bindSchema,
|
|
102
|
+
checked: BlokPropSchemas.DynamicBoolean.optional().describe('Controlled checked state.'),
|
|
103
|
+
disabled: disabledSchema,
|
|
104
|
+
className: classNameSchema,
|
|
105
|
+
onChange: actionProp('Runs on toggle. Arguments may read event.value.'),
|
|
106
|
+
})
|
|
107
|
+
.describe(description);
|
|
108
|
+
|
|
109
|
+
export const overlayContracts = {
|
|
110
|
+
/* Dialog */
|
|
111
|
+
Dialog: {schema: overlayRootSchema('A modal dialog.')},
|
|
112
|
+
DialogTrigger: {schema: triggerSchema('The control that opens a Dialog.')},
|
|
113
|
+
DialogContent: {
|
|
114
|
+
schema: z
|
|
115
|
+
.object({
|
|
116
|
+
children: childListSchema,
|
|
117
|
+
showCloseButton: boolSchema.describe('Show the corner close button. Defaults to true.'),
|
|
118
|
+
className: classNameSchema,
|
|
119
|
+
})
|
|
120
|
+
.describe('The modal panel of a Dialog.'),
|
|
121
|
+
},
|
|
122
|
+
DialogHeader: {schema: panelSchema('The header region of a DialogContent.')},
|
|
123
|
+
DialogFooter: {schema: panelSchema('The footer region of a DialogContent.')},
|
|
124
|
+
DialogTitle: {schema: textPartSchema('The accessible title of a Dialog.')},
|
|
125
|
+
DialogDescription: {schema: textPartSchema('Supporting text under a DialogTitle.')},
|
|
126
|
+
DialogClose: {schema: triggerSchema('A control that closes the surrounding Dialog.')},
|
|
127
|
+
|
|
128
|
+
/* AlertDialog */
|
|
129
|
+
AlertDialog: {schema: overlayRootSchema('A modal dialog that interrupts to confirm a decision.')},
|
|
130
|
+
AlertDialogTrigger: {schema: triggerSchema('The control that opens an AlertDialog.')},
|
|
131
|
+
AlertDialogContent: {schema: panelSchema('The modal panel of an AlertDialog.')},
|
|
132
|
+
AlertDialogHeader: {schema: panelSchema('The header region of an AlertDialogContent.')},
|
|
133
|
+
AlertDialogFooter: {schema: panelSchema('The footer region of an AlertDialogContent.')},
|
|
134
|
+
AlertDialogTitle: {schema: textPartSchema('The accessible title of an AlertDialog.')},
|
|
135
|
+
AlertDialogDescription: {schema: textPartSchema('Supporting text under an AlertDialogTitle.')},
|
|
136
|
+
AlertDialogAction: {
|
|
137
|
+
schema: z
|
|
138
|
+
.object({
|
|
139
|
+
label: BlokPropSchemas.DynamicString.optional().describe('Button text.'),
|
|
140
|
+
onClick: actionProp('Runs when the action is confirmed.'),
|
|
141
|
+
className: classNameSchema,
|
|
142
|
+
})
|
|
143
|
+
.describe('The confirming button of an AlertDialog; closes it when clicked.'),
|
|
144
|
+
},
|
|
145
|
+
AlertDialogCancel: {
|
|
146
|
+
schema: z
|
|
147
|
+
.object({
|
|
148
|
+
label: BlokPropSchemas.DynamicString.optional().describe('Button text.'),
|
|
149
|
+
className: classNameSchema,
|
|
150
|
+
})
|
|
151
|
+
.describe('The dismissing button of an AlertDialog.'),
|
|
152
|
+
},
|
|
153
|
+
|
|
154
|
+
/* Sheet and Drawer */
|
|
155
|
+
Sheet: {schema: overlayRootSchema('A panel that slides in from an edge.')},
|
|
156
|
+
SheetTrigger: {schema: triggerSchema('The control that opens a Sheet.')},
|
|
157
|
+
SheetContent: {
|
|
158
|
+
schema: z
|
|
159
|
+
.object({
|
|
160
|
+
children: childListSchema,
|
|
161
|
+
side: sideSchema,
|
|
162
|
+
showCloseButton: boolSchema.describe('Show the corner close button. Defaults to true.'),
|
|
163
|
+
className: classNameSchema,
|
|
164
|
+
})
|
|
165
|
+
.describe('The sliding panel of a Sheet.'),
|
|
166
|
+
},
|
|
167
|
+
SheetHeader: {schema: panelSchema('The header region of a SheetContent.')},
|
|
168
|
+
SheetFooter: {schema: panelSchema('The footer region of a SheetContent.')},
|
|
169
|
+
SheetTitle: {schema: textPartSchema('The accessible title of a Sheet.')},
|
|
170
|
+
SheetDescription: {schema: textPartSchema('Supporting text under a SheetTitle.')},
|
|
171
|
+
Drawer: {schema: overlayRootSchema('A panel that slides up from the bottom edge.')},
|
|
172
|
+
DrawerTrigger: {schema: triggerSchema('The control that opens a Drawer.')},
|
|
173
|
+
DrawerContent: {schema: panelSchema('The sliding panel of a Drawer.')},
|
|
174
|
+
DrawerHeader: {schema: panelSchema('The header region of a DrawerContent.')},
|
|
175
|
+
DrawerFooter: {schema: panelSchema('The footer region of a DrawerContent.')},
|
|
176
|
+
DrawerTitle: {schema: textPartSchema('The accessible title of a Drawer.')},
|
|
177
|
+
DrawerDescription: {schema: textPartSchema('Supporting text under a DrawerTitle.')},
|
|
178
|
+
|
|
179
|
+
/* Popover, Tooltip, HoverCard */
|
|
180
|
+
Popover: {schema: overlayRootSchema('A surface anchored to a trigger, opened on click.')},
|
|
181
|
+
PopoverTrigger: {schema: triggerSchema('The control that opens a Popover.')},
|
|
182
|
+
PopoverContent: {schema: anchoredContentSchema('The floating panel of a Popover.')},
|
|
183
|
+
Tooltip: {schema: overlayRootSchema('A short hint shown on hover or focus.')},
|
|
184
|
+
TooltipTrigger: {schema: triggerSchema('The element a Tooltip describes.')},
|
|
185
|
+
TooltipContent: {schema: anchoredContentSchema('The hint shown by a Tooltip.')},
|
|
186
|
+
HoverCard: {schema: overlayRootSchema('A rich preview surface shown on hover.')},
|
|
187
|
+
HoverCardTrigger: {schema: triggerSchema('The element a HoverCard previews.')},
|
|
188
|
+
HoverCardContent: {schema: anchoredContentSchema('The floating panel of a HoverCard.')},
|
|
189
|
+
|
|
190
|
+
/* Menus */
|
|
191
|
+
DropdownMenu: {schema: overlayRootSchema('A menu opened from a button.')},
|
|
192
|
+
DropdownMenuTrigger: {schema: triggerSchema('The control that opens a DropdownMenu.')},
|
|
193
|
+
DropdownMenuContent: {schema: panelSchema('The menu panel of a DropdownMenu.')},
|
|
194
|
+
DropdownMenuLabel: {schema: textPartSchema('A non-interactive heading inside a menu.')},
|
|
195
|
+
DropdownMenuItem: {schema: menuItemSchema('One selectable item in a DropdownMenu.')},
|
|
196
|
+
DropdownMenuCheckboxItem: {schema: menuCheckboxItemSchema('A menu item bound to a boolean value.')},
|
|
197
|
+
DropdownMenuSeparator: {
|
|
198
|
+
schema: z.object({className: classNameSchema}).describe('A divider between menu groups.'),
|
|
199
|
+
},
|
|
200
|
+
ContextMenu: {schema: overlayRootSchema('A menu opened by right-clicking its trigger.')},
|
|
201
|
+
ContextMenuTrigger: {
|
|
202
|
+
schema: z
|
|
203
|
+
.object({
|
|
204
|
+
children: contentSchema,
|
|
205
|
+
disabled: disabledSchema,
|
|
206
|
+
className: classNameSchema,
|
|
207
|
+
})
|
|
208
|
+
.describe('The region that opens a ContextMenu on right-click.'),
|
|
209
|
+
},
|
|
210
|
+
ContextMenuContent: {schema: panelSchema('The menu panel of a ContextMenu.')},
|
|
211
|
+
ContextMenuLabel: {schema: textPartSchema('A non-interactive heading inside a context menu.')},
|
|
212
|
+
ContextMenuItem: {schema: menuItemSchema('One selectable item in a ContextMenu.')},
|
|
213
|
+
ContextMenuCheckboxItem: {
|
|
214
|
+
schema: menuCheckboxItemSchema('A context-menu item bound to a boolean value.'),
|
|
215
|
+
},
|
|
216
|
+
ContextMenuSeparator: {
|
|
217
|
+
schema: z
|
|
218
|
+
.object({className: classNameSchema})
|
|
219
|
+
.describe('A divider between context-menu groups.'),
|
|
220
|
+
},
|
|
221
|
+
} satisfies BlokComponentContracts;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
import type {BlokComponentContracts} from '../../renderer/runtime/catalog';
|
|
3
|
+
import {describedString} from '../props';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The components only an action's own blok holds: they read the run it is
|
|
7
|
+
* shown for (scene@1). `Overlay` is the root of one drawn into the space
|
|
8
|
+
* hosting the run, `Anchor` anchors at the agent a dependency is bound to,
|
|
9
|
+
* and `Route` draws a line through several.
|
|
10
|
+
*
|
|
11
|
+
* `Anchor` and `Route` read their props through the module-level schema rather
|
|
12
|
+
* than the `schema` they are handed: those schemas are exported here.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const overlaySchema = z
|
|
16
|
+
.object({})
|
|
17
|
+
.describe(
|
|
18
|
+
'Root of an action\'s overlay: drawn into the space that hosts a run of the action, in its world coordinates, over the agents placed there. It owns no canvas. Place Anchor and Route inside.',
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
export const anchorSchema = z
|
|
22
|
+
.object({
|
|
23
|
+
dep: z.string().describe('The dependency key of the action whose agent this anchors at.'),
|
|
24
|
+
})
|
|
25
|
+
.describe(
|
|
26
|
+
'Anchors its children at the agent the run got for a dependency, where it stands in the hosting space; Glow, Popout and OnClick inside it bind to that device\'s model as its scene blok loaded it. A key bound to several agents anchors at each; an agent the space does not place shows in a side tray.',
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
export const routeSchema = z
|
|
30
|
+
.object({
|
|
31
|
+
through: z
|
|
32
|
+
.unknown()
|
|
33
|
+
.refine(value => value !== undefined, 'A Route runs through dependencies.')
|
|
34
|
+
.describe('The dependency keys the line runs through, in order: `through={["robot", "frame", "robot"]}`.'),
|
|
35
|
+
progress: z
|
|
36
|
+
.number()
|
|
37
|
+
.nullish()
|
|
38
|
+
.describe('How far along the run is, from 0 to 100 (`task.progress`): the way behind is drawn solid, a marker stands at the head.'),
|
|
39
|
+
color: describedString('The colour of the line: a colour role of the theme, usually a chart role (`chart-2`). Defaults to `chart-1`.'),
|
|
40
|
+
})
|
|
41
|
+
.describe(
|
|
42
|
+
'Draws a line through the agents the run got for these dependencies, where they stand in the hosting space. A dependency whose agent is not placed there is skipped.',
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
export const runContracts = {
|
|
46
|
+
Overlay: {
|
|
47
|
+
acceptsChildren: true,
|
|
48
|
+
placement: {childrenContext: 'scene', notDownstreamOf: ['Scene', 'Overlay']},
|
|
49
|
+
schema: overlaySchema,
|
|
50
|
+
},
|
|
51
|
+
Anchor: {
|
|
52
|
+
acceptsChildren: true,
|
|
53
|
+
placement: {context: 'scene', downstreamOf: ['Overlay']},
|
|
54
|
+
schema: anchorSchema,
|
|
55
|
+
},
|
|
56
|
+
Route: {placement: {context: 'scene', downstreamOf: ['Overlay']}, schema: routeSchema},
|
|
57
|
+
} satisfies BlokComponentContracts;
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
import type {BlokComponentContracts} from '../../renderer/runtime/catalog';
|
|
3
|
+
import type {BlokComponentPlacement} from '../../renderer/runtime/components';
|
|
4
|
+
import {markBindSchema} from '../../renderer/runtime/schemas';
|
|
5
|
+
import {actionProp, bindSchema, describedString} from '../props';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The 3D vocabulary: three containers place models, a transform places what
|
|
9
|
+
* it holds (and lets a gizmo move it), eight children bind their named nodes
|
|
10
|
+
* to state, and two handle interaction and HTML.
|
|
11
|
+
*
|
|
12
|
+
* Several renders read their props through the module-level schema rather than
|
|
13
|
+
* the `schema` they are handed: those schemas are exported here.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/* -------------------------------------------------------------------------- */
|
|
17
|
+
/* Scene */
|
|
18
|
+
/* -------------------------------------------------------------------------- */
|
|
19
|
+
|
|
20
|
+
export const sceneSchema = z
|
|
21
|
+
.object({
|
|
22
|
+
camera: z
|
|
23
|
+
.enum(['iso', 'front', 'side', 'top'])
|
|
24
|
+
.optional()
|
|
25
|
+
.describe('Where the camera starts looking from; it frames the models whatever their size. Defaults to iso.'),
|
|
26
|
+
grid: z.boolean().optional().describe('Whether the ground grid starts shown; the viewer can switch it. Defaults to true.'),
|
|
27
|
+
height: describedString(
|
|
28
|
+
'CSS height of the view, e.g. "24rem". Omit to fit the element the scene is in (24rem where that has no height of its own).',
|
|
29
|
+
),
|
|
30
|
+
persist: z
|
|
31
|
+
.boolean()
|
|
32
|
+
.optional()
|
|
33
|
+
.describe('Keep where the viewer leaves the camera (and the grid) on this device, by the scene\'s explicit id.'),
|
|
34
|
+
})
|
|
35
|
+
.describe(
|
|
36
|
+
'Root of a 3D view: one renderer, camera and light rig. Y is up and one unit is one meter. Place Model and Robot inside.',
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
/* -------------------------------------------------------------------------- */
|
|
40
|
+
/* Model and Robot */
|
|
41
|
+
/* -------------------------------------------------------------------------- */
|
|
42
|
+
|
|
43
|
+
const modelShape = {
|
|
44
|
+
src: z
|
|
45
|
+
.string()
|
|
46
|
+
.describe('The 3D model to show: an asset its app registered, as in `{self.assets.scope}`.'),
|
|
47
|
+
origin: describedString('Where the model sits in the scene, as "x y z" in meters.'),
|
|
48
|
+
rotation: describedString('How the model is turned, as "x y z" Euler angles in radians.'),
|
|
49
|
+
scale: z.number().optional().describe('Uniform scale. Defaults to 1; a model is authored in meters.'),
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const modelSchema = z
|
|
53
|
+
.object(modelShape)
|
|
54
|
+
.describe(
|
|
55
|
+
'Places one GLB model in the scene. Its children bind the model\'s named nodes to state. A model that is missing or refused renders a placeholder that says why.',
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const jointValues = z
|
|
59
|
+
.record(z.string(), z.unknown())
|
|
60
|
+
.optional();
|
|
61
|
+
|
|
62
|
+
export const robotSchema = z
|
|
63
|
+
.object({
|
|
64
|
+
...modelShape,
|
|
65
|
+
joints: jointValues.describe(
|
|
66
|
+
'Where each joint is: a map of joint name to radians (revolute, continuous) or meters (prismatic). A joint left out keeps its last value.',
|
|
67
|
+
),
|
|
68
|
+
animateTo: jointValues.describe('Where each joint is going. Joints named here move at speed, or over duration.'),
|
|
69
|
+
speed: z
|
|
70
|
+
.unknown()
|
|
71
|
+
.optional()
|
|
72
|
+
.describe('How fast joints move to animateTo, in rad/s or m/s: one number for all joints or a map by joint name.'),
|
|
73
|
+
duration: z
|
|
74
|
+
.unknown()
|
|
75
|
+
.optional()
|
|
76
|
+
.describe('How long a move to animateTo takes, in seconds: one number or a map by joint name. Ignored where speed is given.'),
|
|
77
|
+
onJointChange: actionProp(
|
|
78
|
+
'Called when the viewer sets a joint by hand. Arguments may read event.name and event.value.',
|
|
79
|
+
),
|
|
80
|
+
})
|
|
81
|
+
.describe(
|
|
82
|
+
'A Model with a joint table (extras.arkitekt.joints): applies a joint state map to it, including mimic joints, and clamps to limits.',
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
const MODEL_PROP_KINDS = {src: 'ASSET'} as const;
|
|
86
|
+
|
|
87
|
+
/* -------------------------------------------------------------------------- */
|
|
88
|
+
/* Transform */
|
|
89
|
+
/* -------------------------------------------------------------------------- */
|
|
90
|
+
|
|
91
|
+
export const transformSchema = z
|
|
92
|
+
.object({
|
|
93
|
+
matrix: z
|
|
94
|
+
.unknown()
|
|
95
|
+
.optional()
|
|
96
|
+
.describe(
|
|
97
|
+
'Where the children stand: a 4x4 affine matrix as four rows, in meters with Y up (as a space placement keeps it). The identity when absent or malformed.',
|
|
98
|
+
),
|
|
99
|
+
bind: markBindSchema(bindSchema.describe(
|
|
100
|
+
'The local holding the matrix (`bind={pose}`): read in place of `matrix`, and written by the gizmo.',
|
|
101
|
+
)),
|
|
102
|
+
persist: z
|
|
103
|
+
.boolean()
|
|
104
|
+
.optional()
|
|
105
|
+
.describe('Keep where the gizmo left the children on this device, by the explicit id (unbound: the pose is the component\'s own).'),
|
|
106
|
+
gizmo: z.boolean().optional().describe('Whether a gizmo moves the children. Defaults to true when bound or persisted; never shown while viewing the past.'),
|
|
107
|
+
mode: z.enum(['translate', 'rotate', 'scale']).optional().describe('What the gizmo does: "translate" (the default), "rotate" or "scale".'),
|
|
108
|
+
size: z.number().optional().describe('The size of the gizmo on screen. Defaults to 0.7.'),
|
|
109
|
+
})
|
|
110
|
+
.describe(
|
|
111
|
+
'Places its children by an affine matrix. Bound (`bind={pose}`) or persisted (`id="arm-pose" persist`), a gizmo moves them and keeps the matrix.',
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
/* -------------------------------------------------------------------------- */
|
|
115
|
+
/* Bindings */
|
|
116
|
+
/* -------------------------------------------------------------------------- */
|
|
117
|
+
|
|
118
|
+
/** Every binding sits somewhere under the model whose nodes it names. */
|
|
119
|
+
const IN_MODEL: BlokComponentPlacement = {context: 'scene', downstreamOf: ['Model', 'Robot']};
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Bindings an action's overlay may also use under an `At`, on the model the
|
|
123
|
+
* anchored device's scene blok loaded. Interaction (OnClick, Popout) sits here too.
|
|
124
|
+
*/
|
|
125
|
+
const IN_MODEL_OR_AT: BlokComponentPlacement = {context: 'scene', downstreamOf: ['Model', 'Robot', 'Anchor']};
|
|
126
|
+
|
|
127
|
+
const nodeProp = z.string().describe('The name of the node in the enclosing model that this binds.');
|
|
128
|
+
|
|
129
|
+
const motionShape = (unit: string, rate: string) => ({
|
|
130
|
+
node: nodeProp,
|
|
131
|
+
axis: z
|
|
132
|
+
.string()
|
|
133
|
+
.describe('The axis in the node\'s own frame: "x", "y", "z" or a vector as "x y z".'),
|
|
134
|
+
value: z
|
|
135
|
+
.unknown()
|
|
136
|
+
.optional()
|
|
137
|
+
.describe(`Where the part is, in ${unit} from the pose the model was authored in. A quantity ({magnitude, unit}) is converted.`),
|
|
138
|
+
animateTo: z
|
|
139
|
+
.unknown()
|
|
140
|
+
.optional()
|
|
141
|
+
.describe('Where the part is going. With it, the view moves there at speed (or over duration) and value corrects it.'),
|
|
142
|
+
speed: z.number().optional().describe(`How fast it moves to animateTo, in ${rate}.`),
|
|
143
|
+
duration: z.number().optional().describe('How long a move to animateTo takes, in seconds. Ignored when speed is given.'),
|
|
144
|
+
scale: z.number().optional().describe('Multiplies the value before it is applied. Defaults to 1.'),
|
|
145
|
+
offset: z.number().optional().describe(`Added after scale, in ${unit}. Defaults to 0.`),
|
|
146
|
+
gain: z.number().optional().describe('Exaggerates the motion on screen only, for travel too small to see. Defaults to 1.'),
|
|
147
|
+
smooth: z.boolean().optional().describe('Whether to ease toward each new value over 300 ms. Defaults to true.'),
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
export const moveSchema = z
|
|
151
|
+
.object(motionShape('meters', 'm/s'))
|
|
152
|
+
.describe('Translates a node along an axis by value x scale + offset meters from its authored pose.');
|
|
153
|
+
export const rotateSchema = z
|
|
154
|
+
.object(motionShape('radians', 'rad/s'))
|
|
155
|
+
.describe('Rotates a node about an axis by value x scale + offset radians from its authored pose.');
|
|
156
|
+
|
|
157
|
+
export const visibleSchema = z
|
|
158
|
+
.object({
|
|
159
|
+
node: nodeProp,
|
|
160
|
+
on: z.boolean().nullish().describe('Whether the node is visible. Hiding a node hides everything beneath it.'),
|
|
161
|
+
})
|
|
162
|
+
.describe('Shows or hides a node and its whole subtree.');
|
|
163
|
+
|
|
164
|
+
export const glowSchema = z
|
|
165
|
+
.object({
|
|
166
|
+
node: describedString('The name of the node in the enclosing model that glows; the whole model when unset.'),
|
|
167
|
+
on: z.boolean().optional().describe('Whether the node glows.'),
|
|
168
|
+
intensity: z.number().optional().describe('How strongly. Defaults to 1 for materials, and to the authored intensity for a light.'),
|
|
169
|
+
color: describedString('The colour of the glow: a colour role of the theme (`brand`, `success`, `chart-1`). Defaults to the material\'s own emissive colour, or white.'),
|
|
170
|
+
})
|
|
171
|
+
.describe('Switches the emissive output of a node\'s materials, or the intensity of a punctual light attached to it.');
|
|
172
|
+
|
|
173
|
+
export const tintSchema = z
|
|
174
|
+
.object({
|
|
175
|
+
node: nodeProp,
|
|
176
|
+
color: describedString('The base colour to give the node: a colour role of the theme (`brand`, `muted`, `chart-3`). Without it the authored colour shows.'),
|
|
177
|
+
})
|
|
178
|
+
.describe('Overrides the base color of a node. Its materials are copied first, so nodes sharing them are unaffected.');
|
|
179
|
+
|
|
180
|
+
export const attachSchema = z
|
|
181
|
+
.object({
|
|
182
|
+
node: nodeProp,
|
|
183
|
+
to: z
|
|
184
|
+
.string()
|
|
185
|
+
.describe('What to attach it to: a node of this model, or "<model id>:<node>" for a node of another model in the scene.'),
|
|
186
|
+
on: z.boolean().nullish().describe('Whether it is attached. When false the node returns to where it was authored.'),
|
|
187
|
+
})
|
|
188
|
+
.describe('While `on` holds, carries a node with another node, keeping its place in the world at the moment of attaching. For picked-up objects.');
|
|
189
|
+
|
|
190
|
+
export const beamSchema = z
|
|
191
|
+
.object({
|
|
192
|
+
start: z.string().describe('The node the beam leaves from.'),
|
|
193
|
+
end: describedString('The node the beam ends at, in this model or as "<model id>:<node>". Use this or length.'),
|
|
194
|
+
length: z.number().optional().describe('How far the beam reaches along the start node\'s own Z axis, in meters. Use this or end.'),
|
|
195
|
+
on: z.boolean().optional().describe('Whether the beam is drawn. Defaults to true.'),
|
|
196
|
+
wavelength: z.number().optional().describe('The wavelength in nanometers, shown as its color.'),
|
|
197
|
+
color: describedString('The colour of the beam: a colour role of the theme (`info`, `chart-2`, `destructive`). Takes precedence over wavelength.'),
|
|
198
|
+
width: z.number().optional().describe('The diameter of the beam in meters. Defaults to 2 mm.'),
|
|
199
|
+
})
|
|
200
|
+
.describe('Draws a beam from one anchor to another, or for a length along an anchor\'s Z axis, following both as they move.');
|
|
201
|
+
|
|
202
|
+
export const animateSchema = z
|
|
203
|
+
.object({
|
|
204
|
+
clip: z.string().describe('The name of an animation clip in the enclosing model.'),
|
|
205
|
+
progress: z.number().optional().describe('Where in the clip to show, from 0 (start) to 1 (end). Use this or time.'),
|
|
206
|
+
time: z.number().optional().describe('Where in the clip to show, in seconds. Use this or progress.'),
|
|
207
|
+
animateTo: z.number().optional().describe('The position to play to, in the unit of whichever of progress or time is used.'),
|
|
208
|
+
duration: z.number().optional().describe('How long playing to animateTo takes, in seconds.'),
|
|
209
|
+
})
|
|
210
|
+
.describe('Scrubs a named animation clip of the model to a position, for mechanisms a single move or turn cannot describe. Never loops on its own.');
|
|
211
|
+
|
|
212
|
+
/* -------------------------------------------------------------------------- */
|
|
213
|
+
/* Interaction */
|
|
214
|
+
/* -------------------------------------------------------------------------- */
|
|
215
|
+
|
|
216
|
+
const nodeOrModelProp = describedString('The name of the node in the enclosing model; the whole model when unset.');
|
|
217
|
+
const titleProp = describedString('The heading of the card; it shows the node name when unset.');
|
|
218
|
+
const descriptionProp = describedString('A line under the heading of the card.');
|
|
219
|
+
|
|
220
|
+
export const onClickSchema = z
|
|
221
|
+
.object({
|
|
222
|
+
node: nodeOrModelProp,
|
|
223
|
+
onClick: actionProp(
|
|
224
|
+
'Called when the node is clicked (not when a drag of the view ends on it). Arguments may read event.node and event.point ([x, y, z] in meters, where it was hit).',
|
|
225
|
+
),
|
|
226
|
+
open: describedString('The name of an html blok to show when the node is clicked.'),
|
|
227
|
+
title: titleProp,
|
|
228
|
+
description: descriptionProp,
|
|
229
|
+
mode: z
|
|
230
|
+
.enum(['popout', 'panel'])
|
|
231
|
+
.optional()
|
|
232
|
+
.describe(
|
|
233
|
+
'Where the opened blok shows: "popout" as a card on the clicked spot (the viewer can drag it aside), "panel" beside the scene. Defaults to popout.',
|
|
234
|
+
),
|
|
235
|
+
})
|
|
236
|
+
.describe(
|
|
237
|
+
'Makes a node and everything beneath it clickable, with a highlight on hover. A click runs an action, opens a blok, or both; a second click closes it, and opening one card closes the others that are not pinned.',
|
|
238
|
+
);
|
|
239
|
+
|
|
240
|
+
export const popoutSchema = z
|
|
241
|
+
.object({
|
|
242
|
+
node: nodeOrModelProp,
|
|
243
|
+
trigger: z
|
|
244
|
+
.enum(['click', 'hover', 'always'])
|
|
245
|
+
.optional()
|
|
246
|
+
.describe('What shows the card: a click on the node, the pointer over it, or always. Defaults to click.'),
|
|
247
|
+
open: z.boolean().optional().describe('Whether the card shows. When bound it decides alone and trigger is ignored.'),
|
|
248
|
+
title: titleProp,
|
|
249
|
+
description: descriptionProp,
|
|
250
|
+
})
|
|
251
|
+
.describe(
|
|
252
|
+
'An HTML card anchored to a node that follows it as it moves; the viewer can drag it aside, and a line keeps pointing at the node. Its children are ordinary html components.',
|
|
253
|
+
);
|
|
254
|
+
|
|
255
|
+
export const sceneContracts = {
|
|
256
|
+
Scene: {
|
|
257
|
+
acceptsChildren: true,
|
|
258
|
+
placement: {childrenContext: 'scene', notDownstreamOf: ['Scene']},
|
|
259
|
+
schema: sceneSchema,
|
|
260
|
+
},
|
|
261
|
+
Model: {
|
|
262
|
+
acceptsChildren: true,
|
|
263
|
+
placement: {context: 'scene', downstreamOf: ['Scene']},
|
|
264
|
+
propKinds: MODEL_PROP_KINDS,
|
|
265
|
+
schema: modelSchema,
|
|
266
|
+
},
|
|
267
|
+
Robot: {
|
|
268
|
+
acceptsChildren: true,
|
|
269
|
+
placement: {context: 'scene', downstreamOf: ['Scene']},
|
|
270
|
+
propKinds: MODEL_PROP_KINDS,
|
|
271
|
+
schema: robotSchema,
|
|
272
|
+
},
|
|
273
|
+
Transform: {
|
|
274
|
+
acceptsChildren: true,
|
|
275
|
+
placement: {context: 'scene', downstreamOf: ['Overlay', 'Scene']},
|
|
276
|
+
schema: transformSchema,
|
|
277
|
+
},
|
|
278
|
+
Move: {placement: IN_MODEL, schema: moveSchema},
|
|
279
|
+
Rotate: {placement: IN_MODEL, schema: rotateSchema},
|
|
280
|
+
Animate: {placement: IN_MODEL, schema: animateSchema},
|
|
281
|
+
Visible: {placement: IN_MODEL, schema: visibleSchema},
|
|
282
|
+
Glow: {placement: IN_MODEL_OR_AT, schema: glowSchema},
|
|
283
|
+
Tint: {placement: IN_MODEL, schema: tintSchema},
|
|
284
|
+
Attach: {placement: IN_MODEL, schema: attachSchema},
|
|
285
|
+
Beam: {placement: IN_MODEL, schema: beamSchema},
|
|
286
|
+
OnClick: {placement: IN_MODEL_OR_AT, schema: onClickSchema},
|
|
287
|
+
Popout: {
|
|
288
|
+
acceptsChildren: true,
|
|
289
|
+
placement: {...IN_MODEL_OR_AT, childrenContext: 'html'},
|
|
290
|
+
schema: popoutSchema,
|
|
291
|
+
},
|
|
292
|
+
} satisfies BlokComponentContracts;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
import type {BlokComponentContracts} from '../../renderer/runtime/catalog';
|
|
3
|
+
import {BlokPropSchemas} from '../../renderer/runtime/schemas';
|
|
4
|
+
import {actionProp, bindSchema, boolSchema, classNameSchema, disabledSchema, sizeSchema, structureValueSchema} from '../props';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* structure@1: bloks over other modules' objects, by structure identifier. The
|
|
8
|
+
* contract only: drawing one needs the app's smart system (its option sources,
|
|
9
|
+
* displays and viewers), so every app that claims structure@1 draws it itself.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const emptyTextSchema = BlokPropSchemas.DynamicString.optional().describe(
|
|
13
|
+
'Shown while there is no structure.',
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
export const structureContracts = {
|
|
17
|
+
StructurePicker: {
|
|
18
|
+
schema: z
|
|
19
|
+
.object({
|
|
20
|
+
identifier: z
|
|
21
|
+
.string()
|
|
22
|
+
.optional()
|
|
23
|
+
.describe(
|
|
24
|
+
'The kind of structure to pick, e.g. "@mikro/arraydataset". As the widget of an action input it defaults to the structure the input is typed on.',
|
|
25
|
+
),
|
|
26
|
+
bind: bindSchema,
|
|
27
|
+
value: structureValueSchema.describe('Controlled value, a structure reference.'),
|
|
28
|
+
query: z
|
|
29
|
+
.string()
|
|
30
|
+
.optional()
|
|
31
|
+
.describe(
|
|
32
|
+
'The GraphQL query that lists the candidates, run on the `ward` service: one `query` operation, never a mutation. It selects a list aliased `options` with `value` (the id), `label` and optionally `description`, and may declare: $search: String (what the user typed), $values: [ID!] (ids to resolve), $limit: Int and $offset: Int (a page), $requires (the constraints of the action input being filled). Any other variable is read from `variables`, else from the data path of the same name; a structure held there is passed as its id. A nullable one narrows the list while it has a value and the user may lift it; the picker waits for one declared non-null. Without a query the module that owns the structure answers.',
|
|
33
|
+
),
|
|
34
|
+
ward: z
|
|
35
|
+
.string()
|
|
36
|
+
.optional()
|
|
37
|
+
.describe('The service that runs `query`, by its key, e.g. "mikro".'),
|
|
38
|
+
variables: z
|
|
39
|
+
.record(z.string(), z.unknown())
|
|
40
|
+
.nullish()
|
|
41
|
+
.describe('Values for the variables `query` declares beyond the ones the picker supplies.'),
|
|
42
|
+
placeholder: BlokPropSchemas.DynamicString.optional().describe(
|
|
43
|
+
'Shown while nothing is selected.',
|
|
44
|
+
),
|
|
45
|
+
disabled: disabledSchema,
|
|
46
|
+
className: classNameSchema,
|
|
47
|
+
onChange: actionProp(
|
|
48
|
+
'Runs on selection. event.value is the structure reference, or null when cleared.',
|
|
49
|
+
),
|
|
50
|
+
})
|
|
51
|
+
.describe(
|
|
52
|
+
'A search-backed picker for one structure of a given identifier. Writes {"object", "__identifier"}, or null when cleared. The candidates come from its `query`, or from the module that owns the structure when it has none.',
|
|
53
|
+
),
|
|
54
|
+
},
|
|
55
|
+
StructureDisplay: {
|
|
56
|
+
schema: z
|
|
57
|
+
.object({
|
|
58
|
+
value: structureValueSchema.describe('The structure to show.'),
|
|
59
|
+
variant: z
|
|
60
|
+
.enum(['inline', 'avatar', 'chip', 'card'])
|
|
61
|
+
.optional()
|
|
62
|
+
.describe('How much of it to show. Defaults to "card".'),
|
|
63
|
+
link: boolSchema.describe("Link to the structure's own page."),
|
|
64
|
+
emptyText: emptyTextSchema,
|
|
65
|
+
className: classNameSchema,
|
|
66
|
+
})
|
|
67
|
+
.describe('Shows a structure through the display of the module that owns it.'),
|
|
68
|
+
},
|
|
69
|
+
StructureViewer: {
|
|
70
|
+
schema: z
|
|
71
|
+
.object({
|
|
72
|
+
value: structureValueSchema.describe('The structure to open.'),
|
|
73
|
+
height: sizeSchema.describe('CSS height of the viewer. Defaults to "24rem".'),
|
|
74
|
+
minHeight: sizeSchema.describe('CSS minimum height of the viewer.'),
|
|
75
|
+
controls: boolSchema.describe("Show the viewer's own controls. Defaults to true."),
|
|
76
|
+
emptyText: emptyTextSchema,
|
|
77
|
+
className: classNameSchema,
|
|
78
|
+
})
|
|
79
|
+
.describe(
|
|
80
|
+
'An interactive viewer for a structure (a mikro image or scene), provided by the module that owns it.',
|
|
81
|
+
),
|
|
82
|
+
},
|
|
83
|
+
} satisfies BlokComponentContracts;
|