funda-ui 4.7.565 → 4.7.570
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.js +14 -12
- package/Checkbox/index.d.ts +1 -1
- package/Checkbox/index.js +3 -3
- package/Date/index.js +73 -50
- package/Input/index.d.ts +23 -23
- package/Input/index.js +71 -45
- package/NumberInput/index.d.ts +1 -1
- package/Radio/index.d.ts +1 -1
- package/Radio/index.js +12 -6
- package/RangeSlider/index.js +71 -45
- package/Select/index.d.ts +1 -1
- package/Select/index.js +22 -0
- package/TagInput/index.d.ts +1 -1
- package/Textarea/index.d.ts +17 -17
- package/Textarea/index.js +14 -12
- package/lib/cjs/Chatbox/index.js +14 -12
- package/lib/cjs/Checkbox/index.d.ts +1 -1
- package/lib/cjs/Checkbox/index.js +3 -3
- package/lib/cjs/Date/index.js +73 -50
- package/lib/cjs/Input/index.d.ts +23 -23
- package/lib/cjs/Input/index.js +71 -45
- package/lib/cjs/NumberInput/index.d.ts +1 -1
- package/lib/cjs/Radio/index.d.ts +1 -1
- package/lib/cjs/Radio/index.js +12 -6
- package/lib/cjs/RangeSlider/index.js +71 -45
- package/lib/cjs/Select/index.d.ts +1 -1
- package/lib/cjs/Select/index.js +22 -0
- package/lib/cjs/TagInput/index.d.ts +1 -1
- package/lib/cjs/Textarea/index.d.ts +17 -17
- package/lib/cjs/Textarea/index.js +14 -12
- package/lib/esm/Chatbox/index.tsx +1 -1
- package/lib/esm/Checkbox/index.tsx +4 -4
- package/lib/esm/Date/index.tsx +2 -4
- package/lib/esm/Input/index.tsx +101 -83
- package/lib/esm/NumberInput/index.tsx +1 -1
- package/lib/esm/Radio/index.tsx +16 -8
- package/lib/esm/Select/index.tsx +34 -1
- package/lib/esm/TagInput/index.tsx +1 -1
- package/lib/esm/Textarea/index.tsx +75 -70
- package/package.json +1 -1
package/Textarea/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { ChangeEvent, KeyboardEvent, FocusEvent } from 'react';
|
|
2
2
|
export declare type TextareaProps = {
|
|
3
3
|
contentRef?: React.ForwardedRef<any>;
|
|
4
4
|
wrapperClassName?: string;
|
|
@@ -11,13 +11,13 @@ export declare type TextareaProps = {
|
|
|
11
11
|
requiredLabel?: React.ReactNode | string;
|
|
12
12
|
label?: React.ReactNode | string;
|
|
13
13
|
name?: string;
|
|
14
|
-
minLength?:
|
|
15
|
-
maxLength?:
|
|
14
|
+
minLength?: number;
|
|
15
|
+
maxLength?: number;
|
|
16
16
|
cols?: number;
|
|
17
17
|
rows?: number;
|
|
18
|
-
disabled?:
|
|
19
|
-
required?:
|
|
20
|
-
readOnly?:
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
required?: boolean;
|
|
20
|
+
readOnly?: boolean;
|
|
21
21
|
placeholder?: string;
|
|
22
22
|
autoSize?: boolean;
|
|
23
23
|
autoSizeMaxHeight?: number;
|
|
@@ -28,23 +28,23 @@ export declare type TextareaProps = {
|
|
|
28
28
|
aiPredictConfirmKey?: Array<string[]>;
|
|
29
29
|
aiPredictFetchFuncAsync?: any;
|
|
30
30
|
aiPredictFetchFuncMethod?: string;
|
|
31
|
-
aiPredictFetchFuncMethodParams?:
|
|
31
|
+
aiPredictFetchFuncMethodParams?: unknown[];
|
|
32
32
|
aiPredictFetchCallback?: (data: any) => void;
|
|
33
33
|
/** -- */
|
|
34
34
|
id?: string;
|
|
35
35
|
style?: React.CSSProperties;
|
|
36
36
|
tabIndex?: number;
|
|
37
37
|
[key: `data-${string}`]: string | undefined;
|
|
38
|
-
onChangeCallback?: (e:
|
|
39
|
-
onInputCallback?: (e:
|
|
40
|
-
onKeyPressedCallback?: (e:
|
|
41
|
-
onChange?: (e:
|
|
42
|
-
onBlur?: (e:
|
|
43
|
-
onFocus?: (e:
|
|
44
|
-
onPressEnter?: (e:
|
|
45
|
-
onKeyDown?: (e:
|
|
46
|
-
onKeyUp?: (e:
|
|
47
|
-
onResize?: (el:
|
|
38
|
+
onChangeCallback?: (e: ChangeEvent<HTMLTextAreaElement> | FocusEvent, el: HTMLTextAreaElement) => string | void;
|
|
39
|
+
onInputCallback?: (e: ChangeEvent<HTMLTextAreaElement> | KeyboardEvent<HTMLTextAreaElement>, el: HTMLTextAreaElement) => string | void;
|
|
40
|
+
onKeyPressedCallback?: (e: KeyboardEvent<HTMLTextAreaElement>, el: HTMLTextAreaElement) => string | void;
|
|
41
|
+
onChange?: (e: ChangeEvent<HTMLTextAreaElement> | KeyboardEvent<HTMLTextAreaElement> | null, el: HTMLTextAreaElement, value: string) => void;
|
|
42
|
+
onBlur?: (e: FocusEvent, el: HTMLTextAreaElement) => void;
|
|
43
|
+
onFocus?: (e: FocusEvent, el: HTMLTextAreaElement) => void;
|
|
44
|
+
onPressEnter?: (e: KeyboardEvent<HTMLTextAreaElement>, el: HTMLTextAreaElement) => void;
|
|
45
|
+
onKeyDown?: (e: KeyboardEvent<HTMLTextAreaElement>, el: HTMLTextAreaElement) => void;
|
|
46
|
+
onKeyUp?: (e: KeyboardEvent<HTMLTextAreaElement>, el: HTMLTextAreaElement) => void;
|
|
47
|
+
onResize?: (el: HTMLTextAreaElement, params: number[]) => void;
|
|
48
48
|
};
|
|
49
49
|
declare const Textarea: React.ForwardRefExoticComponent<TextareaProps & React.RefAttributes<unknown>>;
|
|
50
50
|
export default Textarea;
|
package/Textarea/index.js
CHANGED
|
@@ -1392,7 +1392,7 @@ var Textarea = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(fu
|
|
|
1392
1392
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1393
1393
|
while (1) switch (_context.prev = _context.next) {
|
|
1394
1394
|
case 0:
|
|
1395
|
-
if (!(_typeof(aiPredictFetchFuncAsync) === 'object')) {
|
|
1395
|
+
if (!(_typeof(aiPredictFetchFuncAsync) === 'object' && aiPredictFetchFuncMethod)) {
|
|
1396
1396
|
_context.next = 11;
|
|
1397
1397
|
break;
|
|
1398
1398
|
}
|
|
@@ -1429,8 +1429,10 @@ var Textarea = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(fu
|
|
|
1429
1429
|
if (valRef.current) {
|
|
1430
1430
|
var canvas = document.createElement('canvas');
|
|
1431
1431
|
var context = canvas.getContext('2d');
|
|
1432
|
-
|
|
1433
|
-
|
|
1432
|
+
if (context) {
|
|
1433
|
+
context.font = "".concat(originInputComputedStyle.current.fontSize, "px ").concat(originInputComputedStyle.current.fontFamily);
|
|
1434
|
+
return context.measureText(text).width;
|
|
1435
|
+
}
|
|
1434
1436
|
}
|
|
1435
1437
|
return 0;
|
|
1436
1438
|
};
|
|
@@ -1449,7 +1451,7 @@ var Textarea = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(fu
|
|
|
1449
1451
|
// Match exactly from the start
|
|
1450
1452
|
//----------------
|
|
1451
1453
|
var preciseMatch = function preciseMatch(input, suggestions) {
|
|
1452
|
-
if (!input) return
|
|
1454
|
+
if (!input) return [];
|
|
1453
1455
|
var filtered = suggestions.filter(function (s) {
|
|
1454
1456
|
return s.toLowerCase().startsWith(input.toLowerCase());
|
|
1455
1457
|
});
|
|
@@ -1460,7 +1462,7 @@ var Textarea = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(fu
|
|
|
1460
1462
|
// Fuzzy matching
|
|
1461
1463
|
//----------------
|
|
1462
1464
|
var fuzzyMatch = function fuzzyMatch(input, suggestions) {
|
|
1463
|
-
if (!input) return
|
|
1465
|
+
if (!input) return [];
|
|
1464
1466
|
|
|
1465
1467
|
// Convert input to a regular expression pattern with support for arbitrary position matching
|
|
1466
1468
|
var pattern = input.split('').map(function (_char) {
|
|
@@ -1580,7 +1582,7 @@ var Textarea = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(fu
|
|
|
1580
1582
|
onChange === null || onChange === void 0 ? void 0 : onChange(event, valRef.current, curVal);
|
|
1581
1583
|
|
|
1582
1584
|
// It fires in real time as the user enters
|
|
1583
|
-
if (typeof onInputCallback === 'function') {
|
|
1585
|
+
if (typeof onInputCallback === 'function' && event) {
|
|
1584
1586
|
var newData = onInputCallback(event, valRef.current);
|
|
1585
1587
|
if (newData) setChangedVal(newData); // Avoid the error "react checkbox changing an uncontrolled input to be controlled"
|
|
1586
1588
|
}
|
|
@@ -1588,7 +1590,7 @@ var Textarea = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(fu
|
|
|
1588
1590
|
|
|
1589
1591
|
function handleBlur(event) {
|
|
1590
1592
|
var el = event.target;
|
|
1591
|
-
var val =
|
|
1593
|
+
var val = el.value;
|
|
1592
1594
|
|
|
1593
1595
|
//----
|
|
1594
1596
|
//remove focus style
|
|
@@ -1743,8 +1745,8 @@ var Textarea = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(fu
|
|
|
1743
1745
|
placeholder: placeholder || '',
|
|
1744
1746
|
defaultValue: defaultValue,
|
|
1745
1747
|
value: changedVal,
|
|
1746
|
-
minLength: minLength ||
|
|
1747
|
-
maxLength: maxLength ||
|
|
1748
|
+
minLength: minLength || undefined,
|
|
1749
|
+
maxLength: maxLength || undefined,
|
|
1748
1750
|
onFocus: handleFocus,
|
|
1749
1751
|
onBlur: handleBlur,
|
|
1750
1752
|
onChange: function onChange(e) {
|
|
@@ -1757,9 +1759,9 @@ var Textarea = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(fu
|
|
|
1757
1759
|
},
|
|
1758
1760
|
onKeyDown: handleKeyPressed,
|
|
1759
1761
|
onKeyUp: handleKeyUp,
|
|
1760
|
-
disabled: disabled ||
|
|
1761
|
-
required: required ||
|
|
1762
|
-
readOnly: readOnly ||
|
|
1762
|
+
disabled: disabled || undefined,
|
|
1763
|
+
required: required || undefined,
|
|
1764
|
+
readOnly: readOnly || undefined,
|
|
1763
1765
|
cols: cols || 20,
|
|
1764
1766
|
rows: rows || 2,
|
|
1765
1767
|
style: style
|
package/lib/cjs/Chatbox/index.js
CHANGED
|
@@ -2120,7 +2120,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
2120
2120
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
2121
2121
|
while (1) switch (_context.prev = _context.next) {
|
|
2122
2122
|
case 0:
|
|
2123
|
-
if (!(_typeof(aiPredictFetchFuncAsync) === 'object')) {
|
|
2123
|
+
if (!(_typeof(aiPredictFetchFuncAsync) === 'object' && aiPredictFetchFuncMethod)) {
|
|
2124
2124
|
_context.next = 11;
|
|
2125
2125
|
break;
|
|
2126
2126
|
}
|
|
@@ -2157,8 +2157,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
2157
2157
|
if (valRef.current) {
|
|
2158
2158
|
var canvas = document.createElement('canvas');
|
|
2159
2159
|
var context = canvas.getContext('2d');
|
|
2160
|
-
|
|
2161
|
-
|
|
2160
|
+
if (context) {
|
|
2161
|
+
context.font = "".concat(originInputComputedStyle.current.fontSize, "px ").concat(originInputComputedStyle.current.fontFamily);
|
|
2162
|
+
return context.measureText(text).width;
|
|
2163
|
+
}
|
|
2162
2164
|
}
|
|
2163
2165
|
return 0;
|
|
2164
2166
|
};
|
|
@@ -2177,7 +2179,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
2177
2179
|
// Match exactly from the start
|
|
2178
2180
|
//----------------
|
|
2179
2181
|
var preciseMatch = function preciseMatch(input, suggestions) {
|
|
2180
|
-
if (!input) return
|
|
2182
|
+
if (!input) return [];
|
|
2181
2183
|
var filtered = suggestions.filter(function (s) {
|
|
2182
2184
|
return s.toLowerCase().startsWith(input.toLowerCase());
|
|
2183
2185
|
});
|
|
@@ -2188,7 +2190,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
2188
2190
|
// Fuzzy matching
|
|
2189
2191
|
//----------------
|
|
2190
2192
|
var fuzzyMatch = function fuzzyMatch(input, suggestions) {
|
|
2191
|
-
if (!input) return
|
|
2193
|
+
if (!input) return [];
|
|
2192
2194
|
|
|
2193
2195
|
// Convert input to a regular expression pattern with support for arbitrary position matching
|
|
2194
2196
|
var pattern = input.split('').map(function (_char) {
|
|
@@ -2308,7 +2310,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
2308
2310
|
onChange === null || onChange === void 0 ? void 0 : onChange(event, valRef.current, curVal);
|
|
2309
2311
|
|
|
2310
2312
|
// It fires in real time as the user enters
|
|
2311
|
-
if (typeof onInputCallback === 'function') {
|
|
2313
|
+
if (typeof onInputCallback === 'function' && event) {
|
|
2312
2314
|
var newData = onInputCallback(event, valRef.current);
|
|
2313
2315
|
if (newData) setChangedVal(newData); // Avoid the error "react checkbox changing an uncontrolled input to be controlled"
|
|
2314
2316
|
}
|
|
@@ -2316,7 +2318,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
2316
2318
|
|
|
2317
2319
|
function handleBlur(event) {
|
|
2318
2320
|
var el = event.target;
|
|
2319
|
-
var val =
|
|
2321
|
+
var val = el.value;
|
|
2320
2322
|
|
|
2321
2323
|
//----
|
|
2322
2324
|
//remove focus style
|
|
@@ -2471,8 +2473,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
2471
2473
|
placeholder: placeholder || '',
|
|
2472
2474
|
defaultValue: defaultValue,
|
|
2473
2475
|
value: changedVal,
|
|
2474
|
-
minLength: minLength ||
|
|
2475
|
-
maxLength: maxLength ||
|
|
2476
|
+
minLength: minLength || undefined,
|
|
2477
|
+
maxLength: maxLength || undefined,
|
|
2476
2478
|
onFocus: handleFocus,
|
|
2477
2479
|
onBlur: handleBlur,
|
|
2478
2480
|
onChange: function onChange(e) {
|
|
@@ -2485,9 +2487,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
2485
2487
|
},
|
|
2486
2488
|
onKeyDown: handleKeyPressed,
|
|
2487
2489
|
onKeyUp: handleKeyUp,
|
|
2488
|
-
disabled: disabled ||
|
|
2489
|
-
required: required ||
|
|
2490
|
-
readOnly: readOnly ||
|
|
2490
|
+
disabled: disabled || undefined,
|
|
2491
|
+
required: required || undefined,
|
|
2492
|
+
readOnly: readOnly || undefined,
|
|
2491
2493
|
cols: cols || 20,
|
|
2492
2494
|
rows: rows || 2,
|
|
2493
2495
|
style: style
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export declare type CheckboxOptionChangeFnType = (
|
|
2
|
+
export declare type CheckboxOptionChangeFnType = (e: React.ChangeEvent<HTMLInputElement> | null, val: boolean, element: HTMLElement) => void;
|
|
3
3
|
export declare type CheckboxProps = {
|
|
4
4
|
contentRef?: React.ForwardedRef<any>;
|
|
5
5
|
wrapperClassName?: string;
|
|
@@ -555,14 +555,14 @@ var Checkbox = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(fu
|
|
|
555
555
|
setVal(false);
|
|
556
556
|
cb === null || cb === void 0 ? void 0 : cb();
|
|
557
557
|
if (typeof onChange === 'function') {
|
|
558
|
-
onChange(null, false);
|
|
558
|
+
onChange(null, false, valRef.current);
|
|
559
559
|
}
|
|
560
560
|
},
|
|
561
561
|
set: function set(value, cb) {
|
|
562
562
|
setVal(value);
|
|
563
563
|
cb === null || cb === void 0 ? void 0 : cb();
|
|
564
564
|
if (typeof onChange === 'function') {
|
|
565
|
-
onChange(null, value);
|
|
565
|
+
onChange(null, value, valRef.current);
|
|
566
566
|
}
|
|
567
567
|
}
|
|
568
568
|
};
|
|
@@ -585,7 +585,7 @@ var Checkbox = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(fu
|
|
|
585
585
|
|
|
586
586
|
//
|
|
587
587
|
if (typeof onChange === 'function') {
|
|
588
|
-
onChange(event, _val);
|
|
588
|
+
onChange(event, _val, valRef.current);
|
|
589
589
|
}
|
|
590
590
|
}
|
|
591
591
|
function handleBlur(event) {
|
package/lib/cjs/Date/index.js
CHANGED
|
@@ -1598,14 +1598,17 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
1598
1598
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
1599
1599
|
hasErr = _useState12[0],
|
|
1600
1600
|
setHasErr = _useState12[1];
|
|
1601
|
-
var
|
|
1601
|
+
var _useState13 = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)(0),
|
|
1602
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
1603
|
+
currentSuggestionIndex = _useState14[0],
|
|
1604
|
+
setCurrentSuggestionIndex = _useState14[1];
|
|
1602
1605
|
|
|
1603
1606
|
// A list of suggestions
|
|
1604
1607
|
//----------------
|
|
1605
|
-
var
|
|
1606
|
-
|
|
1607
|
-
suggestions =
|
|
1608
|
-
setSuggestions =
|
|
1608
|
+
var _useState15 = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)([]),
|
|
1609
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
|
1610
|
+
suggestions = _useState16[0],
|
|
1611
|
+
setSuggestions = _useState16[1];
|
|
1609
1612
|
|
|
1610
1613
|
//performance
|
|
1611
1614
|
var handleChangeSuggestionsFetchSafe = funda_utils_dist_cjs_useDebounce__WEBPACK_IMPORTED_MODULE_4___default()(function (e, curVal) {
|
|
@@ -1623,12 +1626,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
1623
1626
|
//----------------
|
|
1624
1627
|
function _fetchSuggestionsData() {
|
|
1625
1628
|
_fetchSuggestionsData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) {
|
|
1626
|
-
var response, _ORGIN_DATA;
|
|
1629
|
+
var response, _ORGIN_DATA, suggestionsArray;
|
|
1627
1630
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1628
1631
|
while (1) switch (_context.prev = _context.next) {
|
|
1629
1632
|
case 0:
|
|
1630
1633
|
if (!(_typeof(aiPredictFetchFuncAsync) === 'object')) {
|
|
1631
|
-
_context.next =
|
|
1634
|
+
_context.next = 12;
|
|
1632
1635
|
break;
|
|
1633
1636
|
}
|
|
1634
1637
|
_context.next = 3;
|
|
@@ -1647,12 +1650,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
1647
1650
|
_ORGIN_DATA = [];
|
|
1648
1651
|
}
|
|
1649
1652
|
|
|
1650
|
-
//
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
return _context.abrupt("return", []);
|
|
1653
|
+
// Type assertion since we've verified it's an array
|
|
1654
|
+
suggestionsArray = _ORGIN_DATA; //
|
|
1655
|
+
setSuggestions(suggestionsArray);
|
|
1656
|
+
return _context.abrupt("return", suggestionsArray);
|
|
1655
1657
|
case 12:
|
|
1658
|
+
return _context.abrupt("return", []);
|
|
1659
|
+
case 13:
|
|
1656
1660
|
case "end":
|
|
1657
1661
|
return _context.stop();
|
|
1658
1662
|
}
|
|
@@ -1664,8 +1668,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
1664
1668
|
if (valRef.current) {
|
|
1665
1669
|
var canvas = document.createElement('canvas');
|
|
1666
1670
|
var context = canvas.getContext('2d');
|
|
1667
|
-
|
|
1668
|
-
|
|
1671
|
+
if (context) {
|
|
1672
|
+
context.font = "".concat(originInputComputedStyle.current.fontSize, "px ").concat(originInputComputedStyle.current.fontFamily);
|
|
1673
|
+
return context.measureText(text).width;
|
|
1674
|
+
}
|
|
1669
1675
|
}
|
|
1670
1676
|
return 0;
|
|
1671
1677
|
};
|
|
@@ -1761,12 +1767,16 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
1761
1767
|
clear: function clear(cb) {
|
|
1762
1768
|
setChangedVal('');
|
|
1763
1769
|
cb === null || cb === void 0 ? void 0 : cb();
|
|
1764
|
-
|
|
1770
|
+
if (valRef.current) {
|
|
1771
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(null, onComposition, valRef.current, '');
|
|
1772
|
+
}
|
|
1765
1773
|
},
|
|
1766
1774
|
set: function set(value, cb) {
|
|
1767
1775
|
setChangedVal("".concat(value));
|
|
1768
1776
|
cb === null || cb === void 0 ? void 0 : cb();
|
|
1769
|
-
|
|
1777
|
+
if (valRef.current) {
|
|
1778
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(null, onComposition, valRef.current, "".concat(value));
|
|
1779
|
+
}
|
|
1770
1780
|
},
|
|
1771
1781
|
aiPredictReset: function aiPredictReset() {
|
|
1772
1782
|
setTimeout(function () {
|
|
@@ -1792,7 +1802,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
1792
1802
|
(_rootRef$current = rootRef.current) === null || _rootRef$current === void 0 ? void 0 : _rootRef$current.classList.add('focus');
|
|
1793
1803
|
|
|
1794
1804
|
//
|
|
1795
|
-
|
|
1805
|
+
if (valRef.current) {
|
|
1806
|
+
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event, onComposition, valRef.current);
|
|
1807
|
+
}
|
|
1796
1808
|
}
|
|
1797
1809
|
function handleChange(event, curVal) {
|
|
1798
1810
|
setChangedVal(curVal);
|
|
@@ -1805,10 +1817,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
1805
1817
|
}
|
|
1806
1818
|
|
|
1807
1819
|
//
|
|
1808
|
-
|
|
1820
|
+
if (valRef.current) {
|
|
1821
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(event, onComposition, valRef.current, curVal);
|
|
1822
|
+
}
|
|
1809
1823
|
|
|
1810
1824
|
// It fires in real time as the user enters
|
|
1811
|
-
if (typeof onInputCallback === 'function') {
|
|
1825
|
+
if (typeof onInputCallback === 'function' && event && valRef.current) {
|
|
1812
1826
|
var newData = onInputCallback(event, valRef.current);
|
|
1813
1827
|
if (newData) setChangedVal(newData); // Avoid the error "react checkbox changing an uncontrolled input to be controlled"
|
|
1814
1828
|
}
|
|
@@ -1826,25 +1840,31 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
1826
1840
|
}
|
|
1827
1841
|
|
|
1828
1842
|
//
|
|
1829
|
-
|
|
1843
|
+
if (valRef.current) {
|
|
1844
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event, onComposition, valRef.current);
|
|
1845
|
+
}
|
|
1830
1846
|
|
|
1831
1847
|
// It fires when focus is lost
|
|
1832
|
-
if (typeof onChangeCallback === 'function') {
|
|
1848
|
+
if (typeof onChangeCallback === 'function' && valRef.current) {
|
|
1833
1849
|
var newData = onChangeCallback(event, valRef.current);
|
|
1834
1850
|
if (newData) setChangedVal(newData); // Avoid the error "react checkbox changing an uncontrolled input to be controlled"
|
|
1835
1851
|
}
|
|
1836
1852
|
}
|
|
1837
1853
|
|
|
1838
1854
|
function handleKeyPressed(event) {
|
|
1839
|
-
|
|
1840
|
-
|
|
1855
|
+
if (valRef.current) {
|
|
1856
|
+
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event, valRef.current);
|
|
1857
|
+
}
|
|
1858
|
+
if (typeof onKeyPressedCallback === 'function' && valRef.current) {
|
|
1841
1859
|
var newData = onKeyPressedCallback(event, valRef.current);
|
|
1842
1860
|
if (newData) setChangedVal(newData); // Avoid the error "react checkbox changing an uncontrolled input to be controlled"
|
|
1843
1861
|
}
|
|
1844
1862
|
|
|
1845
1863
|
if (event.key === 'Enter' || event.key === 'NumpadEnter') {
|
|
1846
1864
|
// DO NOT USE "preventDefault()"
|
|
1847
|
-
|
|
1865
|
+
if (valRef.current) {
|
|
1866
|
+
onPressEnter === null || onPressEnter === void 0 ? void 0 : onPressEnter(event, valRef.current);
|
|
1867
|
+
}
|
|
1848
1868
|
}
|
|
1849
1869
|
|
|
1850
1870
|
// AI Predict
|
|
@@ -1872,16 +1892,22 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
1872
1892
|
|
|
1873
1893
|
// switch result of suggestions
|
|
1874
1894
|
if (event.code === 'ArrowUp') {
|
|
1875
|
-
|
|
1895
|
+
setCurrentSuggestionIndex(function (prev) {
|
|
1896
|
+
return (prev - 1 + tempMatchedSuggestion.length) % tempMatchedSuggestion.length;
|
|
1897
|
+
});
|
|
1876
1898
|
}
|
|
1877
1899
|
if (event.code === 'ArrowDown') {
|
|
1878
|
-
|
|
1900
|
+
setCurrentSuggestionIndex(function (prev) {
|
|
1901
|
+
return (prev + 1) % tempMatchedSuggestion.length;
|
|
1902
|
+
});
|
|
1879
1903
|
}
|
|
1880
|
-
setCurrentSuggestion(tempMatchedSuggestion[currentSuggestionIndex
|
|
1904
|
+
setCurrentSuggestion(tempMatchedSuggestion[currentSuggestionIndex] || '');
|
|
1881
1905
|
}
|
|
1882
1906
|
}
|
|
1883
1907
|
function handleKeyUp(event) {
|
|
1884
|
-
|
|
1908
|
+
if (valRef.current) {
|
|
1909
|
+
onKeyUp === null || onKeyUp === void 0 ? void 0 : onKeyUp(event, valRef.current);
|
|
1910
|
+
}
|
|
1885
1911
|
}
|
|
1886
1912
|
(0, react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
|
|
1887
1913
|
// update default value
|
|
@@ -1948,18 +1974,18 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
1948
1974
|
}),
|
|
1949
1975
|
id: idRes,
|
|
1950
1976
|
name: name,
|
|
1951
|
-
step: step ||
|
|
1952
|
-
min: min ||
|
|
1953
|
-
max: max ||
|
|
1954
|
-
src: src ||
|
|
1955
|
-
size: size
|
|
1956
|
-
alt: alt ||
|
|
1977
|
+
step: step || undefined,
|
|
1978
|
+
min: min || undefined,
|
|
1979
|
+
max: max || undefined,
|
|
1980
|
+
src: src || undefined,
|
|
1981
|
+
size: typeof size === 'number' ? size : undefined,
|
|
1982
|
+
alt: alt || undefined,
|
|
1957
1983
|
inputMode: inputMode || undefined,
|
|
1958
|
-
pattern: pattern ||
|
|
1984
|
+
pattern: pattern || undefined,
|
|
1959
1985
|
placeholder: placeholder || '',
|
|
1960
1986
|
value: changedVal,
|
|
1961
|
-
minLength: minLength
|
|
1962
|
-
maxLength: maxLength
|
|
1987
|
+
minLength: typeof minLength === 'number' ? minLength : undefined,
|
|
1988
|
+
maxLength: typeof maxLength === 'number' ? maxLength : undefined,
|
|
1963
1989
|
autoComplete: typeof autoComplete === 'undefined' ? 'on' : autoComplete,
|
|
1964
1990
|
autoCapitalize: typeof autoCapitalize === 'undefined' ? 'off' : autoCapitalize,
|
|
1965
1991
|
spellCheck: typeof spellCheck === 'undefined' ? false : spellCheck,
|
|
@@ -1978,22 +2004,22 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
1978
2004
|
onCompositionStart: handleComposition,
|
|
1979
2005
|
onCompositionUpdate: handleComposition,
|
|
1980
2006
|
onCompositionEnd: handleComposition,
|
|
1981
|
-
disabled: disabled ||
|
|
1982
|
-
required: required ||
|
|
1983
|
-
readOnly: readOnly ||
|
|
2007
|
+
disabled: disabled || undefined,
|
|
2008
|
+
required: required || undefined,
|
|
2009
|
+
readOnly: readOnly || undefined,
|
|
1984
2010
|
style: style
|
|
1985
2011
|
}, attributes)), appendControl || '', aiPredict && remainingText && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
1986
2012
|
ref: aiInputRef,
|
|
1987
2013
|
className: "position-absolute z-1",
|
|
1988
2014
|
"data-ai": "predict",
|
|
1989
2015
|
style: {
|
|
1990
|
-
left: "".concat(originInputComputedStyle.current.fontSize + textWidth, "px"),
|
|
1991
|
-
top: originInputComputedStyle.current.textTop + 'px',
|
|
2016
|
+
left: "".concat((typeof originInputComputedStyle.current.fontSize === 'number' ? originInputComputedStyle.current.fontSize : 16) + textWidth, "px"),
|
|
2017
|
+
top: (typeof originInputComputedStyle.current.textTop === 'number' ? originInputComputedStyle.current.textTop : 10) + 'px',
|
|
1992
2018
|
color: "rgba(".concat(aiPredictRemainingTextRGB[0], ", ").concat(aiPredictRemainingTextRGB[1], ", ").concat(aiPredictRemainingTextRGB[2], ", ").concat(calculateOpacity(), ")"),
|
|
1993
2019
|
pointerEvents: 'none',
|
|
1994
|
-
fontSize: originInputComputedStyle.current.fontSize + 'px',
|
|
1995
|
-
fontFamily: originInputComputedStyle.current.fontFamily,
|
|
1996
|
-
letterSpacing: originInputComputedStyle.current.letterSpacing
|
|
2020
|
+
fontSize: (typeof originInputComputedStyle.current.fontSize === 'number' ? originInputComputedStyle.current.fontSize : 16) + 'px',
|
|
2021
|
+
fontFamily: typeof originInputComputedStyle.current.fontFamily === 'string' ? originInputComputedStyle.current.fontFamily : 'inherit',
|
|
2022
|
+
letterSpacing: typeof originInputComputedStyle.current.letterSpacing === 'string' ? originInputComputedStyle.current.letterSpacing : 'normal'
|
|
1997
2023
|
}
|
|
1998
2024
|
}, remainingText), required ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(react__WEBPACK_IMPORTED_MODULE_0___default().Fragment, null, requiredLabel || requiredLabel === '' ? requiredLabel : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", {
|
|
1999
2025
|
className: "position-absolute end-0 top-0 my-2 mx-2"
|
|
@@ -5405,11 +5431,8 @@ var src_Date = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_reac
|
|
|
5405
5431
|
//
|
|
5406
5432
|
onFocus === null || onFocus === void 0 ? void 0 : onFocus(inputRef.current, getAllSplittingInputs());
|
|
5407
5433
|
}
|
|
5408
|
-
function handleChange(
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
//
|
|
5412
|
-
_onChange === null || _onChange === void 0 ? void 0 : _onChange(inputRef.current, val, (0,cjs_date.isValidDate)(val), getAllSplittingInputs());
|
|
5434
|
+
function handleChange(e, isComposition, el, value) {
|
|
5435
|
+
_onChange === null || _onChange === void 0 ? void 0 : _onChange(inputRef.current, value, (0,cjs_date.isValidDate)(value), getAllSplittingInputs());
|
|
5413
5436
|
}
|
|
5414
5437
|
function handleBlur(event) {
|
|
5415
5438
|
var _rootRef$current3;
|
package/lib/cjs/Input/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { ChangeEvent, KeyboardEvent, FocusEvent } from 'react';
|
|
2
2
|
export declare type InputProps = {
|
|
3
3
|
contentRef?: React.ForwardedRef<any>;
|
|
4
4
|
wrapperClassName?: string;
|
|
@@ -13,20 +13,20 @@ export declare type InputProps = {
|
|
|
13
13
|
label?: React.ReactNode | string;
|
|
14
14
|
units?: React.ReactNode | string;
|
|
15
15
|
name?: string;
|
|
16
|
-
step?:
|
|
17
|
-
min?:
|
|
18
|
-
max?:
|
|
19
|
-
src?:
|
|
20
|
-
size?:
|
|
21
|
-
minLength?:
|
|
22
|
-
maxLength?:
|
|
23
|
-
alt?:
|
|
16
|
+
step?: string | number;
|
|
17
|
+
min?: string | number;
|
|
18
|
+
max?: string | number;
|
|
19
|
+
src?: string;
|
|
20
|
+
size?: string | number;
|
|
21
|
+
minLength?: string | number;
|
|
22
|
+
maxLength?: string | number;
|
|
23
|
+
alt?: string;
|
|
24
24
|
inputMode?: "search" | "text" | "email" | "tel" | "url" | "none" | "numeric" | "decimal" | undefined;
|
|
25
|
-
disabled?:
|
|
26
|
-
required?:
|
|
27
|
-
readOnly?:
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
required?: boolean;
|
|
27
|
+
readOnly?: boolean;
|
|
28
28
|
placeholder?: string;
|
|
29
|
-
pattern?:
|
|
29
|
+
pattern?: string;
|
|
30
30
|
iconLeft?: React.ReactNode | string;
|
|
31
31
|
iconRight?: React.ReactNode | string;
|
|
32
32
|
appendControl?: React.ReactNode;
|
|
@@ -35,7 +35,7 @@ export declare type InputProps = {
|
|
|
35
35
|
aiPredictConfirmKey?: Array<string[]>;
|
|
36
36
|
aiPredictFetchFuncAsync?: any;
|
|
37
37
|
aiPredictFetchFuncMethod?: string;
|
|
38
|
-
aiPredictFetchFuncMethodParams?:
|
|
38
|
+
aiPredictFetchFuncMethodParams?: (string | number)[];
|
|
39
39
|
aiPredictFetchCallback?: (data: any) => void;
|
|
40
40
|
/** -- */
|
|
41
41
|
id?: string;
|
|
@@ -45,15 +45,15 @@ export declare type InputProps = {
|
|
|
45
45
|
spellCheck?: boolean;
|
|
46
46
|
tabIndex?: number;
|
|
47
47
|
[key: `data-${string}`]: string | undefined;
|
|
48
|
-
onChangeCallback?: (e:
|
|
49
|
-
onInputCallback?: (e:
|
|
50
|
-
onKeyPressedCallback?: (e:
|
|
51
|
-
onChange?: (e:
|
|
52
|
-
onBlur?: (e:
|
|
53
|
-
onFocus?: (e:
|
|
54
|
-
onPressEnter?: (e:
|
|
55
|
-
onKeyDown?: (e:
|
|
56
|
-
onKeyUp?: (e:
|
|
48
|
+
onChangeCallback?: (e: ChangeEvent<HTMLInputElement> | FocusEvent<HTMLInputElement>, el: HTMLInputElement) => string | void;
|
|
49
|
+
onInputCallback?: (e: ChangeEvent<HTMLInputElement>, el: HTMLInputElement) => string | void;
|
|
50
|
+
onKeyPressedCallback?: (e: KeyboardEvent<HTMLInputElement>, el: HTMLInputElement) => string | void;
|
|
51
|
+
onChange?: (e: ChangeEvent<HTMLInputElement> | KeyboardEvent<HTMLInputElement> | null, isComposition: boolean, el: HTMLInputElement, value: string) => void;
|
|
52
|
+
onBlur?: (e: FocusEvent<HTMLInputElement>, param: boolean, el: HTMLInputElement) => void;
|
|
53
|
+
onFocus?: (e: FocusEvent<HTMLInputElement>, param: boolean, el: HTMLInputElement) => void;
|
|
54
|
+
onPressEnter?: (e: KeyboardEvent<HTMLInputElement>, el: HTMLInputElement) => void;
|
|
55
|
+
onKeyDown?: (e: KeyboardEvent<HTMLInputElement>, el: HTMLInputElement) => void;
|
|
56
|
+
onKeyUp?: (e: KeyboardEvent<HTMLInputElement>, el: HTMLInputElement) => void;
|
|
57
57
|
};
|
|
58
58
|
declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<unknown>>;
|
|
59
59
|
export default Input;
|