funda-ui 4.7.185 → 4.7.190
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/MultipleCheckboxes/index.d.ts +6 -5
- package/MultipleCheckboxes/index.js +18 -6
- package/Select/index.js +2 -2
- package/lib/cjs/MultipleCheckboxes/index.d.ts +6 -5
- package/lib/cjs/MultipleCheckboxes/index.js +18 -6
- package/lib/cjs/Select/index.js +2 -2
- package/lib/esm/MultipleCheckboxes/index.tsx +43 -16
- package/lib/esm/Select/index.tsx +2 -3
- package/package.json +1 -1
|
@@ -21,7 +21,7 @@ export interface CustomOptionsItemsListParams {
|
|
|
21
21
|
convertArrToValByBrackets: (arr: string[]) => string;
|
|
22
22
|
isAllSelected: boolean;
|
|
23
23
|
handleSelectAll: () => void;
|
|
24
|
-
onChange?: (e:
|
|
24
|
+
onChange?: (e: React.ChangeEvent<HTMLInputElement> | null, value: string[] | null, valueStr: string, label: string[] | null, labelStr: string, currentData: OptionConfig | null, dataCollection: OptionConfig[]) => void;
|
|
25
25
|
attributes: React.HTMLAttributes<HTMLInputElement>;
|
|
26
26
|
}
|
|
27
27
|
export declare type MultipleCheckboxesProps = {
|
|
@@ -43,6 +43,7 @@ export declare type MultipleCheckboxesProps = {
|
|
|
43
43
|
required?: any;
|
|
44
44
|
showSelectAll?: boolean;
|
|
45
45
|
selectAllLabel?: string;
|
|
46
|
+
singleSelect?: boolean;
|
|
46
47
|
/** Whether to use square brackets to save result and initialize default value */
|
|
47
48
|
extractValueByBrackets?: boolean;
|
|
48
49
|
/** -- */
|
|
@@ -55,10 +56,10 @@ export declare type MultipleCheckboxesProps = {
|
|
|
55
56
|
fetchFuncAsync?: any;
|
|
56
57
|
fetchFuncMethod?: string;
|
|
57
58
|
fetchFuncMethodParams?: any[];
|
|
58
|
-
fetchCallback?: (data:
|
|
59
|
-
onFetch?: (data:
|
|
60
|
-
onLoad?: (
|
|
61
|
-
onChange?: (e:
|
|
59
|
+
fetchCallback?: (data: OptionConfig[]) => OptionConfig[];
|
|
60
|
+
onFetch?: (data: OptionConfig[]) => void;
|
|
61
|
+
onLoad?: (latestData: OptionConfig[], defaultValue: string | string[], rootElement: HTMLDivElement | HTMLTableElement | null) => void;
|
|
62
|
+
onChange?: (e: React.ChangeEvent<HTMLInputElement> | null, value: string[] | null, valueStr: string, label: string[] | null, labelStr: string, currentData: OptionConfig | null, dataCollection: OptionConfig[]) => void;
|
|
62
63
|
onCallbackListItem?: (optiondata: any) => void;
|
|
63
64
|
};
|
|
64
65
|
declare const MultipleCheckboxes: React.ForwardRefExoticComponent<MultipleCheckboxesProps & React.RefAttributes<unknown>>;
|
|
@@ -1183,7 +1183,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1183
1183
|
/* harmony import */ var funda_utils_dist_cjs_object__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(funda_utils_dist_cjs_object__WEBPACK_IMPORTED_MODULE_5__);
|
|
1184
1184
|
/* harmony import */ var funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(188);
|
|
1185
1185
|
/* harmony import */ var funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_6__);
|
|
1186
|
-
var _excluded = ["contentRef", "wrapperClassName", "controlClassName", "tableLayout", "tableLayoutClassName", "tableLayoutCellClassName", "groupWrapperClassName", "groupLabelClassName", "inline", "options", "disabled", "required", "defaultValue", "value", "label", "name", "id", "showSelectAll", "selectAllLabel", "extractValueByBrackets", "style", "fetchFuncAsync", "fetchFuncMethod", "fetchFuncMethodParams", "fetchCallback", "onFetch", "onLoad", "onChange", "onCallbackListItem"];
|
|
1186
|
+
var _excluded = ["contentRef", "wrapperClassName", "controlClassName", "tableLayout", "tableLayoutClassName", "tableLayoutCellClassName", "groupWrapperClassName", "groupLabelClassName", "inline", "options", "disabled", "required", "defaultValue", "value", "label", "name", "id", "showSelectAll", "selectAllLabel", "singleSelect", "extractValueByBrackets", "style", "fetchFuncAsync", "fetchFuncMethod", "fetchFuncMethodParams", "fetchCallback", "onFetch", "onLoad", "onChange", "onCallbackListItem"];
|
|
1187
1187
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
1188
1188
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
1189
1189
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
@@ -1230,6 +1230,8 @@ var MultipleCheckboxes = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forw
|
|
|
1230
1230
|
showSelectAll = _props$showSelectAll === void 0 ? false : _props$showSelectAll,
|
|
1231
1231
|
_props$selectAllLabel = props.selectAllLabel,
|
|
1232
1232
|
selectAllLabel = _props$selectAllLabel === void 0 ? 'Select all' : _props$selectAllLabel,
|
|
1233
|
+
_props$singleSelect = props.singleSelect,
|
|
1234
|
+
singleSelect = _props$singleSelect === void 0 ? false : _props$singleSelect,
|
|
1233
1235
|
extractValueByBrackets = props.extractValueByBrackets,
|
|
1234
1236
|
style = props.style,
|
|
1235
1237
|
fetchFuncAsync = props.fetchFuncAsync,
|
|
@@ -1348,7 +1350,7 @@ var MultipleCheckboxes = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forw
|
|
|
1348
1350
|
clear: function clear(cb) {
|
|
1349
1351
|
initDefaultValue('', dataInit);
|
|
1350
1352
|
cb === null || cb === void 0 ? void 0 : cb();
|
|
1351
|
-
_onChange === null || _onChange === void 0 ? void 0 : _onChange(null, null, '', null,
|
|
1353
|
+
_onChange === null || _onChange === void 0 ? void 0 : _onChange(null, null, '', null, '', null, []);
|
|
1352
1354
|
},
|
|
1353
1355
|
set: function set(value, cb) {
|
|
1354
1356
|
initDefaultValue(value, dataInit);
|
|
@@ -1373,7 +1375,7 @@ var MultipleCheckboxes = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forw
|
|
|
1373
1375
|
}).join(',');
|
|
1374
1376
|
_onChange === null || _onChange === void 0 ? void 0 : _onChange(null, _value, _valueStr, _label, _labelStr, null, _resDataCollection);
|
|
1375
1377
|
} else {
|
|
1376
|
-
_onChange === null || _onChange === void 0 ? void 0 : _onChange(null, null, value
|
|
1378
|
+
_onChange === null || _onChange === void 0 ? void 0 : _onChange(null, null, value !== null && value !== void 0 ? value : '', null, '', null, []);
|
|
1377
1379
|
}
|
|
1378
1380
|
},
|
|
1379
1381
|
selectAll: function selectAll() {
|
|
@@ -1412,10 +1414,20 @@ var MultipleCheckboxes = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forw
|
|
|
1412
1414
|
function handleCheckboxChange(itemKey) {
|
|
1413
1415
|
// first, make a copy of the original set rather than mutating the original
|
|
1414
1416
|
var newSelectedItems = new Set(selectedItems);
|
|
1415
|
-
if (
|
|
1416
|
-
|
|
1417
|
+
if (singleSelect) {
|
|
1418
|
+
// If singleSelect is true, clear all selections first
|
|
1419
|
+
newSelectedItems.clear();
|
|
1420
|
+
// Only add the new selection if it wasn't already selected
|
|
1421
|
+
if (!selectedItems.has(itemKey)) {
|
|
1422
|
+
newSelectedItems.add(itemKey);
|
|
1423
|
+
}
|
|
1417
1424
|
} else {
|
|
1418
|
-
|
|
1425
|
+
// Original multi-select behavior
|
|
1426
|
+
if (!newSelectedItems.has(itemKey)) {
|
|
1427
|
+
newSelectedItems.add(itemKey);
|
|
1428
|
+
} else {
|
|
1429
|
+
newSelectedItems["delete"](itemKey);
|
|
1430
|
+
}
|
|
1419
1431
|
}
|
|
1420
1432
|
setSelectedItems(newSelectedItems);
|
|
1421
1433
|
return newSelectedItems;
|
package/Select/index.js
CHANGED
|
@@ -5280,7 +5280,7 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
5280
5280
|
// ++++++++++++++++++++
|
|
5281
5281
|
// Single selection
|
|
5282
5282
|
// ++++++++++++++++++++
|
|
5283
|
-
if (_typeof(value) === 'object' && !Array.isArray(value)) {
|
|
5283
|
+
if (_typeof(value) === 'object' && !Array.isArray(value) && value !== null) {
|
|
5284
5284
|
if (typeof value.value !== 'undefined' && value.value !== null) setControlValue(value.value);
|
|
5285
5285
|
if (typeof value.label !== 'undefined' && value.label !== null) setControlLabel(formatIndentVal(value.label, INDENT_LAST_PLACEHOLDER));
|
|
5286
5286
|
}
|
|
@@ -5352,7 +5352,7 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
5352
5352
|
// ++++++++++++++++++++
|
|
5353
5353
|
// Single selection
|
|
5354
5354
|
// ++++++++++++++++++++
|
|
5355
|
-
if (_typeof(defaultValue) === 'object' && !Array.isArray(defaultValue)) {
|
|
5355
|
+
if (_typeof(defaultValue) === 'object' && !Array.isArray(defaultValue) && defaultValue !== null) {
|
|
5356
5356
|
if (typeof defaultValue.value !== 'undefined' && defaultValue.value !== null) setControlValue(defaultValue.value);
|
|
5357
5357
|
if (typeof defaultValue.label !== 'undefined' && defaultValue.label !== null) setControlLabel(formatIndentVal(defaultValue.label, INDENT_LAST_PLACEHOLDER));
|
|
5358
5358
|
}
|
|
@@ -21,7 +21,7 @@ export interface CustomOptionsItemsListParams {
|
|
|
21
21
|
convertArrToValByBrackets: (arr: string[]) => string;
|
|
22
22
|
isAllSelected: boolean;
|
|
23
23
|
handleSelectAll: () => void;
|
|
24
|
-
onChange?: (e:
|
|
24
|
+
onChange?: (e: React.ChangeEvent<HTMLInputElement> | null, value: string[] | null, valueStr: string, label: string[] | null, labelStr: string, currentData: OptionConfig | null, dataCollection: OptionConfig[]) => void;
|
|
25
25
|
attributes: React.HTMLAttributes<HTMLInputElement>;
|
|
26
26
|
}
|
|
27
27
|
export declare type MultipleCheckboxesProps = {
|
|
@@ -43,6 +43,7 @@ export declare type MultipleCheckboxesProps = {
|
|
|
43
43
|
required?: any;
|
|
44
44
|
showSelectAll?: boolean;
|
|
45
45
|
selectAllLabel?: string;
|
|
46
|
+
singleSelect?: boolean;
|
|
46
47
|
/** Whether to use square brackets to save result and initialize default value */
|
|
47
48
|
extractValueByBrackets?: boolean;
|
|
48
49
|
/** -- */
|
|
@@ -55,10 +56,10 @@ export declare type MultipleCheckboxesProps = {
|
|
|
55
56
|
fetchFuncAsync?: any;
|
|
56
57
|
fetchFuncMethod?: string;
|
|
57
58
|
fetchFuncMethodParams?: any[];
|
|
58
|
-
fetchCallback?: (data:
|
|
59
|
-
onFetch?: (data:
|
|
60
|
-
onLoad?: (
|
|
61
|
-
onChange?: (e:
|
|
59
|
+
fetchCallback?: (data: OptionConfig[]) => OptionConfig[];
|
|
60
|
+
onFetch?: (data: OptionConfig[]) => void;
|
|
61
|
+
onLoad?: (latestData: OptionConfig[], defaultValue: string | string[], rootElement: HTMLDivElement | HTMLTableElement | null) => void;
|
|
62
|
+
onChange?: (e: React.ChangeEvent<HTMLInputElement> | null, value: string[] | null, valueStr: string, label: string[] | null, labelStr: string, currentData: OptionConfig | null, dataCollection: OptionConfig[]) => void;
|
|
62
63
|
onCallbackListItem?: (optiondata: any) => void;
|
|
63
64
|
};
|
|
64
65
|
declare const MultipleCheckboxes: React.ForwardRefExoticComponent<MultipleCheckboxesProps & React.RefAttributes<unknown>>;
|
|
@@ -1183,7 +1183,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1183
1183
|
/* harmony import */ var funda_utils_dist_cjs_object__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(funda_utils_dist_cjs_object__WEBPACK_IMPORTED_MODULE_5__);
|
|
1184
1184
|
/* harmony import */ var funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(188);
|
|
1185
1185
|
/* harmony import */ var funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_6__);
|
|
1186
|
-
var _excluded = ["contentRef", "wrapperClassName", "controlClassName", "tableLayout", "tableLayoutClassName", "tableLayoutCellClassName", "groupWrapperClassName", "groupLabelClassName", "inline", "options", "disabled", "required", "defaultValue", "value", "label", "name", "id", "showSelectAll", "selectAllLabel", "extractValueByBrackets", "style", "fetchFuncAsync", "fetchFuncMethod", "fetchFuncMethodParams", "fetchCallback", "onFetch", "onLoad", "onChange", "onCallbackListItem"];
|
|
1186
|
+
var _excluded = ["contentRef", "wrapperClassName", "controlClassName", "tableLayout", "tableLayoutClassName", "tableLayoutCellClassName", "groupWrapperClassName", "groupLabelClassName", "inline", "options", "disabled", "required", "defaultValue", "value", "label", "name", "id", "showSelectAll", "selectAllLabel", "singleSelect", "extractValueByBrackets", "style", "fetchFuncAsync", "fetchFuncMethod", "fetchFuncMethodParams", "fetchCallback", "onFetch", "onLoad", "onChange", "onCallbackListItem"];
|
|
1187
1187
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
1188
1188
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
1189
1189
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
@@ -1230,6 +1230,8 @@ var MultipleCheckboxes = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forw
|
|
|
1230
1230
|
showSelectAll = _props$showSelectAll === void 0 ? false : _props$showSelectAll,
|
|
1231
1231
|
_props$selectAllLabel = props.selectAllLabel,
|
|
1232
1232
|
selectAllLabel = _props$selectAllLabel === void 0 ? 'Select all' : _props$selectAllLabel,
|
|
1233
|
+
_props$singleSelect = props.singleSelect,
|
|
1234
|
+
singleSelect = _props$singleSelect === void 0 ? false : _props$singleSelect,
|
|
1233
1235
|
extractValueByBrackets = props.extractValueByBrackets,
|
|
1234
1236
|
style = props.style,
|
|
1235
1237
|
fetchFuncAsync = props.fetchFuncAsync,
|
|
@@ -1348,7 +1350,7 @@ var MultipleCheckboxes = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forw
|
|
|
1348
1350
|
clear: function clear(cb) {
|
|
1349
1351
|
initDefaultValue('', dataInit);
|
|
1350
1352
|
cb === null || cb === void 0 ? void 0 : cb();
|
|
1351
|
-
_onChange === null || _onChange === void 0 ? void 0 : _onChange(null, null, '', null,
|
|
1353
|
+
_onChange === null || _onChange === void 0 ? void 0 : _onChange(null, null, '', null, '', null, []);
|
|
1352
1354
|
},
|
|
1353
1355
|
set: function set(value, cb) {
|
|
1354
1356
|
initDefaultValue(value, dataInit);
|
|
@@ -1373,7 +1375,7 @@ var MultipleCheckboxes = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forw
|
|
|
1373
1375
|
}).join(',');
|
|
1374
1376
|
_onChange === null || _onChange === void 0 ? void 0 : _onChange(null, _value, _valueStr, _label, _labelStr, null, _resDataCollection);
|
|
1375
1377
|
} else {
|
|
1376
|
-
_onChange === null || _onChange === void 0 ? void 0 : _onChange(null, null, value
|
|
1378
|
+
_onChange === null || _onChange === void 0 ? void 0 : _onChange(null, null, value !== null && value !== void 0 ? value : '', null, '', null, []);
|
|
1377
1379
|
}
|
|
1378
1380
|
},
|
|
1379
1381
|
selectAll: function selectAll() {
|
|
@@ -1412,10 +1414,20 @@ var MultipleCheckboxes = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forw
|
|
|
1412
1414
|
function handleCheckboxChange(itemKey) {
|
|
1413
1415
|
// first, make a copy of the original set rather than mutating the original
|
|
1414
1416
|
var newSelectedItems = new Set(selectedItems);
|
|
1415
|
-
if (
|
|
1416
|
-
|
|
1417
|
+
if (singleSelect) {
|
|
1418
|
+
// If singleSelect is true, clear all selections first
|
|
1419
|
+
newSelectedItems.clear();
|
|
1420
|
+
// Only add the new selection if it wasn't already selected
|
|
1421
|
+
if (!selectedItems.has(itemKey)) {
|
|
1422
|
+
newSelectedItems.add(itemKey);
|
|
1423
|
+
}
|
|
1417
1424
|
} else {
|
|
1418
|
-
|
|
1425
|
+
// Original multi-select behavior
|
|
1426
|
+
if (!newSelectedItems.has(itemKey)) {
|
|
1427
|
+
newSelectedItems.add(itemKey);
|
|
1428
|
+
} else {
|
|
1429
|
+
newSelectedItems["delete"](itemKey);
|
|
1430
|
+
}
|
|
1419
1431
|
}
|
|
1420
1432
|
setSelectedItems(newSelectedItems);
|
|
1421
1433
|
return newSelectedItems;
|
package/lib/cjs/Select/index.js
CHANGED
|
@@ -5280,7 +5280,7 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
5280
5280
|
// ++++++++++++++++++++
|
|
5281
5281
|
// Single selection
|
|
5282
5282
|
// ++++++++++++++++++++
|
|
5283
|
-
if (_typeof(value) === 'object' && !Array.isArray(value)) {
|
|
5283
|
+
if (_typeof(value) === 'object' && !Array.isArray(value) && value !== null) {
|
|
5284
5284
|
if (typeof value.value !== 'undefined' && value.value !== null) setControlValue(value.value);
|
|
5285
5285
|
if (typeof value.label !== 'undefined' && value.label !== null) setControlLabel(formatIndentVal(value.label, INDENT_LAST_PLACEHOLDER));
|
|
5286
5286
|
}
|
|
@@ -5352,7 +5352,7 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
|
|
|
5352
5352
|
// ++++++++++++++++++++
|
|
5353
5353
|
// Single selection
|
|
5354
5354
|
// ++++++++++++++++++++
|
|
5355
|
-
if (_typeof(defaultValue) === 'object' && !Array.isArray(defaultValue)) {
|
|
5355
|
+
if (_typeof(defaultValue) === 'object' && !Array.isArray(defaultValue) && defaultValue !== null) {
|
|
5356
5356
|
if (typeof defaultValue.value !== 'undefined' && defaultValue.value !== null) setControlValue(defaultValue.value);
|
|
5357
5357
|
if (typeof defaultValue.label !== 'undefined' && defaultValue.label !== null) setControlLabel(formatIndentVal(defaultValue.label, INDENT_LAST_PLACEHOLDER));
|
|
5358
5358
|
}
|
|
@@ -42,13 +42,13 @@ export interface CustomOptionsItemsListParams {
|
|
|
42
42
|
isAllSelected: boolean;
|
|
43
43
|
handleSelectAll: () => void;
|
|
44
44
|
onChange?: (
|
|
45
|
-
e:
|
|
46
|
-
value:
|
|
47
|
-
valueStr:
|
|
48
|
-
label:
|
|
49
|
-
labelStr:
|
|
50
|
-
currentData:
|
|
51
|
-
dataCollection:
|
|
45
|
+
e: React.ChangeEvent<HTMLInputElement> | null,
|
|
46
|
+
value: string[] | null,
|
|
47
|
+
valueStr: string,
|
|
48
|
+
label: string[] | null,
|
|
49
|
+
labelStr: string,
|
|
50
|
+
currentData: OptionConfig | null,
|
|
51
|
+
dataCollection: OptionConfig[]
|
|
52
52
|
) => void;
|
|
53
53
|
attributes: React.HTMLAttributes<HTMLInputElement>;
|
|
54
54
|
}
|
|
@@ -72,6 +72,7 @@ export type MultipleCheckboxesProps = {
|
|
|
72
72
|
required?: any;
|
|
73
73
|
showSelectAll?: boolean;
|
|
74
74
|
selectAllLabel?: string;
|
|
75
|
+
singleSelect?: boolean;
|
|
75
76
|
/** Whether to use square brackets to save result and initialize default value */
|
|
76
77
|
extractValueByBrackets?: boolean;
|
|
77
78
|
/** -- */
|
|
@@ -84,10 +85,22 @@ export type MultipleCheckboxesProps = {
|
|
|
84
85
|
fetchFuncAsync?: any;
|
|
85
86
|
fetchFuncMethod?: string;
|
|
86
87
|
fetchFuncMethodParams?: any[];
|
|
87
|
-
fetchCallback?: (data:
|
|
88
|
-
onFetch?: (data:
|
|
89
|
-
onLoad?: (
|
|
90
|
-
|
|
88
|
+
fetchCallback?: (data: OptionConfig[]) => OptionConfig[];
|
|
89
|
+
onFetch?: (data: OptionConfig[]) => void;
|
|
90
|
+
onLoad?: (
|
|
91
|
+
latestData: OptionConfig[],
|
|
92
|
+
defaultValue: string | string[],
|
|
93
|
+
rootElement: HTMLDivElement | HTMLTableElement | null
|
|
94
|
+
) => void;
|
|
95
|
+
onChange?: (
|
|
96
|
+
e: React.ChangeEvent<HTMLInputElement> | null,
|
|
97
|
+
value: string[] | null,
|
|
98
|
+
valueStr: string,
|
|
99
|
+
label: string[] | null,
|
|
100
|
+
labelStr: string,
|
|
101
|
+
currentData: OptionConfig | null,
|
|
102
|
+
dataCollection: OptionConfig[]
|
|
103
|
+
) => void;
|
|
91
104
|
onCallbackListItem?: (optiondata: any) => void;
|
|
92
105
|
|
|
93
106
|
};
|
|
@@ -114,6 +127,7 @@ const MultipleCheckboxes = forwardRef((props: MultipleCheckboxesProps, externalR
|
|
|
114
127
|
id,
|
|
115
128
|
showSelectAll = false,
|
|
116
129
|
selectAllLabel = 'Select all',
|
|
130
|
+
singleSelect = false,
|
|
117
131
|
extractValueByBrackets,
|
|
118
132
|
style,
|
|
119
133
|
fetchFuncAsync,
|
|
@@ -226,7 +240,7 @@ const MultipleCheckboxes = forwardRef((props: MultipleCheckboxesProps, externalR
|
|
|
226
240
|
initDefaultValue('', dataInit);
|
|
227
241
|
cb?.();
|
|
228
242
|
|
|
229
|
-
onChange?.(null, null, '', null,
|
|
243
|
+
onChange?.(null, null, '', null, '', null, []);
|
|
230
244
|
},
|
|
231
245
|
set: (value: any, cb?: any) => {
|
|
232
246
|
initDefaultValue(value, dataInit);
|
|
@@ -241,7 +255,7 @@ const MultipleCheckboxes = forwardRef((props: MultipleCheckboxesProps, externalR
|
|
|
241
255
|
|
|
242
256
|
onChange?.(null, _value, _valueStr, _label, _labelStr, null, _resDataCollection);
|
|
243
257
|
} else {
|
|
244
|
-
onChange?.(null, null, value, null,
|
|
258
|
+
onChange?.(null, null, value ?? '', null, '', null, []);
|
|
245
259
|
}
|
|
246
260
|
|
|
247
261
|
},
|
|
@@ -281,11 +295,24 @@ const MultipleCheckboxes = forwardRef((props: MultipleCheckboxesProps, externalR
|
|
|
281
295
|
function handleCheckboxChange(itemKey: string) {
|
|
282
296
|
// first, make a copy of the original set rather than mutating the original
|
|
283
297
|
const newSelectedItems = new Set(selectedItems);
|
|
284
|
-
|
|
285
|
-
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
if (singleSelect) {
|
|
301
|
+
// If singleSelect is true, clear all selections first
|
|
302
|
+
newSelectedItems.clear();
|
|
303
|
+
// Only add the new selection if it wasn't already selected
|
|
304
|
+
if (!selectedItems.has(itemKey)) {
|
|
305
|
+
newSelectedItems.add(itemKey);
|
|
306
|
+
}
|
|
286
307
|
} else {
|
|
287
|
-
|
|
308
|
+
// Original multi-select behavior
|
|
309
|
+
if (!newSelectedItems.has(itemKey)) {
|
|
310
|
+
newSelectedItems.add(itemKey);
|
|
311
|
+
} else {
|
|
312
|
+
newSelectedItems.delete(itemKey);
|
|
313
|
+
}
|
|
288
314
|
}
|
|
315
|
+
|
|
289
316
|
setSelectedItems(newSelectedItems);
|
|
290
317
|
|
|
291
318
|
return newSelectedItems;
|
package/lib/esm/Select/index.tsx
CHANGED
|
@@ -53,7 +53,6 @@ import { clsWrite, combinedCls } from 'funda-utils/dist/cjs/cls';
|
|
|
53
53
|
|
|
54
54
|
|
|
55
55
|
|
|
56
|
-
|
|
57
56
|
export type SelectOptionChangeFnType = (arg1: any, arg2: any, arg3: any) => void;
|
|
58
57
|
|
|
59
58
|
|
|
@@ -2046,7 +2045,7 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
|
|
|
2046
2045
|
// ++++++++++++++++++++
|
|
2047
2046
|
// Single selection
|
|
2048
2047
|
// ++++++++++++++++++++
|
|
2049
|
-
if (typeof value === 'object' && !Array.isArray(value)) {
|
|
2048
|
+
if (typeof value === 'object' && !Array.isArray(value) && value !== null) {
|
|
2050
2049
|
if (typeof value.value !== 'undefined' && value.value !== null) setControlValue(value.value as string);
|
|
2051
2050
|
if (typeof value.label !== 'undefined' && value.label !== null) setControlLabel(formatIndentVal(value.label, INDENT_LAST_PLACEHOLDER));
|
|
2052
2051
|
}
|
|
@@ -2126,7 +2125,7 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
|
|
|
2126
2125
|
// ++++++++++++++++++++
|
|
2127
2126
|
// Single selection
|
|
2128
2127
|
// ++++++++++++++++++++
|
|
2129
|
-
if (typeof defaultValue === 'object' && !Array.isArray(defaultValue)) {
|
|
2128
|
+
if (typeof defaultValue === 'object' && !Array.isArray(defaultValue) && defaultValue !== null) {
|
|
2130
2129
|
if (typeof defaultValue.value !== 'undefined' && defaultValue.value !== null) setControlValue(defaultValue.value as string);
|
|
2131
2130
|
if (typeof defaultValue.label !== 'undefined' && defaultValue.label !== null) setControlLabel(formatIndentVal(defaultValue.label, INDENT_LAST_PLACEHOLDER));
|
|
2132
2131
|
}
|
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.
|
|
5
|
+
"version": "4.7.190",
|
|
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",
|