arengibook 2.4.633 → 2.4.635

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.
Files changed (2) hide show
  1. package/dist/index.js +46 -37
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -39109,10 +39109,7 @@ var MultiSelectMetaAsync = function MultiSelectMetaAsync(_ref) {
39109
39109
  useCheckbox = _ref$useCheckbox === void 0 ? false : _ref$useCheckbox,
39110
39110
  _ref$showSelectAll = _ref.showSelectAll,
39111
39111
  showSelectAll = _ref$showSelectAll === void 0 ? true : _ref$showSelectAll;
39112
- // const [selectedOptions, setSelectedOptions] = useState(value ?? []);
39113
- var _useState = useState(objValue ? _toConsumableArray$7(objValue.map(function (opt) {
39114
- return opt[optionValue];
39115
- })) : value !== null && value !== void 0 ? value : []),
39112
+ var _useState = useState(null),
39116
39113
  _useState2 = _slicedToArray$9(_useState, 2),
39117
39114
  selectedOptions = _useState2[0],
39118
39115
  setSelectedOptions = _useState2[1];
@@ -39133,33 +39130,45 @@ var MultiSelectMetaAsync = function MultiSelectMetaAsync(_ref) {
39133
39130
  var currentPageRef = useRef(1);
39134
39131
  var isOptionsArray = Array.isArray(options);
39135
39132
  useEffect(function () {
39136
- if (isOptionsArray) {
39137
- setLoadedOptions(options);
39138
- } else {
39139
- var loadInitialOptions = /*#__PURE__*/function () {
39140
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
39141
- var result;
39142
- return _regenerator().w(function (_context) {
39143
- while (1) switch (_context.n) {
39144
- case 0:
39145
- _context.n = 1;
39146
- return options('', [], {
39147
- page: 1
39133
+ setSelectedOptions(objValue ? _toConsumableArray$7(objValue.map(function (opt) {
39134
+ return opt[optionValue];
39135
+ })) : value !== null && value !== void 0 ? value : []);
39136
+ console.log(objValue ? _toConsumableArray$7(objValue.map(function (opt) {
39137
+ return opt[optionValue];
39138
+ })) : value !== null && value !== void 0 ? value : []);
39139
+ var loadInitialOptions = /*#__PURE__*/function () {
39140
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
39141
+ var result, _result$options, exists;
39142
+ return _regenerator().w(function (_context) {
39143
+ while (1) switch (_context.n) {
39144
+ case 0:
39145
+ _context.n = 1;
39146
+ return options('', [], {
39147
+ page: 1
39148
+ });
39149
+ case 1:
39150
+ result = _context.v;
39151
+ setLoadedOptions((result === null || result === void 0 ? void 0 : result.options) || []);
39152
+ if (objValue) {
39153
+ exists = result === null || result === void 0 || (_result$options = result.options) === null || _result$options === void 0 ? void 0 : _result$options.some(function (opt) {
39154
+ return opt[optionValue] === objValue[optionValue];
39148
39155
  });
39149
- case 1:
39150
- result = _context.v;
39151
- setLoadedOptions((result === null || result === void 0 ? void 0 : result.options) || []);
39152
- case 2:
39153
- return _context.a(2);
39154
- }
39155
- }, _callee);
39156
- }));
39157
- return function loadInitialOptions() {
39158
- return _ref2.apply(this, arguments);
39159
- };
39160
- }();
39161
- loadInitialOptions();
39162
- }
39156
+ if (!exists) {
39157
+ setLoadedOptions(function (prev) {
39158
+ return [].concat(_toConsumableArray$7(prev), [objValue]);
39159
+ });
39160
+ }
39161
+ }
39162
+ case 2:
39163
+ return _context.a(2);
39164
+ }
39165
+ }, _callee);
39166
+ }));
39167
+ return function loadInitialOptions() {
39168
+ return _ref2.apply(this, arguments);
39169
+ };
39170
+ }();
39171
+ loadInitialOptions();
39163
39172
  }, [options]);
39164
39173
  useEffect(function () {
39165
39174
  var observer = new MutationObserver(function () {
@@ -39329,7 +39338,7 @@ var MultiSelectMetaAsync = function MultiSelectMetaAsync(_ref) {
39329
39338
  }), name && /*#__PURE__*/React__default.createElement("input", {
39330
39339
  type: "hidden",
39331
39340
  name: name,
39332
- value: selectedOptions.map(function (opt) {
39341
+ value: (Array.isArray(selectedOptions) ? selectedOptions : []).map(function (opt) {
39333
39342
  return opt[optionValue];
39334
39343
  }).join(',')
39335
39344
  }), invalid && /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement("small", {
@@ -39815,8 +39824,8 @@ var MultiSelectPresets = {
39815
39824
  isSelectMeta: true,
39816
39825
  // value: ['1', '2'],
39817
39826
  objValue: [{
39818
- label: 'Option 2',
39819
- value: '2',
39827
+ label: 'Option 3',
39828
+ value: '3',
39820
39829
  color: '#ff9900'
39821
39830
  }],
39822
39831
  displayNbOption: false,
@@ -39845,11 +39854,11 @@ var MultiSelectPresets = {
39845
39854
  objValue: [{
39846
39855
  label: 'Option 9',
39847
39856
  value: 9,
39848
- color: '#ff9900'
39857
+ color: "#67688C"
39849
39858
  }, {
39850
39859
  label: 'Option 4',
39851
39860
  value: 4,
39852
- color: 'black'
39861
+ color: "#39C9BF"
39853
39862
  }],
39854
39863
  // objValue: [
39855
39864
  // {
@@ -40023,7 +40032,7 @@ var asyncOptions = /*#__PURE__*/function () {
40023
40032
  var MultiSelectMetaAsyncPresets = {
40024
40033
  // Configuration pour les options synchrones
40025
40034
  SyncOptions: {
40026
- value: ['1', '2'],
40035
+ value: ['2', '9'],
40027
40036
  options: syncOptions,
40028
40037
  placeholder: 'Sélectionnez une ou plusieurs options',
40029
40038
  optionLabel: 'label',
@@ -40045,7 +40054,7 @@ var MultiSelectMetaAsyncPresets = {
40045
40054
  },
40046
40055
  // Configuration pour les options asynchrones
40047
40056
  AsyncOptions: {
40048
- value: ['1', '2'],
40057
+ value: ['1', '12'],
40049
40058
  options: asyncOptions,
40050
40059
  placeholder: 'Sélectionnez une ou plusieurs options',
40051
40060
  optionLabel: 'label',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "arengibook",
3
3
  "private": false,
4
- "version": "2.4.633",
4
+ "version": "2.4.635",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
7
7
  "exports": {