@mieweb/ui 0.8.0-dev.17 → 0.8.0-dev.18

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.cjs CHANGED
@@ -12504,6 +12504,9 @@ var ChatComposer = React13__namespace.forwardRef(function ChatComposer2({
12504
12504
  autoFocus = false,
12505
12505
  maxLength,
12506
12506
  showCharacterCount = false,
12507
+ canSendWhenEmpty = false,
12508
+ maxHeight = MAX_INPUT_HEIGHT,
12509
+ textareaProps,
12507
12510
  addMenuItems,
12508
12511
  allowAttachments = true,
12509
12512
  acceptedFileTypes,
@@ -12549,7 +12552,7 @@ var ChatComposer = React13__namespace.forwardRef(function ChatComposer2({
12549
12552
  const hasText = value.trim().length > 0;
12550
12553
  const hasContent = hasText || attachments.length > 0;
12551
12554
  const isOverLimit = maxLength !== void 0 && value.length > maxLength;
12552
- const canSend = hasContent && onSend !== void 0 && !disabled && !isSending && !isStreaming && !isOverLimit;
12555
+ const canSend = (hasContent || canSendWhenEmpty) && onSend !== void 0 && !disabled && !isSending && !isStreaming && !isOverLimit;
12553
12556
  const setValue = React13__namespace.useCallback(
12554
12557
  (next) => {
12555
12558
  if (!isControlled) setInternalValue(next);
@@ -12561,7 +12564,7 @@ var ChatComposer = React13__namespace.forwardRef(function ChatComposer2({
12561
12564
  const textarea = textareaRef.current;
12562
12565
  if (!textarea) return;
12563
12566
  textarea.style.height = "auto";
12564
- textarea.style.height = `${Math.min(textarea.scrollHeight, MAX_INPUT_HEIGHT)}px`;
12567
+ textarea.style.height = `${textarea.scrollHeight}px`;
12565
12568
  }, [value]);
12566
12569
  const addFiles = React13__namespace.useCallback(
12567
12570
  (files) => {
@@ -12648,7 +12651,8 @@ var ChatComposer = React13__namespace.forwardRef(function ChatComposer2({
12648
12651
  ref,
12649
12652
  () => ({
12650
12653
  addFiles,
12651
- focus: () => textareaRef.current?.focus()
12654
+ focus: () => textareaRef.current?.focus(),
12655
+ getTextarea: () => textareaRef.current
12652
12656
  }),
12653
12657
  [addFiles]
12654
12658
  );
@@ -12732,24 +12736,41 @@ var ChatComposer = React13__namespace.forwardRef(function ChatComposer2({
12732
12736
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-1 pt-1", children: /* @__PURE__ */ jsxRuntime.jsx(
12733
12737
  "textarea",
12734
12738
  {
12739
+ ...textareaProps,
12735
12740
  ref: textareaRef,
12736
12741
  "data-slot": "chat-composer-input",
12737
12742
  value,
12738
- onChange: (event) => setValue(event.target.value),
12739
- onKeyDown: handleKeyDown,
12740
- onPaste: handlePaste,
12743
+ onChange: (event) => {
12744
+ textareaProps?.onChange?.(event);
12745
+ setValue(event.target.value);
12746
+ },
12747
+ onKeyDown: (event) => {
12748
+ textareaProps?.onKeyDown?.(event);
12749
+ if (event.defaultPrevented) return;
12750
+ handleKeyDown(event);
12751
+ },
12752
+ onPaste: (event) => {
12753
+ textareaProps?.onPaste?.(event);
12754
+ if (event.defaultPrevented) return;
12755
+ handlePaste(event);
12756
+ },
12741
12757
  placeholder,
12742
12758
  disabled,
12743
12759
  autoFocus,
12744
12760
  rows: 1,
12745
12761
  "aria-label": inputLabel,
12762
+ style: {
12763
+ ...textareaProps?.style,
12764
+ maxHeight: typeof maxHeight === "number" ? `${maxHeight}px` : maxHeight
12765
+ },
12746
12766
  className: chunkS5RVSXDV_cjs.cn(
12747
12767
  "block w-full resize-none bg-transparent",
12748
12768
  "rounded-lg px-2 pt-2 pb-1 text-sm",
12749
12769
  "text-neutral-900 placeholder:text-neutral-400 dark:text-white dark:placeholder:text-neutral-500",
12750
12770
  // Ring the input itself on focus rather than the whole shell.
12751
12771
  "focus:ring-primary-500 focus:ring-1 focus:outline-none",
12752
- "disabled:cursor-not-allowed"
12772
+ "disabled:cursor-not-allowed",
12773
+ textareaProps?.className
12753
12774
  )
12754
12775
  }
12755
12776
  ) }),