@dxos/react-ui-attention 0.8.4-main.84f28bd → 0.8.4-main.c1de068
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-QPEFFJ4E.mjs → chunk-3K54PTHR.mjs} +48 -14
- package/dist/lib/browser/{chunk-QPEFFJ4E.mjs.map → chunk-3K54PTHR.mjs.map} +3 -3
- package/dist/lib/browser/index.mjs +3 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +2 -4
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/{chunk-F2JRKDYV.mjs → chunk-LVRGGYEI.mjs} +48 -14
- package/dist/lib/node-esm/{chunk-F2JRKDYV.mjs.map → chunk-LVRGGYEI.mjs.map} +3 -3
- package/dist/lib/node-esm/index.mjs +3 -1
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +2 -4
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/types/src/selection.d.ts +26 -14
- package/dist/types/src/selection.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -13
- package/src/selection.ts +44 -15
- package/src/testing/decorators/withAttention.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-attention",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.c1de068",
|
|
4
4
|
"description": "Signifier components and providers for attention system.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -42,12 +42,12 @@
|
|
|
42
42
|
"@radix-ui/react-primitive": "2.0.2",
|
|
43
43
|
"@radix-ui/react-slot": "1.1.2",
|
|
44
44
|
"@radix-ui/react-use-controllable-state": "1.1.0",
|
|
45
|
-
"effect": "3.
|
|
46
|
-
"@dxos/echo-schema": "0.8.4-main.
|
|
47
|
-
"@dxos/invariant": "0.8.4-main.
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/
|
|
45
|
+
"effect": "3.17.0",
|
|
46
|
+
"@dxos/echo-schema": "0.8.4-main.c1de068",
|
|
47
|
+
"@dxos/invariant": "0.8.4-main.c1de068",
|
|
48
|
+
"@dxos/log": "0.8.4-main.c1de068",
|
|
49
|
+
"@dxos/util": "0.8.4-main.c1de068",
|
|
50
|
+
"@dxos/live-object": "0.8.4-main.c1de068"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/react": "~18.2.0",
|
|
@@ -55,17 +55,17 @@
|
|
|
55
55
|
"react": "~18.2.0",
|
|
56
56
|
"react-dom": "~18.2.0",
|
|
57
57
|
"vite": "5.4.7",
|
|
58
|
-
"@dxos/random": "0.8.4-main.
|
|
59
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
60
|
-
"@dxos/react-ui-theme": "0.8.4-main.
|
|
61
|
-
"@dxos/storybook-utils": "0.8.4-main.
|
|
58
|
+
"@dxos/random": "0.8.4-main.c1de068",
|
|
59
|
+
"@dxos/react-ui": "0.8.4-main.c1de068",
|
|
60
|
+
"@dxos/react-ui-theme": "0.8.4-main.c1de068",
|
|
61
|
+
"@dxos/storybook-utils": "0.8.4-main.c1de068"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
64
|
"effect": "^3.13.3",
|
|
65
65
|
"react": "~18.2.0",
|
|
66
66
|
"react-dom": "~18.2.0",
|
|
67
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
68
|
-
"@dxos/react-ui-theme": "0.8.4-main.
|
|
67
|
+
"@dxos/react-ui": "0.8.4-main.c1de068",
|
|
68
|
+
"@dxos/react-ui-theme": "0.8.4-main.c1de068"
|
|
69
69
|
},
|
|
70
70
|
"publishConfig": {
|
|
71
71
|
"access": "public"
|
package/src/selection.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { untracked } from '@preact/signals-core';
|
|
6
|
-
import { Match } from 'effect';
|
|
6
|
+
import { Match, Schema } from 'effect';
|
|
7
7
|
|
|
8
8
|
import { invariant } from '@dxos/invariant';
|
|
9
9
|
import { live, type Live } from '@dxos/live-object';
|
|
@@ -12,17 +12,30 @@ import { live, type Live } from '@dxos/live-object';
|
|
|
12
12
|
|
|
13
13
|
export type SelectionMode = 'single' | 'multi' | 'range' | 'multi-range';
|
|
14
14
|
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
export const SelectionSchema = Schema.Union(
|
|
16
|
+
Schema.Struct({ mode: Schema.Literal('single'), id: Schema.optional(Schema.String) }).pipe(Schema.mutable),
|
|
17
|
+
Schema.Struct({ mode: Schema.Literal('multi'), ids: Schema.Array(Schema.String).pipe(Schema.mutable) }).pipe(
|
|
18
|
+
Schema.mutable,
|
|
19
|
+
),
|
|
20
|
+
Schema.Struct({
|
|
21
|
+
mode: Schema.Literal('range'),
|
|
22
|
+
from: Schema.optional(Schema.String),
|
|
23
|
+
to: Schema.optional(Schema.String),
|
|
24
|
+
}).pipe(Schema.mutable),
|
|
25
|
+
Schema.Struct({
|
|
26
|
+
mode: Schema.Literal('multi-range'),
|
|
27
|
+
ranges: Schema.Array(Schema.Struct({ from: Schema.String, to: Schema.String })).pipe(Schema.mutable),
|
|
28
|
+
}).pipe(Schema.mutable),
|
|
29
|
+
).pipe(Schema.mutable);
|
|
30
|
+
|
|
31
|
+
export type Selection = Schema.Schema.Type<typeof SelectionSchema>;
|
|
20
32
|
|
|
21
33
|
export const defaultSelection = Match.type<SelectionMode>().pipe(
|
|
22
|
-
Match.
|
|
23
|
-
Match.when('
|
|
24
|
-
Match.when('
|
|
25
|
-
Match.when('
|
|
34
|
+
Match.withReturnType<Selection>(),
|
|
35
|
+
Match.when('single', () => ({ mode: 'single' })),
|
|
36
|
+
Match.when('multi', () => ({ mode: 'multi', ids: [] })),
|
|
37
|
+
Match.when('range', () => ({ mode: 'range' })),
|
|
38
|
+
Match.when('multi-range', () => ({ mode: 'multi-range', ranges: [] })),
|
|
26
39
|
Match.exhaustive,
|
|
27
40
|
);
|
|
28
41
|
|
|
@@ -110,7 +123,7 @@ export class SelectionManager {
|
|
|
110
123
|
untracked(() => {
|
|
111
124
|
const selection = this.getSelection(contextId, 'multi');
|
|
112
125
|
invariant(selection?.mode === 'multi', 'Selection mode is not multi');
|
|
113
|
-
selection.ids
|
|
126
|
+
selection.ids.splice(0, selection.ids.length, ...ids);
|
|
114
127
|
});
|
|
115
128
|
}
|
|
116
129
|
|
|
@@ -127,16 +140,32 @@ export class SelectionManager {
|
|
|
127
140
|
untracked(() => {
|
|
128
141
|
const selection = this.getSelection(contextId, 'multi-range');
|
|
129
142
|
invariant(selection?.mode === 'multi-range', 'Selection mode is not multi-range');
|
|
130
|
-
selection.ranges
|
|
143
|
+
selection.ranges.splice(0, selection.ranges.length, ...ranges);
|
|
131
144
|
});
|
|
132
145
|
}
|
|
133
146
|
|
|
134
147
|
clearSelection(contextId: string): void {
|
|
135
148
|
untracked(() => {
|
|
136
149
|
const selection = this.getSelection(contextId);
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
150
|
+
Match.type<Selection | undefined>().pipe(
|
|
151
|
+
Match.when(undefined, () => {
|
|
152
|
+
// No-op.
|
|
153
|
+
}),
|
|
154
|
+
Match.when({ mode: 'single' }, (s) => {
|
|
155
|
+
s.id = undefined;
|
|
156
|
+
}),
|
|
157
|
+
Match.when({ mode: 'multi' }, (s) => {
|
|
158
|
+
s.ids.splice(0, s.ids.length);
|
|
159
|
+
}),
|
|
160
|
+
Match.when({ mode: 'range' }, (s) => {
|
|
161
|
+
s.from = undefined;
|
|
162
|
+
s.to = undefined;
|
|
163
|
+
}),
|
|
164
|
+
Match.when({ mode: 'multi-range' }, (s) => {
|
|
165
|
+
s.ranges.splice(0, s.ranges.length);
|
|
166
|
+
}),
|
|
167
|
+
Match.exhaustive,
|
|
168
|
+
)(selection);
|
|
140
169
|
});
|
|
141
170
|
}
|
|
142
171
|
|
|
@@ -8,5 +8,5 @@ import { createElement } from 'react';
|
|
|
8
8
|
import { RootAttentionProvider } from '../../components';
|
|
9
9
|
|
|
10
10
|
export const withAttention: Decorator = (Story) => {
|
|
11
|
-
return createElement(RootAttentionProvider, {
|
|
11
|
+
return createElement(RootAttentionProvider, {}, createElement(Story));
|
|
12
12
|
};
|