funda-ui 4.5.888 → 4.5.899

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/Textarea/index.js CHANGED
@@ -740,7 +740,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
740
740
 
741
741
  // initialize default row height
742
742
  if (el.scrollHeight > 0 && !defaultRowHeightInit) {
743
- setDefaultRowHeight(el.scrollHeight + parseInt(style.borderTopWidth) + parseInt(style.borderBottomWidth));
743
+ var _defaultRowHeight = el.scrollHeight + parseInt(style.borderTopWidth) + parseInt(style.borderBottomWidth);
744
+ if (maxHeight != 0 && _defaultRowHeight >= maxHeight) {
745
+ _defaultRowHeight = maxHeight;
746
+ }
747
+ setDefaultRowHeight(_defaultRowHeight);
744
748
  setDefaultRowHeightInit(true);
745
749
  }
746
750
 
@@ -757,11 +761,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
757
761
 
758
762
  // !!! Compare initial height and changed height
759
763
  if (scrollHeight > defaultRowHeight && defaultRowHeight > 0) {
760
- if (maxHeight != 0 && scrollHeight >= maxHeight) {
761
- el.style.height = maxHeight + "px";
762
- } else {
763
- el.style.height = scrollHeight + "px";
764
+ var _scrollHeight = scrollHeight;
765
+ if (maxHeight != 0 && _scrollHeight >= maxHeight) {
766
+ _scrollHeight = maxHeight;
764
767
  }
768
+ el.style.height = _scrollHeight + "px";
765
769
  }
766
770
  cb === null || cb === void 0 ? void 0 : cb([_controlWidth, scrollHeight]);
767
771
  }
@@ -188,7 +188,11 @@ var useAutosizeTextArea = function useAutosizeTextArea(_ref) {
188
188
 
189
189
  // initialize default row height
190
190
  if (el.scrollHeight > 0 && !defaultRowHeightInit) {
191
- setDefaultRowHeight(el.scrollHeight + parseInt(style.borderTopWidth) + parseInt(style.borderBottomWidth));
191
+ var _defaultRowHeight = el.scrollHeight + parseInt(style.borderTopWidth) + parseInt(style.borderBottomWidth);
192
+ if (maxHeight != 0 && _defaultRowHeight >= maxHeight) {
193
+ _defaultRowHeight = maxHeight;
194
+ }
195
+ setDefaultRowHeight(_defaultRowHeight);
192
196
  setDefaultRowHeightInit(true);
193
197
  }
194
198
 
@@ -205,11 +209,11 @@ var useAutosizeTextArea = function useAutosizeTextArea(_ref) {
205
209
 
206
210
  // !!! Compare initial height and changed height
207
211
  if (scrollHeight > defaultRowHeight && defaultRowHeight > 0) {
208
- if (maxHeight != 0 && scrollHeight >= maxHeight) {
209
- el.style.height = maxHeight + "px";
210
- } else {
211
- el.style.height = scrollHeight + "px";
212
+ var _scrollHeight = scrollHeight;
213
+ if (maxHeight != 0 && _scrollHeight >= maxHeight) {
214
+ _scrollHeight = maxHeight;
212
215
  }
216
+ el.style.height = _scrollHeight + "px";
213
217
  }
214
218
  cb === null || cb === void 0 ? void 0 : cb([_controlWidth, scrollHeight]);
215
219
  }
@@ -0,0 +1,2 @@
1
+ declare const useGlobalUrlListener: () => string;
2
+ export default useGlobalUrlListener;
@@ -0,0 +1,157 @@
1
+ (function webpackUniversalModuleDefinition(root, factory) {
2
+ if(typeof exports === 'object' && typeof module === 'object')
3
+ module.exports = factory(require("react"));
4
+ else if(typeof define === 'function' && define.amd)
5
+ define(["react"], factory);
6
+ else if(typeof exports === 'object')
7
+ exports["RPB"] = factory(require("react"));
8
+ else
9
+ root["RPB"] = factory(root["React"]);
10
+ })(this, (__WEBPACK_EXTERNAL_MODULE__787__) => {
11
+ return /******/ (() => { // webpackBootstrap
12
+ /******/ "use strict";
13
+ /******/ var __webpack_modules__ = ({
14
+
15
+ /***/ 787:
16
+ /***/ ((module) => {
17
+
18
+ module.exports = __WEBPACK_EXTERNAL_MODULE__787__;
19
+
20
+ /***/ })
21
+
22
+ /******/ });
23
+ /************************************************************************/
24
+ /******/ // The module cache
25
+ /******/ var __webpack_module_cache__ = {};
26
+ /******/
27
+ /******/ // The require function
28
+ /******/ function __webpack_require__(moduleId) {
29
+ /******/ // Check if module is in cache
30
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
31
+ /******/ if (cachedModule !== undefined) {
32
+ /******/ return cachedModule.exports;
33
+ /******/ }
34
+ /******/ // Create a new module (and put it into the cache)
35
+ /******/ var module = __webpack_module_cache__[moduleId] = {
36
+ /******/ // no module.id needed
37
+ /******/ // no module.loaded needed
38
+ /******/ exports: {}
39
+ /******/ };
40
+ /******/
41
+ /******/ // Execute the module function
42
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
43
+ /******/
44
+ /******/ // Return the exports of the module
45
+ /******/ return module.exports;
46
+ /******/ }
47
+ /******/
48
+ /************************************************************************/
49
+ /******/ /* webpack/runtime/compat get default export */
50
+ /******/ (() => {
51
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
52
+ /******/ __webpack_require__.n = (module) => {
53
+ /******/ var getter = module && module.__esModule ?
54
+ /******/ () => (module['default']) :
55
+ /******/ () => (module);
56
+ /******/ __webpack_require__.d(getter, { a: getter });
57
+ /******/ return getter;
58
+ /******/ };
59
+ /******/ })();
60
+ /******/
61
+ /******/ /* webpack/runtime/define property getters */
62
+ /******/ (() => {
63
+ /******/ // define getter functions for harmony exports
64
+ /******/ __webpack_require__.d = (exports, definition) => {
65
+ /******/ for(var key in definition) {
66
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
67
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
68
+ /******/ }
69
+ /******/ }
70
+ /******/ };
71
+ /******/ })();
72
+ /******/
73
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
74
+ /******/ (() => {
75
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
76
+ /******/ })();
77
+ /******/
78
+ /******/ /* webpack/runtime/make namespace object */
79
+ /******/ (() => {
80
+ /******/ // define __esModule on exports
81
+ /******/ __webpack_require__.r = (exports) => {
82
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
83
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
84
+ /******/ }
85
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
86
+ /******/ };
87
+ /******/ })();
88
+ /******/
89
+ /************************************************************************/
90
+ var __webpack_exports__ = {};
91
+ // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
92
+ (() => {
93
+ __webpack_require__.r(__webpack_exports__);
94
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
95
+ /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
96
+ /* harmony export */ });
97
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(787);
98
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
99
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
100
+ 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."); }
101
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
102
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
103
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
104
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
105
+ /**
106
+ * Global Url Listener (including micro frontends, frameworks, hashes, etc., applicable to multiple react app)
107
+ *
108
+ * @usage:
109
+
110
+ const App = () => {
111
+ const url = useGlobalUrlListener();
112
+
113
+ useEffect(() => {
114
+ console.log("URL changed:", url);
115
+ }, [url]);
116
+ };
117
+
118
+ */
119
+
120
+ var useGlobalUrlListener = function useGlobalUrlListener() {
121
+ // Initialize state with empty string to avoid SSR issues
122
+ var _useState = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(''),
123
+ _useState2 = _slicedToArray(_useState, 2),
124
+ url = _useState2[0],
125
+ setUrl = _useState2[1];
126
+ (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
127
+ // Type guard for SSR
128
+ if (typeof window === 'undefined') return;
129
+
130
+ // Initialize the URL on the client side
131
+ setUrl(window.location.href);
132
+
133
+ // Create MutationObserver instance
134
+ var observer = new MutationObserver(function () {
135
+ setUrl(window.location.href);
136
+ });
137
+
138
+ // Start observing
139
+ observer.observe(document, {
140
+ subtree: true,
141
+ childList: true
142
+ });
143
+
144
+ // Cleanup function
145
+ return function () {
146
+ return observer.disconnect();
147
+ };
148
+ }, []);
149
+ return url;
150
+ };
151
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (useGlobalUrlListener);
152
+ })();
153
+
154
+ /******/ return __webpack_exports__;
155
+ /******/ })()
156
+ ;
157
+ });
@@ -0,0 +1,2 @@
1
+ declare const useSessionStorageListener: (key: string) => string;
2
+ export default useSessionStorageListener;
@@ -0,0 +1,157 @@
1
+ (function webpackUniversalModuleDefinition(root, factory) {
2
+ if(typeof exports === 'object' && typeof module === 'object')
3
+ module.exports = factory(require("react"));
4
+ else if(typeof define === 'function' && define.amd)
5
+ define(["react"], factory);
6
+ else if(typeof exports === 'object')
7
+ exports["RPB"] = factory(require("react"));
8
+ else
9
+ root["RPB"] = factory(root["React"]);
10
+ })(this, (__WEBPACK_EXTERNAL_MODULE__787__) => {
11
+ return /******/ (() => { // webpackBootstrap
12
+ /******/ "use strict";
13
+ /******/ var __webpack_modules__ = ({
14
+
15
+ /***/ 787:
16
+ /***/ ((module) => {
17
+
18
+ module.exports = __WEBPACK_EXTERNAL_MODULE__787__;
19
+
20
+ /***/ })
21
+
22
+ /******/ });
23
+ /************************************************************************/
24
+ /******/ // The module cache
25
+ /******/ var __webpack_module_cache__ = {};
26
+ /******/
27
+ /******/ // The require function
28
+ /******/ function __webpack_require__(moduleId) {
29
+ /******/ // Check if module is in cache
30
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
31
+ /******/ if (cachedModule !== undefined) {
32
+ /******/ return cachedModule.exports;
33
+ /******/ }
34
+ /******/ // Create a new module (and put it into the cache)
35
+ /******/ var module = __webpack_module_cache__[moduleId] = {
36
+ /******/ // no module.id needed
37
+ /******/ // no module.loaded needed
38
+ /******/ exports: {}
39
+ /******/ };
40
+ /******/
41
+ /******/ // Execute the module function
42
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
43
+ /******/
44
+ /******/ // Return the exports of the module
45
+ /******/ return module.exports;
46
+ /******/ }
47
+ /******/
48
+ /************************************************************************/
49
+ /******/ /* webpack/runtime/compat get default export */
50
+ /******/ (() => {
51
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
52
+ /******/ __webpack_require__.n = (module) => {
53
+ /******/ var getter = module && module.__esModule ?
54
+ /******/ () => (module['default']) :
55
+ /******/ () => (module);
56
+ /******/ __webpack_require__.d(getter, { a: getter });
57
+ /******/ return getter;
58
+ /******/ };
59
+ /******/ })();
60
+ /******/
61
+ /******/ /* webpack/runtime/define property getters */
62
+ /******/ (() => {
63
+ /******/ // define getter functions for harmony exports
64
+ /******/ __webpack_require__.d = (exports, definition) => {
65
+ /******/ for(var key in definition) {
66
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
67
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
68
+ /******/ }
69
+ /******/ }
70
+ /******/ };
71
+ /******/ })();
72
+ /******/
73
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
74
+ /******/ (() => {
75
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
76
+ /******/ })();
77
+ /******/
78
+ /******/ /* webpack/runtime/make namespace object */
79
+ /******/ (() => {
80
+ /******/ // define __esModule on exports
81
+ /******/ __webpack_require__.r = (exports) => {
82
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
83
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
84
+ /******/ }
85
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
86
+ /******/ };
87
+ /******/ })();
88
+ /******/
89
+ /************************************************************************/
90
+ var __webpack_exports__ = {};
91
+ // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
92
+ (() => {
93
+ __webpack_require__.r(__webpack_exports__);
94
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
95
+ /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
96
+ /* harmony export */ });
97
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(787);
98
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
99
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
100
+ 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."); }
101
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
102
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
103
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
104
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
105
+ /**
106
+ * Session Storage Listener
107
+ *
108
+ * @usage:
109
+
110
+ const App = () => {
111
+ const myValue = useSessionStorageListener("myKey");
112
+
113
+ useEffect(() => {
114
+ console.log("sessionStorage change:", myValue);
115
+ }, [myValue]);
116
+ };
117
+
118
+ */
119
+
120
+ var useSessionStorageListener = function useSessionStorageListener(key) {
121
+ var _useState = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(sessionStorage.getItem(key) || ""),
122
+ _useState2 = _slicedToArray(_useState, 2),
123
+ value = _useState2[0],
124
+ setValue = _useState2[1];
125
+ (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
126
+ var handleStorageChange = function handleStorageChange(event) {
127
+ if (event instanceof CustomEvent && event.detail.key === key) {
128
+ setValue(event.detail.value);
129
+ }
130
+ };
131
+ window.addEventListener("sessionStorageChange", handleStorageChange);
132
+ return function () {
133
+ return window.removeEventListener("sessionStorageChange", handleStorageChange);
134
+ };
135
+ }, [key]);
136
+ return value;
137
+ };
138
+
139
+ // interception sessionStorage.setItem
140
+ var originalSetItem = sessionStorage.setItem;
141
+ sessionStorage.setItem = function (key, value) {
142
+ var event = new CustomEvent("sessionStorageChange", {
143
+ detail: {
144
+ key: key,
145
+ value: value
146
+ }
147
+ });
148
+ window.dispatchEvent(event);
149
+ originalSetItem.apply(this, [key, value]);
150
+ };
151
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (useSessionStorageListener);
152
+ })();
153
+
154
+ /******/ return __webpack_exports__;
155
+ /******/ })()
156
+ ;
157
+ });
@@ -1,4 +1,8 @@
1
1
  import React from "react";
2
+ export interface CustomMethod {
3
+ name: string;
4
+ func: (...args: any[]) => any;
5
+ }
2
6
  export declare type MessageDetail = {
3
7
  sender: string;
4
8
  timestamp: string;
@@ -9,22 +13,29 @@ export interface FloatingButton {
9
13
  label: string;
10
14
  value: string;
11
15
  onClick: string;
16
+ isSelect?: boolean;
17
+ [key: string]: any;
18
+ }
19
+ export interface FloatingButtonSelectOption {
20
+ label: string;
21
+ value: string;
22
+ onClick: string;
12
23
  }
13
24
  export interface RequestConfig {
14
25
  apiUrl: string;
15
26
  requestBody: string;
16
27
  responseExtractor: string;
17
28
  }
18
- declare type CustomRequestConfig = {
29
+ export declare type CustomRequestConfig = {
19
30
  requestBody: any;
20
31
  apiUrl: string;
21
32
  headers: any;
22
33
  };
23
- declare type CustomRequestResponse = {
34
+ export declare type CustomRequestResponse = {
24
35
  content: string | Response | null;
25
36
  isStream: boolean;
26
37
  };
27
- declare type CustomRequestFunction = (message: string, config: CustomRequestConfig) => Promise<CustomRequestResponse>;
38
+ export declare type CustomRequestFunction = (message: string, config: CustomRequestConfig) => Promise<CustomRequestResponse>;
28
39
  export declare type ChatboxProps = {
29
40
  debug?: boolean;
30
41
  prefix?: string;
@@ -53,11 +64,13 @@ export declare type ChatboxProps = {
53
64
  contextData?: Record<string, any>;
54
65
  toolkitButtons?: FloatingButton[];
55
66
  newChatButton?: FloatingButton;
67
+ customMethods?: CustomMethod[];
56
68
  customRequest?: CustomRequestFunction;
57
69
  renderParser?: (input: string) => Promise<string>;
58
70
  requestBodyFormatter?: (body: any, contextData: Record<string, any>, conversationHistory: MessageDetail[]) => Promise<Record<string, any>>;
59
71
  nameFormatter?: (input: string) => string;
60
72
  onInputChange?: (controlRef: React.RefObject<any>, val: string) => any;
73
+ onInputCallback?: (input: string) => Promise<string>;
61
74
  onChunk?: (controlRef: React.RefObject<any>, lastContent: string, conversationHistory: MessageDetail[]) => any;
62
75
  onComplete?: (controlRef: React.RefObject<any>, lastContent: string, conversationHistory: MessageDetail[]) => any;
63
76
  };