@xinghunm/ai-chat 1.3.0 → 1.3.1

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/dist/index.d.mts CHANGED
@@ -441,6 +441,9 @@ interface AiChatLabels {
441
441
  questionnaireMultiSelectHint?: string;
442
442
  questionnaireOtherOptionLabel?: string;
443
443
  questionnaireOtherPlaceholder?: string;
444
+ modelLoading?: string;
445
+ modelLoadFailed?: string;
446
+ modelUnavailable?: string;
444
447
  skillLoading?: string;
445
448
  skillEmpty?: string;
446
449
  removeSkillAriaLabel?: string;
@@ -653,6 +656,9 @@ interface ChatComposerViewProps {
653
656
  skillLoadingLabel: string;
654
657
  skillEmptyLabel: string;
655
658
  removeSkillAriaLabel: string;
659
+ modelLoadingLabel: string;
660
+ modelLoadFailedLabel: string;
661
+ modelUnavailableLabel: string;
656
662
  onValueChange: (value: string) => void;
657
663
  onPickImages: (files: FileList | File[]) => void;
658
664
  onPasteImages: (files: File[]) => void;
package/dist/index.d.ts CHANGED
@@ -441,6 +441,9 @@ interface AiChatLabels {
441
441
  questionnaireMultiSelectHint?: string;
442
442
  questionnaireOtherOptionLabel?: string;
443
443
  questionnaireOtherPlaceholder?: string;
444
+ modelLoading?: string;
445
+ modelLoadFailed?: string;
446
+ modelUnavailable?: string;
444
447
  skillLoading?: string;
445
448
  skillEmpty?: string;
446
449
  removeSkillAriaLabel?: string;
@@ -653,6 +656,9 @@ interface ChatComposerViewProps {
653
656
  skillLoadingLabel: string;
654
657
  skillEmptyLabel: string;
655
658
  removeSkillAriaLabel: string;
659
+ modelLoadingLabel: string;
660
+ modelLoadFailedLabel: string;
661
+ modelUnavailableLabel: string;
656
662
  onValueChange: (value: string) => void;
657
663
  onPickImages: (files: FileList | File[]) => void;
658
664
  onPasteImages: (files: File[]) => void;
package/dist/index.js CHANGED
@@ -95,6 +95,9 @@ var DEFAULT_AI_CHAT_LABELS = {
95
95
  questionnaireMultiSelectHint: "Multiple choice",
96
96
  questionnaireOtherOptionLabel: "Other",
97
97
  questionnaireOtherPlaceholder: "Other",
98
+ modelLoading: "Loading models...",
99
+ modelLoadFailed: "Failed to load models",
100
+ modelUnavailable: "No model available",
98
101
  skillLoading: "Loading skills...",
99
102
  skillEmpty: "No matching skills",
100
103
  removeSkillAriaLabel: "Remove skill"
@@ -7513,6 +7516,9 @@ var ChatModelControl = ({
7513
7516
  isModelsLoading,
7514
7517
  isModelsError,
7515
7518
  hasModels,
7519
+ loadingLabel,
7520
+ loadFailedLabel,
7521
+ unavailableLabel,
7516
7522
  onSelectedModelChange,
7517
7523
  onReloadModels
7518
7524
  }) => {
@@ -7525,7 +7531,7 @@ var ChatModelControl = ({
7525
7531
  "aria-label": "Reload",
7526
7532
  onClick: onReloadModels,
7527
7533
  children: [
7528
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: "Failed to load models" }),
7534
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: loadFailedLabel }),
7529
7535
  /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
7530
7536
  ReloadIcon,
7531
7537
  {
@@ -7547,7 +7553,7 @@ var ChatModelControl = ({
7547
7553
  );
7548
7554
  }
7549
7555
  if (isModelsLoading) {
7550
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ModelBadge, { children: "Loading models..." });
7556
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ModelBadge, { "data-testid": "chat-model-loading", children: loadingLabel });
7551
7557
  }
7552
7558
  if (hasModels && selectedModel) {
7553
7559
  return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
@@ -7565,9 +7571,14 @@ var ChatModelControl = ({
7565
7571
  }
7566
7572
  );
7567
7573
  }
7568
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ModelBadge, { children: "No model available" });
7574
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ModelBadge, { "data-testid": "chat-model-unavailable", children: unavailableLabel });
7569
7575
  };
7570
7576
  var ModelBadge = import_styled11.default.span`
7577
+ display: inline-flex;
7578
+ align-items: center;
7579
+ min-width: 0;
7580
+ max-width: 100%;
7581
+ overflow: hidden;
7571
7582
  border-radius: 999px;
7572
7583
  border: 1px solid var(--border-hover);
7573
7584
  padding: 5px 12px;
@@ -7575,6 +7586,9 @@ var ModelBadge = import_styled11.default.span`
7575
7586
  font-size: 12px;
7576
7587
  color: var(--text-secondary);
7577
7588
  line-height: 12px;
7589
+ white-space: nowrap;
7590
+ text-overflow: ellipsis;
7591
+ flex-shrink: 1;
7578
7592
  `;
7579
7593
  var ModelReloadButton = import_styled11.default.button`
7580
7594
  display: inline-flex;
@@ -7979,6 +7993,9 @@ var ChatComposerView = ({
7979
7993
  skillLoadingLabel,
7980
7994
  skillEmptyLabel,
7981
7995
  removeSkillAriaLabel,
7996
+ modelLoadingLabel,
7997
+ modelLoadFailedLabel,
7998
+ modelUnavailableLabel,
7982
7999
  onValueChange,
7983
8000
  onPickImages,
7984
8001
  onPasteImages,
@@ -8020,9 +8037,10 @@ var ChatComposerView = ({
8020
8037
  }) : [];
8021
8038
  const showSkillMenu = Boolean(skillQueryMatch);
8022
8039
  const activeSkillQueryKey = skillQueryMatch ? `${skillQueryMatch.start}:${skillQueryMatch.end}:${skillQueryMatch.query}:${selectedSkills.join("\0")}` : "";
8023
- const { refs, floatingStyles } = useFloating2({
8040
+ const { refs, floatingStyles, placement } = useFloating2({
8024
8041
  open: showSkillMenu,
8025
8042
  placement: "bottom-start",
8043
+ strategy: "fixed",
8026
8044
  middleware: [
8027
8045
  offset3(3),
8028
8046
  flip3({ padding: 8 }),
@@ -8137,7 +8155,7 @@ var ChatComposerView = ({
8137
8155
  });
8138
8156
  };
8139
8157
  return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(Container2, { children: [
8140
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(Surface, { "data-testid": "chat-composer-surface", children: [
8158
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(Surface, { ref: setSkillMenuReference, "data-testid": "chat-composer-surface", children: [
8141
8159
  enableImageAttachments ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
8142
8160
  "input",
8143
8161
  {
@@ -8171,7 +8189,7 @@ var ChatComposerView = ({
8171
8189
  }
8172
8190
  )
8173
8191
  ] }, skill)) }) : null,
8174
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(InputArea, { ref: setSkillMenuReference, "data-testid": "chat-composer-input-area", children: [
8192
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(InputArea, { "data-testid": "chat-composer-input-area", children: [
8175
8193
  isComposerExpanded || isComposerExpandable ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
8176
8194
  ComposerExpandButton,
8177
8195
  {
@@ -8238,6 +8256,9 @@ var ChatComposerView = ({
8238
8256
  isModelsLoading,
8239
8257
  isModelsError,
8240
8258
  hasModels,
8259
+ loadingLabel: modelLoadingLabel,
8260
+ loadFailedLabel: modelLoadFailedLabel,
8261
+ unavailableLabel: modelUnavailableLabel,
8241
8262
  onSelectedModelChange,
8242
8263
  onReloadModels
8243
8264
  }
@@ -8261,6 +8282,8 @@ var ChatComposerView = ({
8261
8282
  ref: setSkillMenuFloating,
8262
8283
  style: floatingStyles,
8263
8284
  "data-testid": "chat-composer-skill-menu",
8285
+ "data-placement": placement,
8286
+ "data-floating-strategy": "fixed",
8264
8287
  role: "listbox",
8265
8288
  children: isSkillsLoading ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(SkillMenuState, { "data-testid": "chat-composer-skill-loading", children: skillLoadingLabel }) : filteredSkills.length ? filteredSkills.map((skill, index3) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
8266
8289
  SkillMenuItem,
@@ -8322,6 +8345,9 @@ var ChatComposer = () => {
8322
8345
  skillLoadingLabel: labels.skillLoading,
8323
8346
  skillEmptyLabel: labels.skillEmpty,
8324
8347
  removeSkillAriaLabel: labels.removeSkillAriaLabel,
8348
+ modelLoadingLabel: labels.modelLoading,
8349
+ modelLoadFailedLabel: labels.modelLoadFailed,
8350
+ modelUnavailableLabel: labels.modelUnavailable,
8325
8351
  onValueChange: actions.setValue,
8326
8352
  onPickImages: actions.pickImages,
8327
8353
  onPasteImages: actions.pasteImages,
package/dist/index.mjs CHANGED
@@ -48,6 +48,9 @@ var DEFAULT_AI_CHAT_LABELS = {
48
48
  questionnaireMultiSelectHint: "Multiple choice",
49
49
  questionnaireOtherOptionLabel: "Other",
50
50
  questionnaireOtherPlaceholder: "Other",
51
+ modelLoading: "Loading models...",
52
+ modelLoadFailed: "Failed to load models",
53
+ modelUnavailable: "No model available",
51
54
  skillLoading: "Loading skills...",
52
55
  skillEmpty: "No matching skills",
53
56
  removeSkillAriaLabel: "Remove skill"
@@ -7470,6 +7473,9 @@ var ChatModelControl = ({
7470
7473
  isModelsLoading,
7471
7474
  isModelsError,
7472
7475
  hasModels,
7476
+ loadingLabel,
7477
+ loadFailedLabel,
7478
+ unavailableLabel,
7473
7479
  onSelectedModelChange,
7474
7480
  onReloadModels
7475
7481
  }) => {
@@ -7482,7 +7488,7 @@ var ChatModelControl = ({
7482
7488
  "aria-label": "Reload",
7483
7489
  onClick: onReloadModels,
7484
7490
  children: [
7485
- /* @__PURE__ */ jsx13("span", { children: "Failed to load models" }),
7491
+ /* @__PURE__ */ jsx13("span", { children: loadFailedLabel }),
7486
7492
  /* @__PURE__ */ jsxs10(
7487
7493
  ReloadIcon,
7488
7494
  {
@@ -7504,7 +7510,7 @@ var ChatModelControl = ({
7504
7510
  );
7505
7511
  }
7506
7512
  if (isModelsLoading) {
7507
- return /* @__PURE__ */ jsx13(ModelBadge, { children: "Loading models..." });
7513
+ return /* @__PURE__ */ jsx13(ModelBadge, { "data-testid": "chat-model-loading", children: loadingLabel });
7508
7514
  }
7509
7515
  if (hasModels && selectedModel) {
7510
7516
  return /* @__PURE__ */ jsx13(
@@ -7522,9 +7528,14 @@ var ChatModelControl = ({
7522
7528
  }
7523
7529
  );
7524
7530
  }
7525
- return /* @__PURE__ */ jsx13(ModelBadge, { children: "No model available" });
7531
+ return /* @__PURE__ */ jsx13(ModelBadge, { "data-testid": "chat-model-unavailable", children: unavailableLabel });
7526
7532
  };
7527
7533
  var ModelBadge = styled11.span`
7534
+ display: inline-flex;
7535
+ align-items: center;
7536
+ min-width: 0;
7537
+ max-width: 100%;
7538
+ overflow: hidden;
7528
7539
  border-radius: 999px;
7529
7540
  border: 1px solid var(--border-hover);
7530
7541
  padding: 5px 12px;
@@ -7532,6 +7543,9 @@ var ModelBadge = styled11.span`
7532
7543
  font-size: 12px;
7533
7544
  color: var(--text-secondary);
7534
7545
  line-height: 12px;
7546
+ white-space: nowrap;
7547
+ text-overflow: ellipsis;
7548
+ flex-shrink: 1;
7535
7549
  `;
7536
7550
  var ModelReloadButton = styled11.button`
7537
7551
  display: inline-flex;
@@ -7936,6 +7950,9 @@ var ChatComposerView = ({
7936
7950
  skillLoadingLabel,
7937
7951
  skillEmptyLabel,
7938
7952
  removeSkillAriaLabel,
7953
+ modelLoadingLabel,
7954
+ modelLoadFailedLabel,
7955
+ modelUnavailableLabel,
7939
7956
  onValueChange,
7940
7957
  onPickImages,
7941
7958
  onPasteImages,
@@ -7977,9 +7994,10 @@ var ChatComposerView = ({
7977
7994
  }) : [];
7978
7995
  const showSkillMenu = Boolean(skillQueryMatch);
7979
7996
  const activeSkillQueryKey = skillQueryMatch ? `${skillQueryMatch.start}:${skillQueryMatch.end}:${skillQueryMatch.query}:${selectedSkills.join("\0")}` : "";
7980
- const { refs, floatingStyles } = useFloating2({
7997
+ const { refs, floatingStyles, placement } = useFloating2({
7981
7998
  open: showSkillMenu,
7982
7999
  placement: "bottom-start",
8000
+ strategy: "fixed",
7983
8001
  middleware: [
7984
8002
  offset3(3),
7985
8003
  flip3({ padding: 8 }),
@@ -8094,7 +8112,7 @@ var ChatComposerView = ({
8094
8112
  });
8095
8113
  };
8096
8114
  return /* @__PURE__ */ jsxs11(Container2, { children: [
8097
- /* @__PURE__ */ jsxs11(Surface, { "data-testid": "chat-composer-surface", children: [
8115
+ /* @__PURE__ */ jsxs11(Surface, { ref: setSkillMenuReference, "data-testid": "chat-composer-surface", children: [
8098
8116
  enableImageAttachments ? /* @__PURE__ */ jsx16(
8099
8117
  "input",
8100
8118
  {
@@ -8128,7 +8146,7 @@ var ChatComposerView = ({
8128
8146
  }
8129
8147
  )
8130
8148
  ] }, skill)) }) : null,
8131
- /* @__PURE__ */ jsxs11(InputArea, { ref: setSkillMenuReference, "data-testid": "chat-composer-input-area", children: [
8149
+ /* @__PURE__ */ jsxs11(InputArea, { "data-testid": "chat-composer-input-area", children: [
8132
8150
  isComposerExpanded || isComposerExpandable ? /* @__PURE__ */ jsx16(
8133
8151
  ComposerExpandButton,
8134
8152
  {
@@ -8195,6 +8213,9 @@ var ChatComposerView = ({
8195
8213
  isModelsLoading,
8196
8214
  isModelsError,
8197
8215
  hasModels,
8216
+ loadingLabel: modelLoadingLabel,
8217
+ loadFailedLabel: modelLoadFailedLabel,
8218
+ unavailableLabel: modelUnavailableLabel,
8198
8219
  onSelectedModelChange,
8199
8220
  onReloadModels
8200
8221
  }
@@ -8218,6 +8239,8 @@ var ChatComposerView = ({
8218
8239
  ref: setSkillMenuFloating,
8219
8240
  style: floatingStyles,
8220
8241
  "data-testid": "chat-composer-skill-menu",
8242
+ "data-placement": placement,
8243
+ "data-floating-strategy": "fixed",
8221
8244
  role: "listbox",
8222
8245
  children: isSkillsLoading ? /* @__PURE__ */ jsx16(SkillMenuState, { "data-testid": "chat-composer-skill-loading", children: skillLoadingLabel }) : filteredSkills.length ? filteredSkills.map((skill, index3) => /* @__PURE__ */ jsx16(
8223
8246
  SkillMenuItem,
@@ -8279,6 +8302,9 @@ var ChatComposer = () => {
8279
8302
  skillLoadingLabel: labels.skillLoading,
8280
8303
  skillEmptyLabel: labels.skillEmpty,
8281
8304
  removeSkillAriaLabel: labels.removeSkillAriaLabel,
8305
+ modelLoadingLabel: labels.modelLoading,
8306
+ modelLoadFailedLabel: labels.modelLoadFailed,
8307
+ modelUnavailableLabel: labels.modelUnavailable,
8282
8308
  onValueChange: actions.setValue,
8283
8309
  onPickImages: actions.pickImages,
8284
8310
  onPasteImages: actions.pasteImages,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xinghunm/ai-chat",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "AI chat React component library",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",