@promptbook/components 0.101.0-11 → 0.101.0-13

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/esm/index.es.js CHANGED
@@ -21,7 +21,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
21
21
  * @generated
22
22
  * @see https://github.com/webgptorg/promptbook
23
23
  */
24
- const PROMPTBOOK_ENGINE_VERSION = '0.101.0-11';
24
+ const PROMPTBOOK_ENGINE_VERSION = '0.101.0-13';
25
25
  /**
26
26
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
27
27
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -4127,49 +4127,8 @@ const LOADING_INTERACTIVE_IMAGE = 'Loading...';
4127
4127
  * Note: [💞] Ignore a discrepancy between file name and entity name
4128
4128
  */
4129
4129
 
4130
- // Critical inline styles to prevent layout shift during CSS module loading
4131
- const CRITICAL_STYLES = {
4132
- chat: {
4133
- width: '100%',
4134
- height: '100%',
4135
- display: 'flex',
4136
- flexDirection: 'column',
4137
- },
4138
- chatMainFlow: {
4139
- width: '100%',
4140
- height: '100%',
4141
- maxWidth: '100vw',
4142
- display: 'grid',
4143
- gridTemplate: `
4144
- 'header' min-content
4145
- 'messages' 1fr
4146
- 'input' min-content
4147
- / 1fr`,
4148
- },
4149
- chatMessages: {
4150
- gridArea: 'messages',
4151
- width: '100%',
4152
- height: '100%',
4153
- padding: '24px 20px 16px',
4154
- overflowY: 'auto',
4155
- overflowX: 'hidden',
4156
- },
4157
- chatInput: {
4158
- gridArea: 'input',
4159
- width: '100%',
4160
- padding: '20px',
4161
- display: 'flex',
4162
- alignItems: 'center',
4163
- gap: '12px',
4164
- },
4165
- chatBar: {
4166
- gridArea: 'header',
4167
- width: '100%',
4168
- padding: '16px 20px',
4169
- textAlign: 'center',
4170
- },
4171
- };
4172
- // <- TODO: [💩] !!!! "[✨🦬] Fix `<Chat/>` loading"
4130
+ // [🚉] Avatar dimensions constant to prevent layout jumps and maintain DRY principle
4131
+ const AVATAR_SIZE = 40;
4173
4132
  /**
4174
4133
  * Renders a chat with messages and input for new messages
4175
4134
  *
@@ -4350,10 +4309,7 @@ function Chat(props) {
4350
4309
  return { ...message, content: humanizeAiText(message.content) };
4351
4310
  });
4352
4311
  }, [messages, isAiTextHumanized]);
4353
- return (jsxs(Fragment, { children: [ratingConfirmation && jsx("div", { className: styles$1.ratingConfirmation, children: ratingConfirmation }), jsx("div", { className: classNames(className, styles$1.Chat, useChatCssClassName('Chat')), style: {
4354
- ...CRITICAL_STYLES.chat,
4355
- ...style,
4356
- }, children: jsxs("div", { className: classNames(className, styles$1.chatMainFlow, useChatCssClassName('chatMainFlow')), style: CRITICAL_STYLES.chatMainFlow, children: [children && (jsx("div", { className: classNames(styles$1.chatBar, chatBarCssClassName), style: CRITICAL_STYLES.chatBar, children: children })), !isAutoScrolling && (jsx("div", { className: styles$1.scrollToBottomContainer, children: jsx("button", { "data-button-type": "custom", className: classNames(styles$1.scrollToBottom, scrollToBottomCssClassName), onClick: () => {
4312
+ return (jsxs(Fragment, { children: [ratingConfirmation && jsx("div", { className: styles$1.ratingConfirmation, children: ratingConfirmation }), jsx("div", { className: classNames(className, styles$1.Chat, useChatCssClassName('Chat')), style, children: jsxs("div", { className: classNames(className, styles$1.chatMainFlow, useChatCssClassName('chatMainFlow')), children: [children && jsx("div", { className: classNames(styles$1.chatBar, chatBarCssClassName), children: children }), !isAutoScrolling && (jsx("div", { className: styles$1.scrollToBottomContainer, children: jsx("button", { "data-button-type": "custom", className: classNames(styles$1.scrollToBottom, scrollToBottomCssClassName), onClick: () => {
4357
4313
  const chatMessagesElement = chatMessagesRef.current;
4358
4314
  if (chatMessagesElement === null) {
4359
4315
  return;
@@ -4375,7 +4331,7 @@ function Chat(props) {
4375
4331
  return;
4376
4332
  }
4377
4333
  onReset();
4378
- }, children: [jsx(ResetIcon, {}), jsx("span", { className: styles$1.resetButtonText, children: "New chat" })] })), onUseTemplate && (jsxs("button", { className: classNames(styles$1.useTemplateButton), onClick: onUseTemplate, children: [jsx("span", { className: styles$1.resetButtonText, children: "Use this template" }), jsx(TemplateIcon, { size: 16 })] }))] }), jsx("div", { className: classNames(styles$1.chatMessages, useChatCssClassName('chatMessages')), style: CRITICAL_STYLES.chatMessages, ref: (chatMessagesElement) => {
4334
+ }, children: [jsx(ResetIcon, {}), jsx("span", { className: styles$1.resetButtonText, children: "New chat" })] })), onUseTemplate && (jsxs("button", { className: classNames(styles$1.useTemplateButton), onClick: onUseTemplate, children: [jsx("span", { className: styles$1.resetButtonText, children: "Use this template" }), jsx(TemplateIcon, { size: 16 })] }))] }), jsx("div", { className: classNames(styles$1.chatMessages, useChatCssClassName('chatMessages')), ref: (chatMessagesElement) => {
4379
4335
  chatMessagesRef.current = chatMessagesElement;
4380
4336
  if (chatMessagesElement === null) {
4381
4337
  return;
@@ -4418,8 +4374,14 @@ function Chat(props) {
4418
4374
  console.info('participant avatarSrc', avatarSrc);
4419
4375
  console.info('participant color', { color, colorOfText });
4420
4376
  console.groupEnd();
4421
- }, children: [avatarSrc && (jsx("div", { className: styles$1.avatar, children: jsx("img", { width: 256, height: 256, src: avatarSrc, alt: `Avatar of ${message.from.toLocaleLowerCase()}`, style: {
4377
+ }, children: [avatarSrc && (jsx("div", { className: styles$1.avatar, children: jsx("img", { width: AVATAR_SIZE, height: AVATAR_SIZE, src: avatarSrc, alt: `Avatar of ${message.from.toLocaleLowerCase()}`, style: {
4422
4378
  backgroundColor: color.toHex(),
4379
+ width: AVATAR_SIZE,
4380
+ height: AVATAR_SIZE,
4381
+ borderRadius: '50%',
4382
+ objectFit: 'cover',
4383
+ border: '2px solid rgba(125, 125, 125, 0.1)',
4384
+ flexShrink: 0,
4423
4385
  } }) })), jsxs("div", { className: styles$1.messageText, style: {
4424
4386
  backgroundColor: color.toHex(),
4425
4387
  color: colorOfText.toHex(),
@@ -4448,7 +4410,7 @@ function Chat(props) {
4448
4410
  : '#666',
4449
4411
  transition: 'color 0.2s',
4450
4412
  }, children: "\u2B50" })) }))] })] }, i));
4451
- }) }), onMessage && (jsxs("div", { className: classNames(styles$1.chatInput, useChatCssClassName('chatInput')), style: CRITICAL_STYLES.chatInput, children: [jsx("textarea", { ref: (element) => {
4413
+ }) }), onMessage && (jsxs("div", { className: classNames(styles$1.chatInput, useChatCssClassName('chatInput')), children: [jsx("textarea", { ref: (element) => {
4452
4414
  textareaRef.current = element;
4453
4415
  }, style: {
4454
4416
  height: Math.max(countLines(((_b = textareaRef.current) === null || _b === void 0 ? void 0 : _b.value) || defaultMessage || ''), (((_c = textareaRef.current) === null || _c === void 0 ? void 0 : _c.value) || defaultMessage || '').split('\n').length, 3) *