pixelon 0.3.24 → 0.3.25

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.
@@ -8,6 +8,7 @@ export declare const CHAT_EVENT: {
8
8
  readonly RETRY_MESSAGE: "retryMessage";
9
9
  readonly PLACEHOLDER_UPDATED: "placeholderUpdated";
10
10
  readonly THINKING_UPDATED: "thinkingUpdated";
11
+ readonly INPUT_DISABLED: "inputDisabled";
11
12
  readonly CLOSE: "close";
12
13
  };
13
14
  export type ChatEvents = {
@@ -35,6 +36,10 @@ export type ChatEvents = {
35
36
  thinkingUpdated: {
36
37
  isThinking: boolean;
37
38
  };
39
+ /** Consumer -> Chat: enable/disable input controls */
40
+ inputDisabled: {
41
+ disabled: boolean;
42
+ };
38
43
  /** Chat -> Consumer: user sent a message */
39
44
  sendMessage: {
40
45
  content: string;
package/dist/index.esm.js CHANGED
@@ -1774,6 +1774,7 @@ const CHAT_EVENT = {
1774
1774
  RETRY_MESSAGE: "retryMessage",
1775
1775
  PLACEHOLDER_UPDATED: "placeholderUpdated",
1776
1776
  THINKING_UPDATED: "thinkingUpdated",
1777
+ INPUT_DISABLED: "inputDisabled",
1777
1778
  CLOSE: "close"
1778
1779
  };
1779
1780
  const chatEventBus = createEventBus();
@@ -3831,12 +3832,6 @@ const thinkingActions = {
3831
3832
  hide: () => setChatStore(CHAT_STORE_KEYS.ASSISTANT_THINKING_INDICATOR, { visible: false }),
3832
3833
  setThinking: (isThinking) => {
3833
3834
  setChatStore(CHAT_STORE_KEYS.ASSISTANT_THINKING_INDICATOR, { visible: isThinking });
3834
- if (isThinking) {
3835
- chatInputActions.setSendDisabled(true);
3836
- } else {
3837
- const currentInput = chatStore.get(CHAT_STORE_KEYS.CHAT_INPUT);
3838
- chatInputActions.updateButtonVisibility(currentInput.hasText, currentInput.hasAttachments);
3839
- }
3840
3835
  }
3841
3836
  };
3842
3837
  const scrollButtonActions = {
@@ -4849,9 +4844,9 @@ const useChatHandlers = ({
4849
4844
  clearAttachments,
4850
4845
  scrollToLastUserMessage
4851
4846
  }) => {
4852
- const isThinking = () => chatStore.get(CHAT_STORE_KEYS.ASSISTANT_THINKING_INDICATOR).visible;
4847
+ const isInputDisabled = () => chatStore.get(CHAT_STORE_KEYS.CHAT_INPUT).buttonSend.disabled;
4853
4848
  const handleSendWithFiles = (content, files) => {
4854
- if (isThinking()) return;
4849
+ if (isInputDisabled()) return;
4855
4850
  if (!content.trim() && (!files || files.length === 0)) return;
4856
4851
  combinedActions.handleMessageSend();
4857
4852
  onSend(content, files);
@@ -4862,7 +4857,7 @@ const useChatHandlers = ({
4862
4857
  const handleInputKeyDown = (e, inputValue, attachments) => {
4863
4858
  if (e.key === "Enter" && !e.shiftKey) {
4864
4859
  e.preventDefault();
4865
- if (isThinking()) return;
4860
+ if (isInputDisabled()) return;
4866
4861
  handleSendWithFiles(inputValue, attachments);
4867
4862
  }
4868
4863
  };
@@ -5199,12 +5194,21 @@ const Chat = ({
5199
5194
  const unsubComponent = eventBus.on(CHAT_EVENT.COMPONENT_INTERACTION, () => {
5200
5195
  scrollToTopActions.activate();
5201
5196
  });
5197
+ const unsubInputDisabled = eventBus.on(CHAT_EVENT.INPUT_DISABLED, ({ disabled }) => {
5198
+ if (disabled) {
5199
+ chatInputActions.setSendDisabled(true);
5200
+ } else {
5201
+ const { hasText, hasAttachments } = chatStore.get(CHAT_STORE_KEYS.CHAT_INPUT);
5202
+ chatInputActions.updateButtonVisibility(hasText, hasAttachments);
5203
+ }
5204
+ });
5202
5205
  return () => {
5203
5206
  unsubMessages();
5204
5207
  unsubHeader();
5205
5208
  unsubPlaceholder();
5206
5209
  unsubThinking();
5207
5210
  unsubComponent();
5211
+ unsubInputDisabled();
5208
5212
  };
5209
5213
  }, [eventBus]);
5210
5214
  const handleSend = (content, files) => {
@@ -5289,33 +5293,37 @@ const Chat = ({
5289
5293
  ref: messagesContainerRef,
5290
5294
  onClick: handleMainClick,
5291
5295
  children: [
5292
- messageGroups.map((group, groupIndex) => /* @__PURE__ */ jsxs(React.Fragment, { children: [
5293
- /* @__PURE__ */ jsx(DateDivider, { date: group.date }),
5294
- group.messages.map((msg, msgIndex) => {
5295
- const key = msg.id ?? `${groupIndex}-${msgIndex}`;
5296
- return msg.role === "user" ? /* @__PURE__ */ jsx(
5297
- UserMessage,
5298
- {
5299
- content: msg.content,
5300
- timestamp: msg.timestamp,
5301
- status: msg.status,
5302
- onRetry: msg.status === "failed" ? () => handleRetry(msg) : void 0,
5303
- files: msg.files
5304
- },
5305
- key
5306
- ) : /* @__PURE__ */ jsx(
5307
- AssistantMessage,
5308
- {
5309
- content: msg.content,
5310
- timestamp: msg.timestamp,
5311
- files: msg.files,
5312
- eventBus,
5313
- messageId: msg.id
5314
- },
5315
- key
5316
- );
5317
- })
5318
- ] }, `${group.date.getTime()}-${groupIndex}`)),
5296
+ messageGroups.map((group, groupIndex) => {
5297
+ const isToday = group.date.toDateString() === (/* @__PURE__ */ new Date()).toDateString();
5298
+ const showDivider = !(messageGroups.length === 1 && isToday);
5299
+ return /* @__PURE__ */ jsxs(React.Fragment, { children: [
5300
+ showDivider && /* @__PURE__ */ jsx(DateDivider, { date: group.date }),
5301
+ group.messages.map((msg, msgIndex) => {
5302
+ const key = msg.id ?? `${groupIndex}-${msgIndex}`;
5303
+ return msg.role === "user" ? /* @__PURE__ */ jsx(
5304
+ UserMessage,
5305
+ {
5306
+ content: msg.content,
5307
+ timestamp: msg.timestamp,
5308
+ status: msg.status,
5309
+ onRetry: msg.status === "failed" ? () => handleRetry(msg) : void 0,
5310
+ files: msg.files
5311
+ },
5312
+ key
5313
+ ) : /* @__PURE__ */ jsx(
5314
+ AssistantMessage,
5315
+ {
5316
+ content: msg.content,
5317
+ timestamp: msg.timestamp,
5318
+ files: msg.files,
5319
+ eventBus,
5320
+ messageId: msg.id
5321
+ },
5322
+ key
5323
+ );
5324
+ })
5325
+ ] }, `${group.date.getTime()}-${groupIndex}`);
5326
+ }),
5319
5327
  showThinking && /* @__PURE__ */ jsx(AssistantThinkingIndicator, {}),
5320
5328
  /* @__PURE__ */ jsx("div", { ref: messagesEndRef })
5321
5329
  ]
package/dist/index.js CHANGED
@@ -1795,6 +1795,7 @@ const CHAT_EVENT = {
1795
1795
  RETRY_MESSAGE: "retryMessage",
1796
1796
  PLACEHOLDER_UPDATED: "placeholderUpdated",
1797
1797
  THINKING_UPDATED: "thinkingUpdated",
1798
+ INPUT_DISABLED: "inputDisabled",
1798
1799
  CLOSE: "close"
1799
1800
  };
1800
1801
  const chatEventBus = createEventBus();
@@ -3852,12 +3853,6 @@ const thinkingActions = {
3852
3853
  hide: () => setChatStore(CHAT_STORE_KEYS.ASSISTANT_THINKING_INDICATOR, { visible: false }),
3853
3854
  setThinking: (isThinking) => {
3854
3855
  setChatStore(CHAT_STORE_KEYS.ASSISTANT_THINKING_INDICATOR, { visible: isThinking });
3855
- if (isThinking) {
3856
- chatInputActions.setSendDisabled(true);
3857
- } else {
3858
- const currentInput = chatStore.get(CHAT_STORE_KEYS.CHAT_INPUT);
3859
- chatInputActions.updateButtonVisibility(currentInput.hasText, currentInput.hasAttachments);
3860
- }
3861
3856
  }
3862
3857
  };
3863
3858
  const scrollButtonActions = {
@@ -4870,9 +4865,9 @@ const useChatHandlers = ({
4870
4865
  clearAttachments,
4871
4866
  scrollToLastUserMessage
4872
4867
  }) => {
4873
- const isThinking = () => chatStore.get(CHAT_STORE_KEYS.ASSISTANT_THINKING_INDICATOR).visible;
4868
+ const isInputDisabled = () => chatStore.get(CHAT_STORE_KEYS.CHAT_INPUT).buttonSend.disabled;
4874
4869
  const handleSendWithFiles = (content, files) => {
4875
- if (isThinking()) return;
4870
+ if (isInputDisabled()) return;
4876
4871
  if (!content.trim() && (!files || files.length === 0)) return;
4877
4872
  combinedActions.handleMessageSend();
4878
4873
  onSend(content, files);
@@ -4883,7 +4878,7 @@ const useChatHandlers = ({
4883
4878
  const handleInputKeyDown = (e, inputValue, attachments) => {
4884
4879
  if (e.key === "Enter" && !e.shiftKey) {
4885
4880
  e.preventDefault();
4886
- if (isThinking()) return;
4881
+ if (isInputDisabled()) return;
4887
4882
  handleSendWithFiles(inputValue, attachments);
4888
4883
  }
4889
4884
  };
@@ -5220,12 +5215,21 @@ const Chat = ({
5220
5215
  const unsubComponent = eventBus.on(CHAT_EVENT.COMPONENT_INTERACTION, () => {
5221
5216
  scrollToTopActions.activate();
5222
5217
  });
5218
+ const unsubInputDisabled = eventBus.on(CHAT_EVENT.INPUT_DISABLED, ({ disabled }) => {
5219
+ if (disabled) {
5220
+ chatInputActions.setSendDisabled(true);
5221
+ } else {
5222
+ const { hasText, hasAttachments } = chatStore.get(CHAT_STORE_KEYS.CHAT_INPUT);
5223
+ chatInputActions.updateButtonVisibility(hasText, hasAttachments);
5224
+ }
5225
+ });
5223
5226
  return () => {
5224
5227
  unsubMessages();
5225
5228
  unsubHeader();
5226
5229
  unsubPlaceholder();
5227
5230
  unsubThinking();
5228
5231
  unsubComponent();
5232
+ unsubInputDisabled();
5229
5233
  };
5230
5234
  }, [eventBus]);
5231
5235
  const handleSend = (content, files) => {
@@ -5310,33 +5314,37 @@ const Chat = ({
5310
5314
  ref: messagesContainerRef,
5311
5315
  onClick: handleMainClick,
5312
5316
  children: [
5313
- messageGroups.map((group, groupIndex) => /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
5314
- /* @__PURE__ */ jsxRuntime.jsx(DateDivider, { date: group.date }),
5315
- group.messages.map((msg, msgIndex) => {
5316
- const key = msg.id ?? `${groupIndex}-${msgIndex}`;
5317
- return msg.role === "user" ? /* @__PURE__ */ jsxRuntime.jsx(
5318
- UserMessage,
5319
- {
5320
- content: msg.content,
5321
- timestamp: msg.timestamp,
5322
- status: msg.status,
5323
- onRetry: msg.status === "failed" ? () => handleRetry(msg) : void 0,
5324
- files: msg.files
5325
- },
5326
- key
5327
- ) : /* @__PURE__ */ jsxRuntime.jsx(
5328
- AssistantMessage,
5329
- {
5330
- content: msg.content,
5331
- timestamp: msg.timestamp,
5332
- files: msg.files,
5333
- eventBus,
5334
- messageId: msg.id
5335
- },
5336
- key
5337
- );
5338
- })
5339
- ] }, `${group.date.getTime()}-${groupIndex}`)),
5317
+ messageGroups.map((group, groupIndex) => {
5318
+ const isToday = group.date.toDateString() === (/* @__PURE__ */ new Date()).toDateString();
5319
+ const showDivider = !(messageGroups.length === 1 && isToday);
5320
+ return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
5321
+ showDivider && /* @__PURE__ */ jsxRuntime.jsx(DateDivider, { date: group.date }),
5322
+ group.messages.map((msg, msgIndex) => {
5323
+ const key = msg.id ?? `${groupIndex}-${msgIndex}`;
5324
+ return msg.role === "user" ? /* @__PURE__ */ jsxRuntime.jsx(
5325
+ UserMessage,
5326
+ {
5327
+ content: msg.content,
5328
+ timestamp: msg.timestamp,
5329
+ status: msg.status,
5330
+ onRetry: msg.status === "failed" ? () => handleRetry(msg) : void 0,
5331
+ files: msg.files
5332
+ },
5333
+ key
5334
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
5335
+ AssistantMessage,
5336
+ {
5337
+ content: msg.content,
5338
+ timestamp: msg.timestamp,
5339
+ files: msg.files,
5340
+ eventBus,
5341
+ messageId: msg.id
5342
+ },
5343
+ key
5344
+ );
5345
+ })
5346
+ ] }, `${group.date.getTime()}-${groupIndex}`);
5347
+ }),
5340
5348
  showThinking && /* @__PURE__ */ jsxRuntime.jsx(AssistantThinkingIndicator, {}),
5341
5349
  /* @__PURE__ */ jsxRuntime.jsx("div", { ref: messagesEndRef })
5342
5350
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pixelon",
3
- "version": "0.3.24",
3
+ "version": "0.3.25",
4
4
  "description": "Design system de la marca goluti",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",