@digital-ai/dot-components 4.24.0 → 4.25.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.
Files changed (2) hide show
  1. package/index.esm.js +32 -28
  2. package/package.json +1 -1
package/index.esm.js CHANGED
@@ -7267,10 +7267,14 @@ const DotAutoComplete = ({
7267
7267
  }
7268
7268
  });
7269
7269
  // Create handler only if 'onInputChange' or 'actionItem' prop is defined
7270
- const handleInputChange = (onInputChange || isActionItemDefined) && ((event, currentInputValue, reason) => {
7271
- isActionItemDefined && setInputText(currentInputValue);
7270
+ // Custom input change handler for AI mode
7271
+ const handleInputChange = (event, currentInputValue, reason) => {
7272
+ if (isActionItemDefined || ai) {
7273
+ setInputText(currentInputValue); // fallback for action item
7274
+ }
7275
+
7272
7276
  onInputChange === null || onInputChange === void 0 ? void 0 : onInputChange(event, currentInputValue, reason);
7273
- }) || undefined;
7277
+ };
7274
7278
  // Create callback when action item click event handler is defined,
7275
7279
  // free-solo mode is NOT set and 'Enter' key has been pressed
7276
7280
  const handleKeyDown = allowActionButtonClick && (event => {
@@ -7317,29 +7321,27 @@ const DotAutoComplete = ({
7317
7321
  }), getInputAdornment(), nativeEndAdornment]
7318
7322
  });
7319
7323
  };
7320
- const renderAISendAdornment = params => {
7321
- const {
7322
- inputProps
7323
- } = params;
7324
- return jsxs(Fragment, {
7325
- children: [jsx(DotIconButton, {
7326
- iconId: "send-airplane",
7327
- tooltip: "Send",
7328
- "data-testid": dataTestId && `${dataTestId}-send-airplane-icon`,
7329
- shape: "square",
7330
- color: "ai",
7331
- disabled: !(inputProps === null || inputProps === void 0 ? void 0 : inputProps.value),
7332
- onClick: () => {
7333
- if (inputProps === null || inputProps === void 0 ? void 0 : inputProps.value) {
7334
- handleAiAction(inputProps.value.toString());
7335
- }
7324
+ const renderAISendAdornment = useMemo(() => {
7325
+ return jsx(DotIconButton, {
7326
+ iconId: "send-airplane",
7327
+ tooltip: "Send",
7328
+ "data-testid": dataTestId && `${dataTestId}-send-airplane-icon`,
7329
+ shape: "square",
7330
+ color: "ai",
7331
+ disabled: !inputText,
7332
+ onClick: () => {
7333
+ if (inputText) {
7334
+ handleAiAction(inputText);
7335
+ setInputText('');
7336
+ onInputChange === null || onInputChange === void 0 ? void 0 : onInputChange({
7337
+ target: {
7338
+ value: ''
7339
+ }
7340
+ }, '', 'clear');
7336
7341
  }
7337
- }), jsx("span", {
7338
- className: "ai-text-clear-icon",
7339
- children: params.InputProps.endAdornment
7340
- })]
7342
+ }
7341
7343
  });
7342
- };
7344
+ }, [inputText]);
7343
7345
  const renderTrimmedLongOptions = (props, option) => {
7344
7346
  const key = 'id' in option ? option.id : option.title;
7345
7347
  return jsx(DotTooltip, {
@@ -7360,7 +7362,7 @@ const DotAutoComplete = ({
7360
7362
  };
7361
7363
  const getEndAdornment = params => {
7362
7364
  if (ai) {
7363
- return renderAISendAdornment(params);
7365
+ return renderAISendAdornment;
7364
7366
  }
7365
7367
  if (!readOnly) {
7366
7368
  return renderEndAdornment(params.InputProps.endAdornment);
@@ -7448,7 +7450,8 @@ const DotAutoComplete = ({
7448
7450
  'data-testid': dataTestId && `${dataTestId}-input`,
7449
7451
  id: inputId,
7450
7452
  className: useStylesWithRootClass(inputProps.className, 'dot-input'),
7451
- readOnly
7453
+ readOnly,
7454
+ value: ai ? inputText : inputProps.value
7452
7455
  }),
7453
7456
  InputLabelProps: {
7454
7457
  htmlFor: inputId
@@ -7469,8 +7472,9 @@ const DotAutoComplete = ({
7469
7472
  if (event.key === 'Enter' && ai) {
7470
7473
  event.stopPropagation();
7471
7474
  event.preventDefault();
7472
- const text = event.target.value;
7473
- handleAiAction(text);
7475
+ handleAiAction(inputText);
7476
+ setInputText(''); // Clear input after enter
7477
+ onInputChange === null || onInputChange === void 0 ? void 0 : onInputChange(event, '', 'clear');
7474
7478
  }
7475
7479
  },
7476
7480
  placeholder: showPlaceholder ? placeholder : undefined,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digital-ai/dot-components",
3
- "version": "4.24.0",
3
+ "version": "4.25.0",
4
4
  "private": false,
5
5
  "license": "SEE LICENSE IN <LICENSE.md>",
6
6
  "contributors": [