@abraca/nuxt 2.83.0 → 2.85.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/dist/module.json +1 -1
- package/dist/runtime/components/ANodePanel.vue +4 -0
- package/dist/runtime/components/aware/AAccordion.vue +16 -6
- package/dist/runtime/components/aware/ACollapsible.vue +14 -6
- package/dist/runtime/components/aware/AFollowBar.vue +7 -3
- package/dist/runtime/components/aware/AGlobalFocusLayer.d.vue.ts +7 -1
- package/dist/runtime/components/aware/AGlobalFocusLayer.vue +13 -2
- package/dist/runtime/components/aware/AGlobalFocusLayer.vue.d.ts +7 -1
- package/dist/runtime/components/aware/AMedia.d.vue.ts +1 -1
- package/dist/runtime/components/aware/AMedia.vue.d.ts +1 -1
- package/dist/runtime/components/aware/AModal.vue +14 -6
- package/dist/runtime/components/aware/AScroll.vue +11 -3
- package/dist/runtime/components/aware/ASlideover.vue +14 -6
- package/dist/runtime/components/aware/ATabs.vue +14 -4
- package/dist/runtime/components/chat/AChatPanel.d.vue.ts +10 -0
- package/dist/runtime/components/chat/AChatPanel.vue +2 -0
- package/dist/runtime/components/chat/AChatPanel.vue.d.ts +10 -0
- package/dist/runtime/components/chat/ANodeChatPanel.d.vue.ts +3 -0
- package/dist/runtime/components/chat/ANodeChatPanel.vue +2 -0
- package/dist/runtime/components/chat/ANodeChatPanel.vue.d.ts +3 -0
- package/dist/runtime/components/editor/AMetaChip.d.vue.ts +1 -1
- package/dist/runtime/components/editor/AMetaChip.vue +40 -1
- package/dist/runtime/components/editor/AMetaChip.vue.d.ts +1 -1
- package/dist/runtime/composables/useAAFocus.d.ts +19 -1
- package/dist/runtime/composables/useAAFocus.js +24 -13
- package/dist/runtime/composables/useAAFollowPeer.d.ts +22 -0
- package/dist/runtime/composables/useAAFollowPeer.js +12 -2
- package/dist/runtime/composables/useAAFollowShare.d.ts +64 -0
- package/dist/runtime/composables/useAAFollowShare.js +30 -0
- package/package.json +4 -4
package/dist/module.json
CHANGED
|
@@ -443,10 +443,14 @@ const addFieldMenuItems = computed(
|
|
|
443
443
|
v-show="activeTab === 'chat'"
|
|
444
444
|
class="flex flex-col flex-1 min-h-0"
|
|
445
445
|
>
|
|
446
|
+
<!-- `:closable="false"` — this panel's own header already carries a
|
|
447
|
+
close and an expand, so the chat header put a SECOND X directly
|
|
448
|
+
beneath the first, both closing the same slideover. -->
|
|
446
449
|
<ANodeChatPanel
|
|
447
450
|
v-if="nodeId"
|
|
448
451
|
:doc-id="nodeId"
|
|
449
452
|
:label="resolvedLabel || 'Chat'"
|
|
453
|
+
:closable="false"
|
|
450
454
|
class="flex-1 min-h-0"
|
|
451
455
|
/>
|
|
452
456
|
</div>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { computed, ref, useAttrs, watch } from "vue";
|
|
3
3
|
import { useAAField } from "../../composables/useAAField";
|
|
4
4
|
import { useAAUIState } from "../../composables/useAAUIState";
|
|
5
|
-
import {
|
|
5
|
+
import { useAAFollowShare } from "../../composables/useAAFollowShare";
|
|
6
6
|
import AHoverItem from "./AHoverItem.vue";
|
|
7
7
|
function itemId(item) {
|
|
8
8
|
if (item == null) return "";
|
|
@@ -22,9 +22,13 @@ const props = defineProps({
|
|
|
22
22
|
followOnly: { type: Boolean, required: false, default: false },
|
|
23
23
|
total: { type: Boolean, required: false, default: false }
|
|
24
24
|
});
|
|
25
|
-
const { isFollowing } = useAAFollowPeer();
|
|
26
25
|
const enableAwareness = computed(() => props.awareness || props.total);
|
|
27
|
-
const enableLive = computed(() => props.live || props.total
|
|
26
|
+
const enableLive = computed(() => props.live || props.total);
|
|
27
|
+
const follow = useAAFollowShare(
|
|
28
|
+
() => `${props.fieldKey}:expanded`,
|
|
29
|
+
{ enabled: () => props.followOnly }
|
|
30
|
+
);
|
|
31
|
+
const controlled = computed(() => enableLive.value || props.followOnly);
|
|
28
32
|
const attrs = useAttrs();
|
|
29
33
|
const { hoverers, focusers, hoverHandlers } = useAAField(() => props.fieldKey);
|
|
30
34
|
const liveExpanded = useAAUIState(() => `${props.fieldKey}:expanded`, { defaultValue: "" });
|
|
@@ -37,8 +41,10 @@ watch(liveExpanded, (val) => {
|
|
|
37
41
|
if (JSON.stringify(local.value) !== JSON.stringify(val)) local.value = val ?? "";
|
|
38
42
|
});
|
|
39
43
|
watch(local, (val) => {
|
|
40
|
-
if (
|
|
41
|
-
|
|
44
|
+
if (enableLive.value && JSON.stringify(liveExpanded.value) !== JSON.stringify(val)) {
|
|
45
|
+
liveExpanded.value = val;
|
|
46
|
+
}
|
|
47
|
+
follow.publish(val ?? "");
|
|
42
48
|
});
|
|
43
49
|
watch(enableLive, (now, prev) => {
|
|
44
50
|
if (!now || prev) return;
|
|
@@ -47,6 +53,10 @@ watch(enableLive, (now, prev) => {
|
|
|
47
53
|
local.value = incoming;
|
|
48
54
|
}
|
|
49
55
|
});
|
|
56
|
+
watch(() => follow.leaderValue.value, (val) => {
|
|
57
|
+
if (!follow.adopting.value || val === void 0) return;
|
|
58
|
+
if (JSON.stringify(local.value) !== JSON.stringify(val)) local.value = val;
|
|
59
|
+
}, { deep: true });
|
|
50
60
|
const ringStyle = computed(() => {
|
|
51
61
|
if (!enableAwareness.value) return void 0;
|
|
52
62
|
const focusColor = focusers.value[0]?.user?.color;
|
|
@@ -71,7 +81,7 @@ const eventHandlers = computed(() => enableAwareness.value ? hoverHandlers : {})
|
|
|
71
81
|
v-on="eventHandlers"
|
|
72
82
|
>
|
|
73
83
|
<UAccordion
|
|
74
|
-
v-if="
|
|
84
|
+
v-if="controlled && !hasExternalModel"
|
|
75
85
|
v-model="local"
|
|
76
86
|
v-bind="attrs"
|
|
77
87
|
>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { computed, ref, useAttrs, watch } from "vue";
|
|
3
3
|
import { useAAUIState } from "../../composables/useAAUIState";
|
|
4
|
-
import {
|
|
4
|
+
import { useAAFollowShare } from "../../composables/useAAFollowShare";
|
|
5
5
|
defineOptions({ inheritAttrs: false });
|
|
6
6
|
const props = defineProps({
|
|
7
7
|
fieldKey: { type: String, required: true },
|
|
@@ -10,8 +10,12 @@ const props = defineProps({
|
|
|
10
10
|
followOnly: { type: Boolean, required: false, default: false },
|
|
11
11
|
total: { type: Boolean, required: false, default: false }
|
|
12
12
|
});
|
|
13
|
-
const
|
|
14
|
-
const
|
|
13
|
+
const enableLive = computed(() => props.live || props.total);
|
|
14
|
+
const follow = useAAFollowShare(
|
|
15
|
+
() => `${props.fieldKey}:open`,
|
|
16
|
+
{ enabled: () => props.followOnly }
|
|
17
|
+
);
|
|
18
|
+
const controlled = computed(() => enableLive.value || props.followOnly);
|
|
15
19
|
const attrs = useAttrs();
|
|
16
20
|
const liveOpen = useAAUIState(() => `${props.fieldKey}:open`, { defaultValue: false });
|
|
17
21
|
const hasExternalOpen = computed(() => "open" in attrs || "onUpdate:open" in attrs);
|
|
@@ -22,19 +26,23 @@ watch(liveOpen, (val) => {
|
|
|
22
26
|
if (local.value !== next) local.value = next;
|
|
23
27
|
});
|
|
24
28
|
watch(local, (val) => {
|
|
25
|
-
if (
|
|
26
|
-
|
|
29
|
+
if (enableLive.value && !!liveOpen.value !== val) liveOpen.value = val;
|
|
30
|
+
follow.publish(val);
|
|
27
31
|
});
|
|
28
32
|
watch(enableLive, (now, prev) => {
|
|
29
33
|
if (!now || prev) return;
|
|
30
34
|
const incoming = !!liveOpen.value;
|
|
31
35
|
if (local.value !== incoming) local.value = incoming;
|
|
32
36
|
});
|
|
37
|
+
watch(() => follow.leaderValue.value, (val) => {
|
|
38
|
+
if (!follow.adopting.value || val === void 0) return;
|
|
39
|
+
if (local.value !== !!val) local.value = !!val;
|
|
40
|
+
});
|
|
33
41
|
</script>
|
|
34
42
|
|
|
35
43
|
<template>
|
|
36
44
|
<UCollapsible
|
|
37
|
-
v-if="
|
|
45
|
+
v-if="controlled && !hasExternalOpen"
|
|
38
46
|
v-model:open="local"
|
|
39
47
|
v-bind="attrs"
|
|
40
48
|
>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { computed, watch } from "vue";
|
|
2
|
+
import { computed, ref, watch } from "vue";
|
|
3
3
|
import { useRoute, useRouter } from "#imports";
|
|
4
4
|
import { useAAFollowPeer } from "../../composables/useAAFollowPeer";
|
|
5
5
|
import { useAwareness } from "../../composables/useAwareness";
|
|
@@ -12,7 +12,11 @@ const route = useRoute();
|
|
|
12
12
|
const router = useRouter();
|
|
13
13
|
const { setField, states } = useAwareness();
|
|
14
14
|
const { peers } = useAwarenessPeers();
|
|
15
|
-
const
|
|
15
|
+
const barEl = ref(null);
|
|
16
|
+
const { follow, unfollow, followingClientId, followingUser } = useAAFollowPeer({
|
|
17
|
+
keyPrefix: props.keyPrefix,
|
|
18
|
+
ignoreWithin: () => [barEl.value]
|
|
19
|
+
});
|
|
16
20
|
watch(() => route.fullPath, (path) => {
|
|
17
21
|
setField("route", path);
|
|
18
22
|
}, { immediate: true });
|
|
@@ -38,7 +42,7 @@ const positionClass = computed(() => `aa-follow-bar--${props.position}`);
|
|
|
38
42
|
</script>
|
|
39
43
|
|
|
40
44
|
<template>
|
|
41
|
-
<div v-if="visiblePeers.length" class="aa-follow-bar" :class="positionClass">
|
|
45
|
+
<div v-if="visiblePeers.length" ref="barEl" class="aa-follow-bar" :class="positionClass">
|
|
42
46
|
<span class="aa-follow-bar__label">{{ followingUser ? `Following ${followingUser.name}` : "Follow" }}</span>
|
|
43
47
|
<button
|
|
44
48
|
v-for="p in visiblePeers"
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
/** Paint only the peer currently being followed. Off = every peer. */
|
|
3
|
+
followOnly?: boolean;
|
|
4
|
+
};
|
|
5
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
6
|
+
followOnly: boolean;
|
|
7
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
2
8
|
declare const _default: typeof __VLS_export;
|
|
3
9
|
export default _default;
|
|
@@ -2,9 +2,20 @@
|
|
|
2
2
|
import { computed, onBeforeUnmount, onMounted, ref } from "vue";
|
|
3
3
|
import { useRoute } from "#imports";
|
|
4
4
|
import { useAAEphemeral } from "../../composables/useAAEphemeral";
|
|
5
|
+
import { useAAFollowPeer } from "../../composables/useAAFollowPeer";
|
|
5
6
|
import { rangeFromPaths } from "../../utils/domPath";
|
|
7
|
+
const props = defineProps({
|
|
8
|
+
followOnly: { type: Boolean, required: false, default: false }
|
|
9
|
+
});
|
|
6
10
|
const { peers } = useAAEphemeral("aa:focus");
|
|
11
|
+
const { followingClientId } = useAAFollowPeer();
|
|
7
12
|
const route = useRoute();
|
|
13
|
+
const visiblePeers = computed(() => {
|
|
14
|
+
if (!props.followOnly) return peers.value;
|
|
15
|
+
const cid = followingClientId.value;
|
|
16
|
+
if (cid == null) return [];
|
|
17
|
+
return peers.value.filter((p) => p.clientId === cid);
|
|
18
|
+
});
|
|
8
19
|
const selections = ref([]);
|
|
9
20
|
let raf = 0;
|
|
10
21
|
let mo = null;
|
|
@@ -12,7 +23,7 @@ function recompute() {
|
|
|
12
23
|
cancelAnimationFrame(raf);
|
|
13
24
|
raf = requestAnimationFrame(() => {
|
|
14
25
|
const out = [];
|
|
15
|
-
for (const p of
|
|
26
|
+
for (const p of visiblePeers.value) {
|
|
16
27
|
const v = p.value;
|
|
17
28
|
if (!v || v.kind !== "selection" || v.route !== route.path || !v.start || !v.end) continue;
|
|
18
29
|
const range = rangeFromPaths(v.start, v.end);
|
|
@@ -44,7 +55,7 @@ onBeforeUnmount(() => {
|
|
|
44
55
|
mo?.disconnect();
|
|
45
56
|
});
|
|
46
57
|
import { watch } from "vue";
|
|
47
|
-
watch(
|
|
58
|
+
watch(visiblePeers, recompute, { deep: true, flush: "post" });
|
|
48
59
|
watch(() => route.path, recompute);
|
|
49
60
|
function tintFor(p) {
|
|
50
61
|
return p.user?.color ?? "#888";
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
/** Paint only the peer currently being followed. Off = every peer. */
|
|
3
|
+
followOnly?: boolean;
|
|
4
|
+
};
|
|
5
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
6
|
+
followOnly: boolean;
|
|
7
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
2
8
|
declare const _default: typeof __VLS_export;
|
|
3
9
|
export default _default;
|
|
@@ -12,8 +12,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
|
|
|
12
12
|
awareness: boolean;
|
|
13
13
|
tag: "video" | "audio";
|
|
14
14
|
live: boolean;
|
|
15
|
-
total: boolean;
|
|
16
15
|
controls: boolean;
|
|
16
|
+
total: boolean;
|
|
17
17
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
18
18
|
declare const _default: typeof __VLS_export;
|
|
19
19
|
export default _default;
|
|
@@ -12,8 +12,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
|
|
|
12
12
|
awareness: boolean;
|
|
13
13
|
tag: "video" | "audio";
|
|
14
14
|
live: boolean;
|
|
15
|
-
total: boolean;
|
|
16
15
|
controls: boolean;
|
|
16
|
+
total: boolean;
|
|
17
17
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
18
18
|
declare const _default: typeof __VLS_export;
|
|
19
19
|
export default _default;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { computed, ref, useAttrs, watch } from "vue";
|
|
3
3
|
import { useAAUIState, useAAUIStateAuthor } from "../../composables/useAAUIState";
|
|
4
|
-
import {
|
|
4
|
+
import { useAAFollowShare } from "../../composables/useAAFollowShare";
|
|
5
5
|
import { useAwareness } from "../../composables/useAwareness";
|
|
6
6
|
defineOptions({ inheritAttrs: false });
|
|
7
7
|
const props = defineProps({
|
|
@@ -11,8 +11,12 @@ const props = defineProps({
|
|
|
11
11
|
followOnly: { type: Boolean, required: false, default: false },
|
|
12
12
|
total: { type: Boolean, required: false, default: false }
|
|
13
13
|
});
|
|
14
|
-
const
|
|
15
|
-
const
|
|
14
|
+
const enableLive = computed(() => props.live || props.total);
|
|
15
|
+
const follow = useAAFollowShare(
|
|
16
|
+
() => `${props.fieldKey}:open`,
|
|
17
|
+
{ enabled: () => props.followOnly }
|
|
18
|
+
);
|
|
19
|
+
const controlled = computed(() => enableLive.value || props.followOnly);
|
|
16
20
|
const attrs = useAttrs();
|
|
17
21
|
const liveOpen = useAAUIState(() => `${props.fieldKey}:open`, { defaultValue: false });
|
|
18
22
|
const author = useAAUIStateAuthor(() => `${props.fieldKey}:open`);
|
|
@@ -25,14 +29,18 @@ watch(liveOpen, (val) => {
|
|
|
25
29
|
if (local.value !== next) local.value = next;
|
|
26
30
|
});
|
|
27
31
|
watch(local, (val) => {
|
|
28
|
-
if (
|
|
29
|
-
|
|
32
|
+
if (enableLive.value && !!liveOpen.value !== val) liveOpen.value = val;
|
|
33
|
+
follow.publish(val);
|
|
30
34
|
});
|
|
31
35
|
watch(enableLive, (now, prev) => {
|
|
32
36
|
if (!now || prev) return;
|
|
33
37
|
const incoming = !!liveOpen.value;
|
|
34
38
|
if (local.value !== incoming) local.value = incoming;
|
|
35
39
|
});
|
|
40
|
+
watch(() => follow.leaderValue.value, (val) => {
|
|
41
|
+
if (!follow.adopting.value || val === void 0) return;
|
|
42
|
+
if (local.value !== !!val) local.value = !!val;
|
|
43
|
+
});
|
|
36
44
|
const openedByUser = computed(() => {
|
|
37
45
|
if (!enableLive.value || !local.value || author.value == null) return null;
|
|
38
46
|
const state = states.value.get(author.value);
|
|
@@ -42,7 +50,7 @@ const openedByUser = computed(() => {
|
|
|
42
50
|
|
|
43
51
|
<template>
|
|
44
52
|
<UModal
|
|
45
|
-
v-if="
|
|
53
|
+
v-if="controlled && !hasExternalOpen"
|
|
46
54
|
v-model:open="local"
|
|
47
55
|
v-bind="attrs"
|
|
48
56
|
>
|
|
@@ -3,7 +3,7 @@ import { computed, onBeforeUnmount, onMounted, ref, useAttrs, watch } from "vue"
|
|
|
3
3
|
import { useAAField } from "../../composables/useAAField";
|
|
4
4
|
import { useAAUIState } from "../../composables/useAAUIState";
|
|
5
5
|
import { useAAEphemeral } from "../../composables/useAAEphemeral";
|
|
6
|
-
import {
|
|
6
|
+
import { useAAFollowShare } from "../../composables/useAAFollowShare";
|
|
7
7
|
import { awareRingStyle } from "../../utils/awareRingStyle";
|
|
8
8
|
defineOptions({ inheritAttrs: false });
|
|
9
9
|
const props = defineProps({
|
|
@@ -14,10 +14,13 @@ const props = defineProps({
|
|
|
14
14
|
peers: { type: Boolean, required: false, default: false },
|
|
15
15
|
total: { type: Boolean, required: false, default: false }
|
|
16
16
|
});
|
|
17
|
-
const { isFollowing } = useAAFollowPeer();
|
|
18
17
|
const enableAwareness = computed(() => props.awareness || props.total);
|
|
19
|
-
const enableLive = computed(() => props.live || props.total
|
|
18
|
+
const enableLive = computed(() => props.live || props.total);
|
|
20
19
|
const enablePeers = computed(() => props.peers || props.total);
|
|
20
|
+
const follow = useAAFollowShare(
|
|
21
|
+
() => `${props.fieldKey}:scroll`,
|
|
22
|
+
{ enabled: () => props.followOnly }
|
|
23
|
+
);
|
|
21
24
|
const { hoverers, focusers, pressers, isPressed, hoverHandlers } = useAAField(() => props.fieldKey);
|
|
22
25
|
const ringStyle = computed(
|
|
23
26
|
() => enableAwareness.value ? awareRingStyle({
|
|
@@ -39,6 +42,7 @@ function flush() {
|
|
|
39
42
|
const payload = { y: el.scrollTop, x: el.scrollLeft };
|
|
40
43
|
if (enableLive.value && !suppress) liveScroll.value = payload;
|
|
41
44
|
if (enablePeers.value) setPeerScroll(payload);
|
|
45
|
+
if (!suppress) follow.publish(payload);
|
|
42
46
|
}
|
|
43
47
|
function onScroll() {
|
|
44
48
|
if (!raf) raf = requestAnimationFrame(flush);
|
|
@@ -61,6 +65,10 @@ watch(enableLive, (now, prev) => {
|
|
|
61
65
|
if (!now || prev) return;
|
|
62
66
|
applyLiveScroll(liveScroll.value);
|
|
63
67
|
});
|
|
68
|
+
watch(() => follow.leaderValue.value, (val) => {
|
|
69
|
+
if (!follow.adopting.value) return;
|
|
70
|
+
applyLiveScroll(val);
|
|
71
|
+
}, { deep: true });
|
|
64
72
|
onMounted(() => {
|
|
65
73
|
elRef.value?.addEventListener("scroll", onScroll, { passive: true });
|
|
66
74
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { computed, ref, useAttrs, watch } from "vue";
|
|
3
3
|
import { useAAUIState, useAAUIStateAuthor } from "../../composables/useAAUIState";
|
|
4
|
-
import {
|
|
4
|
+
import { useAAFollowShare } from "../../composables/useAAFollowShare";
|
|
5
5
|
import { useAwareness } from "../../composables/useAwareness";
|
|
6
6
|
defineOptions({ inheritAttrs: false });
|
|
7
7
|
const props = defineProps({
|
|
@@ -11,8 +11,12 @@ const props = defineProps({
|
|
|
11
11
|
followOnly: { type: Boolean, required: false, default: false },
|
|
12
12
|
total: { type: Boolean, required: false, default: false }
|
|
13
13
|
});
|
|
14
|
-
const
|
|
15
|
-
const
|
|
14
|
+
const enableLive = computed(() => props.live || props.total);
|
|
15
|
+
const follow = useAAFollowShare(
|
|
16
|
+
() => `${props.fieldKey}:open`,
|
|
17
|
+
{ enabled: () => props.followOnly }
|
|
18
|
+
);
|
|
19
|
+
const controlled = computed(() => enableLive.value || props.followOnly);
|
|
16
20
|
const attrs = useAttrs();
|
|
17
21
|
const liveOpen = useAAUIState(() => `${props.fieldKey}:open`, { defaultValue: false });
|
|
18
22
|
const author = useAAUIStateAuthor(() => `${props.fieldKey}:open`);
|
|
@@ -25,14 +29,18 @@ watch(liveOpen, (val) => {
|
|
|
25
29
|
if (local.value !== next) local.value = next;
|
|
26
30
|
});
|
|
27
31
|
watch(local, (val) => {
|
|
28
|
-
if (
|
|
29
|
-
|
|
32
|
+
if (enableLive.value && !!liveOpen.value !== val) liveOpen.value = val;
|
|
33
|
+
follow.publish(val);
|
|
30
34
|
});
|
|
31
35
|
watch(enableLive, (now, prev) => {
|
|
32
36
|
if (!now || prev) return;
|
|
33
37
|
const incoming = !!liveOpen.value;
|
|
34
38
|
if (local.value !== incoming) local.value = incoming;
|
|
35
39
|
});
|
|
40
|
+
watch(() => follow.leaderValue.value, (val) => {
|
|
41
|
+
if (!follow.adopting.value || val === void 0) return;
|
|
42
|
+
if (local.value !== !!val) local.value = !!val;
|
|
43
|
+
});
|
|
36
44
|
const openedByUser = computed(() => {
|
|
37
45
|
if (!enableLive.value || !local.value || author.value == null) return null;
|
|
38
46
|
const state = states.value.get(author.value);
|
|
@@ -42,7 +50,7 @@ const openedByUser = computed(() => {
|
|
|
42
50
|
|
|
43
51
|
<template>
|
|
44
52
|
<USlideover
|
|
45
|
-
v-if="
|
|
53
|
+
v-if="controlled && !hasExternalOpen"
|
|
46
54
|
v-model:open="local"
|
|
47
55
|
v-bind="attrs"
|
|
48
56
|
>
|
|
@@ -3,7 +3,7 @@ import { computed, ref, useAttrs, watch } from "vue";
|
|
|
3
3
|
import { useAAField } from "../../composables/useAAField";
|
|
4
4
|
import { useAAUIState } from "../../composables/useAAUIState";
|
|
5
5
|
import { useAAEphemeral } from "../../composables/useAAEphemeral";
|
|
6
|
-
import {
|
|
6
|
+
import { useAAFollowShare } from "../../composables/useAAFollowShare";
|
|
7
7
|
import AHoverItem from "./AHoverItem.vue";
|
|
8
8
|
function tabId(item) {
|
|
9
9
|
if (item == null) return "";
|
|
@@ -24,10 +24,14 @@ const props = defineProps({
|
|
|
24
24
|
peers: { type: Boolean, required: false, default: false },
|
|
25
25
|
total: { type: Boolean, required: false, default: false }
|
|
26
26
|
});
|
|
27
|
-
const { isFollowing } = useAAFollowPeer();
|
|
28
27
|
const enableAwareness = computed(() => props.awareness || props.total);
|
|
29
|
-
const enableLive = computed(() => props.live || props.total
|
|
28
|
+
const enableLive = computed(() => props.live || props.total);
|
|
30
29
|
const enablePeers = computed(() => props.peers || props.total);
|
|
30
|
+
const follow = useAAFollowShare(
|
|
31
|
+
() => `${props.fieldKey}:active`,
|
|
32
|
+
{ enabled: () => props.followOnly }
|
|
33
|
+
);
|
|
34
|
+
const controlled = computed(() => enableLive.value || props.followOnly);
|
|
31
35
|
const attrs = useAttrs();
|
|
32
36
|
const { hoverers, focusers, hoverHandlers } = useAAField(() => props.fieldKey);
|
|
33
37
|
const liveActive = useAAUIState(() => `${props.fieldKey}:active`, { defaultValue: "" });
|
|
@@ -44,12 +48,18 @@ watch(liveActive, (val) => {
|
|
|
44
48
|
watch(local, (val) => {
|
|
45
49
|
if (enableLive.value && (liveActive.value || "") !== val) liveActive.value = val;
|
|
46
50
|
if (enablePeers.value) setLocal(val || null);
|
|
51
|
+
follow.publish(val || "");
|
|
47
52
|
});
|
|
48
53
|
watch(enableLive, (now, prev) => {
|
|
49
54
|
if (!now || prev) return;
|
|
50
55
|
const incoming = liveActive.value || "";
|
|
51
56
|
if (incoming && local.value !== incoming) local.value = incoming;
|
|
52
57
|
});
|
|
58
|
+
watch(() => follow.leaderValue.value, (val) => {
|
|
59
|
+
if (!follow.adopting.value) return;
|
|
60
|
+
const next = val || "";
|
|
61
|
+
if (next && local.value !== next) local.value = next;
|
|
62
|
+
});
|
|
53
63
|
const ringStyle = computed(() => {
|
|
54
64
|
if (!enableAwareness.value) return void 0;
|
|
55
65
|
const focusColor = focusers.value[0]?.user?.color;
|
|
@@ -74,7 +84,7 @@ const eventHandlers = computed(() => enableAwareness.value ? hoverHandlers : {})
|
|
|
74
84
|
v-on="eventHandlers"
|
|
75
85
|
>
|
|
76
86
|
<UTabs
|
|
77
|
-
v-if="
|
|
87
|
+
v-if="controlled && !hasExternalModel"
|
|
78
88
|
v-model="local"
|
|
79
89
|
v-bind="attrs"
|
|
80
90
|
>
|
|
@@ -25,6 +25,15 @@ type __VLS_Props = {
|
|
|
25
25
|
mentionUsers?: ChatMentionUser[];
|
|
26
26
|
/** Input placeholder */
|
|
27
27
|
placeholder?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Show the header's close button.
|
|
30
|
+
*
|
|
31
|
+
* `false` where the panel is EMBEDDED in chrome that already closes it — the
|
|
32
|
+
* `<ANodePanel>` Chat tab is the case this exists for: its toolbar carries a
|
|
33
|
+
* close and an expand, and the chat header put a second X directly beneath
|
|
34
|
+
* the first, three rows from the top of the same slideover.
|
|
35
|
+
*/
|
|
36
|
+
closable?: boolean;
|
|
28
37
|
/** Whether to auto-focus the input */
|
|
29
38
|
autofocus?: boolean;
|
|
30
39
|
/** Empty state customization */
|
|
@@ -77,6 +86,7 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
|
|
|
77
86
|
mentionUsers: ChatMentionUser[];
|
|
78
87
|
typingUsers: TypingUser[];
|
|
79
88
|
activeAgents: ActiveAgent[];
|
|
89
|
+
closable: boolean;
|
|
80
90
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
81
91
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
82
92
|
declare const _default: typeof __VLS_export;
|
|
@@ -9,6 +9,7 @@ const props = defineProps({
|
|
|
9
9
|
activeAgents: { type: Array, required: false, default: () => [] },
|
|
10
10
|
mentionUsers: { type: Array, required: false, default: () => [] },
|
|
11
11
|
placeholder: { type: String, required: false, default: "Type a message\u2026" },
|
|
12
|
+
closable: { type: Boolean, required: false, default: true },
|
|
12
13
|
autofocus: { type: Boolean, required: false, default: false },
|
|
13
14
|
emptyIcon: { type: String, required: false, default: "i-lucide-message-circle" },
|
|
14
15
|
emptyText: { type: String, required: false, default: "No messages yet" },
|
|
@@ -60,6 +61,7 @@ defineExpose({
|
|
|
60
61
|
</h3>
|
|
61
62
|
<slot name="trailing" />
|
|
62
63
|
<UButton
|
|
64
|
+
v-if="closable"
|
|
63
65
|
icon="i-lucide-x"
|
|
64
66
|
color="neutral"
|
|
65
67
|
variant="ghost"
|
|
@@ -25,6 +25,15 @@ type __VLS_Props = {
|
|
|
25
25
|
mentionUsers?: ChatMentionUser[];
|
|
26
26
|
/** Input placeholder */
|
|
27
27
|
placeholder?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Show the header's close button.
|
|
30
|
+
*
|
|
31
|
+
* `false` where the panel is EMBEDDED in chrome that already closes it — the
|
|
32
|
+
* `<ANodePanel>` Chat tab is the case this exists for: its toolbar carries a
|
|
33
|
+
* close and an expand, and the chat header put a second X directly beneath
|
|
34
|
+
* the first, three rows from the top of the same slideover.
|
|
35
|
+
*/
|
|
36
|
+
closable?: boolean;
|
|
28
37
|
/** Whether to auto-focus the input */
|
|
29
38
|
autofocus?: boolean;
|
|
30
39
|
/** Empty state customization */
|
|
@@ -77,6 +86,7 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
|
|
|
77
86
|
mentionUsers: ChatMentionUser[];
|
|
78
87
|
typingUsers: TypingUser[];
|
|
79
88
|
activeAgents: ActiveAgent[];
|
|
89
|
+
closable: boolean;
|
|
80
90
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
81
91
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
82
92
|
declare const _default: typeof __VLS_export;
|
|
@@ -7,6 +7,8 @@ type __VLS_Props = {
|
|
|
7
7
|
placeholder?: string;
|
|
8
8
|
/** Auto-focus the input when mounted. */
|
|
9
9
|
autofocus?: boolean;
|
|
10
|
+
/** Show the header close button. Off when embedded in chrome that has one. */
|
|
11
|
+
closable?: boolean;
|
|
10
12
|
emptyIcon?: string;
|
|
11
13
|
emptyText?: string;
|
|
12
14
|
emptySubtext?: string;
|
|
@@ -31,6 +33,7 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {},
|
|
|
31
33
|
emptyText: string;
|
|
32
34
|
emptyIcon: string;
|
|
33
35
|
emptySubtext: string;
|
|
36
|
+
closable: boolean;
|
|
34
37
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
35
38
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
36
39
|
declare const _default: typeof __VLS_export;
|
|
@@ -9,6 +9,7 @@ const props = defineProps({
|
|
|
9
9
|
label: { type: String, required: false },
|
|
10
10
|
placeholder: { type: String, required: false, default: "Type a message\u2026" },
|
|
11
11
|
autofocus: { type: Boolean, required: false, default: false },
|
|
12
|
+
closable: { type: Boolean, required: false, default: true },
|
|
12
13
|
emptyIcon: { type: String, required: false, default: "i-lucide-message-circle" },
|
|
13
14
|
emptyText: { type: String, required: false, default: "No messages yet" },
|
|
14
15
|
emptySubtext: { type: String, required: false, default: "Be the first to send a message" }
|
|
@@ -38,6 +39,7 @@ const typingUsersAdapted = computed(
|
|
|
38
39
|
:active-agents="channelAgents"
|
|
39
40
|
:placeholder="placeholder"
|
|
40
41
|
:autofocus="autofocus"
|
|
42
|
+
:closable="closable"
|
|
41
43
|
:empty-icon="emptyIcon"
|
|
42
44
|
:empty-text="emptyText"
|
|
43
45
|
:empty-subtext="emptySubtext"
|
|
@@ -7,6 +7,8 @@ type __VLS_Props = {
|
|
|
7
7
|
placeholder?: string;
|
|
8
8
|
/** Auto-focus the input when mounted. */
|
|
9
9
|
autofocus?: boolean;
|
|
10
|
+
/** Show the header close button. Off when embedded in chrome that has one. */
|
|
11
|
+
closable?: boolean;
|
|
10
12
|
emptyIcon?: string;
|
|
11
13
|
emptyText?: string;
|
|
12
14
|
emptySubtext?: string;
|
|
@@ -31,6 +33,7 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {},
|
|
|
31
33
|
emptyText: string;
|
|
32
34
|
emptyIcon: string;
|
|
33
35
|
emptySubtext: string;
|
|
36
|
+
closable: boolean;
|
|
34
37
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
35
38
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
36
39
|
declare const _default: typeof __VLS_export;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
type __VLS_Props = {
|
|
2
|
-
fieldType: 'text' | 'url' | 'date' | 'datetime' | 'daterange' | 'location' | 'select' | 'icon';
|
|
2
|
+
fieldType: 'text' | 'url' | 'date' | 'datetime' | 'daterange' | 'location' | 'select' | 'icon' | 'tags';
|
|
3
3
|
/** Chip label — shown while the field is empty, and as the popover title. */
|
|
4
4
|
label?: string;
|
|
5
5
|
/** Lucide icon override (defaults per field type). */
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
} from "@internationalized/date";
|
|
9
9
|
import ALocationPickerPopover from "./ALocationPickerPopover.vue";
|
|
10
10
|
import AIconPickerPopover from "./AIconPickerPopover.vue";
|
|
11
|
+
import ATagsEditor from "../ATagsEditor.vue";
|
|
11
12
|
const props = defineProps({
|
|
12
13
|
fieldType: { type: String, required: true },
|
|
13
14
|
label: { type: String, required: false, default: "" },
|
|
@@ -33,7 +34,8 @@ const DEFAULT_ICONS = {
|
|
|
33
34
|
daterange: "i-lucide-calendar-range",
|
|
34
35
|
location: "i-lucide-map-pin",
|
|
35
36
|
select: "i-lucide-list",
|
|
36
|
-
icon: "i-lucide-smile"
|
|
37
|
+
icon: "i-lucide-smile",
|
|
38
|
+
tags: "i-lucide-tags"
|
|
37
39
|
};
|
|
38
40
|
const chipIcon = computed(() => {
|
|
39
41
|
if (props.fieldType === "icon") {
|
|
@@ -55,6 +57,9 @@ function patch(update) {
|
|
|
55
57
|
if (props.readonly) return;
|
|
56
58
|
emit("patch", update);
|
|
57
59
|
}
|
|
60
|
+
function onTagsSave(next) {
|
|
61
|
+
patch({ [props.metaKey]: next.length ? next : void 0 });
|
|
62
|
+
}
|
|
58
63
|
function isoToCalendarDate(s) {
|
|
59
64
|
if (s.length < 10) return void 0;
|
|
60
65
|
try {
|
|
@@ -87,6 +92,12 @@ function asSingleTime(raw) {
|
|
|
87
92
|
}
|
|
88
93
|
return null;
|
|
89
94
|
}
|
|
95
|
+
const tagList = computed(() => {
|
|
96
|
+
const raw = props.meta?.[props.metaKey];
|
|
97
|
+
if (Array.isArray(raw)) return raw.map((t) => String(t).trim()).filter(Boolean);
|
|
98
|
+
if (typeof raw === "string") return raw.split(",").map((t) => t.trim()).filter(Boolean);
|
|
99
|
+
return [];
|
|
100
|
+
});
|
|
90
101
|
const displayText = computed(() => {
|
|
91
102
|
switch (props.fieldType) {
|
|
92
103
|
case "text":
|
|
@@ -125,6 +136,8 @@ const displayText = computed(() => {
|
|
|
125
136
|
return getStr(props.metaKey);
|
|
126
137
|
case "icon":
|
|
127
138
|
return getStr(props.metaKey);
|
|
139
|
+
case "tags":
|
|
140
|
+
return tagList.value.join(", ");
|
|
128
141
|
default:
|
|
129
142
|
return "";
|
|
130
143
|
}
|
|
@@ -266,6 +279,32 @@ function onIconPick(name) {
|
|
|
266
279
|
/>
|
|
267
280
|
</template>
|
|
268
281
|
|
|
282
|
+
<!-- tags delegates to the shared editor. It is a MODAL rather than a
|
|
283
|
+
popover, so the chip is an ordinary button that opens it — an
|
|
284
|
+
`<UInputTags>` inline in a popover loses its own focus to the popover's
|
|
285
|
+
focus trap on the first Enter. -->
|
|
286
|
+
<template v-else-if="fieldType === 'tags' && !readonly">
|
|
287
|
+
<UButton
|
|
288
|
+
size="sm"
|
|
289
|
+
color="neutral"
|
|
290
|
+
variant="ghost"
|
|
291
|
+
:icon="chipIcon"
|
|
292
|
+
:class="CHIP_CLASS"
|
|
293
|
+
@click="popoverOpen = true"
|
|
294
|
+
>
|
|
295
|
+
<span
|
|
296
|
+
class="max-w-44 truncate"
|
|
297
|
+
:class="isEmpty ? 'text-(--ui-text-muted)' : ''"
|
|
298
|
+
>{{ chipText }}</span>
|
|
299
|
+
</UButton>
|
|
300
|
+
<ATagsEditor
|
|
301
|
+
v-model:open="popoverOpen"
|
|
302
|
+
:tags="tagList"
|
|
303
|
+
:title="label ? `Edit ${label.toLowerCase()}` : 'Edit tags'"
|
|
304
|
+
@save="onTagsSave"
|
|
305
|
+
/>
|
|
306
|
+
</template>
|
|
307
|
+
|
|
269
308
|
<UPopover
|
|
270
309
|
v-else-if="!readonly"
|
|
271
310
|
:open="popoverOpen"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
type __VLS_Props = {
|
|
2
|
-
fieldType: 'text' | 'url' | 'date' | 'datetime' | 'daterange' | 'location' | 'select' | 'icon';
|
|
2
|
+
fieldType: 'text' | 'url' | 'date' | 'datetime' | 'daterange' | 'location' | 'select' | 'icon' | 'tags';
|
|
3
3
|
/** Chip label — shown while the field is empty, and as the popover title. */
|
|
4
4
|
label?: string;
|
|
5
5
|
/** Lucide icon override (defaults per field type). */
|
|
@@ -63,6 +63,24 @@ export interface AAFocusPayload {
|
|
|
63
63
|
* *content* position regardless of either tab's scroll state. */
|
|
64
64
|
pointer?: AAPointerAnchor;
|
|
65
65
|
}
|
|
66
|
-
export
|
|
66
|
+
export interface UseAAFocusOptions {
|
|
67
|
+
/**
|
|
68
|
+
* Publish TEXT SELECTIONS only — no pointer anchor, no scroll anchors, and
|
|
69
|
+
* no listeners for either.
|
|
70
|
+
*
|
|
71
|
+
* The full broadcast is not cheap: it re-serialises on every `pointermove`,
|
|
72
|
+
* and `collectScrollers()` walks `document.querySelectorAll('*')` on each one
|
|
73
|
+
* to find every overflow container on the page. On a long or tile-heavy page
|
|
74
|
+
* that is thousands of elements per move — worth it when something is
|
|
75
|
+
* consuming the anchors (smart follow-scroll, presence blobs), and pure waste
|
|
76
|
+
* when the only consumer is `<AGlobalFocusLayer>`, which reads `kind:
|
|
77
|
+
* 'selection'` and nothing else.
|
|
78
|
+
*
|
|
79
|
+
* In this mode the only listener is `selectionchange`, and a collapsed
|
|
80
|
+
* selection clears the slot rather than falling back to an anchor.
|
|
81
|
+
*/
|
|
82
|
+
selectionOnly?: boolean;
|
|
83
|
+
}
|
|
84
|
+
export declare function useAAFocus(options?: UseAAFocusOptions): {
|
|
67
85
|
snapshot: () => void;
|
|
68
86
|
};
|
|
@@ -2,18 +2,21 @@ import { onMounted, onScopeDispose } from "vue";
|
|
|
2
2
|
import { useRoute } from "#imports";
|
|
3
3
|
import { useAAEphemeral } from "./useAAEphemeral.js";
|
|
4
4
|
import { serializeRangeEndpoint, pathFromElement } from "../utils/domPath.js";
|
|
5
|
-
export function useAAFocus() {
|
|
5
|
+
export function useAAFocus(options = {}) {
|
|
6
|
+
const selectionOnly = options.selectionOnly === true;
|
|
6
7
|
const { setLocal } = useAAEphemeral("aa:focus");
|
|
7
8
|
const route = useRoute();
|
|
8
9
|
let raf = 0;
|
|
9
10
|
let lastSerialized = null;
|
|
10
11
|
const pointer = { clientX: 0, clientY: 0, fresh: false };
|
|
11
12
|
function publish(payload) {
|
|
12
|
-
if (
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
if (!selectionOnly) {
|
|
14
|
+
if (pointer.fresh) {
|
|
15
|
+
const anchor = serializePointer(pointer.clientX, pointer.clientY);
|
|
16
|
+
if (anchor) payload.pointer = anchor;
|
|
17
|
+
}
|
|
18
|
+
payload.scrollers = collectScrollers();
|
|
15
19
|
}
|
|
16
|
-
payload.scrollers = collectScrollers();
|
|
17
20
|
const json = JSON.stringify(payload);
|
|
18
21
|
if (json === lastSerialized) return;
|
|
19
22
|
lastSerialized = json;
|
|
@@ -126,6 +129,10 @@ export function useAAFocus() {
|
|
|
126
129
|
return;
|
|
127
130
|
}
|
|
128
131
|
}
|
|
132
|
+
if (selectionOnly) {
|
|
133
|
+
clear();
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
129
136
|
const picked = pickAnchorElement();
|
|
130
137
|
if (!picked) {
|
|
131
138
|
clear();
|
|
@@ -160,19 +167,23 @@ export function useAAFocus() {
|
|
|
160
167
|
}
|
|
161
168
|
onMounted(() => {
|
|
162
169
|
document.addEventListener("selectionchange", onSelectionChange);
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
170
|
+
if (!selectionOnly) {
|
|
171
|
+
document.addEventListener("scroll", onScroll, { passive: true, capture: true });
|
|
172
|
+
document.addEventListener("pointermove", onPointerMove, { passive: true });
|
|
173
|
+
document.addEventListener("pointerleave", onPointerLeave);
|
|
174
|
+
window.addEventListener("resize", onResize, { passive: true });
|
|
175
|
+
}
|
|
167
176
|
snapshot();
|
|
168
177
|
});
|
|
169
178
|
onScopeDispose(() => {
|
|
170
179
|
cancelAnimationFrame(raf);
|
|
171
180
|
document.removeEventListener("selectionchange", onSelectionChange);
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
181
|
+
if (!selectionOnly) {
|
|
182
|
+
document.removeEventListener("scroll", onScroll, { capture: true });
|
|
183
|
+
document.removeEventListener("pointermove", onPointerMove);
|
|
184
|
+
document.removeEventListener("pointerleave", onPointerLeave);
|
|
185
|
+
window.removeEventListener("resize", onResize);
|
|
186
|
+
}
|
|
176
187
|
clear();
|
|
177
188
|
});
|
|
178
189
|
return { snapshot };
|
|
@@ -17,6 +17,28 @@ export interface UseAAFollowPeerOptions {
|
|
|
17
17
|
keyPrefix?: string;
|
|
18
18
|
/** Hook fired when the user breaks follow via local interaction. */
|
|
19
19
|
onBreak?: () => void;
|
|
20
|
+
/**
|
|
21
|
+
* Which local interactions end the follow.
|
|
22
|
+
*
|
|
23
|
+
* The default (`'any'`) is right for an INCIDENTAL follow — you were dragged
|
|
24
|
+
* along by someone's scroll and the first thing you do should get you out.
|
|
25
|
+
* It is wrong for a DELIBERATE one: with `'any'`, the very next click ends
|
|
26
|
+
* it, including the click on the follow button used to check whether it
|
|
27
|
+
* worked, and including any click inside the UI that offers the follow.
|
|
28
|
+
*
|
|
29
|
+
* `'scroll-keys'` keeps the escape hatch that matters (scrolling or typing —
|
|
30
|
+
* the things you do to the CONTENT) and ignores clicks, so a follow survives
|
|
31
|
+
* using the interface around it.
|
|
32
|
+
*
|
|
33
|
+
* `'none'` never breaks automatically; the caller owns `unfollow()`.
|
|
34
|
+
*/
|
|
35
|
+
breakOn?: 'any' | 'scroll-keys' | 'none';
|
|
36
|
+
/**
|
|
37
|
+
* A pointerdown inside one of these is not an escape. Pass the surface that
|
|
38
|
+
* owns the follow UI — its own controls should not cancel the thing they
|
|
39
|
+
* exist to control. Ignored unless `breakOn` is `'any'`.
|
|
40
|
+
*/
|
|
41
|
+
ignoreWithin?: () => (HTMLElement | null | undefined)[];
|
|
20
42
|
}
|
|
21
43
|
export declare function useAAFollowPeer(options?: UseAAFollowPeerOptions): {
|
|
22
44
|
follow: (clientIdOrPublicKey: number | string) => void;
|
|
@@ -46,14 +46,24 @@ export function useAAFollowPeer(options = {}) {
|
|
|
46
46
|
function attachInteractionBreaker() {
|
|
47
47
|
detachInteraction();
|
|
48
48
|
if (typeof window === "undefined") return;
|
|
49
|
+
const mode = options.breakOn ?? "any";
|
|
50
|
+
if (mode === "none") return;
|
|
49
51
|
const onBreak = () => unfollow();
|
|
52
|
+
const onPointerDown = (event) => {
|
|
53
|
+
const roots = options.ignoreWithin?.() ?? [];
|
|
54
|
+
const target = event.target;
|
|
55
|
+
for (const root of roots) {
|
|
56
|
+
if (root && target && root.contains(target)) return;
|
|
57
|
+
}
|
|
58
|
+
unfollow();
|
|
59
|
+
};
|
|
50
60
|
window.addEventListener("keydown", onBreak);
|
|
51
|
-
window.addEventListener("pointerdown", onBreak);
|
|
52
61
|
window.addEventListener("wheel", onBreak, { passive: true });
|
|
62
|
+
if (mode === "any") window.addEventListener("pointerdown", onPointerDown);
|
|
53
63
|
unsubInteraction = () => {
|
|
54
64
|
window.removeEventListener("keydown", onBreak);
|
|
55
|
-
window.removeEventListener("pointerdown", onBreak);
|
|
56
65
|
window.removeEventListener("wheel", onBreak);
|
|
66
|
+
window.removeEventListener("pointerdown", onPointerDown);
|
|
57
67
|
};
|
|
58
68
|
}
|
|
59
69
|
function follow(clientIdOrPublicKey) {
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { MaybeRefOrGetter } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* The channel `followOnly` runs on.
|
|
4
|
+
*
|
|
5
|
+
* ## The bug this exists to fix
|
|
6
|
+
*
|
|
7
|
+
* `followOnly` had never worked, in any of the six aware components that offer
|
|
8
|
+
* it, since the day it was added. Every one of them gated the WRITE and the
|
|
9
|
+
* READ on a single computed:
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* const enableLive = computed(() =>
|
|
13
|
+
* props.live || props.total || (props.followOnly && isFollowing.value))
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* `isFollowing` is false for anyone who is not currently following someone —
|
|
17
|
+
* **including the leader**. So the leader never published, the follower had
|
|
18
|
+
* nothing to adopt, and the mode was inert in both directions. It is not a
|
|
19
|
+
* corner case: the module's own docs recommend `followOnly` as the DEFAULT for
|
|
20
|
+
* scroll, tabs, collapsibles and modal-open, and describe the intent the code
|
|
21
|
+
* did not implement — *"live semantics, but only adopted while actively
|
|
22
|
+
* following someone."* Adoption was gated correctly; publication was gated by
|
|
23
|
+
* mistake.
|
|
24
|
+
*
|
|
25
|
+
* ## Why "just publish always" is the wrong fix
|
|
26
|
+
*
|
|
27
|
+
* That was the obvious repair and it makes `followOnly` identical to `live`.
|
|
28
|
+
* `useAAUIState` stores **one entry per fieldKey** on a shared `aware-ui`
|
|
29
|
+
* Y.Map (`{value, by, ts}`, last-write-wins, not per client), so unconditional
|
|
30
|
+
* publishing means every visitor's scroll position overwrites the same slot and
|
|
31
|
+
* drags everybody else with it. The shared slot is what `live` NEEDS; it is
|
|
32
|
+
* exactly wrong here.
|
|
33
|
+
*
|
|
34
|
+
* ## The shape that works
|
|
35
|
+
*
|
|
36
|
+
* A per-peer ephemeral channel. `useAAEphemeral` keys on the awareness
|
|
37
|
+
* clientId, so N peers write N slots and never collide, and none of it touches
|
|
38
|
+
* the CRDT. Publish unconditionally into that; while following, read back the
|
|
39
|
+
* one entry whose `clientId` is the leader's. `aware-ui` is left alone as the
|
|
40
|
+
* shared-slot channel `live` and `total` need.
|
|
41
|
+
*
|
|
42
|
+
* There is a working reference for this shape already: `useAAFocus` publishes
|
|
43
|
+
* selection to `useAAEphemeral('aa:focus')` and `<AGlobalFocusLayer follow-only>`
|
|
44
|
+
* filters on `followingClientId`. This is the same two lines, generalised so
|
|
45
|
+
* the six components share one implementation instead of six near-copies.
|
|
46
|
+
*
|
|
47
|
+
* ## Publishing is skipped when nobody could be listening
|
|
48
|
+
*
|
|
49
|
+
* A visitor alone on a page has no follower, so every awareness frame this
|
|
50
|
+
* would send is waste — and on a personal site "alone" is the common case, not
|
|
51
|
+
* the edge one. The guard costs one comparison and removes the whole cost.
|
|
52
|
+
*/
|
|
53
|
+
export interface UseAAFollowShareOptions {
|
|
54
|
+
/**
|
|
55
|
+
* Whether this component is in `followOnly` mode at all. When false nothing
|
|
56
|
+
* is published and nothing is adopted — the component is solo.
|
|
57
|
+
*/
|
|
58
|
+
enabled: MaybeRefOrGetter<boolean>;
|
|
59
|
+
}
|
|
60
|
+
export declare function useAAFollowShare<T>(fieldKey: MaybeRefOrGetter<string>, options: UseAAFollowShareOptions): {
|
|
61
|
+
publish: (value: T) => void;
|
|
62
|
+
leaderValue: import("vue").ComputedRef<T | undefined>;
|
|
63
|
+
adopting: import("vue").ComputedRef<boolean>;
|
|
64
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { computed, onScopeDispose, toValue, watch } from "vue";
|
|
2
|
+
import { useAAEphemeral } from "./useAAEphemeral.js";
|
|
3
|
+
import { useAAFollowPeer } from "./useAAFollowPeer.js";
|
|
4
|
+
import { useAwareness } from "./useAwareness.js";
|
|
5
|
+
function resolveKey(fieldKey) {
|
|
6
|
+
return toValue(fieldKey);
|
|
7
|
+
}
|
|
8
|
+
export function useAAFollowShare(fieldKey, options) {
|
|
9
|
+
const { peers, setLocal } = useAAEphemeral(() => `${resolveKey(fieldKey)}:follow`);
|
|
10
|
+
const { followingClientId, isFollowing } = useAAFollowPeer();
|
|
11
|
+
const { states } = useAwareness();
|
|
12
|
+
const enabled = computed(() => !!toValue(options.enabled));
|
|
13
|
+
const observed = computed(() => states.value.size > 1);
|
|
14
|
+
const leaderValue = computed(() => {
|
|
15
|
+
if (!enabled.value) return void 0;
|
|
16
|
+
const cid = followingClientId.value;
|
|
17
|
+
if (cid == null) return void 0;
|
|
18
|
+
return peers.value.find((p) => p.clientId === cid)?.value;
|
|
19
|
+
});
|
|
20
|
+
const adopting = computed(() => enabled.value && isFollowing.value);
|
|
21
|
+
function publish(value) {
|
|
22
|
+
if (!enabled.value || !observed.value) return;
|
|
23
|
+
setLocal(value);
|
|
24
|
+
}
|
|
25
|
+
watch(enabled, (on) => {
|
|
26
|
+
if (!on) setLocal(null);
|
|
27
|
+
});
|
|
28
|
+
onScopeDispose(() => setLocal(null));
|
|
29
|
+
return { publish, leaderValue, adopting };
|
|
30
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abraca/nuxt",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.85.0",
|
|
4
4
|
"description": "First-class Nuxt module for the Abracadabra CRDT collaboration platform",
|
|
5
5
|
"repository": "abracadabra/abracadabra-nuxt",
|
|
6
6
|
"license": "MIT",
|
|
@@ -173,9 +173,9 @@
|
|
|
173
173
|
}
|
|
174
174
|
},
|
|
175
175
|
"devDependencies": {
|
|
176
|
-
"@abraca/convert": "^2.
|
|
177
|
-
"@abraca/dabra": "^2.
|
|
178
|
-
"@abraca/plugin": "^2.
|
|
176
|
+
"@abraca/convert": "^2.84.0",
|
|
177
|
+
"@abraca/dabra": "^2.84.0",
|
|
178
|
+
"@abraca/plugin": "^2.84.0",
|
|
179
179
|
"@codemirror/autocomplete": "^6.18.0",
|
|
180
180
|
"@codemirror/commands": "^6.7.0",
|
|
181
181
|
"@codemirror/lang-css": "^6.3.1",
|