funda-ui 4.7.161 → 4.7.163

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/Select/index.js CHANGED
@@ -3913,6 +3913,9 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
3913
3913
  _useState26 = _slicedToArray(_useState25, 2),
3914
3914
  controlArr = _useState26[0],
3915
3915
  setControlArr = _useState26[1];
3916
+ function chkValueExist(v) {
3917
+ return typeof v !== 'undefined' && v !== '';
3918
+ }
3916
3919
  var listContainerHeightLimit = function listContainerHeightLimit(num) {
3917
3920
  var res = num;
3918
3921
  if (res > LIST_CONTAINER_MAX_HEIGHT) res = LIST_CONTAINER_MAX_HEIGHT;
@@ -4110,11 +4113,15 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
4110
4113
  filterResQueryValue,
4111
4114
  filterResQueryLabel,
4112
4115
  _currentData,
4116
+ _tempLabels,
4117
+ _tempValues,
4113
4118
  _values,
4114
- _filterRes3,
4119
+ _filterRes2,
4115
4120
  _filterResQueryValue,
4116
4121
  _filterResQueryLabel,
4117
4122
  _currentData2,
4123
+ _tempLabels2,
4124
+ _tempValues2,
4118
4125
  _values3,
4119
4126
  _args = arguments;
4120
4127
  return _regeneratorRuntime().wrap(function _callee$(_context) {
@@ -4187,7 +4194,7 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
4187
4194
  // ++++++++++++++++++++
4188
4195
  // Single selection
4189
4196
  // ++++++++++++++++++++
4190
- if (typeof defaultValue === 'undefined' || defaultValue === '') {
4197
+ if (!chkValueExist(defaultValue)) {
4191
4198
  // Do not use `init`, otherwise the query will revert to the default value if there is no value
4192
4199
  setControlValue('');
4193
4200
  setControlLabel('');
@@ -4202,42 +4209,34 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
4202
4209
  // Multiple selection
4203
4210
  // ++++++++++++++++++++
4204
4211
  if (MULTI_SEL_VALID) {
4205
- if ((typeof defaultValue === 'undefined' || defaultValue === '') && init) {
4212
+ if (!chkValueExist(defaultValue) && init) {
4206
4213
  setControlArr({
4207
4214
  labels: [],
4208
4215
  values: []
4209
4216
  });
4210
4217
  }
4211
- if (typeof defaultValue !== 'undefined' && defaultValue !== '' && (multiSelect === null || multiSelect === void 0 ? void 0 : multiSelect.data) !== null) {
4218
+ if (chkValueExist(defaultValue) && (multiSelect === null || multiSelect === void 0 ? void 0 : multiSelect.data) !== null) {
4212
4219
  // initialize default values of Multiple selection
4213
4220
  _currentData = multiSelect === null || multiSelect === void 0 ? void 0 : multiSelect.data;
4214
- setControlArr({
4215
- labels: _currentData.labels,
4216
- values: _currentData.values
4217
- });
4218
-
4219
- //
4221
+ _tempLabels = _toConsumableArray(_currentData.labels);
4222
+ _tempValues = _toConsumableArray(_currentData.values);
4220
4223
  _values = VALUE_BY_BRACKETS ? (0,extract.extractContentsOfBrackets)(defaultValue) : defaultValue.split(',');
4221
4224
  _values.forEach(function (_value, _index) {
4222
4225
  if (!multiSelControlOptionExist(_currentData.values, _value) && typeof _currentData.values[_index] !== 'undefined') {
4223
- var _filterRes2 = [];
4224
- _filterRes2 = [{
4225
- value: _currentData.values[_index],
4226
- label: _currentData.labels[_index],
4227
- queryString: _currentData.queryStrings[_index]
4228
- }];
4229
- setControlArr(function (prevState) {
4230
- return {
4231
- labels: unique([].concat(_toConsumableArray(prevState.labels), [typeof _filterRes2[0] !== 'undefined' ? _filterRes2[0].label : '']).filter(function (v) {
4232
- return v !== '';
4233
- })),
4234
- values: unique([].concat(_toConsumableArray(prevState.values), [typeof _filterRes2[0] !== 'undefined' ? _filterRes2[0].value : '']).filter(function (v) {
4235
- return v !== '';
4236
- }))
4237
- };
4238
- });
4226
+ _tempLabels.push(_currentData.labels[_index]);
4227
+ _tempValues.push(_currentData.values[_index]);
4239
4228
  }
4240
4229
  });
4230
+ _tempLabels = unique(_tempLabels.filter(function (v) {
4231
+ return v !== '';
4232
+ }));
4233
+ _tempValues = unique(_tempValues.filter(function (v) {
4234
+ return v !== '';
4235
+ }));
4236
+ setControlArr({
4237
+ labels: _tempLabels,
4238
+ values: _tempValues
4239
+ });
4241
4240
  }
4242
4241
 
4243
4242
  // Appropriate multi-item container height
@@ -4283,33 +4282,33 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
4283
4282
  // value & label must be initialized
4284
4283
 
4285
4284
  // If the default value is label, match value
4286
- _filterRes3 = [];
4285
+ _filterRes2 = [];
4287
4286
  _filterResQueryValue = staticOptionsData.filter(function (item) {
4288
4287
  return item.value == defaultValue;
4289
4288
  });
4290
4289
  _filterResQueryLabel = staticOptionsData.filter(function (item) {
4291
4290
  return item.label == defaultValue;
4292
4291
  });
4293
- _filterRes3 = _filterResQueryValue;
4294
- if (_filterResQueryValue.length === 0) _filterRes3 = _filterResQueryLabel;
4292
+ _filterRes2 = _filterResQueryValue;
4293
+ if (_filterResQueryValue.length === 0) _filterRes2 = _filterResQueryLabel;
4295
4294
 
4296
4295
  // if the default value is Object
4297
- if (isObject(inputDefault) && _filterRes3.length === 0) {
4298
- _filterRes3 = [inputDefault];
4296
+ if (isObject(inputDefault) && _filterRes2.length === 0) {
4297
+ _filterRes2 = [inputDefault];
4299
4298
  }
4300
4299
 
4301
4300
  // STEP 4: ===========
4302
4301
  // ++++++++++++++++++++
4303
4302
  // Single selection
4304
4303
  // ++++++++++++++++++++
4305
- if (typeof defaultValue === 'undefined' || defaultValue === '') {
4304
+ if (!chkValueExist(defaultValue)) {
4306
4305
  // Do not use `init`, otherwise the query will revert to the default value if there is no value
4307
4306
  setControlValue('');
4308
4307
  setControlLabel('');
4309
4308
  } else {
4310
- if (_filterRes3.length > 0) {
4311
- setControlValue(_filterRes3[0].value);
4312
- setControlLabel(formatIndentVal(_filterRes3[0].label, INDENT_LAST_PLACEHOLDER));
4309
+ if (_filterRes2.length > 0) {
4310
+ setControlValue(_filterRes2[0].value);
4311
+ setControlLabel(formatIndentVal(_filterRes2[0].label, INDENT_LAST_PLACEHOLDER));
4313
4312
  }
4314
4313
  }
4315
4314
 
@@ -4317,42 +4316,34 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
4317
4316
  // Multiple selection
4318
4317
  // ++++++++++++++++++++
4319
4318
  if (MULTI_SEL_VALID) {
4320
- if ((typeof defaultValue === 'undefined' || defaultValue === '') && init) {
4319
+ if (!chkValueExist(defaultValue) && init) {
4321
4320
  setControlArr({
4322
4321
  labels: [],
4323
4322
  values: []
4324
4323
  });
4325
4324
  }
4326
- if (typeof defaultValue !== 'undefined' && defaultValue !== '' && (multiSelect === null || multiSelect === void 0 ? void 0 : multiSelect.data) !== null) {
4325
+ if (chkValueExist(defaultValue) && (multiSelect === null || multiSelect === void 0 ? void 0 : multiSelect.data) !== null) {
4327
4326
  // initialize default values of Multiple selection
4328
4327
  _currentData2 = multiSelect === null || multiSelect === void 0 ? void 0 : multiSelect.data;
4329
- setControlArr({
4330
- labels: _currentData2.labels,
4331
- values: _currentData2.values
4332
- });
4333
-
4334
- //
4335
- _values3 = typeof defaultValue !== 'undefined' ? VALUE_BY_BRACKETS ? (0,extract.extractContentsOfBrackets)(defaultValue) : defaultValue.split(',') : [];
4328
+ _tempLabels2 = _toConsumableArray(_currentData2.labels);
4329
+ _tempValues2 = _toConsumableArray(_currentData2.values);
4330
+ _values3 = VALUE_BY_BRACKETS ? (0,extract.extractContentsOfBrackets)(defaultValue) : defaultValue.split(',');
4336
4331
  _values3.forEach(function (_value, _index) {
4337
4332
  if (!multiSelControlOptionExist(_currentData2.values, _value) && typeof _currentData2.values[_index] !== 'undefined') {
4338
- var _filterRes4 = [];
4339
- _filterRes4 = [{
4340
- value: _currentData2.values[_index],
4341
- label: _currentData2.labels[_index],
4342
- queryString: _currentData2.queryStrings[_index]
4343
- }];
4344
- setControlArr(function (prevState) {
4345
- return {
4346
- labels: unique([].concat(_toConsumableArray(prevState.labels), [typeof _filterRes4[0] !== 'undefined' ? _filterRes4[0].label : '']).filter(function (v) {
4347
- return v !== '';
4348
- })),
4349
- values: unique([].concat(_toConsumableArray(prevState.values), [typeof _filterRes4[0] !== 'undefined' ? _filterRes4[0].value : '']).filter(function (v) {
4350
- return v !== '';
4351
- }))
4352
- };
4353
- });
4333
+ _tempLabels2.push(_currentData2.labels[_index]);
4334
+ _tempValues2.push(_currentData2.values[_index]);
4354
4335
  }
4355
4336
  });
4337
+ _tempLabels2 = unique(_tempLabels2.filter(function (v) {
4338
+ return v !== '';
4339
+ }));
4340
+ _tempValues2 = unique(_tempValues2.filter(function (v) {
4341
+ return v !== '';
4342
+ }));
4343
+ setControlArr({
4344
+ labels: _tempLabels2,
4345
+ values: _tempValues2
4346
+ });
4356
4347
  }
4357
4348
 
4358
4349
  // Appropriate multi-item container height
@@ -5248,25 +5239,18 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
5248
5239
  while (1) switch (_context4.prev = _context4.next) {
5249
5240
  case 0:
5250
5241
  inputVal = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : null;
5251
- if (!MANUAL_REQ) {
5252
- _context4.next = 3;
5253
- break;
5254
- }
5255
- return _context4.abrupt("return", []);
5256
- case 3:
5257
- //
5258
5242
  _oparams = fetchFuncMethodParams || [];
5259
5243
  _params = _oparams.map(function (item) {
5260
5244
  return item !== '$QUERY_STRING' ? item : MANUAL_REQ ? QUERY_STRING_PLACEHOLDER : '';
5261
5245
  });
5262
- _context4.next = 7;
5246
+ _context4.next = 5;
5263
5247
  return fetchData(_params.join(','), finalRes(inputVal), inputVal);
5264
- case 7:
5248
+ case 5:
5265
5249
  res = _context4.sent;
5266
5250
  // Set an identifier indicating that the first request has been completed
5267
5251
  if (!handleFirstFetchCompleted) setHandleFirstFetchCompleted(true);
5268
5252
  return _context4.abrupt("return", res);
5269
- case 10:
5253
+ case 8:
5270
5254
  case "end":
5271
5255
  return _context4.stop();
5272
5256
  }
@@ -5491,13 +5475,43 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
5491
5475
  //--------------
5492
5476
  if (FIRST_REQUEST_AUTO) {
5493
5477
  handleFirstFetch(value);
5478
+ } else {
5479
+ if (MULTI_SEL_VALID) {
5480
+ // Appropriate multi-item container height
5481
+ setTimeout(function () {
5482
+ adjustMultiControlContainerHeight();
5483
+ }, 0);
5484
+ }
5494
5485
  }
5495
5486
 
5496
5487
  // Forced assignment does not depend on "fetch" or "firstRequestAutoExe"
5497
5488
  // Don't use "value.value && value.label" directly, if it is empty, it will be treated as FALSE
5498
- if (value && _typeof(value) === 'object') {
5499
- if (typeof value.value !== 'undefined' && value.value !== null) setControlValue(value.value);
5500
- if (typeof value.label !== 'undefined' && value.label !== null) setControlLabel(formatIndentVal(value.label, INDENT_LAST_PLACEHOLDER));
5489
+ if (chkValueExist(value)) {
5490
+ if (_typeof(value) === 'object') {
5491
+ // Single selection
5492
+ if (typeof value.value !== 'undefined' && value.value !== null) setControlValue(value.value);
5493
+ if (typeof value.label !== 'undefined' && value.label !== null) setControlLabel(formatIndentVal(value.label, INDENT_LAST_PLACEHOLDER));
5494
+ }
5495
+ if (_typeof(multiSelect === null || multiSelect === void 0 ? void 0 : multiSelect.data) === 'object' && MULTI_SEL_VALID) {
5496
+ // Multiple selection
5497
+ if (chkValueExist(value) && (multiSelect === null || multiSelect === void 0 ? void 0 : multiSelect.data) !== null) {
5498
+ // initialize default values of Multiple selection
5499
+ var _currentData = multiSelect === null || multiSelect === void 0 ? void 0 : multiSelect.data;
5500
+ setControlArr({
5501
+ labels: _currentData.labels,
5502
+ values: _currentData.values
5503
+ });
5504
+ }
5505
+ }
5506
+ } else {
5507
+ if (!FIRST_REQUEST_AUTO) {
5508
+ setControlValue('');
5509
+ setControlLabel('');
5510
+ setControlArr({
5511
+ labels: [],
5512
+ values: []
5513
+ });
5514
+ }
5501
5515
  }
5502
5516
 
5503
5517
  //
@@ -5520,6 +5534,13 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
5520
5534
  //--------------
5521
5535
  if (FIRST_REQUEST_AUTO) {
5522
5536
  handleFirstFetch(defaultValue);
5537
+ } else {
5538
+ if (MULTI_SEL_VALID) {
5539
+ // Appropriate multi-item container height
5540
+ setTimeout(function () {
5541
+ adjustMultiControlContainerHeight();
5542
+ }, 0);
5543
+ }
5523
5544
  }
5524
5545
  }
5525
5546
  }, []);
@@ -3913,6 +3913,9 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
3913
3913
  _useState26 = _slicedToArray(_useState25, 2),
3914
3914
  controlArr = _useState26[0],
3915
3915
  setControlArr = _useState26[1];
3916
+ function chkValueExist(v) {
3917
+ return typeof v !== 'undefined' && v !== '';
3918
+ }
3916
3919
  var listContainerHeightLimit = function listContainerHeightLimit(num) {
3917
3920
  var res = num;
3918
3921
  if (res > LIST_CONTAINER_MAX_HEIGHT) res = LIST_CONTAINER_MAX_HEIGHT;
@@ -4110,11 +4113,15 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
4110
4113
  filterResQueryValue,
4111
4114
  filterResQueryLabel,
4112
4115
  _currentData,
4116
+ _tempLabels,
4117
+ _tempValues,
4113
4118
  _values,
4114
- _filterRes3,
4119
+ _filterRes2,
4115
4120
  _filterResQueryValue,
4116
4121
  _filterResQueryLabel,
4117
4122
  _currentData2,
4123
+ _tempLabels2,
4124
+ _tempValues2,
4118
4125
  _values3,
4119
4126
  _args = arguments;
4120
4127
  return _regeneratorRuntime().wrap(function _callee$(_context) {
@@ -4187,7 +4194,7 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
4187
4194
  // ++++++++++++++++++++
4188
4195
  // Single selection
4189
4196
  // ++++++++++++++++++++
4190
- if (typeof defaultValue === 'undefined' || defaultValue === '') {
4197
+ if (!chkValueExist(defaultValue)) {
4191
4198
  // Do not use `init`, otherwise the query will revert to the default value if there is no value
4192
4199
  setControlValue('');
4193
4200
  setControlLabel('');
@@ -4202,42 +4209,34 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
4202
4209
  // Multiple selection
4203
4210
  // ++++++++++++++++++++
4204
4211
  if (MULTI_SEL_VALID) {
4205
- if ((typeof defaultValue === 'undefined' || defaultValue === '') && init) {
4212
+ if (!chkValueExist(defaultValue) && init) {
4206
4213
  setControlArr({
4207
4214
  labels: [],
4208
4215
  values: []
4209
4216
  });
4210
4217
  }
4211
- if (typeof defaultValue !== 'undefined' && defaultValue !== '' && (multiSelect === null || multiSelect === void 0 ? void 0 : multiSelect.data) !== null) {
4218
+ if (chkValueExist(defaultValue) && (multiSelect === null || multiSelect === void 0 ? void 0 : multiSelect.data) !== null) {
4212
4219
  // initialize default values of Multiple selection
4213
4220
  _currentData = multiSelect === null || multiSelect === void 0 ? void 0 : multiSelect.data;
4214
- setControlArr({
4215
- labels: _currentData.labels,
4216
- values: _currentData.values
4217
- });
4218
-
4219
- //
4221
+ _tempLabels = _toConsumableArray(_currentData.labels);
4222
+ _tempValues = _toConsumableArray(_currentData.values);
4220
4223
  _values = VALUE_BY_BRACKETS ? (0,extract.extractContentsOfBrackets)(defaultValue) : defaultValue.split(',');
4221
4224
  _values.forEach(function (_value, _index) {
4222
4225
  if (!multiSelControlOptionExist(_currentData.values, _value) && typeof _currentData.values[_index] !== 'undefined') {
4223
- var _filterRes2 = [];
4224
- _filterRes2 = [{
4225
- value: _currentData.values[_index],
4226
- label: _currentData.labels[_index],
4227
- queryString: _currentData.queryStrings[_index]
4228
- }];
4229
- setControlArr(function (prevState) {
4230
- return {
4231
- labels: unique([].concat(_toConsumableArray(prevState.labels), [typeof _filterRes2[0] !== 'undefined' ? _filterRes2[0].label : '']).filter(function (v) {
4232
- return v !== '';
4233
- })),
4234
- values: unique([].concat(_toConsumableArray(prevState.values), [typeof _filterRes2[0] !== 'undefined' ? _filterRes2[0].value : '']).filter(function (v) {
4235
- return v !== '';
4236
- }))
4237
- };
4238
- });
4226
+ _tempLabels.push(_currentData.labels[_index]);
4227
+ _tempValues.push(_currentData.values[_index]);
4239
4228
  }
4240
4229
  });
4230
+ _tempLabels = unique(_tempLabels.filter(function (v) {
4231
+ return v !== '';
4232
+ }));
4233
+ _tempValues = unique(_tempValues.filter(function (v) {
4234
+ return v !== '';
4235
+ }));
4236
+ setControlArr({
4237
+ labels: _tempLabels,
4238
+ values: _tempValues
4239
+ });
4241
4240
  }
4242
4241
 
4243
4242
  // Appropriate multi-item container height
@@ -4283,33 +4282,33 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
4283
4282
  // value & label must be initialized
4284
4283
 
4285
4284
  // If the default value is label, match value
4286
- _filterRes3 = [];
4285
+ _filterRes2 = [];
4287
4286
  _filterResQueryValue = staticOptionsData.filter(function (item) {
4288
4287
  return item.value == defaultValue;
4289
4288
  });
4290
4289
  _filterResQueryLabel = staticOptionsData.filter(function (item) {
4291
4290
  return item.label == defaultValue;
4292
4291
  });
4293
- _filterRes3 = _filterResQueryValue;
4294
- if (_filterResQueryValue.length === 0) _filterRes3 = _filterResQueryLabel;
4292
+ _filterRes2 = _filterResQueryValue;
4293
+ if (_filterResQueryValue.length === 0) _filterRes2 = _filterResQueryLabel;
4295
4294
 
4296
4295
  // if the default value is Object
4297
- if (isObject(inputDefault) && _filterRes3.length === 0) {
4298
- _filterRes3 = [inputDefault];
4296
+ if (isObject(inputDefault) && _filterRes2.length === 0) {
4297
+ _filterRes2 = [inputDefault];
4299
4298
  }
4300
4299
 
4301
4300
  // STEP 4: ===========
4302
4301
  // ++++++++++++++++++++
4303
4302
  // Single selection
4304
4303
  // ++++++++++++++++++++
4305
- if (typeof defaultValue === 'undefined' || defaultValue === '') {
4304
+ if (!chkValueExist(defaultValue)) {
4306
4305
  // Do not use `init`, otherwise the query will revert to the default value if there is no value
4307
4306
  setControlValue('');
4308
4307
  setControlLabel('');
4309
4308
  } else {
4310
- if (_filterRes3.length > 0) {
4311
- setControlValue(_filterRes3[0].value);
4312
- setControlLabel(formatIndentVal(_filterRes3[0].label, INDENT_LAST_PLACEHOLDER));
4309
+ if (_filterRes2.length > 0) {
4310
+ setControlValue(_filterRes2[0].value);
4311
+ setControlLabel(formatIndentVal(_filterRes2[0].label, INDENT_LAST_PLACEHOLDER));
4313
4312
  }
4314
4313
  }
4315
4314
 
@@ -4317,42 +4316,34 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
4317
4316
  // Multiple selection
4318
4317
  // ++++++++++++++++++++
4319
4318
  if (MULTI_SEL_VALID) {
4320
- if ((typeof defaultValue === 'undefined' || defaultValue === '') && init) {
4319
+ if (!chkValueExist(defaultValue) && init) {
4321
4320
  setControlArr({
4322
4321
  labels: [],
4323
4322
  values: []
4324
4323
  });
4325
4324
  }
4326
- if (typeof defaultValue !== 'undefined' && defaultValue !== '' && (multiSelect === null || multiSelect === void 0 ? void 0 : multiSelect.data) !== null) {
4325
+ if (chkValueExist(defaultValue) && (multiSelect === null || multiSelect === void 0 ? void 0 : multiSelect.data) !== null) {
4327
4326
  // initialize default values of Multiple selection
4328
4327
  _currentData2 = multiSelect === null || multiSelect === void 0 ? void 0 : multiSelect.data;
4329
- setControlArr({
4330
- labels: _currentData2.labels,
4331
- values: _currentData2.values
4332
- });
4333
-
4334
- //
4335
- _values3 = typeof defaultValue !== 'undefined' ? VALUE_BY_BRACKETS ? (0,extract.extractContentsOfBrackets)(defaultValue) : defaultValue.split(',') : [];
4328
+ _tempLabels2 = _toConsumableArray(_currentData2.labels);
4329
+ _tempValues2 = _toConsumableArray(_currentData2.values);
4330
+ _values3 = VALUE_BY_BRACKETS ? (0,extract.extractContentsOfBrackets)(defaultValue) : defaultValue.split(',');
4336
4331
  _values3.forEach(function (_value, _index) {
4337
4332
  if (!multiSelControlOptionExist(_currentData2.values, _value) && typeof _currentData2.values[_index] !== 'undefined') {
4338
- var _filterRes4 = [];
4339
- _filterRes4 = [{
4340
- value: _currentData2.values[_index],
4341
- label: _currentData2.labels[_index],
4342
- queryString: _currentData2.queryStrings[_index]
4343
- }];
4344
- setControlArr(function (prevState) {
4345
- return {
4346
- labels: unique([].concat(_toConsumableArray(prevState.labels), [typeof _filterRes4[0] !== 'undefined' ? _filterRes4[0].label : '']).filter(function (v) {
4347
- return v !== '';
4348
- })),
4349
- values: unique([].concat(_toConsumableArray(prevState.values), [typeof _filterRes4[0] !== 'undefined' ? _filterRes4[0].value : '']).filter(function (v) {
4350
- return v !== '';
4351
- }))
4352
- };
4353
- });
4333
+ _tempLabels2.push(_currentData2.labels[_index]);
4334
+ _tempValues2.push(_currentData2.values[_index]);
4354
4335
  }
4355
4336
  });
4337
+ _tempLabels2 = unique(_tempLabels2.filter(function (v) {
4338
+ return v !== '';
4339
+ }));
4340
+ _tempValues2 = unique(_tempValues2.filter(function (v) {
4341
+ return v !== '';
4342
+ }));
4343
+ setControlArr({
4344
+ labels: _tempLabels2,
4345
+ values: _tempValues2
4346
+ });
4356
4347
  }
4357
4348
 
4358
4349
  // Appropriate multi-item container height
@@ -5248,25 +5239,18 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
5248
5239
  while (1) switch (_context4.prev = _context4.next) {
5249
5240
  case 0:
5250
5241
  inputVal = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : null;
5251
- if (!MANUAL_REQ) {
5252
- _context4.next = 3;
5253
- break;
5254
- }
5255
- return _context4.abrupt("return", []);
5256
- case 3:
5257
- //
5258
5242
  _oparams = fetchFuncMethodParams || [];
5259
5243
  _params = _oparams.map(function (item) {
5260
5244
  return item !== '$QUERY_STRING' ? item : MANUAL_REQ ? QUERY_STRING_PLACEHOLDER : '';
5261
5245
  });
5262
- _context4.next = 7;
5246
+ _context4.next = 5;
5263
5247
  return fetchData(_params.join(','), finalRes(inputVal), inputVal);
5264
- case 7:
5248
+ case 5:
5265
5249
  res = _context4.sent;
5266
5250
  // Set an identifier indicating that the first request has been completed
5267
5251
  if (!handleFirstFetchCompleted) setHandleFirstFetchCompleted(true);
5268
5252
  return _context4.abrupt("return", res);
5269
- case 10:
5253
+ case 8:
5270
5254
  case "end":
5271
5255
  return _context4.stop();
5272
5256
  }
@@ -5491,13 +5475,43 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
5491
5475
  //--------------
5492
5476
  if (FIRST_REQUEST_AUTO) {
5493
5477
  handleFirstFetch(value);
5478
+ } else {
5479
+ if (MULTI_SEL_VALID) {
5480
+ // Appropriate multi-item container height
5481
+ setTimeout(function () {
5482
+ adjustMultiControlContainerHeight();
5483
+ }, 0);
5484
+ }
5494
5485
  }
5495
5486
 
5496
5487
  // Forced assignment does not depend on "fetch" or "firstRequestAutoExe"
5497
5488
  // Don't use "value.value && value.label" directly, if it is empty, it will be treated as FALSE
5498
- if (value && _typeof(value) === 'object') {
5499
- if (typeof value.value !== 'undefined' && value.value !== null) setControlValue(value.value);
5500
- if (typeof value.label !== 'undefined' && value.label !== null) setControlLabel(formatIndentVal(value.label, INDENT_LAST_PLACEHOLDER));
5489
+ if (chkValueExist(value)) {
5490
+ if (_typeof(value) === 'object') {
5491
+ // Single selection
5492
+ if (typeof value.value !== 'undefined' && value.value !== null) setControlValue(value.value);
5493
+ if (typeof value.label !== 'undefined' && value.label !== null) setControlLabel(formatIndentVal(value.label, INDENT_LAST_PLACEHOLDER));
5494
+ }
5495
+ if (_typeof(multiSelect === null || multiSelect === void 0 ? void 0 : multiSelect.data) === 'object' && MULTI_SEL_VALID) {
5496
+ // Multiple selection
5497
+ if (chkValueExist(value) && (multiSelect === null || multiSelect === void 0 ? void 0 : multiSelect.data) !== null) {
5498
+ // initialize default values of Multiple selection
5499
+ var _currentData = multiSelect === null || multiSelect === void 0 ? void 0 : multiSelect.data;
5500
+ setControlArr({
5501
+ labels: _currentData.labels,
5502
+ values: _currentData.values
5503
+ });
5504
+ }
5505
+ }
5506
+ } else {
5507
+ if (!FIRST_REQUEST_AUTO) {
5508
+ setControlValue('');
5509
+ setControlLabel('');
5510
+ setControlArr({
5511
+ labels: [],
5512
+ values: []
5513
+ });
5514
+ }
5501
5515
  }
5502
5516
 
5503
5517
  //
@@ -5520,6 +5534,13 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
5520
5534
  //--------------
5521
5535
  if (FIRST_REQUEST_AUTO) {
5522
5536
  handleFirstFetch(defaultValue);
5537
+ } else {
5538
+ if (MULTI_SEL_VALID) {
5539
+ // Appropriate multi-item container height
5540
+ setTimeout(function () {
5541
+ adjustMultiControlContainerHeight();
5542
+ }, 0);
5543
+ }
5523
5544
  }
5524
5545
  }
5525
5546
  }, []);
@@ -303,6 +303,11 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
303
303
  values: []
304
304
  });
305
305
 
306
+ function chkValueExist(v: any) {
307
+ return typeof v !== 'undefined' && v !== '';
308
+ }
309
+
310
+
306
311
  const listContainerHeightLimit = (num: number) => {
307
312
  let res = num;
308
313
  if (res > LIST_CONTAINER_MAX_HEIGHT) res = LIST_CONTAINER_MAX_HEIGHT;
@@ -515,7 +520,6 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
515
520
  // Determine whether the default value is user query input or default input
516
521
  const defaultValue = init ? valueToInputDefault : '';
517
522
 
518
-
519
523
  if (typeof fetchFuncAsync === 'object') {
520
524
 
521
525
 
@@ -555,7 +559,6 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
555
559
  // value & label must be initialized
556
560
  let filterRes: any = [];
557
561
 
558
-
559
562
  if (MANUAL_REQ) {
560
563
 
561
564
  // If a manual action is used to trigger the request
@@ -583,13 +586,12 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
583
586
 
584
587
  }
585
588
 
586
-
587
589
 
588
590
  // STEP 4: ===========
589
591
  // ++++++++++++++++++++
590
592
  // Single selection
591
593
  // ++++++++++++++++++++
592
- if (typeof defaultValue === 'undefined' || defaultValue === '') { // Do not use `init`, otherwise the query will revert to the default value if there is no value
594
+ if (!chkValueExist(defaultValue)) { // Do not use `init`, otherwise the query will revert to the default value if there is no value
593
595
  setControlValue('');
594
596
  setControlLabel('');
595
597
  } else {
@@ -607,7 +609,7 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
607
609
  if (MULTI_SEL_VALID) {
608
610
 
609
611
 
610
- if ((typeof defaultValue === 'undefined' || defaultValue === '') && init) {
612
+ if (!chkValueExist(defaultValue) && init) {
611
613
  setControlArr({
612
614
  labels: [],
613
615
  values: []
@@ -616,42 +618,30 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
616
618
 
617
619
 
618
620
 
619
- if (typeof defaultValue !== 'undefined' && defaultValue !== '' && multiSelect?.data !== null) {
621
+ if (chkValueExist(defaultValue) && multiSelect?.data !== null) {
620
622
 
621
623
  // initialize default values of Multiple selection
622
624
  const _currentData: any = multiSelect?.data;
623
625
 
624
- setControlArr({
625
- labels: _currentData.labels,
626
- values: _currentData.values,
627
- });
626
+ let _tempLabels = [..._currentData.labels];
627
+ let _tempValues = [..._currentData.values];
628
628
 
629
- //
630
629
  const _values: string[] = VALUE_BY_BRACKETS ? extractContentsOfBrackets(defaultValue) : defaultValue.split(',');
631
630
 
632
-
633
631
  _values.forEach((_value: string, _index: number) => {
634
-
635
632
  if (!multiSelControlOptionExist(_currentData.values, _value) && typeof _currentData.values[_index] !== 'undefined') {
636
-
637
- let filterRes: any = [];
638
- filterRes = [{
639
- value: _currentData.values[_index],
640
- label: _currentData.labels[_index],
641
- queryString: _currentData.queryStrings[_index]
642
- }];
643
-
644
- setControlArr((prevState: any) => {
645
- return {
646
- labels: unique([...prevState.labels, typeof filterRes[0] !== 'undefined' ? filterRes[0].label : ''].filter((v: any) => v !== '')),
647
- values: unique([...prevState.values, typeof filterRes[0] !== 'undefined' ? filterRes[0].value : ''].filter((v: any) => v !== ''))
648
- }
649
- });
650
-
633
+ _tempLabels.push(_currentData.labels[_index]);
634
+ _tempValues.push(_currentData.values[_index]);
651
635
  }
652
-
653
636
  });
654
637
 
638
+ _tempLabels = unique(_tempLabels.filter((v: any) => v !== ''));
639
+ _tempValues = unique(_tempValues.filter((v: any) => v !== ''));
640
+
641
+ setControlArr({
642
+ labels: _tempLabels,
643
+ values: _tempValues,
644
+ });
655
645
 
656
646
  }
657
647
 
@@ -727,7 +717,7 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
727
717
  // ++++++++++++++++++++
728
718
  // Single selection
729
719
  // ++++++++++++++++++++
730
- if (typeof defaultValue === 'undefined' || defaultValue === '') { // Do not use `init`, otherwise the query will revert to the default value if there is no value
720
+ if (!chkValueExist(defaultValue)) { // Do not use `init`, otherwise the query will revert to the default value if there is no value
731
721
  setControlValue('');
732
722
  setControlLabel('');
733
723
  } else {
@@ -746,46 +736,36 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
746
736
  if (MULTI_SEL_VALID) {
747
737
 
748
738
 
749
- if ((typeof defaultValue === 'undefined' || defaultValue === '') && init) {
739
+ if (!chkValueExist(defaultValue) && init) {
750
740
  setControlArr({
751
741
  labels: [],
752
742
  values: []
753
743
  });
754
744
  }
755
745
 
756
- if (typeof defaultValue !== 'undefined' && defaultValue !== '' && multiSelect?.data !== null) {
746
+ if (chkValueExist(defaultValue) && multiSelect?.data !== null) {
757
747
 
758
748
  // initialize default values of Multiple selection
759
749
  const _currentData: any = multiSelect?.data;
760
750
 
761
- setControlArr({
762
- labels: _currentData.labels,
763
- values: _currentData.values,
764
- });
751
+ let _tempLabels = [..._currentData.labels];
752
+ let _tempValues = [..._currentData.values];
765
753
 
766
- //
767
- const _values: string[] = typeof defaultValue !== 'undefined' ? (VALUE_BY_BRACKETS ? extractContentsOfBrackets(defaultValue) : defaultValue.split(',')) : [];
768
- _values.forEach((_value: string, _index: number) => {
754
+ const _values: string[] = VALUE_BY_BRACKETS ? extractContentsOfBrackets(defaultValue) : defaultValue.split(',');
769
755
 
756
+ _values.forEach((_value: string, _index: number) => {
770
757
  if (!multiSelControlOptionExist(_currentData.values, _value) && typeof _currentData.values[_index] !== 'undefined') {
758
+ _tempLabels.push(_currentData.labels[_index]);
759
+ _tempValues.push(_currentData.values[_index]);
760
+ }
761
+ });
771
762
 
763
+ _tempLabels = unique(_tempLabels.filter((v: any) => v !== ''));
764
+ _tempValues = unique(_tempValues.filter((v: any) => v !== ''));
772
765
 
773
- let filterRes: any = [];
774
- filterRes = [{
775
- value: _currentData.values[_index],
776
- label: _currentData.labels[_index],
777
- queryString: _currentData.queryStrings[_index]
778
- }];
779
-
780
- setControlArr((prevState: any) => {
781
- return {
782
- labels: unique([...prevState.labels, typeof filterRes[0] !== 'undefined' ? filterRes[0].label : ''].filter((v: any) => v !== '')),
783
- values: unique([...prevState.values, typeof filterRes[0] !== 'undefined' ? filterRes[0].value : ''].filter((v: any) => v !== ''))
784
- }
785
- });
786
-
787
-
788
- }
766
+ setControlArr({
767
+ labels: _tempLabels,
768
+ values: _tempValues,
789
769
  });
790
770
  }
791
771
 
@@ -1848,10 +1828,6 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
1848
1828
 
1849
1829
  async function handleFirstFetch(inputVal: any = null) {
1850
1830
 
1851
- // If manual requests are enabled, do not send them for the first time
1852
- if (MANUAL_REQ) return [];
1853
-
1854
- //
1855
1831
  const _oparams: any[] = fetchFuncMethodParams || [];
1856
1832
  const _params: any[] = _oparams.map((item: any) => item !== '$QUERY_STRING' ? item : (MANUAL_REQ ? QUERY_STRING_PLACEHOLDER : ''));
1857
1833
  const res = await fetchData((_params).join(','), finalRes(inputVal), inputVal);
@@ -2103,16 +2079,51 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
2103
2079
  //--------------
2104
2080
  if (FIRST_REQUEST_AUTO) {
2105
2081
  handleFirstFetch(value);
2082
+ } else {
2083
+ if (MULTI_SEL_VALID) {
2084
+ // Appropriate multi-item container height
2085
+ setTimeout(() => {
2086
+ adjustMultiControlContainerHeight();
2087
+ }, 0);
2088
+ }
2106
2089
  }
2107
2090
 
2108
2091
  // Forced assignment does not depend on "fetch" or "firstRequestAutoExe"
2109
2092
  // Don't use "value.value && value.label" directly, if it is empty, it will be treated as FALSE
2110
- if ( value && typeof value === 'object' ) {
2111
- if (typeof value.value !== 'undefined' && value.value !== null) setControlValue(value.value as string);
2112
- if (typeof value.label !== 'undefined' && value.label !== null) setControlLabel(formatIndentVal(value.label, INDENT_LAST_PLACEHOLDER));
2093
+ if (chkValueExist(value)) {
2094
+ if (typeof value === 'object') { // Single selection
2095
+ if (typeof value.value !== 'undefined' && value.value !== null) setControlValue(value.value as string);
2096
+ if (typeof value.label !== 'undefined' && value.label !== null) setControlLabel(formatIndentVal(value.label, INDENT_LAST_PLACEHOLDER));
2097
+ }
2098
+
2099
+ if ( typeof multiSelect?.data === 'object' && MULTI_SEL_VALID) { // Multiple selection
2100
+ if (chkValueExist(value) && multiSelect?.data !== null) {
2101
+
2102
+ // initialize default values of Multiple selection
2103
+ const _currentData: any = multiSelect?.data;
2104
+
2105
+ setControlArr({
2106
+ labels: _currentData.labels,
2107
+ values: _currentData.values,
2108
+ });
2109
+ }
2110
+ }
2111
+
2112
+ } else {
2113
+ if (!FIRST_REQUEST_AUTO) {
2114
+ setControlValue('');
2115
+ setControlLabel('');
2116
+ setControlArr({
2117
+ labels: [],
2118
+ values: []
2119
+ });
2120
+ }
2113
2121
  }
2114
2122
 
2115
2123
 
2124
+
2125
+
2126
+
2116
2127
  //
2117
2128
  //--------------
2118
2129
  return () => {
@@ -2137,6 +2148,13 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
2137
2148
  //--------------
2138
2149
  if (FIRST_REQUEST_AUTO) {
2139
2150
  handleFirstFetch(defaultValue);
2151
+ } else {
2152
+ if (MULTI_SEL_VALID) {
2153
+ // Appropriate multi-item container height
2154
+ setTimeout(() => {
2155
+ adjustMultiControlContainerHeight();
2156
+ }, 0);
2157
+ }
2140
2158
  }
2141
2159
 
2142
2160
  }
@@ -2144,7 +2162,6 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
2144
2162
  }, []);
2145
2163
 
2146
2164
 
2147
-
2148
2165
  // Fixed an out-of-focus issue
2149
2166
  //--------------
2150
2167
  // !!! TIPS:
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "author": "UIUX Lab",
3
3
  "email": "uiuxlab@gmail.com",
4
4
  "name": "funda-ui",
5
- "version": "4.7.161",
5
+ "version": "4.7.163",
6
6
  "description": "React components using pure Bootstrap 5+ which does not contain any external style and script libraries.",
7
7
  "repository": {
8
8
  "type": "git",