@konce-pt/angular 0.11.2 → 0.12.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/CHANGELOG.md +237 -0
- package/charts/src/lib/llms.txt +8 -0
- package/chat/src/lib/llms.txt +9 -0
- package/fesm2022/konce-pt-angular-charts.mjs +141 -60
- package/fesm2022/konce-pt-angular-charts.mjs.map +1 -1
- package/fesm2022/konce-pt-angular-chat.mjs +70 -18
- package/fesm2022/konce-pt-angular-chat.mjs.map +1 -1
- package/fesm2022/konce-pt-angular-icons.mjs.map +1 -1
- package/fesm2022/konce-pt-angular-map.mjs +62 -23
- package/fesm2022/konce-pt-angular-map.mjs.map +1 -1
- package/fesm2022/konce-pt-angular-roadmap.mjs +103 -17
- package/fesm2022/konce-pt-angular-roadmap.mjs.map +1 -1
- package/fesm2022/konce-pt-angular.mjs +3373 -1911
- package/fesm2022/konce-pt-angular.mjs.map +1 -1
- package/map/src/lib/llms.txt +1 -0
- package/package.json +11 -11
- package/roadmap/src/lib/llms.txt +11 -1
- package/src/lib/alert/llms.txt +1 -0
- package/src/lib/app-shell/llms.txt +3 -2
- package/src/lib/auth/llms.txt +6 -2
- package/src/lib/autocomplete/llms.txt +3 -0
- package/src/lib/bottom-sheet/llms.txt +3 -0
- package/src/lib/breadcrumb/llms.txt +8 -0
- package/src/lib/button-group/llms.txt +4 -1
- package/src/lib/checkbox/llms.txt +3 -0
- package/src/lib/chips-input/llms.txt +3 -0
- package/src/lib/color-picker/llms.txt +3 -0
- package/src/lib/confirm/llms.txt +6 -0
- package/src/lib/context-menu/llms.txt +3 -0
- package/src/lib/data-table/llms.txt +22 -10
- package/src/lib/date-range/llms.txt +20 -1
- package/src/lib/datepicker/llms.txt +21 -4
- package/src/lib/dialog/llms.txt +3 -0
- package/src/lib/divider/llms.txt +1 -0
- package/src/lib/drawer/llms.txt +3 -0
- package/src/lib/file-upload/llms.txt +3 -0
- package/src/lib/i18n/llms.txt +7 -0
- package/src/lib/icon/llms.txt +1 -1
- package/src/lib/input-mask/llms.txt +3 -0
- package/src/lib/input-number/llms.txt +5 -2
- package/src/lib/input-otp/llms.txt +11 -0
- package/src/lib/knob/llms.txt +4 -2
- package/src/lib/listbox/llms.txt +3 -0
- package/src/lib/megamenu/llms.txt +11 -0
- package/src/lib/menubar/llms.txt +11 -0
- package/src/lib/order-list/llms.txt +3 -0
- package/src/lib/password/llms.txt +5 -1
- package/src/lib/peek/llms.txt +1 -1
- package/src/lib/pick-list/llms.txt +3 -0
- package/src/lib/popover/llms.txt +3 -0
- package/src/lib/radio-group/llms.txt +3 -0
- package/src/lib/rich-text/llms.txt +13 -0
- package/src/lib/select/llms.txt +3 -0
- package/src/lib/slider/llms.txt +3 -0
- package/src/lib/stepper/llms.txt +3 -0
- package/src/lib/switch/llms.txt +3 -0
- package/src/lib/switch-group/llms.txt +3 -0
- package/src/lib/tabs/llms.txt +3 -0
- package/src/lib/toast/llms.txt +3 -0
- package/src/lib/tooltip/llms.txt +4 -1
- package/src/lib/tree/llms.txt +1 -0
- package/types/konce-pt-angular-charts.d.ts +11 -0
- package/types/konce-pt-angular-charts.d.ts.map +1 -1
- package/types/konce-pt-angular-chat.d.ts +16 -1
- package/types/konce-pt-angular-chat.d.ts.map +1 -1
- package/types/konce-pt-angular-map.d.ts +14 -2
- package/types/konce-pt-angular-map.d.ts.map +1 -1
- package/types/konce-pt-angular-roadmap.d.ts +26 -1
- package/types/konce-pt-angular-roadmap.d.ts.map +1 -1
- package/types/konce-pt-angular.d.ts +517 -152
- package/types/konce-pt-angular.d.ts.map +1 -1
|
@@ -2,7 +2,7 @@ import { NgTemplateOutlet } from '@angular/common';
|
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
3
|
import { input, booleanAttribute, output, inject, ElementRef, signal, computed, effect, ViewEncapsulation, ChangeDetectionStrategy, Component, contentChild, TemplateRef, viewChild, DestroyRef, afterRenderEffect, untracked, afterNextRender, model } from '@angular/core';
|
|
4
4
|
import { KptI18n, KptAvatar, KptIcon, KptIconButton, KptBadge, KptFab } from '@konce-pt/angular';
|
|
5
|
-
import { KPT_CHAT_REACTIONS, toDate, canRetry, KPT_CHAT_GROUP_GAP_MS, buildChatRows, pendingCount, chatDayIndicator } from '@konce-pt/chat';
|
|
5
|
+
import { KPT_CHAT_REACTIONS, toDate, canRetry, KPT_CHAT_GROUP_GAP_MS, buildChatRows, pendingCount, chatDayIndicator, KPT_CHAT_TYPING_THROTTLE_MS } from '@konce-pt/chat';
|
|
6
6
|
export { KPT_CHAT_GROUP_GAP_MS, KPT_CHAT_REACTIONS, buildChatRows, canRetry, chatDayIndicator, dateLabel, diffInDays, isSameDay, mergeStatus, pendingCount, replyRefFrom, startOfDay, statusRank, toDate, toggleReaction } from '@konce-pt/chat';
|
|
7
7
|
|
|
8
8
|
const _c0$3 = ["*"];
|
|
@@ -333,7 +333,7 @@ class KptChatMessage {
|
|
|
333
333
|
/** Kliknięcie w cytat — aplikacja może przewinąć listę do oryginału. */
|
|
334
334
|
this.quoted = output();
|
|
335
335
|
this.i18n = inject(KptI18n);
|
|
336
|
-
this.host = inject(
|
|
336
|
+
this.host = inject(ElementRef);
|
|
337
337
|
/** Czy wybierak reakcji jest otwarty. */
|
|
338
338
|
this.pickerOpen = signal(false, /* @ts-ignore */
|
|
339
339
|
...(ngDevMode ? [{ debugName: "pickerOpen" }] : /* istanbul ignore next */ []));
|
|
@@ -428,6 +428,8 @@ class KptChatMessage {
|
|
|
428
428
|
}
|
|
429
429
|
/** Etykieta opcji wybieraka — `like` → `chat.reactLike`. */
|
|
430
430
|
reactionLabel(option) {
|
|
431
|
+
if (option.label)
|
|
432
|
+
return option.label;
|
|
431
433
|
return this.i18n.t('chat.react' + option.kind[0].toUpperCase() + option.kind.slice(1));
|
|
432
434
|
}
|
|
433
435
|
/** Czy bieżący użytkownik dał już tę reakcję — opcja wybieraka pokazuje to przez `aria-pressed`. */
|
|
@@ -471,7 +473,7 @@ class KptChatMessage {
|
|
|
471
473
|
class: 'kpt-chat-message-host',
|
|
472
474
|
'[attr.role]': 'isSystem() ? "note" : "article"',
|
|
473
475
|
'[attr.aria-label]': 'ariaLabel()',
|
|
474
|
-
}, template: "@if (isSystem()) {\n <p class=\"kpt-chat-message__system\">{{ resolvedText() }}</p>\n} @else {\n <div class=\"kpt-chat-message__row\" [attr.data-align]=\"align()\">\n @if (align() === 'start') {\n <span class=\"kpt-chat-message__avatar\" aria-hidden=\"true\">\n @if (showAvatar()) {\n <kpt-avatar size=\"sm\" [src]=\"resolvedAuthor()?.avatar ?? null\" [name]=\"resolvedAuthor()?.name ?? ''\" />\n }\n </span>\n }\n\n <div class=\"kpt-chat-message__stack\">\n @if (showAuthor() && resolvedAuthor(); as author) {\n <span class=\"kpt-chat-message__author\">{{ author.name }}</span>\n }\n\n <div\n class=\"kpt-chat-message__bubble\"\n [attr.data-variant]=\"resolvedVariant()\"\n [attr.data-align]=\"align()\"\n [attr.data-position]=\"position()\"\n [attr.data-status]=\"resolvedStatus()\"\n [attr.data-tail]=\"hasTail() ? '' : null\"\n >\n @if (resolvedReplyTo(); as quote) {\n <button type=\"button\" class=\"kpt-chat-message__quote\" (click)=\"quoted.emit(quote)\">\n <span class=\"kpt-chat-message__quote-author\">{{ quote.author }}</span>\n <span class=\"kpt-chat-message__quote-text\">{{ quote.excerpt }}</span>\n </button>\n }\n\n @if (resolvedText()) {\n <p class=\"kpt-chat-message__text\">{{ resolvedText() }}</p>\n }\n <ng-content />\n\n @if (resolvedAttachments().length) {\n <ul class=\"kpt-chat-message__files\">\n @for (file of resolvedAttachments(); track file.id) {\n <li class=\"kpt-chat-message__file\">\n @if (file.thumbnail) {\n <img class=\"kpt-chat-message__file-thumb\" [src]=\"file.thumbnail\" [alt]=\"file.name\" />\n } @else {\n <kpt-icon name=\"paperclip\" aria-hidden=\"true\" />\n }\n <a class=\"kpt-chat-message__file-name\" [attr.href]=\"file.url ?? null\" [attr.download]=\"file.url ? file.name : null\">\n {{ file.name }}\n </a>\n @if (file.size) {\n <span class=\"kpt-chat-message__file-size\">{{ fileSize(file.size) }}</span>\n }\n </li>\n }\n </ul>\n }\n\n @if (showMeta()) {\n <span class=\"kpt-chat-message__meta\">\n @if (timeLabel()) {\n <time class=\"kpt-chat-message__time\" [attr.datetime]=\"isoTime()\">{{ timeLabel() }}</time>\n }\n @if (statusIcon(); as icon) {\n <kpt-icon class=\"kpt-chat-message__status\" [name]=\"icon\" aria-hidden=\"true\" />\n }\n </span>\n }\n\n @if (resolvedReactions().length) {\n <ul class=\"kpt-chat-message__reactions\" [attr.data-align]=\"align()\">\n @for (reaction of resolvedReactions(); track reaction.emoji) {\n <li class=\"kpt-chat-message__reaction\" [attr.data-reacted]=\"reaction.reacted ? '' : null\">\n <span aria-hidden=\"true\">{{ reaction.emoji }}</span>\n <span class=\"kpt-chat-message__reaction-count\">{{ reaction.count }}</span>\n </li>\n }\n </ul>\n }\n </div>\n </div>\n\n <span class=\"kpt-chat-message__actions\" [attr.data-open]=\"pickerOpen() ? '' : null\">\n @if (canRetry()) {\n <kpt-icon-button\n class=\"kpt-chat-message__retry\"\n size=\"sm\"\n [ariaLabel]=\"i18n.t('chat.retry')\"\n (click)=\"retry.emit()\"\n >\n <kpt-icon name=\"refresh\" />\n </kpt-icon-button>\n } @else if (actions()) {\n <kpt-icon-button size=\"sm\" [ariaLabel]=\"i18n.t('chat.replyTo', { author: resolvedAuthor()?.name ?? '' })\" (click)=\"reply.emit()\">\n <kpt-icon name=\"corner-up-left\" />\n </kpt-icon-button>\n\n <span class=\"kpt-chat-message__react\" (keydown.escape)=\"pickerOpen.set(false)\" (focusout)=\"onPickerFocusOut($event)\">\n <kpt-icon-button\n size=\"sm\"\n [ariaLabel]=\"i18n.t('chat.react')\"\n [ariaExpanded]=\"pickerOpen()\"\n (click)=\"pickerOpen.set(!pickerOpen())\"\n >\n <kpt-icon name=\"mood-smile\" />\n </kpt-icon-button>\n\n @if (pickerOpen()) {\n <span class=\"kpt-chat-message__picker\" role=\"group\" [attr.aria-label]=\"i18n.t('chat.react')\">\n @for (option of reactionOptions(); track option.kind) {\n <button\n type=\"button\"\n class=\"kpt-chat-message__pick\"\n [attr.aria-label]=\"reactionLabel(option)\"\n [attr.title]=\"reactionLabel(option)\"\n [attr.aria-pressed]=\"hasReacted(option.emoji)\"\n (click)=\"pick(option.emoji)\"\n >\n <span aria-hidden=\"true\">{{ option.emoji }}</span>\n </button>\n }\n </span>\n }\n </span>\n }\n </span>\n </div>\n}\n", styles: ["@charset \"UTF-8\";@layer kpt.components{.kpt-chat-message-host{display:block}.kpt-chat-message__system{margin:var(--kpt-space-2, .5rem) 0;text-align:center;color:var(--kpt-color-text-muted);font-size:var(--kpt-font-size-xs, .75rem)}.kpt-chat-message__row{display:flex;align-items:flex-end;gap:var(--kpt-space-2, .5rem)}.kpt-chat-message__row[data-align=end]{flex-direction:row-reverse}.kpt-chat-message__avatar{flex:0 0 2rem;align-self:flex-end}.kpt-chat-message__stack{display:flex;flex-direction:column;min-width:0;max-inline-size:min(42rem,78%)}.kpt-chat-message__author{margin-inline-start:var(--kpt-space-3, .75rem);margin-block-end:var(--kpt-space-1, .25rem);color:var(--kpt-color-text-muted);font-size:var(--kpt-font-size-xs, .75rem);font-weight:var(--kpt-font-weight-medium, 500)}.kpt-chat-message__bubble{--_bg: var(--kpt-color-muted);--_fg: var(--kpt-color-on-muted);--_radius: var(--kpt-radius-lg, .75rem);--_radius-tight: var(--kpt-radius-sm, .25rem);position:relative;padding:var(--kpt-space-2, .5rem) var(--kpt-space-3, .75rem);border-radius:var(--_radius);background:var(--_bg);color:var(--_fg);font-size:var(--kpt-font-size-sm, .875rem);line-height:var(--kpt-font-lineHeight-normal, 1.5)}.kpt-chat-message__bubble[data-variant=primary]{--_bg: var(--kpt-color-primary-subtle);--_fg: var(--kpt-color-text)}.kpt-chat-message__bubble[data-variant=solid]{--_bg: var(--kpt-color-primary);--_fg: var(--kpt-color-on-primary)}.kpt-chat-message__bubble[data-variant=ghost]{--_bg: transparent;--_fg: var(--kpt-color-text);padding-inline:0}.kpt-chat-message__bubble[data-status=failed]{--_bg: var(--kpt-color-danger-subtle);--_fg: var(--kpt-color-text);box-shadow:inset 0 0 0 var(--kpt-border-width-thin, 1px) var(--kpt-color-danger-border)}.kpt-chat-message__bubble[data-align=end][data-position=first]{border-end-end-radius:var(--_radius-tight)}.kpt-chat-message__bubble[data-align=end][data-position=middle]{border-start-end-radius:var(--_radius-tight);border-end-end-radius:var(--_radius-tight)}.kpt-chat-message__bubble[data-align=end][data-position=last]{border-start-end-radius:var(--_radius-tight)}.kpt-chat-message__bubble[data-align=start][data-position=first]{border-end-start-radius:var(--_radius-tight)}.kpt-chat-message__bubble[data-align=start][data-position=middle]{border-start-start-radius:var(--_radius-tight);border-end-start-radius:var(--_radius-tight)}.kpt-chat-message__bubble[data-align=start][data-position=last]{border-start-start-radius:var(--_radius-tight)}.kpt-chat-message__bubble[data-tail][data-align=end]{border-end-end-radius:0}.kpt-chat-message__bubble[data-tail][data-align=start]{border-end-start-radius:0}.kpt-chat-message__bubble[data-tail]:after{content:\"\";position:absolute;inset-block-end:0;inline-size:.75rem;block-size:.75rem;background:var(--_bg);-webkit-mask:radial-gradient(circle at 100% 0,transparent 0 .75rem,#000 .75rem);mask:radial-gradient(circle at 100% 0,transparent 0 .75rem,#000 .75rem)}.kpt-chat-message__bubble[data-tail][data-align=end]:after{inset-inline-end:-.5rem}.kpt-chat-message__bubble[data-tail][data-align=start]:after{inset-inline-start:-.5rem;transform:scaleX(-1)}.kpt-chat-message__bubble:has(.kpt-chat-message__reactions){margin-block-end:.875rem}.kpt-chat-message__quote{display:flex;flex-direction:column;gap:.125rem;width:100%;margin-block-end:var(--kpt-space-1, .25rem);padding:var(--kpt-space-1, .25rem) var(--kpt-space-2, .5rem);border:0;border-inline-start:2px solid var(--kpt-color-primary);border-radius:var(--kpt-radius-sm, .25rem);background:color-mix(in oklch,currentColor 8%,transparent);color:inherit;font:inherit;text-align:start;cursor:pointer}.kpt-chat-message__quote-author{font-size:var(--kpt-font-size-xs, .75rem);font-weight:var(--kpt-font-weight-semibold, 600)}.kpt-chat-message__quote-text{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;font-size:var(--kpt-font-size-xs, .75rem);opacity:.8}.kpt-chat-message__text{margin:0;white-space:pre-wrap;overflow-wrap:anywhere}.kpt-chat-message__files{display:flex;flex-direction:column;gap:var(--kpt-space-1, .25rem);margin:var(--kpt-space-2, .5rem) 0 0;padding:0;list-style:none}.kpt-chat-message__file{display:flex;align-items:center;gap:var(--kpt-space-2, .5rem);font-size:var(--kpt-font-size-xs, .75rem)}.kpt-chat-message__file-thumb{width:2rem;height:2rem;border-radius:var(--kpt-radius-sm, .25rem);object-fit:cover}.kpt-chat-message__file-name{color:inherit;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.kpt-chat-message__file-size{color:inherit;opacity:.6}.kpt-chat-message__meta{display:flex;align-items:center;justify-content:flex-end;gap:.25rem;margin-block-start:.125rem;font-size:var(--kpt-font-size-xs, .75rem);opacity:.7}.kpt-chat-message__status{font-size:.875rem}.kpt-chat-message__bubble[data-status=read] .kpt-chat-message__status{color:var(--kpt-color-primary);opacity:1}.kpt-chat-message__bubble[data-variant=solid][data-status=read] .kpt-chat-message__status{color:currentcolor}.kpt-chat-message__bubble[data-status=failed] .kpt-chat-message__status{color:var(--kpt-color-danger);opacity:1}.kpt-chat-message__reactions{position:absolute;inset-block-end:-.75rem;display:flex;gap:.25rem;margin:0;padding:0;list-style:none}.kpt-chat-message__reactions[data-align=end]{inset-inline-end:var(--kpt-space-2, .5rem)}.kpt-chat-message__reactions[data-align=start]{inset-inline-start:var(--kpt-space-2, .5rem)}.kpt-chat-message__reaction{display:inline-flex;align-items:center;gap:.125rem;padding:.0625rem .375rem;border:var(--kpt-border-width-thin, 1px) solid var(--kpt-color-border);border-radius:var(--kpt-radius-full, 9999px);background:var(--kpt-color-surface-raised);color:var(--kpt-color-text);font-size:var(--kpt-font-size-xs, .75rem);line-height:1.25;box-shadow:var(--kpt-elevation-1)}.kpt-chat-message__reaction[data-reacted]{border-color:var(--kpt-color-primary-border);background:var(--kpt-color-primary-subtle)}.kpt-chat-message__reaction-count{opacity:.7}.kpt-chat-message__actions{display:flex;flex:0 0 auto;align-items:center;gap:.125rem}.kpt-chat-message__actions .kpt-icon-button-host{opacity:0;transition:opacity var(--kpt-motion-duration-fast, .12s) var(--kpt-motion-easing-standard, ease)}.kpt-chat-message__actions .kpt-chat-message__retry{opacity:1;color:var(--kpt-color-danger)}.kpt-chat-message__row:hover .kpt-chat-message__actions .kpt-icon-button-host,.kpt-chat-message__row:focus-within .kpt-chat-message__actions .kpt-icon-button-host,.kpt-chat-message__actions[data-open] .kpt-icon-button-host{opacity:1}.kpt-chat-message__react{position:relative;display:inline-flex}.kpt-chat-message__picker{position:absolute;inset-block-end:calc(100% + var(--kpt-space-1, .25rem));inset-inline-end:0;z-index:var(--kpt-z-raised, 1);display:flex;gap:.125rem;padding:.1875rem;border:var(--kpt-border-width-thin, 1px) solid var(--kpt-color-border);border-radius:var(--kpt-radius-full, 9999px);background:var(--kpt-color-surface-raised);box-shadow:var(--kpt-elevation-2)}.kpt-chat-message__row[data-align=end] .kpt-chat-message__picker{inset-inline:0 auto}.kpt-chat-message__pick{display:inline-flex;align-items:center;justify-content:center;inline-size:1.75rem;block-size:1.75rem;padding:0;border:0;border-radius:var(--kpt-radius-full, 9999px);background:transparent;font:inherit;font-size:var(--kpt-font-size-md, 1rem);line-height:1;cursor:pointer;transition:transform var(--kpt-motion-duration-fast, .12s) var(--kpt-motion-easing-standard, ease)}.kpt-chat-message__pick:hover{background:var(--kpt-color-surface-hover);transform:scale(1.15)}.kpt-chat-message__pick:focus-visible{outline:2px solid var(--kpt-color-focus-ring);outline-offset:1px}.kpt-chat-message__pick[aria-pressed=true]{background:var(--kpt-color-primary-subtle)}@media(prefers-reduced-motion:reduce){.kpt-chat-message__actions .kpt-icon-button-host,.kpt-chat-message__pick{transition:none}.kpt-chat-message__pick:hover{transform:none}}}\n"] }]
|
|
476
|
+
}, template: "@if (isSystem()) {\n <p class=\"kpt-chat-message__system\">{{ resolvedText() }}</p>\n} @else {\n <div class=\"kpt-chat-message__row\" [attr.data-align]=\"align()\">\n @if (align() === 'start') {\n <span class=\"kpt-chat-message__avatar\" aria-hidden=\"true\">\n @if (showAvatar()) {\n <kpt-avatar size=\"sm\" [src]=\"resolvedAuthor()?.avatar ?? null\" [name]=\"resolvedAuthor()?.name ?? ''\" />\n }\n </span>\n }\n\n <div class=\"kpt-chat-message__stack\">\n @if (showAuthor() && resolvedAuthor(); as author) {\n <span class=\"kpt-chat-message__author\">{{ author.name }}</span>\n }\n\n <div\n class=\"kpt-chat-message__bubble\"\n [attr.data-variant]=\"resolvedVariant()\"\n [attr.data-align]=\"align()\"\n [attr.data-position]=\"position()\"\n [attr.data-status]=\"resolvedStatus()\"\n [attr.data-tail]=\"hasTail() ? '' : null\"\n >\n @if (resolvedReplyTo(); as quote) {\n <button type=\"button\" class=\"kpt-chat-message__quote\" (click)=\"quoted.emit(quote)\">\n <span class=\"kpt-chat-message__quote-author\">{{ quote.author }}</span>\n <span class=\"kpt-chat-message__quote-text\">{{ quote.excerpt }}</span>\n </button>\n }\n\n @if (resolvedText()) {\n <p class=\"kpt-chat-message__text\">{{ resolvedText() }}</p>\n }\n <ng-content />\n\n @if (resolvedAttachments().length) {\n <ul class=\"kpt-chat-message__files\">\n @for (file of resolvedAttachments(); track file.id) {\n <li class=\"kpt-chat-message__file\">\n @if (file.thumbnail) {\n <img class=\"kpt-chat-message__file-thumb\" [src]=\"file.thumbnail\" [alt]=\"file.name\" />\n } @else {\n <kpt-icon name=\"paperclip\" aria-hidden=\"true\" />\n }\n <a class=\"kpt-chat-message__file-name\" [attr.href]=\"file.url ?? null\" [attr.download]=\"file.url ? file.name : null\">\n {{ file.name }}\n </a>\n @if (file.size) {\n <span class=\"kpt-chat-message__file-size\">{{ fileSize(file.size) }}</span>\n }\n </li>\n }\n </ul>\n }\n\n @if (showMeta()) {\n <span class=\"kpt-chat-message__meta\">\n @if (timeLabel()) {\n <time class=\"kpt-chat-message__time\" [attr.datetime]=\"isoTime()\">{{ timeLabel() }}</time>\n }\n @if (statusIcon(); as icon) {\n <kpt-icon class=\"kpt-chat-message__status\" [name]=\"icon\" aria-hidden=\"true\" />\n }\n </span>\n }\n\n @if (resolvedReactions().length) {\n <ul class=\"kpt-chat-message__reactions\" [attr.data-align]=\"align()\">\n @for (reaction of resolvedReactions(); track reaction.emoji) {\n <li class=\"kpt-chat-message__reaction\" [attr.data-reacted]=\"reaction.reacted ? '' : null\">\n <span aria-hidden=\"true\">{{ reaction.emoji }}</span>\n <span class=\"kpt-chat-message__reaction-count\">{{ reaction.count }}</span>\n </li>\n }\n </ul>\n }\n </div>\n </div>\n\n <span class=\"kpt-chat-message__actions\" [attr.data-open]=\"pickerOpen() ? '' : null\">\n @if (canRetry()) {\n <kpt-icon-button\n class=\"kpt-chat-message__retry\"\n size=\"sm\"\n [ariaLabel]=\"i18n.t('chat.retry')\"\n (click)=\"retry.emit()\"\n >\n <kpt-icon name=\"refresh\" />\n </kpt-icon-button>\n } @else if (actions()) {\n <kpt-icon-button size=\"sm\" [ariaLabel]=\"i18n.t('chat.replyTo', { author: resolvedAuthor()?.name ?? '' })\" (click)=\"reply.emit()\">\n <kpt-icon name=\"corner-up-left\" />\n </kpt-icon-button>\n\n <!-- eslint-disable-next-line @angular-eslint/template/interactive-supports-focus -- Escape i focusout z przycisk\u00F3w wyboru reakcji, delegacja -->\n <span class=\"kpt-chat-message__react\" (keydown.escape)=\"pickerOpen.set(false)\" (focusout)=\"onPickerFocusOut($event)\">\n <kpt-icon-button\n size=\"sm\"\n [ariaLabel]=\"i18n.t('chat.react')\"\n [ariaExpanded]=\"pickerOpen()\"\n (click)=\"pickerOpen.set(!pickerOpen())\"\n >\n <kpt-icon name=\"mood-smile\" />\n </kpt-icon-button>\n\n @if (pickerOpen()) {\n <span class=\"kpt-chat-message__picker\" role=\"group\" [attr.aria-label]=\"i18n.t('chat.react')\">\n @for (option of reactionOptions(); track option.kind) {\n <button\n type=\"button\"\n class=\"kpt-chat-message__pick\"\n [attr.aria-label]=\"reactionLabel(option)\"\n [attr.title]=\"reactionLabel(option)\"\n [attr.aria-pressed]=\"hasReacted(option.emoji)\"\n (click)=\"pick(option.emoji)\"\n >\n <span aria-hidden=\"true\">{{ option.emoji }}</span>\n </button>\n }\n </span>\n }\n </span>\n }\n </span>\n </div>\n}\n", styles: ["@charset \"UTF-8\";@layer kpt.components{.kpt-chat-message-host{display:block}.kpt-chat-message__system{margin:var(--kpt-space-2, .5rem) 0;text-align:center;color:var(--kpt-color-text-muted);font-size:var(--kpt-font-size-xs, .75rem)}.kpt-chat-message__row{display:flex;align-items:flex-end;gap:var(--kpt-space-2, .5rem)}.kpt-chat-message__row[data-align=end]{flex-direction:row-reverse}.kpt-chat-message__avatar{flex:0 0 2rem;align-self:flex-end}.kpt-chat-message__stack{display:flex;flex-direction:column;min-width:0;max-inline-size:min(42rem,78%)}.kpt-chat-message__author{margin-inline-start:var(--kpt-space-3, .75rem);margin-block-end:var(--kpt-space-1, .25rem);color:var(--kpt-color-text-muted);font-size:var(--kpt-font-size-xs, .75rem);font-weight:var(--kpt-font-weight-medium, 500)}.kpt-chat-message__bubble{--_bg: var(--kpt-color-muted);--_fg: var(--kpt-color-on-muted);--_radius: var(--kpt-radius-lg, .75rem);--_radius-tight: var(--kpt-radius-sm, .25rem);position:relative;padding:var(--kpt-space-2, .5rem) var(--kpt-space-3, .75rem);border-radius:var(--_radius);background:var(--_bg);color:var(--_fg);font-size:var(--kpt-font-size-sm, .875rem);line-height:var(--kpt-font-lineHeight-normal, 1.5)}.kpt-chat-message__bubble[data-variant=primary]{--_bg: var(--kpt-color-primary-subtle);--_fg: var(--kpt-color-text)}.kpt-chat-message__bubble[data-variant=solid]{--_bg: var(--kpt-color-primary);--_fg: var(--kpt-color-on-primary)}.kpt-chat-message__bubble[data-variant=ghost]{--_bg: transparent;--_fg: var(--kpt-color-text);padding-inline:0}.kpt-chat-message__bubble[data-status=failed]{--_bg: var(--kpt-color-danger-subtle);--_fg: var(--kpt-color-text);box-shadow:inset 0 0 0 var(--kpt-border-width-thin, 1px) var(--kpt-color-danger-border)}.kpt-chat-message__bubble[data-align=end][data-position=first]{border-end-end-radius:var(--_radius-tight)}.kpt-chat-message__bubble[data-align=end][data-position=middle]{border-start-end-radius:var(--_radius-tight);border-end-end-radius:var(--_radius-tight)}.kpt-chat-message__bubble[data-align=end][data-position=last]{border-start-end-radius:var(--_radius-tight)}.kpt-chat-message__bubble[data-align=start][data-position=first]{border-end-start-radius:var(--_radius-tight)}.kpt-chat-message__bubble[data-align=start][data-position=middle]{border-start-start-radius:var(--_radius-tight);border-end-start-radius:var(--_radius-tight)}.kpt-chat-message__bubble[data-align=start][data-position=last]{border-start-start-radius:var(--_radius-tight)}.kpt-chat-message__bubble[data-tail][data-align=end]{border-end-end-radius:0}.kpt-chat-message__bubble[data-tail][data-align=start]{border-end-start-radius:0}.kpt-chat-message__bubble[data-tail]:after{content:\"\";position:absolute;inset-block-end:0;inline-size:.75rem;block-size:.75rem;background:var(--_bg);-webkit-mask:radial-gradient(circle at 100% 0,transparent 0 .75rem,#000 .75rem);mask:radial-gradient(circle at 100% 0,transparent 0 .75rem,#000 .75rem)}.kpt-chat-message__bubble[data-tail][data-align=end]:after{inset-inline-end:-.5rem}.kpt-chat-message__bubble[data-tail][data-align=start]:after{inset-inline-start:-.5rem;transform:scaleX(-1)}.kpt-chat-message__bubble:has(.kpt-chat-message__reactions){margin-block-end:.875rem}.kpt-chat-message__quote{display:flex;flex-direction:column;gap:.125rem;width:100%;margin-block-end:var(--kpt-space-1, .25rem);padding:var(--kpt-space-1, .25rem) var(--kpt-space-2, .5rem);border:0;border-inline-start:2px solid var(--kpt-color-primary);border-radius:var(--kpt-radius-sm, .25rem);background:color-mix(in oklch,currentColor 8%,transparent);color:inherit;font:inherit;text-align:start;cursor:pointer}.kpt-chat-message__quote-author{font-size:var(--kpt-font-size-xs, .75rem);font-weight:var(--kpt-font-weight-semibold, 600)}.kpt-chat-message__quote-text{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;font-size:var(--kpt-font-size-xs, .75rem);opacity:.8}.kpt-chat-message__text{margin:0;white-space:pre-wrap;overflow-wrap:anywhere}.kpt-chat-message__files{display:flex;flex-direction:column;gap:var(--kpt-space-1, .25rem);margin:var(--kpt-space-2, .5rem) 0 0;padding:0;list-style:none}.kpt-chat-message__file{display:flex;align-items:center;gap:var(--kpt-space-2, .5rem);font-size:var(--kpt-font-size-xs, .75rem)}.kpt-chat-message__file-thumb{width:2rem;height:2rem;border-radius:var(--kpt-radius-sm, .25rem);object-fit:cover}.kpt-chat-message__file-name{color:inherit;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.kpt-chat-message__file-size{color:inherit;opacity:.6}.kpt-chat-message__meta{display:flex;align-items:center;justify-content:flex-end;gap:.25rem;margin-block-start:.125rem;font-size:var(--kpt-font-size-xs, .75rem);opacity:.7}.kpt-chat-message__status{font-size:.875rem}.kpt-chat-message__bubble[data-status=read] .kpt-chat-message__status{color:var(--kpt-color-primary);opacity:1}.kpt-chat-message__bubble[data-variant=solid][data-status=read] .kpt-chat-message__status{color:currentcolor}.kpt-chat-message__bubble[data-status=failed] .kpt-chat-message__status{color:var(--kpt-color-danger);opacity:1}.kpt-chat-message__reactions{position:absolute;inset-block-end:-.75rem;display:flex;gap:.25rem;margin:0;padding:0;list-style:none}.kpt-chat-message__reactions[data-align=end]{inset-inline-end:var(--kpt-space-2, .5rem)}.kpt-chat-message__reactions[data-align=start]{inset-inline-start:var(--kpt-space-2, .5rem)}.kpt-chat-message__reaction{display:inline-flex;align-items:center;gap:.125rem;padding:.0625rem .375rem;border:var(--kpt-border-width-thin, 1px) solid var(--kpt-color-border);border-radius:var(--kpt-radius-full, 9999px);background:var(--kpt-color-surface-raised);color:var(--kpt-color-text);font-size:var(--kpt-font-size-xs, .75rem);line-height:1.25;box-shadow:var(--kpt-elevation-1)}.kpt-chat-message__reaction[data-reacted]{border-color:var(--kpt-color-primary-border);background:var(--kpt-color-primary-subtle)}.kpt-chat-message__reaction-count{opacity:.7}.kpt-chat-message__actions{display:flex;flex:0 0 auto;align-items:center;gap:.125rem}.kpt-chat-message__actions .kpt-icon-button-host{opacity:0;transition:opacity var(--kpt-motion-duration-fast, .12s) var(--kpt-motion-easing-standard, ease)}.kpt-chat-message__actions .kpt-chat-message__retry{opacity:1;color:var(--kpt-color-danger)}.kpt-chat-message__row:hover .kpt-chat-message__actions .kpt-icon-button-host,.kpt-chat-message__row:focus-within .kpt-chat-message__actions .kpt-icon-button-host,.kpt-chat-message__actions[data-open] .kpt-icon-button-host{opacity:1}.kpt-chat-message__react{position:relative;display:inline-flex}.kpt-chat-message__picker{position:absolute;inset-block-end:calc(100% + var(--kpt-space-1, .25rem));inset-inline-end:0;z-index:var(--kpt-z-raised, 1);display:flex;gap:.125rem;padding:.1875rem;border:var(--kpt-border-width-thin, 1px) solid var(--kpt-color-border);border-radius:var(--kpt-radius-full, 9999px);background:var(--kpt-color-surface-raised);box-shadow:var(--kpt-elevation-2)}.kpt-chat-message__row[data-align=end] .kpt-chat-message__picker{inset-inline:0 auto}.kpt-chat-message__pick{display:inline-flex;align-items:center;justify-content:center;inline-size:1.75rem;block-size:1.75rem;padding:0;border:0;border-radius:var(--kpt-radius-full, 9999px);background:transparent;font:inherit;font-size:var(--kpt-font-size-md, 1rem);line-height:1;cursor:pointer;transition:transform var(--kpt-motion-duration-fast, .12s) var(--kpt-motion-easing-standard, ease)}.kpt-chat-message__pick:hover{background:var(--kpt-color-surface-hover);transform:scale(1.15)}.kpt-chat-message__pick:focus-visible{outline:2px solid var(--kpt-color-focus-ring);outline-offset:1px}.kpt-chat-message__pick[aria-pressed=true]{background:var(--kpt-color-primary-subtle)}@media(prefers-reduced-motion:reduce){.kpt-chat-message__actions .kpt-icon-button-host,.kpt-chat-message__pick{transition:none}.kpt-chat-message__pick:hover{transform:none}}}\n"] }]
|
|
475
477
|
}], () => [], { message: [{ type: i0.Input, args: [{ isSignal: true, alias: "message", required: false }] }], author: [{ type: i0.Input, args: [{ isSignal: true, alias: "author", required: false }] }], text: [{ type: i0.Input, args: [{ isSignal: true, alias: "text", required: false }] }], time: [{ type: i0.Input, args: [{ isSignal: true, alias: "time", required: false }] }], attachments: [{ type: i0.Input, args: [{ isSignal: true, alias: "attachments", required: false }] }], reactions: [{ type: i0.Input, args: [{ isSignal: true, alias: "reactions", required: false }] }], replyTo: [{ type: i0.Input, args: [{ isSignal: true, alias: "replyTo", required: false }] }], status: [{ type: i0.Input, args: [{ isSignal: true, alias: "status", required: false }] }], align: [{ type: i0.Input, args: [{ isSignal: true, alias: "align", required: false }] }], variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], position: [{ type: i0.Input, args: [{ isSignal: true, alias: "position", required: false }] }], system: [{ type: i0.Input, args: [{ isSignal: true, alias: "system", required: false }] }], showAuthor: [{ type: i0.Input, args: [{ isSignal: true, alias: "showAuthor", required: false }] }], showAvatar: [{ type: i0.Input, args: [{ isSignal: true, alias: "showAvatar", required: false }] }], showMeta: [{ type: i0.Input, args: [{ isSignal: true, alias: "showMeta", required: false }] }], tail: [{ type: i0.Input, args: [{ isSignal: true, alias: "tail", required: false }] }], actions: [{ type: i0.Input, args: [{ isSignal: true, alias: "actions", required: false }] }], reactionOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "reactionOptions", required: false }] }], retry: [{ type: i0.Output, args: ["retry"] }], reply: [{ type: i0.Output, args: ["reply"] }], react: [{ type: i0.Output, args: ["react"] }], quoted: [{ type: i0.Output, args: ["quoted"] }] }); })();
|
|
476
478
|
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(KptChatMessage, { className: "KptChatMessage", filePath: "lib/chat-message.component.ts", lineNumber: 67 }); })();
|
|
477
479
|
|
|
@@ -640,16 +642,19 @@ function KptChat_For_6_Template(rf, ctx) { if (rf & 1) {
|
|
|
640
642
|
i0.ɵɵconditional((tmp_12_0 = row_r4.kind) === "date" ? 0 : tmp_12_0 === "unread" ? 1 : tmp_12_0 === "message" ? 2 : -1);
|
|
641
643
|
} }
|
|
642
644
|
function KptChat_Conditional_7_Template(rf, ctx) { if (rf & 1) {
|
|
643
|
-
i0.ɵɵ
|
|
645
|
+
i0.ɵɵelementStart(0, "div", 6);
|
|
646
|
+
i0.ɵɵelement(1, "kpt-chat-typing", 16);
|
|
647
|
+
i0.ɵɵelementEnd();
|
|
644
648
|
} if (rf & 2) {
|
|
645
649
|
const ctx_r1 = i0.ɵɵnextContext();
|
|
650
|
+
i0.ɵɵadvance();
|
|
646
651
|
i0.ɵɵproperty("authors", ctx_r1.typing());
|
|
647
652
|
} }
|
|
648
653
|
function KptChat_Conditional_11_Template(rf, ctx) { if (rf & 1) {
|
|
649
654
|
const _r6 = i0.ɵɵgetCurrentView();
|
|
650
|
-
i0.ɵɵelementStart(0, "button",
|
|
655
|
+
i0.ɵɵelementStart(0, "button", 17);
|
|
651
656
|
i0.ɵɵlistener("click", function KptChat_Conditional_11_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r6); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.jumpToLatest()); });
|
|
652
|
-
i0.ɵɵelement(1, "kpt-icon",
|
|
657
|
+
i0.ɵɵelement(1, "kpt-icon", 18);
|
|
653
658
|
i0.ɵɵtext(2);
|
|
654
659
|
i0.ɵɵelementEnd();
|
|
655
660
|
} if (rf & 2) {
|
|
@@ -683,6 +688,16 @@ const BLOCKING_ROWS = '.kpt-chat__date, .kpt-chat__unread, .kpt-chat-message__sy
|
|
|
683
688
|
* <kpt-chat [messages]="messages()" currentUser="me" [typing]="typing()" (retry)="resend($event)" />
|
|
684
689
|
*/
|
|
685
690
|
class KptChat {
|
|
691
|
+
/**
|
|
692
|
+
* Po doklejeniu historii na górze widok zostaje przy tej samej wiadomości. Przeglądarki
|
|
693
|
+
* z `overflow-anchor` robią to same; Safari go nie ma i bez tego lista skacze.
|
|
694
|
+
*/
|
|
695
|
+
keepAnchor(element) {
|
|
696
|
+
const height = element.scrollHeight;
|
|
697
|
+
if (!globalThis.CSS?.supports('overflow-anchor', 'auto'))
|
|
698
|
+
element.scrollTop += height - this.prevScrollHeight;
|
|
699
|
+
this.prevScrollHeight = height;
|
|
700
|
+
}
|
|
686
701
|
constructor() {
|
|
687
702
|
/** Wiadomości w kolejności chronologicznej — komponent ich nie sortuje. */
|
|
688
703
|
this.messages = input([], /* @ts-ignore */
|
|
@@ -740,6 +755,12 @@ class KptChat {
|
|
|
740
755
|
...(ngDevMode ? [{ debugName: "dayVisible" }] : /* istanbul ignore next */ []));
|
|
741
756
|
this.lastCount = 0;
|
|
742
757
|
this.wasAtTop = false;
|
|
758
|
+
/** Id pierwszej wiadomości — jej zmiana przy wzroście listy to dociągnięta historia. */
|
|
759
|
+
this.firstId = null;
|
|
760
|
+
/** Wysokość treści z poprzedniego renderu — do kotwiczenia przewinięcia. */
|
|
761
|
+
this.prevScrollHeight = 0;
|
|
762
|
+
/** Zaplanowany pomiar pigułki dnia — najwyżej jeden na klatkę przy przewijaniu. */
|
|
763
|
+
this.dayFrame = 0;
|
|
743
764
|
this.rows = computed(() => buildChatRows(this.messages(), {
|
|
744
765
|
currentUserId: this.currentUser(),
|
|
745
766
|
gapMs: this.groupGapMs(),
|
|
@@ -757,18 +778,29 @@ class KptChat {
|
|
|
757
778
|
if (!element)
|
|
758
779
|
return;
|
|
759
780
|
untracked(() => {
|
|
760
|
-
const
|
|
761
|
-
const
|
|
781
|
+
const messages = this.messages();
|
|
782
|
+
const count = messages.length;
|
|
783
|
+
const added = count - this.lastCount;
|
|
762
784
|
const first = this.lastCount === 0;
|
|
785
|
+
const firstId = messages[0]?.id ?? null;
|
|
786
|
+
// Starsze wiadomości doklejone na górze (`loadMore`) — nie są nowe, a widok ma zostać w miejscu.
|
|
787
|
+
const prepended = !first && added > 0 && firstId !== this.firstId;
|
|
763
788
|
this.lastCount = count;
|
|
764
|
-
|
|
789
|
+
this.firstId = firstId;
|
|
790
|
+
if (prepended) {
|
|
791
|
+
this.keepAnchor(element);
|
|
792
|
+
return;
|
|
793
|
+
}
|
|
794
|
+
this.prevScrollHeight = element.scrollHeight;
|
|
795
|
+
if (added <= 0)
|
|
765
796
|
return;
|
|
766
797
|
// Pierwsze wejście zawsze ląduje na dole — rozmowę czyta się od końca.
|
|
767
798
|
if (first || (this.autoScroll() && this.pinned())) {
|
|
768
799
|
this.scrollToBottom(first ? 'auto' : undefined);
|
|
769
800
|
}
|
|
770
801
|
else {
|
|
771
|
-
|
|
802
|
+
// Tyle, ile naprawdę przyszło — paczka pięciu wiadomości z serwera to „5 nowych”, nie „1”.
|
|
803
|
+
this.newCount.update((value) => value + added);
|
|
772
804
|
}
|
|
773
805
|
});
|
|
774
806
|
untracked(() => this.syncDay());
|
|
@@ -781,7 +813,11 @@ class KptChat {
|
|
|
781
813
|
return;
|
|
782
814
|
const observer = new ResizeObserver(() => this.syncDay());
|
|
783
815
|
observer.observe(element);
|
|
784
|
-
this.destroyRef.onDestroy(() =>
|
|
816
|
+
this.destroyRef.onDestroy(() => {
|
|
817
|
+
observer.disconnect();
|
|
818
|
+
if (this.dayFrame)
|
|
819
|
+
cancelAnimationFrame(this.dayFrame);
|
|
820
|
+
});
|
|
785
821
|
});
|
|
786
822
|
}
|
|
787
823
|
/** Przewija do najnowszej wiadomości i kasuje licznik nowych. */
|
|
@@ -802,7 +838,13 @@ class KptChat {
|
|
|
802
838
|
if (atTop && !this.wasAtTop)
|
|
803
839
|
this.loadMore.emit();
|
|
804
840
|
this.wasAtTop = atTop;
|
|
805
|
-
|
|
841
|
+
// Pomiary pigułki raz na klatkę, nie przy każdym zdarzeniu `scroll` (wymuszony układ).
|
|
842
|
+
if (this.dayFrame || typeof requestAnimationFrame === 'undefined')
|
|
843
|
+
return;
|
|
844
|
+
this.dayFrame = requestAnimationFrame(() => {
|
|
845
|
+
this.dayFrame = 0;
|
|
846
|
+
this.syncDay();
|
|
847
|
+
});
|
|
806
848
|
}
|
|
807
849
|
/**
|
|
808
850
|
* Ustawia tekst pływającej pigułki dnia — co ma na niej być, liczy `chatDayIndicator`
|
|
@@ -865,14 +907,14 @@ class KptChat {
|
|
|
865
907
|
i0.ɵɵviewQuerySignal(ctx.viewport, _c0$2, 5)(ctx.day, _c1$1, 5);
|
|
866
908
|
} if (rf & 2) {
|
|
867
909
|
i0.ɵɵqueryAdvance(2);
|
|
868
|
-
} }, hostAttrs: [1, "kpt-chat-host"], inputs: { messages: [1, "messages"], currentUser: [1, "currentUser"], groupGapMs: [1, "groupGapMs"], unreadFrom: [1, "unreadFrom"], offline: [1, "offline"], typing: [1, "typing"], autoScroll: [1, "autoScroll"], actions: [1, "actions"], reactionOptions: [1, "reactionOptions"], emptyLabel: [1, "emptyLabel"] }, outputs: { retry: "retry", reply: "reply", react: "react", quoted: "quoted", loadMore: "loadMore" }, decls: 12, vars:
|
|
910
|
+
} }, hostAttrs: [1, "kpt-chat-host"], inputs: { messages: [1, "messages"], currentUser: [1, "currentUser"], groupGapMs: [1, "groupGapMs"], unreadFrom: [1, "unreadFrom"], offline: [1, "offline"], typing: [1, "typing"], autoScroll: [1, "autoScroll"], actions: [1, "actions"], reactionOptions: [1, "reactionOptions"], emptyLabel: [1, "emptyLabel"] }, outputs: { retry: "retry", reply: "reply", react: "react", quoted: "quoted", loadMore: "loadMore" }, decls: 12, vars: 7, consts: [["viewport", ""], ["day", ""], ["role", "status", 1, "kpt-chat__offline"], [1, "kpt-chat__body"], ["role", "log", "aria-live", "polite", "aria-relevant", "additions", "tabindex", "0", 1, "kpt-chat__viewport", 3, "scroll"], [1, "kpt-chat__empty"], ["aria-live", "off"], ["aria-hidden", "true", 1, "kpt-chat__day"], ["type", "button", 1, "kpt-chat__jump"], ["name", "alert-triangle", "aria-hidden", "true"], [1, "kpt-chat__offline-count"], ["role", "separator", 1, "kpt-chat__date"], ["role", "separator", 1, "kpt-chat__unread"], [3, "message", "text", "align", "position", "showAuthor", "showAvatar", "showMeta", "actions", "reactionOptions"], [3, "retry", "reply", "react", "quoted", "message", "text", "align", "position", "showAuthor", "showAvatar", "showMeta", "actions", "reactionOptions"], [3, "ngTemplateOutlet", "ngTemplateOutletContext"], [3, "authors"], ["type", "button", 1, "kpt-chat__jump", 3, "click"], ["name", "arrow-down", "aria-hidden", "true"]], template: function KptChat_Template(rf, ctx) { if (rf & 1) {
|
|
869
911
|
const _r1 = i0.ɵɵgetCurrentView();
|
|
870
912
|
i0.ɵɵconditionalCreate(0, KptChat_Conditional_0_Template, 5, 2, "p", 2);
|
|
871
913
|
i0.ɵɵelementStart(1, "div", 3)(2, "div", 4, 0);
|
|
872
914
|
i0.ɵɵlistener("scroll", function KptChat_Template_div_scroll_2_listener() { i0.ɵɵrestoreView(_r1); const viewport_r3 = i0.ɵɵreference(3); return i0.ɵɵresetView(ctx.onScroll(viewport_r3)); });
|
|
873
915
|
i0.ɵɵconditionalCreate(4, KptChat_Conditional_4_Template, 2, 1, "p", 5);
|
|
874
916
|
i0.ɵɵrepeaterCreate(5, KptChat_For_6_Template, 3, 1, null, null, _forTrack0$1);
|
|
875
|
-
i0.ɵɵconditionalCreate(7, KptChat_Conditional_7_Template,
|
|
917
|
+
i0.ɵɵconditionalCreate(7, KptChat_Conditional_7_Template, 2, 1, "div", 6);
|
|
876
918
|
i0.ɵɵelementEnd();
|
|
877
919
|
i0.ɵɵelementStart(8, "p", 7, 1);
|
|
878
920
|
i0.ɵɵtext(10);
|
|
@@ -881,7 +923,9 @@ class KptChat {
|
|
|
881
923
|
i0.ɵɵelementEnd();
|
|
882
924
|
} if (rf & 2) {
|
|
883
925
|
i0.ɵɵconditional(ctx.offline() ? 0 : -1);
|
|
884
|
-
i0.ɵɵadvance(
|
|
926
|
+
i0.ɵɵadvance(2);
|
|
927
|
+
i0.ɵɵattribute("aria-label", ctx.i18n.t("chat.history"));
|
|
928
|
+
i0.ɵɵadvance(2);
|
|
885
929
|
i0.ɵɵconditional(!ctx.viewRows().length ? 4 : -1);
|
|
886
930
|
i0.ɵɵadvance();
|
|
887
931
|
i0.ɵɵrepeater(ctx.viewRows());
|
|
@@ -897,7 +941,7 @@ class KptChat {
|
|
|
897
941
|
}
|
|
898
942
|
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(KptChat, [{
|
|
899
943
|
type: Component,
|
|
900
|
-
args: [{ selector: 'kpt-chat', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, imports: [NgTemplateOutlet, KptChatMessage, KptChatTyping, KptIcon], host: { class: 'kpt-chat-host' }, template: "@if (offline()) {\n <p class=\"kpt-chat__offline\" role=\"status\">\n <kpt-icon name=\"alert-triangle\" aria-hidden=\"true\" />\n <span>{{ i18n.t('chat.offline') }}</span>\n @if (pending()) {\n <span class=\"kpt-chat__offline-count\">{{ i18n.t('chat.pending', { count: pending() }) }}</span>\n }\n </p>\n}\n\n<div class=\"kpt-chat__body\">\n <div\n #viewport\n class=\"kpt-chat__viewport\"\n role=\"log\"\n aria-live=\"polite\"\n aria-relevant=\"additions\"\n (scroll)=\"onScroll(viewport)\"\n >\n @if (!viewRows().length) {\n <p class=\"kpt-chat__empty\">{{ emptyLabel() || i18n.t('chat.empty') }}</p>\n }\n\n @for (row of viewRows(); track row.key) {\n @switch (row.kind) {\n @case ('date') {\n <p class=\"kpt-chat__date\" role=\"separator\" [attr.aria-label]=\"row.text\">{{ row.text }}</p>\n }\n @case ('unread') {\n <p class=\"kpt-chat__unread\" role=\"separator\" [attr.aria-label]=\"i18n.t('chat.newMessages', { count: row.count })\">\n <span>{{ i18n.t('chat.unread') }}</span>\n </p>\n }\n @case ('message') {\n <kpt-chat-message\n [message]=\"row.message\"\n [text]=\"messageTpl() ? '' : null\"\n [align]=\"row.own ? 'end' : 'start'\"\n [position]=\"row.position\"\n [showAuthor]=\"row.showAuthor\"\n [showAvatar]=\"row.showAvatar\"\n [showMeta]=\"row.showMeta\"\n [actions]=\"actions()\"\n [reactionOptions]=\"reactionOptions()\"\n (retry)=\"retry.emit(row.message)\"\n (reply)=\"reply.emit(row.message)\"\n (react)=\"react.emit({ message: row.message, emoji: $event })\"\n (quoted)=\"quoted.emit($event)\"\n >\n @if (messageTpl(); as tpl) {\n <ng-container [ngTemplateOutlet]=\"tpl\" [ngTemplateOutletContext]=\"{ $implicit: row.message, row: row }\" />\n }\n </kpt-chat-message>\n }\n }\n }\n\n @if (typing().length) {\n <kpt-chat-typing [authors]=\"typing()\" />\n }\n </div>\n\n <!-- Pigu\u0142ka dnia wisi nad list\u0105, a nie w niej: w li\u015Bcie jad\u0105 separatory z `role=\"separator\"`,\n wi\u0119c dla czytnika ekranu jest tylko ich wizualnym echem \u2014 st\u0105d `aria-hidden`. W DOM stoi\n zawsze, bo skrypt musi umie\u0107 zmierzy\u0107 jej pas tak\u017Ce wtedy, gdy jest zgaszona. -->\n <p #day class=\"kpt-chat__day\" aria-hidden=\"true\" [attr.data-hidden]=\"dayVisible() ? null : ''\">{{ dayLabel() }}</p>\n\n @if (newCount()) {\n <button type=\"button\" class=\"kpt-chat__jump\" (click)=\"jumpToLatest()\">\n <kpt-icon name=\"arrow-down\" aria-hidden=\"true\" />\n {{ i18n.t('chat.newMessages', { count: newCount() }) }}\n </button>\n }\n</div>\n", styles: ["@charset \"UTF-8\";@layer kpt.components{.kpt-chat-host{--_gap: var(--kpt-space-1, .25rem);--_group-gap: var(--kpt-space-4, 1rem);display:flex;flex-direction:column;min-height:0;background:var(--kpt-color-surface);color:var(--kpt-color-text)}.kpt-chat__offline{display:flex;align-items:center;gap:var(--kpt-space-2, .5rem);margin:0;padding:var(--kpt-space-2, .5rem) var(--kpt-space-3, .75rem);border-block-end:var(--kpt-border-width-thin, 1px) solid var(--kpt-color-warning-border);background:var(--kpt-color-warning-subtle);color:var(--kpt-color-text);font-size:var(--kpt-font-size-sm, .875rem)}.kpt-chat__offline-count{margin-inline-start:auto;color:var(--kpt-color-text-muted);font-size:var(--kpt-font-size-xs, .75rem)}.kpt-chat__body{position:relative;display:flex;flex:1 1 auto;min-height:0}.kpt-chat__viewport{display:flex;flex:1 1 auto;flex-direction:column;gap:var(--_gap);min-height:0;padding:var(--kpt-space-4, 1rem);overflow-y:auto;overscroll-behavior:contain}.kpt-chat__viewport>.kpt-chat-message-host:has(.kpt-chat-message__bubble[data-position=first]),.kpt-chat__viewport>.kpt-chat-message-host:has(.kpt-chat-message__bubble[data-position=single]){margin-block-start:var(--_group-gap)}.kpt-chat__viewport>.kpt-chat-message-host:first-child{margin-block-start:0}.kpt-chat__empty{margin:auto;padding:var(--kpt-space-8, 2rem);color:var(--kpt-color-text-muted);font-size:var(--kpt-font-size-sm, .875rem);text-align:center}.kpt-chat__date,.kpt-chat__day{padding:.125rem var(--kpt-space-3, .75rem);border:var(--kpt-border-width-thin, 1px) solid var(--kpt-color-border);border-radius:var(--kpt-radius-full, 9999px);background:var(--kpt-color-surface-raised);color:var(--kpt-color-text-muted);font-size:var(--kpt-font-size-xs, .75rem);box-shadow:var(--kpt-elevation-1)}.kpt-chat__date{align-self:center;margin:var(--kpt-space-4, 1rem) 0 var(--kpt-space-2, .5rem)}.kpt-chat__day{position:absolute;inset-block-start:var(--kpt-space-2, .5rem);inset-inline:0 var(--kpt-space-3, .75rem);z-index:var(--kpt-z-raised, 1);width:fit-content;margin:0 auto;pointer-events:none}.kpt-chat__day:before{content:\"\\200b\"}.kpt-chat__day[data-hidden]{visibility:hidden}.kpt-chat__unread{display:flex;align-items:center;gap:var(--kpt-space-3, .75rem);margin:var(--kpt-space-4, 1rem) 0 var(--kpt-space-2, .5rem);color:var(--kpt-color-primary);font-size:var(--kpt-font-size-xs, .75rem)}.kpt-chat__unread:before,.kpt-chat__unread:after{content:\"\";flex:1 1 auto;block-size:var(--kpt-border-width-thin, 1px);background:var(--kpt-color-primary-border)}.kpt-chat__jump{position:absolute;inset-block-end:var(--kpt-space-3, .75rem);inset-inline:0;display:inline-flex;align-items:center;gap:var(--kpt-space-1, .25rem);width:fit-content;margin-inline:auto;padding:var(--kpt-space-1, .25rem) var(--kpt-space-3, .75rem);border:var(--kpt-border-width-thin, 1px) solid var(--kpt-color-primary-border);border-radius:var(--kpt-radius-full, 9999px);background:var(--kpt-color-surface-raised);color:var(--kpt-color-primary);font:inherit;font-size:var(--kpt-font-size-xs, .75rem);cursor:pointer;box-shadow:var(--kpt-elevation-2)}.kpt-chat__jump:hover{background:var(--kpt-color-surface-hover)}.kpt-chat__jump:focus-visible{outline:2px solid var(--kpt-color-focus-ring);outline-offset:2px}}\n"] }]
|
|
944
|
+
args: [{ selector: 'kpt-chat', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, imports: [NgTemplateOutlet, KptChatMessage, KptChatTyping, KptIcon], host: { class: 'kpt-chat-host' }, template: "@if (offline()) {\n <p class=\"kpt-chat__offline\" role=\"status\">\n <kpt-icon name=\"alert-triangle\" aria-hidden=\"true\" />\n <span>{{ i18n.t('chat.offline') }}</span>\n @if (pending()) {\n <span class=\"kpt-chat__offline-count\">{{ i18n.t('chat.pending', { count: pending() }) }}</span>\n }\n </p>\n}\n\n<div class=\"kpt-chat__body\">\n <div\n #viewport\n class=\"kpt-chat__viewport\"\n role=\"log\"\n aria-live=\"polite\"\n aria-relevant=\"additions\"\n tabindex=\"0\"\n [attr.aria-label]=\"i18n.t('chat.history')\"\n (scroll)=\"onScroll(viewport)\"\n >\n @if (!viewRows().length) {\n <p class=\"kpt-chat__empty\">{{ emptyLabel() || i18n.t('chat.empty') }}</p>\n }\n\n @for (row of viewRows(); track row.key) {\n @switch (row.kind) {\n @case ('date') {\n <p class=\"kpt-chat__date\" role=\"separator\" [attr.aria-label]=\"row.text\">{{ row.text }}</p>\n }\n @case ('unread') {\n <p class=\"kpt-chat__unread\" role=\"separator\" [attr.aria-label]=\"i18n.t('chat.newMessages', { count: row.count })\">\n <span>{{ i18n.t('chat.unread') }}</span>\n </p>\n }\n @case ('message') {\n <kpt-chat-message\n [message]=\"row.message\"\n [text]=\"messageTpl() ? '' : null\"\n [align]=\"row.own ? 'end' : 'start'\"\n [position]=\"row.position\"\n [showAuthor]=\"row.showAuthor\"\n [showAvatar]=\"row.showAvatar\"\n [showMeta]=\"row.showMeta\"\n [actions]=\"actions()\"\n [reactionOptions]=\"reactionOptions()\"\n (retry)=\"retry.emit(row.message)\"\n (reply)=\"reply.emit(row.message)\"\n (react)=\"react.emit({ message: row.message, emoji: $event })\"\n (quoted)=\"quoted.emit($event)\"\n >\n @if (messageTpl(); as tpl) {\n <ng-container [ngTemplateOutlet]=\"tpl\" [ngTemplateOutletContext]=\"{ $implicit: row.message, row: row }\" />\n }\n </kpt-chat-message>\n }\n }\n }\n\n @if (typing().length) {\n <!-- Wewn\u0105trz logu, ale wyciszone: inaczej ka\u017Cda zmiana \u201EX pisze\u2026\u201D by\u0142aby og\u0142aszana jak nowa wiadomo\u015B\u0107. -->\n <div aria-live=\"off\">\n <kpt-chat-typing [authors]=\"typing()\" />\n </div>\n }\n </div>\n\n <!-- Pigu\u0142ka dnia wisi nad list\u0105, a nie w niej: w li\u015Bcie jad\u0105 separatory z `role=\"separator\"`,\n wi\u0119c dla czytnika ekranu jest tylko ich wizualnym echem \u2014 st\u0105d `aria-hidden`. W DOM stoi\n zawsze, bo skrypt musi umie\u0107 zmierzy\u0107 jej pas tak\u017Ce wtedy, gdy jest zgaszona. -->\n <p #day class=\"kpt-chat__day\" aria-hidden=\"true\" [attr.data-hidden]=\"dayVisible() ? null : ''\">{{ dayLabel() }}</p>\n\n @if (newCount()) {\n <button type=\"button\" class=\"kpt-chat__jump\" (click)=\"jumpToLatest()\">\n <kpt-icon name=\"arrow-down\" aria-hidden=\"true\" />\n {{ i18n.t('chat.newMessages', { count: newCount() }) }}\n </button>\n }\n</div>\n", styles: ["@charset \"UTF-8\";@layer kpt.components{.kpt-chat-host{--_gap: var(--kpt-space-1, .25rem);--_group-gap: var(--kpt-space-4, 1rem);display:flex;flex-direction:column;min-height:0;background:var(--kpt-color-surface);color:var(--kpt-color-text)}.kpt-chat__offline{display:flex;align-items:center;gap:var(--kpt-space-2, .5rem);margin:0;padding:var(--kpt-space-2, .5rem) var(--kpt-space-3, .75rem);border-block-end:var(--kpt-border-width-thin, 1px) solid var(--kpt-color-warning-border);background:var(--kpt-color-warning-subtle);color:var(--kpt-color-text);font-size:var(--kpt-font-size-sm, .875rem)}.kpt-chat__offline-count{margin-inline-start:auto;color:var(--kpt-color-text-muted);font-size:var(--kpt-font-size-xs, .75rem)}.kpt-chat__body{position:relative;display:flex;flex:1 1 auto;min-height:0}.kpt-chat__viewport{display:flex;flex:1 1 auto;flex-direction:column;gap:var(--_gap);min-height:0;padding:var(--kpt-space-4, 1rem);overflow-y:auto;overscroll-behavior:contain}.kpt-chat__viewport>.kpt-chat-message-host:has(.kpt-chat-message__bubble[data-position=first]),.kpt-chat__viewport>.kpt-chat-message-host:has(.kpt-chat-message__bubble[data-position=single]){margin-block-start:var(--_group-gap)}.kpt-chat__viewport>.kpt-chat-message-host:first-child{margin-block-start:0}.kpt-chat__empty{margin:auto;padding:var(--kpt-space-8, 2rem);color:var(--kpt-color-text-muted);font-size:var(--kpt-font-size-sm, .875rem);text-align:center}.kpt-chat__date,.kpt-chat__day{padding:.125rem var(--kpt-space-3, .75rem);border:var(--kpt-border-width-thin, 1px) solid var(--kpt-color-border);border-radius:var(--kpt-radius-full, 9999px);background:var(--kpt-color-surface-raised);color:var(--kpt-color-text-muted);font-size:var(--kpt-font-size-xs, .75rem);box-shadow:var(--kpt-elevation-1)}.kpt-chat__date{align-self:center;margin:var(--kpt-space-4, 1rem) 0 var(--kpt-space-2, .5rem)}.kpt-chat__day{position:absolute;inset-block-start:var(--kpt-space-2, .5rem);inset-inline:0 var(--kpt-space-3, .75rem);z-index:var(--kpt-z-raised, 1);width:fit-content;margin:0 auto;pointer-events:none}.kpt-chat__day:before{content:\"\\200b\"}.kpt-chat__day[data-hidden]{visibility:hidden}.kpt-chat__unread{display:flex;align-items:center;gap:var(--kpt-space-3, .75rem);margin:var(--kpt-space-4, 1rem) 0 var(--kpt-space-2, .5rem);color:var(--kpt-color-primary);font-size:var(--kpt-font-size-xs, .75rem)}.kpt-chat__unread:before,.kpt-chat__unread:after{content:\"\";flex:1 1 auto;block-size:var(--kpt-border-width-thin, 1px);background:var(--kpt-color-primary-border)}.kpt-chat__jump{position:absolute;inset-block-end:var(--kpt-space-3, .75rem);inset-inline:0;display:inline-flex;align-items:center;gap:var(--kpt-space-1, .25rem);width:fit-content;margin-inline:auto;padding:var(--kpt-space-1, .25rem) var(--kpt-space-3, .75rem);border:var(--kpt-border-width-thin, 1px) solid var(--kpt-color-primary-border);border-radius:var(--kpt-radius-full, 9999px);background:var(--kpt-color-surface-raised);color:var(--kpt-color-primary);font:inherit;font-size:var(--kpt-font-size-xs, .75rem);cursor:pointer;box-shadow:var(--kpt-elevation-2)}.kpt-chat__jump:hover{background:var(--kpt-color-surface-hover)}.kpt-chat__jump:focus-visible{outline:2px solid var(--kpt-color-focus-ring);outline-offset:2px}}\n"] }]
|
|
901
945
|
}], () => [], { messages: [{ type: i0.Input, args: [{ isSignal: true, alias: "messages", required: false }] }], currentUser: [{ type: i0.Input, args: [{ isSignal: true, alias: "currentUser", required: false }] }], groupGapMs: [{ type: i0.Input, args: [{ isSignal: true, alias: "groupGapMs", required: false }] }], unreadFrom: [{ type: i0.Input, args: [{ isSignal: true, alias: "unreadFrom", required: false }] }], offline: [{ type: i0.Input, args: [{ isSignal: true, alias: "offline", required: false }] }], typing: [{ type: i0.Input, args: [{ isSignal: true, alias: "typing", required: false }] }], autoScroll: [{ type: i0.Input, args: [{ isSignal: true, alias: "autoScroll", required: false }] }], actions: [{ type: i0.Input, args: [{ isSignal: true, alias: "actions", required: false }] }], reactionOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "reactionOptions", required: false }] }], emptyLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptyLabel", required: false }] }], retry: [{ type: i0.Output, args: ["retry"] }], reply: [{ type: i0.Output, args: ["reply"] }], react: [{ type: i0.Output, args: ["react"] }], quoted: [{ type: i0.Output, args: ["quoted"] }], loadMore: [{ type: i0.Output, args: ["loadMore"] }], messageTpl: [{ type: i0.ContentChild, args: [i0.forwardRef(() => TemplateRef), { isSignal: true }] }], viewport: [{ type: i0.ViewChild, args: ['viewport', { isSignal: true }] }], day: [{ type: i0.ViewChild, args: ['day', { isSignal: true }] }] }); })();
|
|
902
946
|
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(KptChat, { className: "KptChat", filePath: "lib/chat.component.ts", lineNumber: 80 }); })();
|
|
903
947
|
|
|
@@ -999,8 +1043,12 @@ class KptChatComposer {
|
|
|
999
1043
|
this.replyTo = model(null, /* @ts-ignore */
|
|
1000
1044
|
...(ngDevMode ? [{ debugName: "replyTo" }] : /* istanbul ignore next */ []));
|
|
1001
1045
|
this.send = output();
|
|
1002
|
-
/**
|
|
1046
|
+
/**
|
|
1047
|
+
* Sygnał „piszę” dla drugiej strony: przy pierwszym znaku, a w trakcie pisania najwyżej raz na
|
|
1048
|
+
* `KPT_CHAT_TYPING_THROTTLE_MS` (3 s) — nie przy każdym znaku.
|
|
1049
|
+
*/
|
|
1003
1050
|
this.typing = output();
|
|
1051
|
+
this.lastTyping = 0;
|
|
1004
1052
|
this.i18n = inject(KptI18n);
|
|
1005
1053
|
this.files = signal([], /* @ts-ignore */
|
|
1006
1054
|
...(ngDevMode ? [{ debugName: "files" }] : /* istanbul ignore next */ []));
|
|
@@ -1012,7 +1060,11 @@ class KptChatComposer {
|
|
|
1012
1060
|
onInput(element) {
|
|
1013
1061
|
this.value.set(element.value);
|
|
1014
1062
|
this.grow(element);
|
|
1015
|
-
|
|
1063
|
+
const now = Date.now();
|
|
1064
|
+
if (now - this.lastTyping >= KPT_CHAT_TYPING_THROTTLE_MS) {
|
|
1065
|
+
this.lastTyping = now;
|
|
1066
|
+
this.typing.emit();
|
|
1067
|
+
}
|
|
1016
1068
|
}
|
|
1017
1069
|
onKeydown(event, element) {
|
|
1018
1070
|
if (event.key !== 'Enter')
|