funda-ui 4.7.625 → 4.7.701
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/CascadingSelect/index.js +2 -2
- package/CascadingSelectE2E/index.js +2 -2
- package/Chatbox/index.js +3 -17
- package/Checkbox/index.js +3 -3
- package/ColorPicker/index.js +3 -18
- package/Date/index.js +3 -18
- package/EventCalendarTimeline/index.d.ts +1 -1
- package/EventCalendarTimeline/index.js +11 -1
- package/File/index.d.ts +9 -0
- package/File/index.js +245 -93
- package/Input/index.js +3 -18
- package/LiveSearch/index.js +3 -18
- package/NativeSelect/index.js +3 -3
- package/NumberInput/index.js +3 -18
- package/Popover/index.css +198 -0
- package/Popover/index.d.ts +4 -0
- package/Popover/index.js +1808 -0
- package/README.md +1 -0
- package/Radio/index.js +3 -3
- package/RangeSlider/index.js +3 -18
- package/SearchBar/index.js +3 -18
- package/Select/index.js +3 -2
- package/Switch/index.js +3 -3
- package/TagInput/index.css +31 -31
- package/TagInput/index.js +12 -23
- package/Textarea/index.js +3 -17
- package/Utils/useSSE.d.ts +9 -0
- package/Utils/useSSE.js +211 -0
- package/all.d.ts +1 -0
- package/all.js +1 -0
- package/lib/cjs/CascadingSelect/index.js +2 -2
- package/lib/cjs/CascadingSelectE2E/index.js +2 -2
- package/lib/cjs/Chatbox/index.js +3 -17
- package/lib/cjs/Checkbox/index.js +3 -3
- package/lib/cjs/ColorPicker/index.js +3 -18
- package/lib/cjs/Date/index.js +3 -18
- package/lib/cjs/EventCalendarTimeline/index.d.ts +1 -1
- package/lib/cjs/EventCalendarTimeline/index.js +11 -1
- package/lib/cjs/File/index.d.ts +9 -0
- package/lib/cjs/File/index.js +245 -93
- package/lib/cjs/Input/index.js +3 -18
- package/lib/cjs/LiveSearch/index.js +3 -18
- package/lib/cjs/NativeSelect/index.js +3 -3
- package/lib/cjs/NumberInput/index.js +3 -18
- package/lib/cjs/Popover/index.d.ts +4 -0
- package/lib/cjs/Popover/index.js +1808 -0
- package/lib/cjs/Radio/index.js +3 -3
- package/lib/cjs/RangeSlider/index.js +3 -18
- package/lib/cjs/SearchBar/index.js +3 -18
- package/lib/cjs/Select/index.js +3 -2
- package/lib/cjs/Switch/index.js +3 -3
- package/lib/cjs/TagInput/index.js +12 -23
- package/lib/cjs/Textarea/index.js +3 -17
- package/lib/cjs/Utils/useSSE.d.ts +9 -0
- package/lib/cjs/Utils/useSSE.js +211 -0
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +1 -0
- package/lib/css/Popover/index.css +198 -0
- package/lib/css/TagInput/index.css +31 -31
- package/lib/esm/CascadingSelect/index.tsx +2 -2
- package/lib/esm/CascadingSelectE2E/index.tsx +2 -2
- package/lib/esm/Checkbox/index.tsx +3 -3
- package/lib/esm/ColorPicker/index.tsx +4 -15
- package/lib/esm/EventCalendarTimeline/index.tsx +11 -2
- package/lib/esm/File/index.tsx +148 -23
- package/lib/esm/Input/index.tsx +6 -17
- package/lib/esm/NativeSelect/index.tsx +3 -3
- package/lib/esm/NumberInput/index.tsx +7 -15
- package/lib/esm/Popover/Popover.tsx +251 -0
- package/lib/esm/Popover/PopoverClose.tsx +51 -0
- package/lib/esm/Popover/PopoverContent.tsx +72 -0
- package/lib/esm/Popover/PopoverTrigger.tsx +62 -0
- package/lib/esm/Popover/index.scss +272 -0
- package/lib/esm/Popover/index.tsx +4 -0
- package/lib/esm/Radio/index.tsx +3 -3
- package/lib/esm/SearchBar/index.tsx +8 -12
- package/lib/esm/Select/index.tsx +2 -2
- package/lib/esm/Switch/index.tsx +3 -3
- package/lib/esm/TagInput/index.scss +24 -24
- package/lib/esm/TagInput/index.tsx +13 -20
- package/lib/esm/Textarea/index.tsx +6 -14
- package/lib/esm/Utils/hooks/useSSE.tsx +109 -0
- package/lib/esm/index.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -60,6 +60,7 @@ Here is a table of the components and their status.
|
|
|
60
60
|
| [Event Calendar Timeline ✅🔥](packages/EventCalendarTimeline/README.md) | | | | |
|
|
61
61
|
| [Chatbox ✅🔥🤖](packages/Chatbox/README.md) | | | | |
|
|
62
62
|
| [Stepper ✅](packages/Stepper/README.md) | | | | |
|
|
63
|
+
| [Popover ✅](packages/Popover/README.md) | | | | |
|
|
63
64
|
|
|
64
65
|
|
|
65
66
|
## Usage
|
package/Radio/index.js
CHANGED
|
@@ -1587,7 +1587,7 @@ var Radio = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(funct
|
|
|
1587
1587
|
}
|
|
1588
1588
|
function handleFocus(event) {
|
|
1589
1589
|
var _rootRef$current;
|
|
1590
|
-
(_rootRef$current = rootRef.current) === null || _rootRef$current === void 0 ? void 0 : _rootRef$current.classList.add('focus');
|
|
1590
|
+
(_rootRef$current = rootRef.current) === null || _rootRef$current === void 0 ? void 0 : _rootRef$current.classList.add('focus-floating');
|
|
1591
1591
|
|
|
1592
1592
|
//
|
|
1593
1593
|
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
|
|
@@ -1606,7 +1606,7 @@ var Radio = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(funct
|
|
|
1606
1606
|
|
|
1607
1607
|
//----
|
|
1608
1608
|
//remove focus style
|
|
1609
|
-
(_rootRef$current2 = rootRef.current) === null || _rootRef$current2 === void 0 ? void 0 : _rootRef$current2.classList.remove('focus');
|
|
1609
|
+
(_rootRef$current2 = rootRef.current) === null || _rootRef$current2 === void 0 ? void 0 : _rootRef$current2.classList.remove('focus-floating');
|
|
1610
1610
|
|
|
1611
1611
|
//
|
|
1612
1612
|
if (typeof onChange === 'function') {
|
|
@@ -1620,7 +1620,7 @@ var Radio = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(funct
|
|
|
1620
1620
|
var _rootRef$current3;
|
|
1621
1621
|
//----
|
|
1622
1622
|
//remove focus style
|
|
1623
|
-
(_rootRef$current3 = rootRef.current) === null || _rootRef$current3 === void 0 ? void 0 : _rootRef$current3.classList.remove('focus');
|
|
1623
|
+
(_rootRef$current3 = rootRef.current) === null || _rootRef$current3 === void 0 ? void 0 : _rootRef$current3.classList.remove('focus-floating');
|
|
1624
1624
|
|
|
1625
1625
|
//
|
|
1626
1626
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
package/RangeSlider/index.js
CHANGED
|
@@ -1764,9 +1764,6 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
1764
1764
|
}
|
|
1765
1765
|
}
|
|
1766
1766
|
function handleFocus(event) {
|
|
1767
|
-
var _rootRef$current;
|
|
1768
|
-
(_rootRef$current = rootRef.current) === null || _rootRef$current === void 0 ? void 0 : _rootRef$current.classList.add('focus');
|
|
1769
|
-
|
|
1770
1767
|
//
|
|
1771
1768
|
if (valRef.current) {
|
|
1772
1769
|
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event, onComposition, valRef.current);
|
|
@@ -1775,13 +1772,6 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
1775
1772
|
function handleChange(event, curVal) {
|
|
1776
1773
|
setChangedVal(curVal);
|
|
1777
1774
|
|
|
1778
|
-
//----
|
|
1779
|
-
//remove focus style
|
|
1780
|
-
if (curVal === '') {
|
|
1781
|
-
var _rootRef$current2;
|
|
1782
|
-
(_rootRef$current2 = rootRef.current) === null || _rootRef$current2 === void 0 ? void 0 : _rootRef$current2.classList.remove('focus');
|
|
1783
|
-
}
|
|
1784
|
-
|
|
1785
1775
|
//
|
|
1786
1776
|
if (valRef.current) {
|
|
1787
1777
|
onChange === null || onChange === void 0 ? void 0 : onChange(event, onComposition, valRef.current, curVal);
|
|
@@ -1798,13 +1788,6 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
1798
1788
|
var el = event.target;
|
|
1799
1789
|
var val = event.target.value;
|
|
1800
1790
|
|
|
1801
|
-
//----
|
|
1802
|
-
//remove focus style
|
|
1803
|
-
if (val === '') {
|
|
1804
|
-
var _rootRef$current3;
|
|
1805
|
-
(_rootRef$current3 = rootRef.current) === null || _rootRef$current3 === void 0 ? void 0 : _rootRef$current3.classList.remove('focus');
|
|
1806
|
-
}
|
|
1807
|
-
|
|
1808
1791
|
//
|
|
1809
1792
|
if (valRef.current) {
|
|
1810
1793
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event, onComposition, valRef.current);
|
|
@@ -1902,7 +1885,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
1902
1885
|
}
|
|
1903
1886
|
}, []);
|
|
1904
1887
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(react__WEBPACK_IMPORTED_MODULE_0___default().Fragment, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
1905
|
-
className: (0, funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_2__.clsWrite)(wrapperClassName, 'mb-3 position-relative'),
|
|
1888
|
+
className: (0, funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_2__.combinedCls)((0, funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_2__.clsWrite)(wrapperClassName, 'mb-3 position-relative'), {
|
|
1889
|
+
'focus-floating': changedVal !== ''
|
|
1890
|
+
}),
|
|
1906
1891
|
ref: rootRef
|
|
1907
1892
|
}, label ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(react__WEBPACK_IMPORTED_MODULE_0___default().Fragment, null, typeof label === 'string' ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("label", {
|
|
1908
1893
|
htmlFor: idRes,
|
package/SearchBar/index.js
CHANGED
|
@@ -573,9 +573,6 @@ var SearchBar = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(f
|
|
|
573
573
|
onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(event);
|
|
574
574
|
}
|
|
575
575
|
function handleFocus(event) {
|
|
576
|
-
var _rootRef$current;
|
|
577
|
-
(_rootRef$current = rootRef.current) === null || _rootRef$current === void 0 ? void 0 : _rootRef$current.classList.add('focus');
|
|
578
|
-
|
|
579
576
|
//
|
|
580
577
|
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event, onComposition);
|
|
581
578
|
}
|
|
@@ -583,13 +580,6 @@ var SearchBar = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(f
|
|
|
583
580
|
var val = event.target.value;
|
|
584
581
|
setChangedVal(val);
|
|
585
582
|
|
|
586
|
-
//----
|
|
587
|
-
//remove focus style
|
|
588
|
-
if (val === '') {
|
|
589
|
-
var _rootRef$current2;
|
|
590
|
-
(_rootRef$current2 = rootRef.current) === null || _rootRef$current2 === void 0 ? void 0 : _rootRef$current2.classList.remove('focus');
|
|
591
|
-
}
|
|
592
|
-
|
|
593
583
|
//
|
|
594
584
|
onChange === null || onChange === void 0 ? void 0 : onChange(event, onComposition);
|
|
595
585
|
}
|
|
@@ -597,13 +587,6 @@ var SearchBar = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(f
|
|
|
597
587
|
var el = event.target;
|
|
598
588
|
var val = event.target.value;
|
|
599
589
|
|
|
600
|
-
//----
|
|
601
|
-
//remove focus style
|
|
602
|
-
if (val === '') {
|
|
603
|
-
var _rootRef$current3;
|
|
604
|
-
(_rootRef$current3 = rootRef.current) === null || _rootRef$current3 === void 0 ? void 0 : _rootRef$current3.classList.remove('focus');
|
|
605
|
-
}
|
|
606
|
-
|
|
607
590
|
//
|
|
608
591
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event, onComposition);
|
|
609
592
|
}
|
|
@@ -624,7 +607,9 @@ var SearchBar = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(f
|
|
|
624
607
|
setChangedVal(value || '');
|
|
625
608
|
}, [value]);
|
|
626
609
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
627
|
-
className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_2__.clsWrite)(wrapperClassName, 'mb-3 position-relative'),
|
|
610
|
+
className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_2__.combinedCls)((0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_2__.clsWrite)(wrapperClassName, 'mb-3 position-relative'), {
|
|
611
|
+
'focus-floating': changedVal !== ''
|
|
612
|
+
}),
|
|
628
613
|
ref: rootRef
|
|
629
614
|
}, label ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, typeof label === 'string' ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("label", {
|
|
630
615
|
htmlFor: idRes,
|
package/Select/index.js
CHANGED
|
@@ -4975,12 +4975,13 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
4975
4975
|
filteredHeight = listContainerHeightLimit(filteredHeight);
|
|
4976
4976
|
if (parseFloat(oldHeight) > filteredHeight) {
|
|
4977
4977
|
listContentRef.current.style.height = filteredHeight + 'px';
|
|
4978
|
-
console.log('popwinContainerHeightAdjust - height changed to:', filteredHeight);
|
|
4978
|
+
// console.log('popwinContainerHeightAdjust - height changed to:', filteredHeight);
|
|
4979
4979
|
} else {
|
|
4980
4980
|
listContentRef.current.style.height = oldHeight + 'px';
|
|
4981
|
-
console.log('popwinContainerHeightAdjust - height kept as:', oldHeight);
|
|
4981
|
+
// console.log('popwinContainerHeightAdjust - height kept as:', oldHeight);
|
|
4982
4982
|
}
|
|
4983
4983
|
}
|
|
4984
|
+
|
|
4984
4985
|
function popwinNoMatchInit() {
|
|
4985
4986
|
if (listContentRef.current === null) return;
|
|
4986
4987
|
var _btnSelectAll = listContentRef.current.querySelector('.custom-select-multi__control-option-item--select-all');
|
package/Switch/index.js
CHANGED
|
@@ -540,7 +540,7 @@ var Switch = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(func
|
|
|
540
540
|
|
|
541
541
|
function handleFocus(event) {
|
|
542
542
|
var _rootRef$current;
|
|
543
|
-
(_rootRef$current = rootRef.current) === null || _rootRef$current === void 0 ? void 0 : _rootRef$current.classList.add('focus');
|
|
543
|
+
(_rootRef$current = rootRef.current) === null || _rootRef$current === void 0 ? void 0 : _rootRef$current.classList.add('focus-floating');
|
|
544
544
|
|
|
545
545
|
//
|
|
546
546
|
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
|
|
@@ -552,7 +552,7 @@ var Switch = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(func
|
|
|
552
552
|
|
|
553
553
|
//----
|
|
554
554
|
//remove focus style
|
|
555
|
-
(_rootRef$current2 = rootRef.current) === null || _rootRef$current2 === void 0 ? void 0 : _rootRef$current2.classList.remove('focus');
|
|
555
|
+
(_rootRef$current2 = rootRef.current) === null || _rootRef$current2 === void 0 ? void 0 : _rootRef$current2.classList.remove('focus-floating');
|
|
556
556
|
|
|
557
557
|
//
|
|
558
558
|
if (typeof onChange === 'function') {
|
|
@@ -563,7 +563,7 @@ var Switch = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(func
|
|
|
563
563
|
var _rootRef$current3;
|
|
564
564
|
//----
|
|
565
565
|
//remove focus style
|
|
566
|
-
(_rootRef$current3 = rootRef.current) === null || _rootRef$current3 === void 0 ? void 0 : _rootRef$current3.classList.remove('focus');
|
|
566
|
+
(_rootRef$current3 = rootRef.current) === null || _rootRef$current3 === void 0 ? void 0 : _rootRef$current3.classList.remove('focus-floating');
|
|
567
567
|
|
|
568
568
|
//
|
|
569
569
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
package/TagInput/index.css
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
1
|
/* ======================================================
|
|
2
2
|
<!-- Tag Input -->
|
|
3
3
|
/* ====================================================== */
|
|
4
|
-
.
|
|
5
|
-
--
|
|
6
|
-
--
|
|
7
|
-
--
|
|
8
|
-
--
|
|
9
|
-
--
|
|
10
|
-
--
|
|
11
|
-
--
|
|
12
|
-
--
|
|
13
|
-
--
|
|
4
|
+
.taginput__wrapper {
|
|
5
|
+
--taginput-control-border-radius: 0.375rem;
|
|
6
|
+
--taginput-control-wrapper-bg: #fff;
|
|
7
|
+
--taginput-control-wrapper-border-color: #dee2e6;
|
|
8
|
+
--taginput-control-color: #adb5bd;
|
|
9
|
+
--taginput-list-bg: #efefef;
|
|
10
|
+
--taginput-removebtn-fill: #000;
|
|
11
|
+
--taginput-removebtn-hover-fill: #f00;
|
|
12
|
+
--taginput-focus-border-color:#86b7fe;
|
|
13
|
+
--taginput-focus-box-shadow: 0 0 0 0.25rem rgba(13,110,253,.25);
|
|
14
14
|
display: flex;
|
|
15
15
|
}
|
|
16
|
-
.
|
|
17
|
-
.
|
|
16
|
+
.taginput__wrapper ul,
|
|
17
|
+
.taginput__wrapper li {
|
|
18
18
|
padding: 0;
|
|
19
19
|
margin: 0;
|
|
20
20
|
list-style: none;
|
|
21
21
|
}
|
|
22
|
-
.
|
|
22
|
+
.taginput__wrapper .taginput__control-wrapper {
|
|
23
23
|
display: flex;
|
|
24
24
|
}
|
|
25
|
-
.
|
|
25
|
+
.taginput__wrapper .taginput__control-wrapper > div {
|
|
26
26
|
position: relative;
|
|
27
27
|
align-items: center;
|
|
28
28
|
display: flex;
|
|
29
29
|
flex-wrap: wrap;
|
|
30
30
|
/* bootstrap style that match ".form-control" */
|
|
31
31
|
padding: 0.375rem;
|
|
32
|
-
background-color: var(--
|
|
32
|
+
background-color: var(--taginput-control-wrapper-bg);
|
|
33
33
|
background-clip: padding-box;
|
|
34
|
-
border: 1px solid var(--
|
|
34
|
+
border: 1px solid var(--taginput-control-wrapper-border-color);
|
|
35
35
|
appearance: none;
|
|
36
|
-
border-radius: var(--
|
|
36
|
+
border-radius: var(--taginput-control-border-radius);
|
|
37
37
|
transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
|
|
38
38
|
padding-bottom: 1px;
|
|
39
39
|
}
|
|
40
|
-
.
|
|
40
|
+
.taginput__wrapper .taginput__control-wrapper > div .taginput__control {
|
|
41
41
|
margin-bottom: 0.375rem;
|
|
42
42
|
}
|
|
43
|
-
.
|
|
43
|
+
.taginput__wrapper .taginput__control-wrapper > div .taginput__control input {
|
|
44
44
|
background: transparent;
|
|
45
45
|
border: none;
|
|
46
46
|
outline: none;
|
|
@@ -51,25 +51,25 @@
|
|
|
51
51
|
font-size: 0.875rem;
|
|
52
52
|
font-weight: 400;
|
|
53
53
|
line-height: 1.5;
|
|
54
|
-
color: var(--
|
|
54
|
+
color: var(--taginput-control-color);
|
|
55
55
|
}
|
|
56
|
-
.
|
|
56
|
+
.taginput__wrapper .taginput__control-wrapper > div .taginput__control input:focus {
|
|
57
57
|
outline: none;
|
|
58
58
|
box-shadow: none;
|
|
59
59
|
}
|
|
60
|
-
.
|
|
60
|
+
.taginput__wrapper ul.taginput__list li {
|
|
61
61
|
display: inline-block;
|
|
62
62
|
margin: 5px;
|
|
63
63
|
margin-bottom: 0;
|
|
64
64
|
padding: 0.1rem 1.5rem 0.1rem 1rem;
|
|
65
65
|
font-size: 0.875rem;
|
|
66
|
-
background: var(--
|
|
66
|
+
background: var(--taginput-list-bg);
|
|
67
67
|
border-radius: 30px;
|
|
68
68
|
overflow: hidden;
|
|
69
69
|
text-overflow: ellipsis;
|
|
70
70
|
position: relative;
|
|
71
71
|
}
|
|
72
|
-
.
|
|
72
|
+
.taginput__wrapper ul.taginput__list li > a {
|
|
73
73
|
font-weight: 400;
|
|
74
74
|
opacity: 0.6;
|
|
75
75
|
font-size: 18px;
|
|
@@ -79,13 +79,13 @@
|
|
|
79
79
|
top: 50%;
|
|
80
80
|
transform: translateY(-50%);
|
|
81
81
|
}
|
|
82
|
-
.
|
|
83
|
-
fill: var(--
|
|
82
|
+
.taginput__wrapper ul.taginput__list li > a path {
|
|
83
|
+
fill: var(--taginput-removebtn-fill);
|
|
84
84
|
}
|
|
85
|
-
.
|
|
86
|
-
fill: var(--
|
|
85
|
+
.taginput__wrapper ul.taginput__list li > a:hover path {
|
|
86
|
+
fill: var(--taginput-removebtn-hover-fill);
|
|
87
87
|
}
|
|
88
|
-
.
|
|
89
|
-
box-shadow: var(--
|
|
90
|
-
border-color: var(--
|
|
88
|
+
.taginput__wrapper.focus-floating .taginput__control-wrapper > div {
|
|
89
|
+
box-shadow: var(--taginput-focus-box-shadow);
|
|
90
|
+
border-color: var(--taginput-focus-border-color);
|
|
91
91
|
}
|
package/TagInput/index.js
CHANGED
|
@@ -1075,13 +1075,6 @@ var TagInput = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(fu
|
|
|
1075
1075
|
function handleChange(event) {
|
|
1076
1076
|
var val = event.target.value;
|
|
1077
1077
|
|
|
1078
|
-
//----
|
|
1079
|
-
//remove focus style
|
|
1080
|
-
if (val === '') {
|
|
1081
|
-
var _rootRef$current;
|
|
1082
|
-
(_rootRef$current = rootRef.current) === null || _rootRef$current === void 0 ? void 0 : _rootRef$current.classList.remove('focus');
|
|
1083
|
-
}
|
|
1084
|
-
|
|
1085
1078
|
//
|
|
1086
1079
|
var _alreadyInItems = alreadyInItems;
|
|
1087
1080
|
if (items && items.length > 0) {
|
|
@@ -1098,8 +1091,9 @@ var TagInput = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(fu
|
|
|
1098
1091
|
setUserInput(val);
|
|
1099
1092
|
}
|
|
1100
1093
|
function handleFocus(event) {
|
|
1101
|
-
var _rootRef$
|
|
1102
|
-
|
|
1094
|
+
var _rootRef$current;
|
|
1095
|
+
// tag style
|
|
1096
|
+
(_rootRef$current = rootRef.current) === null || _rootRef$current === void 0 ? void 0 : _rootRef$current.classList.add('focus-floating');
|
|
1103
1097
|
|
|
1104
1098
|
//
|
|
1105
1099
|
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
|
|
@@ -1107,15 +1101,8 @@ var TagInput = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(fu
|
|
|
1107
1101
|
function handleBlur(event) {
|
|
1108
1102
|
var el = event.target;
|
|
1109
1103
|
var val = event.target.value;
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
//remove focus style
|
|
1113
|
-
if (val === '') {
|
|
1114
|
-
var _rootRef$current3;
|
|
1115
|
-
(_rootRef$current3 = rootRef.current) === null || _rootRef$current3 === void 0 ? void 0 : _rootRef$current3.classList.remove('focus');
|
|
1116
|
-
}
|
|
1117
|
-
|
|
1118
|
-
//
|
|
1104
|
+
setUserInput('');
|
|
1105
|
+
setAlreadyInItems(false);
|
|
1119
1106
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
1120
1107
|
}
|
|
1121
1108
|
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
|
|
@@ -1124,7 +1111,9 @@ var TagInput = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(fu
|
|
|
1124
1111
|
initDefaultValue(value);
|
|
1125
1112
|
}, [value]);
|
|
1126
1113
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
1127
|
-
className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_4__.combinedCls)('
|
|
1114
|
+
className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_4__.combinedCls)('taginput__wrapper', (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_4__.clsWrite)(wrapperClassName, 'mb-3 position-relative'), {
|
|
1115
|
+
'focus-floating': userInput !== ''
|
|
1116
|
+
}),
|
|
1128
1117
|
ref: rootRef
|
|
1129
1118
|
}, label ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, typeof label === 'string' ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("label", {
|
|
1130
1119
|
htmlFor: "label-".concat(idRes),
|
|
@@ -1136,9 +1125,9 @@ var TagInput = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(fu
|
|
|
1136
1125
|
htmlFor: "label-".concat(idRes),
|
|
1137
1126
|
className: "form-label"
|
|
1138
1127
|
}, label)) : null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
1139
|
-
className: "
|
|
1128
|
+
className: "taginput__control-wrapper"
|
|
1140
1129
|
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("ul", {
|
|
1141
|
-
className: "
|
|
1130
|
+
className: "taginput__list"
|
|
1142
1131
|
}, 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) {
|
|
1143
1132
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("li", {
|
|
1144
1133
|
key: index
|
|
@@ -1156,7 +1145,7 @@ var TagInput = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(fu
|
|
|
1156
1145
|
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"
|
|
1157
1146
|
}))));
|
|
1158
1147
|
}) : null)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
1159
|
-
className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_4__.combinedCls)('
|
|
1148
|
+
className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_4__.combinedCls)('taginput__control', {
|
|
1160
1149
|
'disabled': disabled
|
|
1161
1150
|
}),
|
|
1162
1151
|
style: {
|
|
@@ -1171,7 +1160,7 @@ var TagInput = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(fu
|
|
|
1171
1160
|
// Don't use "name", it's just a container to display the label
|
|
1172
1161
|
,
|
|
1173
1162
|
"data-name": name !== null && name !== void 0 && name.match(/(\[.*?\])/gi) ? "".concat(name.split('[')[0], "-label[]") : "".concat(name, "-label"),
|
|
1174
|
-
"data-
|
|
1163
|
+
"data-taginput": true,
|
|
1175
1164
|
autoComplete: typeof autoComplete === 'undefined' ? 'off' : autoComplete,
|
|
1176
1165
|
autoCapitalize: typeof autoCapitalize === 'undefined' ? 'off' : autoCapitalize,
|
|
1177
1166
|
spellCheck: typeof spellCheck === 'undefined' ? false : spellCheck,
|
package/Textarea/index.js
CHANGED
|
@@ -1561,9 +1561,7 @@ var Textarea = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(fu
|
|
|
1561
1561
|
return typeof p !== 'undefined' && p !== null && p !== '';
|
|
1562
1562
|
};
|
|
1563
1563
|
function handleFocus(event) {
|
|
1564
|
-
var _rootRef$current;
|
|
1565
1564
|
var el = event.target;
|
|
1566
|
-
(_rootRef$current = rootRef.current) === null || _rootRef$current === void 0 ? void 0 : _rootRef$current.classList.add('focus');
|
|
1567
1565
|
|
|
1568
1566
|
//
|
|
1569
1567
|
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event, valRef.current);
|
|
@@ -1571,13 +1569,6 @@ var Textarea = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(fu
|
|
|
1571
1569
|
function handleChange(event, curVal) {
|
|
1572
1570
|
setChangedVal(curVal);
|
|
1573
1571
|
|
|
1574
|
-
//----
|
|
1575
|
-
//remove focus style
|
|
1576
|
-
if (curVal === '') {
|
|
1577
|
-
var _rootRef$current2;
|
|
1578
|
-
(_rootRef$current2 = rootRef.current) === null || _rootRef$current2 === void 0 ? void 0 : _rootRef$current2.classList.remove('focus');
|
|
1579
|
-
}
|
|
1580
|
-
|
|
1581
1572
|
//
|
|
1582
1573
|
onChange === null || onChange === void 0 ? void 0 : onChange(event, valRef.current, curVal);
|
|
1583
1574
|
|
|
@@ -1592,13 +1583,6 @@ var Textarea = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(fu
|
|
|
1592
1583
|
var el = event.target;
|
|
1593
1584
|
var val = el.value;
|
|
1594
1585
|
|
|
1595
|
-
//----
|
|
1596
|
-
//remove focus style
|
|
1597
|
-
if (val === '') {
|
|
1598
|
-
var _rootRef$current3;
|
|
1599
|
-
(_rootRef$current3 = rootRef.current) === null || _rootRef$current3 === void 0 ? void 0 : _rootRef$current3.classList.remove('focus');
|
|
1600
|
-
}
|
|
1601
|
-
|
|
1602
1586
|
//
|
|
1603
1587
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event, valRef.current);
|
|
1604
1588
|
|
|
@@ -1705,7 +1689,9 @@ var Textarea = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(fu
|
|
|
1705
1689
|
}
|
|
1706
1690
|
}, []);
|
|
1707
1691
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
1708
|
-
className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_3__.clsWrite)(wrapperClassName, 'mb-3 position-relative'),
|
|
1692
|
+
className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_3__.combinedCls)((0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_3__.clsWrite)(wrapperClassName, 'mb-3 position-relative'), {
|
|
1693
|
+
'focus-floating': changedVal !== ''
|
|
1694
|
+
}),
|
|
1709
1695
|
ref: rootRef
|
|
1710
1696
|
}, label ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, typeof label === 'string' ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("label", {
|
|
1711
1697
|
htmlFor: idRes,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare const useSSE: (url: string | null | undefined, retryDelay?: number) => {
|
|
2
|
+
readonly connected: boolean;
|
|
3
|
+
readonly messages: string[];
|
|
4
|
+
readonly disconnect: () => void;
|
|
5
|
+
readonly reconnect: () => void;
|
|
6
|
+
readonly resetMessages: () => void;
|
|
7
|
+
};
|
|
8
|
+
export default useSSE;
|
|
9
|
+
export { useSSE };
|
package/Utils/useSSE.js
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
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 */ "useSSE": () => (/* binding */ useSSE)
|
|
97
|
+
/* harmony export */ });
|
|
98
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(787);
|
|
99
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
100
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
101
|
+
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."); }
|
|
102
|
+
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); }
|
|
103
|
+
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; }
|
|
104
|
+
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; } }
|
|
105
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
106
|
+
/**
|
|
107
|
+
* SSE
|
|
108
|
+
*
|
|
109
|
+
* @usage:
|
|
110
|
+
*
|
|
111
|
+
* const App = () => {
|
|
112
|
+
* const { connected, messages, disconnect, reconnect } = useSSE('http://localhost:3000/sse');
|
|
113
|
+
*
|
|
114
|
+
* return (
|
|
115
|
+
* <div>
|
|
116
|
+
* <p>Status: {connected ? '✅ Connected' : '❌ Disconnected'}</p>
|
|
117
|
+
* <button onClick={disconnect}>Disconnect</button>
|
|
118
|
+
* <button onClick={reconnect}>Reconnect</button>
|
|
119
|
+
* {messages.map((m, i) => <div key={i}>{m}</div>)}
|
|
120
|
+
* </div>
|
|
121
|
+
* );
|
|
122
|
+
* };
|
|
123
|
+
*/
|
|
124
|
+
|
|
125
|
+
var useSSE = function useSSE(url) {
|
|
126
|
+
var retryDelay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 3000;
|
|
127
|
+
var _useState = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false),
|
|
128
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
129
|
+
connected = _useState2[0],
|
|
130
|
+
setConnected = _useState2[1];
|
|
131
|
+
var _useState3 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)([]),
|
|
132
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
133
|
+
messages = _useState4[0],
|
|
134
|
+
setMessages = _useState4[1];
|
|
135
|
+
var sourceRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);
|
|
136
|
+
var reconnectTimerRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);
|
|
137
|
+
var manuallyClosedRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(false);
|
|
138
|
+
var internalCleanup = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function () {
|
|
139
|
+
if (reconnectTimerRef.current) {
|
|
140
|
+
clearTimeout(reconnectTimerRef.current);
|
|
141
|
+
reconnectTimerRef.current = null;
|
|
142
|
+
}
|
|
143
|
+
if (sourceRef.current) {
|
|
144
|
+
try {
|
|
145
|
+
sourceRef.current.close();
|
|
146
|
+
} catch (_) {
|
|
147
|
+
// Ignore errors during cleanup
|
|
148
|
+
}
|
|
149
|
+
sourceRef.current = null;
|
|
150
|
+
}
|
|
151
|
+
setConnected(false);
|
|
152
|
+
}, []);
|
|
153
|
+
var connect = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function () {
|
|
154
|
+
if (!url || manuallyClosedRef.current) return;
|
|
155
|
+
|
|
156
|
+
// Prevent duplicate connections
|
|
157
|
+
if (sourceRef.current) return;
|
|
158
|
+
var source = new EventSource(url);
|
|
159
|
+
sourceRef.current = source;
|
|
160
|
+
source.onopen = function () {
|
|
161
|
+
setConnected(true);
|
|
162
|
+
};
|
|
163
|
+
source.onmessage = function (event) {
|
|
164
|
+
setMessages([event.data]);
|
|
165
|
+
};
|
|
166
|
+
source.onerror = function (err) {
|
|
167
|
+
internalCleanup();
|
|
168
|
+
if (!manuallyClosedRef.current) {
|
|
169
|
+
reconnectTimerRef.current = setTimeout(function () {
|
|
170
|
+
connect();
|
|
171
|
+
}, retryDelay);
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
}, [internalCleanup, retryDelay, url]);
|
|
175
|
+
var disconnect = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function () {
|
|
176
|
+
manuallyClosedRef.current = true;
|
|
177
|
+
internalCleanup();
|
|
178
|
+
}, [internalCleanup]);
|
|
179
|
+
var reconnect = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function () {
|
|
180
|
+
manuallyClosedRef.current = false;
|
|
181
|
+
internalCleanup();
|
|
182
|
+
connect();
|
|
183
|
+
}, [connect, internalCleanup]);
|
|
184
|
+
var resetMessages = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function () {
|
|
185
|
+
return setMessages([]);
|
|
186
|
+
}, []);
|
|
187
|
+
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
|
|
188
|
+
if (!url) return;
|
|
189
|
+
manuallyClosedRef.current = false;
|
|
190
|
+
connect();
|
|
191
|
+
return function () {
|
|
192
|
+
// Cleanup on unmount (does not mark manual close)
|
|
193
|
+
internalCleanup();
|
|
194
|
+
};
|
|
195
|
+
}, [url, connect, internalCleanup]);
|
|
196
|
+
return {
|
|
197
|
+
connected: connected,
|
|
198
|
+
messages: messages,
|
|
199
|
+
disconnect: disconnect,
|
|
200
|
+
reconnect: reconnect,
|
|
201
|
+
resetMessages: resetMessages
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (useSSE);
|
|
205
|
+
|
|
206
|
+
})();
|
|
207
|
+
|
|
208
|
+
/******/ return __webpack_exports__;
|
|
209
|
+
/******/ })()
|
|
210
|
+
;
|
|
211
|
+
});
|