funda-ui 1.1.190 → 1.2.115

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.
@@ -10,6 +10,8 @@ declare type DynamicFieldsValueProps = {
10
10
  };
11
11
  declare type DynamicFieldsProps = {
12
12
  wrapperClassName?: string;
13
+ btnAddWrapperClassName?: string;
14
+ btnRemoveWrapperClassName?: string;
13
15
  value?: string;
14
16
  label?: React.ReactNode | string;
15
17
  data: DynamicFieldsValueProps | null;
@@ -109,6 +109,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
109
109
 
110
110
  var DynamicFields = function DynamicFields(props) {
111
111
  var wrapperClassName = props.wrapperClassName,
112
+ btnAddWrapperClassName = props.btnAddWrapperClassName,
113
+ btnRemoveWrapperClassName = props.btnRemoveWrapperClassName,
112
114
  label = props.label,
113
115
  data = props.data,
114
116
  maxFields = props.maxFields,
@@ -282,7 +284,7 @@ var DynamicFields = function DynamicFields(props) {
282
284
  var removeBtyn = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("a", {
283
285
  href: "#",
284
286
  tabIndex: -1,
285
- className: "dynamic-fields__removebtn align-middle",
287
+ className: "dynamic-fields__removebtn ".concat(btnRemoveWrapperClassName || 'align-middle'),
286
288
  onClick: handleClickRemove
287
289
  }, iconRemove ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, iconRemove) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("svg", {
288
290
  width: "20px",
@@ -316,7 +318,7 @@ var DynamicFields = function DynamicFields(props) {
316
318
  id: addBtnIdRef.current,
317
319
  href: "#",
318
320
  tabIndex: -1,
319
- className: "dynamic-fields__addbtn align-middle",
321
+ className: "dynamic-fields__addbtn ".concat(btnAddWrapperClassName || 'align-middle'),
320
322
  onClick: handleClickAdd
321
323
  }, iconAdd ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, iconAdd) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("svg", {
322
324
  width: "20px",
@@ -254,11 +254,16 @@ function MenuList(props) {
254
254
  activeClass(hyperlink.parentNode, 'add');
255
255
 
256
256
  // init <ul> height
257
- [].slice.call(ul).forEach(function (el) {
258
- if (typeof el.querySelectorAll('li')[0] !== 'undefined') {
259
- var calcH = el.querySelectorAll('li').length * el.querySelectorAll('li')[0].scrollHeight;
260
- el.style.maxHeight = "".concat(calcH, "px");
261
- }
257
+ [].slice.call(ul).forEach(function (_curUl) {
258
+ var allHeight = [].slice.call(_curUl.querySelectorAll('li')).map(function (_curLi) {
259
+ return _curLi.scrollHeight;
260
+ });
261
+ var totalHeight = allHeight.reduce(function (accumulator, currentValue) {
262
+ return accumulator + currentValue;
263
+ }, 0);
264
+
265
+ // Prevent the use of iframe or other situations where the height is 0
266
+ _curUl.style.maxHeight = "".concat(totalHeight == 0 ? 999 : totalHeight, "px");
262
267
  });
263
268
  };
264
269
  function handleClick(e) {
@@ -339,13 +344,16 @@ function MenuList(props) {
339
344
 
340
345
  // init <ul> height
341
346
  var ul = (0,dom.getNextSiblings)(hyperlink.el, 'ul');
342
- [].slice.call(ul).forEach(function (el) {
343
- if (typeof el.querySelectorAll('li')[0] !== 'undefined') {
344
- var calcH = el.querySelectorAll('li').length * el.querySelectorAll('li')[0].scrollHeight;
347
+ [].slice.call(ul).forEach(function (_curUl) {
348
+ var allHeight = [].slice.call(_curUl.querySelectorAll('li')).map(function (_curLi) {
349
+ return _curLi.scrollHeight;
350
+ });
351
+ var totalHeight = allHeight.reduce(function (accumulator, currentValue) {
352
+ return accumulator + currentValue;
353
+ }, 0);
345
354
 
346
- // Prevent the use of iframe or other situations where the height is 0
347
- el.style.maxHeight = "".concat(calcH == 0 ? 999 : calcH, "px");
348
- }
355
+ // Prevent the use of iframe or other situations where the height is 0
356
+ _curUl.style.maxHeight = "".concat(totalHeight == 0 ? 999 : totalHeight, "px");
349
357
  });
350
358
  }
351
359
  });
@@ -4,11 +4,13 @@ interface OptionConfig {
4
4
  }
5
5
  declare type MultipleCheckboxesProps = {
6
6
  wrapperClassName?: string;
7
+ groupWrapperClassName?: string;
8
+ groupLabelClassName?: string;
7
9
  inline?: boolean;
8
10
  value?: string;
9
11
  label?: React.ReactNode | string;
10
12
  name?: string;
11
- options?: OptionConfig[] | string;
13
+ options?: OptionConfig[] | string | unknown;
12
14
  disabled?: any;
13
15
  required?: any;
14
16
  /** Whether to use square brackets to save result and initialize default value */
@@ -661,7 +661,7 @@ __webpack_require__.r(__webpack_exports__);
661
661
  /* harmony import */ var _utils_extract__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_utils_extract__WEBPACK_IMPORTED_MODULE_2__);
662
662
  /* harmony import */ var _utils_convert__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(498);
663
663
  /* harmony import */ var _utils_convert__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_utils_convert__WEBPACK_IMPORTED_MODULE_3__);
664
- var _excluded = ["wrapperClassName", "inline", "options", "disabled", "required", "value", "label", "name", "id", "extractValueByBrackets", "style", "onChange"];
664
+ var _excluded = ["wrapperClassName", "groupWrapperClassName", "groupLabelClassName", "inline", "options", "disabled", "required", "value", "label", "name", "id", "extractValueByBrackets", "style", "onChange"];
665
665
  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); }
666
666
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
667
667
  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."); }
@@ -682,6 +682,8 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
682
682
 
683
683
  var MultipleCheckboxes = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(function (props, ref) {
684
684
  var wrapperClassName = props.wrapperClassName,
685
+ groupWrapperClassName = props.groupWrapperClassName,
686
+ groupLabelClassName = props.groupLabelClassName,
685
687
  inline = props.inline,
686
688
  options = props.options,
687
689
  disabled = props.disabled,
@@ -766,44 +768,103 @@ var MultipleCheckboxes = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forw
766
768
  })) : null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
767
769
  className: "multiple-checkboxes__control-wrapper",
768
770
  style: style
769
- }, valData ? valData.map(function (item, i) {
770
- return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
771
- key: 'checkbox' + i,
772
- className: "multiple-checkboxes__control ".concat(_inline ? 'd-inline-block' : '', " pe-3"),
773
- "data-index": i,
774
- "data-label": item.label,
775
- "data-list-item-label": "".concat(typeof item.listItemLabel === 'undefined' ? '' : item.listItemLabel),
776
- "data-value": item.value,
777
- "data-disabled": disabled || 'false'
778
- }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((funda_checkbox__WEBPACK_IMPORTED_MODULE_1___default()), _extends({
779
- wrapperClassName: "",
780
- "data-index": i,
781
- "data-label": item.label,
782
- "data-list-item-label": "".concat(typeof item.listItemLabel === 'undefined' ? '' : item.listItemLabel),
783
- "data-value": item.value,
784
- "data-disabled": disabled || 'false',
785
- label: typeof item.listItemLabel === 'undefined' ? item.label : item.listItemLabel,
786
- value: item.value,
787
- disabled: disabled || (typeof item.disabled !== 'undefined' ? item.disabled : null),
788
- onChange: function onChange(e, val) {
789
- setValSelected(function (prevState) {
790
- var newData = JSON.parse(JSON.stringify(prevState));
791
- var index = newData.findIndex(function (item) {
792
- return item == e.target.value;
793
- });
794
- if (index !== -1) newData.splice(index, 1);
795
- var _res = val ? Array.from(new Set([e.target.value].concat(_toConsumableArray(newData)))) : newData;
796
- var _resLabel = optionsRes.filter(function (v) {
797
- return _res.includes(v.value);
798
- }).map(function (k) {
799
- return k.label;
771
+ }, valData ? valData.map(function (item, index) {
772
+ if (typeof item.optgroup !== 'undefined') {
773
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
774
+ className: "multiple-checkboxes-group__wrapper ".concat(groupWrapperClassName || ''),
775
+ key: 'optgroup-' + index
776
+ }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
777
+ className: "rmultiple-checkboxes-group__label ".concat(groupLabelClassName || '')
778
+ }, item.label), item.optgroup.map(function (opt, optIndex) {
779
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
780
+ key: 'checkbox' + optIndex,
781
+ className: "multiple-checkboxes__control ".concat(_inline ? 'd-inline-block' : '', " pe-3"),
782
+ "data-index": "".concat(index, "-").concat(optIndex),
783
+ "data-label": opt.label,
784
+ "data-list-item-label": "".concat(typeof opt.listItemLabel === 'undefined' ? '' : opt.listItemLabel),
785
+ "data-value": opt.value,
786
+ "data-disabled": disabled || (typeof opt.disabled !== 'undefined' ? "".concat(opt.disabled) : 'false')
787
+ }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((funda_checkbox__WEBPACK_IMPORTED_MODULE_1___default()), _extends({
788
+ wrapperClassName: "",
789
+ "data-index": "".concat(index, "-").concat(optIndex),
790
+ "data-label": opt.label,
791
+ "data-list-item-label": "".concat(typeof opt.listItemLabel === 'undefined' ? '' : opt.listItemLabel),
792
+ "data-value": opt.value,
793
+ "data-disabled": disabled || (typeof opt.disabled !== 'undefined' ? "".concat(opt.disabled) : 'false'),
794
+ label: typeof opt.listItemLabel === 'undefined' ? opt.label : opt.listItemLabel,
795
+ value: opt.value,
796
+ disabled: disabled || (typeof opt.disabled !== 'undefined' ? opt.disabled : null),
797
+ onChange: function onChange(e, val) {
798
+ setValSelected(function (prevState) {
799
+ var newData = JSON.parse(JSON.stringify(prevState));
800
+ var elIndex = newData.findIndex(function (item) {
801
+ return item == e.target.value;
802
+ });
803
+ if (elIndex !== -1) newData.splice(elIndex, 1);
804
+ var _res = val ? Array.from(new Set([e.target.value].concat(_toConsumableArray(newData)))) : newData;
805
+ var _resLabel = optionsRes.filter(function (v) {
806
+ return _res.includes(v.value);
807
+ }).map(function (k) {
808
+ return k.label;
809
+ });
810
+
811
+ //
812
+ var curData;
813
+
814
+ // if group
815
+ if (typeof item.optgroup !== 'undefined') {
816
+ var groupItemIndex = optIndex;
817
+ var groupOpts = item.optgroup;
818
+ curData = groupOpts[groupItemIndex];
819
+ } else {
820
+ curData = item;
821
+ }
822
+ _onChange === null || _onChange === void 0 ? void 0 : _onChange(e.target, _res, VALUE_BY_BRACKETS ? (0,_utils_convert__WEBPACK_IMPORTED_MODULE_3__.convertArrToValByBrackets)(_res) : _res.join(','), _resLabel, VALUE_BY_BRACKETS ? (0,_utils_convert__WEBPACK_IMPORTED_MODULE_3__.convertArrToValByBrackets)(_resLabel) : _resLabel.join(','), curData);
823
+ return _res;
824
+ });
825
+ },
826
+ checked: valSelected.includes(opt.value)
827
+ }, attributes)));
828
+ }));
829
+ } else {
830
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
831
+ key: 'checkbox' + index,
832
+ className: "multiple-checkboxes__control ".concat(_inline ? 'd-inline-block' : '', " pe-3"),
833
+ "data-index": index,
834
+ "data-label": item.label,
835
+ "data-list-item-label": "".concat(typeof item.listItemLabel === 'undefined' ? '' : item.listItemLabel),
836
+ "data-value": item.value,
837
+ "data-disabled": disabled || (typeof item.disabled !== 'undefined' ? "".concat(item.disabled) : 'false')
838
+ }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((funda_checkbox__WEBPACK_IMPORTED_MODULE_1___default()), _extends({
839
+ wrapperClassName: "",
840
+ "data-index": index,
841
+ "data-label": item.label,
842
+ "data-list-item-label": "".concat(typeof item.listItemLabel === 'undefined' ? '' : item.listItemLabel),
843
+ "data-value": item.value,
844
+ "data-disabled": disabled || (typeof item.disabled !== 'undefined' ? "".concat(item.disabled) : 'false'),
845
+ label: typeof item.listItemLabel === 'undefined' ? item.label : item.listItemLabel,
846
+ value: item.value,
847
+ disabled: disabled || (typeof item.disabled !== 'undefined' ? item.disabled : null),
848
+ onChange: function onChange(e, val) {
849
+ setValSelected(function (prevState) {
850
+ var newData = JSON.parse(JSON.stringify(prevState));
851
+ var elIndex = newData.findIndex(function (item) {
852
+ return item == e.target.value;
853
+ });
854
+ if (elIndex !== -1) newData.splice(elIndex, 1);
855
+ var _res = val ? Array.from(new Set([e.target.value].concat(_toConsumableArray(newData)))) : newData;
856
+ var _resLabel = optionsRes.filter(function (v) {
857
+ return _res.includes(v.value);
858
+ }).map(function (k) {
859
+ return k.label;
860
+ });
861
+ _onChange === null || _onChange === void 0 ? void 0 : _onChange(e.target, _res, VALUE_BY_BRACKETS ? (0,_utils_convert__WEBPACK_IMPORTED_MODULE_3__.convertArrToValByBrackets)(_res) : _res.join(','), _resLabel, VALUE_BY_BRACKETS ? (0,_utils_convert__WEBPACK_IMPORTED_MODULE_3__.convertArrToValByBrackets)(_resLabel) : _resLabel.join(','), item);
862
+ return _res;
800
863
  });
801
- _onChange === null || _onChange === void 0 ? void 0 : _onChange(e.target, _res, VALUE_BY_BRACKETS ? (0,_utils_convert__WEBPACK_IMPORTED_MODULE_3__.convertArrToValByBrackets)(_res) : _res.join(','), _resLabel, VALUE_BY_BRACKETS ? (0,_utils_convert__WEBPACK_IMPORTED_MODULE_3__.convertArrToValByBrackets)(_resLabel) : _resLabel.join(','), item);
802
- return _res;
803
- });
804
- },
805
- checked: valSelected.includes(item.value)
806
- }, attributes)));
864
+ },
865
+ checked: valSelected.includes(item.value)
866
+ }, attributes)));
867
+ }
807
868
  }) : null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("input", _extends({
808
869
  ref: inputRef,
809
870
  tabIndex: -1,
package/Radio/index.d.ts CHANGED
@@ -10,12 +10,14 @@ interface OptionConfig {
10
10
  declare type RadioOptionChangeFnType = (arg1: any, arg2: any, arg3?: any, arg4?: any) => void;
11
11
  declare type RadioProps = {
12
12
  wrapperClassName?: string;
13
+ groupWrapperClassName?: string;
14
+ groupLabelClassName?: string;
13
15
  value?: string;
14
16
  label?: React.ReactNode | string;
15
17
  name?: string;
16
18
  disabled?: any;
17
19
  required?: any;
18
- options?: OptionConfig[] | string;
20
+ options?: OptionConfig[] | string | unknown;
19
21
  inline?: boolean;
20
22
  /** -- */
21
23
  id?: string;
package/Radio/index.js CHANGED
@@ -96,7 +96,7 @@ __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", "fetchFuncAsync", "fetchFuncMethod", "fetchFuncMethodParams", "fetchCallback", "onFetch", "onLoad", "onClick", "onChange", "onBlur", "onFocus"];
99
+ var _excluded = ["wrapperClassName", "groupWrapperClassName", "groupLabelClassName", "disabled", "required", "value", "label", "name", "id", "options", "inline", "style", "tabIndex", "fetchFuncAsync", "fetchFuncMethod", "fetchFuncMethodParams", "fetchCallback", "onFetch", "onLoad", "onClick", "onChange", "onBlur", "onFocus"];
100
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
101
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
102
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."); }
@@ -117,6 +117,8 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
117
117
 
118
118
  var Radio = function Radio(props) {
119
119
  var wrapperClassName = props.wrapperClassName,
120
+ groupWrapperClassName = props.groupWrapperClassName,
121
+ groupLabelClassName = props.groupLabelClassName,
120
122
  disabled = props.disabled,
121
123
  required = props.required,
122
124
  value = props.value,
@@ -248,8 +250,20 @@ var Radio = function Radio(props) {
248
250
  }
249
251
  function handleChange(event) {
250
252
  var val = event.target.value;
253
+ var curData;
251
254
  var currentIndex = event.target.dataset.index;
252
255
 
256
+ // if group
257
+ if (currentIndex.indexOf('-') >= 0) {
258
+ var groupIdArr = currentIndex.split('-');
259
+ var groupIndex = groupIdArr[0];
260
+ var groupItemIndex = groupIdArr[1];
261
+ var groupOpts = dataInit[groupIndex].optgroup;
262
+ curData = groupOpts[groupItemIndex];
263
+ } else {
264
+ curData = dataInit[currentIndex];
265
+ }
266
+
253
267
  //----
254
268
  // update value
255
269
  setControlValue(val);
@@ -260,10 +274,10 @@ var Radio = function Radio(props) {
260
274
 
261
275
  //
262
276
  if (typeof onChange === 'function') {
263
- onChange(event, val, dataInit[currentIndex], currentIndex);
277
+ onChange(event, val, curData, currentIndex);
264
278
  }
265
279
  if (typeof onClick === 'function') {
266
- onClick(event, val, dataInit[currentIndex], currentIndex);
280
+ onClick(event, val, curData, currentIndex);
267
281
  }
268
282
  }
269
283
  function handleBlur(event) {
@@ -278,45 +292,94 @@ var Radio = function Radio(props) {
278
292
  // Generate list of options
279
293
  var itemsList = Array.isArray(dataInit) ? dataInit.map(function (item, index) {
280
294
  var requiredVal = index === 0 ? required || null : null;
281
- return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
282
- key: index,
283
- className: inline ? "form-check form-check-inline" : "form-check"
284
- }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
285
- className: "d-inline-block"
286
- }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("input", _extends({
287
- tabIndex: tabIndex || 0,
288
- type: "radio",
289
- className: "form-check-input",
290
- id: "field-".concat(uniqueID, "-").concat(index),
291
- name: name,
292
- "data-index": index,
293
- "data-label": item.label,
294
- "data-list-item-label": "".concat(typeof item.listItemLabel === 'undefined' ? '' : item.listItemLabel),
295
- "data-value": item.value,
296
- "data-disabled": disabled || 'false',
297
- value: "".concat(item.value),
298
- required: requiredVal,
299
- disabled: disabled || (typeof item.disabled !== 'undefined' ? item.disabled : null),
300
- onChange: handleChange,
301
- onClick: typeof onClick === 'function' ? handleChange : function () {
302
- return void 0;
303
- },
304
- onFocus: handleFocus,
305
- onBlur: handleBlur,
306
- checked: controlValue == item.value // component status will not change if defaultChecked is used
307
- ,
308
- style: style
309
- }, attributes)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("label", {
310
- className: "form-check-label",
311
- htmlFor: "field-".concat(uniqueID, "-").concat(index),
312
- dangerouslySetInnerHTML: {
313
- __html: "".concat(typeof item.listItemLabel === 'undefined' ? item.label : item.listItemLabel)
314
- }
315
- })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
316
- className: "d-inline-block"
317
- }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
318
- className: "form-control-extends__wrapper"
319
- }, typeof item["extends"] !== 'undefined' ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, item["extends"]) : null)));
295
+ if (typeof item.optgroup !== 'undefined') {
296
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
297
+ className: "radio-group__wrapper ".concat(groupWrapperClassName || ''),
298
+ key: 'optgroup-' + index
299
+ }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
300
+ className: "radio-group__label ".concat(groupLabelClassName || '')
301
+ }, item.label), item.optgroup.map(function (opt, optIndex) {
302
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
303
+ key: 'option-' + optIndex,
304
+ className: inline ? "form-check form-check-inline" : "form-check"
305
+ }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
306
+ className: "d-inline-block"
307
+ }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("input", _extends({
308
+ tabIndex: tabIndex || 0,
309
+ type: "radio",
310
+ className: "form-check-input",
311
+ id: "field-".concat(uniqueID, "-").concat(index, "-").concat(optIndex),
312
+ name: name,
313
+ "data-index": "".concat(index, "-").concat(optIndex),
314
+ "data-label": opt.label,
315
+ "data-list-item-label": "".concat(typeof opt.listItemLabel === 'undefined' ? '' : opt.listItemLabel),
316
+ "data-value": opt.value,
317
+ "data-disabled": disabled || (typeof opt.disabled !== 'undefined' ? "".concat(opt.disabled) : 'false'),
318
+ value: "".concat(opt.value),
319
+ required: requiredVal,
320
+ disabled: disabled || (typeof opt.disabled !== 'undefined' ? opt.disabled : null),
321
+ onChange: handleChange,
322
+ onClick: typeof onClick === 'function' ? handleChange : function () {
323
+ return void 0;
324
+ },
325
+ onFocus: handleFocus,
326
+ onBlur: handleBlur,
327
+ checked: controlValue == opt.value // component status will not change if defaultChecked is used
328
+ ,
329
+ style: style
330
+ }, attributes)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("label", {
331
+ className: "form-check-label",
332
+ htmlFor: "field-".concat(uniqueID, "-").concat(index, "-").concat(optIndex),
333
+ dangerouslySetInnerHTML: {
334
+ __html: "".concat(typeof opt.listItemLabel === 'undefined' ? opt.label : opt.listItemLabel)
335
+ }
336
+ })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
337
+ className: "d-inline-block"
338
+ }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
339
+ className: "form-control-extends__wrapper"
340
+ }, typeof opt["extends"] !== 'undefined' ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, opt["extends"]) : null)));
341
+ }));
342
+ } else {
343
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
344
+ key: 'option-' + index,
345
+ className: inline ? "form-check form-check-inline" : "form-check"
346
+ }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
347
+ className: "d-inline-block"
348
+ }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("input", _extends({
349
+ tabIndex: tabIndex || 0,
350
+ type: "radio",
351
+ className: "form-check-input",
352
+ id: "field-".concat(uniqueID, "-").concat(index),
353
+ name: name,
354
+ "data-index": index,
355
+ "data-label": item.label,
356
+ "data-list-item-label": "".concat(typeof item.listItemLabel === 'undefined' ? '' : item.listItemLabel),
357
+ "data-value": item.value,
358
+ "data-disabled": disabled || (typeof item.disabled !== 'undefined' ? "".concat(item.disabled) : 'false'),
359
+ value: "".concat(item.value),
360
+ required: requiredVal,
361
+ disabled: disabled || (typeof item.disabled !== 'undefined' ? item.disabled : null),
362
+ onChange: handleChange,
363
+ onClick: typeof onClick === 'function' ? handleChange : function () {
364
+ return void 0;
365
+ },
366
+ onFocus: handleFocus,
367
+ onBlur: handleBlur,
368
+ checked: controlValue == item.value // component status will not change if defaultChecked is used
369
+ ,
370
+ style: style
371
+ }, attributes)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("label", {
372
+ className: "form-check-label",
373
+ htmlFor: "field-".concat(uniqueID, "-").concat(index),
374
+ dangerouslySetInnerHTML: {
375
+ __html: "".concat(typeof item.listItemLabel === 'undefined' ? item.label : item.listItemLabel)
376
+ }
377
+ })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
378
+ className: "d-inline-block"
379
+ }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
380
+ className: "form-control-extends__wrapper"
381
+ }, typeof item["extends"] !== 'undefined' ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, item["extends"]) : null)));
382
+ }
320
383
  }) : null;
321
384
  (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
322
385
  // data init
package/Select/index.js CHANGED
@@ -462,7 +462,7 @@ var Select = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(func
462
462
  key: 'option-' + optIndex,
463
463
  value: opt.value,
464
464
  dangerouslySetInnerHTML: {
465
- __html: "".concat(opt.label)
465
+ __html: "".concat(typeof opt.listItemLabel === 'undefined' ? opt.label : opt.listItemLabel)
466
466
  },
467
467
  disabled: _disabled
468
468
  });
@@ -473,7 +473,7 @@ var Select = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(func
473
473
  key: 'option-' + index,
474
474
  value: item.value,
475
475
  dangerouslySetInnerHTML: {
476
- __html: "".concat(item.label)
476
+ __html: "".concat(typeof item.listItemLabel === 'undefined' ? item.label : item.listItemLabel)
477
477
  },
478
478
  disabled: _disabled
479
479
  });