funda-ui 4.7.333 → 4.7.345
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.css +86 -86
- package/CascadingSelect/index.d.ts +21 -4
- package/CascadingSelect/index.js +209 -53
- package/CascadingSelectE2E/index.css +86 -86
- package/CascadingSelectE2E/index.d.ts +22 -5
- package/CascadingSelectE2E/index.js +233 -69
- package/MultipleCheckboxes/index.js +71 -0
- package/MultipleSelect/index.js +71 -0
- package/Select/index.js +15 -10
- package/TagInput/index.js +71 -0
- package/Utils/extract.d.ts +39 -1
- package/Utils/extract.js +65 -0
- package/Utils/useDragDropPosition.d.ts +0 -3
- package/Utils/useDragDropPosition.js +0 -3
- package/lib/cjs/CascadingSelect/index.d.ts +21 -4
- package/lib/cjs/CascadingSelect/index.js +209 -53
- package/lib/cjs/CascadingSelectE2E/index.d.ts +22 -5
- package/lib/cjs/CascadingSelectE2E/index.js +233 -69
- package/lib/cjs/MultipleCheckboxes/index.js +71 -0
- package/lib/cjs/MultipleSelect/index.js +71 -0
- package/lib/cjs/Select/index.js +15 -10
- package/lib/cjs/TagInput/index.js +71 -0
- package/lib/cjs/Utils/extract.d.ts +39 -1
- package/lib/cjs/Utils/extract.js +65 -0
- package/lib/cjs/Utils/useDragDropPosition.d.ts +0 -3
- package/lib/cjs/Utils/useDragDropPosition.js +0 -3
- package/lib/css/CascadingSelect/index.css +86 -86
- package/lib/css/CascadingSelectE2E/index.css +86 -86
- package/lib/esm/CascadingSelect/Group.tsx +4 -3
- package/lib/esm/CascadingSelect/index.scss +67 -65
- package/lib/esm/CascadingSelect/index.tsx +201 -60
- package/lib/esm/CascadingSelectE2E/Group.tsx +3 -3
- package/lib/esm/CascadingSelectE2E/index.scss +67 -65
- package/lib/esm/CascadingSelectE2E/index.tsx +235 -79
- package/lib/esm/Select/index.tsx +8 -8
- package/lib/esm/Utils/hooks/useDragDropPosition.tsx +0 -3
- package/lib/esm/Utils/libs/extract.ts +77 -3
- package/package.json +1 -1
|
@@ -462,6 +462,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
462
462
|
return (/* binding */_extractContentsOfBrackets
|
|
463
463
|
);
|
|
464
464
|
},
|
|
465
|
+
/* harmony export */"extractContentsOfMixedCharactersWithBraces": function extractContentsOfMixedCharactersWithBraces() {
|
|
466
|
+
return (/* binding */_extractContentsOfMixedCharactersWithBraces
|
|
467
|
+
);
|
|
468
|
+
},
|
|
469
|
+
/* harmony export */"extractContentsOfMixedCharactersWithComma": function extractContentsOfMixedCharactersWithComma() {
|
|
470
|
+
return (/* binding */_extractContentsOfMixedCharactersWithComma
|
|
471
|
+
);
|
|
472
|
+
},
|
|
465
473
|
/* harmony export */"extractContentsOfParentheses": function extractContentsOfParentheses() {
|
|
466
474
|
return (/* binding */_extractContentsOfParentheses
|
|
467
475
|
);
|
|
@@ -545,6 +553,69 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
545
553
|
}
|
|
546
554
|
}
|
|
547
555
|
|
|
556
|
+
/**
|
|
557
|
+
* Parses a braces-separated string of `{label[value]}` pairs into an array of objects.
|
|
558
|
+
*
|
|
559
|
+
* Example:
|
|
560
|
+
* Input: "{Poor[c]}{Sub-option 4[c-2]}{Empty[]}"
|
|
561
|
+
* Input: "{{Poor[c]}{Sub-option 4[c-2]}{Empty[]}[]}"
|
|
562
|
+
*
|
|
563
|
+
* Output: [
|
|
564
|
+
* { label: "Poor", value: "c" },
|
|
565
|
+
* { label: "Sub-option 4", value: "c-2" },
|
|
566
|
+
* { label: "Empty", value: "" }
|
|
567
|
+
* ]
|
|
568
|
+
*
|
|
569
|
+
* @param {string} str - The input string containing one or more `{label[value]}` segments.
|
|
570
|
+
* @returns {Array<{label: string, value: string}>} - An array of extracted label-value objects.
|
|
571
|
+
*/
|
|
572
|
+
function _extractContentsOfMixedCharactersWithBraces(str) {
|
|
573
|
+
// Fix the extra '{' at the beginning
|
|
574
|
+
var cleaned = str.replace(/^{{/, '{');
|
|
575
|
+
|
|
576
|
+
// Remove empty {} or {[]} tail
|
|
577
|
+
var trimmed = cleaned.replace(/\{\[\]\}$/, '');
|
|
578
|
+
|
|
579
|
+
// The match is like {label[value]}
|
|
580
|
+
var pattern = /\{(.*?)\[(.*?)\]\}/g;
|
|
581
|
+
var matches = Array.from(trimmed.matchAll(pattern));
|
|
582
|
+
return matches.map(function (match) {
|
|
583
|
+
return {
|
|
584
|
+
label: match[1],
|
|
585
|
+
value: match[2]
|
|
586
|
+
};
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* Parses a comma-separated string of `label[value]` pairs into an array of objects.
|
|
592
|
+
*
|
|
593
|
+
* Example:
|
|
594
|
+
* Input: "Poor[c],Sub-option 4[c-2],Empty[]"
|
|
595
|
+
* Output: [
|
|
596
|
+
* { label: "Poor", value: "c" },
|
|
597
|
+
* { label: "Sub-option 4", value: "c-2" },
|
|
598
|
+
* { label: "Empty", value: "" }
|
|
599
|
+
* ]
|
|
600
|
+
*
|
|
601
|
+
* @param {string} str - A string containing label-value pairs in the format `label[value]`, separated by commas.
|
|
602
|
+
* @returns {Array<{ label: string, value: string }>} - An array of parsed objects.
|
|
603
|
+
*/
|
|
604
|
+
function _extractContentsOfMixedCharactersWithComma(str) {
|
|
605
|
+
return str.split(",").map(function (item) {
|
|
606
|
+
return item.trim();
|
|
607
|
+
}).map(function (item) {
|
|
608
|
+
var match = item.match(/^(.*?)\[(.*?)\]$/);
|
|
609
|
+
if (match) {
|
|
610
|
+
return {
|
|
611
|
+
label: match[1],
|
|
612
|
+
value: match[2]
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
return null;
|
|
616
|
+
}).filter(Boolean);
|
|
617
|
+
}
|
|
618
|
+
|
|
548
619
|
/******/
|
|
549
620
|
return __webpack_exports__;
|
|
550
621
|
/******/
|
package/MultipleSelect/index.js
CHANGED
|
@@ -2269,6 +2269,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
2269
2269
|
return (/* binding */_extractContentsOfBrackets
|
|
2270
2270
|
);
|
|
2271
2271
|
},
|
|
2272
|
+
/* harmony export */"extractContentsOfMixedCharactersWithBraces": function extractContentsOfMixedCharactersWithBraces() {
|
|
2273
|
+
return (/* binding */_extractContentsOfMixedCharactersWithBraces
|
|
2274
|
+
);
|
|
2275
|
+
},
|
|
2276
|
+
/* harmony export */"extractContentsOfMixedCharactersWithComma": function extractContentsOfMixedCharactersWithComma() {
|
|
2277
|
+
return (/* binding */_extractContentsOfMixedCharactersWithComma
|
|
2278
|
+
);
|
|
2279
|
+
},
|
|
2272
2280
|
/* harmony export */"extractContentsOfParentheses": function extractContentsOfParentheses() {
|
|
2273
2281
|
return (/* binding */_extractContentsOfParentheses
|
|
2274
2282
|
);
|
|
@@ -2352,6 +2360,69 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
2352
2360
|
}
|
|
2353
2361
|
}
|
|
2354
2362
|
|
|
2363
|
+
/**
|
|
2364
|
+
* Parses a braces-separated string of `{label[value]}` pairs into an array of objects.
|
|
2365
|
+
*
|
|
2366
|
+
* Example:
|
|
2367
|
+
* Input: "{Poor[c]}{Sub-option 4[c-2]}{Empty[]}"
|
|
2368
|
+
* Input: "{{Poor[c]}{Sub-option 4[c-2]}{Empty[]}[]}"
|
|
2369
|
+
*
|
|
2370
|
+
* Output: [
|
|
2371
|
+
* { label: "Poor", value: "c" },
|
|
2372
|
+
* { label: "Sub-option 4", value: "c-2" },
|
|
2373
|
+
* { label: "Empty", value: "" }
|
|
2374
|
+
* ]
|
|
2375
|
+
*
|
|
2376
|
+
* @param {string} str - The input string containing one or more `{label[value]}` segments.
|
|
2377
|
+
* @returns {Array<{label: string, value: string}>} - An array of extracted label-value objects.
|
|
2378
|
+
*/
|
|
2379
|
+
function _extractContentsOfMixedCharactersWithBraces(str) {
|
|
2380
|
+
// Fix the extra '{' at the beginning
|
|
2381
|
+
var cleaned = str.replace(/^{{/, '{');
|
|
2382
|
+
|
|
2383
|
+
// Remove empty {} or {[]} tail
|
|
2384
|
+
var trimmed = cleaned.replace(/\{\[\]\}$/, '');
|
|
2385
|
+
|
|
2386
|
+
// The match is like {label[value]}
|
|
2387
|
+
var pattern = /\{(.*?)\[(.*?)\]\}/g;
|
|
2388
|
+
var matches = Array.from(trimmed.matchAll(pattern));
|
|
2389
|
+
return matches.map(function (match) {
|
|
2390
|
+
return {
|
|
2391
|
+
label: match[1],
|
|
2392
|
+
value: match[2]
|
|
2393
|
+
};
|
|
2394
|
+
});
|
|
2395
|
+
}
|
|
2396
|
+
|
|
2397
|
+
/**
|
|
2398
|
+
* Parses a comma-separated string of `label[value]` pairs into an array of objects.
|
|
2399
|
+
*
|
|
2400
|
+
* Example:
|
|
2401
|
+
* Input: "Poor[c],Sub-option 4[c-2],Empty[]"
|
|
2402
|
+
* Output: [
|
|
2403
|
+
* { label: "Poor", value: "c" },
|
|
2404
|
+
* { label: "Sub-option 4", value: "c-2" },
|
|
2405
|
+
* { label: "Empty", value: "" }
|
|
2406
|
+
* ]
|
|
2407
|
+
*
|
|
2408
|
+
* @param {string} str - A string containing label-value pairs in the format `label[value]`, separated by commas.
|
|
2409
|
+
* @returns {Array<{ label: string, value: string }>} - An array of parsed objects.
|
|
2410
|
+
*/
|
|
2411
|
+
function _extractContentsOfMixedCharactersWithComma(str) {
|
|
2412
|
+
return str.split(",").map(function (item) {
|
|
2413
|
+
return item.trim();
|
|
2414
|
+
}).map(function (item) {
|
|
2415
|
+
var match = item.match(/^(.*?)\[(.*?)\]$/);
|
|
2416
|
+
if (match) {
|
|
2417
|
+
return {
|
|
2418
|
+
label: match[1],
|
|
2419
|
+
value: match[2]
|
|
2420
|
+
};
|
|
2421
|
+
}
|
|
2422
|
+
return null;
|
|
2423
|
+
}).filter(Boolean);
|
|
2424
|
+
}
|
|
2425
|
+
|
|
2355
2426
|
/******/
|
|
2356
2427
|
return __webpack_exports__;
|
|
2357
2428
|
/******/
|
package/Select/index.js
CHANGED
|
@@ -3846,19 +3846,22 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
3846
3846
|
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useImperativeHandle)(contentRef, function () {
|
|
3847
3847
|
return {
|
|
3848
3848
|
active: function active() {
|
|
3849
|
+
var _selectInputRef$curre;
|
|
3849
3850
|
handleShowList();
|
|
3850
|
-
selectInputRef.current.select();
|
|
3851
|
+
(_selectInputRef$curre = selectInputRef.current) === null || _selectInputRef$curre === void 0 ? void 0 : _selectInputRef$curre.select();
|
|
3851
3852
|
},
|
|
3852
3853
|
focus: function focus() {
|
|
3853
|
-
|
|
3854
|
+
var _selectInputRef$curre2;
|
|
3855
|
+
(_selectInputRef$curre2 = selectInputRef.current) === null || _selectInputRef$curre2 === void 0 ? void 0 : _selectInputRef$curre2.select();
|
|
3854
3856
|
},
|
|
3855
3857
|
clear: function clear(cb) {
|
|
3858
|
+
var _selectInputRef$curre3;
|
|
3856
3859
|
if (MULTI_SEL_VALID) {
|
|
3857
3860
|
updateOptionCheckboxes('remove');
|
|
3858
3861
|
} else {
|
|
3859
3862
|
handleClearValue();
|
|
3860
3863
|
}
|
|
3861
|
-
selectInputRef.current.blur();
|
|
3864
|
+
(_selectInputRef$curre3 = selectInputRef.current) === null || _selectInputRef$curre3 === void 0 ? void 0 : _selectInputRef$curre3.blur();
|
|
3862
3865
|
cb === null || cb === void 0 ? void 0 : cb();
|
|
3863
3866
|
},
|
|
3864
3867
|
/*
|
|
@@ -3881,7 +3884,7 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
3881
3884
|
cb === null || cb === void 0 ? void 0 : cb();
|
|
3882
3885
|
}
|
|
3883
3886
|
};
|
|
3884
|
-
}, [contentRef]);
|
|
3887
|
+
}, [contentRef, selectInputRef]);
|
|
3885
3888
|
|
|
3886
3889
|
// click outside
|
|
3887
3890
|
useClickOutside_default()({
|
|
@@ -4628,6 +4631,7 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
4628
4631
|
$el,
|
|
4629
4632
|
_selected,
|
|
4630
4633
|
_selectedVal,
|
|
4634
|
+
_selectInputRef$curre4,
|
|
4631
4635
|
_curItem$callback,
|
|
4632
4636
|
_value2,
|
|
4633
4637
|
_label2,
|
|
@@ -4636,6 +4640,7 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
4636
4640
|
_$el,
|
|
4637
4641
|
_selected2,
|
|
4638
4642
|
_selectedVal2,
|
|
4643
|
+
_selectInputRef$curre5,
|
|
4639
4644
|
_args3 = arguments;
|
|
4640
4645
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
4641
4646
|
while (1) switch (_context3.prev = _context3.next) {
|
|
@@ -4776,7 +4781,7 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
4776
4781
|
return onChange === null || onChange === void 0 ? void 0 : onChange(selectInputRef.current, valueInputRef.current, !MULTI_SEL_VALID ? curItem : multipleSelectionCallback(currentControlValueArr, currentControlLabelArr));
|
|
4777
4782
|
case 25:
|
|
4778
4783
|
//
|
|
4779
|
-
selectInputRef.current.blur();
|
|
4784
|
+
(_selectInputRef$curre4 = selectInputRef.current) === null || _selectInputRef$curre4 === void 0 ? void 0 : _selectInputRef$curre4.blur();
|
|
4780
4785
|
case 26:
|
|
4781
4786
|
_context3.next = 42;
|
|
4782
4787
|
break;
|
|
@@ -4884,7 +4889,7 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
4884
4889
|
return onChange === null || onChange === void 0 ? void 0 : onChange(selectInputRef.current, valueInputRef.current, !MULTI_SEL_VALID ? curItem : multipleSelectionCallback(_currentControlValueArr, _currentControlLabelArr));
|
|
4885
4890
|
case 41:
|
|
4886
4891
|
//
|
|
4887
|
-
selectInputRef.current.blur();
|
|
4892
|
+
(_selectInputRef$curre5 = selectInputRef.current) === null || _selectInputRef$curre5 === void 0 ? void 0 : _selectInputRef$curre5.blur();
|
|
4888
4893
|
case 42:
|
|
4889
4894
|
// Fixed an out-of-focus issue
|
|
4890
4895
|
fixFocusStatus();
|
|
@@ -5020,7 +5025,7 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
5020
5025
|
}
|
|
5021
5026
|
function _handleMultiControlItemRemove() {
|
|
5022
5027
|
_handleMultiControlItemRemove = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(event) {
|
|
5023
|
-
var valueToRemove, getCurrentIndex, currentControlValueArr, currentControlLabelArr, _value, _label;
|
|
5028
|
+
var valueToRemove, getCurrentIndex, currentControlValueArr, currentControlLabelArr, _value, _label, _selectInputRef$curre6;
|
|
5024
5029
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
5025
5030
|
while (1) switch (_context5.prev = _context5.next) {
|
|
5026
5031
|
case 0:
|
|
@@ -5057,7 +5062,7 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
5057
5062
|
return onChange === null || onChange === void 0 ? void 0 : onChange(selectInputRef.current, valueInputRef.current, multipleSelectionCallback(currentControlValueArr, currentControlLabelArr));
|
|
5058
5063
|
case 15:
|
|
5059
5064
|
//
|
|
5060
|
-
selectInputRef.current.blur();
|
|
5065
|
+
(_selectInputRef$curre6 = selectInputRef.current) === null || _selectInputRef$curre6 === void 0 ? void 0 : _selectInputRef$curre6.blur();
|
|
5061
5066
|
case 16:
|
|
5062
5067
|
case "end":
|
|
5063
5068
|
return _context5.stop();
|
|
@@ -5246,7 +5251,7 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
5246
5251
|
}
|
|
5247
5252
|
function _handleKeyPressed() {
|
|
5248
5253
|
_handleKeyPressed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(event) {
|
|
5249
|
-
var key, res, currentIndex, currentData, currentControlValueArr, currentControlLabelArr, htmlOptions;
|
|
5254
|
+
var key, res, currentIndex, currentData, currentControlValueArr, currentControlLabelArr, htmlOptions, _selectInputRef$curre7;
|
|
5250
5255
|
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
5251
5256
|
while (1) switch (_context8.prev = _context8.next) {
|
|
5252
5257
|
case 0:
|
|
@@ -5314,7 +5319,7 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
5314
5319
|
return onChange === null || onChange === void 0 ? void 0 : onChange(selectInputRef.current, valueInputRef.current, !MULTI_SEL_VALID ? currentData : multipleSelectionCallback(currentControlValueArr, currentControlLabelArr));
|
|
5315
5320
|
case 25:
|
|
5316
5321
|
//
|
|
5317
|
-
selectInputRef.current.blur();
|
|
5322
|
+
(_selectInputRef$curre7 = selectInputRef.current) === null || _selectInputRef$curre7 === void 0 ? void 0 : _selectInputRef$curre7.blur();
|
|
5318
5323
|
case 26:
|
|
5319
5324
|
if (!(key === 'ArrowUp')) {
|
|
5320
5325
|
_context8.next = 30;
|
package/TagInput/index.js
CHANGED
|
@@ -462,6 +462,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
462
462
|
return (/* binding */_extractContentsOfBrackets
|
|
463
463
|
);
|
|
464
464
|
},
|
|
465
|
+
/* harmony export */"extractContentsOfMixedCharactersWithBraces": function extractContentsOfMixedCharactersWithBraces() {
|
|
466
|
+
return (/* binding */_extractContentsOfMixedCharactersWithBraces
|
|
467
|
+
);
|
|
468
|
+
},
|
|
469
|
+
/* harmony export */"extractContentsOfMixedCharactersWithComma": function extractContentsOfMixedCharactersWithComma() {
|
|
470
|
+
return (/* binding */_extractContentsOfMixedCharactersWithComma
|
|
471
|
+
);
|
|
472
|
+
},
|
|
465
473
|
/* harmony export */"extractContentsOfParentheses": function extractContentsOfParentheses() {
|
|
466
474
|
return (/* binding */_extractContentsOfParentheses
|
|
467
475
|
);
|
|
@@ -545,6 +553,69 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
545
553
|
}
|
|
546
554
|
}
|
|
547
555
|
|
|
556
|
+
/**
|
|
557
|
+
* Parses a braces-separated string of `{label[value]}` pairs into an array of objects.
|
|
558
|
+
*
|
|
559
|
+
* Example:
|
|
560
|
+
* Input: "{Poor[c]}{Sub-option 4[c-2]}{Empty[]}"
|
|
561
|
+
* Input: "{{Poor[c]}{Sub-option 4[c-2]}{Empty[]}[]}"
|
|
562
|
+
*
|
|
563
|
+
* Output: [
|
|
564
|
+
* { label: "Poor", value: "c" },
|
|
565
|
+
* { label: "Sub-option 4", value: "c-2" },
|
|
566
|
+
* { label: "Empty", value: "" }
|
|
567
|
+
* ]
|
|
568
|
+
*
|
|
569
|
+
* @param {string} str - The input string containing one or more `{label[value]}` segments.
|
|
570
|
+
* @returns {Array<{label: string, value: string}>} - An array of extracted label-value objects.
|
|
571
|
+
*/
|
|
572
|
+
function _extractContentsOfMixedCharactersWithBraces(str) {
|
|
573
|
+
// Fix the extra '{' at the beginning
|
|
574
|
+
var cleaned = str.replace(/^{{/, '{');
|
|
575
|
+
|
|
576
|
+
// Remove empty {} or {[]} tail
|
|
577
|
+
var trimmed = cleaned.replace(/\{\[\]\}$/, '');
|
|
578
|
+
|
|
579
|
+
// The match is like {label[value]}
|
|
580
|
+
var pattern = /\{(.*?)\[(.*?)\]\}/g;
|
|
581
|
+
var matches = Array.from(trimmed.matchAll(pattern));
|
|
582
|
+
return matches.map(function (match) {
|
|
583
|
+
return {
|
|
584
|
+
label: match[1],
|
|
585
|
+
value: match[2]
|
|
586
|
+
};
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* Parses a comma-separated string of `label[value]` pairs into an array of objects.
|
|
592
|
+
*
|
|
593
|
+
* Example:
|
|
594
|
+
* Input: "Poor[c],Sub-option 4[c-2],Empty[]"
|
|
595
|
+
* Output: [
|
|
596
|
+
* { label: "Poor", value: "c" },
|
|
597
|
+
* { label: "Sub-option 4", value: "c-2" },
|
|
598
|
+
* { label: "Empty", value: "" }
|
|
599
|
+
* ]
|
|
600
|
+
*
|
|
601
|
+
* @param {string} str - A string containing label-value pairs in the format `label[value]`, separated by commas.
|
|
602
|
+
* @returns {Array<{ label: string, value: string }>} - An array of parsed objects.
|
|
603
|
+
*/
|
|
604
|
+
function _extractContentsOfMixedCharactersWithComma(str) {
|
|
605
|
+
return str.split(",").map(function (item) {
|
|
606
|
+
return item.trim();
|
|
607
|
+
}).map(function (item) {
|
|
608
|
+
var match = item.match(/^(.*?)\[(.*?)\]$/);
|
|
609
|
+
if (match) {
|
|
610
|
+
return {
|
|
611
|
+
label: match[1],
|
|
612
|
+
value: match[2]
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
return null;
|
|
616
|
+
}).filter(Boolean);
|
|
617
|
+
}
|
|
618
|
+
|
|
548
619
|
/******/
|
|
549
620
|
return __webpack_exports__;
|
|
550
621
|
/******/
|
package/Utils/extract.d.ts
CHANGED
|
@@ -25,4 +25,42 @@ declare function extractContentsOfBraces(str: string, commaSeparated?: boolean):
|
|
|
25
25
|
* @returns {Array<string>|string} such as: ['1,2','f','c']
|
|
26
26
|
*/
|
|
27
27
|
declare function extractContentsOfParentheses(str: string, commaSeparated?: boolean): Array<string> | string;
|
|
28
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Parses a braces-separated string of `{label[value]}` pairs into an array of objects.
|
|
30
|
+
*
|
|
31
|
+
* Example:
|
|
32
|
+
* Input: "{Poor[c]}{Sub-option 4[c-2]}{Empty[]}"
|
|
33
|
+
* Input: "{{Poor[c]}{Sub-option 4[c-2]}{Empty[]}[]}"
|
|
34
|
+
*
|
|
35
|
+
* Output: [
|
|
36
|
+
* { label: "Poor", value: "c" },
|
|
37
|
+
* { label: "Sub-option 4", value: "c-2" },
|
|
38
|
+
* { label: "Empty", value: "" }
|
|
39
|
+
* ]
|
|
40
|
+
*
|
|
41
|
+
* @param {string} str - The input string containing one or more `{label[value]}` segments.
|
|
42
|
+
* @returns {Array<{label: string, value: string}>} - An array of extracted label-value objects.
|
|
43
|
+
*/
|
|
44
|
+
declare function extractContentsOfMixedCharactersWithBraces(str: string): {
|
|
45
|
+
label: string;
|
|
46
|
+
value: string | number;
|
|
47
|
+
}[];
|
|
48
|
+
/**
|
|
49
|
+
* Parses a comma-separated string of `label[value]` pairs into an array of objects.
|
|
50
|
+
*
|
|
51
|
+
* Example:
|
|
52
|
+
* Input: "Poor[c],Sub-option 4[c-2],Empty[]"
|
|
53
|
+
* Output: [
|
|
54
|
+
* { label: "Poor", value: "c" },
|
|
55
|
+
* { label: "Sub-option 4", value: "c-2" },
|
|
56
|
+
* { label: "Empty", value: "" }
|
|
57
|
+
* ]
|
|
58
|
+
*
|
|
59
|
+
* @param {string} str - A string containing label-value pairs in the format `label[value]`, separated by commas.
|
|
60
|
+
* @returns {Array<{ label: string, value: string }>} - An array of parsed objects.
|
|
61
|
+
*/
|
|
62
|
+
declare function extractContentsOfMixedCharactersWithComma(str: string): {
|
|
63
|
+
label: string;
|
|
64
|
+
value: string | number;
|
|
65
|
+
}[];
|
|
66
|
+
export { extractorExist, extractContentsOfBrackets, extractContentsOfBraces, extractContentsOfParentheses, extractContentsOfMixedCharactersWithBraces, extractContentsOfMixedCharactersWithComma };
|
package/Utils/extract.js
CHANGED
|
@@ -48,6 +48,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
48
48
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
49
49
|
/* harmony export */ "extractContentsOfBraces": () => (/* binding */ extractContentsOfBraces),
|
|
50
50
|
/* harmony export */ "extractContentsOfBrackets": () => (/* binding */ extractContentsOfBrackets),
|
|
51
|
+
/* harmony export */ "extractContentsOfMixedCharactersWithBraces": () => (/* binding */ extractContentsOfMixedCharactersWithBraces),
|
|
52
|
+
/* harmony export */ "extractContentsOfMixedCharactersWithComma": () => (/* binding */ extractContentsOfMixedCharactersWithComma),
|
|
51
53
|
/* harmony export */ "extractContentsOfParentheses": () => (/* binding */ extractContentsOfParentheses),
|
|
52
54
|
/* harmony export */ "extractorExist": () => (/* binding */ extractorExist)
|
|
53
55
|
/* harmony export */ });
|
|
@@ -124,6 +126,69 @@ function extractContentsOfParentheses(str) {
|
|
|
124
126
|
}
|
|
125
127
|
}
|
|
126
128
|
|
|
129
|
+
/**
|
|
130
|
+
* Parses a braces-separated string of `{label[value]}` pairs into an array of objects.
|
|
131
|
+
*
|
|
132
|
+
* Example:
|
|
133
|
+
* Input: "{Poor[c]}{Sub-option 4[c-2]}{Empty[]}"
|
|
134
|
+
* Input: "{{Poor[c]}{Sub-option 4[c-2]}{Empty[]}[]}"
|
|
135
|
+
*
|
|
136
|
+
* Output: [
|
|
137
|
+
* { label: "Poor", value: "c" },
|
|
138
|
+
* { label: "Sub-option 4", value: "c-2" },
|
|
139
|
+
* { label: "Empty", value: "" }
|
|
140
|
+
* ]
|
|
141
|
+
*
|
|
142
|
+
* @param {string} str - The input string containing one or more `{label[value]}` segments.
|
|
143
|
+
* @returns {Array<{label: string, value: string}>} - An array of extracted label-value objects.
|
|
144
|
+
*/
|
|
145
|
+
function extractContentsOfMixedCharactersWithBraces(str) {
|
|
146
|
+
// Fix the extra '{' at the beginning
|
|
147
|
+
var cleaned = str.replace(/^{{/, '{');
|
|
148
|
+
|
|
149
|
+
// Remove empty {} or {[]} tail
|
|
150
|
+
var trimmed = cleaned.replace(/\{\[\]\}$/, '');
|
|
151
|
+
|
|
152
|
+
// The match is like {label[value]}
|
|
153
|
+
var pattern = /\{(.*?)\[(.*?)\]\}/g;
|
|
154
|
+
var matches = Array.from(trimmed.matchAll(pattern));
|
|
155
|
+
return matches.map(function (match) {
|
|
156
|
+
return {
|
|
157
|
+
label: match[1],
|
|
158
|
+
value: match[2]
|
|
159
|
+
};
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Parses a comma-separated string of `label[value]` pairs into an array of objects.
|
|
165
|
+
*
|
|
166
|
+
* Example:
|
|
167
|
+
* Input: "Poor[c],Sub-option 4[c-2],Empty[]"
|
|
168
|
+
* Output: [
|
|
169
|
+
* { label: "Poor", value: "c" },
|
|
170
|
+
* { label: "Sub-option 4", value: "c-2" },
|
|
171
|
+
* { label: "Empty", value: "" }
|
|
172
|
+
* ]
|
|
173
|
+
*
|
|
174
|
+
* @param {string} str - A string containing label-value pairs in the format `label[value]`, separated by commas.
|
|
175
|
+
* @returns {Array<{ label: string, value: string }>} - An array of parsed objects.
|
|
176
|
+
*/
|
|
177
|
+
function extractContentsOfMixedCharactersWithComma(str) {
|
|
178
|
+
return str.split(",").map(function (item) {
|
|
179
|
+
return item.trim();
|
|
180
|
+
}).map(function (item) {
|
|
181
|
+
var match = item.match(/^(.*?)\[(.*?)\]$/);
|
|
182
|
+
if (match) {
|
|
183
|
+
return {
|
|
184
|
+
label: match[1],
|
|
185
|
+
value: match[2]
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
return null;
|
|
189
|
+
}).filter(Boolean);
|
|
190
|
+
}
|
|
191
|
+
|
|
127
192
|
/******/ return __webpack_exports__;
|
|
128
193
|
/******/ })()
|
|
129
194
|
;
|
|
@@ -101,9 +101,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
101
101
|
*
|
|
102
102
|
* @usage:
|
|
103
103
|
|
|
104
|
-
import { useState, useCallback } from 'react';
|
|
105
|
-
import { useDragDropPosition } from '@/utils/hooks/useDragDropPosition';
|
|
106
|
-
|
|
107
104
|
const App = () => {
|
|
108
105
|
|
|
109
106
|
const [show, setShow] = useState<boolean>(false);
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export declare type CascadingSelectOptionChangeFnType = (input: any, currentData: any, index: any, depth: any, value:
|
|
2
|
+
export declare type CascadingSelectOptionChangeFnType = (input: any, currentData: any, index: any, depth: any, value: string, closeFunc: any) => void;
|
|
3
3
|
export declare type CascadingSelectProps = {
|
|
4
4
|
popupRef?: React.ForwardedRef<any>;
|
|
5
5
|
wrapperClassName?: string;
|
|
6
6
|
controlClassName?: string;
|
|
7
7
|
controlExClassName?: string;
|
|
8
|
+
controlGroupWrapperClassName?: string;
|
|
9
|
+
controlGroupTextClassName?: string;
|
|
8
10
|
searchable?: boolean;
|
|
9
11
|
searchPlaceholder?: string;
|
|
10
12
|
perColumnHeadersShow?: boolean;
|
|
@@ -13,8 +15,15 @@ export declare type CascadingSelectProps = {
|
|
|
13
15
|
label?: React.ReactNode | string;
|
|
14
16
|
name?: string;
|
|
15
17
|
placeholder?: string;
|
|
18
|
+
readOnly?: any;
|
|
16
19
|
disabled?: any;
|
|
17
20
|
required?: any;
|
|
21
|
+
requiredLabel?: React.ReactNode | string;
|
|
22
|
+
units?: React.ReactNode | string;
|
|
23
|
+
iconLeft?: React.ReactNode | string;
|
|
24
|
+
iconRight?: React.ReactNode | string;
|
|
25
|
+
minLength?: any;
|
|
26
|
+
maxLength?: any;
|
|
18
27
|
/** Whether to use curly braces to save result and initialize default value */
|
|
19
28
|
extractValueByBraces?: boolean;
|
|
20
29
|
/** Set headers for each column group */
|
|
@@ -31,8 +40,8 @@ export declare type CascadingSelectProps = {
|
|
|
31
40
|
/** Set a loader component to show while the component waits for the next load of data.
|
|
32
41
|
* e.g. `<span>Loading...</span>` or any fancy loader element */
|
|
33
42
|
loader?: React.ReactNode;
|
|
34
|
-
/** Whether
|
|
35
|
-
|
|
43
|
+
/** Whether it can be modified in the input box */
|
|
44
|
+
inputable?: boolean;
|
|
36
45
|
/** Set an arrow of breadcrumb result */
|
|
37
46
|
displayResultArrow?: React.ReactNode;
|
|
38
47
|
/** Set an arrow of control */
|
|
@@ -58,6 +67,14 @@ export declare type CascadingSelectProps = {
|
|
|
58
67
|
onChange?: CascadingSelectOptionChangeFnType | null;
|
|
59
68
|
onBlur?: (e: any) => void;
|
|
60
69
|
onFocus?: (e: any) => void;
|
|
70
|
+
/**
|
|
71
|
+
* Customize the function of formatting the value of the input input box, and the parameters are labels, values, and queryIds
|
|
72
|
+
* Returns a string as the value of the input
|
|
73
|
+
*/
|
|
74
|
+
formatInputResult?: (param: Array<{
|
|
75
|
+
label: string;
|
|
76
|
+
value: string | number;
|
|
77
|
+
}>) => string;
|
|
61
78
|
};
|
|
62
|
-
declare const CascadingSelect:
|
|
79
|
+
declare const CascadingSelect: React.ForwardRefExoticComponent<CascadingSelectProps & React.RefAttributes<unknown>>;
|
|
63
80
|
export default CascadingSelect;
|