funda-ui 4.7.565 → 4.7.582

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.
Files changed (47) hide show
  1. package/Chatbox/index.js +14 -12
  2. package/Checkbox/index.d.ts +1 -1
  3. package/Checkbox/index.js +3 -3
  4. package/Date/index.js +73 -50
  5. package/EventCalendar/index.js +3 -2
  6. package/EventCalendarTimeline/index.js +6 -4
  7. package/Input/index.d.ts +23 -23
  8. package/Input/index.js +71 -45
  9. package/NumberInput/index.d.ts +4 -4
  10. package/Radio/index.d.ts +1 -1
  11. package/Radio/index.js +12 -6
  12. package/RangeSlider/index.js +71 -45
  13. package/Select/index.d.ts +1 -1
  14. package/Select/index.js +22 -0
  15. package/TagInput/index.d.ts +1 -1
  16. package/Textarea/index.d.ts +17 -17
  17. package/Textarea/index.js +14 -12
  18. package/lib/cjs/Chatbox/index.js +14 -12
  19. package/lib/cjs/Checkbox/index.d.ts +1 -1
  20. package/lib/cjs/Checkbox/index.js +3 -3
  21. package/lib/cjs/Date/index.js +73 -50
  22. package/lib/cjs/EventCalendar/index.js +3 -2
  23. package/lib/cjs/EventCalendarTimeline/index.js +6 -4
  24. package/lib/cjs/Input/index.d.ts +23 -23
  25. package/lib/cjs/Input/index.js +71 -45
  26. package/lib/cjs/NumberInput/index.d.ts +4 -4
  27. package/lib/cjs/Radio/index.d.ts +1 -1
  28. package/lib/cjs/Radio/index.js +12 -6
  29. package/lib/cjs/RangeSlider/index.js +71 -45
  30. package/lib/cjs/Select/index.d.ts +1 -1
  31. package/lib/cjs/Select/index.js +22 -0
  32. package/lib/cjs/TagInput/index.d.ts +1 -1
  33. package/lib/cjs/Textarea/index.d.ts +17 -17
  34. package/lib/cjs/Textarea/index.js +14 -12
  35. package/lib/esm/Chatbox/index.tsx +1 -1
  36. package/lib/esm/Checkbox/index.tsx +4 -4
  37. package/lib/esm/Date/index.tsx +2 -4
  38. package/lib/esm/EventCalendar/index.tsx +2 -2
  39. package/lib/esm/EventCalendarTimeline/index.tsx +6 -4
  40. package/lib/esm/Input/index.tsx +101 -83
  41. package/lib/esm/ModalDialog/index.tsx +1 -0
  42. package/lib/esm/NumberInput/index.tsx +7 -3
  43. package/lib/esm/Radio/index.tsx +16 -8
  44. package/lib/esm/Select/index.tsx +34 -1
  45. package/lib/esm/TagInput/index.tsx +1 -1
  46. package/lib/esm/Textarea/index.tsx +75 -70
  47. package/package.json +1 -1
package/Input/index.js CHANGED
@@ -1044,14 +1044,17 @@ var Input = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(funct
1044
1044
  _useState12 = _slicedToArray(_useState11, 2),
1045
1045
  hasErr = _useState12[0],
1046
1046
  setHasErr = _useState12[1];
1047
- var currentSuggestionIndex = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(0);
1047
+ var _useState13 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(0),
1048
+ _useState14 = _slicedToArray(_useState13, 2),
1049
+ currentSuggestionIndex = _useState14[0],
1050
+ setCurrentSuggestionIndex = _useState14[1];
1048
1051
 
1049
1052
  // A list of suggestions
1050
1053
  //----------------
1051
- var _useState13 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)([]),
1052
- _useState14 = _slicedToArray(_useState13, 2),
1053
- suggestions = _useState14[0],
1054
- setSuggestions = _useState14[1];
1054
+ var _useState15 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)([]),
1055
+ _useState16 = _slicedToArray(_useState15, 2),
1056
+ suggestions = _useState16[0],
1057
+ setSuggestions = _useState16[1];
1055
1058
 
1056
1059
  //performance
1057
1060
  var handleChangeSuggestionsFetchSafe = funda_utils_dist_cjs_useDebounce__WEBPACK_IMPORTED_MODULE_4___default()(function (e, curVal) {
@@ -1069,12 +1072,12 @@ var Input = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(funct
1069
1072
  //----------------
1070
1073
  function _fetchSuggestionsData() {
1071
1074
  _fetchSuggestionsData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) {
1072
- var response, _ORGIN_DATA;
1075
+ var response, _ORGIN_DATA, suggestionsArray;
1073
1076
  return _regeneratorRuntime().wrap(function _callee$(_context) {
1074
1077
  while (1) switch (_context.prev = _context.next) {
1075
1078
  case 0:
1076
1079
  if (!(_typeof(aiPredictFetchFuncAsync) === 'object')) {
1077
- _context.next = 11;
1080
+ _context.next = 12;
1078
1081
  break;
1079
1082
  }
1080
1083
  _context.next = 3;
@@ -1093,12 +1096,13 @@ var Input = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(funct
1093
1096
  _ORGIN_DATA = [];
1094
1097
  }
1095
1098
 
1096
- //
1097
- setSuggestions(_ORGIN_DATA);
1098
- return _context.abrupt("return", _ORGIN_DATA);
1099
- case 11:
1100
- return _context.abrupt("return", []);
1099
+ // Type assertion since we've verified it's an array
1100
+ suggestionsArray = _ORGIN_DATA; //
1101
+ setSuggestions(suggestionsArray);
1102
+ return _context.abrupt("return", suggestionsArray);
1101
1103
  case 12:
1104
+ return _context.abrupt("return", []);
1105
+ case 13:
1102
1106
  case "end":
1103
1107
  return _context.stop();
1104
1108
  }
@@ -1110,8 +1114,10 @@ var Input = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(funct
1110
1114
  if (valRef.current) {
1111
1115
  var canvas = document.createElement('canvas');
1112
1116
  var context = canvas.getContext('2d');
1113
- context.font = "".concat(originInputComputedStyle.current.fontSize, "px ").concat(originInputComputedStyle.current.fontFamily);
1114
- return context.measureText(text).width;
1117
+ if (context) {
1118
+ context.font = "".concat(originInputComputedStyle.current.fontSize, "px ").concat(originInputComputedStyle.current.fontFamily);
1119
+ return context.measureText(text).width;
1120
+ }
1115
1121
  }
1116
1122
  return 0;
1117
1123
  };
@@ -1207,12 +1213,16 @@ var Input = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(funct
1207
1213
  clear: function clear(cb) {
1208
1214
  setChangedVal('');
1209
1215
  cb === null || cb === void 0 ? void 0 : cb();
1210
- onChange === null || onChange === void 0 ? void 0 : onChange(null, onComposition, valRef.current, '');
1216
+ if (valRef.current) {
1217
+ onChange === null || onChange === void 0 ? void 0 : onChange(null, onComposition, valRef.current, '');
1218
+ }
1211
1219
  },
1212
1220
  set: function set(value, cb) {
1213
1221
  setChangedVal("".concat(value));
1214
1222
  cb === null || cb === void 0 ? void 0 : cb();
1215
- onChange === null || onChange === void 0 ? void 0 : onChange(null, onComposition, valRef.current, "".concat(value));
1223
+ if (valRef.current) {
1224
+ onChange === null || onChange === void 0 ? void 0 : onChange(null, onComposition, valRef.current, "".concat(value));
1225
+ }
1216
1226
  },
1217
1227
  aiPredictReset: function aiPredictReset() {
1218
1228
  setTimeout(function () {
@@ -1238,7 +1248,9 @@ var Input = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(funct
1238
1248
  (_rootRef$current = rootRef.current) === null || _rootRef$current === void 0 ? void 0 : _rootRef$current.classList.add('focus');
1239
1249
 
1240
1250
  //
1241
- onFocus === null || onFocus === void 0 ? void 0 : onFocus(event, onComposition, valRef.current);
1251
+ if (valRef.current) {
1252
+ onFocus === null || onFocus === void 0 ? void 0 : onFocus(event, onComposition, valRef.current);
1253
+ }
1242
1254
  }
1243
1255
  function handleChange(event, curVal) {
1244
1256
  setChangedVal(curVal);
@@ -1251,10 +1263,12 @@ var Input = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(funct
1251
1263
  }
1252
1264
 
1253
1265
  //
1254
- onChange === null || onChange === void 0 ? void 0 : onChange(event, onComposition, valRef.current, curVal);
1266
+ if (valRef.current) {
1267
+ onChange === null || onChange === void 0 ? void 0 : onChange(event, onComposition, valRef.current, curVal);
1268
+ }
1255
1269
 
1256
1270
  // It fires in real time as the user enters
1257
- if (typeof onInputCallback === 'function') {
1271
+ if (typeof onInputCallback === 'function' && event && valRef.current) {
1258
1272
  var newData = onInputCallback(event, valRef.current);
1259
1273
  if (newData) setChangedVal(newData); // Avoid the error "react checkbox changing an uncontrolled input to be controlled"
1260
1274
  }
@@ -1272,25 +1286,31 @@ var Input = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(funct
1272
1286
  }
1273
1287
 
1274
1288
  //
1275
- onBlur === null || onBlur === void 0 ? void 0 : onBlur(event, onComposition, valRef.current);
1289
+ if (valRef.current) {
1290
+ onBlur === null || onBlur === void 0 ? void 0 : onBlur(event, onComposition, valRef.current);
1291
+ }
1276
1292
 
1277
1293
  // It fires when focus is lost
1278
- if (typeof onChangeCallback === 'function') {
1294
+ if (typeof onChangeCallback === 'function' && valRef.current) {
1279
1295
  var newData = onChangeCallback(event, valRef.current);
1280
1296
  if (newData) setChangedVal(newData); // Avoid the error "react checkbox changing an uncontrolled input to be controlled"
1281
1297
  }
1282
1298
  }
1283
1299
 
1284
1300
  function handleKeyPressed(event) {
1285
- onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event, valRef.current);
1286
- if (typeof onKeyPressedCallback === 'function') {
1301
+ if (valRef.current) {
1302
+ onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event, valRef.current);
1303
+ }
1304
+ if (typeof onKeyPressedCallback === 'function' && valRef.current) {
1287
1305
  var newData = onKeyPressedCallback(event, valRef.current);
1288
1306
  if (newData) setChangedVal(newData); // Avoid the error "react checkbox changing an uncontrolled input to be controlled"
1289
1307
  }
1290
1308
 
1291
1309
  if (event.key === 'Enter' || event.key === 'NumpadEnter') {
1292
1310
  // DO NOT USE "preventDefault()"
1293
- onPressEnter === null || onPressEnter === void 0 ? void 0 : onPressEnter(event, valRef.current);
1311
+ if (valRef.current) {
1312
+ onPressEnter === null || onPressEnter === void 0 ? void 0 : onPressEnter(event, valRef.current);
1313
+ }
1294
1314
  }
1295
1315
 
1296
1316
  // AI Predict
@@ -1318,16 +1338,22 @@ var Input = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(funct
1318
1338
 
1319
1339
  // switch result of suggestions
1320
1340
  if (event.code === 'ArrowUp') {
1321
- currentSuggestionIndex.current = (currentSuggestionIndex.current - 1 + tempMatchedSuggestion.length) % tempMatchedSuggestion.length;
1341
+ setCurrentSuggestionIndex(function (prev) {
1342
+ return (prev - 1 + tempMatchedSuggestion.length) % tempMatchedSuggestion.length;
1343
+ });
1322
1344
  }
1323
1345
  if (event.code === 'ArrowDown') {
1324
- currentSuggestionIndex.current = (currentSuggestionIndex.current + 1) % tempMatchedSuggestion.length;
1346
+ setCurrentSuggestionIndex(function (prev) {
1347
+ return (prev + 1) % tempMatchedSuggestion.length;
1348
+ });
1325
1349
  }
1326
- setCurrentSuggestion(tempMatchedSuggestion[currentSuggestionIndex.current] || '');
1350
+ setCurrentSuggestion(tempMatchedSuggestion[currentSuggestionIndex] || '');
1327
1351
  }
1328
1352
  }
1329
1353
  function handleKeyUp(event) {
1330
- onKeyUp === null || onKeyUp === void 0 ? void 0 : onKeyUp(event, valRef.current);
1354
+ if (valRef.current) {
1355
+ onKeyUp === null || onKeyUp === void 0 ? void 0 : onKeyUp(event, valRef.current);
1356
+ }
1331
1357
  }
1332
1358
  (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
1333
1359
  // update default value
@@ -1394,18 +1420,18 @@ var Input = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(funct
1394
1420
  }),
1395
1421
  id: idRes,
1396
1422
  name: name,
1397
- step: step || null,
1398
- min: min || null,
1399
- max: max || null,
1400
- src: src || null,
1401
- size: size || null,
1402
- alt: alt || null,
1423
+ step: step || undefined,
1424
+ min: min || undefined,
1425
+ max: max || undefined,
1426
+ src: src || undefined,
1427
+ size: typeof size === 'number' ? size : undefined,
1428
+ alt: alt || undefined,
1403
1429
  inputMode: inputMode || undefined,
1404
- pattern: pattern || null,
1430
+ pattern: pattern || undefined,
1405
1431
  placeholder: placeholder || '',
1406
1432
  value: changedVal,
1407
- minLength: minLength || null,
1408
- maxLength: maxLength || null,
1433
+ minLength: typeof minLength === 'number' ? minLength : undefined,
1434
+ maxLength: typeof maxLength === 'number' ? maxLength : undefined,
1409
1435
  autoComplete: typeof autoComplete === 'undefined' ? 'on' : autoComplete,
1410
1436
  autoCapitalize: typeof autoCapitalize === 'undefined' ? 'off' : autoCapitalize,
1411
1437
  spellCheck: typeof spellCheck === 'undefined' ? false : spellCheck,
@@ -1424,22 +1450,22 @@ var Input = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(funct
1424
1450
  onCompositionStart: handleComposition,
1425
1451
  onCompositionUpdate: handleComposition,
1426
1452
  onCompositionEnd: handleComposition,
1427
- disabled: disabled || null,
1428
- required: required || null,
1429
- readOnly: readOnly || null,
1453
+ disabled: disabled || undefined,
1454
+ required: required || undefined,
1455
+ readOnly: readOnly || undefined,
1430
1456
  style: style
1431
1457
  }, attributes)), appendControl || '', aiPredict && remainingText && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
1432
1458
  ref: aiInputRef,
1433
1459
  className: "position-absolute z-1",
1434
1460
  "data-ai": "predict",
1435
1461
  style: {
1436
- left: "".concat(originInputComputedStyle.current.fontSize + textWidth, "px"),
1437
- top: originInputComputedStyle.current.textTop + 'px',
1462
+ left: "".concat((typeof originInputComputedStyle.current.fontSize === 'number' ? originInputComputedStyle.current.fontSize : 16) + textWidth, "px"),
1463
+ top: (typeof originInputComputedStyle.current.textTop === 'number' ? originInputComputedStyle.current.textTop : 10) + 'px',
1438
1464
  color: "rgba(".concat(aiPredictRemainingTextRGB[0], ", ").concat(aiPredictRemainingTextRGB[1], ", ").concat(aiPredictRemainingTextRGB[2], ", ").concat(calculateOpacity(), ")"),
1439
1465
  pointerEvents: 'none',
1440
- fontSize: originInputComputedStyle.current.fontSize + 'px',
1441
- fontFamily: originInputComputedStyle.current.fontFamily,
1442
- letterSpacing: originInputComputedStyle.current.letterSpacing
1466
+ fontSize: (typeof originInputComputedStyle.current.fontSize === 'number' ? originInputComputedStyle.current.fontSize : 16) + 'px',
1467
+ fontFamily: typeof originInputComputedStyle.current.fontFamily === 'string' ? originInputComputedStyle.current.fontFamily : 'inherit',
1468
+ letterSpacing: typeof originInputComputedStyle.current.letterSpacing === 'string' ? originInputComputedStyle.current.letterSpacing : 'normal'
1443
1469
  }
1444
1470
  }, 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", {
1445
1471
  className: "position-absolute end-0 top-0 my-2 mx-2"
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { ChangeEvent, FocusEvent } from 'react';
2
2
  export declare type NumberInputProps = {
3
3
  contentRef?: React.ForwardedRef<any>;
4
4
  wrapperClassName?: string;
@@ -32,9 +32,9 @@ export declare type NumberInputProps = {
32
32
  style?: React.CSSProperties;
33
33
  tabIndex?: number;
34
34
  [key: `data-${string}`]: string | undefined;
35
- onChange?: (e: any, el: any, val: number) => void;
36
- onBlur?: (e: any, el: any) => void;
37
- onFocus?: (e: any, el: any) => void;
35
+ onChange?: (e: ChangeEvent<HTMLInputElement> | React.MouseEvent<HTMLButtonElement> | null, el: HTMLInputElement | null, val: number) => void;
36
+ onBlur?: (e: FocusEvent<HTMLInputElement>, el: HTMLInputElement | null) => void;
37
+ onFocus?: (e: FocusEvent<HTMLInputElement>, el: HTMLInputElement | null) => void;
38
38
  };
39
39
  declare const NumberInput: React.ForwardRefExoticComponent<NumberInputProps & React.RefAttributes<unknown>>;
40
40
  export default NumberInput;
package/Radio/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  export interface OptionConfig {
3
3
  [propName: string]: string | number | React.ReactNode | boolean;
4
4
  }
5
- export declare type RadioOptionChangeFnType = (arg1: any, arg2: any, arg3?: any, arg4?: any) => void;
5
+ export declare type RadioOptionChangeFnType = (e: React.ChangeEvent<HTMLInputElement> | null, val: string, currentData: OptionConfig | null, currentIndex: string | number | null, element: HTMLElement) => void;
6
6
  export declare type RadioProps = {
7
7
  contentRef?: React.ForwardedRef<any>;
8
8
  wrapperClassName?: string;
package/Radio/index.js CHANGED
@@ -1037,10 +1037,13 @@ var Radio = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(funct
1037
1037
  var curData = optionsFlat(dataInit).find(function (v) {
1038
1038
  return v.value == value;
1039
1039
  });
1040
- var currentIndex = optionsFlat(dataInit).findIndex(function (v) {
1040
+ var _currentIndex = optionsFlat(dataInit).findIndex(function (v) {
1041
1041
  return v.value == value;
1042
1042
  });
1043
- onChange(null, '', null, null);
1043
+ var targetInput = getAllControls().find(function (input) {
1044
+ return input.checked;
1045
+ });
1046
+ onChange(null, '', null, null, typeof targetInput !== 'undefined' ? targetInput : getAllControls()[0]);
1044
1047
  }
1045
1048
  },
1046
1049
  set: function set(value, cb) {
@@ -1050,10 +1053,13 @@ var Radio = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(funct
1050
1053
  var curData = optionsFlat(dataInit).find(function (v) {
1051
1054
  return v.value == value;
1052
1055
  });
1053
- var currentIndex = optionsFlat(dataInit).findIndex(function (v) {
1056
+ var _currentIndex2 = optionsFlat(dataInit).findIndex(function (v) {
1054
1057
  return v.value == value;
1055
1058
  });
1056
- onChange(null, "".concat(value), curData, currentIndex);
1059
+ var targetInput = getAllControls().find(function (input) {
1060
+ return input.value === value;
1061
+ });
1062
+ onChange(null, "".concat(value), curData, _currentIndex2, typeof targetInput !== 'undefined' ? targetInput : getAllControls()[0]);
1057
1063
  }
1058
1064
  }
1059
1065
  };
@@ -1234,10 +1240,10 @@ var Radio = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(funct
1234
1240
 
1235
1241
  //
1236
1242
  if (typeof onChange === 'function') {
1237
- onChange(event, val, curData, currentIndex);
1243
+ onChange(event, val, curData, currentIndex, event.target);
1238
1244
  }
1239
1245
  if (typeof onClick === 'function') {
1240
- onClick(event, val, curData, currentIndex);
1246
+ onClick(event, val, curData, currentIndex, event.target);
1241
1247
  }
1242
1248
  }
1243
1249
  function handleBlur(event) {
@@ -1564,14 +1564,17 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
1564
1564
  _useState12 = _slicedToArray(_useState11, 2),
1565
1565
  hasErr = _useState12[0],
1566
1566
  setHasErr = _useState12[1];
1567
- var currentSuggestionIndex = (0, react__WEBPACK_IMPORTED_MODULE_0__.useRef)(0);
1567
+ var _useState13 = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)(0),
1568
+ _useState14 = _slicedToArray(_useState13, 2),
1569
+ currentSuggestionIndex = _useState14[0],
1570
+ setCurrentSuggestionIndex = _useState14[1];
1568
1571
 
1569
1572
  // A list of suggestions
1570
1573
  //----------------
1571
- var _useState13 = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)([]),
1572
- _useState14 = _slicedToArray(_useState13, 2),
1573
- suggestions = _useState14[0],
1574
- setSuggestions = _useState14[1];
1574
+ var _useState15 = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)([]),
1575
+ _useState16 = _slicedToArray(_useState15, 2),
1576
+ suggestions = _useState16[0],
1577
+ setSuggestions = _useState16[1];
1575
1578
 
1576
1579
  //performance
1577
1580
  var handleChangeSuggestionsFetchSafe = funda_utils_dist_cjs_useDebounce__WEBPACK_IMPORTED_MODULE_4___default()(function (e, curVal) {
@@ -1589,12 +1592,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
1589
1592
  //----------------
1590
1593
  function _fetchSuggestionsData() {
1591
1594
  _fetchSuggestionsData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) {
1592
- var response, _ORGIN_DATA;
1595
+ var response, _ORGIN_DATA, suggestionsArray;
1593
1596
  return _regeneratorRuntime().wrap(function _callee$(_context) {
1594
1597
  while (1) switch (_context.prev = _context.next) {
1595
1598
  case 0:
1596
1599
  if (!(_typeof(aiPredictFetchFuncAsync) === 'object')) {
1597
- _context.next = 11;
1600
+ _context.next = 12;
1598
1601
  break;
1599
1602
  }
1600
1603
  _context.next = 3;
@@ -1613,12 +1616,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
1613
1616
  _ORGIN_DATA = [];
1614
1617
  }
1615
1618
 
1616
- //
1617
- setSuggestions(_ORGIN_DATA);
1618
- return _context.abrupt("return", _ORGIN_DATA);
1619
- case 11:
1620
- return _context.abrupt("return", []);
1619
+ // Type assertion since we've verified it's an array
1620
+ suggestionsArray = _ORGIN_DATA; //
1621
+ setSuggestions(suggestionsArray);
1622
+ return _context.abrupt("return", suggestionsArray);
1621
1623
  case 12:
1624
+ return _context.abrupt("return", []);
1625
+ case 13:
1622
1626
  case "end":
1623
1627
  return _context.stop();
1624
1628
  }
@@ -1630,8 +1634,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
1630
1634
  if (valRef.current) {
1631
1635
  var canvas = document.createElement('canvas');
1632
1636
  var context = canvas.getContext('2d');
1633
- context.font = "".concat(originInputComputedStyle.current.fontSize, "px ").concat(originInputComputedStyle.current.fontFamily);
1634
- return context.measureText(text).width;
1637
+ if (context) {
1638
+ context.font = "".concat(originInputComputedStyle.current.fontSize, "px ").concat(originInputComputedStyle.current.fontFamily);
1639
+ return context.measureText(text).width;
1640
+ }
1635
1641
  }
1636
1642
  return 0;
1637
1643
  };
@@ -1727,12 +1733,16 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
1727
1733
  clear: function clear(cb) {
1728
1734
  setChangedVal('');
1729
1735
  cb === null || cb === void 0 ? void 0 : cb();
1730
- onChange === null || onChange === void 0 ? void 0 : onChange(null, onComposition, valRef.current, '');
1736
+ if (valRef.current) {
1737
+ onChange === null || onChange === void 0 ? void 0 : onChange(null, onComposition, valRef.current, '');
1738
+ }
1731
1739
  },
1732
1740
  set: function set(value, cb) {
1733
1741
  setChangedVal("".concat(value));
1734
1742
  cb === null || cb === void 0 ? void 0 : cb();
1735
- onChange === null || onChange === void 0 ? void 0 : onChange(null, onComposition, valRef.current, "".concat(value));
1743
+ if (valRef.current) {
1744
+ onChange === null || onChange === void 0 ? void 0 : onChange(null, onComposition, valRef.current, "".concat(value));
1745
+ }
1736
1746
  },
1737
1747
  aiPredictReset: function aiPredictReset() {
1738
1748
  setTimeout(function () {
@@ -1758,7 +1768,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
1758
1768
  (_rootRef$current = rootRef.current) === null || _rootRef$current === void 0 ? void 0 : _rootRef$current.classList.add('focus');
1759
1769
 
1760
1770
  //
1761
- onFocus === null || onFocus === void 0 ? void 0 : onFocus(event, onComposition, valRef.current);
1771
+ if (valRef.current) {
1772
+ onFocus === null || onFocus === void 0 ? void 0 : onFocus(event, onComposition, valRef.current);
1773
+ }
1762
1774
  }
1763
1775
  function handleChange(event, curVal) {
1764
1776
  setChangedVal(curVal);
@@ -1771,10 +1783,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
1771
1783
  }
1772
1784
 
1773
1785
  //
1774
- onChange === null || onChange === void 0 ? void 0 : onChange(event, onComposition, valRef.current, curVal);
1786
+ if (valRef.current) {
1787
+ onChange === null || onChange === void 0 ? void 0 : onChange(event, onComposition, valRef.current, curVal);
1788
+ }
1775
1789
 
1776
1790
  // It fires in real time as the user enters
1777
- if (typeof onInputCallback === 'function') {
1791
+ if (typeof onInputCallback === 'function' && event && valRef.current) {
1778
1792
  var newData = onInputCallback(event, valRef.current);
1779
1793
  if (newData) setChangedVal(newData); // Avoid the error "react checkbox changing an uncontrolled input to be controlled"
1780
1794
  }
@@ -1792,25 +1806,31 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
1792
1806
  }
1793
1807
 
1794
1808
  //
1795
- onBlur === null || onBlur === void 0 ? void 0 : onBlur(event, onComposition, valRef.current);
1809
+ if (valRef.current) {
1810
+ onBlur === null || onBlur === void 0 ? void 0 : onBlur(event, onComposition, valRef.current);
1811
+ }
1796
1812
 
1797
1813
  // It fires when focus is lost
1798
- if (typeof onChangeCallback === 'function') {
1814
+ if (typeof onChangeCallback === 'function' && valRef.current) {
1799
1815
  var newData = onChangeCallback(event, valRef.current);
1800
1816
  if (newData) setChangedVal(newData); // Avoid the error "react checkbox changing an uncontrolled input to be controlled"
1801
1817
  }
1802
1818
  }
1803
1819
 
1804
1820
  function handleKeyPressed(event) {
1805
- onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event, valRef.current);
1806
- if (typeof onKeyPressedCallback === 'function') {
1821
+ if (valRef.current) {
1822
+ onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event, valRef.current);
1823
+ }
1824
+ if (typeof onKeyPressedCallback === 'function' && valRef.current) {
1807
1825
  var newData = onKeyPressedCallback(event, valRef.current);
1808
1826
  if (newData) setChangedVal(newData); // Avoid the error "react checkbox changing an uncontrolled input to be controlled"
1809
1827
  }
1810
1828
 
1811
1829
  if (event.key === 'Enter' || event.key === 'NumpadEnter') {
1812
1830
  // DO NOT USE "preventDefault()"
1813
- onPressEnter === null || onPressEnter === void 0 ? void 0 : onPressEnter(event, valRef.current);
1831
+ if (valRef.current) {
1832
+ onPressEnter === null || onPressEnter === void 0 ? void 0 : onPressEnter(event, valRef.current);
1833
+ }
1814
1834
  }
1815
1835
 
1816
1836
  // AI Predict
@@ -1838,16 +1858,22 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
1838
1858
 
1839
1859
  // switch result of suggestions
1840
1860
  if (event.code === 'ArrowUp') {
1841
- currentSuggestionIndex.current = (currentSuggestionIndex.current - 1 + tempMatchedSuggestion.length) % tempMatchedSuggestion.length;
1861
+ setCurrentSuggestionIndex(function (prev) {
1862
+ return (prev - 1 + tempMatchedSuggestion.length) % tempMatchedSuggestion.length;
1863
+ });
1842
1864
  }
1843
1865
  if (event.code === 'ArrowDown') {
1844
- currentSuggestionIndex.current = (currentSuggestionIndex.current + 1) % tempMatchedSuggestion.length;
1866
+ setCurrentSuggestionIndex(function (prev) {
1867
+ return (prev + 1) % tempMatchedSuggestion.length;
1868
+ });
1845
1869
  }
1846
- setCurrentSuggestion(tempMatchedSuggestion[currentSuggestionIndex.current] || '');
1870
+ setCurrentSuggestion(tempMatchedSuggestion[currentSuggestionIndex] || '');
1847
1871
  }
1848
1872
  }
1849
1873
  function handleKeyUp(event) {
1850
- onKeyUp === null || onKeyUp === void 0 ? void 0 : onKeyUp(event, valRef.current);
1874
+ if (valRef.current) {
1875
+ onKeyUp === null || onKeyUp === void 0 ? void 0 : onKeyUp(event, valRef.current);
1876
+ }
1851
1877
  }
1852
1878
  (0, react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
1853
1879
  // update default value
@@ -1914,18 +1940,18 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
1914
1940
  }),
1915
1941
  id: idRes,
1916
1942
  name: name,
1917
- step: step || null,
1918
- min: min || null,
1919
- max: max || null,
1920
- src: src || null,
1921
- size: size || null,
1922
- alt: alt || null,
1943
+ step: step || undefined,
1944
+ min: min || undefined,
1945
+ max: max || undefined,
1946
+ src: src || undefined,
1947
+ size: typeof size === 'number' ? size : undefined,
1948
+ alt: alt || undefined,
1923
1949
  inputMode: inputMode || undefined,
1924
- pattern: pattern || null,
1950
+ pattern: pattern || undefined,
1925
1951
  placeholder: placeholder || '',
1926
1952
  value: changedVal,
1927
- minLength: minLength || null,
1928
- maxLength: maxLength || null,
1953
+ minLength: typeof minLength === 'number' ? minLength : undefined,
1954
+ maxLength: typeof maxLength === 'number' ? maxLength : undefined,
1929
1955
  autoComplete: typeof autoComplete === 'undefined' ? 'on' : autoComplete,
1930
1956
  autoCapitalize: typeof autoCapitalize === 'undefined' ? 'off' : autoCapitalize,
1931
1957
  spellCheck: typeof spellCheck === 'undefined' ? false : spellCheck,
@@ -1944,22 +1970,22 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
1944
1970
  onCompositionStart: handleComposition,
1945
1971
  onCompositionUpdate: handleComposition,
1946
1972
  onCompositionEnd: handleComposition,
1947
- disabled: disabled || null,
1948
- required: required || null,
1949
- readOnly: readOnly || null,
1973
+ disabled: disabled || undefined,
1974
+ required: required || undefined,
1975
+ readOnly: readOnly || undefined,
1950
1976
  style: style
1951
1977
  }, attributes)), appendControl || '', aiPredict && remainingText && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
1952
1978
  ref: aiInputRef,
1953
1979
  className: "position-absolute z-1",
1954
1980
  "data-ai": "predict",
1955
1981
  style: {
1956
- left: "".concat(originInputComputedStyle.current.fontSize + textWidth, "px"),
1957
- top: originInputComputedStyle.current.textTop + 'px',
1982
+ left: "".concat((typeof originInputComputedStyle.current.fontSize === 'number' ? originInputComputedStyle.current.fontSize : 16) + textWidth, "px"),
1983
+ top: (typeof originInputComputedStyle.current.textTop === 'number' ? originInputComputedStyle.current.textTop : 10) + 'px',
1958
1984
  color: "rgba(".concat(aiPredictRemainingTextRGB[0], ", ").concat(aiPredictRemainingTextRGB[1], ", ").concat(aiPredictRemainingTextRGB[2], ", ").concat(calculateOpacity(), ")"),
1959
1985
  pointerEvents: 'none',
1960
- fontSize: originInputComputedStyle.current.fontSize + 'px',
1961
- fontFamily: originInputComputedStyle.current.fontFamily,
1962
- letterSpacing: originInputComputedStyle.current.letterSpacing
1986
+ fontSize: (typeof originInputComputedStyle.current.fontSize === 'number' ? originInputComputedStyle.current.fontSize : 16) + 'px',
1987
+ fontFamily: typeof originInputComputedStyle.current.fontFamily === 'string' ? originInputComputedStyle.current.fontFamily : 'inherit',
1988
+ letterSpacing: typeof originInputComputedStyle.current.letterSpacing === 'string' ? originInputComputedStyle.current.letterSpacing : 'normal'
1963
1989
  }
1964
1990
  }, 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", {
1965
1991
  className: "position-absolute end-0 top-0 my-2 mx-2"
package/Select/index.d.ts CHANGED
@@ -9,7 +9,7 @@ export interface MultiSelectValue {
9
9
  labelsOfString: string;
10
10
  valuesOfString: string;
11
11
  }
12
- export declare type SelectOptionChangeFnType = (event: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>, element: HTMLElement, value: OptionConfig | MultiSelectValue) => void | Promise<void>;
12
+ export declare type SelectOptionChangeFnType = (element: HTMLElement, valueElement: HTMLElement, value: OptionConfig | MultiSelectValue) => void | Promise<void>;
13
13
  export interface MultiSelectControlValConfig {
14
14
  values: string[];
15
15
  labels: string[];
package/Select/index.js CHANGED
@@ -3899,6 +3899,11 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
3899
3899
  var _selectInputRef$curre3;
3900
3900
  if (MULTI_SEL_VALID) {
3901
3901
  updateOptionCheckboxes('remove');
3902
+
3903
+ //
3904
+ if (typeof onChange === 'function') {
3905
+ onChange(selectInputRef.current, valueInputRef.current, multipleSelectionCallback([], []));
3906
+ }
3902
3907
  } else {
3903
3908
  handleClearValue();
3904
3909
  }
@@ -3918,9 +3923,23 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
3918
3923
  return v.value;
3919
3924
  })
3920
3925
  });
3926
+
3927
+ //
3928
+ if (typeof onChange === 'function') {
3929
+ onChange(selectInputRef.current, valueInputRef.current, multipleSelectionCallback(value.map(function (v) {
3930
+ return v.value;
3931
+ }), value.map(function (v) {
3932
+ return v.label;
3933
+ })));
3934
+ }
3921
3935
  } else {
3922
3936
  var _val = value[0];
3923
3937
  handleSelect(null, _typeof(_val) === 'object' ? JSON.stringify(_val) : _val, ["".concat(_val.value)], ["".concat(_val.label)]);
3938
+
3939
+ //
3940
+ if (typeof onChange === 'function') {
3941
+ onChange(selectInputRef.current, valueInputRef.current, _val);
3942
+ }
3924
3943
  }
3925
3944
  cb === null || cb === void 0 ? void 0 : cb();
3926
3945
  }
@@ -5661,6 +5680,9 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
5661
5680
  }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("button", {
5662
5681
  tabIndex: -1,
5663
5682
  type: "button",
5683
+ style: disabled ? {
5684
+ display: 'none'
5685
+ } : undefined,
5664
5686
  onClick: /*#__PURE__*/function () {
5665
5687
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(e) {
5666
5688
  return _regeneratorRuntime().wrap(function _callee$(_context) {
@@ -29,7 +29,7 @@ export declare type TagInputProps = {
29
29
  style?: React.CSSProperties;
30
30
  tabIndex?: number;
31
31
  [key: `data-${string}`]: string | undefined;
32
- onChange?: (e: any, data: any, dataStr: any) => void;
32
+ onChange?: (el: HTMLElement, data: any, dataStr: any) => void;
33
33
  onBlur?: (e: any) => void;
34
34
  onFocus?: (e: any) => void;
35
35
  };