@orbe-agro/client-core 5.6.348 → 5.6.349
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/@ecme/assets/styles/app.css +18 -12
- package/dist/@ecme/assets/styles/tailwind/index.css +18 -13
- package/dist/@ecme/components/template/Footer.js +1 -1
- package/dist/@ecme/components/ui/Input/Input.js +3 -1
- package/dist/@ecme/components/ui/Input/Input.js.map +1 -1
- package/dist/@ecme/components/view/ChatBox/components/ChatInput.js +31 -16
- package/dist/@ecme/components/view/ChatBox/components/ChatInput.js.map +1 -1
- package/dist/@ecme/views/concepts/ai/Chat/components/ChatLandingView.js +4 -1
- package/dist/@ecme/views/concepts/ai/Chat/components/ChatLandingView.js.map +1 -1
- package/dist/@ecme/views/concepts/ai/Chat/components/ChatView.js +1 -1
- package/dist/@ecme/views/concepts/ai/Chat/components/ChatView.js.map +1 -1
- package/dist/@ecme/views/concepts/chat/Chat/components/ChatBody.js +1 -1
- package/dist/@ecme/views/concepts/chat/Chat/components/ChatBody.js.map +1 -1
- package/dist/@types/@ecme/components/ui/Input/Input.d.ts.map +1 -1
- package/dist/@types/@ecme/components/view/ChatBox/components/ChatInput.d.ts +1 -1
- package/dist/@types/@ecme/components/view/ChatBox/components/ChatInput.d.ts.map +1 -1
- package/dist/@types/@ecme/views/concepts/ai/Chat/components/ChatLandingView.d.ts.map +1 -1
- package/dist/base/assets/styles/init.css +22 -12
- package/lib/@ecme/components/ui/Input/Input.tsx +3 -1
- package/lib/@ecme/components/view/ChatBox/components/ChatInput.tsx +69 -35
- package/lib/@ecme/views/concepts/ai/Chat/components/ChatLandingView.tsx +6 -1
- package/lib/@ecme/views/concepts/ai/Chat/components/ChatView.tsx +2 -2
- package/lib/@ecme/views/concepts/chat/Chat/components/ChatBody.tsx +1 -1
- package/package.json +1 -1
|
@@ -5408,6 +5408,9 @@ video {
|
|
|
5408
5408
|
.mr-8{
|
|
5409
5409
|
margin-right: 2rem;
|
|
5410
5410
|
}
|
|
5411
|
+
.mt-0{
|
|
5412
|
+
margin-top: 0px;
|
|
5413
|
+
}
|
|
5411
5414
|
.mt-0\.5{
|
|
5412
5415
|
margin-top: 0.125rem;
|
|
5413
5416
|
}
|
|
@@ -5581,9 +5584,6 @@ video {
|
|
|
5581
5584
|
.h-\[42px\]{
|
|
5582
5585
|
height: 42px;
|
|
5583
5586
|
}
|
|
5584
|
-
.h-\[50px\]{
|
|
5585
|
-
height: 50px;
|
|
5586
|
-
}
|
|
5587
5587
|
.h-\[56px\]{
|
|
5588
5588
|
height: 56px;
|
|
5589
5589
|
}
|
|
@@ -5599,9 +5599,6 @@ video {
|
|
|
5599
5599
|
.h-\[calc\(100\%-100px\)\]{
|
|
5600
5600
|
height: calc(100% - 100px);
|
|
5601
5601
|
}
|
|
5602
|
-
.h-\[calc\(100\%-124px\)\]{
|
|
5603
|
-
height: calc(100% - 124px);
|
|
5604
|
-
}
|
|
5605
5602
|
.h-\[calc\(100\%-150px\)\]{
|
|
5606
5603
|
height: calc(100% - 150px);
|
|
5607
5604
|
}
|
|
@@ -5659,6 +5656,9 @@ video {
|
|
|
5659
5656
|
.max-h-\[390px\]{
|
|
5660
5657
|
max-height: 390px;
|
|
5661
5658
|
}
|
|
5659
|
+
.max-h-\[6\.25rem\]{
|
|
5660
|
+
max-height: 6.25rem;
|
|
5661
|
+
}
|
|
5662
5662
|
.max-h-\[600px\]{
|
|
5663
5663
|
max-height: 600px;
|
|
5664
5664
|
}
|
|
@@ -5932,9 +5932,6 @@ video {
|
|
|
5932
5932
|
.min-w-\[330px\]{
|
|
5933
5933
|
min-width: 330px;
|
|
5934
5934
|
}
|
|
5935
|
-
.min-w-\[6rem\]{
|
|
5936
|
-
min-width: 6rem;
|
|
5937
|
-
}
|
|
5938
5935
|
.min-w-full{
|
|
5939
5936
|
min-width: 100%;
|
|
5940
5937
|
}
|
|
@@ -7710,6 +7707,9 @@ video {
|
|
|
7710
7707
|
.last\:mb-0:last-child{
|
|
7711
7708
|
margin-bottom: 0px;
|
|
7712
7709
|
}
|
|
7710
|
+
.focus-within\:border-gray-400:focus-within{
|
|
7711
|
+
border-color: var(--gray-400);
|
|
7712
|
+
}
|
|
7713
7713
|
.focus-within\:border-primary:focus-within{
|
|
7714
7714
|
border-color: var(--primary);
|
|
7715
7715
|
}
|
|
@@ -8371,6 +8371,9 @@ video {
|
|
|
8371
8371
|
.dark\:ring-primary:is(.dark *){
|
|
8372
8372
|
--tw-ring-color: var(--primary);
|
|
8373
8373
|
}
|
|
8374
|
+
.dark\:focus-within\:border-gray-500:focus-within:is(.dark *){
|
|
8375
|
+
border-color: var(--gray-500);
|
|
8376
|
+
}
|
|
8374
8377
|
.dark\:hover\:border-gray-600:hover:is(.dark *){
|
|
8375
8378
|
border-color: var(--gray-600);
|
|
8376
8379
|
}
|
|
@@ -8738,9 +8741,6 @@ video {
|
|
|
8738
8741
|
.xl\:flex{
|
|
8739
8742
|
display: flex;
|
|
8740
8743
|
}
|
|
8741
|
-
.xl\:h-\[calc\(100\%-94px\)\]{
|
|
8742
|
-
height: calc(100% - 94px);
|
|
8743
|
-
}
|
|
8744
8744
|
.xl\:h-full{
|
|
8745
8745
|
height: 100%;
|
|
8746
8746
|
}
|
|
@@ -8868,6 +8868,9 @@ video {
|
|
|
8868
8868
|
.ltr\:ml-\[11\.5px\]:where([dir="ltr"], [dir="ltr"] *){
|
|
8869
8869
|
margin-left: 11.5px;
|
|
8870
8870
|
}
|
|
8871
|
+
.ltr\:ml-auto:where([dir="ltr"], [dir="ltr"] *){
|
|
8872
|
+
margin-left: auto;
|
|
8873
|
+
}
|
|
8871
8874
|
.ltr\:mr-1:where([dir="ltr"], [dir="ltr"] *){
|
|
8872
8875
|
margin-right: 0.25rem;
|
|
8873
8876
|
}
|
|
@@ -8947,6 +8950,9 @@ video {
|
|
|
8947
8950
|
.rtl\:mr-4:where([dir="rtl"], [dir="rtl"] *){
|
|
8948
8951
|
margin-right: 1rem;
|
|
8949
8952
|
}
|
|
8953
|
+
.rtl\:mr-auto:where([dir="rtl"], [dir="rtl"] *){
|
|
8954
|
+
margin-right: auto;
|
|
8955
|
+
}
|
|
8950
8956
|
.rtl\:flex-row-reverse:where([dir="rtl"], [dir="rtl"] *){
|
|
8951
8957
|
flex-direction: row-reverse;
|
|
8952
8958
|
}
|
|
@@ -1485,6 +1485,9 @@ video {
|
|
|
1485
1485
|
.mr-8 {
|
|
1486
1486
|
margin-right: 2rem;
|
|
1487
1487
|
}
|
|
1488
|
+
.mt-0 {
|
|
1489
|
+
margin-top: 0px;
|
|
1490
|
+
}
|
|
1488
1491
|
.mt-0\.5 {
|
|
1489
1492
|
margin-top: 0.125rem;
|
|
1490
1493
|
}
|
|
@@ -1658,9 +1661,6 @@ video {
|
|
|
1658
1661
|
.h-\[42px\] {
|
|
1659
1662
|
height: 42px;
|
|
1660
1663
|
}
|
|
1661
|
-
.h-\[50px\] {
|
|
1662
|
-
height: 50px;
|
|
1663
|
-
}
|
|
1664
1664
|
.h-\[56px\] {
|
|
1665
1665
|
height: 56px;
|
|
1666
1666
|
}
|
|
@@ -1676,9 +1676,6 @@ video {
|
|
|
1676
1676
|
.h-\[calc\(100\%-100px\)\] {
|
|
1677
1677
|
height: calc(100% - 100px);
|
|
1678
1678
|
}
|
|
1679
|
-
.h-\[calc\(100\%-124px\)\] {
|
|
1680
|
-
height: calc(100% - 124px);
|
|
1681
|
-
}
|
|
1682
1679
|
.h-\[calc\(100\%-150px\)\] {
|
|
1683
1680
|
height: calc(100% - 150px);
|
|
1684
1681
|
}
|
|
@@ -1736,6 +1733,9 @@ video {
|
|
|
1736
1733
|
.max-h-\[390px\] {
|
|
1737
1734
|
max-height: 390px;
|
|
1738
1735
|
}
|
|
1736
|
+
.max-h-\[6\.25rem\] {
|
|
1737
|
+
max-height: 6.25rem;
|
|
1738
|
+
}
|
|
1739
1739
|
.max-h-\[600px\] {
|
|
1740
1740
|
max-height: 600px;
|
|
1741
1741
|
}
|
|
@@ -2009,9 +2009,6 @@ video {
|
|
|
2009
2009
|
.min-w-\[330px\] {
|
|
2010
2010
|
min-width: 330px;
|
|
2011
2011
|
}
|
|
2012
|
-
.min-w-\[6rem\] {
|
|
2013
|
-
min-width: 6rem;
|
|
2014
|
-
}
|
|
2015
2012
|
.min-w-full {
|
|
2016
2013
|
min-width: 100%;
|
|
2017
2014
|
}
|
|
@@ -3789,6 +3786,9 @@ video {
|
|
|
3789
3786
|
.last\:mb-0:last-child {
|
|
3790
3787
|
margin-bottom: 0px;
|
|
3791
3788
|
}
|
|
3789
|
+
.focus-within\:border-gray-400:focus-within {
|
|
3790
|
+
border-color: var(--gray-400);
|
|
3791
|
+
}
|
|
3792
3792
|
.focus-within\:border-primary:focus-within {
|
|
3793
3793
|
border-color: var(--primary);
|
|
3794
3794
|
}
|
|
@@ -4468,6 +4468,9 @@ video {
|
|
|
4468
4468
|
.dark\:ring-primary:is(.dark *) {
|
|
4469
4469
|
--tw-ring-color: var(--primary);
|
|
4470
4470
|
}
|
|
4471
|
+
.dark\:focus-within\:border-gray-500:focus-within:is(.dark *) {
|
|
4472
|
+
border-color: var(--gray-500);
|
|
4473
|
+
}
|
|
4471
4474
|
.dark\:hover\:border-gray-600:hover:is(.dark *) {
|
|
4472
4475
|
border-color: var(--gray-600);
|
|
4473
4476
|
}
|
|
@@ -4922,10 +4925,6 @@ video {
|
|
|
4922
4925
|
display: flex;
|
|
4923
4926
|
}
|
|
4924
4927
|
|
|
4925
|
-
.xl\:h-\[calc\(100\%-94px\)\] {
|
|
4926
|
-
height: calc(100% - 94px);
|
|
4927
|
-
}
|
|
4928
|
-
|
|
4929
4928
|
.xl\:h-full {
|
|
4930
4929
|
height: 100%;
|
|
4931
4930
|
}
|
|
@@ -5084,6 +5083,9 @@ video {
|
|
|
5084
5083
|
.ltr\:ml-\[11\.5px\]:where([dir="ltr"], [dir="ltr"] *) {
|
|
5085
5084
|
margin-left: 11.5px;
|
|
5086
5085
|
}
|
|
5086
|
+
.ltr\:ml-auto:where([dir="ltr"], [dir="ltr"] *) {
|
|
5087
|
+
margin-left: auto;
|
|
5088
|
+
}
|
|
5087
5089
|
.ltr\:mr-1:where([dir="ltr"], [dir="ltr"] *) {
|
|
5088
5090
|
margin-right: 0.25rem;
|
|
5089
5091
|
}
|
|
@@ -5165,6 +5167,9 @@ video {
|
|
|
5165
5167
|
.rtl\:mr-4:where([dir="rtl"], [dir="rtl"] *) {
|
|
5166
5168
|
margin-right: 1rem;
|
|
5167
5169
|
}
|
|
5170
|
+
.rtl\:mr-auto:where([dir="rtl"], [dir="rtl"] *) {
|
|
5171
|
+
margin-right: auto;
|
|
5172
|
+
}
|
|
5168
5173
|
.rtl\:flex-row-reverse:where([dir="rtl"], [dir="rtl"] *) {
|
|
5169
5174
|
flex-direction: row-reverse;
|
|
5170
5175
|
}
|
|
@@ -3,7 +3,7 @@ import Container from "../shared/Container.js";
|
|
|
3
3
|
import classNames from "../../utils/classNames.js";
|
|
4
4
|
import { APP_NAME } from "../../constants/app.constant.js";
|
|
5
5
|
import { PAGE_CONTAINER_GUTTER_X } from "../../constants/theme.constant.js";
|
|
6
|
-
const version = true ? "5.6.
|
|
6
|
+
const version = true ? "5.6.349" : "0.0.0";
|
|
7
7
|
const FooterContent = () => {
|
|
8
8
|
return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-auto items-center justify-between", children: [
|
|
9
9
|
/* @__PURE__ */ jsxs("span", { children: [
|
|
@@ -104,7 +104,9 @@ const Input = (props) => {
|
|
|
104
104
|
return gutterStyle;
|
|
105
105
|
};
|
|
106
106
|
const inputProps = {
|
|
107
|
-
|
|
107
|
+
// Sem estilo do template, mas com as classes de quem chamou: `unstyle`
|
|
108
|
+
// remove a aparência padrão, não o className.
|
|
109
|
+
className: !unstyle ? inputClass : className,
|
|
108
110
|
disabled,
|
|
109
111
|
type,
|
|
110
112
|
ref,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.js","sources":["../../../../../lib/@ecme/components/ui/Input/Input.tsx"],"sourcesContent":["import { useState, useEffect, useRef } from \"react\";\nimport classNames from \"classnames\";\nimport { useConfig } from \"../ConfigProvider\";\nimport { useForm, useFormItem } from \"../Form/context\";\nimport { useInputGroup } from \"../InputGroup/context\";\nimport { CONTROL_SIZES } from \"../utils/constants\";\nimport isNil from \"lodash/isNil\";\nimport type { CommonProps, TypeAttributes } from \"../@types/common\";\nimport type {\n InputHTMLAttributes,\n ElementType,\n ReactNode,\n HTMLInputTypeAttribute,\n ClassAttributes,\n Ref,\n} from \"react\";\n\nexport interface InputProps\n extends CommonProps,\n Omit<\n InputHTMLAttributes<HTMLInputElement | HTMLTextAreaElement>,\n \"size\" | \"prefix\"\n > {\n asElement?: ElementType;\n disabled?: boolean;\n invalid?: boolean;\n prefix?: string | ReactNode;\n rows?: number;\n ref?: Ref<ElementType | HTMLInputElement | HTMLTextAreaElement>;\n size?: TypeAttributes.ControlSize;\n suffix?: string | ReactNode;\n textArea?: boolean;\n type?: HTMLInputTypeAttribute;\n unstyle?: boolean;\n disallowWhitespaceOnly?: boolean;\n}\n\nconst Input = (props: InputProps) => {\n const {\n asElement: Component = \"input\",\n className,\n disabled,\n invalid,\n prefix,\n size,\n suffix,\n textArea,\n type = \"text\",\n ref,\n rows,\n style,\n unstyle = false,\n disallowWhitespaceOnly = false,\n ...rest\n } = props;\n\n const [prefixGutter, setPrefixGutter] = useState(0);\n const [suffixGutter, setSuffixGutter] = useState(0);\n\n const { controlSize, direction } = useConfig();\n const formControlSize = useForm()?.size;\n const formItemInvalid = useFormItem()?.invalid;\n const inputGroupSize = useInputGroup()?.size;\n\n const inputSize = size || inputGroupSize || formControlSize || controlSize;\n\n const isInputInvalid = invalid || formItemInvalid;\n\n const fixControlledValue = (\n val: string | number | readonly string[] | undefined\n ) => {\n if (typeof val === \"undefined\" || val === null) {\n return \"\";\n }\n return val;\n };\n\n if (\"value\" in props) {\n rest.value = fixControlledValue(props.value);\n delete rest.defaultValue;\n }\n\n const inputDefaultClass = \"input\";\n const inputSizeClass = `input-${inputSize} ${CONTROL_SIZES[inputSize].h}`;\n const inputFocusClass = `focus:ring-primary focus-within:ring-primary focus-within:border-primary focus:border-primary`;\n const inputWrapperClass = classNames(\n \"input-wrapper\",\n prefix || suffix ? className : \"\"\n );\n const inputClass = classNames(\n inputDefaultClass,\n !textArea && inputSizeClass,\n !isInputInvalid && inputFocusClass,\n !prefix && !suffix ? className : \"\",\n disabled && \"input-disabled\",\n isInputInvalid && \"input-invalid\",\n textArea && \"input-textarea\"\n );\n\n const prefixNode = useRef<HTMLDivElement>(null);\n const suffixNode = useRef<HTMLDivElement>(null);\n\n const getAffixSize = () => {\n if (!prefixNode.current && !suffixNode.current) {\n return;\n }\n const prefixNodeWidth = prefixNode?.current?.offsetWidth;\n const suffixNodeWidth = suffixNode?.current?.offsetWidth;\n\n if (isNil(prefixNodeWidth) && isNil(suffixNodeWidth)) {\n return;\n }\n\n if (prefixNodeWidth) {\n setPrefixGutter(prefixNodeWidth);\n }\n\n if (suffixNodeWidth) {\n setSuffixGutter(suffixNodeWidth);\n }\n };\n\n useEffect(() => {\n getAffixSize();\n }, [prefix, suffix]);\n\n const remToPxConvertion = (pixel: number) => 0.0625 * pixel;\n\n const affixGutterStyle = () => {\n const leftGutter = `${remToPxConvertion(prefixGutter) + 1}rem`;\n const rightGutter = `${remToPxConvertion(suffixGutter) + 1}rem`;\n const gutterStyle: {\n paddingLeft?: string;\n paddingRight?: string;\n } = {};\n\n if (direction === \"ltr\") {\n if (prefix) {\n gutterStyle.paddingLeft = leftGutter;\n }\n\n if (suffix) {\n gutterStyle.paddingRight = rightGutter;\n }\n }\n\n if (direction === \"rtl\") {\n if (prefix) {\n gutterStyle.paddingRight = leftGutter;\n }\n\n if (suffix) {\n gutterStyle.paddingLeft = rightGutter;\n }\n }\n\n return gutterStyle;\n };\n\n const inputProps = {\n className: !unstyle ? inputClass :
|
|
1
|
+
{"version":3,"file":"Input.js","sources":["../../../../../lib/@ecme/components/ui/Input/Input.tsx"],"sourcesContent":["import { useState, useEffect, useRef } from \"react\";\nimport classNames from \"classnames\";\nimport { useConfig } from \"../ConfigProvider\";\nimport { useForm, useFormItem } from \"../Form/context\";\nimport { useInputGroup } from \"../InputGroup/context\";\nimport { CONTROL_SIZES } from \"../utils/constants\";\nimport isNil from \"lodash/isNil\";\nimport type { CommonProps, TypeAttributes } from \"../@types/common\";\nimport type {\n InputHTMLAttributes,\n ElementType,\n ReactNode,\n HTMLInputTypeAttribute,\n ClassAttributes,\n Ref,\n} from \"react\";\n\nexport interface InputProps\n extends CommonProps,\n Omit<\n InputHTMLAttributes<HTMLInputElement | HTMLTextAreaElement>,\n \"size\" | \"prefix\"\n > {\n asElement?: ElementType;\n disabled?: boolean;\n invalid?: boolean;\n prefix?: string | ReactNode;\n rows?: number;\n ref?: Ref<ElementType | HTMLInputElement | HTMLTextAreaElement>;\n size?: TypeAttributes.ControlSize;\n suffix?: string | ReactNode;\n textArea?: boolean;\n type?: HTMLInputTypeAttribute;\n unstyle?: boolean;\n disallowWhitespaceOnly?: boolean;\n}\n\nconst Input = (props: InputProps) => {\n const {\n asElement: Component = \"input\",\n className,\n disabled,\n invalid,\n prefix,\n size,\n suffix,\n textArea,\n type = \"text\",\n ref,\n rows,\n style,\n unstyle = false,\n disallowWhitespaceOnly = false,\n ...rest\n } = props;\n\n const [prefixGutter, setPrefixGutter] = useState(0);\n const [suffixGutter, setSuffixGutter] = useState(0);\n\n const { controlSize, direction } = useConfig();\n const formControlSize = useForm()?.size;\n const formItemInvalid = useFormItem()?.invalid;\n const inputGroupSize = useInputGroup()?.size;\n\n const inputSize = size || inputGroupSize || formControlSize || controlSize;\n\n const isInputInvalid = invalid || formItemInvalid;\n\n const fixControlledValue = (\n val: string | number | readonly string[] | undefined\n ) => {\n if (typeof val === \"undefined\" || val === null) {\n return \"\";\n }\n return val;\n };\n\n if (\"value\" in props) {\n rest.value = fixControlledValue(props.value);\n delete rest.defaultValue;\n }\n\n const inputDefaultClass = \"input\";\n const inputSizeClass = `input-${inputSize} ${CONTROL_SIZES[inputSize].h}`;\n const inputFocusClass = `focus:ring-primary focus-within:ring-primary focus-within:border-primary focus:border-primary`;\n const inputWrapperClass = classNames(\n \"input-wrapper\",\n prefix || suffix ? className : \"\"\n );\n const inputClass = classNames(\n inputDefaultClass,\n !textArea && inputSizeClass,\n !isInputInvalid && inputFocusClass,\n !prefix && !suffix ? className : \"\",\n disabled && \"input-disabled\",\n isInputInvalid && \"input-invalid\",\n textArea && \"input-textarea\"\n );\n\n const prefixNode = useRef<HTMLDivElement>(null);\n const suffixNode = useRef<HTMLDivElement>(null);\n\n const getAffixSize = () => {\n if (!prefixNode.current && !suffixNode.current) {\n return;\n }\n const prefixNodeWidth = prefixNode?.current?.offsetWidth;\n const suffixNodeWidth = suffixNode?.current?.offsetWidth;\n\n if (isNil(prefixNodeWidth) && isNil(suffixNodeWidth)) {\n return;\n }\n\n if (prefixNodeWidth) {\n setPrefixGutter(prefixNodeWidth);\n }\n\n if (suffixNodeWidth) {\n setSuffixGutter(suffixNodeWidth);\n }\n };\n\n useEffect(() => {\n getAffixSize();\n }, [prefix, suffix]);\n\n const remToPxConvertion = (pixel: number) => 0.0625 * pixel;\n\n const affixGutterStyle = () => {\n const leftGutter = `${remToPxConvertion(prefixGutter) + 1}rem`;\n const rightGutter = `${remToPxConvertion(suffixGutter) + 1}rem`;\n const gutterStyle: {\n paddingLeft?: string;\n paddingRight?: string;\n } = {};\n\n if (direction === \"ltr\") {\n if (prefix) {\n gutterStyle.paddingLeft = leftGutter;\n }\n\n if (suffix) {\n gutterStyle.paddingRight = rightGutter;\n }\n }\n\n if (direction === \"rtl\") {\n if (prefix) {\n gutterStyle.paddingRight = leftGutter;\n }\n\n if (suffix) {\n gutterStyle.paddingLeft = rightGutter;\n }\n }\n\n return gutterStyle;\n };\n\n const inputProps = {\n // Sem estilo do template, mas com as classes de quem chamou: `unstyle`\n // remove a aparência padrão, não o className.\n className: !unstyle ? inputClass : className,\n disabled,\n type,\n ref,\n ...rest,\n };\n\n if (disallowWhitespaceOnly && type === \"text\") {\n inputProps.pattern = \"\\\\S(?!\\\\s*$).*\"; \n inputProps.title = \"Este campo não pode conter apenas espaços.\"; \n }\n\n const renderTextArea = (\n <textarea\n style={style}\n rows={rows}\n {...(inputProps as ClassAttributes<HTMLTextAreaElement>)}\n ></textarea>\n );\n\n const renderInput = (\n <Component style={{ ...affixGutterStyle(), ...style }} {...inputProps} />\n );\n\n const renderAffixInput = (\n <span className={inputWrapperClass}>\n {prefix ? (\n <div ref={prefixNode} className=\"input-suffix-start\">\n {\" \"}\n {prefix}{\" \"}\n </div>\n ) : null}\n {renderInput}\n {suffix ? (\n <div ref={suffixNode} className=\"input-suffix-end\">\n {suffix}\n </div>\n ) : null}\n </span>\n );\n\n const renderChildren = () => {\n if (textArea) {\n return renderTextArea;\n }\n\n if (prefix || suffix) {\n return renderAffixInput;\n } else {\n return renderInput;\n }\n };\n\n return renderChildren();\n};\n\nexport default Input;\n"],"names":[],"mappings":";;;;;;;;;AAqCA,MAAM,QAAQ,CAAC,UAAsB;AACnC,QAAM;AAAA,IACJ,WAAW,YAAY;AAAA,IACvB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV,yBAAyB;AAAA,IACzB,GAAG;AAAA,EAAA,IACD;AAEJ,QAAM,CAAC,cAAc,eAAe,IAAI,SAAS,CAAC;AAClD,QAAM,CAAC,cAAc,eAAe,IAAI,SAAS,CAAC;AAElD,QAAM,EAAE,aAAa,UAAA,IAAc,UAAA;AACnC,QAAM,kBAAkB,WAAW;AACnC,QAAM,kBAAkB,eAAe;AACvC,QAAM,iBAAiB,iBAAiB;AAExC,QAAM,YAAY,QAAQ,kBAAkB,mBAAmB;AAE/D,QAAM,iBAAiB,WAAW;AAElC,QAAM,qBAAqB,CACzB,QACG;AACH,QAA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time";
|
|
2
2
|
import { useState, useRef } from "react";
|
|
3
3
|
import "../../../ui/Button/index.js";
|
|
4
|
+
import "../../../ui/Input/index.js";
|
|
4
5
|
import "../../../ui/Upload/index.js";
|
|
5
6
|
import hooks from "../../../ui/hooks/index.js";
|
|
6
7
|
import { TbPhotoPlus, TbPlayerStopFilled, TbArrowRight } from "react-icons/tb";
|
|
7
8
|
import Upload from "../../../ui/Upload/Upload.js";
|
|
9
|
+
import Input from "../../../ui/Input/Input.js";
|
|
8
10
|
import Button from "../../../ui/Button/Button.js";
|
|
9
11
|
const { useMergeRef } = hooks;
|
|
12
|
+
const CLASSES_DO_TEXTAREA = "w-full max-h-[6.25rem] resize-none overflow-y-auto bg-transparent p-0 leading-5 heading-text placeholder:text-gray-400 focus:outline-none";
|
|
10
13
|
const ChatInput = (props) => {
|
|
11
14
|
const [attachments, setAttachments] = useState([]);
|
|
12
15
|
const {
|
|
@@ -19,9 +22,14 @@ const ChatInput = (props) => {
|
|
|
19
22
|
onStop
|
|
20
23
|
} = props;
|
|
21
24
|
const inputRef = useRef(null);
|
|
25
|
+
const ajustarAltura = (el) => {
|
|
26
|
+
el.style.height = "auto";
|
|
27
|
+
el.style.height = `${el.scrollHeight}px`;
|
|
28
|
+
};
|
|
22
29
|
const handleInputClear = () => {
|
|
23
30
|
if (inputRef.current) {
|
|
24
31
|
inputRef.current.value = "";
|
|
32
|
+
inputRef.current.style.height = "";
|
|
25
33
|
}
|
|
26
34
|
setAttachments([]);
|
|
27
35
|
};
|
|
@@ -34,22 +42,38 @@ const ChatInput = (props) => {
|
|
|
34
42
|
handleInputClear();
|
|
35
43
|
};
|
|
36
44
|
const handleKeyDown = (event) => {
|
|
37
|
-
if (event.key === "Enter" && !
|
|
38
|
-
|
|
45
|
+
if (event.key === "Enter" && !event.shiftKey && !event.nativeEvent.isComposing) {
|
|
46
|
+
event.preventDefault();
|
|
47
|
+
if (!executando) {
|
|
48
|
+
enviar();
|
|
49
|
+
}
|
|
39
50
|
}
|
|
40
51
|
};
|
|
41
|
-
return /* @__PURE__ */ jsxs("div", { className: "border-2 border-gray-200 dark:border-gray-700 rounded-xl
|
|
52
|
+
return /* @__PURE__ */ jsxs("div", { className: "shrink-0 border-2 border-gray-200 dark:border-gray-700 rounded-xl px-3 py-2 flex flex-col gap-1.5 transition-colors focus-within:border-gray-400 dark:focus-within:border-gray-500", children: [
|
|
42
53
|
attachments.length > 0 && /* @__PURE__ */ jsx(
|
|
43
54
|
Upload,
|
|
44
55
|
{
|
|
45
56
|
fileList: attachments,
|
|
46
|
-
fileListClass: "flex gap-
|
|
57
|
+
fileListClass: "mt-0 flex flex-wrap gap-2",
|
|
47
58
|
fileItemClass: "flex gap-8",
|
|
48
59
|
onFileRemove: setAttachments,
|
|
49
60
|
children: /* @__PURE__ */ jsx(Fragment, {})
|
|
50
61
|
}
|
|
51
62
|
),
|
|
52
|
-
/* @__PURE__ */
|
|
63
|
+
/* @__PURE__ */ jsx(
|
|
64
|
+
Input,
|
|
65
|
+
{
|
|
66
|
+
ref: useMergeRef(inputRef, ref),
|
|
67
|
+
textArea: true,
|
|
68
|
+
unstyle: true,
|
|
69
|
+
rows: 1,
|
|
70
|
+
placeholder,
|
|
71
|
+
onKeyDown: handleKeyDown,
|
|
72
|
+
onChange: (event) => ajustarAltura(event.currentTarget),
|
|
73
|
+
className: CLASSES_DO_TEXTAREA
|
|
74
|
+
}
|
|
75
|
+
),
|
|
76
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 w-full", children: [
|
|
53
77
|
/* @__PURE__ */ jsx(
|
|
54
78
|
Upload,
|
|
55
79
|
{
|
|
@@ -68,17 +92,8 @@ const ChatInput = (props) => {
|
|
|
68
92
|
)
|
|
69
93
|
}
|
|
70
94
|
),
|
|
71
|
-
/* @__PURE__ */ jsx(
|
|
72
|
-
"input",
|
|
73
|
-
{
|
|
74
|
-
ref: useMergeRef(inputRef, ref),
|
|
75
|
-
className: "flex-1 min-w-[6rem] h-full placeholder:text-gray-400 bg-transparent focus:outline-none heading-text",
|
|
76
|
-
placeholder,
|
|
77
|
-
onKeyDown: handleKeyDown
|
|
78
|
-
}
|
|
79
|
-
),
|
|
80
95
|
inputActions,
|
|
81
|
-
executando ? /* @__PURE__ */ jsx(
|
|
96
|
+
/* @__PURE__ */ jsx("div", { className: "ltr:ml-auto rtl:mr-auto shrink-0", children: executando ? /* @__PURE__ */ jsx(
|
|
82
97
|
Button,
|
|
83
98
|
{
|
|
84
99
|
size: "xs",
|
|
@@ -100,7 +115,7 @@ const ChatInput = (props) => {
|
|
|
100
115
|
title: "Enviar",
|
|
101
116
|
onClick: enviar
|
|
102
117
|
}
|
|
103
|
-
)
|
|
118
|
+
) })
|
|
104
119
|
] })
|
|
105
120
|
] });
|
|
106
121
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatInput.js","sources":["../../../../../../lib/@ecme/components/view/ChatBox/components/ChatInput.tsx"],"sourcesContent":["import { useState, useRef } from 'react'\nimport Button from '@/components/ui/Button'\nimport Upload from '@/components/ui/Upload'\nimport hooks from '@/components/ui/hooks'\nimport { TbPhotoPlus, TbArrowRight, TbPlayerStopFilled } from 'react-icons/tb'\nimport type { UploadProps } from '@/components/ui/Upload'\nimport type { KeyboardEvent, ReactNode, Ref } from 'react'\n\nexport type ChatInputProps = {\n placeholder?: string\n onInputChange?: (payload: { value: string; attachments: File[] }) => void\n ref?: Ref<
|
|
1
|
+
{"version":3,"file":"ChatInput.js","sources":["../../../../../../lib/@ecme/components/view/ChatBox/components/ChatInput.tsx"],"sourcesContent":["import { useState, useRef } from 'react'\nimport Button from '@/components/ui/Button'\nimport Input from '@/components/ui/Input'\nimport Upload from '@/components/ui/Upload'\nimport hooks from '@/components/ui/hooks'\nimport { TbPhotoPlus, TbArrowRight, TbPlayerStopFilled } from 'react-icons/tb'\nimport type { UploadProps } from '@/components/ui/Upload'\nimport type { KeyboardEvent, ReactNode, Ref } from 'react'\n\nexport type ChatInputProps = {\n placeholder?: string\n onInputChange?: (payload: { value: string; attachments: File[] }) => void\n ref?: Ref<HTMLTextAreaElement>\n /** Controles extras dentro da caixa, logo antes do botão de enviar. */\n inputActions?: ReactNode\n /** Restrições do seletor de anexos (tipos aceitos, validação e bloqueio). */\n uploadProps?: Pick<UploadProps, 'accept' | 'beforeUpload' | 'disabled'>\n /**\n * Uma resposta está chegando: o botão de enviar vira o de parar, e o Enter\n * não envia — senão abriria uma segunda resposta na mesma conversa. O texto\n * digitado fica na caixa para depois.\n */\n executando?: boolean\n /** Para a resposta que está chegando. */\n onStop?: () => void\n}\n\nconst { useMergeRef } = hooks\n\n/**\n * A altura inicial é `rows={1}`. Daí cresce com o conteúdo até o `max-h` de\n * 5 linhas de 20px (`leading-5`, o ritmo do texto de 14px do app); passando\n * disso, o próprio textarea rola.\n */\nconst CLASSES_DO_TEXTAREA =\n 'w-full max-h-[6.25rem] resize-none overflow-y-auto bg-transparent p-0 leading-5 heading-text placeholder:text-gray-400 focus:outline-none'\n\nconst ChatInput = (props: ChatInputProps) => {\n const [attachments, setAttachments] = useState<File[]>([])\n\n const {\n placeholder,\n onInputChange,\n ref = null,\n inputActions,\n uploadProps,\n executando = false,\n onStop,\n } = props\n\n const inputRef = useRef<HTMLTextAreaElement>(null)\n\n /** Cresce com o conteúdo; o `max-h` do textarea é o limite. */\n const ajustarAltura = (el: HTMLInputElement | HTMLTextAreaElement) => {\n el.style.height = 'auto'\n el.style.height = `${el.scrollHeight}px`\n }\n\n const handleInputClear = () => {\n if (inputRef.current) {\n inputRef.current.value = ''\n // Volta para a altura de uma linha.\n inputRef.current.style.height = ''\n }\n setAttachments([])\n }\n\n /** Envia texto, anexos ou os dois; com a caixa vazia não faz nada. */\n const enviar = () => {\n const value = inputRef.current?.value ?? ''\n if (!value.trim() && attachments.length === 0) {\n return\n }\n onInputChange?.({ value, attachments })\n handleInputClear()\n }\n\n const handleKeyDown = (\n event: KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>,\n ) => {\n // Enter envia; Shift+Enter quebra linha. Composição de IME (acentos)\n // não envia: o Enter ali está confirmando o caractere.\n if (\n event.key === 'Enter' &&\n !event.shiftKey &&\n !event.nativeEvent.isComposing\n ) {\n event.preventDefault()\n if (!executando) {\n enviar()\n }\n }\n }\n\n return (\n <div className=\"shrink-0 border-2 border-gray-200 dark:border-gray-700 rounded-xl px-3 py-2 flex flex-col gap-1.5 transition-colors focus-within:border-gray-400 dark:focus-within:border-gray-500\">\n {attachments.length > 0 && (\n <Upload\n fileList={attachments}\n fileListClass=\"mt-0 flex flex-wrap gap-2\"\n fileItemClass=\"flex gap-8\"\n onFileRemove={setAttachments}\n >\n <></>\n </Upload>\n )}\n <Input\n ref={useMergeRef(inputRef, ref)}\n textArea\n unstyle\n rows={1}\n placeholder={placeholder}\n onKeyDown={handleKeyDown}\n onChange={(event) => ajustarAltura(event.currentTarget)}\n className={CLASSES_DO_TEXTAREA}\n />\n <div className=\"flex items-center gap-2 w-full\">\n <Upload\n {...uploadProps}\n fileList={attachments}\n showList={false}\n onChange={setAttachments}\n >\n <button\n className=\"text-xl heading-text enabled:hover:text-primary disabled:cursor-not-allowed disabled:opacity-40 px-1 py-2\"\n type=\"button\"\n disabled={uploadProps?.disabled}\n >\n <TbPhotoPlus />\n </button>\n </Upload>\n {inputActions}\n <div className=\"ltr:ml-auto rtl:mr-auto shrink-0\">\n {executando ? (\n <Button\n size=\"xs\"\n shape=\"circle\"\n variant=\"solid\"\n icon={<TbPlayerStopFilled />}\n aria-label=\"Parar a resposta\"\n title=\"Parar a resposta\"\n onClick={onStop}\n />\n ) : (\n <Button\n size=\"xs\"\n shape=\"circle\"\n variant=\"solid\"\n icon={<TbArrowRight />}\n aria-label=\"Enviar\"\n title=\"Enviar\"\n onClick={enviar}\n />\n )}\n </div>\n </div>\n </div>\n )\n}\n\nexport default ChatInput\n"],"names":[],"mappings":";;;;;;;;;;AA2BA,MAAM,EAAE,gBAAgB;AAOxB,MAAM,sBACF;AAEJ,MAAM,YAA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M;AAAA,QACN;AAAA,QACA,WAAW;AAAA,QACX,UAAU,CAAC,UAAU,cAAc,MAAM,aAAa;AAAA,QACtD,WAAW;AAAA,MAAA;AAAA,IAAA;AAAA,IAEf,qBAAC,OAAA,EAAI,WAAU,kCACX,UAAA;AAAA,MAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACI,GAAG;AAAA,UACJ,UAAU;AAAA,UACV,UAAU;AAAA,UACV,UAAU;AAAA,UAEV,UAAA;AAAA,YAAC;AAAA,YAAA;AAAA,cACG,WAAU;AAAA,cACV,MAAK;AAAA,cACL,UAAU,aAAa;AAAA,cAEvB,8BAAC,aAAA,CAAA,CAAY;AAAA,YAAA;AAAA,UAAA;AAAA,QACjB;AAAA,MAAA;AAAA,MAEH;AAAA,MACD,oBAAC,OAAA,EAAI,WAAU,oCACV,UAAA,aACG;AAAA,QAAC;AAAA,QAAA;AAAA,UACG,MAAK;AAAA,UACL,OAAM;AAAA,UACN,SAAQ;AAAA,UACR,0BAAO,oBAAA,EAAmB;AAAA,UAC1B,cAAW;AAAA,UACX,OAAM;AAAA,UACN,SAAS;AAAA,QAAA;AAAA,MAAA,IAGb;AAAA,QAAC;AAAA,QAAA;AAAA,UACG,MAAK;AAAA,UACL,OAAM;AAAA,UACN,SAAQ;AAAA,UACR,0BAAO,cAAA,EAAa;AAAA,UACpB,cAAW;AAAA,UACX,OAAM;AAAA,UACN,SAAS;AAAA,QAAA;AAAA,MAAA,EACb,CAER;AAAA,IAAA,EAAA,CACJ;AAAA,EAAA,GACJ;AAER;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useSessionUser } from "../../../../../store/authStore.js";
|
|
2
3
|
import useChatSend from "../hooks/useChatSend.js";
|
|
3
4
|
import { iconeFerramenta } from "./toolPresentation.js";
|
|
4
5
|
const promptSuggestion = [
|
|
@@ -29,9 +30,11 @@ const promptSuggestion = [
|
|
|
29
30
|
];
|
|
30
31
|
const ChatLandingView = () => {
|
|
31
32
|
const { handleSend } = useChatSend();
|
|
33
|
+
const userName = useSessionUser((state) => state.user.userName);
|
|
34
|
+
const primeiroNome = userName?.trim().split(/\s+/)[0] ?? "";
|
|
32
35
|
return /* @__PURE__ */ jsx("div", { className: "max-w-[900px] w-full mx-auto mt-6", children: /* @__PURE__ */ jsxs("div", { children: [
|
|
33
36
|
/* @__PURE__ */ jsxs("div", { className: "heading-text text-2xl leading-snug", children: [
|
|
34
|
-
/* @__PURE__ */ jsx("span", { className: "font-semibold bg-gradient-to-r from-indigo-500 to-red-400 bg-clip-text text-transparent text-3xl", children: "Olá!" }),
|
|
37
|
+
/* @__PURE__ */ jsx("span", { className: "font-semibold bg-gradient-to-r from-indigo-500 to-red-400 bg-clip-text text-transparent text-3xl", children: primeiroNome ? `Olá, ${primeiroNome}!` : "Olá!" }),
|
|
35
38
|
/* @__PURE__ */ jsx("br", {}),
|
|
36
39
|
/* @__PURE__ */ jsx("span", { children: "Como posso te ajudar hoje?" })
|
|
37
40
|
] }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatLandingView.js","sources":["../../../../../../../lib/@ecme/views/concepts/ai/Chat/components/ChatLandingView.tsx"],"sourcesContent":["import useChatSend from '../hooks/useChatSend'\nimport { iconeFerramenta } from './toolPresentation'\n\n/**\n * O que o agente sabe fazer, em quatro exemplos que executam de verdade.\n *\n * `title` e o rotulo curto do card; `prompt` e a frase enviada ao agente.\n * `tool` nomeia a ferramenta que o exemplo exercita e de onde sai o icone —\n * o MESMO que aparecera no chip quando ela rodar, entao o card e a execucao\n * falam a mesma lingua e ha um registro so (ver toolPresentation.ts).\n *\n * Os dois exemplos de criacao mandam a intencao SEM os dados de proposito: o\n * agente pede os campos que faltam por formulario e so entao abre a tela de\n * aprovacao — o fluxo humano inteiro em um clique. Nada e gravado sem confirmar.\n */\nconst promptSuggestion: {\n title: string\n prompt: string\n tool: string\n cor: string\n}[] = [\n {\n title: 'Buscar um usuário pelo ID',\n prompt: 'Quem é o usuário de um dado id?',\n tool: 'buscar_usuario',\n cor: 'text-blue-500',\n },\n {\n title: 'Consultar uma área pelo código',\n prompt: 'Me mostra a área de um dado id?',\n tool: 'buscar_area',\n cor: 'text-emerald-500',\n },\n {\n title: 'Criar uma nova área',\n prompt: 'Quero criar uma área nova',\n tool: 'criar_area',\n cor: 'text-amber-500',\n },\n {\n title: 'Criar um contrato de compra de grãos',\n prompt: 'Quero criar um contrato de compra de armazenagem de grãos',\n tool: 'criar_contrato_armazenagem_graos',\n cor: 'text-indigo-500',\n },\n]\n\nconst ChatLandingView = () => {\n const { handleSend } = useChatSend()\n\n return (\n <div className=\"max-w-[900px] w-full mx-auto mt-6\">\n <div>\n <div className=\"heading-text text-2xl leading-snug\">\n <span className=\"font-semibold bg-gradient-to-r from-indigo-500 to-red-400 bg-clip-text text-transparent text-3xl\">\n Ol
|
|
1
|
+
{"version":3,"file":"ChatLandingView.js","sources":["../../../../../../../lib/@ecme/views/concepts/ai/Chat/components/ChatLandingView.tsx"],"sourcesContent":["import { useSessionUser } from '@/store/authStore'\nimport useChatSend from '../hooks/useChatSend'\nimport { iconeFerramenta } from './toolPresentation'\n\n/**\n * O que o agente sabe fazer, em quatro exemplos que executam de verdade.\n *\n * `title` e o rotulo curto do card; `prompt` e a frase enviada ao agente.\n * `tool` nomeia a ferramenta que o exemplo exercita e de onde sai o icone —\n * o MESMO que aparecera no chip quando ela rodar, entao o card e a execucao\n * falam a mesma lingua e ha um registro so (ver toolPresentation.ts).\n *\n * Os dois exemplos de criacao mandam a intencao SEM os dados de proposito: o\n * agente pede os campos que faltam por formulario e so entao abre a tela de\n * aprovacao — o fluxo humano inteiro em um clique. Nada e gravado sem confirmar.\n */\nconst promptSuggestion: {\n title: string\n prompt: string\n tool: string\n cor: string\n}[] = [\n {\n title: 'Buscar um usuário pelo ID',\n prompt: 'Quem é o usuário de um dado id?',\n tool: 'buscar_usuario',\n cor: 'text-blue-500',\n },\n {\n title: 'Consultar uma área pelo código',\n prompt: 'Me mostra a área de um dado id?',\n tool: 'buscar_area',\n cor: 'text-emerald-500',\n },\n {\n title: 'Criar uma nova área',\n prompt: 'Quero criar uma área nova',\n tool: 'criar_area',\n cor: 'text-amber-500',\n },\n {\n title: 'Criar um contrato de compra de grãos',\n prompt: 'Quero criar um contrato de compra de armazenagem de grãos',\n tool: 'criar_contrato_armazenagem_graos',\n cor: 'text-indigo-500',\n },\n]\n\nconst ChatLandingView = () => {\n const { handleSend } = useChatSend()\n // O nome completo vem do backend (`resp.nome`, ver AuthProvider). A\n // saudação usa só o primeiro nome, e cai no \"Olá!\" sem nome se ele faltar.\n const userName = useSessionUser((state) => state.user.userName)\n const primeiroNome = userName?.trim().split(/\\s+/)[0] ?? ''\n\n return (\n <div className=\"max-w-[900px] w-full mx-auto mt-6\">\n <div>\n <div className=\"heading-text text-2xl leading-snug\">\n <span className=\"font-semibold bg-gradient-to-r from-indigo-500 to-red-400 bg-clip-text text-transparent text-3xl\">\n {primeiroNome ? `Olá, ${primeiroNome}!` : 'Olá!'}\n </span>\n <br />\n <span>Como posso te ajudar hoje?</span>\n </div>\n <div className=\"mt-6 grid grid-cols-1 sm:grid-cols-2 gap-3\">\n {promptSuggestion.map((suggestion) => {\n const Icone = iconeFerramenta(suggestion.tool)\n\n return (\n <div\n key={suggestion.title}\n className=\"flex flex-col gap-3 justify-between rounded-xl bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 p-4 min-h-28 cursor-pointer\"\n role=\"button\"\n onClick={() => handleSend(suggestion.prompt)}\n >\n <h6 className=\"font-normal\">\n {suggestion.title}\n </h6>\n <div>\n <div className=\"bg-white dark:bg-gray-800 rounded-full p-2 inline-flex\">\n <span className=\"text-2xl\">\n <Icone className={suggestion.cor} />\n </span>\n </div>\n </div>\n </div>\n )\n })}\n </div>\n </div>\n </div>\n )\n}\n\nexport default ChatLandingView\n"],"names":[],"mappings":";;;;AAgBA,MAAM,mBAKA;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YACZ,8BAAC,OAAA,EAAM,WAAW,WAAW,IAAA,CAAK,EAAA,CACtC,GACJ,EAAA,CACJ;AAAA,UAAA;AAAA,QAAA;AAAA,QAdK,WAAW;AAAA,MAAA;AAAA,IAiB5B,CAAC,EAAA,CACL;AAAA,EAAA,EAAA,CACJ,EAAA,CACJ;AAER;"}
|
|
@@ -89,7 +89,7 @@ const ChatView = ({
|
|
|
89
89
|
errorBubbleClass: "bg-red-50 dark:bg-red-500/10 border border-red-200 dark:border-red-500/20",
|
|
90
90
|
renderTyping: () => /* @__PURE__ */ jsx("div", { className: BALAO_AGENTE, children: /* @__PURE__ */ jsx(AiThinkingIndicator, {}) }),
|
|
91
91
|
containerClass: showMobileNav ? "h-[calc(100%-30px)] xl:h-full" : "h-full",
|
|
92
|
-
messageListClass: "
|
|
92
|
+
messageListClass: "flex-1 min-h-0",
|
|
93
93
|
typing: isTyping || carregando ? {
|
|
94
94
|
id: "ai",
|
|
95
95
|
name: "Chat AI",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatView.js","sources":["../../../../../../../lib/@ecme/views/concepts/ai/Chat/components/ChatView.tsx"],"sourcesContent":["import { useRef, useEffect, useMemo } from 'react'\nimport Card from '@/components/ui/Card'\nimport ChatBox from '@/components/view/ChatBox'\nimport ChatLandingView from './ChatLandingView'\nimport ChatMobileNav from './ChatMobileNav'\nimport ChatCustomContent from './ChatCustomContent'\nimport ChatCustomAction from './ChatCustomAction'\nimport AiThinkingIndicator from './AiThinkingIndicator'\nimport AiErrorMessage from './AiErrorMessage'\nimport RespostaInterrompida from './RespostaInterrompida'\nimport ToolCallChip from './ToolCallChip'\nimport ApprovalCard from './ApprovalCard'\nimport DataRequestCard from './DataRequestCard'\nimport FormatoCard from './FormatoCard'\nimport ModeloERaciocinio from './ModeloERaciocinio'\nimport ImagensDaMensagem from './ImagensDaMensagem'\nimport PlanilhaNaMensagem from './PlanilhaNaMensagem'\nimport RelatorioNaMensagem from './RelatorioNaMensagem'\nimport { UPLOAD_DE_IMAGENS } from '../imagens'\nimport { usGenerativeChatStore } from '../store/generativeChatStore'\nimport useChatSend from '../hooks/useChatSend'\nimport useConversationMessages from '../hooks/useConversationMessages'\nimport useModelos from '../hooks/useModelos'\nimport type { Conversation } from '../types'\nimport type { ScrollBarRef } from '@/components/ui/ScrollBar'\n\n/**\n * O balao de fala do agente, desenhado aqui em vez de vir do ChatBox.\n *\n * O `botBubbleClass` abaixo zera o balao que o Message desenharia, para os chips\n * de ferramenta e o card de aprovacao ficarem FORA dele — antes tudo dividia a\n * mesma caixa cinza e as ferramentas eram lidas como uma segunda mensagem.\n * Usado tambem pelo indicador de \"pensando\", que passa pelo mesmo balao zerado.\n *\n * Repete `prose text-sm` do balao original de proposito: o reset de margem do\n * @tailwindcss/typography e `.prose > :first-child`, filho DIRETO. Sem o `prose`\n * aqui, o markdown ficaria um nivel abaixo do container e o primeiro paragrafo\n * voltaria a ter margem, inflando todos os baloes.\n */\nconst BALAO_AGENTE =\n 'prose rounded-xl bg-gray-100 px-5 py-2.5 text-sm text-gray-900 dark:bg-gray-700 dark:text-gray-100'\n\ntype ChatViewProps = {\n /**\n * Mostra o drawer de histórico do ChatMobileNav abaixo de xl. O widget\n * flutuante desliga, porque tem o próprio drawer dentro do painel.\n */\n showMobileNav?: boolean\n /**\n * Classes dos menus flutuantes do chat. O widget passa um z-index acima do\n * próprio painel; sem isso o menu abriria atrás dele.\n */\n dropdownFloatingClass?: string\n}\n\nconst ChatView = ({\n showMobileNav = true,\n dropdownFloatingClass,\n}: ChatViewProps) => {\n const scrollRef = useRef<ScrollBarRef>(null)\n const {\n selectedConversation,\n chatHistory,\n isTyping,\n execucao,\n disabledChatFresh,\n } = usGenerativeChatStore()\n const {\n handleSend,\n handleStop,\n handleApproval,\n handleDataSubmit,\n handleFormato,\n } = useChatSend()\n // Conversa aberta da lista: as mensagens vêm do backend na primeira vez.\n const { carregando } = useConversationMessages()\n // Modelo que só lê texto: o botão de imagem fica desligado.\n const { atual } = useModelos()\n\n const scrollToBottom = () => {\n if (scrollRef.current?.getScrollElement) {\n const scrollElement = scrollRef.current.getScrollElement()\n if (scrollElement) {\n scrollElement.scrollTop = scrollElement.scrollHeight\n }\n }\n }\n\n useEffect(() => {\n scrollToBottom()\n }, [selectedConversation, chatHistory])\n\n const messageList = useMemo(() => {\n const chat = chatHistory.find(\n (chat) => chat.id === selectedConversation,\n )\n return chat?.conversation || []\n }, [selectedConversation, chatHistory])\n\n const handleInputChange = async ({\n value,\n attachments,\n }: {\n value: string\n attachments: File[]\n }) => {\n await handleSend(value, attachments)\n }\n\n const handleFinish = (id: string) => {\n disabledChatFresh(id)\n scrollToBottom()\n }\n\n return (\n <Card className=\"flex-1 h-full\" bodyClass=\"h-full\">\n {showMobileNav && <ChatMobileNav />}\n <ChatBox\n ref={scrollRef}\n messageList={messageList}\n placeholder=\"Pergunte algo sobre o Orbe Agro…\"\n showMessageList={Boolean(selectedConversation)}\n showAvatar={false}\n avatarGap={false}\n myBubbleClass=\"bg-primary text-white\"\n botBubbleClass=\"bg-transparent dark:bg-transparent p-0 rounded-none\"\n errorBubbleClass=\"bg-red-50 dark:bg-red-500/10 border border-red-200 dark:border-red-500/20\"\n renderTyping={() => (\n <div className={BALAO_AGENTE}>\n <AiThinkingIndicator />\n </div>\n )}\n containerClass={\n showMobileNav ? 'h-[calc(100%-30px)] xl:h-full' : 'h-full'\n }\n // +24px sobre a altura do input: espaco da linha de aviso.\n messageListClass=\"h-[calc(100%-124px)] xl:h-[calc(100%-94px)]\"\n typing={\n isTyping || carregando\n ? {\n id: 'ai',\n name: 'Chat AI',\n avatarImageUrl: '/img/thumbs/ai.jpg',\n }\n : false\n }\n customRenderer={(message) => {\n if (message.isError) {\n return <AiErrorMessage />\n }\n\n if (message.sender.id === 'ai') {\n // As ferramentas e as pausas chegam pelo streaming e\n // vivem no Conversation; o tipo do ChatBox nao os conhece.\n const {\n tools,\n pendingApproval,\n pendingInput,\n pendingFormat,\n relatorios,\n falhou,\n interrompida,\n } = message as Conversation\n // Enquanto as ferramentas rodam o conteudo ainda e '':\n // sem esta guarda sobraria um balao cinza vazio.\n const temTexto = Boolean(\n (message.content as string)?.trim(),\n )\n\n return (\n <div className=\"flex flex-col items-start gap-1.5\">\n {tools?.map((tool) => (\n <ToolCallChip key={tool.id} tool={tool} />\n ))}\n {temTexto && (\n <div className={BALAO_AGENTE}>\n <ChatCustomContent\n content={message.content as string}\n triggerTyping={\n message.fresh\n ? message.fresh\n : false\n }\n onFinish={() =>\n handleFinish(message.id)\n }\n />\n </div>\n )}\n {relatorios?.map((relatorio) =>\n relatorio.formato === 'xlsx' ? (\n <PlanilhaNaMensagem\n key={relatorio.id}\n planilha={relatorio}\n />\n ) : (\n <RelatorioNaMensagem\n key={relatorio.id}\n relatorio={relatorio}\n />\n ),\n )}\n {pendingFormat && (\n <FormatoCard\n onChoose={(formato) =>\n handleFormato(\n selectedConversation,\n message.id,\n formato,\n )\n }\n />\n )}\n {pendingInput && (\n <DataRequestCard\n input={pendingInput}\n onSubmit={(dados) =>\n handleDataSubmit(\n selectedConversation,\n message.id,\n dados,\n )\n }\n />\n )}\n {pendingApproval && (\n <ApprovalCard\n approval={pendingApproval}\n onDecide={(aprovado) =>\n handleApproval(\n selectedConversation,\n message.id,\n aprovado,\n )\n }\n />\n )}\n {/* Falhou no meio: o que ja chegou fica, e o\n aviso vem depois, em vez de apagar tudo. */}\n {falhou && <AiErrorMessage />}\n {/* Parou pelo botao: o que chegou fica, e o\n aviso, discreto, vem depois. */}\n {interrompida && <RespostaInterrompida />}\n </div>\n )\n }\n\n const { imagens } = message as Conversation\n return (\n <div className=\"flex flex-col gap-2\">\n <ImagensDaMensagem imagens={imagens} />\n {message.content}\n </div>\n )\n }}\n customAction={(message) => {\n if (message.sender.id === 'ai' && !message.isError) {\n return (\n <ChatCustomAction\n content={message.content as string}\n />\n )\n }\n\n return null\n }}\n onInputChange={handleInputChange}\n executando={Boolean(execucao)}\n onStop={handleStop}\n uploadProps={{\n ...UPLOAD_DE_IMAGENS,\n disabled: atual?.imagens === false,\n }}\n inputActions={\n <ModeloERaciocinio floatingClass={dropdownFloatingClass} />\n }\n >\n {/* Os children ficam entre a lista e o input: sem conversa e a\n landing com os cards; com conversa, o aviso sobre a IA. */}\n {selectedConversation ? (\n <p className=\"py-1 text-center text-xs text-gray-500 dark:text-gray-400\">\n Orbe-AI é uma inteligência artificial e pode cometer\n erros.\n </p>\n ) : (\n <div className=\"flex-1 min-h-0 overflow-y-auto\">\n <ChatLandingView />\n </div>\n )}\n </ChatBox>\n </Card>\n )\n}\n\nexport default ChatView\n"],"names":["chat"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,MAAM,eACF;AAeJ,MAAM,WAAW,CAAC;AAAA,EACd,gBAAgB;AAAA,EAChB;AACJ,MAAqB;AACjB,QAAM,YAAY,OAAqB,IAAI;AAC3C,QAAM;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IACA,sBAAA;AACJ,QAAM;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IACA,YAAA;AAEJ,QAAM,EAAE,WAAA,IAAe,wBAAA;AAEvB,QAAM,EAAE,MAAA,IAAU,WAAA;AAElB,QAAM,iBAAiB,MAAM;AACzB,QAAI,UAAU,SAAS,kBAAkB;AACrC,YAAM,gBAAgB,UAAU,QAAQ,iBAAA;AACxC,UAAI,eAAe;AACf,sBAAc,YAAY,cAAc;AAAA,MAC5C;AAAA,IACJ;AAAA,EACJ;AAEA,YAAU,MAAM;AACZ,mBAAA;AAAA,EACJ,GAAG,CAAC,sBAAsB,WAAW,CAAC;AAEtC,QAAM,cAAc,QAAQ,MAAM;AAC9B,UAAM,OAAO,YAAY;AAAA,MACrB,CAACA,UAASA,MAAK,OAAO;AAAA,IAAA;AAE1B,WAAO,MAAM,gBAAgB,CAAA;AAAA,EACjC,GAAG,CAAC,sBAAs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B,cAAI,QAAQ,OAAO,OAAO,QAAQ,CAAC,QAAQ,SAAS;AAChD,mBACI;AAAA,cAAC;AAAA,cAAA;AAAA,gBACG,SAAS,QAAQ;AAAA,cAAA;AAAA,YAAA;AAAA,UAG7B;AAEA,iBAAO;AAAA,QACX;AAAA,QACA,eAAe;AAAA,QACf,YAAY,QAAQ,QAAQ;AAAA,QAC5B,QAAQ;AAAA,QACR,aAAa;AAAA,UACT,GAAG;AAAA,UACH,UAAU,OAAO,YAAY;AAAA,QAAA;AAAA,QAEjC,cACI,oBAAC,mBAAA,EAAkB,eAAe,sBAAA,CAAuB;AAAA,QAK5D,UAAA,uBACG,oBAAC,KAAA,EAAE,WAAU,6DAA4D,UAAA,8DAAA,CAGzE,IAEA,oBAAC,OAAA,EAAI,WAAU,kCACX,UAAA,oBAAC,mBAAgB,EAAA,CACrB;AAAA,MAAA;AAAA,IAAA;AAAA,EAER,GACJ;AAER;"}
|
|
1
|
+
{"version":3,"file":"ChatView.js","sources":["../../../../../../../lib/@ecme/views/concepts/ai/Chat/components/ChatView.tsx"],"sourcesContent":["import { useRef, useEffect, useMemo } from 'react'\nimport Card from '@/components/ui/Card'\nimport ChatBox from '@/components/view/ChatBox'\nimport ChatLandingView from './ChatLandingView'\nimport ChatMobileNav from './ChatMobileNav'\nimport ChatCustomContent from './ChatCustomContent'\nimport ChatCustomAction from './ChatCustomAction'\nimport AiThinkingIndicator from './AiThinkingIndicator'\nimport AiErrorMessage from './AiErrorMessage'\nimport RespostaInterrompida from './RespostaInterrompida'\nimport ToolCallChip from './ToolCallChip'\nimport ApprovalCard from './ApprovalCard'\nimport DataRequestCard from './DataRequestCard'\nimport FormatoCard from './FormatoCard'\nimport ModeloERaciocinio from './ModeloERaciocinio'\nimport ImagensDaMensagem from './ImagensDaMensagem'\nimport PlanilhaNaMensagem from './PlanilhaNaMensagem'\nimport RelatorioNaMensagem from './RelatorioNaMensagem'\nimport { UPLOAD_DE_IMAGENS } from '../imagens'\nimport { usGenerativeChatStore } from '../store/generativeChatStore'\nimport useChatSend from '../hooks/useChatSend'\nimport useConversationMessages from '../hooks/useConversationMessages'\nimport useModelos from '../hooks/useModelos'\nimport type { Conversation } from '../types'\nimport type { ScrollBarRef } from '@/components/ui/ScrollBar'\n\n/**\n * O balao de fala do agente, desenhado aqui em vez de vir do ChatBox.\n *\n * O `botBubbleClass` abaixo zera o balao que o Message desenharia, para os chips\n * de ferramenta e o card de aprovacao ficarem FORA dele — antes tudo dividia a\n * mesma caixa cinza e as ferramentas eram lidas como uma segunda mensagem.\n * Usado tambem pelo indicador de \"pensando\", que passa pelo mesmo balao zerado.\n *\n * Repete `prose text-sm` do balao original de proposito: o reset de margem do\n * @tailwindcss/typography e `.prose > :first-child`, filho DIRETO. Sem o `prose`\n * aqui, o markdown ficaria um nivel abaixo do container e o primeiro paragrafo\n * voltaria a ter margem, inflando todos os baloes.\n */\nconst BALAO_AGENTE =\n 'prose rounded-xl bg-gray-100 px-5 py-2.5 text-sm text-gray-900 dark:bg-gray-700 dark:text-gray-100'\n\ntype ChatViewProps = {\n /**\n * Mostra o drawer de histórico do ChatMobileNav abaixo de xl. O widget\n * flutuante desliga, porque tem o próprio drawer dentro do painel.\n */\n showMobileNav?: boolean\n /**\n * Classes dos menus flutuantes do chat. O widget passa um z-index acima do\n * próprio painel; sem isso o menu abriria atrás dele.\n */\n dropdownFloatingClass?: string\n}\n\nconst ChatView = ({\n showMobileNav = true,\n dropdownFloatingClass,\n}: ChatViewProps) => {\n const scrollRef = useRef<ScrollBarRef>(null)\n const {\n selectedConversation,\n chatHistory,\n isTyping,\n execucao,\n disabledChatFresh,\n } = usGenerativeChatStore()\n const {\n handleSend,\n handleStop,\n handleApproval,\n handleDataSubmit,\n handleFormato,\n } = useChatSend()\n // Conversa aberta da lista: as mensagens vêm do backend na primeira vez.\n const { carregando } = useConversationMessages()\n // Modelo que só lê texto: o botão de imagem fica desligado.\n const { atual } = useModelos()\n\n const scrollToBottom = () => {\n if (scrollRef.current?.getScrollElement) {\n const scrollElement = scrollRef.current.getScrollElement()\n if (scrollElement) {\n scrollElement.scrollTop = scrollElement.scrollHeight\n }\n }\n }\n\n useEffect(() => {\n scrollToBottom()\n }, [selectedConversation, chatHistory])\n\n const messageList = useMemo(() => {\n const chat = chatHistory.find(\n (chat) => chat.id === selectedConversation,\n )\n return chat?.conversation || []\n }, [selectedConversation, chatHistory])\n\n const handleInputChange = async ({\n value,\n attachments,\n }: {\n value: string\n attachments: File[]\n }) => {\n await handleSend(value, attachments)\n }\n\n const handleFinish = (id: string) => {\n disabledChatFresh(id)\n scrollToBottom()\n }\n\n return (\n <Card className=\"flex-1 h-full\" bodyClass=\"h-full\">\n {showMobileNav && <ChatMobileNav />}\n <ChatBox\n ref={scrollRef}\n messageList={messageList}\n placeholder=\"Pergunte algo sobre o Orbe Agro…\"\n showMessageList={Boolean(selectedConversation)}\n showAvatar={false}\n avatarGap={false}\n myBubbleClass=\"bg-primary text-white\"\n botBubbleClass=\"bg-transparent dark:bg-transparent p-0 rounded-none\"\n errorBubbleClass=\"bg-red-50 dark:bg-red-500/10 border border-red-200 dark:border-red-500/20\"\n renderTyping={() => (\n <div className={BALAO_AGENTE}>\n <AiThinkingIndicator />\n </div>\n )}\n containerClass={\n showMobileNav ? 'h-[calc(100%-30px)] xl:h-full' : 'h-full'\n }\n // A lista ocupa o que sobra: o compositor cresce com o texto.\n messageListClass=\"flex-1 min-h-0\"\n typing={\n isTyping || carregando\n ? {\n id: 'ai',\n name: 'Chat AI',\n avatarImageUrl: '/img/thumbs/ai.jpg',\n }\n : false\n }\n customRenderer={(message) => {\n if (message.isError) {\n return <AiErrorMessage />\n }\n\n if (message.sender.id === 'ai') {\n // As ferramentas e as pausas chegam pelo streaming e\n // vivem no Conversation; o tipo do ChatBox nao os conhece.\n const {\n tools,\n pendingApproval,\n pendingInput,\n pendingFormat,\n relatorios,\n falhou,\n interrompida,\n } = message as Conversation\n // Enquanto as ferramentas rodam o conteudo ainda e '':\n // sem esta guarda sobraria um balao cinza vazio.\n const temTexto = Boolean(\n (message.content as string)?.trim(),\n )\n\n return (\n <div className=\"flex flex-col items-start gap-1.5\">\n {tools?.map((tool) => (\n <ToolCallChip key={tool.id} tool={tool} />\n ))}\n {temTexto && (\n <div className={BALAO_AGENTE}>\n <ChatCustomContent\n content={message.content as string}\n triggerTyping={\n message.fresh\n ? message.fresh\n : false\n }\n onFinish={() =>\n handleFinish(message.id)\n }\n />\n </div>\n )}\n {relatorios?.map((relatorio) =>\n relatorio.formato === 'xlsx' ? (\n <PlanilhaNaMensagem\n key={relatorio.id}\n planilha={relatorio}\n />\n ) : (\n <RelatorioNaMensagem\n key={relatorio.id}\n relatorio={relatorio}\n />\n ),\n )}\n {pendingFormat && (\n <FormatoCard\n onChoose={(formato) =>\n handleFormato(\n selectedConversation,\n message.id,\n formato,\n )\n }\n />\n )}\n {pendingInput && (\n <DataRequestCard\n input={pendingInput}\n onSubmit={(dados) =>\n handleDataSubmit(\n selectedConversation,\n message.id,\n dados,\n )\n }\n />\n )}\n {pendingApproval && (\n <ApprovalCard\n approval={pendingApproval}\n onDecide={(aprovado) =>\n handleApproval(\n selectedConversation,\n message.id,\n aprovado,\n )\n }\n />\n )}\n {/* Falhou no meio: o que ja chegou fica, e o\n aviso vem depois, em vez de apagar tudo. */}\n {falhou && <AiErrorMessage />}\n {/* Parou pelo botao: o que chegou fica, e o\n aviso, discreto, vem depois. */}\n {interrompida && <RespostaInterrompida />}\n </div>\n )\n }\n\n const { imagens } = message as Conversation\n return (\n <div className=\"flex flex-col gap-2\">\n <ImagensDaMensagem imagens={imagens} />\n {message.content}\n </div>\n )\n }}\n customAction={(message) => {\n if (message.sender.id === 'ai' && !message.isError) {\n return (\n <ChatCustomAction\n content={message.content as string}\n />\n )\n }\n\n return null\n }}\n onInputChange={handleInputChange}\n executando={Boolean(execucao)}\n onStop={handleStop}\n uploadProps={{\n ...UPLOAD_DE_IMAGENS,\n disabled: atual?.imagens === false,\n }}\n inputActions={\n <ModeloERaciocinio floatingClass={dropdownFloatingClass} />\n }\n >\n {/* Os children ficam entre a lista e o input: sem conversa e a\n landing com os cards; com conversa, o aviso sobre a IA. */}\n {selectedConversation ? (\n <p className=\"py-1 text-center text-xs text-gray-500 dark:text-gray-400\">\n Orbe-AI é uma inteligência artificial e pode cometer\n erros.\n </p>\n ) : (\n <div className=\"flex-1 min-h-0 overflow-y-auto\">\n <ChatLandingView />\n </div>\n )}\n </ChatBox>\n </Card>\n )\n}\n\nexport default ChatView\n"],"names":["chat"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,MAAM,eACF;AAeJ,MAAM,WAAW,CAAC;AAAA,EACd,gBAAgB;AAAA,EAChB;AACJ,MAAqB;AACjB,QAAM,YAAY,OAAqB,IAAI;AAC3C,QAAM;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IACA,sBAAA;AACJ,QAAM;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IACA,YAAA;AAEJ,QAAM,EAAE,WAAA,IAAe,wBAAA;AAEvB,QAAM,EAAE,MAAA,IAAU,WAAA;AAElB,QAAM,iBAAiB,MAAM;AACzB,QAAI,UAAU,SAAS,kBAAkB;AACrC,YAAM,gBAAgB,UAAU,QAAQ,iBAAA;AACxC,UAAI,eAAe;AACf,sBAAc,YAAY,cAAc;AAAA,MAC5C;AAAA,IACJ;AAAA,EACJ;AAEA,YAAU,MAAM;AACZ,mBAAA;AAAA,EACJ,GAAG,CAAC,sBAAsB,WAAW,CAAC;AAEtC,QAAM,cAAc,QAAQ,MAAM;AAC9B,UAAM,OAAO,YAAY;AAAA,MACrB,CAACA,UAASA,MAAK,OAAO;AAAA,IAAA;AAE1B,WAAO,MAAM,gBAAgB,CAAA;AAAA,EACjC,GAAG,CAAC,sBAAsB,WAAW,CAAC;AAEtC,QAAM,oBAAoB,OAAO;AAAA,IAC7B;AAAA,IACA;AAAA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,cAAC;AAAA,cAAA;AAAA,gBACG,SAAS,QAAQ;AAAA,cAAA;AAAA,YAAA;AAAA,UAG7B;AAEA,iBAAO;AAAA,QACX;AAAA,QACA,eAAe;AAAA,QACf,YAAY,QAAQ,QAAQ;AAAA,QAC5B,QAAQ;AAAA,QACR,aAAa;AAAA,UACT,GAAG;AAAA,UACH,UAAU,OAAO,YAAY;AAAA,QAAA;AAAA,QAEjC,cACI,oBAAC,mBAAA,EAAkB,eAAe,sBAAA,CAAuB;AAAA,QAK5D,UAAA,uBACG,oBAAC,KAAA,EAAE,WAAU,6DAA4D,UAAA,8DAAA,CAGzE,IAEA,oBAAC,OAAA,EAAI,WAAU,kCACX,UAAA,oBAAC,mBAAgB,EAAA,CACrB;AAAA,MAAA;AAAA,IAAA;AAAA,EAER,GACJ;AAER;"}
|
|
@@ -181,7 +181,7 @@ const ChatBody = () => {
|
|
|
181
181
|
placeholder: "Enter a prompt here",
|
|
182
182
|
showAvatar: true,
|
|
183
183
|
avatarGap: true,
|
|
184
|
-
messageListClass: "h-
|
|
184
|
+
messageListClass: "flex-1 min-h-0",
|
|
185
185
|
bubbleClass: "max-w-[300px]",
|
|
186
186
|
onInputChange: handleInputChange
|
|
187
187
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatBody.js","sources":["../../../../../../../lib/@ecme/views/concepts/chat/Chat/components/ChatBody.tsx"],"sourcesContent":["import { useState, useEffect, useRef, useMemo } from 'react'\nimport Avatar from '@/components/ui/Avatar'\nimport Card from '@/components/ui/Card'\nimport ChatBox from '@/components/view/ChatBox'\nimport ChatAction from './ChatAction'\nimport StartConverstation from '@/assets/svg/StartConverstation'\nimport { useChatStore } from '../store/chatStore'\nimport { apiGetConversation } from '@/services/ChatService'\nimport classNames from '@/utils/classNames'\nimport useResponsive from '@/utils/hooks/useResponsive'\nimport dayjs from 'dayjs'\nimport uniqueId from 'lodash/uniqueId'\nimport { TbChevronLeft } from 'react-icons/tb'\nimport type { GetConversationResponse, Message, ChatType } from '../types'\nimport type { ScrollBarRef } from '@/components/ui/ScrollBar'\n\nconst getFileType = (file: File) => {\n console.log('file.type', file.type)\n switch (file.type) {\n case 'image/jpg':\n case 'image/jpeg':\n case 'image/png':\n case 'image/webp':\n return 'image'\n case 'video/mp4':\n case 'video/avi':\n return 'video'\n case 'audio/mp3':\n case 'audio/wav':\n return 'audio'\n default:\n return 'misc'\n }\n}\n\nconst ChatBody = () => {\n const scrollRef = useRef<ScrollBarRef>(null)\n const selectedChat = useChatStore((state) => state.selectedChat)\n const conversationRecord = useChatStore((state) => state.conversationRecord)\n const pushConversationRecord = useChatStore(\n (state) => state.pushConversationRecord,\n )\n const setSelectedChat = useChatStore((state) => state.setSelectedChat)\n const pushConversationMessage = useChatStore(\n (state) => state.pushConversationMessage,\n )\n const setContactInfoDrawer = useChatStore(\n (state) => state.setContactInfoDrawer,\n )\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const [_, setIsFetchingConversation] = useState(false)\n const [conversation, setConversation] = useState<Message[]>([])\n\n const { smaller } = useResponsive()\n\n const scrollToBottom = () => {\n if (scrollRef.current?.getScrollElement) {\n const scrollElement = scrollRef.current.getScrollElement()\n if (scrollElement) {\n scrollElement.scrollTop = scrollElement.scrollHeight\n }\n }\n }\n\n const handleProfileClick = () => {\n setContactInfoDrawer({\n userId: selectedChat.user?.id as string,\n chatId: selectedChat.id as string,\n chatType: selectedChat.chatType as ChatType,\n open: true,\n })\n }\n\n const handlePushMessage = (message: Message) => {\n pushConversationMessage(selectedChat.id as string, message)\n setConversation((prevConversation) => {\n prevConversation.push(message)\n return structuredClone(prevConversation)\n })\n }\n\n const handleInputChange = async ({\n value,\n attachments,\n }: {\n value: string\n attachments?: File[]\n }) => {\n const newMessage: Message = {\n id: uniqueId('chat-conversation-'),\n sender: {\n id: '1',\n name: 'Angelina Gotelli',\n avatarImageUrl: '/img/avatars/thumb-1.jpg',\n },\n content: value,\n attachments: attachments?.map((attachment) => {\n return {\n type: getFileType(attachment),\n source: attachment,\n mediaUrl: URL.createObjectURL(attachment),\n }\n }),\n timestamp: dayjs().toDate(),\n type: 'regular',\n isMyMessage: true,\n }\n handlePushMessage(newMessage)\n }\n\n const cardHeaderProps = {\n header: {\n content: (\n <div className=\"flex items-center gap-2\">\n {smaller.md && (\n <button\n className=\"text-xl hover:text-primary\"\n onClick={() => setSelectedChat({})}\n >\n <TbChevronLeft />\n </button>\n )}\n <button\n className=\"flex items-center gap-2\"\n role=\"button\"\n onClick={handleProfileClick}\n >\n <div>\n <Avatar src={selectedChat.user?.avatarImageUrl} />\n </div>\n <div className=\"min-w-0 flex-1\">\n <div className=\"flex justify-between\">\n <div className=\"font-bold heading-text truncate\">\n {selectedChat.user?.name}\n </div>\n </div>\n <div>\n {selectedChat?.chatType === 'groups'\n ? 'click here for group info'\n : 'last seen recently'}\n </div>\n </div>\n </button>\n </div>\n ),\n extra: <ChatAction muted={selectedChat.muted} />,\n className: 'bg-gray-100 dark:bg-gray-600 h-[100px]',\n },\n }\n\n useEffect(() => {\n const fetchConvesation = async () => {\n setIsFetchingConversation(true)\n\n const record = conversationRecord.find(\n (item) => item.id === selectedChat.id,\n )\n\n if (record) {\n setConversation(record.conversation)\n } else {\n const resp = await apiGetConversation<GetConversationResponse>({\n id: selectedChat.id as string,\n })\n setConversation(resp.conversation)\n pushConversationRecord(resp)\n }\n\n setIsFetchingConversation(false)\n scrollToBottom()\n }\n\n if (selectedChat.id) {\n setConversation([])\n fetchConvesation()\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [selectedChat.id, conversation])\n\n const messageList = useMemo(() => {\n return conversation.map((item) => {\n item.timestamp = dayjs\n .unix(item.timestamp as number)\n .toDate() as Date\n if (item.isMyMessage) {\n item.showAvatar = false\n }\n return item\n })\n }, [conversation])\n\n return (\n <div\n className={classNames(\n 'w-full md:block',\n !selectedChat.id && 'hidden',\n )}\n >\n {selectedChat.id ? (\n <Card\n className=\"flex-1 h-full max-h-full dark:border-gray-700\"\n bodyClass=\"h-[calc(100%-100px)] relative\"\n {...cardHeaderProps}\n >\n <ChatBox\n ref={scrollRef}\n messageList={messageList}\n placeholder=\"Enter a prompt here\"\n showAvatar={true}\n avatarGap={true}\n messageListClass=\"h-[calc(100%-100px)]\"\n bubbleClass=\"max-w-[300px]\"\n onInputChange={handleInputChange}\n />\n </Card>\n ) : (\n <div className=\"flex-1 h-full max-h-full flex flex-col items-center justify-center rounded-2xl border border-gray-200 dark:border-gray-800\">\n <StartConverstation height={250} width={250} />\n <div className=\"mt-10 text-center\">\n <h3>Start Chatting!</h3>\n <p className=\"mt-2 text-base\">\n Pick a Conversation or Begin a New One\n </p>\n </div>\n </div>\n )}\n </div>\n )\n}\n\nexport default ChatBody\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAgBA,MAAM,cAAc,CAAC,SAAe;AAChC,UAAQ,IAAI,aAAa,KAAK,IAAI;AAClC,UAAQ,KAAK,MAAA;AAAA,IACT,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AAAA,IACL,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AAAA,IACL,KAAK;AACD,aAAO;AAAA,IACX;AACI,aAAO;AAAA,EAAA;AAEnB;AAEA,MAAM,WAAW,MAAM;AACnB,QAAM,YAAY,OAAqB,IAAI;AAC3C,QAAM,eAAe,aAAa,CAAC,UAAU,MAAM,YAAY;AAC/D,QAAM,qBAAqB,aAAa,CAAC,UAAU,MAAM,kBAAkB;AAC3E,QAAM,yBAAyB;AAAA,IAC3B,CAAC,UAAU,MAAM;AAAA,EAAA;AAErB,QAAM,kBAAkB,aAAa,CAAC,UAAU,MAAM,eAAe;AACrE,QAAM,0BAA0B;AAAA,IAC5B,CAAC,UAAU,MAAM;AAAA,EAAA;AAErB,QAAM,uBAAuB;AAAA,IACzB,CAAC,UAAU,MAAM;AAAA,EAAA;AAGrB,QAAM,CAAC,GAAG,yBAAyB,IA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,uBAAA;AAAA,IACJ;AAAA,EAEJ,GAAG,CAAC,aAAa,IAAI,YAAY,CAAC;AAElC,QAAM,cAAc,QAAQ,MAAM;AAC9B,WAAO,aAAa,IAAI,CAAC,SAAS;AAC9B,WAAK,YAAY,MACZ,KAAK,KAAK,SAAmB,EAC7B,OAAA;AACL,UAAI,KAAK,aAAa;AAClB,aAAK,aAAa;AAAA,MACtB;AACA,aAAO;AAAA,IACX,CAAC;AAAA,EACL,GAAG,CAAC,YAAY,CAAC;AAEjB,SACI;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,WAAW;AAAA,QACP;AAAA,QACA,CAAC,aAAa,MAAM;AAAA,MAAA;AAAA,MAGvB,uBAAa,KACV;AAAA,QAAC;AAAA,QAAA;AAAA,UACG,WAAU;AAAA,UACV,WAAU;AAAA,UACT,GAAG;AAAA,UAEJ,UAAA;AAAA,YAAC;AAAA,YAAA;AAAA,cACG,KAAK;AAAA,cACL;AAAA,cACA,aAAY;AAAA,cACZ,YAAY;AAAA,cACZ,WAAW;AAAA,cACX,kBAAiB;AAAA,cACjB,aAAY;AAAA,cACZ,eAAe;AAAA,YAAA;AAAA,UAAA;AAAA,QACnB;AAAA,MAAA,IAGJ,qBAAC,OAAA,EAAI,WAAU,8HACX,UAAA;AAAA,QAAA,oBAAC,oBAAA,EAAmB,QAAQ,KAAK,OAAO,KAAK;AAAA,QAC7C,qBAAC,OAAA,EAAI,WAAU,qBACX,UAAA;AAAA,UAAA,oBAAC,QAAG,UAAA,kBAAA,CAAe;AAAA,UACnB,oBAAC,KAAA,EAAE,WAAU,kBAAiB,UAAA,yCAAA,CAE9B;AAAA,QAAA,EAAA,CACJ;AAAA,MAAA,EAAA,CACJ;AAAA,IAAA;AAAA,EAAA;AAIhB;"}
|
|
1
|
+
{"version":3,"file":"ChatBody.js","sources":["../../../../../../../lib/@ecme/views/concepts/chat/Chat/components/ChatBody.tsx"],"sourcesContent":["import { useState, useEffect, useRef, useMemo } from 'react'\nimport Avatar from '@/components/ui/Avatar'\nimport Card from '@/components/ui/Card'\nimport ChatBox from '@/components/view/ChatBox'\nimport ChatAction from './ChatAction'\nimport StartConverstation from '@/assets/svg/StartConverstation'\nimport { useChatStore } from '../store/chatStore'\nimport { apiGetConversation } from '@/services/ChatService'\nimport classNames from '@/utils/classNames'\nimport useResponsive from '@/utils/hooks/useResponsive'\nimport dayjs from 'dayjs'\nimport uniqueId from 'lodash/uniqueId'\nimport { TbChevronLeft } from 'react-icons/tb'\nimport type { GetConversationResponse, Message, ChatType } from '../types'\nimport type { ScrollBarRef } from '@/components/ui/ScrollBar'\n\nconst getFileType = (file: File) => {\n console.log('file.type', file.type)\n switch (file.type) {\n case 'image/jpg':\n case 'image/jpeg':\n case 'image/png':\n case 'image/webp':\n return 'image'\n case 'video/mp4':\n case 'video/avi':\n return 'video'\n case 'audio/mp3':\n case 'audio/wav':\n return 'audio'\n default:\n return 'misc'\n }\n}\n\nconst ChatBody = () => {\n const scrollRef = useRef<ScrollBarRef>(null)\n const selectedChat = useChatStore((state) => state.selectedChat)\n const conversationRecord = useChatStore((state) => state.conversationRecord)\n const pushConversationRecord = useChatStore(\n (state) => state.pushConversationRecord,\n )\n const setSelectedChat = useChatStore((state) => state.setSelectedChat)\n const pushConversationMessage = useChatStore(\n (state) => state.pushConversationMessage,\n )\n const setContactInfoDrawer = useChatStore(\n (state) => state.setContactInfoDrawer,\n )\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const [_, setIsFetchingConversation] = useState(false)\n const [conversation, setConversation] = useState<Message[]>([])\n\n const { smaller } = useResponsive()\n\n const scrollToBottom = () => {\n if (scrollRef.current?.getScrollElement) {\n const scrollElement = scrollRef.current.getScrollElement()\n if (scrollElement) {\n scrollElement.scrollTop = scrollElement.scrollHeight\n }\n }\n }\n\n const handleProfileClick = () => {\n setContactInfoDrawer({\n userId: selectedChat.user?.id as string,\n chatId: selectedChat.id as string,\n chatType: selectedChat.chatType as ChatType,\n open: true,\n })\n }\n\n const handlePushMessage = (message: Message) => {\n pushConversationMessage(selectedChat.id as string, message)\n setConversation((prevConversation) => {\n prevConversation.push(message)\n return structuredClone(prevConversation)\n })\n }\n\n const handleInputChange = async ({\n value,\n attachments,\n }: {\n value: string\n attachments?: File[]\n }) => {\n const newMessage: Message = {\n id: uniqueId('chat-conversation-'),\n sender: {\n id: '1',\n name: 'Angelina Gotelli',\n avatarImageUrl: '/img/avatars/thumb-1.jpg',\n },\n content: value,\n attachments: attachments?.map((attachment) => {\n return {\n type: getFileType(attachment),\n source: attachment,\n mediaUrl: URL.createObjectURL(attachment),\n }\n }),\n timestamp: dayjs().toDate(),\n type: 'regular',\n isMyMessage: true,\n }\n handlePushMessage(newMessage)\n }\n\n const cardHeaderProps = {\n header: {\n content: (\n <div className=\"flex items-center gap-2\">\n {smaller.md && (\n <button\n className=\"text-xl hover:text-primary\"\n onClick={() => setSelectedChat({})}\n >\n <TbChevronLeft />\n </button>\n )}\n <button\n className=\"flex items-center gap-2\"\n role=\"button\"\n onClick={handleProfileClick}\n >\n <div>\n <Avatar src={selectedChat.user?.avatarImageUrl} />\n </div>\n <div className=\"min-w-0 flex-1\">\n <div className=\"flex justify-between\">\n <div className=\"font-bold heading-text truncate\">\n {selectedChat.user?.name}\n </div>\n </div>\n <div>\n {selectedChat?.chatType === 'groups'\n ? 'click here for group info'\n : 'last seen recently'}\n </div>\n </div>\n </button>\n </div>\n ),\n extra: <ChatAction muted={selectedChat.muted} />,\n className: 'bg-gray-100 dark:bg-gray-600 h-[100px]',\n },\n }\n\n useEffect(() => {\n const fetchConvesation = async () => {\n setIsFetchingConversation(true)\n\n const record = conversationRecord.find(\n (item) => item.id === selectedChat.id,\n )\n\n if (record) {\n setConversation(record.conversation)\n } else {\n const resp = await apiGetConversation<GetConversationResponse>({\n id: selectedChat.id as string,\n })\n setConversation(resp.conversation)\n pushConversationRecord(resp)\n }\n\n setIsFetchingConversation(false)\n scrollToBottom()\n }\n\n if (selectedChat.id) {\n setConversation([])\n fetchConvesation()\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [selectedChat.id, conversation])\n\n const messageList = useMemo(() => {\n return conversation.map((item) => {\n item.timestamp = dayjs\n .unix(item.timestamp as number)\n .toDate() as Date\n if (item.isMyMessage) {\n item.showAvatar = false\n }\n return item\n })\n }, [conversation])\n\n return (\n <div\n className={classNames(\n 'w-full md:block',\n !selectedChat.id && 'hidden',\n )}\n >\n {selectedChat.id ? (\n <Card\n className=\"flex-1 h-full max-h-full dark:border-gray-700\"\n bodyClass=\"h-[calc(100%-100px)] relative\"\n {...cardHeaderProps}\n >\n <ChatBox\n ref={scrollRef}\n messageList={messageList}\n placeholder=\"Enter a prompt here\"\n showAvatar={true}\n avatarGap={true}\n messageListClass=\"flex-1 min-h-0\"\n bubbleClass=\"max-w-[300px]\"\n onInputChange={handleInputChange}\n />\n </Card>\n ) : (\n <div className=\"flex-1 h-full max-h-full flex flex-col items-center justify-center rounded-2xl border border-gray-200 dark:border-gray-800\">\n <StartConverstation height={250} width={250} />\n <div className=\"mt-10 text-center\">\n <h3>Start Chatting!</h3>\n <p className=\"mt-2 text-base\">\n Pick a Conversation or Begin a New One\n </p>\n </div>\n </div>\n )}\n </div>\n )\n}\n\nexport default ChatBody\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAgBA,MAAM,cAAc,CAAC,SAAe;AAChC,UAAQ,IAAI,aAAa,KAAK,IAAI;AAClC,UAAQ,KAAK,MAAA;AAAA,IACT,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AAAA,IACL,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AAAA,IACL,KAAK;AACD,aAAO;AAAA,IACX;AACI,aAAO;AAAA,EAAA;AAEnB;AAEA,MAAM,WAAW,MAAM;AACnB,QAAM,YAAY,OAAqB,IAAI;AAC3C,QAAM,eAAe,aAAa,CAAC,UAAU,MAAM,YAAY;AAC/D,QAAM,qBAAqB,aAAa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A,kBAAA,CAAe;AAAA,UACnB,oBAAC,KAAA,EAAE,WAAU,kBAAiB,UAAA,yCAAA,CAE9B;AAAA,QAAA,EAAA,CACJ;AAAA,MAAA,EAAA,CACJ;AAAA,IAAA;AAAA,EAAA;AAIhB;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../../../../lib/@ecme/components/ui/Input/Input.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,KAAK,EACV,mBAAmB,EACnB,WAAW,EACX,SAAS,EACT,sBAAsB,EAEtB,GAAG,EACJ,MAAM,OAAO,CAAC;AAEf,MAAM,WAAW,UACf,SAAQ,WAAW,EACjB,IAAI,CACF,mBAAmB,CAAC,gBAAgB,GAAG,mBAAmB,CAAC,EAC3D,MAAM,GAAG,QAAQ,CAClB;IACH,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,GAAG,CAAC,WAAW,GAAG,gBAAgB,GAAG,mBAAmB,CAAC,CAAC;IAChE,IAAI,CAAC,EAAE,cAAc,CAAC,WAAW,CAAC;IAClC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,sBAAsB,CAAC;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED,QAAA,MAAM,KAAK,GAAI,OAAO,UAAU,
|
|
1
|
+
{"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../../../../lib/@ecme/components/ui/Input/Input.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,KAAK,EACV,mBAAmB,EACnB,WAAW,EACX,SAAS,EACT,sBAAsB,EAEtB,GAAG,EACJ,MAAM,OAAO,CAAC;AAEf,MAAM,WAAW,UACf,SAAQ,WAAW,EACjB,IAAI,CACF,mBAAmB,CAAC,gBAAgB,GAAG,mBAAmB,CAAC,EAC3D,MAAM,GAAG,QAAQ,CAClB;IACH,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,GAAG,CAAC,WAAW,GAAG,gBAAgB,GAAG,mBAAmB,CAAC,CAAC;IAChE,IAAI,CAAC,EAAE,cAAc,CAAC,WAAW,CAAC;IAClC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,sBAAsB,CAAC;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED,QAAA,MAAM,KAAK,GAAI,OAAO,UAAU,4CAmL/B,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
|
@@ -6,7 +6,7 @@ export type ChatInputProps = {
|
|
|
6
6
|
value: string;
|
|
7
7
|
attachments: File[];
|
|
8
8
|
}) => void;
|
|
9
|
-
ref?: Ref<
|
|
9
|
+
ref?: Ref<HTMLTextAreaElement>;
|
|
10
10
|
/** Controles extras dentro da caixa, logo antes do botão de enviar. */
|
|
11
11
|
inputActions?: ReactNode;
|
|
12
12
|
/** Restrições do seletor de anexos (tipos aceitos, validação e bloqueio). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatInput.d.ts","sourceRoot":"","sources":["../../../../../../../lib/@ecme/components/view/ChatBox/components/ChatInput.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ChatInput.d.ts","sourceRoot":"","sources":["../../../../../../../lib/@ecme/components/view/ChatBox/components/ChatInput.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,KAAK,EAAiB,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAE1D,MAAM,MAAM,cAAc,GAAG;IACzB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,IAAI,EAAE,CAAA;KAAE,KAAK,IAAI,CAAA;IACzE,GAAG,CAAC,EAAE,GAAG,CAAC,mBAAmB,CAAC,CAAA;IAC9B,uEAAuE;IACvE,YAAY,CAAC,EAAE,SAAS,CAAA;IACxB,6EAA6E;IAC7E,WAAW,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ,GAAG,cAAc,GAAG,UAAU,CAAC,CAAA;IACvE;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,yCAAyC;IACzC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAA;CACtB,CAAA;AAYD,QAAA,MAAM,SAAS,GAAI,OAAO,cAAc,4CAyHvC,CAAA;AAED,eAAe,SAAS,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatLandingView.d.ts","sourceRoot":"","sources":["../../../../../../../../lib/@ecme/views/concepts/ai/Chat/components/ChatLandingView.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ChatLandingView.d.ts","sourceRoot":"","sources":["../../../../../../../../lib/@ecme/views/concepts/ai/Chat/components/ChatLandingView.tsx"],"names":[],"mappings":"AAgDA,QAAA,MAAM,eAAe,+CA6CpB,CAAA;AAED,eAAe,eAAe,CAAA"}
|
|
@@ -5408,6 +5408,9 @@ video {
|
|
|
5408
5408
|
.mr-8{
|
|
5409
5409
|
margin-right: 2rem;
|
|
5410
5410
|
}
|
|
5411
|
+
.mt-0{
|
|
5412
|
+
margin-top: 0px;
|
|
5413
|
+
}
|
|
5411
5414
|
.mt-0\.5{
|
|
5412
5415
|
margin-top: 0.125rem;
|
|
5413
5416
|
}
|
|
@@ -5581,9 +5584,6 @@ video {
|
|
|
5581
5584
|
.h-\[42px\]{
|
|
5582
5585
|
height: 42px;
|
|
5583
5586
|
}
|
|
5584
|
-
.h-\[50px\]{
|
|
5585
|
-
height: 50px;
|
|
5586
|
-
}
|
|
5587
5587
|
.h-\[56px\]{
|
|
5588
5588
|
height: 56px;
|
|
5589
5589
|
}
|
|
@@ -5599,9 +5599,6 @@ video {
|
|
|
5599
5599
|
.h-\[calc\(100\%-100px\)\]{
|
|
5600
5600
|
height: calc(100% - 100px);
|
|
5601
5601
|
}
|
|
5602
|
-
.h-\[calc\(100\%-124px\)\]{
|
|
5603
|
-
height: calc(100% - 124px);
|
|
5604
|
-
}
|
|
5605
5602
|
.h-\[calc\(100\%-150px\)\]{
|
|
5606
5603
|
height: calc(100% - 150px);
|
|
5607
5604
|
}
|
|
@@ -5659,6 +5656,9 @@ video {
|
|
|
5659
5656
|
.max-h-\[390px\]{
|
|
5660
5657
|
max-height: 390px;
|
|
5661
5658
|
}
|
|
5659
|
+
.max-h-\[6\.25rem\]{
|
|
5660
|
+
max-height: 6.25rem;
|
|
5661
|
+
}
|
|
5662
5662
|
.max-h-\[600px\]{
|
|
5663
5663
|
max-height: 600px;
|
|
5664
5664
|
}
|
|
@@ -5932,9 +5932,6 @@ video {
|
|
|
5932
5932
|
.min-w-\[330px\]{
|
|
5933
5933
|
min-width: 330px;
|
|
5934
5934
|
}
|
|
5935
|
-
.min-w-\[6rem\]{
|
|
5936
|
-
min-width: 6rem;
|
|
5937
|
-
}
|
|
5938
5935
|
.min-w-full{
|
|
5939
5936
|
min-width: 100%;
|
|
5940
5937
|
}
|
|
@@ -7745,6 +7742,10 @@ video {
|
|
|
7745
7742
|
margin-bottom: 0px;
|
|
7746
7743
|
}
|
|
7747
7744
|
|
|
7745
|
+
.focus-within\:border-gray-400:focus-within{
|
|
7746
|
+
border-color: var(--gray-400);
|
|
7747
|
+
}
|
|
7748
|
+
|
|
7748
7749
|
.focus-within\:border-primary:focus-within{
|
|
7749
7750
|
border-color: var(--primary);
|
|
7750
7751
|
}
|
|
@@ -8583,6 +8584,10 @@ video {
|
|
|
8583
8584
|
--tw-ring-color: var(--primary);
|
|
8584
8585
|
}
|
|
8585
8586
|
|
|
8587
|
+
.dark\:focus-within\:border-gray-500:focus-within:is(.dark *){
|
|
8588
|
+
border-color: var(--gray-500);
|
|
8589
|
+
}
|
|
8590
|
+
|
|
8586
8591
|
.dark\:hover\:border-gray-600:hover:is(.dark *){
|
|
8587
8592
|
border-color: var(--gray-600);
|
|
8588
8593
|
}
|
|
@@ -8982,9 +8987,6 @@ video {
|
|
|
8982
8987
|
.xl\:flex{
|
|
8983
8988
|
display: flex;
|
|
8984
8989
|
}
|
|
8985
|
-
.xl\:h-\[calc\(100\%-94px\)\]{
|
|
8986
|
-
height: calc(100% - 94px);
|
|
8987
|
-
}
|
|
8988
8990
|
.xl\:h-full{
|
|
8989
8991
|
height: 100%;
|
|
8990
8992
|
}
|
|
@@ -9123,6 +9125,10 @@ video {
|
|
|
9123
9125
|
margin-left: 11.5px;
|
|
9124
9126
|
}
|
|
9125
9127
|
|
|
9128
|
+
.ltr\:ml-auto:where([dir="ltr"], [dir="ltr"] *){
|
|
9129
|
+
margin-left: auto;
|
|
9130
|
+
}
|
|
9131
|
+
|
|
9126
9132
|
.ltr\:mr-1:where([dir="ltr"], [dir="ltr"] *){
|
|
9127
9133
|
margin-right: 0.25rem;
|
|
9128
9134
|
}
|
|
@@ -9227,6 +9233,10 @@ video {
|
|
|
9227
9233
|
margin-right: 1rem;
|
|
9228
9234
|
}
|
|
9229
9235
|
|
|
9236
|
+
.rtl\:mr-auto:where([dir="rtl"], [dir="rtl"] *){
|
|
9237
|
+
margin-right: auto;
|
|
9238
|
+
}
|
|
9239
|
+
|
|
9230
9240
|
.rtl\:flex-row-reverse:where([dir="rtl"], [dir="rtl"] *){
|
|
9231
9241
|
flex-direction: row-reverse;
|
|
9232
9242
|
}
|
|
@@ -158,7 +158,9 @@ const Input = (props: InputProps) => {
|
|
|
158
158
|
};
|
|
159
159
|
|
|
160
160
|
const inputProps = {
|
|
161
|
-
|
|
161
|
+
// Sem estilo do template, mas com as classes de quem chamou: `unstyle`
|
|
162
|
+
// remove a aparência padrão, não o className.
|
|
163
|
+
className: !unstyle ? inputClass : className,
|
|
162
164
|
disabled,
|
|
163
165
|
type,
|
|
164
166
|
ref,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useState, useRef } from 'react'
|
|
2
2
|
import Button from '@/components/ui/Button'
|
|
3
|
+
import Input from '@/components/ui/Input'
|
|
3
4
|
import Upload from '@/components/ui/Upload'
|
|
4
5
|
import hooks from '@/components/ui/hooks'
|
|
5
6
|
import { TbPhotoPlus, TbArrowRight, TbPlayerStopFilled } from 'react-icons/tb'
|
|
@@ -9,7 +10,7 @@ import type { KeyboardEvent, ReactNode, Ref } from 'react'
|
|
|
9
10
|
export type ChatInputProps = {
|
|
10
11
|
placeholder?: string
|
|
11
12
|
onInputChange?: (payload: { value: string; attachments: File[] }) => void
|
|
12
|
-
ref?: Ref<
|
|
13
|
+
ref?: Ref<HTMLTextAreaElement>
|
|
13
14
|
/** Controles extras dentro da caixa, logo antes do botão de enviar. */
|
|
14
15
|
inputActions?: ReactNode
|
|
15
16
|
/** Restrições do seletor de anexos (tipos aceitos, validação e bloqueio). */
|
|
@@ -26,6 +27,14 @@ export type ChatInputProps = {
|
|
|
26
27
|
|
|
27
28
|
const { useMergeRef } = hooks
|
|
28
29
|
|
|
30
|
+
/**
|
|
31
|
+
* A altura inicial é `rows={1}`. Daí cresce com o conteúdo até o `max-h` de
|
|
32
|
+
* 5 linhas de 20px (`leading-5`, o ritmo do texto de 14px do app); passando
|
|
33
|
+
* disso, o próprio textarea rola.
|
|
34
|
+
*/
|
|
35
|
+
const CLASSES_DO_TEXTAREA =
|
|
36
|
+
'w-full max-h-[6.25rem] resize-none overflow-y-auto bg-transparent p-0 leading-5 heading-text placeholder:text-gray-400 focus:outline-none'
|
|
37
|
+
|
|
29
38
|
const ChatInput = (props: ChatInputProps) => {
|
|
30
39
|
const [attachments, setAttachments] = useState<File[]>([])
|
|
31
40
|
|
|
@@ -39,11 +48,19 @@ const ChatInput = (props: ChatInputProps) => {
|
|
|
39
48
|
onStop,
|
|
40
49
|
} = props
|
|
41
50
|
|
|
42
|
-
const inputRef = useRef<
|
|
51
|
+
const inputRef = useRef<HTMLTextAreaElement>(null)
|
|
52
|
+
|
|
53
|
+
/** Cresce com o conteúdo; o `max-h` do textarea é o limite. */
|
|
54
|
+
const ajustarAltura = (el: HTMLInputElement | HTMLTextAreaElement) => {
|
|
55
|
+
el.style.height = 'auto'
|
|
56
|
+
el.style.height = `${el.scrollHeight}px`
|
|
57
|
+
}
|
|
43
58
|
|
|
44
59
|
const handleInputClear = () => {
|
|
45
60
|
if (inputRef.current) {
|
|
46
61
|
inputRef.current.value = ''
|
|
62
|
+
// Volta para a altura de uma linha.
|
|
63
|
+
inputRef.current.style.height = ''
|
|
47
64
|
}
|
|
48
65
|
setAttachments([])
|
|
49
66
|
}
|
|
@@ -58,25 +75,46 @@ const ChatInput = (props: ChatInputProps) => {
|
|
|
58
75
|
handleInputClear()
|
|
59
76
|
}
|
|
60
77
|
|
|
61
|
-
const handleKeyDown = (
|
|
62
|
-
|
|
63
|
-
|
|
78
|
+
const handleKeyDown = (
|
|
79
|
+
event: KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>,
|
|
80
|
+
) => {
|
|
81
|
+
// Enter envia; Shift+Enter quebra linha. Composição de IME (acentos)
|
|
82
|
+
// não envia: o Enter ali está confirmando o caractere.
|
|
83
|
+
if (
|
|
84
|
+
event.key === 'Enter' &&
|
|
85
|
+
!event.shiftKey &&
|
|
86
|
+
!event.nativeEvent.isComposing
|
|
87
|
+
) {
|
|
88
|
+
event.preventDefault()
|
|
89
|
+
if (!executando) {
|
|
90
|
+
enviar()
|
|
91
|
+
}
|
|
64
92
|
}
|
|
65
93
|
}
|
|
66
94
|
|
|
67
95
|
return (
|
|
68
|
-
<div className="border-2 border-gray-200 dark:border-gray-700 rounded-xl
|
|
96
|
+
<div className="shrink-0 border-2 border-gray-200 dark:border-gray-700 rounded-xl px-3 py-2 flex flex-col gap-1.5 transition-colors focus-within:border-gray-400 dark:focus-within:border-gray-500">
|
|
69
97
|
{attachments.length > 0 && (
|
|
70
98
|
<Upload
|
|
71
99
|
fileList={attachments}
|
|
72
|
-
fileListClass="flex gap-
|
|
100
|
+
fileListClass="mt-0 flex flex-wrap gap-2"
|
|
73
101
|
fileItemClass="flex gap-8"
|
|
74
102
|
onFileRemove={setAttachments}
|
|
75
103
|
>
|
|
76
104
|
<></>
|
|
77
105
|
</Upload>
|
|
78
106
|
)}
|
|
79
|
-
<
|
|
107
|
+
<Input
|
|
108
|
+
ref={useMergeRef(inputRef, ref)}
|
|
109
|
+
textArea
|
|
110
|
+
unstyle
|
|
111
|
+
rows={1}
|
|
112
|
+
placeholder={placeholder}
|
|
113
|
+
onKeyDown={handleKeyDown}
|
|
114
|
+
onChange={(event) => ajustarAltura(event.currentTarget)}
|
|
115
|
+
className={CLASSES_DO_TEXTAREA}
|
|
116
|
+
/>
|
|
117
|
+
<div className="flex items-center gap-2 w-full">
|
|
80
118
|
<Upload
|
|
81
119
|
{...uploadProps}
|
|
82
120
|
fileList={attachments}
|
|
@@ -91,34 +129,30 @@ const ChatInput = (props: ChatInputProps) => {
|
|
|
91
129
|
<TbPhotoPlus />
|
|
92
130
|
</button>
|
|
93
131
|
</Upload>
|
|
94
|
-
<input
|
|
95
|
-
ref={useMergeRef(inputRef, ref)}
|
|
96
|
-
className="flex-1 min-w-[6rem] h-full placeholder:text-gray-400 bg-transparent focus:outline-none heading-text"
|
|
97
|
-
placeholder={placeholder}
|
|
98
|
-
onKeyDown={handleKeyDown}
|
|
99
|
-
/>
|
|
100
132
|
{inputActions}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
133
|
+
<div className="ltr:ml-auto rtl:mr-auto shrink-0">
|
|
134
|
+
{executando ? (
|
|
135
|
+
<Button
|
|
136
|
+
size="xs"
|
|
137
|
+
shape="circle"
|
|
138
|
+
variant="solid"
|
|
139
|
+
icon={<TbPlayerStopFilled />}
|
|
140
|
+
aria-label="Parar a resposta"
|
|
141
|
+
title="Parar a resposta"
|
|
142
|
+
onClick={onStop}
|
|
143
|
+
/>
|
|
144
|
+
) : (
|
|
145
|
+
<Button
|
|
146
|
+
size="xs"
|
|
147
|
+
shape="circle"
|
|
148
|
+
variant="solid"
|
|
149
|
+
icon={<TbArrowRight />}
|
|
150
|
+
aria-label="Enviar"
|
|
151
|
+
title="Enviar"
|
|
152
|
+
onClick={enviar}
|
|
153
|
+
/>
|
|
154
|
+
)}
|
|
155
|
+
</div>
|
|
122
156
|
</div>
|
|
123
157
|
</div>
|
|
124
158
|
)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useSessionUser } from '@/store/authStore'
|
|
1
2
|
import useChatSend from '../hooks/useChatSend'
|
|
2
3
|
import { iconeFerramenta } from './toolPresentation'
|
|
3
4
|
|
|
@@ -47,13 +48,17 @@ const promptSuggestion: {
|
|
|
47
48
|
|
|
48
49
|
const ChatLandingView = () => {
|
|
49
50
|
const { handleSend } = useChatSend()
|
|
51
|
+
// O nome completo vem do backend (`resp.nome`, ver AuthProvider). A
|
|
52
|
+
// saudação usa só o primeiro nome, e cai no "Olá!" sem nome se ele faltar.
|
|
53
|
+
const userName = useSessionUser((state) => state.user.userName)
|
|
54
|
+
const primeiroNome = userName?.trim().split(/\s+/)[0] ?? ''
|
|
50
55
|
|
|
51
56
|
return (
|
|
52
57
|
<div className="max-w-[900px] w-full mx-auto mt-6">
|
|
53
58
|
<div>
|
|
54
59
|
<div className="heading-text text-2xl leading-snug">
|
|
55
60
|
<span className="font-semibold bg-gradient-to-r from-indigo-500 to-red-400 bg-clip-text text-transparent text-3xl">
|
|
56
|
-
Olá!
|
|
61
|
+
{primeiroNome ? `Olá, ${primeiroNome}!` : 'Olá!'}
|
|
57
62
|
</span>
|
|
58
63
|
<br />
|
|
59
64
|
<span>Como posso te ajudar hoje?</span>
|
|
@@ -133,8 +133,8 @@ const ChatView = ({
|
|
|
133
133
|
containerClass={
|
|
134
134
|
showMobileNav ? 'h-[calc(100%-30px)] xl:h-full' : 'h-full'
|
|
135
135
|
}
|
|
136
|
-
//
|
|
137
|
-
messageListClass="
|
|
136
|
+
// A lista ocupa o que sobra: o compositor cresce com o texto.
|
|
137
|
+
messageListClass="flex-1 min-h-0"
|
|
138
138
|
typing={
|
|
139
139
|
isTyping || carregando
|
|
140
140
|
? {
|
|
@@ -208,7 +208,7 @@ const ChatBody = () => {
|
|
|
208
208
|
placeholder="Enter a prompt here"
|
|
209
209
|
showAvatar={true}
|
|
210
210
|
avatarGap={true}
|
|
211
|
-
messageListClass="h-
|
|
211
|
+
messageListClass="flex-1 min-h-0"
|
|
212
212
|
bubbleClass="max-w-[300px]"
|
|
213
213
|
onInputChange={handleInputChange}
|
|
214
214
|
/>
|
package/package.json
CHANGED