@c2n/chat-message 0.0.12 → 0.0.14
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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"schemaVersion":"1.0.0","readme":"","modules":[{"kind":"javascript-module","path":"src/chat-message.ts","declarations":[{"kind":"class","description":"Flexible message row for conversations, assistant answers and activity updates.","name":"ChatMessage","cssProperties":[{"type":{"text":"pixel"},"name":"--c2-chat-message--gap","default":"12px"},{"type":{"text":"font-size"},"name":"--c2-chat-message--font-size","default":"14px"},{"type":{"text":"font-weight"},"name":"--c2-chat-message--font-weight","default":"400"},{"type":{"text":"font-family"},"name":"--c2-chat-message--font-family","default":"inherit"},{"type":{"text":"line-height"},"name":"--c2-chat-message--line-height","default":"1.55"},{"type":{"text":"pixel"},"name":"--c2-chat-message__avatar--margin-top","default":"2px"},{"type":{"text":"pixel"},"name":"--c2-chat-message__message--gap","default":"6px"},{"type":{"text":"length"},"name":"--c2-chat-message__message--max-width","default":"44rem"},{"type":{"text":"border"},"name":"--c2-chat-message__message--border-top","default":"0 solid transparent"},{"type":{"text":"border"},"name":"--c2-chat-message__message--border-right","default":"0 solid transparent"},{"type":{"text":"border"},"name":"--c2-chat-message__message--border-bottom","default":"0 solid transparent"},{"type":{"text":"border"},"name":"--c2-chat-message__message--border-left","default":"0 solid transparent"},{"type":{"text":"border-radius"},"name":"--c2-chat-message__message--border-top-left-radius","default":"0"},{"type":{"text":"border-radius"},"name":"--c2-chat-message__message--border-top-right-radius","default":"0"},{"type":{"text":"border-radius"},"name":"--c2-chat-message__message--border-bottom-left-radius","default":"0"},{"type":{"text":"border-radius"},"name":"--c2-chat-message__message--border-bottom-right-radius","default":"0"},{"type":{"text":"padding"},"name":"--c2-chat-message__message--padding-top","default":"0"},{"type":{"text":"padding"},"name":"--c2-chat-message__message--padding-right","default":"0"},{"type":{"text":"padding"},"name":"--c2-chat-message__message--padding-bottom","default":"0"},{"type":{"text":"padding"},"name":"--c2-chat-message__message--padding-left","default":"0"},{"type":{"text":"color"},"name":"--c2-chat-message__message--color","default":"#27272a"},{"type":{"text":"background"},"name":"--c2-chat-message__message--background","default":"transparent"},{"type":{"text":"pixel"},"name":"--c2-chat-message__header--gap","default":"8px"},{"type":{"text":"color"},"name":"--c2-chat-message__header__title--color","default":"#18181b"},{"type":{"text":"font-size"},"name":"--c2-chat-message__header__title--font-size","default":"13px"},{"type":{"text":"font-weight"},"name":"--c2-chat-message__header__title--font-weight","default":"600"},{"type":{"text":"font-style"},"name":"--c2-chat-message__header__title--font-style","default":"normal"},{"type":{"text":"color"},"name":"--c2-chat-message__time--color","default":"#71717a"},{"type":{"text":"font-size"},"name":"--c2-chat-message__time--font-size","default":"12px"},{"type":{"text":"font-weight"},"name":"--c2-chat-message__time--font-weight","default":"400"},{"type":{"text":"font-style"},"name":"--c2-chat-message__time--font-style","default":"normal"},{"type":{"text":"pixel"},"name":"--c2-chat-message__footer--gap","default":"8px"}],"cssParts":[{"description":"The complete message row.","name":"base"},{"description":"Component-owned region wrapping the assigned `avatar` slot.","name":"avatar"},{"description":"Component-owned column wrapping the default slot between the header and footer.","name":"body"},{"description":"Title and header timestamp row.","name":"header"},{"description":"Main message content.","name":"content"},{"description":"Reactions and footer timestamp row.","name":"footer"},{"description":"Reaction/action region.","name":"actions"}],"slots":[{"description":"Main message body. Prefer this slot for new usage.","name":""},{"description":"Sender avatar shown beside the message.","name":"avatar"},{"description":"Sender name or message heading.","name":"title"},{"description":"Timestamp displayed beside the title.","name":"header-time"},{"description":"Named main message body, retained for compatibility.","name":"message"},{"description":"Reactions or sentiment controls below the message.","name":"emotion"},{"description":"Timestamp displayed below the message.","name":"footer-time"}],"members":[{"kind":"field","name":"align","type":{"text":"ChatMessageAlign"},"default":"'left'","description":"Places the avatar and message on the left or right side of the row.","attribute":"align","reflects":true},{"kind":"field","name":"slotPresence","privacy":"private","readonly":true,"default":"new SlotPresenceController(this, ['title', 'header-time', 'emotion', 'footer-time'])"}],"attributes":[{"name":"align","type":{"text":"ChatMessageAlign"},"default":"'left'","description":"Places the avatar and message on the left or right side of the row.","fieldName":"align"}],"superclass":{"name":"LitElement","package":"lit"},"tagName":"c2-chat-message","customElement":true,"slotComponents":["c2-avatar"]}],"exports":[{"kind":"js","name":"ChatMessage","declaration":{"name":"ChatMessage","module":"src/chat-message.ts"}},{"kind":"custom-element-definition","name":"c2-chat-message","declaration":{"name":"ChatMessage","module":"src/chat-message.ts"}}]}]}
|
package/dist/chat-message.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { LitElement, html, unsafeCSS } from "lit";
|
|
2
|
-
import { property
|
|
2
|
+
import { property } from "@c2n/core/lit-helper.js";
|
|
3
3
|
import { customElement } from "@c2n/core/element-helper.js";
|
|
4
|
+
import { SlotPresenceController } from "@c2n/core/dom-helper.js";
|
|
4
5
|
//#region src/chat-message.scss?inline
|
|
5
6
|
var chat_message_default = "/* ex : var((width: 24px), width, c2-checkbox) returns var(--c2-checkbox-width, 24px) */\n:host {\n display: block;\n max-width: 100%;\n}\n\n.c2-chat-message {\n display: flex;\n align-items: flex-start;\n gap: var(--c2-chat-message--gap,12px);\n width: 100%;\n}\n\n.c2-chat-message__avatar {\n display: contents;\n}\n\nslot[name=avatar]::slotted(*) {\n flex: none;\n margin-top: var(--c2-chat-message__avatar--margin-top,2px);\n}\n\n.c2-chat-message__body {\n box-sizing: border-box;\n display: flex;\n flex: 0 1 auto;\n flex-direction: column;\n gap: var(--c2-chat-message__message--gap,6px);\n min-width: 0;\n max-width: min(100%, var(--c2-chat-message__message--max-width,44rem));\n padding-top: var(--c2-chat-message__message--padding-top,0);\n padding-right: var(--c2-chat-message__message--padding-right,0);\n padding-bottom: var(--c2-chat-message__message--padding-bottom,0);\n padding-left: var(--c2-chat-message__message--padding-left,0);\n border-top: var(--c2-chat-message__message--border-top,0 solid transparent);\n border-right: var(--c2-chat-message__message--border-right,0 solid transparent);\n border-bottom: var(--c2-chat-message__message--border-bottom,0 solid transparent);\n border-left: var(--c2-chat-message__message--border-left,0 solid transparent);\n border-top-left-radius: var(--c2-chat-message__message--border-top-left-radius,0);\n border-top-right-radius: var(--c2-chat-message__message--border-top-right-radius,0);\n border-bottom-left-radius: var(--c2-chat-message__message--border-bottom-left-radius,0);\n border-bottom-right-radius: var(--c2-chat-message__message--border-bottom-right-radius,0);\n background: var(--c2-chat-message__message--background,transparent);\n color: var(--c2-chat-message__message--color,#27272a);\n font-variant-ligatures: common-ligatures;\n font-size: var(--c2-chat-message--font-size,14px);\n font-weight: var(--c2-chat-message--font-weight,400);\n font-family: var(--c2-chat-message--font-family,inherit);\n line-height: var(--c2-chat-message--line-height,1.55);\n}\n\n.c2-chat-message__header,\n.c2-chat-message__footer {\n display: flex;\n align-items: center;\n}\n\n.c2-chat-message__header {\n gap: var(--c2-chat-message__header--gap,8px);\n}\n\n.c2-chat-message__header[hidden],\n.c2-chat-message__footer[hidden] {\n display: none;\n}\n\nslot[name=title] {\n color: var(--c2-chat-message__header__title--color,#18181b);\n font-size: var(--c2-chat-message__header__title--font-size,13px);\n font-weight: var(--c2-chat-message__header__title--font-weight,600);\n font-style: var(--c2-chat-message__header__title--font-style,normal);\n line-height: 1.25;\n}\n\nslot[name=header-time],\nslot[name=footer-time] {\n color: var(--c2-chat-message__time--color,#71717a);\n font-size: var(--c2-chat-message__time--font-size,12px);\n font-weight: var(--c2-chat-message__time--font-weight,400);\n font-style: var(--c2-chat-message__time--font-style,normal);\n line-height: 1.25;\n}\n\n.c2-chat-message__content {\n min-width: 0;\n overflow-wrap: anywhere;\n}\n\n.c2-chat-message__content ::slotted(*) {\n box-sizing: border-box;\n max-width: 100%;\n}\n\n.c2-chat-message__footer {\n justify-content: space-between;\n gap: var(--c2-chat-message__footer--gap,8px);\n}\n\n.c2-chat-message__emotion {\n display: flex;\n align-items: center;\n min-width: 0;\n}\n\n:host([align=right]) .c2-chat-message {\n flex-direction: row-reverse;\n}\n:host([align=right]) .c2-chat-message__body {\n align-items: flex-end;\n margin-left: auto;\n}\n:host([align=right]) .c2-chat-message__header {\n flex-direction: row-reverse;\n}\n:host([align=right]) .c2-chat-message__content {\n text-align: right;\n}\n:host([align=right]) .c2-chat-message__footer {\n flex-direction: row-reverse;\n}";
|
|
6
7
|
//#endregion
|
|
@@ -17,33 +18,29 @@ var ChatMessage = class ChatMessage extends LitElement {
|
|
|
17
18
|
constructor(..._args) {
|
|
18
19
|
super(..._args);
|
|
19
20
|
this.align = "left";
|
|
20
|
-
this.
|
|
21
|
-
|
|
21
|
+
this.slotPresence = new SlotPresenceController(this, [
|
|
22
|
+
"title",
|
|
23
|
+
"header-time",
|
|
24
|
+
"emotion",
|
|
25
|
+
"footer-time"
|
|
26
|
+
]);
|
|
22
27
|
}
|
|
23
28
|
static {
|
|
24
29
|
this.styles = unsafeCSS(chat_message_default);
|
|
25
30
|
}
|
|
26
|
-
syncOptionalRegions() {
|
|
27
|
-
const assigned = (name) => {
|
|
28
|
-
const slot = this.renderRoot.querySelector(`slot[name='${name}']`);
|
|
29
|
-
return Boolean(slot?.assignedNodes({ flatten: true }).some((node) => node.nodeType !== Node.TEXT_NODE || Boolean(node.textContent?.trim())));
|
|
30
|
-
};
|
|
31
|
-
this.hasHeader = assigned("title") || assigned("header-time");
|
|
32
|
-
this.hasFooter = assigned("emotion") || assigned("footer-time");
|
|
33
|
-
}
|
|
34
31
|
render() {
|
|
35
32
|
return html`
|
|
36
33
|
<article class="c2-chat-message" part="base">
|
|
37
34
|
<div class="c2-chat-message__avatar" part="avatar"><slot name="avatar"></slot></div>
|
|
38
35
|
<div class="c2-chat-message__body" part="body">
|
|
39
|
-
<header class="c2-chat-message__header" part="header" ?hidden=${!this.
|
|
40
|
-
<slot name="title" @slotchange=${this.
|
|
41
|
-
<slot name="header-time" @slotchange=${this.
|
|
36
|
+
<header class="c2-chat-message__header" part="header" ?hidden=${!this.slotPresence.has("title") && !this.slotPresence.has("header-time")}>
|
|
37
|
+
<slot name="title" @slotchange=${this.slotPresence.handleSlotChange}></slot>
|
|
38
|
+
<slot name="header-time" @slotchange=${this.slotPresence.handleSlotChange}></slot>
|
|
42
39
|
</header>
|
|
43
40
|
<div class="c2-chat-message__content" part="content"><slot name="message"></slot><slot></slot></div>
|
|
44
|
-
<footer class="c2-chat-message__footer" part="footer" ?hidden=${!this.
|
|
45
|
-
<div class="c2-chat-message__emotion" part="actions"><slot name="emotion" @slotchange=${this.
|
|
46
|
-
<div class="c2-chat-message__footer-time"><slot name="footer-time" @slotchange=${this.
|
|
41
|
+
<footer class="c2-chat-message__footer" part="footer" ?hidden=${!this.slotPresence.has("emotion") && !this.slotPresence.has("footer-time")}>
|
|
42
|
+
<div class="c2-chat-message__emotion" part="actions"><slot name="emotion" @slotchange=${this.slotPresence.handleSlotChange}></slot></div>
|
|
43
|
+
<div class="c2-chat-message__footer-time"><slot name="footer-time" @slotchange=${this.slotPresence.handleSlotChange}></slot></div>
|
|
47
44
|
</footer>
|
|
48
45
|
</div>
|
|
49
46
|
</article>
|
|
@@ -51,8 +48,6 @@ var ChatMessage = class ChatMessage extends LitElement {
|
|
|
51
48
|
}
|
|
52
49
|
};
|
|
53
50
|
__decorate([property({ reflect: true })], ChatMessage.prototype, "align", void 0);
|
|
54
|
-
__decorate([state()], ChatMessage.prototype, "hasHeader", void 0);
|
|
55
|
-
__decorate([state()], ChatMessage.prototype, "hasFooter", void 0);
|
|
56
51
|
ChatMessage = __decorate([customElement("c2-chat-message")], ChatMessage);
|
|
57
52
|
//#endregion
|
|
58
53
|
export { ChatMessage };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c2n/chat-message",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/chat-message.js",
|
|
6
6
|
"exports": {
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"files": [
|
|
22
22
|
"dist",
|
|
23
23
|
"types",
|
|
24
|
+
"custom-elements.json",
|
|
24
25
|
"react.d.ts",
|
|
25
26
|
"react.js",
|
|
26
27
|
"vue.d.ts",
|
|
@@ -61,12 +62,12 @@
|
|
|
61
62
|
}
|
|
62
63
|
},
|
|
63
64
|
"dependencies": {
|
|
64
|
-
"@c2n/core": "0.0.
|
|
65
|
+
"@c2n/core": "0.0.14",
|
|
65
66
|
"lit": "3.3.3"
|
|
66
67
|
},
|
|
67
68
|
"devDependencies": {
|
|
68
69
|
"@c2n/config": "*"
|
|
69
70
|
},
|
|
70
71
|
"customElements": "custom-elements.json",
|
|
71
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "0261bfceaaa9f710a54e8f36cb57f946c0b83e53"
|
|
72
73
|
}
|
|
@@ -14,8 +14,8 @@ export type ChatMessageAlign = 'left' | 'right';
|
|
|
14
14
|
* @slot footer-time - Timestamp displayed below the message.
|
|
15
15
|
*
|
|
16
16
|
* @csspart base - The complete message row.
|
|
17
|
-
* @csspart avatar -
|
|
18
|
-
* @csspart body -
|
|
17
|
+
* @csspart avatar - Component-owned region wrapping the assigned `avatar` slot.
|
|
18
|
+
* @csspart body - Component-owned column wrapping the default slot between the header and footer.
|
|
19
19
|
* @csspart header - Title and header timestamp row.
|
|
20
20
|
* @csspart content - Main message content.
|
|
21
21
|
* @csspart footer - Reactions and footer timestamp row.
|
|
@@ -65,10 +65,8 @@ export type ChatMessageAlign = 'left' | 'right';
|
|
|
65
65
|
export declare class ChatMessage extends LitElement {
|
|
66
66
|
/** Places the avatar and message on the left or right side of the row. */
|
|
67
67
|
align: ChatMessageAlign;
|
|
68
|
-
private
|
|
69
|
-
private hasFooter;
|
|
68
|
+
private readonly slotPresence;
|
|
70
69
|
static styles: import("lit").CSSResult;
|
|
71
|
-
private syncOptionalRegions;
|
|
72
70
|
render(): import("lit-html").TemplateResult<1>;
|
|
73
71
|
}
|
|
74
72
|
declare global {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-message.d.ts","sourceRoot":"","sources":["../../src/chat-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAmB,MAAM,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"chat-message.d.ts","sourceRoot":"","sources":["../../src/chat-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAmB,MAAM,KAAK,CAAA;AAMjD,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,OAAO,CAAA;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AACH,qBACa,WAAY,SAAQ,UAAU;IACzC,0EAA0E;IAC7C,KAAK,EAAE,gBAAgB,CAAS;IAE7D,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAuF;IAEpH,OAAgB,MAAM,0BAAoB;IAEjC,MAAM;CAkBhB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,iBAAiB,EAAE,WAAW,CAAA;KAC/B;CACF"}
|