funda-ui 4.6.101 → 4.6.151
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/Chatbox/index.css +25 -1
- package/Chatbox/index.d.ts +7 -0
- package/Chatbox/index.js +279 -133
- package/Date/index.js +53 -47
- package/Select/index.d.ts +4 -4
- package/TagInput/index.d.ts +6 -0
- package/TagInput/index.js +6 -3
- package/Textarea/index.js +46 -46
- package/Utils/sanitize.d.ts +14 -0
- package/Utils/sanitize.js +87 -0
- package/Utils/useAutosizeTextArea.js +46 -46
- package/lib/cjs/Chatbox/index.d.ts +7 -0
- package/lib/cjs/Chatbox/index.js +279 -133
- package/lib/cjs/Date/index.js +53 -47
- package/lib/cjs/Select/index.d.ts +4 -4
- package/lib/cjs/TagInput/index.d.ts +6 -0
- package/lib/cjs/TagInput/index.js +6 -3
- package/lib/cjs/Textarea/index.js +46 -46
- package/lib/cjs/Utils/sanitize.d.ts +14 -0
- package/lib/cjs/Utils/sanitize.js +87 -0
- package/lib/cjs/Utils/useAutosizeTextArea.js +46 -46
- package/lib/css/Chatbox/index.css +25 -1
- package/lib/esm/Chatbox/index.scss +33 -2
- package/lib/esm/Chatbox/index.tsx +70 -8
- package/lib/esm/Chatbox/utils/func.ts +0 -54
- package/lib/esm/Date/index.tsx +60 -43
- package/lib/esm/Input/index.tsx +1 -0
- package/lib/esm/Select/index.tsx +4 -5
- package/lib/esm/TagInput/index.tsx +30 -10
- package/lib/esm/Textarea/index.tsx +1 -0
- package/lib/esm/Utils/hooks/useAutosizeTextArea.tsx +47 -49
- package/lib/esm/Utils/libs/sanitize.ts +55 -0
- package/package.json +1 -1
package/Date/index.js
CHANGED
|
@@ -5002,6 +5002,9 @@ var src_Date = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_reac
|
|
|
5002
5002
|
var defaultValueIsEmpty = function defaultValueIsEmpty(s) {
|
|
5003
5003
|
return typeof s === 'undefined' || s === null || s === 'null' || s === '';
|
|
5004
5004
|
};
|
|
5005
|
+
var propExist = function propExist(p) {
|
|
5006
|
+
return typeof p !== 'undefined' && p !== null && p !== '';
|
|
5007
|
+
};
|
|
5005
5008
|
|
|
5006
5009
|
// Localization
|
|
5007
5010
|
var _langHoursTitle = langHoursTitle || 'Hours';
|
|
@@ -5613,6 +5616,54 @@ var src_Date = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_reac
|
|
|
5613
5616
|
}
|
|
5614
5617
|
return [_res, v];
|
|
5615
5618
|
}
|
|
5619
|
+
function tools() {
|
|
5620
|
+
return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", {
|
|
5621
|
+
className: (0,cls.combinedCls)('date2d__control-tools', {
|
|
5622
|
+
'date2d__control-tools--hover-show-tools': SHOW_TOOLS_ENABLED
|
|
5623
|
+
})
|
|
5624
|
+
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("a", {
|
|
5625
|
+
tabIndex: -1,
|
|
5626
|
+
href: "#",
|
|
5627
|
+
className: (0,cls.combinedCls)('date2d__control-tools__close', {
|
|
5628
|
+
'd-none': HIDE_CLEAR_BTN_ENABLED || !dateDefaultValueExist
|
|
5629
|
+
}),
|
|
5630
|
+
onClick: function onClick(e) {
|
|
5631
|
+
e.preventDefault();
|
|
5632
|
+
e.stopPropagation(); // Avoid triggering pop-ups
|
|
5633
|
+
|
|
5634
|
+
clearAll();
|
|
5635
|
+
onClear === null || onClear === void 0 ? void 0 : onClear(getFullTimeData(''));
|
|
5636
|
+
}
|
|
5637
|
+
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("svg", {
|
|
5638
|
+
width: "12px",
|
|
5639
|
+
height: "12px",
|
|
5640
|
+
viewBox: "0 0 1024 1024"
|
|
5641
|
+
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("path", {
|
|
5642
|
+
fill: "#000",
|
|
5643
|
+
d: "M195.2 195.2a64 64 0 0 1 90.496 0L512 421.504 738.304 195.2a64 64 0 0 1 90.496 90.496L602.496 512 828.8 738.304a64 64 0 0 1-90.496 90.496L512 602.496 285.696 828.8a64 64 0 0 1-90.496-90.496L421.504 512 195.2 285.696a64 64 0 0 1 0-90.496z"
|
|
5644
|
+
}))), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("a", {
|
|
5645
|
+
tabIndex: -1,
|
|
5646
|
+
href: "#",
|
|
5647
|
+
className: "date2d__control-tools__trigger",
|
|
5648
|
+
onClick: function onClick(e) {
|
|
5649
|
+
e.preventDefault();
|
|
5650
|
+
e.stopPropagation(); // Avoid triggering pop-ups
|
|
5651
|
+
|
|
5652
|
+
handleShow();
|
|
5653
|
+
}
|
|
5654
|
+
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("svg", {
|
|
5655
|
+
width: "14px",
|
|
5656
|
+
height: "14px",
|
|
5657
|
+
viewBox: "0 0 24 24",
|
|
5658
|
+
fill: "none"
|
|
5659
|
+
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("path", {
|
|
5660
|
+
d: "M3 9H21M9 15L11 17L15 13M7 3V5M17 3V5M6.2 21H17.8C18.9201 21 19.4802 21 19.908 20.782C20.2843 20.5903 20.5903 20.2843 20.782 19.908C21 19.4802 21 18.9201 21 17.8V8.2C21 7.07989 21 6.51984 20.782 6.09202C20.5903 5.71569 20.2843 5.40973 19.908 5.21799C19.4802 5 18.9201 5 17.8 5H6.2C5.0799 5 4.51984 5 4.09202 5.21799C3.71569 5.40973 3.40973 5.71569 3.21799 6.09202C3 6.51984 3 7.07989 3 8.2V17.8C3 18.9201 3 19.4802 3.21799 19.908C3.40973 20.2843 3.71569 20.5903 4.09202 20.782C4.51984 21 5.07989 21 6.2 21Z",
|
|
5661
|
+
stroke: "#000000",
|
|
5662
|
+
strokeWidth: "2",
|
|
5663
|
+
strokeLinecap: "round",
|
|
5664
|
+
strokeLinejoin: "round"
|
|
5665
|
+
}))));
|
|
5666
|
+
}
|
|
5616
5667
|
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
|
|
5617
5668
|
// update default value
|
|
5618
5669
|
//--------------
|
|
@@ -5931,54 +5982,9 @@ var src_Date = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_reac
|
|
|
5931
5982
|
setChangedVal(_full);
|
|
5932
5983
|
setTimeVal([splitVals[3], splitVals[4], _val]);
|
|
5933
5984
|
}
|
|
5934
|
-
}, attributes))) : null) : null)),
|
|
5985
|
+
}, attributes))) : null) : null), propExist(iconRight) ? tools() : null),
|
|
5935
5986
|
style: style
|
|
5936
|
-
}, attributes)), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(
|
|
5937
|
-
className: (0,cls.combinedCls)('date2d__control-tools', {
|
|
5938
|
-
'date2d__control-tools--hover-show-tools': SHOW_TOOLS_ENABLED
|
|
5939
|
-
})
|
|
5940
|
-
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("a", {
|
|
5941
|
-
tabIndex: -1,
|
|
5942
|
-
href: "#",
|
|
5943
|
-
className: (0,cls.combinedCls)('date2d__control-tools__close', {
|
|
5944
|
-
'd-none': HIDE_CLEAR_BTN_ENABLED || !dateDefaultValueExist
|
|
5945
|
-
}),
|
|
5946
|
-
onClick: function onClick(e) {
|
|
5947
|
-
e.preventDefault();
|
|
5948
|
-
e.stopPropagation(); // Avoid triggering pop-ups
|
|
5949
|
-
|
|
5950
|
-
clearAll();
|
|
5951
|
-
onClear === null || onClear === void 0 ? void 0 : onClear(getFullTimeData(''));
|
|
5952
|
-
}
|
|
5953
|
-
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("svg", {
|
|
5954
|
-
width: "12px",
|
|
5955
|
-
height: "12px",
|
|
5956
|
-
viewBox: "0 0 1024 1024"
|
|
5957
|
-
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("path", {
|
|
5958
|
-
fill: "#000",
|
|
5959
|
-
d: "M195.2 195.2a64 64 0 0 1 90.496 0L512 421.504 738.304 195.2a64 64 0 0 1 90.496 90.496L602.496 512 828.8 738.304a64 64 0 0 1-90.496 90.496L512 602.496 285.696 828.8a64 64 0 0 1-90.496-90.496L421.504 512 195.2 285.696a64 64 0 0 1 0-90.496z"
|
|
5960
|
-
}))), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("a", {
|
|
5961
|
-
tabIndex: -1,
|
|
5962
|
-
href: "#",
|
|
5963
|
-
className: "date2d__control-tools__trigger",
|
|
5964
|
-
onClick: function onClick(e) {
|
|
5965
|
-
e.preventDefault();
|
|
5966
|
-
e.stopPropagation(); // Avoid triggering pop-ups
|
|
5967
|
-
|
|
5968
|
-
handleShow();
|
|
5969
|
-
}
|
|
5970
|
-
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("svg", {
|
|
5971
|
-
width: "14px",
|
|
5972
|
-
height: "14px",
|
|
5973
|
-
viewBox: "0 0 24 24",
|
|
5974
|
-
fill: "none"
|
|
5975
|
-
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("path", {
|
|
5976
|
-
d: "M3 9H21M9 15L11 17L15 13M7 3V5M17 3V5M6.2 21H17.8C18.9201 21 19.4802 21 19.908 20.782C20.2843 20.5903 20.5903 20.2843 20.782 19.908C21 19.4802 21 18.9201 21 17.8V8.2C21 7.07989 21 6.51984 20.782 6.09202C20.5903 5.71569 20.2843 5.40973 19.908 5.21799C19.4802 5 18.9201 5 17.8 5H6.2C5.0799 5 4.51984 5 4.09202 5.21799C3.71569 5.40973 3.40973 5.71569 3.21799 6.09202C3 6.51984 3 7.07989 3 8.2V17.8C3 18.9201 3 19.4802 3.21799 19.908C3.40973 20.2843 3.71569 20.5903 4.09202 20.782C4.51984 21 5.07989 21 6.2 21Z",
|
|
5977
|
-
stroke: "#000000",
|
|
5978
|
-
strokeWidth: "2",
|
|
5979
|
-
strokeLinecap: "round",
|
|
5980
|
-
strokeLinejoin: "round"
|
|
5981
|
-
})))))), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((dist_cjs_default()), {
|
|
5987
|
+
}, attributes)), !propExist(iconRight) ? tools() : null)), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((dist_cjs_default()), {
|
|
5982
5988
|
show: isShow,
|
|
5983
5989
|
containerClassName: (0,cls.combinedCls)('Date', "Date--".concat(type))
|
|
5984
5990
|
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", _extends({
|
package/Select/index.d.ts
CHANGED
|
@@ -13,9 +13,9 @@ export interface OptionConfig {
|
|
|
13
13
|
disabled?: boolean;
|
|
14
14
|
optgroup?: any[];
|
|
15
15
|
group?: boolean;
|
|
16
|
-
label:
|
|
17
|
-
listItemLabel?:
|
|
18
|
-
value:
|
|
16
|
+
label: string;
|
|
17
|
+
listItemLabel?: string;
|
|
18
|
+
value: string | number | boolean;
|
|
19
19
|
queryString: string | number;
|
|
20
20
|
callback?: () => void;
|
|
21
21
|
}
|
|
@@ -46,7 +46,7 @@ export declare type SelectProps = {
|
|
|
46
46
|
multiSelect?: MultiSelectConfig;
|
|
47
47
|
multiSelectEntireAreaTrigger?: boolean;
|
|
48
48
|
multiSelectSelectedItemOnlyStatus?: multiSelectSelectedItemOnlyStatusConfig;
|
|
49
|
-
renderSelectedValue?: (selectedData: MultiSelectControlValConfig, removeFunc: (e: React.MouseEvent) => void) =>
|
|
49
|
+
renderSelectedValue?: (selectedData: MultiSelectControlValConfig, removeFunc: (e: React.MouseEvent) => void) => React.ReactNode;
|
|
50
50
|
cleanTrigger?: CleanTriggerConfig;
|
|
51
51
|
defaultValue?: string | OptionConfig;
|
|
52
52
|
value?: string | OptionConfig;
|
package/TagInput/index.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
export interface TagValConfig {
|
|
3
|
+
content: string;
|
|
4
|
+
id: number;
|
|
5
|
+
[key: string]: string | boolean | number;
|
|
6
|
+
}
|
|
2
7
|
export declare type TagInputProps = {
|
|
3
8
|
contentRef?: React.ForwardedRef<any>;
|
|
4
9
|
wrapperClassName?: string;
|
|
@@ -13,6 +18,7 @@ export declare type TagInputProps = {
|
|
|
13
18
|
required?: any;
|
|
14
19
|
readOnly?: any;
|
|
15
20
|
placeholder?: string;
|
|
21
|
+
renderSelectedValue?: (selectedData: TagValConfig[], removeFunc: (e: React.MouseEvent) => void) => React.ReactNode;
|
|
16
22
|
/** Whether to use square brackets to save result and initialize default value */
|
|
17
23
|
extractValueByBrackets?: boolean;
|
|
18
24
|
/** -- */
|
package/TagInput/index.js
CHANGED
|
@@ -828,7 +828,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
828
828
|
/* harmony import */ var funda_utils_dist_cjs_convert__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(funda_utils_dist_cjs_convert__WEBPACK_IMPORTED_MODULE_3__);
|
|
829
829
|
/* harmony import */ var funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(188);
|
|
830
830
|
/* harmony import */ var funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_4__);
|
|
831
|
-
var _excluded = ["contentRef", "wrapperClassName", "maxTags", "disabled", "required", "placeholder", "readOnly", "value", "requiredLabel", "label", "name", "id", "autoComplete", "autoCapitalize", "spellCheck", "extractValueByBrackets", "minLength", "maxLength", "style", "tabIndex", "onChange", "onBlur", "onFocus"];
|
|
831
|
+
var _excluded = ["contentRef", "wrapperClassName", "maxTags", "disabled", "required", "placeholder", "renderSelectedValue", "readOnly", "value", "requiredLabel", "label", "name", "id", "autoComplete", "autoCapitalize", "spellCheck", "extractValueByBrackets", "minLength", "maxLength", "style", "tabIndex", "onChange", "onBlur", "onFocus"];
|
|
832
832
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
833
833
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
834
834
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -850,6 +850,7 @@ var TagInput = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(fu
|
|
|
850
850
|
disabled = props.disabled,
|
|
851
851
|
required = props.required,
|
|
852
852
|
placeholder = props.placeholder,
|
|
853
|
+
renderSelectedValue = props.renderSelectedValue,
|
|
853
854
|
readOnly = props.readOnly,
|
|
854
855
|
value = props.value,
|
|
855
856
|
requiredLabel = props.requiredLabel,
|
|
@@ -932,6 +933,8 @@ var TagInput = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(fu
|
|
|
932
933
|
}
|
|
933
934
|
function handleRemove(e) {
|
|
934
935
|
e.preventDefault();
|
|
936
|
+
e.stopPropagation(); /* REQUIRED */
|
|
937
|
+
|
|
935
938
|
var idToRemove = Number(e.currentTarget.dataset.item);
|
|
936
939
|
var newArray = items.filter(function (item) {
|
|
937
940
|
return item.id !== idToRemove;
|
|
@@ -1056,7 +1059,7 @@ var TagInput = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(fu
|
|
|
1056
1059
|
className: "tag-input__control-wrapper"
|
|
1057
1060
|
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("ul", {
|
|
1058
1061
|
className: "tag-input__list"
|
|
1059
|
-
}, items ? items.map(function (item, index) {
|
|
1062
|
+
}, typeof renderSelectedValue === 'function' ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, renderSelectedValue(items, handleRemove)) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, items ? items.map(function (item, index) {
|
|
1060
1063
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("li", {
|
|
1061
1064
|
key: index
|
|
1062
1065
|
}, item.content, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("a", {
|
|
@@ -1072,7 +1075,7 @@ var TagInput = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(fu
|
|
|
1072
1075
|
fill: "#000",
|
|
1073
1076
|
d: "M195.2 195.2a64 64 0 0 1 90.496 0L512 421.504 738.304 195.2a64 64 0 0 1 90.496 90.496L602.496 512 828.8 738.304a64 64 0 0 1-90.496 90.496L512 602.496 285.696 828.8a64 64 0 0 1-90.496-90.496L421.504 512 195.2 285.696a64 64 0 0 1 0-90.496z"
|
|
1074
1077
|
}))));
|
|
1075
|
-
}) : null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
1078
|
+
}) : null)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
1076
1079
|
className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_4__.combinedCls)('tag-input__control', {
|
|
1077
1080
|
'disabled': disabled
|
|
1078
1081
|
}),
|
package/Textarea/index.js
CHANGED
|
@@ -713,63 +713,63 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
713
713
|
_ref$maxHeight = _ref.maxHeight,
|
|
714
714
|
maxHeight = _ref$maxHeight === void 0 ? 0 : _ref$maxHeight,
|
|
715
715
|
cb = _ref.cb;
|
|
716
|
-
var _useState = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)(
|
|
716
|
+
var _useState = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)(false),
|
|
717
717
|
_useState2 = _slicedToArray(_useState, 2),
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
var _useState3 = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)(false),
|
|
721
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
722
|
-
defaultRowHeightInit = _useState4[0],
|
|
723
|
-
setDefaultRowHeightInit = _useState4[1];
|
|
718
|
+
defaultRowHeightInit = _useState2[0],
|
|
719
|
+
setDefaultRowHeightInit = _useState2[1];
|
|
724
720
|
|
|
725
721
|
// Reset function to restore default height
|
|
726
722
|
var reset = (0, react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function () {
|
|
727
|
-
if (el
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
}, [el,
|
|
723
|
+
if (!el) return;
|
|
724
|
+
var scrollHeight = el.scrollHeight;
|
|
725
|
+
el.style.height = scrollHeight + "px";
|
|
726
|
+
|
|
727
|
+
// Get current dimensions after reset
|
|
728
|
+
var style = window.getComputedStyle(el);
|
|
729
|
+
var _controlWidth = el.scrollWidth + parseInt(style.borderLeftWidth) + parseInt(style.borderRightWidth);
|
|
730
|
+
cb === null || cb === void 0 ? void 0 : cb([_controlWidth, scrollHeight]);
|
|
731
|
+
}, [el, cb]);
|
|
736
732
|
(0, react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
|
|
737
|
-
if (el)
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
733
|
+
if (!el) return;
|
|
734
|
+
|
|
735
|
+
// Initialize default height
|
|
736
|
+
if (!defaultRowHeightInit) {
|
|
737
|
+
el.style.height = 'auto';
|
|
738
|
+
var initialHeight = el.scrollHeight;
|
|
739
|
+
setDefaultRowHeightInit(true);
|
|
740
|
+
|
|
741
|
+
// If the height is 0, set it to "auto"
|
|
742
|
+
if (initialHeight === 0) {
|
|
743
|
+
el.style.height = "auto";
|
|
744
|
+
} else {
|
|
745
|
+
el.style.height = initialHeight + "px";
|
|
749
746
|
}
|
|
747
|
+
}
|
|
750
748
|
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
}
|
|
749
|
+
// Get dimensions
|
|
750
|
+
var style = window.getComputedStyle(el);
|
|
751
|
+
var _controlWidth = el.scrollWidth + parseInt(style.borderLeftWidth) + parseInt(style.borderRightWidth);
|
|
755
752
|
|
|
756
|
-
|
|
757
|
-
|
|
753
|
+
// Calculate height
|
|
754
|
+
el.style.height = 'auto';
|
|
755
|
+
var finalHeight = el.scrollHeight;
|
|
758
756
|
|
|
759
|
-
|
|
760
|
-
|
|
757
|
+
// Apply max height limit if needed
|
|
758
|
+
if (maxHeight > 0 && finalHeight > maxHeight) {
|
|
759
|
+
finalHeight = maxHeight;
|
|
760
|
+
}
|
|
761
761
|
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
el.style.height = _scrollHeight + "px";
|
|
769
|
-
}
|
|
770
|
-
cb === null || cb === void 0 ? void 0 : cb([_controlWidth, scrollHeight]);
|
|
762
|
+
// Set final height
|
|
763
|
+
// If the height is 0, set it to "auto"
|
|
764
|
+
if (finalHeight === 0) {
|
|
765
|
+
el.style.height = "auto";
|
|
766
|
+
} else {
|
|
767
|
+
el.style.height = finalHeight + "px";
|
|
771
768
|
}
|
|
772
|
-
|
|
769
|
+
|
|
770
|
+
// Callback
|
|
771
|
+
cb === null || cb === void 0 ? void 0 : cb([_controlWidth, finalHeight]);
|
|
772
|
+
}, [el, value, maxHeight, defaultRowHeightInit]);
|
|
773
773
|
return {
|
|
774
774
|
reset: reset
|
|
775
775
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTML entities encode
|
|
3
|
+
*
|
|
4
|
+
* @param {String} str Input text
|
|
5
|
+
* @return {String} Filtered text
|
|
6
|
+
*/ declare function htmlEncode(str: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* HTML entities decode
|
|
9
|
+
*
|
|
10
|
+
* @param {String} str Input text
|
|
11
|
+
* @return {String} Filtered text
|
|
12
|
+
*/
|
|
13
|
+
declare function htmlDecode(str?: string): string;
|
|
14
|
+
export { htmlEncode, htmlDecode };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
|
2
|
+
if(typeof exports === 'object' && typeof module === 'object')
|
|
3
|
+
module.exports = factory();
|
|
4
|
+
else if(typeof define === 'function' && define.amd)
|
|
5
|
+
define([], factory);
|
|
6
|
+
else if(typeof exports === 'object')
|
|
7
|
+
exports["RPB"] = factory();
|
|
8
|
+
else
|
|
9
|
+
root["RPB"] = factory();
|
|
10
|
+
})(this, () => {
|
|
11
|
+
return /******/ (() => { // webpackBootstrap
|
|
12
|
+
/******/ "use strict";
|
|
13
|
+
/******/ // The require scope
|
|
14
|
+
/******/ var __webpack_require__ = {};
|
|
15
|
+
/******/
|
|
16
|
+
/************************************************************************/
|
|
17
|
+
/******/ /* webpack/runtime/define property getters */
|
|
18
|
+
/******/ (() => {
|
|
19
|
+
/******/ // define getter functions for harmony exports
|
|
20
|
+
/******/ __webpack_require__.d = (exports, definition) => {
|
|
21
|
+
/******/ for(var key in definition) {
|
|
22
|
+
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
23
|
+
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
24
|
+
/******/ }
|
|
25
|
+
/******/ }
|
|
26
|
+
/******/ };
|
|
27
|
+
/******/ })();
|
|
28
|
+
/******/
|
|
29
|
+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
30
|
+
/******/ (() => {
|
|
31
|
+
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
32
|
+
/******/ })();
|
|
33
|
+
/******/
|
|
34
|
+
/******/ /* webpack/runtime/make namespace object */
|
|
35
|
+
/******/ (() => {
|
|
36
|
+
/******/ // define __esModule on exports
|
|
37
|
+
/******/ __webpack_require__.r = (exports) => {
|
|
38
|
+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
39
|
+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
40
|
+
/******/ }
|
|
41
|
+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
42
|
+
/******/ };
|
|
43
|
+
/******/ })();
|
|
44
|
+
/******/
|
|
45
|
+
/************************************************************************/
|
|
46
|
+
var __webpack_exports__ = {};
|
|
47
|
+
__webpack_require__.r(__webpack_exports__);
|
|
48
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
49
|
+
/* harmony export */ "htmlDecode": () => (/* binding */ htmlDecode),
|
|
50
|
+
/* harmony export */ "htmlEncode": () => (/* binding */ htmlEncode)
|
|
51
|
+
/* harmony export */ });
|
|
52
|
+
/**
|
|
53
|
+
* HTML entities encode
|
|
54
|
+
*
|
|
55
|
+
* @param {String} str Input text
|
|
56
|
+
* @return {String} Filtered text
|
|
57
|
+
*/function htmlEncode(str) {
|
|
58
|
+
return str.replace(/[&<>'"]/g, function (tag) {
|
|
59
|
+
return {
|
|
60
|
+
'&': '&',
|
|
61
|
+
'<': '<',
|
|
62
|
+
'>': '>',
|
|
63
|
+
"'": ''',
|
|
64
|
+
'"': '"'
|
|
65
|
+
}[tag];
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* HTML entities decode
|
|
71
|
+
*
|
|
72
|
+
* @param {String} str Input text
|
|
73
|
+
* @return {String} Filtered text
|
|
74
|
+
*/
|
|
75
|
+
function htmlDecode() {
|
|
76
|
+
var str = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
77
|
+
var entities = [['amp', '&'], ['apos', '\''], ['#x27', '\''], ['#x2F', '/'], ['#39', '\''], ['#47', '/'], ['lt', '<'], ['gt', '>'], ['nbsp', ' '], ['quot', '"'], ['#60', '<'], ['#62', '>']];
|
|
78
|
+
for (var i = 0, max = entities.length; i < max; i++) {
|
|
79
|
+
str = str.replace(new RegExp('&' + entities[i][0] + ';', 'g'), entities[i][1]);
|
|
80
|
+
}
|
|
81
|
+
return str;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/******/ return __webpack_exports__;
|
|
85
|
+
/******/ })()
|
|
86
|
+
;
|
|
87
|
+
});
|
|
@@ -161,63 +161,63 @@ var useAutosizeTextArea = function useAutosizeTextArea(_ref) {
|
|
|
161
161
|
_ref$maxHeight = _ref.maxHeight,
|
|
162
162
|
maxHeight = _ref$maxHeight === void 0 ? 0 : _ref$maxHeight,
|
|
163
163
|
cb = _ref.cb;
|
|
164
|
-
var _useState = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(
|
|
164
|
+
var _useState = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false),
|
|
165
165
|
_useState2 = _slicedToArray(_useState, 2),
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
var _useState3 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false),
|
|
169
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
170
|
-
defaultRowHeightInit = _useState4[0],
|
|
171
|
-
setDefaultRowHeightInit = _useState4[1];
|
|
166
|
+
defaultRowHeightInit = _useState2[0],
|
|
167
|
+
setDefaultRowHeightInit = _useState2[1];
|
|
172
168
|
|
|
173
169
|
// Reset function to restore default height
|
|
174
170
|
var reset = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function () {
|
|
175
|
-
if (el
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}, [el,
|
|
171
|
+
if (!el) return;
|
|
172
|
+
var scrollHeight = el.scrollHeight;
|
|
173
|
+
el.style.height = scrollHeight + "px";
|
|
174
|
+
|
|
175
|
+
// Get current dimensions after reset
|
|
176
|
+
var style = window.getComputedStyle(el);
|
|
177
|
+
var _controlWidth = el.scrollWidth + parseInt(style.borderLeftWidth) + parseInt(style.borderRightWidth);
|
|
178
|
+
cb === null || cb === void 0 ? void 0 : cb([_controlWidth, scrollHeight]);
|
|
179
|
+
}, [el, cb]);
|
|
184
180
|
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
|
|
185
|
-
if (el)
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
181
|
+
if (!el) return;
|
|
182
|
+
|
|
183
|
+
// Initialize default height
|
|
184
|
+
if (!defaultRowHeightInit) {
|
|
185
|
+
el.style.height = 'auto';
|
|
186
|
+
var initialHeight = el.scrollHeight;
|
|
187
|
+
setDefaultRowHeightInit(true);
|
|
188
|
+
|
|
189
|
+
// If the height is 0, set it to "auto"
|
|
190
|
+
if (initialHeight === 0) {
|
|
191
|
+
el.style.height = "auto";
|
|
192
|
+
} else {
|
|
193
|
+
el.style.height = initialHeight + "px";
|
|
197
194
|
}
|
|
195
|
+
}
|
|
198
196
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}
|
|
197
|
+
// Get dimensions
|
|
198
|
+
var style = window.getComputedStyle(el);
|
|
199
|
+
var _controlWidth = el.scrollWidth + parseInt(style.borderLeftWidth) + parseInt(style.borderRightWidth);
|
|
203
200
|
|
|
204
|
-
|
|
205
|
-
|
|
201
|
+
// Calculate height
|
|
202
|
+
el.style.height = 'auto';
|
|
203
|
+
var finalHeight = el.scrollHeight;
|
|
206
204
|
|
|
207
|
-
|
|
208
|
-
|
|
205
|
+
// Apply max height limit if needed
|
|
206
|
+
if (maxHeight > 0 && finalHeight > maxHeight) {
|
|
207
|
+
finalHeight = maxHeight;
|
|
208
|
+
}
|
|
209
209
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
el.style.height = _scrollHeight + "px";
|
|
217
|
-
}
|
|
218
|
-
cb === null || cb === void 0 ? void 0 : cb([_controlWidth, scrollHeight]);
|
|
210
|
+
// Set final height
|
|
211
|
+
// If the height is 0, set it to "auto"
|
|
212
|
+
if (finalHeight === 0) {
|
|
213
|
+
el.style.height = "auto";
|
|
214
|
+
} else {
|
|
215
|
+
el.style.height = finalHeight + "px";
|
|
219
216
|
}
|
|
220
|
-
|
|
217
|
+
|
|
218
|
+
// Callback
|
|
219
|
+
cb === null || cb === void 0 ? void 0 : cb([_controlWidth, finalHeight]);
|
|
220
|
+
}, [el, value, maxHeight, defaultRowHeightInit]);
|
|
221
221
|
return {
|
|
222
222
|
reset: reset
|
|
223
223
|
};
|
|
@@ -9,6 +9,10 @@ export declare type MessageDetail = {
|
|
|
9
9
|
content: string;
|
|
10
10
|
tag: string;
|
|
11
11
|
};
|
|
12
|
+
export declare type QuestionData = {
|
|
13
|
+
title: string;
|
|
14
|
+
list: Array<string>;
|
|
15
|
+
};
|
|
12
16
|
export interface FloatingButton {
|
|
13
17
|
label: string;
|
|
14
18
|
value: string;
|
|
@@ -38,6 +42,7 @@ export declare type CustomRequestResponse = {
|
|
|
38
42
|
export declare type CustomRequestFunction = (message: string, config: CustomRequestConfig) => Promise<CustomRequestResponse>;
|
|
39
43
|
export declare type ChatboxProps = {
|
|
40
44
|
debug?: boolean;
|
|
45
|
+
defaultRows?: number;
|
|
41
46
|
prefix?: string;
|
|
42
47
|
contentRef?: React.RefObject<any>;
|
|
43
48
|
model?: string;
|
|
@@ -65,10 +70,12 @@ export declare type ChatboxProps = {
|
|
|
65
70
|
toolkitButtons?: FloatingButton[];
|
|
66
71
|
newChatButton?: FloatingButton;
|
|
67
72
|
customMethods?: CustomMethod[];
|
|
73
|
+
defaultQuestions?: QuestionData;
|
|
68
74
|
customRequest?: CustomRequestFunction;
|
|
69
75
|
renderParser?: (input: string) => Promise<string>;
|
|
70
76
|
requestBodyFormatter?: (body: any, contextData: Record<string, any>, conversationHistory: MessageDetail[]) => Promise<Record<string, any>>;
|
|
71
77
|
nameFormatter?: (input: string) => string;
|
|
78
|
+
onQuestionClick?: (text: string, methods: Record<string, Function>) => void;
|
|
72
79
|
onInputChange?: (controlRef: React.RefObject<any>, val: string) => any;
|
|
73
80
|
onInputCallback?: (input: string) => Promise<string>;
|
|
74
81
|
onChunk?: (controlRef: React.RefObject<any>, lastContent: string, conversationHistory: MessageDetail[]) => any;
|