@dxos/plugin-deck 0.8.2-main.36232bc → 0.8.2-main.5ca3450
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/dist/lib/browser/{chunk-STZ4VVW6.mjs → chunk-AHTP72DY.mjs} +28 -14
- package/dist/lib/browser/chunk-AHTP72DY.mjs.map +7 -0
- package/dist/lib/browser/chunk-E7TOEOGO.mjs +157 -0
- package/dist/lib/browser/chunk-E7TOEOGO.mjs.map +7 -0
- package/dist/lib/browser/{chunk-6HJZL3WT.mjs → chunk-PGSJT5PG.mjs} +2 -2
- package/dist/lib/browser/{chunk-WFTGOFIF.mjs → chunk-RKYIMUKW.mjs} +8 -8
- package/dist/lib/browser/index.mjs +3 -3
- package/dist/lib/browser/{intent-resolver-JKWXWUV6.mjs → intent-resolver-NO6L67KF.mjs} +23 -23
- package/dist/lib/browser/intent-resolver-NO6L67KF.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-root-7JVQQA4K.mjs → react-root-5RWCIUXV.mjs} +5 -5
- package/dist/lib/browser/{react-surface-MQ7QJ7JJ.mjs → react-surface-DIDOPTH7.mjs} +5 -5
- package/dist/lib/browser/{settings-6NU7CF2B.mjs → settings-C7LX2GXF.mjs} +2 -2
- package/dist/lib/browser/{state-Z6UY2Z3M.mjs → state-AX74YEJD.mjs} +2 -2
- package/dist/lib/browser/{tools-VDVQTJMD.mjs → tools-7W7KZRAX.mjs} +7 -7
- package/dist/lib/browser/tools-7W7KZRAX.mjs.map +7 -0
- package/dist/lib/browser/types.mjs +1 -1
- package/dist/lib/browser/{url-handler-3CARFXQK.mjs → url-handler-AF5SYROZ.mjs} +2 -2
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/check-app-scheme.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/tools.d.ts.map +1 -1
- package/dist/types/src/capabilities/url-handler.d.ts.map +1 -1
- package/dist/types/src/components/DeckLayout/Banner.d.ts.map +1 -1
- package/dist/types/src/components/DeckLayout/DeckLayout.d.ts.map +1 -1
- package/dist/types/src/components/DeckLayout/Popover.d.ts.map +1 -1
- package/dist/types/src/components/DeckLayout/StatusBar.d.ts.map +1 -1
- package/dist/types/src/components/DeckLayout/Toast.d.ts.map +1 -1
- package/dist/types/src/components/DeckSettings/DeckSettings.d.ts.map +1 -1
- package/dist/types/src/components/Plank/Plank.d.ts.map +1 -1
- package/dist/types/src/components/Plank/PlankError.d.ts.map +1 -1
- package/dist/types/src/components/Plank/PlankHeading.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/ComplementarySidebar.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/SidebarButton.d.ts.map +1 -1
- package/dist/types/src/hooks/useNodeActionExpander.d.ts.map +1 -1
- package/dist/types/src/layout.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +104 -104
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/src/util/layoutAppliesTopbar.d.ts.map +1 -1
- package/dist/types/src/util/overscroll.d.ts.map +1 -1
- package/dist/types/src/util/set-active.d.ts.map +1 -1
- package/dist/types/src/util/useCompanions.d.ts.map +1 -1
- package/dist/types/src/util/useHoistStatusbar.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +30 -29
- package/src/capabilities/intent-resolver.ts +32 -32
- package/src/capabilities/tools.ts +4 -3
- package/src/components/DeckLayout/Popover.tsx +18 -3
- package/src/components/Plank/Plank.tsx +3 -1
- package/src/components/Plank/PlankHeading.tsx +3 -0
- package/src/types.ts +72 -71
- package/dist/lib/browser/chunk-STZ4VVW6.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZMJMCN7O.mjs +0 -157
- package/dist/lib/browser/chunk-ZMJMCN7O.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-JKWXWUV6.mjs.map +0 -7
- package/dist/lib/browser/tools-VDVQTJMD.mjs.map +0 -7
- /package/dist/lib/browser/{chunk-6HJZL3WT.mjs.map → chunk-PGSJT5PG.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-WFTGOFIF.mjs.map → chunk-RKYIMUKW.mjs.map} +0 -0
- /package/dist/lib/browser/{react-root-7JVQQA4K.mjs.map → react-root-5RWCIUXV.mjs.map} +0 -0
- /package/dist/lib/browser/{react-surface-MQ7QJ7JJ.mjs.map → react-surface-DIDOPTH7.mjs.map} +0 -0
- /package/dist/lib/browser/{settings-6NU7CF2B.mjs.map → settings-C7LX2GXF.mjs.map} +0 -0
- /package/dist/lib/browser/{state-Z6UY2Z3M.mjs.map → state-AX74YEJD.mjs.map} +0 -0
- /package/dist/lib/browser/{url-handler-3CARFXQK.mjs.map → url-handler-AF5SYROZ.mjs.map} +0 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { batch } from '@preact/signals-core';
|
|
6
|
-
import { Effect, pipe } from 'effect';
|
|
6
|
+
import { Schema, Effect, pipe } from 'effect';
|
|
7
7
|
|
|
8
8
|
import {
|
|
9
9
|
Capabilities,
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
createIntent,
|
|
16
16
|
chain,
|
|
17
17
|
} from '@dxos/app-framework';
|
|
18
|
-
import { getTypename
|
|
18
|
+
import { getTypename } from '@dxos/echo-schema';
|
|
19
19
|
import { invariant } from '@dxos/invariant';
|
|
20
20
|
import { isLiveObject } from '@dxos/live-object';
|
|
21
21
|
import { log } from '@dxos/log';
|
|
@@ -67,10 +67,10 @@ export default (context: PluginsContext) =>
|
|
|
67
67
|
}),
|
|
68
68
|
createResolver({
|
|
69
69
|
intent: LayoutAction.UpdateLayout,
|
|
70
|
-
// TODO(wittjosiah): This should be able to just be `
|
|
70
|
+
// TODO(wittjosiah): This should be able to just be `Schema.is(LayoutAction.UpdateSidebar.fields.input)`
|
|
71
71
|
// but the filter is not being applied correctly.
|
|
72
|
-
filter: (data): data is
|
|
73
|
-
|
|
72
|
+
filter: (data): data is Schema.Schema.Type<typeof LayoutAction.UpdateSidebar.fields.input> =>
|
|
73
|
+
Schema.is(LayoutAction.UpdateSidebar.fields.input)(data),
|
|
74
74
|
resolve: ({ options }) => {
|
|
75
75
|
const layout = context.requestCapability(DeckCapabilities.MutableDeckState);
|
|
76
76
|
const next = options?.state ?? layout.sidebarState;
|
|
@@ -81,10 +81,10 @@ export default (context: PluginsContext) =>
|
|
|
81
81
|
}),
|
|
82
82
|
createResolver({
|
|
83
83
|
intent: LayoutAction.UpdateLayout,
|
|
84
|
-
// TODO(wittjosiah): This should be able to just be `
|
|
84
|
+
// TODO(wittjosiah): This should be able to just be `Schema.is(LayoutAction.UpdateComplementary.fields.input)`
|
|
85
85
|
// but the filter is not being applied correctly.
|
|
86
|
-
filter: (data): data is
|
|
87
|
-
|
|
86
|
+
filter: (data): data is Schema.Schema.Type<typeof LayoutAction.UpdateComplementary.fields.input> =>
|
|
87
|
+
Schema.is(LayoutAction.UpdateComplementary.fields.input)(data),
|
|
88
88
|
resolve: ({ subject, options }) => {
|
|
89
89
|
const layout = context.requestCapability(DeckCapabilities.MutableDeckState);
|
|
90
90
|
|
|
@@ -100,10 +100,10 @@ export default (context: PluginsContext) =>
|
|
|
100
100
|
}),
|
|
101
101
|
createResolver({
|
|
102
102
|
intent: LayoutAction.UpdateLayout,
|
|
103
|
-
// TODO(wittjosiah): This should be able to just be `
|
|
103
|
+
// TODO(wittjosiah): This should be able to just be `Schema.is(LayoutAction.UpdateDialog.fields.input)`
|
|
104
104
|
// but the filter is not being applied correctly.
|
|
105
|
-
filter: (data): data is
|
|
106
|
-
|
|
105
|
+
filter: (data): data is Schema.Schema.Type<typeof LayoutAction.UpdateDialog.fields.input> =>
|
|
106
|
+
Schema.is(LayoutAction.UpdateDialog.fields.input)(data),
|
|
107
107
|
resolve: ({ subject, options }) => {
|
|
108
108
|
const layout = context.requestCapability(DeckCapabilities.MutableDeckState);
|
|
109
109
|
layout.dialogOpen = options.state ?? Boolean(subject);
|
|
@@ -114,10 +114,10 @@ export default (context: PluginsContext) =>
|
|
|
114
114
|
}),
|
|
115
115
|
createResolver({
|
|
116
116
|
intent: LayoutAction.UpdateLayout,
|
|
117
|
-
// TODO(wittjosiah): This should be able to just be `
|
|
117
|
+
// TODO(wittjosiah): This should be able to just be `Schema.is(LayoutAction.UpdatePopover.fields.input)`
|
|
118
118
|
// but the filter is not being applied correctly.
|
|
119
|
-
filter: (data): data is
|
|
120
|
-
|
|
119
|
+
filter: (data): data is Schema.Schema.Type<typeof LayoutAction.UpdatePopover.fields.input> =>
|
|
120
|
+
Schema.is(LayoutAction.UpdatePopover.fields.input)(data),
|
|
121
121
|
resolve: ({ subject, options }) => {
|
|
122
122
|
const layout = context.requestCapability(DeckCapabilities.MutableDeckState);
|
|
123
123
|
layout.popoverOpen = options.state ?? Boolean(subject);
|
|
@@ -133,10 +133,10 @@ export default (context: PluginsContext) =>
|
|
|
133
133
|
}),
|
|
134
134
|
createResolver({
|
|
135
135
|
intent: LayoutAction.UpdateLayout,
|
|
136
|
-
// TODO(wittjosiah): This should be able to just be `
|
|
136
|
+
// TODO(wittjosiah): This should be able to just be `Schema.is(LayoutAction.AddToast.fields.input)`
|
|
137
137
|
// but the filter is not being applied correctly.
|
|
138
|
-
filter: (data): data is
|
|
139
|
-
|
|
138
|
+
filter: (data): data is Schema.Schema.Type<typeof LayoutAction.AddToast.fields.input> =>
|
|
139
|
+
Schema.is(LayoutAction.AddToast.fields.input)(data),
|
|
140
140
|
resolve: ({ subject }) => {
|
|
141
141
|
const layout = context.requestCapability(DeckCapabilities.MutableDeckState);
|
|
142
142
|
layout.toasts.push(subject);
|
|
@@ -144,10 +144,10 @@ export default (context: PluginsContext) =>
|
|
|
144
144
|
}),
|
|
145
145
|
createResolver({
|
|
146
146
|
intent: LayoutAction.UpdateLayout,
|
|
147
|
-
// TODO(wittjosiah): This should be able to just be `
|
|
147
|
+
// TODO(wittjosiah): This should be able to just be `Schema.is(LayoutAction.SetLayoutMode.fields.input)`
|
|
148
148
|
// but the filter is not being applied correctly.
|
|
149
|
-
filter: (data): data is
|
|
150
|
-
if (!
|
|
149
|
+
filter: (data): data is Schema.Schema.Type<typeof LayoutAction.SetLayoutMode.fields.input> => {
|
|
150
|
+
if (!Schema.is(LayoutAction.SetLayoutMode.fields.input)(data)) {
|
|
151
151
|
return false;
|
|
152
152
|
}
|
|
153
153
|
|
|
@@ -202,8 +202,8 @@ export default (context: PluginsContext) =>
|
|
|
202
202
|
}),
|
|
203
203
|
createResolver({
|
|
204
204
|
intent: LayoutAction.UpdateLayout,
|
|
205
|
-
filter: (data): data is
|
|
206
|
-
|
|
205
|
+
filter: (data): data is Schema.Schema.Type<typeof LayoutAction.SwitchWorkspace.fields.input> =>
|
|
206
|
+
Schema.is(LayoutAction.SwitchWorkspace.fields.input)(data),
|
|
207
207
|
resolve: ({ subject }) => {
|
|
208
208
|
const state = context.requestCapability(DeckCapabilities.MutableDeckState);
|
|
209
209
|
batch(() => {
|
|
@@ -228,8 +228,8 @@ export default (context: PluginsContext) =>
|
|
|
228
228
|
}),
|
|
229
229
|
createResolver({
|
|
230
230
|
intent: LayoutAction.UpdateLayout,
|
|
231
|
-
filter: (data): data is
|
|
232
|
-
|
|
231
|
+
filter: (data): data is Schema.Schema.Type<typeof LayoutAction.RevertWorkspace.fields.input> =>
|
|
232
|
+
Schema.is(LayoutAction.RevertWorkspace.fields.input)(data),
|
|
233
233
|
resolve: () => {
|
|
234
234
|
const state = context.requestCapability(DeckCapabilities.MutableDeckState);
|
|
235
235
|
return {
|
|
@@ -239,8 +239,8 @@ export default (context: PluginsContext) =>
|
|
|
239
239
|
}),
|
|
240
240
|
createResolver({
|
|
241
241
|
intent: LayoutAction.UpdateLayout,
|
|
242
|
-
filter: (data): data is
|
|
243
|
-
|
|
242
|
+
filter: (data): data is Schema.Schema.Type<typeof LayoutAction.Open.fields.input> =>
|
|
243
|
+
Schema.is(LayoutAction.Open.fields.input)(data),
|
|
244
244
|
resolve: ({ subject, options }) =>
|
|
245
245
|
Effect.gen(function* () {
|
|
246
246
|
const { graph } = context.requestCapability(Capabilities.AppGraph);
|
|
@@ -301,8 +301,8 @@ export default (context: PluginsContext) =>
|
|
|
301
301
|
}),
|
|
302
302
|
createResolver({
|
|
303
303
|
intent: LayoutAction.UpdateLayout,
|
|
304
|
-
filter: (data): data is
|
|
305
|
-
|
|
304
|
+
filter: (data): data is Schema.Schema.Type<typeof LayoutAction.Close.fields.input> =>
|
|
305
|
+
Schema.is(LayoutAction.Close.fields.input)(data),
|
|
306
306
|
resolve: ({ subject }) => {
|
|
307
307
|
const state = context.requestCapability(DeckCapabilities.MutableDeckState);
|
|
308
308
|
const attention = context.requestCapability(AttentionCapabilities.Attention);
|
|
@@ -324,8 +324,8 @@ export default (context: PluginsContext) =>
|
|
|
324
324
|
}),
|
|
325
325
|
createResolver({
|
|
326
326
|
intent: LayoutAction.UpdateLayout,
|
|
327
|
-
filter: (data): data is
|
|
328
|
-
|
|
327
|
+
filter: (data): data is Schema.Schema.Type<typeof LayoutAction.Set.fields.input> =>
|
|
328
|
+
Schema.is(LayoutAction.Set.fields.input)(data),
|
|
329
329
|
resolve: ({ subject }) => {
|
|
330
330
|
const state = context.requestCapability(DeckCapabilities.MutableDeckState);
|
|
331
331
|
const attention = context.requestCapability(AttentionCapabilities.Attention);
|
|
@@ -337,8 +337,8 @@ export default (context: PluginsContext) =>
|
|
|
337
337
|
}),
|
|
338
338
|
createResolver({
|
|
339
339
|
intent: LayoutAction.UpdateLayout,
|
|
340
|
-
filter: (data): data is
|
|
341
|
-
|
|
340
|
+
filter: (data): data is Schema.Schema.Type<typeof LayoutAction.ScrollIntoView.fields.input> =>
|
|
341
|
+
Schema.is(LayoutAction.ScrollIntoView.fields.input)(data),
|
|
342
342
|
resolve: ({ subject }) => {
|
|
343
343
|
const layout = context.requestCapability(DeckCapabilities.MutableDeckState);
|
|
344
344
|
layout.scrollIntoView = subject;
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { Schema } from 'effect';
|
|
6
|
+
|
|
5
7
|
import {
|
|
6
8
|
contributes,
|
|
7
9
|
createIntent,
|
|
@@ -10,7 +12,6 @@ import {
|
|
|
10
12
|
type PromiseIntentDispatcher,
|
|
11
13
|
} from '@dxos/app-framework';
|
|
12
14
|
import { defineTool, ToolResult } from '@dxos/artifact';
|
|
13
|
-
import { S } from '@dxos/echo-schema';
|
|
14
15
|
import { invariant } from '@dxos/invariant';
|
|
15
16
|
|
|
16
17
|
import { meta } from '../meta';
|
|
@@ -35,8 +36,8 @@ export default () =>
|
|
|
35
36
|
`,
|
|
36
37
|
caption: 'Showing item...',
|
|
37
38
|
// TODO(wittjosiah): Refactor Layout/Navigation/Deck actions so that they can be used directly.
|
|
38
|
-
schema:
|
|
39
|
-
id:
|
|
39
|
+
schema: Schema.Struct({
|
|
40
|
+
id: Schema.String.annotations({
|
|
40
41
|
description: 'The ID of the item to show.',
|
|
41
42
|
}),
|
|
42
43
|
}),
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { createContext } from '@radix-ui/react-context';
|
|
6
|
-
import React, { type PropsWithChildren, useCallback, useEffect, useRef, useState } from 'react';
|
|
6
|
+
import React, { type PropsWithChildren, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
7
7
|
|
|
8
8
|
import { Surface, useCapability } from '@dxos/app-framework';
|
|
9
9
|
import { Popover, type PopoverContentInteractOutsideEvent } from '@dxos/react-ui';
|
|
@@ -45,7 +45,7 @@ export const PopoverRoot = ({ children }: DeckPopoverRootProps) => {
|
|
|
45
45
|
|
|
46
46
|
return (
|
|
47
47
|
<DeckPopoverProvider setOpen={setOpen}>
|
|
48
|
-
<Popover.Root modal open={open}>
|
|
48
|
+
<Popover.Root modal={false} open={open}>
|
|
49
49
|
{layout.popoverAnchor && <Popover.VirtualTrigger key={virtualIter} virtualRef={virtualRef} />}
|
|
50
50
|
{children}
|
|
51
51
|
</Popover.Root>
|
|
@@ -76,9 +76,24 @@ export const PopoverContent = () => {
|
|
|
76
76
|
[setOpen],
|
|
77
77
|
);
|
|
78
78
|
|
|
79
|
+
const collisionBoundaries: HTMLElement[] = useMemo(() => {
|
|
80
|
+
const closest = layout.popoverAnchor?.closest('[data-popover-collision-boundary]') as
|
|
81
|
+
| HTMLElement
|
|
82
|
+
| null
|
|
83
|
+
| undefined;
|
|
84
|
+
return closest ? [closest] : [];
|
|
85
|
+
}, [layout.popoverAnchor]);
|
|
86
|
+
|
|
79
87
|
return (
|
|
80
88
|
<Popover.Portal>
|
|
81
|
-
<Popover.Content
|
|
89
|
+
<Popover.Content
|
|
90
|
+
side={layout.popoverSide}
|
|
91
|
+
onInteractOutside={handleClose}
|
|
92
|
+
onEscapeKeyDown={handleClose}
|
|
93
|
+
collisionBoundary={collisionBoundaries}
|
|
94
|
+
sticky='always'
|
|
95
|
+
hideWhenDetached
|
|
96
|
+
>
|
|
82
97
|
<Popover.Viewport>
|
|
83
98
|
<Surface role='popover' data={layout.popoverContent} limit={1} />
|
|
84
99
|
</Popover.Viewport>
|
|
@@ -116,7 +116,7 @@ const PlankImpl = memo(
|
|
|
116
116
|
path,
|
|
117
117
|
popoverAnchorId,
|
|
118
118
|
},
|
|
119
|
-
[node, node?.data, path, popoverAnchorId, primary?.data],
|
|
119
|
+
[node, node?.data, path, popoverAnchorId, primary?.data, variant],
|
|
120
120
|
);
|
|
121
121
|
|
|
122
122
|
// TODO(wittjosiah): Change prop to accept a component.
|
|
@@ -131,6 +131,8 @@ const PlankImpl = memo(
|
|
|
131
131
|
part === 'deck' && (companioned === 'companion' ? '!border-separator border-ie' : '!border-separator border-li'),
|
|
132
132
|
part.startsWith('solo-') && 'row-span-2 grid-rows-subgrid min-is-0',
|
|
133
133
|
part === 'solo-companion' && '!border-separator border-is',
|
|
134
|
+
layoutMode === 'solo--fullscreen' &&
|
|
135
|
+
'!transition-[margin-block-start,inline-size] -mbs-[--rail-action] has-[[data-plank-heading]:hover]:mbs-0',
|
|
134
136
|
);
|
|
135
137
|
|
|
136
138
|
return (
|
|
@@ -145,7 +145,10 @@ export const PlankHeading = memo(
|
|
|
145
145
|
classNames={[
|
|
146
146
|
'plb-1 border-be border-separator items-stretch gap-1 sticky inline-start-12 app-drag min-is-0 contain-layout',
|
|
147
147
|
part === 'solo' ? soloInlinePadding : 'pli-1',
|
|
148
|
+
layoutMode === 'solo--fullscreen' &&
|
|
149
|
+
'opacity-0 border-transparent hover:border-separator hover:opacity-100 transition-[border-color,opacity]',
|
|
148
150
|
]}
|
|
151
|
+
data-plank-heading
|
|
149
152
|
>
|
|
150
153
|
{companions && isCompanionNode ? (
|
|
151
154
|
<div role='none' className='flex-1 min-is-0 overflow-x-auto scrollbar-thin flex gap-1'>
|
package/src/types.ts
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { Schema } from 'effect';
|
|
6
|
+
|
|
5
7
|
import { LayoutAction } from '@dxos/app-framework';
|
|
6
|
-
import { S } from '@dxos/echo-schema';
|
|
7
8
|
import { type DeepReadonly } from '@dxos/util';
|
|
8
9
|
|
|
9
10
|
import { DECK_PLUGIN } from './meta';
|
|
@@ -23,33 +24,33 @@ export type Overscroll = (typeof OverscrollOptions)[number];
|
|
|
23
24
|
export type Part = 'solo' | 'deck' | 'complementary';
|
|
24
25
|
export type ResolvedPart = Part | 'solo-primary' | 'solo-companion';
|
|
25
26
|
|
|
26
|
-
export const DeckSettingsSchema =
|
|
27
|
-
showHints:
|
|
28
|
-
enableDeck:
|
|
29
|
-
enableNativeRedirect:
|
|
30
|
-
enableStatusbar:
|
|
31
|
-
newPlankPositioning:
|
|
32
|
-
overscroll:
|
|
33
|
-
}).pipe(
|
|
34
|
-
export type DeckSettingsProps =
|
|
27
|
+
export const DeckSettingsSchema = Schema.Struct({
|
|
28
|
+
showHints: Schema.optional(Schema.Boolean),
|
|
29
|
+
enableDeck: Schema.optional(Schema.Boolean),
|
|
30
|
+
enableNativeRedirect: Schema.optional(Schema.Boolean),
|
|
31
|
+
enableStatusbar: Schema.optional(Schema.Boolean),
|
|
32
|
+
newPlankPositioning: Schema.optional(Schema.Literal(...NewPlankPositions)),
|
|
33
|
+
overscroll: Schema.optional(Schema.Literal(...OverscrollOptions)),
|
|
34
|
+
}).pipe(Schema.mutable);
|
|
35
|
+
export type DeckSettingsProps = Schema.Schema.Type<typeof DeckSettingsSchema>;
|
|
35
36
|
|
|
36
|
-
export const PlankSizing =
|
|
37
|
-
export type PlankSizing =
|
|
37
|
+
export const PlankSizing = Schema.Record({ key: Schema.String, value: Schema.Number });
|
|
38
|
+
export type PlankSizing = Schema.Schema.Type<typeof PlankSizing>;
|
|
38
39
|
|
|
39
40
|
// State of an individual deck.
|
|
40
|
-
export const DeckState =
|
|
41
|
+
export const DeckState = Schema.Struct({
|
|
41
42
|
/** If false, the deck has not yet left solo mode and new planks should be soloed. */
|
|
42
|
-
initialized:
|
|
43
|
-
active:
|
|
43
|
+
initialized: Schema.Boolean,
|
|
44
|
+
active: Schema.mutable(Schema.Array(Schema.String)),
|
|
44
45
|
// TODO(wittjosiah): Piping into both mutable and optional caused invalid typescript output.
|
|
45
|
-
activeCompanions:
|
|
46
|
-
inactive:
|
|
47
|
-
solo:
|
|
48
|
-
fullscreen:
|
|
49
|
-
plankSizing:
|
|
50
|
-
companionFrameSizing:
|
|
46
|
+
activeCompanions: Schema.optional(Schema.mutable(Schema.Record({ key: Schema.String, value: Schema.String }))),
|
|
47
|
+
inactive: Schema.mutable(Schema.Array(Schema.String)),
|
|
48
|
+
solo: Schema.optional(Schema.String),
|
|
49
|
+
fullscreen: Schema.Boolean,
|
|
50
|
+
plankSizing: Schema.mutable(PlankSizing),
|
|
51
|
+
companionFrameSizing: Schema.mutable(PlankSizing),
|
|
51
52
|
});
|
|
52
|
-
export type DeckState =
|
|
53
|
+
export type DeckState = Schema.Schema.Type<typeof DeckState>;
|
|
53
54
|
|
|
54
55
|
export const defaultDeck: DeckState = {
|
|
55
56
|
initialized: false,
|
|
@@ -62,9 +63,9 @@ export const defaultDeck: DeckState = {
|
|
|
62
63
|
companionFrameSizing: {},
|
|
63
64
|
};
|
|
64
65
|
|
|
65
|
-
const LayoutMode =
|
|
66
|
-
export type LayoutMode =
|
|
67
|
-
export const isLayoutMode = (value: any): value is LayoutMode =>
|
|
66
|
+
const LayoutMode = Schema.Literal('deck', 'solo', 'solo--fullscreen');
|
|
67
|
+
export type LayoutMode = Schema.Schema.Type<typeof LayoutMode>;
|
|
68
|
+
export const isLayoutMode = (value: any): value is LayoutMode => Schema.is(LayoutMode)(value);
|
|
68
69
|
|
|
69
70
|
export const getMode = (deck: DeckState | DeepReadonly<DeckState>): LayoutMode => {
|
|
70
71
|
if (deck.solo) {
|
|
@@ -75,73 +76,73 @@ export const getMode = (deck: DeckState | DeepReadonly<DeckState>): LayoutMode =
|
|
|
75
76
|
};
|
|
76
77
|
|
|
77
78
|
// State of the deck plugin.
|
|
78
|
-
export const DeckPluginState =
|
|
79
|
-
sidebarState:
|
|
80
|
-
complementarySidebarState:
|
|
81
|
-
complementarySidebarPanel:
|
|
82
|
-
|
|
83
|
-
dialogOpen:
|
|
84
|
-
dialogBlockAlign:
|
|
85
|
-
dialogType:
|
|
79
|
+
export const DeckPluginState = Schema.Struct({
|
|
80
|
+
sidebarState: Schema.Literal('closed', 'collapsed', 'expanded'),
|
|
81
|
+
complementarySidebarState: Schema.Literal('closed', 'collapsed', 'expanded'),
|
|
82
|
+
complementarySidebarPanel: Schema.optional(Schema.String),
|
|
83
|
+
|
|
84
|
+
dialogOpen: Schema.Boolean,
|
|
85
|
+
dialogBlockAlign: Schema.optional(Schema.Literal('start', 'center', 'end')),
|
|
86
|
+
dialogType: Schema.optional(Schema.Literal('default', 'alert')),
|
|
86
87
|
/** Data to be passed to the dialog Surface. */
|
|
87
|
-
dialogContent:
|
|
88
|
+
dialogContent: Schema.optional(Schema.Any),
|
|
88
89
|
|
|
89
|
-
popoverOpen:
|
|
90
|
-
popoverSide:
|
|
91
|
-
popoverAnchor:
|
|
92
|
-
popoverAnchorId:
|
|
90
|
+
popoverOpen: Schema.Boolean,
|
|
91
|
+
popoverSide: Schema.optional(Schema.Literal('top', 'right', 'bottom', 'left')),
|
|
92
|
+
popoverAnchor: Schema.optional(Schema.Any),
|
|
93
|
+
popoverAnchorId: Schema.optional(Schema.String),
|
|
93
94
|
/** Data to be passed to the popover Surface. */
|
|
94
|
-
popoverContent:
|
|
95
|
+
popoverContent: Schema.optional(Schema.Any),
|
|
95
96
|
|
|
96
|
-
toasts:
|
|
97
|
-
currentUndoId:
|
|
97
|
+
toasts: Schema.mutable(Schema.Array(LayoutAction.Toast)),
|
|
98
|
+
currentUndoId: Schema.optional(Schema.String),
|
|
98
99
|
|
|
99
|
-
activeDeck:
|
|
100
|
-
previousDeck:
|
|
101
|
-
decks:
|
|
102
|
-
previousMode:
|
|
103
|
-
deck:
|
|
100
|
+
activeDeck: Schema.String,
|
|
101
|
+
previousDeck: Schema.String,
|
|
102
|
+
decks: Schema.mutable(Schema.Record({ key: Schema.String, value: Schema.mutable(DeckState) })),
|
|
103
|
+
previousMode: Schema.mutable(Schema.Record({ key: Schema.String, value: LayoutMode })),
|
|
104
|
+
deck: Schema.mutable(DeckState),
|
|
104
105
|
|
|
105
106
|
/** The identifier of a component to scroll into view when it is mounted. */
|
|
106
|
-
scrollIntoView:
|
|
107
|
-
}).pipe(
|
|
107
|
+
scrollIntoView: Schema.optional(Schema.String),
|
|
108
|
+
}).pipe(Schema.mutable);
|
|
108
109
|
|
|
109
|
-
export type DeckPluginState =
|
|
110
|
+
export type DeckPluginState = Schema.Schema.Type<typeof DeckPluginState>;
|
|
110
111
|
|
|
111
112
|
export const DECK_ACTION = `${DECK_PLUGIN}/action`;
|
|
112
113
|
|
|
113
114
|
export namespace DeckAction {
|
|
114
|
-
const PartAdjustmentSchema =
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
115
|
+
const PartAdjustmentSchema = Schema.Union(
|
|
116
|
+
Schema.Literal('close').annotations({ description: 'Close the plank.' }),
|
|
117
|
+
Schema.Literal('companion').annotations({ description: 'Open the companion plank.' }),
|
|
118
|
+
Schema.Literal('solo').annotations({ description: 'Solo the plank.' }),
|
|
119
|
+
Schema.Literal('solo--fullscreen').annotations({ description: 'Fullscreen the plank.' }),
|
|
120
|
+
Schema.Literal('increment-start').annotations({ description: 'Move the plank towards the start of the deck.' }),
|
|
121
|
+
Schema.Literal('increment-end').annotations({ description: 'Move the plank towards the end of the deck.' }),
|
|
121
122
|
);
|
|
122
|
-
export type PartAdjustment =
|
|
123
|
-
export const Adjustment =
|
|
124
|
-
export type Adjustment =
|
|
123
|
+
export type PartAdjustment = Schema.Schema.Type<typeof PartAdjustmentSchema>;
|
|
124
|
+
export const Adjustment = Schema.mutable(Schema.Struct({ id: Schema.String, type: PartAdjustmentSchema }));
|
|
125
|
+
export type Adjustment = Schema.Schema.Type<typeof Adjustment>;
|
|
125
126
|
|
|
126
127
|
// An atomic transaction to apply to the deck, describing which element to move to which location.
|
|
127
|
-
export class Adjust extends
|
|
128
|
+
export class Adjust extends Schema.TaggedClass<Adjust>()(`${DECK_ACTION}/adjust`, {
|
|
128
129
|
input: Adjustment,
|
|
129
|
-
output:
|
|
130
|
+
output: Schema.Void,
|
|
130
131
|
}) {}
|
|
131
132
|
|
|
132
|
-
export class UpdatePlankSize extends
|
|
133
|
-
input:
|
|
134
|
-
id:
|
|
135
|
-
size:
|
|
133
|
+
export class UpdatePlankSize extends Schema.TaggedClass<UpdatePlankSize>()(`${DECK_ACTION}/update-plank-size`, {
|
|
134
|
+
input: Schema.Struct({
|
|
135
|
+
id: Schema.String,
|
|
136
|
+
size: Schema.Number,
|
|
136
137
|
}),
|
|
137
|
-
output:
|
|
138
|
+
output: Schema.Void,
|
|
138
139
|
}) {}
|
|
139
140
|
|
|
140
|
-
export class ChangeCompanion extends
|
|
141
|
-
input:
|
|
142
|
-
primary:
|
|
143
|
-
companion:
|
|
141
|
+
export class ChangeCompanion extends Schema.TaggedClass<ChangeCompanion>()(`${DECK_ACTION}/change-companion`, {
|
|
142
|
+
input: Schema.Struct({
|
|
143
|
+
primary: Schema.String,
|
|
144
|
+
companion: Schema.Union(Schema.String, Schema.Null),
|
|
144
145
|
}),
|
|
145
|
-
output:
|
|
146
|
+
output: Schema.Void,
|
|
146
147
|
}) {}
|
|
147
148
|
}
|