@aphexcms/ui 0.8.2 → 0.8.4
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/components/ui/attachment/attachment-action.svelte +7 -0
- package/dist/components/ui/attachment/attachment-action.svelte.d.ts +4 -0
- package/dist/components/ui/attachment/attachment-actions.svelte +19 -0
- package/dist/components/ui/attachment/attachment-actions.svelte.d.ts +5 -0
- package/dist/components/ui/attachment/attachment-content.svelte +19 -0
- package/dist/components/ui/attachment/attachment-content.svelte.d.ts +5 -0
- package/dist/components/ui/attachment/attachment-context.svelte.d.ts +10 -0
- package/dist/components/ui/attachment/attachment-context.svelte.js +13 -0
- package/dist/components/ui/attachment/attachment-description.svelte +19 -0
- package/dist/components/ui/attachment/attachment-description.svelte.d.ts +5 -0
- package/dist/components/ui/attachment/attachment-group.svelte +22 -0
- package/dist/components/ui/attachment/attachment-group.svelte.d.ts +5 -0
- package/dist/components/ui/attachment/attachment-media.svelte +26 -0
- package/dist/components/ui/attachment/attachment-media.svelte.d.ts +8 -0
- package/dist/components/ui/attachment/attachment-title.svelte +25 -0
- package/dist/components/ui/attachment/attachment-title.svelte.d.ts +5 -0
- package/dist/components/ui/attachment/attachment-trigger.svelte +34 -0
- package/dist/components/ui/attachment/attachment-trigger.svelte.d.ts +6 -0
- package/dist/components/ui/attachment/attachment.svelte +56 -0
- package/dist/components/ui/attachment/attachment.svelte.d.ts +11 -0
- package/dist/components/ui/attachment/index.d.ts +10 -0
- package/dist/components/ui/attachment/index.js +9 -0
- package/dist/components/ui/avatar/avatar-fallback.svelte +4 -1
- package/dist/components/ui/avatar/avatar-image.svelte +1 -1
- package/dist/components/ui/avatar/avatar.svelte +9 -2
- package/dist/components/ui/avatar/avatar.svelte.d.ts +4 -1
- package/dist/components/ui/bubble/bubble-content.svelte +22 -0
- package/dist/components/ui/bubble/bubble-content.svelte.d.ts +5 -0
- package/dist/components/ui/bubble/bubble-group.svelte +19 -0
- package/dist/components/ui/bubble/bubble-group.svelte.d.ts +5 -0
- package/dist/components/ui/bubble/bubble-reactions.svelte +32 -0
- package/dist/components/ui/bubble/bubble-reactions.svelte.d.ts +9 -0
- package/dist/components/ui/bubble/bubble.svelte +48 -0
- package/dist/components/ui/bubble/bubble.svelte.d.ts +43 -0
- package/dist/components/ui/bubble/index.d.ts +5 -0
- package/dist/components/ui/bubble/index.js +5 -0
- package/dist/components/ui/button-group/button-group-separator.svelte +23 -0
- package/dist/components/ui/button-group/button-group-separator.svelte.d.ts +13 -0
- package/dist/components/ui/button-group/button-group-text.svelte +31 -0
- package/dist/components/ui/button-group/button-group-text.svelte.d.ts +11 -0
- package/dist/components/ui/button-group/button-group.svelte +46 -0
- package/dist/components/ui/button-group/button-group.svelte.d.ts +26 -0
- package/dist/components/ui/button-group/index.d.ts +4 -0
- package/dist/components/ui/button-group/index.js +6 -0
- package/dist/components/ui/marker/index.d.ts +4 -0
- package/dist/components/ui/marker/index.js +4 -0
- package/dist/components/ui/marker/marker-content.svelte +17 -0
- package/dist/components/ui/marker/marker-content.svelte.d.ts +5 -0
- package/dist/components/ui/marker/marker-icon.svelte +18 -0
- package/dist/components/ui/marker/marker-icon.svelte.d.ts +5 -0
- package/dist/components/ui/marker/marker.svelte +38 -0
- package/dist/components/ui/marker/marker.svelte.d.ts +29 -0
- package/dist/components/ui/message/index.d.ts +7 -0
- package/dist/components/ui/message/index.js +6 -0
- package/dist/components/ui/message/message-avatar.svelte +22 -0
- package/dist/components/ui/message/message-avatar.svelte.d.ts +5 -0
- package/dist/components/ui/message/message-content.svelte +19 -0
- package/dist/components/ui/message/message-content.svelte.d.ts +5 -0
- package/dist/components/ui/message/message-context.d.ts +3 -0
- package/dist/components/ui/message/message-context.js +8 -0
- package/dist/components/ui/message/message-footer.svelte +22 -0
- package/dist/components/ui/message/message-footer.svelte.d.ts +5 -0
- package/dist/components/ui/message/message-group.svelte +19 -0
- package/dist/components/ui/message/message-group.svelte.d.ts +5 -0
- package/dist/components/ui/message/message-header.svelte +19 -0
- package/dist/components/ui/message/message-header.svelte.d.ts +5 -0
- package/dist/components/ui/message/message.svelte +27 -0
- package/dist/components/ui/message/message.svelte.d.ts +9 -0
- package/dist/components/ui/message-scroller/index.d.ts +7 -0
- package/dist/components/ui/message-scroller/index.js +7 -0
- package/dist/components/ui/message-scroller/message-scroller-button.svelte +51 -0
- package/dist/components/ui/message-scroller/message-scroller-button.svelte.d.ts +11 -0
- package/dist/components/ui/message-scroller/message-scroller-content.svelte +35 -0
- package/dist/components/ui/message-scroller/message-scroller-content.svelte.d.ts +5 -0
- package/dist/components/ui/message-scroller/message-scroller-context.svelte.d.ts +39 -0
- package/dist/components/ui/message-scroller/message-scroller-context.svelte.js +161 -0
- package/dist/components/ui/message-scroller/message-scroller-item.svelte +51 -0
- package/dist/components/ui/message-scroller/message-scroller-item.svelte.d.ts +9 -0
- package/dist/components/ui/message-scroller/message-scroller-provider.svelte +40 -0
- package/dist/components/ui/message-scroller/message-scroller-provider.svelte.d.ts +12 -0
- package/dist/components/ui/message-scroller/message-scroller-viewport.svelte +46 -0
- package/dist/components/ui/message-scroller/message-scroller-viewport.svelte.d.ts +5 -0
- package/dist/components/ui/message-scroller/message-scroller.svelte +27 -0
- package/dist/components/ui/message-scroller/message-scroller.svelte.d.ts +5 -0
- package/dist/components/ui/sidebar/context.svelte.js +9 -0
- package/dist/components/ui/sidebar/sidebar-input.svelte.d.ts +1 -1
- package/package.json +35 -5
- package/src/app.css +451 -174
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export type ScrollPosition = 'start' | 'end' | 'last-anchor';
|
|
2
|
+
export type MessageScrollerOptions = {
|
|
3
|
+
autoScroll: boolean;
|
|
4
|
+
defaultScrollPosition: ScrollPosition;
|
|
5
|
+
preserveScrollOnPrepend: boolean;
|
|
6
|
+
scrollPreviousItemPeek: number;
|
|
7
|
+
};
|
|
8
|
+
export declare class MessageScrollerState {
|
|
9
|
+
#private;
|
|
10
|
+
viewport: HTMLDivElement | null;
|
|
11
|
+
content: HTMLDivElement | null;
|
|
12
|
+
autoscrolling: boolean;
|
|
13
|
+
initialized: boolean;
|
|
14
|
+
canScrollStart: boolean;
|
|
15
|
+
canScrollEnd: boolean;
|
|
16
|
+
currentAnchorId: string | null;
|
|
17
|
+
visibleMessageIds: string[];
|
|
18
|
+
options: MessageScrollerOptions;
|
|
19
|
+
constructor(options: MessageScrollerOptions);
|
|
20
|
+
setViewport(element: HTMLDivElement | null): void;
|
|
21
|
+
setContent(element: HTMLDivElement | null): void;
|
|
22
|
+
registerItem(id: string, element: HTMLElement, anchor: boolean): () => void;
|
|
23
|
+
setItemVisible(id: string, visible: boolean): void;
|
|
24
|
+
releaseFollow(): void;
|
|
25
|
+
handleScroll(trusted?: boolean): void;
|
|
26
|
+
scrollToStart(behavior?: ScrollBehavior): void;
|
|
27
|
+
scrollToEnd(behavior?: ScrollBehavior): void;
|
|
28
|
+
scrollToMessage(id: string, behavior?: ScrollBehavior): boolean;
|
|
29
|
+
scheduleLayout(): void;
|
|
30
|
+
destroy(): void;
|
|
31
|
+
private orderedItems;
|
|
32
|
+
private layout;
|
|
33
|
+
private scrollTo;
|
|
34
|
+
private updateCurrentAnchor;
|
|
35
|
+
}
|
|
36
|
+
export declare function setMessageScroller(options: MessageScrollerOptions): MessageScrollerState;
|
|
37
|
+
export declare function useMessageScroller(): MessageScrollerState;
|
|
38
|
+
export declare const useMessageScrollerVisibility: typeof useMessageScroller;
|
|
39
|
+
export declare const useMessageScrollerScrollable: typeof useMessageScroller;
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { getContext, setContext } from 'svelte';
|
|
2
|
+
const MESSAGE_SCROLLER = Symbol.for('aphexcms.ui.message-scroller');
|
|
3
|
+
export class MessageScrollerState {
|
|
4
|
+
viewport = $state(null);
|
|
5
|
+
content = $state(null);
|
|
6
|
+
autoscrolling = $state(false);
|
|
7
|
+
initialized = $state(false);
|
|
8
|
+
canScrollStart = $state(false);
|
|
9
|
+
canScrollEnd = $state(false);
|
|
10
|
+
currentAnchorId = $state(null);
|
|
11
|
+
visibleMessageIds = $state([]);
|
|
12
|
+
options;
|
|
13
|
+
#items = new Map();
|
|
14
|
+
#visible = new Set();
|
|
15
|
+
#following = false;
|
|
16
|
+
#frame = 0;
|
|
17
|
+
#previousIds = [];
|
|
18
|
+
#previousHeight = 0;
|
|
19
|
+
#lastAnchorId = null;
|
|
20
|
+
constructor(options) {
|
|
21
|
+
this.options = options;
|
|
22
|
+
}
|
|
23
|
+
setViewport(element) {
|
|
24
|
+
this.viewport = element;
|
|
25
|
+
this.scheduleLayout();
|
|
26
|
+
}
|
|
27
|
+
setContent(element) {
|
|
28
|
+
this.content = element;
|
|
29
|
+
this.scheduleLayout();
|
|
30
|
+
}
|
|
31
|
+
registerItem(id, element, anchor) {
|
|
32
|
+
this.#items.set(id, { element, anchor });
|
|
33
|
+
this.scheduleLayout();
|
|
34
|
+
return () => {
|
|
35
|
+
this.#items.delete(id);
|
|
36
|
+
this.#visible.delete(id);
|
|
37
|
+
this.scheduleLayout();
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
setItemVisible(id, visible) {
|
|
41
|
+
if (visible)
|
|
42
|
+
this.#visible.add(id);
|
|
43
|
+
else
|
|
44
|
+
this.#visible.delete(id);
|
|
45
|
+
this.visibleMessageIds = this.orderedItems()
|
|
46
|
+
.filter(([messageId]) => this.#visible.has(messageId))
|
|
47
|
+
.map(([messageId]) => messageId);
|
|
48
|
+
this.updateCurrentAnchor();
|
|
49
|
+
}
|
|
50
|
+
releaseFollow() {
|
|
51
|
+
this.#following = false;
|
|
52
|
+
}
|
|
53
|
+
handleScroll(trusted = false) {
|
|
54
|
+
const viewport = this.viewport;
|
|
55
|
+
if (!viewport)
|
|
56
|
+
return;
|
|
57
|
+
const distance = viewport.scrollHeight - viewport.scrollTop - viewport.clientHeight;
|
|
58
|
+
this.canScrollStart = viewport.scrollTop > 1;
|
|
59
|
+
this.canScrollEnd = distance > 1;
|
|
60
|
+
if (trusted && this.options.autoScroll)
|
|
61
|
+
this.#following = distance <= 2;
|
|
62
|
+
this.updateCurrentAnchor();
|
|
63
|
+
}
|
|
64
|
+
scrollToStart(behavior = 'smooth') {
|
|
65
|
+
this.#following = false;
|
|
66
|
+
this.scrollTo(0, behavior);
|
|
67
|
+
}
|
|
68
|
+
scrollToEnd(behavior = 'smooth') {
|
|
69
|
+
this.#following = this.options.autoScroll;
|
|
70
|
+
this.scrollTo(this.viewport?.scrollHeight ?? 0, behavior);
|
|
71
|
+
}
|
|
72
|
+
scrollToMessage(id, behavior = 'smooth') {
|
|
73
|
+
const item = this.#items.get(id);
|
|
74
|
+
if (!item || !this.viewport)
|
|
75
|
+
return false;
|
|
76
|
+
this.#following = false;
|
|
77
|
+
this.scrollTo(item.element.offsetTop, behavior);
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
scheduleLayout() {
|
|
81
|
+
cancelAnimationFrame(this.#frame);
|
|
82
|
+
this.#frame = requestAnimationFrame(() => this.layout());
|
|
83
|
+
}
|
|
84
|
+
destroy() {
|
|
85
|
+
cancelAnimationFrame(this.#frame);
|
|
86
|
+
}
|
|
87
|
+
orderedItems() {
|
|
88
|
+
return [...this.#items.entries()].sort((a, b) => a[1].element.offsetTop - b[1].element.offsetTop);
|
|
89
|
+
}
|
|
90
|
+
layout() {
|
|
91
|
+
const viewport = this.viewport;
|
|
92
|
+
const content = this.content;
|
|
93
|
+
if (!viewport || !content)
|
|
94
|
+
return;
|
|
95
|
+
const items = this.orderedItems();
|
|
96
|
+
const ids = items.map(([id]) => id);
|
|
97
|
+
const anchors = items.filter(([, item]) => item.anchor);
|
|
98
|
+
const lastAnchor = anchors.at(-1) ?? null;
|
|
99
|
+
if (!this.initialized) {
|
|
100
|
+
this.initialized = true;
|
|
101
|
+
if (this.options.defaultScrollPosition === 'start')
|
|
102
|
+
this.scrollToStart('auto');
|
|
103
|
+
else if (this.options.defaultScrollPosition === 'last-anchor' && lastAnchor) {
|
|
104
|
+
this.scrollTo(Math.max(0, lastAnchor[1].element.offsetTop - this.options.scrollPreviousItemPeek), 'auto');
|
|
105
|
+
}
|
|
106
|
+
else
|
|
107
|
+
this.scrollToEnd('auto');
|
|
108
|
+
this.#following = this.options.autoScroll && !this.canScrollEnd;
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
const previousFirst = this.#previousIds[0];
|
|
112
|
+
const previousFirstIndex = previousFirst ? ids.indexOf(previousFirst) : -1;
|
|
113
|
+
const prepended = previousFirstIndex > 0;
|
|
114
|
+
if (prepended && this.options.preserveScrollOnPrepend) {
|
|
115
|
+
viewport.scrollTop += content.scrollHeight - this.#previousHeight;
|
|
116
|
+
}
|
|
117
|
+
else if (lastAnchor && lastAnchor[0] !== this.#lastAnchorId) {
|
|
118
|
+
this.#following = false;
|
|
119
|
+
this.scrollTo(Math.max(0, lastAnchor[1].element.offsetTop - this.options.scrollPreviousItemPeek), 'smooth');
|
|
120
|
+
}
|
|
121
|
+
else if (this.#following && this.options.autoScroll) {
|
|
122
|
+
this.scrollToEnd('auto');
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
this.#previousIds = ids;
|
|
126
|
+
this.#previousHeight = content.scrollHeight;
|
|
127
|
+
this.#lastAnchorId = lastAnchor?.[0] ?? null;
|
|
128
|
+
this.handleScroll();
|
|
129
|
+
}
|
|
130
|
+
scrollTo(top, behavior) {
|
|
131
|
+
if (!this.viewport)
|
|
132
|
+
return;
|
|
133
|
+
this.autoscrolling = true;
|
|
134
|
+
this.viewport.scrollTo({ top, behavior });
|
|
135
|
+
requestAnimationFrame(() => {
|
|
136
|
+
this.autoscrolling = false;
|
|
137
|
+
this.handleScroll();
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
updateCurrentAnchor() {
|
|
141
|
+
const viewport = this.viewport;
|
|
142
|
+
if (!viewport)
|
|
143
|
+
return;
|
|
144
|
+
const top = viewport.scrollTop + this.options.scrollPreviousItemPeek + 1;
|
|
145
|
+
for (const [id, item] of this.orderedItems()) {
|
|
146
|
+
if (item.anchor && item.element.offsetTop <= top)
|
|
147
|
+
this.currentAnchorId = id;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
export function setMessageScroller(options) {
|
|
152
|
+
return setContext(MESSAGE_SCROLLER, new MessageScrollerState(options));
|
|
153
|
+
}
|
|
154
|
+
export function useMessageScroller() {
|
|
155
|
+
const state = getContext(MESSAGE_SCROLLER);
|
|
156
|
+
if (!state)
|
|
157
|
+
throw new Error('Message scroller parts must be inside MessageScrollerProvider');
|
|
158
|
+
return state;
|
|
159
|
+
}
|
|
160
|
+
export const useMessageScrollerVisibility = useMessageScroller;
|
|
161
|
+
export const useMessageScrollerScrollable = useMessageScroller;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount } from 'svelte';
|
|
3
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
4
|
+
import { cn, type WithElementRef } from '../../../utils.js';
|
|
5
|
+
import { useMessageScroller } from './message-scroller-context.svelte.js';
|
|
6
|
+
|
|
7
|
+
type Props = WithElementRef<HTMLAttributes<HTMLDivElement>> & {
|
|
8
|
+
messageId?: string;
|
|
9
|
+
scrollAnchor?: boolean;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
let {
|
|
13
|
+
ref = $bindable(null),
|
|
14
|
+
class: className,
|
|
15
|
+
children,
|
|
16
|
+
messageId,
|
|
17
|
+
scrollAnchor = false,
|
|
18
|
+
...restProps
|
|
19
|
+
}: Props = $props();
|
|
20
|
+
const state = useMessageScroller();
|
|
21
|
+
|
|
22
|
+
onMount(() => {
|
|
23
|
+
if (!ref) return;
|
|
24
|
+
const id = messageId ?? crypto.randomUUID();
|
|
25
|
+
const unregister = state.registerItem(id, ref, scrollAnchor);
|
|
26
|
+
const observer = new IntersectionObserver(
|
|
27
|
+
([entry]) => state.setItemVisible(id, entry?.isIntersecting ?? false),
|
|
28
|
+
{ root: state.viewport }
|
|
29
|
+
);
|
|
30
|
+
observer.observe(ref);
|
|
31
|
+
return () => {
|
|
32
|
+
observer.disconnect();
|
|
33
|
+
unregister();
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<div
|
|
39
|
+
bind:this={ref}
|
|
40
|
+
id={messageId}
|
|
41
|
+
data-slot="message-scroller-item"
|
|
42
|
+
data-message-id={messageId}
|
|
43
|
+
data-scroll-anchor={scrollAnchor ? '' : undefined}
|
|
44
|
+
class={cn(
|
|
45
|
+
'cn-message-scroller-item min-w-0 shrink-0 [contain-intrinsic-size:auto_10rem] [content-visibility:auto]',
|
|
46
|
+
className
|
|
47
|
+
)}
|
|
48
|
+
{...restProps}
|
|
49
|
+
>
|
|
50
|
+
{@render children?.()}
|
|
51
|
+
</div>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
|
+
import { type WithElementRef } from '../../../utils.js';
|
|
3
|
+
type Props = WithElementRef<HTMLAttributes<HTMLDivElement>> & {
|
|
4
|
+
messageId?: string;
|
|
5
|
+
scrollAnchor?: boolean;
|
|
6
|
+
};
|
|
7
|
+
declare const MessageScrollerItem: import("svelte").Component<Props, {}, "ref">;
|
|
8
|
+
type MessageScrollerItem = ReturnType<typeof MessageScrollerItem>;
|
|
9
|
+
export default MessageScrollerItem;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import { setMessageScroller, type ScrollPosition } from './message-scroller-context.svelte.js';
|
|
4
|
+
|
|
5
|
+
type Props = {
|
|
6
|
+
autoScroll?: boolean;
|
|
7
|
+
defaultScrollPosition?: ScrollPosition;
|
|
8
|
+
preserveScrollOnPrepend?: boolean;
|
|
9
|
+
scrollPreviousItemPeek?: number;
|
|
10
|
+
children?: Snippet;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
let {
|
|
14
|
+
autoScroll = false,
|
|
15
|
+
defaultScrollPosition = 'last-anchor',
|
|
16
|
+
preserveScrollOnPrepend = true,
|
|
17
|
+
scrollPreviousItemPeek = 64,
|
|
18
|
+
children
|
|
19
|
+
}: Props = $props();
|
|
20
|
+
|
|
21
|
+
const state = setMessageScroller({
|
|
22
|
+
autoScroll: false,
|
|
23
|
+
defaultScrollPosition: 'last-anchor',
|
|
24
|
+
preserveScrollOnPrepend: true,
|
|
25
|
+
scrollPreviousItemPeek: 64
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
$effect(() => {
|
|
29
|
+
state.options = {
|
|
30
|
+
autoScroll,
|
|
31
|
+
defaultScrollPosition,
|
|
32
|
+
preserveScrollOnPrepend,
|
|
33
|
+
scrollPreviousItemPeek
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
$effect(() => () => state.destroy());
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
{@render children?.()}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import { type ScrollPosition } from './message-scroller-context.svelte.js';
|
|
3
|
+
type Props = {
|
|
4
|
+
autoScroll?: boolean;
|
|
5
|
+
defaultScrollPosition?: ScrollPosition;
|
|
6
|
+
preserveScrollOnPrepend?: boolean;
|
|
7
|
+
scrollPreviousItemPeek?: number;
|
|
8
|
+
children?: Snippet;
|
|
9
|
+
};
|
|
10
|
+
declare const MessageScrollerProvider: import("svelte").Component<Props, {}, "">;
|
|
11
|
+
type MessageScrollerProvider = ReturnType<typeof MessageScrollerProvider>;
|
|
12
|
+
export default MessageScrollerProvider;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount } from 'svelte';
|
|
3
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
4
|
+
import { cn, type WithElementRef } from '../../../utils.js';
|
|
5
|
+
import { useMessageScroller } from './message-scroller-context.svelte.js';
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
ref = $bindable(null),
|
|
9
|
+
class: className,
|
|
10
|
+
children,
|
|
11
|
+
'aria-label': ariaLabel = 'Messages',
|
|
12
|
+
...restProps
|
|
13
|
+
}: WithElementRef<HTMLAttributes<HTMLDivElement>, HTMLDivElement> = $props();
|
|
14
|
+
const state = useMessageScroller();
|
|
15
|
+
|
|
16
|
+
onMount(() => {
|
|
17
|
+
state.setViewport(ref);
|
|
18
|
+
return () => state.setViewport(null);
|
|
19
|
+
});
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
|
|
23
|
+
<div
|
|
24
|
+
bind:this={ref}
|
|
25
|
+
data-slot="message-scroller-viewport"
|
|
26
|
+
data-autoscrolling={state.autoscrolling ? '' : undefined}
|
|
27
|
+
class={cn(
|
|
28
|
+
'cn-message-scroller-viewport scroll-fade-b size-full min-h-0 min-w-0 scrollbar-thin scrollbar-gutter-stable overflow-y-auto overscroll-contain contain-content data-autoscrolling:scrollbar-thumb-transparent data-autoscrolling:scrollbar-track-transparent',
|
|
29
|
+
className
|
|
30
|
+
)}
|
|
31
|
+
role="region"
|
|
32
|
+
aria-label={ariaLabel}
|
|
33
|
+
tabindex="0"
|
|
34
|
+
onscroll={(event) => state.handleScroll(event.isTrusted)}
|
|
35
|
+
onwheel={() => state.releaseFollow()}
|
|
36
|
+
ontouchstart={() => state.releaseFollow()}
|
|
37
|
+
onpointerdown={() => state.releaseFollow()}
|
|
38
|
+
onkeydown={(event) => {
|
|
39
|
+
if (['ArrowUp', 'ArrowDown', 'PageUp', 'PageDown', 'Home', 'End', ' '].includes(event.key)) {
|
|
40
|
+
state.releaseFollow();
|
|
41
|
+
}
|
|
42
|
+
}}
|
|
43
|
+
{...restProps}
|
|
44
|
+
>
|
|
45
|
+
{@render children?.()}
|
|
46
|
+
</div>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
|
+
import { type WithElementRef } from '../../../utils.js';
|
|
3
|
+
declare const MessageScrollerViewport: import("svelte").Component<WithElementRef<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}, "ref">;
|
|
4
|
+
type MessageScrollerViewport = ReturnType<typeof MessageScrollerViewport>;
|
|
5
|
+
export default MessageScrollerViewport;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import { cn, type WithElementRef } from '../../../utils.js';
|
|
4
|
+
import { useMessageScroller } from './message-scroller-context.svelte.js';
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
ref = $bindable(null),
|
|
8
|
+
class: className,
|
|
9
|
+
children,
|
|
10
|
+
...restProps
|
|
11
|
+
}: WithElementRef<HTMLAttributes<HTMLDivElement>> = $props();
|
|
12
|
+
const state = useMessageScroller();
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<div
|
|
16
|
+
bind:this={ref}
|
|
17
|
+
data-slot="message-scroller"
|
|
18
|
+
data-autoscrolling={state.autoscrolling ? '' : undefined}
|
|
19
|
+
data-scrollable={state.canScrollStart || state.canScrollEnd ? '' : undefined}
|
|
20
|
+
class={cn(
|
|
21
|
+
'cn-message-scroller group/message-scroller relative flex size-full min-h-0 flex-col overflow-hidden',
|
|
22
|
+
className
|
|
23
|
+
)}
|
|
24
|
+
{...restProps}
|
|
25
|
+
>
|
|
26
|
+
{@render children?.()}
|
|
27
|
+
</div>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
|
+
import { type WithElementRef } from '../../../utils.js';
|
|
3
|
+
declare const MessageScroller: import("svelte").Component<WithElementRef<HTMLAttributes<HTMLDivElement>>, {}, "ref">;
|
|
4
|
+
type MessageScroller = ReturnType<typeof MessageScroller>;
|
|
5
|
+
export default MessageScroller;
|
|
@@ -21,6 +21,15 @@ class SidebarState {
|
|
|
21
21
|
// Event handler to apply to the `<svelte:window>`
|
|
22
22
|
handleShortcutKeydown = (e) => {
|
|
23
23
|
if (e.key === SIDEBAR_KEYBOARD_SHORTCUT && (e.metaKey || e.ctrlKey)) {
|
|
24
|
+
// Don't steal the shortcut while the user is typing in an editable field —
|
|
25
|
+
// Cmd/Ctrl+B is bold in the rich-text editor, and this global toggle would
|
|
26
|
+
// otherwise fire alongside it. Bail for inputs, textareas, and any
|
|
27
|
+
// contenteditable (ProseMirror) surface.
|
|
28
|
+
const target = e.target;
|
|
29
|
+
if (target instanceof HTMLElement &&
|
|
30
|
+
(target.isContentEditable || target.closest('input, textarea, [contenteditable="true"]'))) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
24
33
|
e.preventDefault();
|
|
25
34
|
this.toggle();
|
|
26
35
|
}
|
|
@@ -2,7 +2,7 @@ declare const SidebarInput: import("svelte").Component<(Omit<import("svelte/elem
|
|
|
2
2
|
type: "file";
|
|
3
3
|
files?: FileList;
|
|
4
4
|
} | {
|
|
5
|
-
type?: "number" | "hidden" | "color" | "
|
|
5
|
+
type?: "number" | "hidden" | "color" | "button" | "search" | "time" | "image" | "text" | "submit" | "reset" | (string & {}) | "checkbox" | "radio" | "tel" | "url" | "email" | "date" | "datetime-local" | "month" | "password" | "range" | "week";
|
|
6
6
|
files?: undefined;
|
|
7
7
|
})) & {
|
|
8
8
|
ref?: HTMLElement | null | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aphexcms/ui",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4",
|
|
4
4
|
"description": "Shared UI components for Aphex CMS (shadcn-svelte)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -25,6 +25,11 @@
|
|
|
25
25
|
"svelte": "./dist/components/ui/alert-dialog/index.js",
|
|
26
26
|
"default": "./dist/components/ui/alert-dialog/index.js"
|
|
27
27
|
},
|
|
28
|
+
"./shadcn/attachment": {
|
|
29
|
+
"types": "./dist/components/ui/attachment/index.d.ts",
|
|
30
|
+
"svelte": "./dist/components/ui/attachment/index.js",
|
|
31
|
+
"default": "./dist/components/ui/attachment/index.js"
|
|
32
|
+
},
|
|
28
33
|
"./shadcn/avatar": {
|
|
29
34
|
"types": "./dist/components/ui/avatar/index.d.ts",
|
|
30
35
|
"svelte": "./dist/components/ui/avatar/index.js",
|
|
@@ -40,11 +45,21 @@
|
|
|
40
45
|
"svelte": "./dist/components/ui/breadcrumb/index.js",
|
|
41
46
|
"default": "./dist/components/ui/breadcrumb/index.js"
|
|
42
47
|
},
|
|
48
|
+
"./shadcn/bubble": {
|
|
49
|
+
"types": "./dist/components/ui/bubble/index.d.ts",
|
|
50
|
+
"svelte": "./dist/components/ui/bubble/index.js",
|
|
51
|
+
"default": "./dist/components/ui/bubble/index.js"
|
|
52
|
+
},
|
|
43
53
|
"./shadcn/button": {
|
|
44
54
|
"types": "./dist/components/ui/button/index.d.ts",
|
|
45
55
|
"svelte": "./dist/components/ui/button/index.js",
|
|
46
56
|
"default": "./dist/components/ui/button/index.js"
|
|
47
57
|
},
|
|
58
|
+
"./shadcn/button-group": {
|
|
59
|
+
"types": "./dist/components/ui/button-group/index.d.ts",
|
|
60
|
+
"svelte": "./dist/components/ui/button-group/index.js",
|
|
61
|
+
"default": "./dist/components/ui/button-group/index.js"
|
|
62
|
+
},
|
|
48
63
|
"./shadcn/calendar": {
|
|
49
64
|
"types": "./dist/components/ui/calendar/index.d.ts",
|
|
50
65
|
"svelte": "./dist/components/ui/calendar/index.js",
|
|
@@ -90,6 +105,21 @@
|
|
|
90
105
|
"svelte": "./dist/components/ui/label/index.js",
|
|
91
106
|
"default": "./dist/components/ui/label/index.js"
|
|
92
107
|
},
|
|
108
|
+
"./shadcn/marker": {
|
|
109
|
+
"types": "./dist/components/ui/marker/index.d.ts",
|
|
110
|
+
"svelte": "./dist/components/ui/marker/index.js",
|
|
111
|
+
"default": "./dist/components/ui/marker/index.js"
|
|
112
|
+
},
|
|
113
|
+
"./shadcn/message": {
|
|
114
|
+
"types": "./dist/components/ui/message/index.d.ts",
|
|
115
|
+
"svelte": "./dist/components/ui/message/index.js",
|
|
116
|
+
"default": "./dist/components/ui/message/index.js"
|
|
117
|
+
},
|
|
118
|
+
"./shadcn/message-scroller": {
|
|
119
|
+
"types": "./dist/components/ui/message-scroller/index.d.ts",
|
|
120
|
+
"svelte": "./dist/components/ui/message-scroller/index.js",
|
|
121
|
+
"default": "./dist/components/ui/message-scroller/index.js"
|
|
122
|
+
},
|
|
93
123
|
"./shadcn/popover": {
|
|
94
124
|
"types": "./dist/components/ui/popover/index.d.ts",
|
|
95
125
|
"svelte": "./dist/components/ui/popover/index.js",
|
|
@@ -177,8 +207,8 @@
|
|
|
177
207
|
"@lucide/svelte": "^0.561.0",
|
|
178
208
|
"@sveltejs/kit": "^2.59.1",
|
|
179
209
|
"@sveltejs/package": "^2.5.6",
|
|
180
|
-
"@sveltejs/vite-plugin-svelte": "^
|
|
181
|
-
"@tailwindcss/vite": "^4.
|
|
210
|
+
"@sveltejs/vite-plugin-svelte": "^7.0.0",
|
|
211
|
+
"@tailwindcss/vite": "^4.3.0",
|
|
182
212
|
"bits-ui": "^2.18.1",
|
|
183
213
|
"clsx": "^2.1.1",
|
|
184
214
|
"mode-watcher": "^1.1.0",
|
|
@@ -186,10 +216,10 @@
|
|
|
186
216
|
"svelte-sonner": "^1.0.7",
|
|
187
217
|
"tailwind-merge": "^3.4.0",
|
|
188
218
|
"tailwind-variants": "^3.2.2",
|
|
189
|
-
"tailwindcss": "^4.
|
|
219
|
+
"tailwindcss": "^4.3.0",
|
|
190
220
|
"tw-animate-css": "^1.4.0",
|
|
191
221
|
"typescript": "^5.9.3",
|
|
192
|
-
"vite": "^
|
|
222
|
+
"vite": "^8.1.5"
|
|
193
223
|
},
|
|
194
224
|
"scripts": {
|
|
195
225
|
"dev": "svelte-package --watch",
|