@knitify/vue 0.0.9 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +111 -0
- package/dist/index.es.js +4490 -221
- package/dist/index.umd.js +1 -1
- package/dist/types/components/Accordion/KAccordion.vue.d.ts +11 -0
- package/dist/types/components/Accordion/KAccordionItem.vue.d.ts +22 -0
- package/dist/types/components/Accordion/keys.d.ts +2 -0
- package/dist/types/components/Accordion/types.d.ts +37 -0
- package/dist/types/components/Alert/KAlert.vue.d.ts +11 -0
- package/dist/types/components/Alert/types.d.ts +18 -0
- package/dist/types/components/Avatar/KAvatar.vue.d.ts +15 -0
- package/dist/types/components/Avatar/KAvatarGroup.vue.d.ts +11 -0
- package/dist/types/components/Avatar/types.d.ts +130 -0
- package/dist/types/components/Badge/types.d.ts +2 -0
- package/dist/types/components/Breadcrumb/KBreadcrumb.vue.d.ts +11 -0
- package/dist/types/components/Breadcrumb/KBreadcrumbItem.vue.d.ts +11 -0
- package/dist/types/components/Breadcrumb/types.d.ts +23 -0
- package/dist/types/components/Button/types.d.ts +15 -4
- package/dist/types/components/Calendar/KCalendar.vue.d.ts +34 -0
- package/dist/types/components/Calendar/types.d.ts +26 -0
- package/dist/types/components/Card/KCard.vue.d.ts +11 -0
- package/dist/types/components/Card/types.d.ts +26 -0
- package/dist/types/components/Chat/KChat.vue.d.ts +14 -0
- package/dist/types/components/Chat/KChatDivider.vue.d.ts +11 -0
- package/dist/types/components/Chat/KChatMessage.vue.d.ts +11 -0
- package/dist/types/components/Chat/KChatMessageActions.vue.d.ts +18 -0
- package/dist/types/components/Chat/KChatMessages.vue.d.ts +11 -0
- package/dist/types/components/Chat/KChatNotice.vue.d.ts +11 -0
- package/dist/types/components/Chat/KChatPrompt.vue.d.ts +30 -0
- package/dist/types/components/Chat/KChatShimmer.vue.d.ts +11 -0
- package/dist/types/components/Chat/keys.d.ts +2 -0
- package/dist/types/components/Chat/types.d.ts +140 -0
- package/dist/types/components/ChatDock/KChatDock.vue.d.ts +45 -0
- package/dist/types/components/ChatDock/KChatDockItem.vue.d.ts +11 -0
- package/dist/types/components/ChatDock/KChatDockPanel.vue.d.ts +11 -0
- package/dist/types/components/ChatDock/KChatWindow.vue.d.ts +27 -0
- package/dist/types/components/ChatDock/KMessenger.vue.d.ts +23 -0
- package/dist/types/components/ChatDock/keys.d.ts +98 -0
- package/dist/types/components/ChatDock/messenger-types.d.ts +280 -0
- package/dist/types/components/ChatDock/store-keys.d.ts +7 -0
- package/dist/types/components/ChatDock/types.d.ts +134 -0
- package/dist/types/components/ChatDock/useChatDock.d.ts +11 -0
- package/dist/types/components/Checkbox/KCheckbox.vue.d.ts +20 -0
- package/dist/types/components/Checkbox/types.d.ts +23 -0
- package/dist/types/components/Collapse/KCollapse.vue.d.ts +32 -0
- package/dist/types/components/Collapse/types.d.ts +32 -0
- package/dist/types/components/Collapse/useCollapseSync.d.ts +31 -0
- package/dist/types/components/Drawer/KDrawer.vue.d.ts +34 -0
- package/dist/types/components/Drawer/types.d.ts +54 -0
- package/dist/types/components/Dropdown/KDropdown.vue.d.ts +28 -0
- package/dist/types/components/Dropdown/KDropdownItem.vue.d.ts +13 -0
- package/dist/types/components/Dropdown/KDropdownMenu.vue.d.ts +13 -0
- package/dist/types/components/Dropdown/types.d.ts +34 -0
- package/dist/types/components/FileTree/KFileTree.vue.d.ts +34 -0
- package/dist/types/components/FileTree/KFileTreeNode.vue.d.ts +20 -0
- package/dist/types/components/FileTree/types.d.ts +39 -0
- package/dist/types/components/Grid/KGrid.vue.d.ts +11 -0
- package/dist/types/components/Grid/KGridColumn.vue.d.ts +11 -0
- package/dist/types/components/Grid/KGridRow.vue.d.ts +19 -0
- package/dist/types/components/Grid/types.d.ts +41 -0
- package/dist/types/components/Grid/useGrid.d.ts +8 -0
- package/dist/types/components/Icon/types.d.ts +1 -1
- package/dist/types/components/Input/KInput.vue.d.ts +3 -1
- package/dist/types/components/Input/types.d.ts +8 -0
- package/dist/types/components/MenuList/KMenuList.vue.d.ts +11 -0
- package/dist/types/components/MenuList/KMenuListItem.vue.d.ts +11 -0
- package/dist/types/components/MenuList/types.d.ts +20 -0
- package/dist/types/components/Modal/KModal.vue.d.ts +36 -0
- package/dist/types/components/Modal/types.d.ts +57 -0
- package/dist/types/components/NotificationList/KNotificationList.vue.d.ts +11 -0
- package/dist/types/components/NotificationList/KNotificationListItem.vue.d.ts +11 -0
- package/dist/types/components/NotificationList/types.d.ts +36 -0
- package/dist/types/components/Popover/KPopover.vue.d.ts +28 -0
- package/dist/types/components/Popover/types.d.ts +24 -0
- package/dist/types/components/Popover/useOverlaySync.d.ts +49 -0
- package/dist/types/components/Progress/KProgress.vue.d.ts +11 -0
- package/dist/types/components/Progress/types.d.ts +19 -0
- package/dist/types/components/Radio/KRadio.vue.d.ts +20 -0
- package/dist/types/components/Radio/types.d.ts +20 -0
- package/dist/types/components/Select/KSelect.vue.d.ts +22 -0
- package/dist/types/components/Select/types.d.ts +30 -0
- package/dist/types/components/Spinner/KSpinner.vue.d.ts +6 -0
- package/dist/types/components/Spinner/types.d.ts +13 -0
- package/dist/types/components/Table/KTable.vue.d.ts +11 -0
- package/dist/types/components/Table/types.d.ts +16 -0
- package/dist/types/components/Tabs/KTab.vue.d.ts +13 -0
- package/dist/types/components/Tabs/KTabPanel.vue.d.ts +13 -0
- package/dist/types/components/Tabs/KTabs.vue.d.ts +25 -0
- package/dist/types/components/Tabs/types.d.ts +35 -0
- package/dist/types/components/Toast/types.d.ts +20 -0
- package/dist/types/components/Toast/useToast.d.ts +20 -0
- package/dist/types/components/Toggle/KToggle.vue.d.ts +20 -0
- package/dist/types/components/Toggle/types.d.ts +8 -0
- package/dist/types/components/Tooltip/KTooltip.vue.d.ts +45 -0
- package/dist/types/components/Tooltip/types.d.ts +18 -0
- package/dist/types/components/Workspace/KWorkspace.vue.d.ts +30 -0
- package/dist/types/components/Workspace/types.d.ts +29 -0
- package/dist/types/components/index.d.ts +56 -0
- package/dist/types/components/types.d.ts +31 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/types.d.ts +1 -0
- package/dist/types/utils/useDocumentEvent.d.ts +19 -0
- package/dist/types/utils/useExclusive.d.ts +13 -0
- package/dist/types/utils/useTopmost.d.ts +17 -0
- package/dist/web-types.json +5107 -0
- package/package.json +22 -6
- package/dist/types/stories/KBadge.stories.d.ts +0 -104
- package/dist/types/stories/KButton.stories.d.ts +0 -117
- package/dist/types/stories/KContainer.stories.d.ts +0 -84
- package/dist/types/stories/KInput.stories.d.ts +0 -172
- package/dist/types/stories/KNavbar.stories.d.ts +0 -67
- package/dist/types/stories/KNavbarMenu.stories.d.ts +0 -99
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import type { ComputedRef, Ref } from 'vue';
|
|
2
|
+
export type ChatConversation = {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
/** Image URL; the avatar falls back to initials from `name`. */
|
|
6
|
+
avatar?: string;
|
|
7
|
+
/** Last message line, shown in the panel row. */
|
|
8
|
+
preview?: string;
|
|
9
|
+
unread?: number;
|
|
10
|
+
/** ISO timestamp; when present the panel sorts newest first. */
|
|
11
|
+
updatedAt?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Untouched by the store — carry app-specific payload through to the slots.
|
|
14
|
+
* Replaced, not merged, when `refreshConversations` returns a conversation
|
|
15
|
+
* that carries one: the merge is a shallow spread.
|
|
16
|
+
*/
|
|
17
|
+
meta?: unknown;
|
|
18
|
+
};
|
|
19
|
+
export type ChatMessage = {
|
|
20
|
+
id: string;
|
|
21
|
+
conversationId: string;
|
|
22
|
+
text: string;
|
|
23
|
+
/** `true` for the current user; drives `KChatMessage`'s `sender`. */
|
|
24
|
+
sender: boolean;
|
|
25
|
+
/** Display string, e.g. "10:42 AM". */
|
|
26
|
+
time?: string;
|
|
27
|
+
/** ISO timestamp, for ordering by the server. */
|
|
28
|
+
sentAt?: string;
|
|
29
|
+
/** Optimistic send in flight; cleared when `sendMessage` resolves. */
|
|
30
|
+
pending?: boolean;
|
|
31
|
+
/** `sendMessage` rejected; the message shows a retry control. */
|
|
32
|
+
failed?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Untouched by the store — carry app-specific payload through to the slots.
|
|
35
|
+
* An optimistic message created by `send()` has none; the message returned
|
|
36
|
+
* by `sendMessage` replaces it wholesale, so `meta` appears when the server
|
|
37
|
+
* response does.
|
|
38
|
+
*/
|
|
39
|
+
meta?: unknown;
|
|
40
|
+
};
|
|
41
|
+
export type ChatMessagesPage = {
|
|
42
|
+
messages: ChatMessage[];
|
|
43
|
+
/** `null` or `undefined` means there is nothing older. */
|
|
44
|
+
nextCursor?: string | null;
|
|
45
|
+
};
|
|
46
|
+
export type ChatDockLoaders = {
|
|
47
|
+
loadConversations: () => Promise<ChatConversation[]>;
|
|
48
|
+
/** Chronological within the page (oldest first). `cursor` asks for older. */
|
|
49
|
+
loadMessages: (id: string, cursor?: string) => Promise<ChatMessagesPage>;
|
|
50
|
+
/** Optional; without it the composer is hidden. */
|
|
51
|
+
sendMessage?: (id: string, text: string) => Promise<ChatMessage>;
|
|
52
|
+
/** Optional; called when a window expands. Unread is zeroed locally either way. */
|
|
53
|
+
markRead?: (id: string) => Promise<void>;
|
|
54
|
+
};
|
|
55
|
+
export type ChatDockOptions = {
|
|
56
|
+
/** Drop messages, cursor and draft when a window closes. Default `false`. */
|
|
57
|
+
evictOnClose?: boolean;
|
|
58
|
+
};
|
|
59
|
+
export type ChatWindowState = 'closed' | 'expanded' | 'railed';
|
|
60
|
+
export type LoadState = 'idle' | 'loading' | 'loaded' | 'error';
|
|
61
|
+
export type ChatEntry = {
|
|
62
|
+
conversation: ChatConversation;
|
|
63
|
+
window: ChatWindowState;
|
|
64
|
+
messages: ChatMessage[];
|
|
65
|
+
/** `undefined` until the first page loads; `null` when nothing older exists. */
|
|
66
|
+
cursor: string | null | undefined;
|
|
67
|
+
loading: LoadState;
|
|
68
|
+
loadingOlder: boolean;
|
|
69
|
+
error?: unknown;
|
|
70
|
+
draft: string;
|
|
71
|
+
};
|
|
72
|
+
export type ChatDockErrorKind = 'conversations' | 'messages' | 'send';
|
|
73
|
+
export type ChatDockStore = {
|
|
74
|
+
/** Sorted newest first when `updatedAt` is present on every entry. */
|
|
75
|
+
conversations: ComputedRef<ChatConversation[]>;
|
|
76
|
+
entries: Record<string, ChatEntry>;
|
|
77
|
+
/** Ids whose window is not `'closed'`, most recently opened first. */
|
|
78
|
+
openIds: ComputedRef<string[]>;
|
|
79
|
+
listLoading: Ref<LoadState>;
|
|
80
|
+
listError: Ref<unknown>;
|
|
81
|
+
query: Ref<string>;
|
|
82
|
+
/** Whether a composer can be rendered at all. */
|
|
83
|
+
canSend: boolean;
|
|
84
|
+
refreshConversations: () => Promise<void>;
|
|
85
|
+
open: (id: string) => Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* Shows a window again without treating it as a user-initiated open: no
|
|
88
|
+
* rank change, no unread reset, no `markRead`, no `'open'` event. For a
|
|
89
|
+
* reflow un-railing a window; use `open` for a real choice.
|
|
90
|
+
*/
|
|
91
|
+
expand: (id: string) => Promise<void>;
|
|
92
|
+
minimize: (id: string) => void;
|
|
93
|
+
close: (id: string) => void;
|
|
94
|
+
loadOlder: (id: string) => Promise<void>;
|
|
95
|
+
send: (id: string, text: string) => Promise<void>;
|
|
96
|
+
retry: (id: string, messageId: string) => Promise<void>;
|
|
97
|
+
retryLoad: (id: string) => Promise<void>;
|
|
98
|
+
receive: (message: ChatMessage) => void;
|
|
99
|
+
setDraft: (id: string, text: string) => void;
|
|
100
|
+
setQuery: (text: string) => void;
|
|
101
|
+
/**
|
|
102
|
+
* Fires after an action outcome, so a component can mirror it as an emit.
|
|
103
|
+
* Returns an unsubscribe function.
|
|
104
|
+
*/
|
|
105
|
+
onEvent: (listener: (event: ChatDockEvent) => void) => () => void;
|
|
106
|
+
};
|
|
107
|
+
export type ChatDockEvent = {
|
|
108
|
+
type: 'open';
|
|
109
|
+
id: string;
|
|
110
|
+
} | {
|
|
111
|
+
type: 'close';
|
|
112
|
+
id: string;
|
|
113
|
+
} | {
|
|
114
|
+
type: 'send';
|
|
115
|
+
message: ChatMessage;
|
|
116
|
+
} | {
|
|
117
|
+
type: 'receive';
|
|
118
|
+
message: ChatMessage;
|
|
119
|
+
} | {
|
|
120
|
+
type: 'error';
|
|
121
|
+
kind: ChatDockErrorKind;
|
|
122
|
+
id?: string;
|
|
123
|
+
error: unknown;
|
|
124
|
+
};
|
|
125
|
+
export type KMessengerProps = {
|
|
126
|
+
/** The component creates its own store. Exactly one of `loaders` or `store`. */
|
|
127
|
+
loaders?: ChatDockLoaders;
|
|
128
|
+
/** A store created with `useChatDock` elsewhere and shared. */
|
|
129
|
+
store?: ChatDockStore;
|
|
130
|
+
minWindows?: number;
|
|
131
|
+
title?: string;
|
|
132
|
+
placeholder?: string;
|
|
133
|
+
/** Passed to `useChatDock` when the component creates the store. */
|
|
134
|
+
evictOnClose?: boolean;
|
|
135
|
+
/**
|
|
136
|
+
* Passed to every window's `KChat`: stacks message actions under the bubble.
|
|
137
|
+
* Defaults to `true` — a dock window is too narrow to spare the width beside
|
|
138
|
+
* each bubble. Pass `false` to put them back at the side.
|
|
139
|
+
*/
|
|
140
|
+
actionsBottom?: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Called for each message with the one before it. Return a label to render
|
|
143
|
+
* a divider above that message, or `undefined` for none. `previous` is
|
|
144
|
+
* `undefined` for the first message in the list.
|
|
145
|
+
*
|
|
146
|
+
* A boundary hook, not a date hook: an app tracking its own unread boundary
|
|
147
|
+
* returns "Unread messages" there and a day label elsewhere.
|
|
148
|
+
*
|
|
149
|
+
* Called for every message on every render, so compare pre-computed day
|
|
150
|
+
* keys here rather than parsing and formatting inside the callback.
|
|
151
|
+
*/
|
|
152
|
+
dateLabel?: (message: ChatMessage, previous?: ChatMessage) => string | undefined;
|
|
153
|
+
/**
|
|
154
|
+
* Return a label to render this message as a `KChatNotice` instead of a
|
|
155
|
+
* `KChatMessage`. `undefined` renders it as a normal bubble.
|
|
156
|
+
*
|
|
157
|
+
* For an event that arrives in the same message stream as ordinary
|
|
158
|
+
* messages and is distinguished per message — "You left the meeting room",
|
|
159
|
+
* "Call ended at 01:48 PM".
|
|
160
|
+
*
|
|
161
|
+
* A notice renders no bubble, no sender side, no time and no actions row,
|
|
162
|
+
* and so no retry control either: a message carrying both `failed` and a
|
|
163
|
+
* notice label loses the way to retry it. Return `undefined` for a message
|
|
164
|
+
* still in flight. `dateLabel` still applies above a notice, so a day
|
|
165
|
+
* divider can precede one.
|
|
166
|
+
*
|
|
167
|
+
* Called for every message on every render, like `dateLabel` — read a
|
|
168
|
+
* pre-computed field here rather than deriving one inside the callback.
|
|
169
|
+
*/
|
|
170
|
+
noticeLabel?: (message: ChatMessage) => string | undefined;
|
|
171
|
+
};
|
|
172
|
+
export type KMessengerEmits = {
|
|
173
|
+
open: [id: string];
|
|
174
|
+
close: [id: string];
|
|
175
|
+
send: [message: ChatMessage];
|
|
176
|
+
receive: [message: ChatMessage];
|
|
177
|
+
error: [kind: ChatDockErrorKind, id: string | undefined, error: unknown];
|
|
178
|
+
};
|
|
179
|
+
export type KMessengerSlots = {
|
|
180
|
+
/** Inside the avatar circle of a head and a panel row. */
|
|
181
|
+
avatar?(props: {
|
|
182
|
+
conversation: ChatConversation;
|
|
183
|
+
}): any;
|
|
184
|
+
/**
|
|
185
|
+
* The window header's action area, before the minimize and close controls.
|
|
186
|
+
* `window-` prefixed because an unprefixed `title` would read as the dock's
|
|
187
|
+
* own title, which is already a prop, and `actions` would collide with the
|
|
188
|
+
* panel's.
|
|
189
|
+
*/
|
|
190
|
+
'window-actions'?(props: {
|
|
191
|
+
conversation: ChatConversation;
|
|
192
|
+
entry: ChatEntry;
|
|
193
|
+
}): any;
|
|
194
|
+
/** The window header's title text. */
|
|
195
|
+
'window-title'?(props: {
|
|
196
|
+
conversation: ChatConversation;
|
|
197
|
+
entry: ChatEntry;
|
|
198
|
+
}): any;
|
|
199
|
+
/** Inside a railed head's avatar circle. Falls back to `avatar`. */
|
|
200
|
+
head?(props: {
|
|
201
|
+
conversation: ChatConversation;
|
|
202
|
+
entry: ChatEntry;
|
|
203
|
+
}): any;
|
|
204
|
+
/** Inside a `+N` popover row's avatar. Falls back to `avatar`. */
|
|
205
|
+
row?(props: {
|
|
206
|
+
conversation: ChatConversation;
|
|
207
|
+
entry: ChatEntry;
|
|
208
|
+
}): any;
|
|
209
|
+
/** The panel header's action area, between the title and close. */
|
|
210
|
+
'panel-actions'?(): any;
|
|
211
|
+
/** The whole panel row. */
|
|
212
|
+
item?(props: {
|
|
213
|
+
conversation: ChatConversation;
|
|
214
|
+
entry: ChatEntry;
|
|
215
|
+
}): any;
|
|
216
|
+
/** One message bubble's content. */
|
|
217
|
+
message?(props: {
|
|
218
|
+
message: ChatMessage;
|
|
219
|
+
conversation: ChatConversation;
|
|
220
|
+
}): any;
|
|
221
|
+
/**
|
|
222
|
+
* The hover row beside a message's bubble — put a `KChatMessageActions`
|
|
223
|
+
* here. `message-` prefixed to match `window-actions` and `panel-actions`,
|
|
224
|
+
* which are the two headers rather than a message.
|
|
225
|
+
*
|
|
226
|
+
* Forwarded only when you pass it, so `KChatMessage`'s own empty actions
|
|
227
|
+
* rendering is unchanged otherwise. Not rendered for a message that
|
|
228
|
+
* `noticeLabel` turned into a notice.
|
|
229
|
+
*/
|
|
230
|
+
'message-actions'?(props: {
|
|
231
|
+
message: ChatMessage;
|
|
232
|
+
conversation: ChatConversation;
|
|
233
|
+
}): any;
|
|
234
|
+
/** The window footer. */
|
|
235
|
+
composer?(props: {
|
|
236
|
+
conversation: ChatConversation;
|
|
237
|
+
draft: string;
|
|
238
|
+
send: (text: string) => void;
|
|
239
|
+
setDraft: (text: string) => void;
|
|
240
|
+
}): any;
|
|
241
|
+
/** Window body while the first page loads. */
|
|
242
|
+
loading?(props: {
|
|
243
|
+
conversation: ChatConversation;
|
|
244
|
+
}): any;
|
|
245
|
+
/**
|
|
246
|
+
* The list row shown while an older page loads. Rendered inside the
|
|
247
|
+
* message `<ul>`, so its root must be an `<li>`.
|
|
248
|
+
*/
|
|
249
|
+
'loading-older'?(props: {
|
|
250
|
+
conversation: ChatConversation;
|
|
251
|
+
}): any;
|
|
252
|
+
/** Window body when the first page failed. */
|
|
253
|
+
error?(props: {
|
|
254
|
+
conversation: ChatConversation;
|
|
255
|
+
error: unknown;
|
|
256
|
+
retry: () => void;
|
|
257
|
+
}): any;
|
|
258
|
+
/** Panel text when the filter matches nothing. */
|
|
259
|
+
empty?(): any;
|
|
260
|
+
launcher?(): any;
|
|
261
|
+
/**
|
|
262
|
+
* Replaces the rendered divider while keeping `dateLabel`'s positioning.
|
|
263
|
+
* Whatever you render must be an `<li>`: it is a direct child of the
|
|
264
|
+
* message list's `<ul>`.
|
|
265
|
+
*/
|
|
266
|
+
divider?(props: {
|
|
267
|
+
label: string;
|
|
268
|
+
message: ChatMessage;
|
|
269
|
+
previous?: ChatMessage;
|
|
270
|
+
}): any;
|
|
271
|
+
/**
|
|
272
|
+
* Replaces the rendered notice while keeping `noticeLabel`'s decision.
|
|
273
|
+
* Whatever you render must be an `<li>`: it is a direct child of the
|
|
274
|
+
* message list's `<ul>`.
|
|
275
|
+
*/
|
|
276
|
+
notice?(props: {
|
|
277
|
+
label: string;
|
|
278
|
+
message: ChatMessage;
|
|
279
|
+
}): any;
|
|
280
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type InjectionKey } from 'vue';
|
|
2
|
+
import type { ChatDockStore } from './messenger-types';
|
|
3
|
+
export declare const chatDockStoreKey: InjectionKey<ChatDockStore>;
|
|
4
|
+
/** Shares a store created with `useChatDock` with the component subtree. */
|
|
5
|
+
export declare function provideChatDock(store: ChatDockStore): void;
|
|
6
|
+
/** The store an ancestor provided, or `undefined` outside one. */
|
|
7
|
+
export declare function injectChatDock(): ChatDockStore | undefined;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
export type KChatWindowState = 'expanded' | 'railed';
|
|
2
|
+
export type KChatDockProps = {
|
|
3
|
+
/**
|
|
4
|
+
* Capacity floor, so a narrow dock still shows one window rather than
|
|
5
|
+
* nothing but heads. Gap, offset and window dimensions are deliberately not
|
|
6
|
+
* props — they are the CSS variables registered on `.KChatDock`, and the
|
|
7
|
+
* module measures them back rather than being told them twice.
|
|
8
|
+
*/
|
|
9
|
+
minWindows?: number;
|
|
10
|
+
};
|
|
11
|
+
export type KChatDockEmits = {
|
|
12
|
+
reflow: [];
|
|
13
|
+
launcher: [];
|
|
14
|
+
/** After the panel opens or closes. */
|
|
15
|
+
panel: [open: boolean];
|
|
16
|
+
/** After each filter, including the reset when the panel closes. */
|
|
17
|
+
search: [query: string];
|
|
18
|
+
/**
|
|
19
|
+
* An item was picked. `opened` is `true` when the dock expanded an existing
|
|
20
|
+
* `KChatWindow` with that id itself; `false` means the app must mount one.
|
|
21
|
+
*/
|
|
22
|
+
select: [id: string, opened: boolean];
|
|
23
|
+
/**
|
|
24
|
+
* A user expanded a railed window from its head, a `+N` popover row, or the
|
|
25
|
+
* window's own toggle. Distinct from `update:state` on the window, which
|
|
26
|
+
* also fires when a reflow un-rails by capacity.
|
|
27
|
+
*/
|
|
28
|
+
activate: [id: string];
|
|
29
|
+
};
|
|
30
|
+
export type KChatDockSlots = {
|
|
31
|
+
default?(): any;
|
|
32
|
+
launcher?(): any;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* `KChatWindow` teleports its head into the dock's rail, which makes it a
|
|
36
|
+
* multi-root (Fragment) component — unlike every other component in this
|
|
37
|
+
* package. A template `ref` on it resolves `$el` to the fragment's anchor
|
|
38
|
+
* text node, not the window element, so reading DOM properties (e.g.
|
|
39
|
+
* `.classList`) off that ref will throw.
|
|
40
|
+
*/
|
|
41
|
+
export type KChatWindowProps = {
|
|
42
|
+
closable?: boolean;
|
|
43
|
+
minimizable?: boolean;
|
|
44
|
+
title?: string;
|
|
45
|
+
unread?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Links this window to its head in the rail. Core reads it from
|
|
48
|
+
* `data-kt-chat-window` to pair the two, so a window without one gets no
|
|
49
|
+
* head — which is legitimate, just headless.
|
|
50
|
+
*/
|
|
51
|
+
id?: string;
|
|
52
|
+
};
|
|
53
|
+
export type KChatWindowEmits = {
|
|
54
|
+
close: [];
|
|
55
|
+
};
|
|
56
|
+
export type KChatWindowSlots = {
|
|
57
|
+
actions?(): any;
|
|
58
|
+
/**
|
|
59
|
+
* The fallback for `head` and `row` — a railed head's circle and a `+N`
|
|
60
|
+
* popover row. It does NOT appear in an open window's header: the title
|
|
61
|
+
* already names the conversation there, and the 320px header has the
|
|
62
|
+
* minimize and close controls competing for it.
|
|
63
|
+
*/
|
|
64
|
+
avatar?(): any;
|
|
65
|
+
default?(): any;
|
|
66
|
+
/** A railed head's circle. Falls back to `avatar` when not given. */
|
|
67
|
+
head?(): any;
|
|
68
|
+
/** The popover row's avatar. Falls back to `avatar` when not given. */
|
|
69
|
+
row?(): any;
|
|
70
|
+
title?(): any;
|
|
71
|
+
};
|
|
72
|
+
export type KChatDockPanelProps = {
|
|
73
|
+
/** Header text. */
|
|
74
|
+
title?: string;
|
|
75
|
+
/** Search field placeholder. */
|
|
76
|
+
placeholder?: string;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* `KChatDockPanel` teleports into the dock's row zone, so it is multi-root
|
|
80
|
+
* like `KChatWindow`: a template `ref` on it resolves `$el` to a fragment
|
|
81
|
+
* anchor, not the panel element.
|
|
82
|
+
*/
|
|
83
|
+
export type KChatDockPanelSlots = {
|
|
84
|
+
/** `KChatDockItem`s. */
|
|
85
|
+
default?(): any;
|
|
86
|
+
/**
|
|
87
|
+
* Header controls, between the title and the close button — so close stays
|
|
88
|
+
* last in the DOM and in the tab order. Rendered only when passed.
|
|
89
|
+
*
|
|
90
|
+
* Controls here bind their own handlers. Do not put
|
|
91
|
+
* `data-kt-chat-dock-item` on anything in this slot: `KChatDock`'s root
|
|
92
|
+
* click handler routes that attribute as a conversation selection.
|
|
93
|
+
*/
|
|
94
|
+
actions?(): any;
|
|
95
|
+
/** Replaces the "No conversations found" text. */
|
|
96
|
+
empty?(): any;
|
|
97
|
+
};
|
|
98
|
+
export type KChatDockItemProps = {
|
|
99
|
+
/** Conversation id, the same page-wide id space as `KChatWindow`'s `id`. */
|
|
100
|
+
id: string;
|
|
101
|
+
name: string;
|
|
102
|
+
/** One-line last-message preview, muted and truncated. */
|
|
103
|
+
preview?: string;
|
|
104
|
+
unread?: number;
|
|
105
|
+
};
|
|
106
|
+
export type KChatDockItemSlots = {
|
|
107
|
+
/** Inside the avatar circle. Falls back to initials from `name`. */
|
|
108
|
+
avatar?(): any;
|
|
109
|
+
/**
|
|
110
|
+
* Replaces the avatar circle entirely, for an app that draws its own — a
|
|
111
|
+
* stack of participant avatars for a group, a presence dot overlaid on the
|
|
112
|
+
* photo. `avatar` fills the built-in circle; this one stands in for it, so
|
|
113
|
+
* use it instead of nesting a circle inside `KAvatar`.
|
|
114
|
+
*
|
|
115
|
+
* Like `trailing`, this renders inside the row's own `<button>`: keep the
|
|
116
|
+
* content non-interactive, or the parser closes the button early and breaks
|
|
117
|
+
* `data-kt-chat-dock-item` click routing for every row after it.
|
|
118
|
+
*/
|
|
119
|
+
media?(): any;
|
|
120
|
+
/**
|
|
121
|
+
* After the body, where the unread badge sits. Falls back to that badge, so
|
|
122
|
+
* a row that does not use this slot is unchanged. Replacing the badge does
|
|
123
|
+
* not change the row's accessible name, which still folds in `unread` —
|
|
124
|
+
* keep the two consistent or pass a matching `unread`.
|
|
125
|
+
*
|
|
126
|
+
* This slot renders inside the row's own `<button>` — non-interactive
|
|
127
|
+
* content only (a badge, a timestamp). A nested `<button>` (e.g. a mute
|
|
128
|
+
* control) is invalid HTML: the parser repairs it by closing the outer
|
|
129
|
+
* button early, corrupting the row and breaking
|
|
130
|
+
* `data-kt-chat-dock-item` click routing for everything after it. For a
|
|
131
|
+
* real control, render it outside the row instead.
|
|
132
|
+
*/
|
|
133
|
+
trailing?(): any;
|
|
134
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ChatDockLoaders, ChatDockOptions, ChatDockStore } from './messenger-types';
|
|
2
|
+
/**
|
|
3
|
+
* Owns everything about a dock's conversations except the DOM: which windows
|
|
4
|
+
* are open, each one's messages, cursor, loading state, error and draft, and
|
|
5
|
+
* every call to the app's loaders. `KMessenger` renders it; any component can
|
|
6
|
+
* hold the same instance through `provideChatDock` / `injectChatDock`.
|
|
7
|
+
*
|
|
8
|
+
* Every action is idempotent and safe before the list has loaded. None throws:
|
|
9
|
+
* a loader rejection becomes `error` / `listError` and an `'error'` event.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useChatDock(loaders: ChatDockLoaders, options?: ChatDockOptions): ChatDockStore;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { KCheckboxModel, KCheckboxProps, KCheckboxSlots } from './types';
|
|
2
|
+
type __VLS_Props = KCheckboxProps;
|
|
3
|
+
type __VLS_Slots = KCheckboxSlots;
|
|
4
|
+
type __VLS_ModelProps = {
|
|
5
|
+
modelValue?: KCheckboxModel;
|
|
6
|
+
};
|
|
7
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
8
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
9
|
+
"update:modelValue": (value: KCheckboxModel) => any;
|
|
10
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
11
|
+
"onUpdate:modelValue"?: ((value: KCheckboxModel) => any) | undefined;
|
|
12
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
13
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
14
|
+
declare const _default: typeof __VLS_export;
|
|
15
|
+
export default _default;
|
|
16
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
17
|
+
new (): {
|
|
18
|
+
$slots: S;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `boolean` for a standalone box; an array for a group, where `value` is the
|
|
3
|
+
* entry added and removed as the box is toggled.
|
|
4
|
+
*
|
|
5
|
+
* Core ships no `--error` modifier — the one in its docs helper was removed —
|
|
6
|
+
* so there is deliberately no `error` prop here.
|
|
7
|
+
*/
|
|
8
|
+
export type KCheckboxModel = boolean | unknown[];
|
|
9
|
+
export type KCheckboxProps = {
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Partially-selected, for a "select all" parent. This is a DOM property
|
|
13
|
+
* rather than an attribute, so it is written to the input imperatively.
|
|
14
|
+
*/
|
|
15
|
+
indeterminate?: boolean;
|
|
16
|
+
/** Text beside the box. The default slot overrides it; omit both for a bare box. */
|
|
17
|
+
label?: string;
|
|
18
|
+
/** The entry this box contributes when the model is an array. */
|
|
19
|
+
value?: unknown;
|
|
20
|
+
};
|
|
21
|
+
export type KCheckboxSlots = {
|
|
22
|
+
default?(): any;
|
|
23
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { KCollapseProps, KCollapseSlots } from './types';
|
|
2
|
+
type __VLS_Props = KCollapseProps;
|
|
3
|
+
type __VLS_Slots = KCollapseSlots;
|
|
4
|
+
type __VLS_ModelProps = {
|
|
5
|
+
'expanded'?: boolean;
|
|
6
|
+
};
|
|
7
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
8
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
9
|
+
toggle: () => void;
|
|
10
|
+
expand: () => boolean;
|
|
11
|
+
collapse: () => boolean;
|
|
12
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
13
|
+
expanded: () => any;
|
|
14
|
+
collapse: () => any;
|
|
15
|
+
collapsed: () => any;
|
|
16
|
+
expand: () => any;
|
|
17
|
+
"update:expanded": (value: boolean) => any;
|
|
18
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
19
|
+
onExpanded?: (() => any) | undefined;
|
|
20
|
+
onCollapse?: (() => any) | undefined;
|
|
21
|
+
onCollapsed?: (() => any) | undefined;
|
|
22
|
+
onExpand?: (() => any) | undefined;
|
|
23
|
+
"onUpdate:expanded"?: ((value: boolean) => any) | undefined;
|
|
24
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
25
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
26
|
+
declare const _default: typeof __VLS_export;
|
|
27
|
+
export default _default;
|
|
28
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
29
|
+
new (): {
|
|
30
|
+
$slots: S;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type KCollapseDirection = 'left' | 'right';
|
|
2
|
+
export type KCollapseProps = {
|
|
3
|
+
/**
|
|
4
|
+
* Which edge a horizontal collapse clips from. `right` clips from the right;
|
|
5
|
+
* `left` pins the content to the right edge, which is what a right-hand
|
|
6
|
+
* sidebar wants.
|
|
7
|
+
*/
|
|
8
|
+
direction?: KCollapseDirection;
|
|
9
|
+
/** Collapse along the inline axis rather than the block one. */
|
|
10
|
+
horizontal?: boolean;
|
|
11
|
+
/** Element to render as. */
|
|
12
|
+
tag?: string;
|
|
13
|
+
};
|
|
14
|
+
/** Mirrors core's four `kt.collapse*` events. None carries a payload. */
|
|
15
|
+
export type KCollapseEmits = {
|
|
16
|
+
collapse: [];
|
|
17
|
+
collapsed: [];
|
|
18
|
+
expand: [];
|
|
19
|
+
expanded: [];
|
|
20
|
+
};
|
|
21
|
+
export type KCollapseSlots = {
|
|
22
|
+
/** The panel that opens and closes. */
|
|
23
|
+
default?(): any;
|
|
24
|
+
/**
|
|
25
|
+
* Anything here sits outside the collapsing region. A
|
|
26
|
+
* `data-kt-collapse-toggle` element inside it is driven by core directly.
|
|
27
|
+
*/
|
|
28
|
+
toggle?(props: {
|
|
29
|
+
toggle: () => void;
|
|
30
|
+
expanded: boolean;
|
|
31
|
+
}): any;
|
|
32
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type Ref, type ShallowRef } from 'vue';
|
|
2
|
+
export type CollapseSyncOptions = {
|
|
3
|
+
direction?: () => 'left' | 'right';
|
|
4
|
+
/** The `[data-kt-collapse]` root. */
|
|
5
|
+
element: Readonly<ShallowRef<HTMLElement | null>>;
|
|
6
|
+
expanded: Ref<boolean>;
|
|
7
|
+
horizontal?: () => boolean;
|
|
8
|
+
onEvent?: (name: 'collapse' | 'collapsed' | 'expand' | 'expanded') => void;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Two-way binding between a `v-model` and core's Collapse module.
|
|
12
|
+
*
|
|
13
|
+
* `data-kt-collapse` stays on the element, so `data-kt-collapse-group` keeps
|
|
14
|
+
* working: opening one pane closes its siblings inside core's `expand()` rather
|
|
15
|
+
* than through Vue. Each sibling hears its own `kt.collapse` and updates its own
|
|
16
|
+
* model, so grouping needs no coordination here.
|
|
17
|
+
*
|
|
18
|
+
* The toggle click is bound below rather than left to core's delegated handler,
|
|
19
|
+
* so a collapse works in an app that never called `Knitify.init()`.
|
|
20
|
+
*
|
|
21
|
+
* The guard is `moduleExpanded` — which way the module is actually going —
|
|
22
|
+
* rather than a flag set around the model write. Vue 3.5 batches reactive
|
|
23
|
+
* effects, so even a `sync` watcher runs at the end of the enclosing batch,
|
|
24
|
+
* by which time a flag would already have been cleared and the watcher would
|
|
25
|
+
* re-enter the module and dispatch a second event.
|
|
26
|
+
*/
|
|
27
|
+
export declare function useCollapseSync({ direction, element, expanded, horizontal, onEvent, }: CollapseSyncOptions): {
|
|
28
|
+
collapse: () => void;
|
|
29
|
+
expand: () => void;
|
|
30
|
+
toggle: () => void;
|
|
31
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { KDrawerProps, KDrawerSlots } from './types';
|
|
2
|
+
type __VLS_Props = KDrawerProps;
|
|
3
|
+
type __VLS_Slots = KDrawerSlots;
|
|
4
|
+
declare function hide(): void;
|
|
5
|
+
type __VLS_ModelProps = {
|
|
6
|
+
'open'?: boolean;
|
|
7
|
+
};
|
|
8
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
9
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
10
|
+
show: () => boolean;
|
|
11
|
+
hide: typeof hide;
|
|
12
|
+
toggle: () => boolean;
|
|
13
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
14
|
+
"update:open": (value: boolean) => any;
|
|
15
|
+
} & {
|
|
16
|
+
shown: () => any;
|
|
17
|
+
hidden: () => any;
|
|
18
|
+
hide: () => any;
|
|
19
|
+
show: () => any;
|
|
20
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
21
|
+
onShown?: (() => any) | undefined;
|
|
22
|
+
onHidden?: (() => any) | undefined;
|
|
23
|
+
onHide?: (() => any) | undefined;
|
|
24
|
+
"onUpdate:open"?: ((value: boolean) => any) | undefined;
|
|
25
|
+
onShow?: (() => any) | undefined;
|
|
26
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
27
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
28
|
+
declare const _default: typeof __VLS_export;
|
|
29
|
+
export default _default;
|
|
30
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
31
|
+
new (): {
|
|
32
|
+
$slots: S;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { ClassValue } from 'vue';
|
|
2
|
+
export type KDrawerEdge = 'left' | 'right';
|
|
3
|
+
/** `md` is core's default and emits no modifier class. */
|
|
4
|
+
export type KDrawerSize = 'sm' | 'md' | 'lg';
|
|
5
|
+
export type KDrawerProps = {
|
|
6
|
+
bodyClass?: ClassValue;
|
|
7
|
+
/** Renders the header's dismiss button. */
|
|
8
|
+
closable?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Confine the drawer to its nearest positioned ancestor rather than the
|
|
11
|
+
* viewport. Implies `teleport: false` — moving it to `<body>` would defeat
|
|
12
|
+
* the containment.
|
|
13
|
+
*/
|
|
14
|
+
contained?: boolean;
|
|
15
|
+
/** Which side it slides in from. */
|
|
16
|
+
edge?: KDrawerEdge;
|
|
17
|
+
/**
|
|
18
|
+
* Focus the first focusable element on open. Core rebuilds its own instance
|
|
19
|
+
* for `data-kt-drawer-toggle` clicks and does not read this off the DOM, so
|
|
20
|
+
* it only applies when Vue opens the drawer.
|
|
21
|
+
*/
|
|
22
|
+
focus?: boolean;
|
|
23
|
+
footerClass?: ClassValue;
|
|
24
|
+
headerClass?: ClassValue;
|
|
25
|
+
/** Defaults to a generated id. Point `data-kt-drawer-toggle` at this. */
|
|
26
|
+
id?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Close on Escape. Honoured on both paths — the wrapper intercepts the key
|
|
29
|
+
* in the capture phase to hold core's own handler off.
|
|
30
|
+
*/
|
|
31
|
+
keyboard?: boolean;
|
|
32
|
+
/** Leaves the page behind clickable and drops the scrim. */
|
|
33
|
+
noBackdrop?: boolean;
|
|
34
|
+
panelClass?: ClassValue;
|
|
35
|
+
size?: KDrawerSize;
|
|
36
|
+
/** Ignore backdrop clicks, leaving an explicit dismiss the only way out. */
|
|
37
|
+
staticBackdrop?: boolean;
|
|
38
|
+
/** Defaults to true, except for a `contained` drawer. */
|
|
39
|
+
teleport?: boolean;
|
|
40
|
+
title?: string;
|
|
41
|
+
};
|
|
42
|
+
export type KDrawerEmits = {
|
|
43
|
+
(event: 'hide'): void;
|
|
44
|
+
(event: 'hidden'): void;
|
|
45
|
+
(event: 'show'): void;
|
|
46
|
+
(event: 'shown'): void;
|
|
47
|
+
};
|
|
48
|
+
export type KDrawerSlots = {
|
|
49
|
+
close?(): any;
|
|
50
|
+
default?(): any;
|
|
51
|
+
footer?(): any;
|
|
52
|
+
header?(): any;
|
|
53
|
+
title?(): any;
|
|
54
|
+
};
|