funda-ui 1.0.516 → 1.0.520
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/Input/index.js +6 -4
- package/Radio/index.d.ts +9 -1
- package/Radio/index.js +123 -30
- package/RangeSlider/index.js +6 -4
- package/Table/index.js +463 -31
- package/Textarea/index.d.ts +2 -0
- package/Textarea/index.js +124 -21
- package/lib/cjs/Input/index.js +6 -4
- package/lib/cjs/Radio/index.d.ts +9 -1
- package/lib/cjs/Radio/index.js +123 -30
- package/lib/cjs/RangeSlider/index.js +6 -4
- package/lib/cjs/Table/index.js +463 -31
- package/lib/cjs/Textarea/index.d.ts +2 -0
- package/lib/cjs/Textarea/index.js +124 -21
- package/lib/esm/Input/index.tsx +7 -4
- package/lib/esm/Radio/index.tsx +141 -56
- package/lib/esm/Textarea/index.tsx +18 -0
- package/lib/esm/Textarea/utils/useAutosizeTextArea.js +83 -0
- package/package.json +1 -1
package/Input/index.js
CHANGED
|
@@ -178,10 +178,6 @@ var Input = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(funct
|
|
|
178
178
|
|
|
179
179
|
//
|
|
180
180
|
onChange === null || onChange === void 0 ? void 0 : onChange(event, onComposition);
|
|
181
|
-
if (typeof onChangeCallback === 'function') {
|
|
182
|
-
var newData = onChangeCallback(event);
|
|
183
|
-
setChangedVal(newData);
|
|
184
|
-
}
|
|
185
181
|
}
|
|
186
182
|
function handleBlur(event) {
|
|
187
183
|
var el = event.target;
|
|
@@ -195,6 +191,12 @@ var Input = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(funct
|
|
|
195
191
|
|
|
196
192
|
//
|
|
197
193
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event, onComposition);
|
|
194
|
+
|
|
195
|
+
//
|
|
196
|
+
if (typeof onChangeCallback === 'function') {
|
|
197
|
+
var newData = onChangeCallback(event);
|
|
198
|
+
setChangedVal(newData);
|
|
199
|
+
}
|
|
198
200
|
}
|
|
199
201
|
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
|
|
200
202
|
// update default value
|
package/Radio/index.d.ts
CHANGED
|
@@ -4,6 +4,9 @@ declare module 'react' {
|
|
|
4
4
|
children?: any;
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
|
+
interface OptionConfig {
|
|
8
|
+
[propName: string]: string | number;
|
|
9
|
+
}
|
|
7
10
|
declare type RadioOptionChangeFnType = (arg1: any, arg2: any) => void;
|
|
8
11
|
declare type RadioProps = {
|
|
9
12
|
wrapperClassName?: string;
|
|
@@ -12,7 +15,7 @@ declare type RadioProps = {
|
|
|
12
15
|
name?: string;
|
|
13
16
|
disabled?: any;
|
|
14
17
|
required?: any;
|
|
15
|
-
options
|
|
18
|
+
options?: OptionConfig[] | string;
|
|
16
19
|
inline?: boolean;
|
|
17
20
|
/** -- */
|
|
18
21
|
id?: string;
|
|
@@ -22,6 +25,11 @@ declare type RadioProps = {
|
|
|
22
25
|
/** This function is called whenever the data is updated.
|
|
23
26
|
* Exposes the JSON format data about the option as an argument.
|
|
24
27
|
*/
|
|
28
|
+
fetchFuncAsync?: any;
|
|
29
|
+
fetchFuncMethod?: string;
|
|
30
|
+
fetchFuncMethodParams?: any[];
|
|
31
|
+
fetchCallback?: (data: any) => void;
|
|
32
|
+
onFetch?: (data: any) => void;
|
|
25
33
|
onClick?: RadioOptionChangeFnType | null;
|
|
26
34
|
onChange?: RadioOptionChangeFnType | null;
|
|
27
35
|
onBlur?: (e: any) => void;
|
package/Radio/index.js
CHANGED
|
@@ -96,9 +96,16 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
96
96
|
/* harmony export */ });
|
|
97
97
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(787);
|
|
98
98
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
99
|
-
var _excluded = ["wrapperClassName", "disabled", "required", "value", "label", "name", "id", "options", "inline", "style", "tabIndex", "onClick", "onChange", "onBlur", "onFocus"];
|
|
99
|
+
var _excluded = ["wrapperClassName", "disabled", "required", "value", "label", "name", "id", "options", "inline", "style", "tabIndex", "fetchFuncAsync", "fetchFuncMethod", "fetchFuncMethodParams", "fetchCallback", "onFetch", "onClick", "onChange", "onBlur", "onFocus"];
|
|
100
|
+
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; }
|
|
101
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
102
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
103
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
104
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
100
105
|
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); }
|
|
101
106
|
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); }
|
|
107
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
108
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
102
109
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
103
110
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
104
111
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -120,6 +127,11 @@ var Radio = function Radio(props) {
|
|
|
120
127
|
inline = props.inline,
|
|
121
128
|
style = props.style,
|
|
122
129
|
tabIndex = props.tabIndex,
|
|
130
|
+
fetchFuncAsync = props.fetchFuncAsync,
|
|
131
|
+
fetchFuncMethod = props.fetchFuncMethod,
|
|
132
|
+
fetchFuncMethodParams = props.fetchFuncMethodParams,
|
|
133
|
+
fetchCallback = props.fetchCallback,
|
|
134
|
+
onFetch = props.onFetch,
|
|
123
135
|
onClick = props.onClick,
|
|
124
136
|
onChange = props.onChange,
|
|
125
137
|
onBlur = props.onBlur,
|
|
@@ -128,12 +140,94 @@ var Radio = function Radio(props) {
|
|
|
128
140
|
var uniqueID = (0,react__WEBPACK_IMPORTED_MODULE_0__.useId)();
|
|
129
141
|
var idRes = id || uniqueID;
|
|
130
142
|
var rootRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);
|
|
131
|
-
var
|
|
143
|
+
var optionsRes = options ? isJSON(options) ? JSON.parse(options) : options : '';
|
|
144
|
+
|
|
145
|
+
// return a array of options
|
|
146
|
+
var optionsDataInit = [];
|
|
147
|
+
var optionKeys = Object.keys(optionsRes);
|
|
148
|
+
var optionValues = Object.values(optionsRes).map(function (item) {
|
|
149
|
+
return item.toString();
|
|
150
|
+
});
|
|
151
|
+
optionsDataInit = optionKeys.map(function (item, index) {
|
|
152
|
+
return {
|
|
153
|
+
label: optionKeys[index],
|
|
154
|
+
value: optionValues[index]
|
|
155
|
+
};
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
//
|
|
159
|
+
var _useState = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(optionsDataInit),
|
|
132
160
|
_useState2 = _slicedToArray(_useState, 2),
|
|
133
|
-
|
|
134
|
-
|
|
161
|
+
dataInit = _useState2[0],
|
|
162
|
+
setDataInit = _useState2[1];
|
|
163
|
+
var _useState3 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false),
|
|
164
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
165
|
+
hasErr = _useState4[0],
|
|
166
|
+
setHasErr = _useState4[1];
|
|
167
|
+
var _useState5 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(''),
|
|
168
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
169
|
+
controlValue = _useState6[0],
|
|
170
|
+
setControlValue = _useState6[1];
|
|
171
|
+
function fetchData(_x2) {
|
|
172
|
+
return _fetchData.apply(this, arguments);
|
|
173
|
+
} // Determine whether it is in JSON format
|
|
174
|
+
function _fetchData() {
|
|
175
|
+
_fetchData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) {
|
|
176
|
+
var response, _ORGIN_DATA;
|
|
177
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
178
|
+
while (1) switch (_context.prev = _context.next) {
|
|
179
|
+
case 0:
|
|
180
|
+
// set default value
|
|
181
|
+
if (typeof value !== 'undefined' && value !== '') rootRef.current.dataset.value = value;
|
|
182
|
+
|
|
183
|
+
//
|
|
184
|
+
if (!(_typeof(fetchFuncAsync) === 'object')) {
|
|
185
|
+
_context.next = 14;
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
_context.next = 4;
|
|
189
|
+
return fetchFuncAsync["".concat(fetchFuncMethod)].apply(fetchFuncAsync, _toConsumableArray(params.split(',')));
|
|
190
|
+
case 4:
|
|
191
|
+
response = _context.sent;
|
|
192
|
+
_ORGIN_DATA = response.data; // reset data structure
|
|
193
|
+
if (typeof fetchCallback === 'function') {
|
|
194
|
+
_ORGIN_DATA = fetchCallback(_ORGIN_DATA);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Determine whether the data structure matches
|
|
198
|
+
if (_ORGIN_DATA.length > 0 && typeof _ORGIN_DATA[0].value === 'undefined') {
|
|
199
|
+
console.warn('The data structure does not match, please refer to the example in the component documentation.');
|
|
200
|
+
setHasErr(true);
|
|
201
|
+
_ORGIN_DATA = [];
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
//
|
|
205
|
+
setControlValue(value); // value must be initialized
|
|
206
|
+
|
|
207
|
+
//
|
|
208
|
+
setDataInit(_ORGIN_DATA); // data must be initialized
|
|
209
|
+
|
|
210
|
+
//
|
|
211
|
+
onFetch === null || onFetch === void 0 ? void 0 : onFetch(_ORGIN_DATA);
|
|
212
|
+
return _context.abrupt("return", _ORGIN_DATA);
|
|
213
|
+
case 14:
|
|
214
|
+
//
|
|
215
|
+
setControlValue(value); // value must be initialized
|
|
135
216
|
|
|
136
|
-
|
|
217
|
+
//
|
|
218
|
+
setDataInit(optionsDataInit); // data must be initialized
|
|
219
|
+
|
|
220
|
+
//
|
|
221
|
+
onFetch === null || onFetch === void 0 ? void 0 : onFetch(optionsDataInit);
|
|
222
|
+
return _context.abrupt("return", optionsDataInit);
|
|
223
|
+
case 18:
|
|
224
|
+
case "end":
|
|
225
|
+
return _context.stop();
|
|
226
|
+
}
|
|
227
|
+
}, _callee);
|
|
228
|
+
}));
|
|
229
|
+
return _fetchData.apply(this, arguments);
|
|
230
|
+
}
|
|
137
231
|
function isJSON(str) {
|
|
138
232
|
if (typeof str === 'string' && str.length > 0) {
|
|
139
233
|
if (str.replace(/\"\"/g, '').replace(/\,/g, '') == '[{}]') {
|
|
@@ -153,47 +247,42 @@ var Radio = function Radio(props) {
|
|
|
153
247
|
}
|
|
154
248
|
}
|
|
155
249
|
}
|
|
250
|
+
|
|
251
|
+
//
|
|
156
252
|
function handleFocus(event) {
|
|
157
|
-
|
|
253
|
+
rootRef.current.classList.add('focus');
|
|
158
254
|
|
|
159
255
|
//
|
|
160
256
|
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
|
|
161
257
|
}
|
|
162
258
|
function handleChange(event) {
|
|
163
|
-
var
|
|
164
|
-
|
|
259
|
+
var val = event.target.value;
|
|
260
|
+
|
|
261
|
+
//----
|
|
262
|
+
// update value
|
|
263
|
+
setControlValue(val);
|
|
165
264
|
|
|
166
265
|
//----
|
|
167
266
|
//remove focus style
|
|
168
|
-
|
|
169
|
-
var _el$parentElement;
|
|
170
|
-
(_el$parentElement = el.parentElement) === null || _el$parentElement === void 0 ? void 0 : _el$parentElement.classList.remove('focus');
|
|
171
|
-
});
|
|
267
|
+
rootRef.current.classList.remove('focus');
|
|
172
268
|
|
|
173
269
|
//
|
|
174
270
|
if (typeof onChange === 'function') {
|
|
175
|
-
onChange(event,
|
|
176
|
-
|
|
177
|
-
if (typeof onClick === 'function') {
|
|
178
|
-
onClick(event, _val);
|
|
271
|
+
onChange(event, dataInit[event.target.selectedIndex]);
|
|
272
|
+
event.target.blur();
|
|
179
273
|
}
|
|
180
274
|
}
|
|
181
275
|
function handleBlur(event) {
|
|
182
276
|
//----
|
|
183
277
|
//remove focus style
|
|
184
|
-
|
|
278
|
+
rootRef.current.classList.remove('focus');
|
|
185
279
|
|
|
186
280
|
//
|
|
187
281
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
188
282
|
}
|
|
189
283
|
|
|
190
|
-
//
|
|
191
|
-
var
|
|
192
|
-
var optionKeys = selectOptions === null ? [] : Object.keys(selectOptions);
|
|
193
|
-
var optionValues = selectOptions === null ? [] : Object.values(selectOptions).map(function (item) {
|
|
194
|
-
return item.toString();
|
|
195
|
-
});
|
|
196
|
-
var radioOptionsList = optionKeys.map(function (radioOption, index) {
|
|
284
|
+
// Generate list of options
|
|
285
|
+
var itemsList = dataInit.map(function (item, index) {
|
|
197
286
|
var requiredVal = index === 0 ? required || null : null;
|
|
198
287
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
199
288
|
key: index,
|
|
@@ -204,7 +293,7 @@ var Radio = function Radio(props) {
|
|
|
204
293
|
className: "form-check-input",
|
|
205
294
|
id: "field-".concat(uniqueID, "-").concat(index),
|
|
206
295
|
name: name,
|
|
207
|
-
value:
|
|
296
|
+
value: "".concat(item.value),
|
|
208
297
|
required: requiredVal,
|
|
209
298
|
disabled: disabled || null,
|
|
210
299
|
onChange: handleChange,
|
|
@@ -213,22 +302,26 @@ var Radio = function Radio(props) {
|
|
|
213
302
|
},
|
|
214
303
|
onFocus: handleFocus,
|
|
215
304
|
onBlur: handleBlur,
|
|
216
|
-
checked:
|
|
305
|
+
checked: controlValue == item.value // component status will not change if defaultChecked is used
|
|
217
306
|
,
|
|
218
307
|
style: style
|
|
219
308
|
}, attributes)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("label", {
|
|
220
309
|
className: "form-check-label",
|
|
221
310
|
htmlFor: "field-".concat(uniqueID, "-").concat(index),
|
|
222
311
|
dangerouslySetInnerHTML: {
|
|
223
|
-
__html:
|
|
312
|
+
__html: "".concat(item.label)
|
|
224
313
|
}
|
|
225
314
|
}));
|
|
226
315
|
});
|
|
227
316
|
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
|
|
228
|
-
|
|
317
|
+
// data init
|
|
318
|
+
//--------------
|
|
319
|
+
var _params = fetchFuncMethodParams || [];
|
|
320
|
+
fetchData(_params.join(','));
|
|
229
321
|
}, [value, options]);
|
|
230
322
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
231
|
-
|
|
323
|
+
id: "radio__wrapper-".concat(idRes),
|
|
324
|
+
className: "radio__wrapper ".concat(wrapperClassName || wrapperClassName === '' ? wrapperClassName : 'mb-3 position-relative'),
|
|
232
325
|
ref: rootRef
|
|
233
326
|
}, label ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("label", {
|
|
234
327
|
htmlFor: idRes,
|
|
@@ -238,7 +331,7 @@ var Radio = function Radio(props) {
|
|
|
238
331
|
}
|
|
239
332
|
})) : null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
240
333
|
id: idRes
|
|
241
|
-
},
|
|
334
|
+
}, !hasErr ? itemsList : null)));
|
|
242
335
|
};
|
|
243
336
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Radio);
|
|
244
337
|
})();
|
package/RangeSlider/index.js
CHANGED
|
@@ -320,10 +320,6 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
320
320
|
|
|
321
321
|
//
|
|
322
322
|
onChange === null || onChange === void 0 ? void 0 : onChange(event, onComposition);
|
|
323
|
-
if (typeof onChangeCallback === 'function') {
|
|
324
|
-
var newData = onChangeCallback(event);
|
|
325
|
-
setChangedVal(newData);
|
|
326
|
-
}
|
|
327
323
|
}
|
|
328
324
|
function handleBlur(event) {
|
|
329
325
|
var el = event.target;
|
|
@@ -337,6 +333,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
337
333
|
|
|
338
334
|
//
|
|
339
335
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event, onComposition);
|
|
336
|
+
|
|
337
|
+
//
|
|
338
|
+
if (typeof onChangeCallback === 'function') {
|
|
339
|
+
var newData = onChangeCallback(event);
|
|
340
|
+
setChangedVal(newData);
|
|
341
|
+
}
|
|
340
342
|
}
|
|
341
343
|
(0, react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
|
|
342
344
|
// update default value
|