arengibook 2.1.1-table → 2.1.2-table

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 +128 -73
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -49075,41 +49075,65 @@ var SelfEditableCell = function SelfEditableCell(_ref11) {
49075
49075
  switch (col.type) {
49076
49076
  case 'select':
49077
49077
  case 'lienFormulaire':
49078
- return /*#__PURE__*/React__default.createElement("div", {
49079
- ref: containerRef
49080
- }, /*#__PURE__*/React__default.createElement(Dropdown, _extends$J({}, DropdownPresets.Base, {
49081
- value: localValue,
49082
- options: col.options,
49083
- onChange: function onChange(e) {
49084
- return commit(e.value);
49085
- },
49086
- withColor: true,
49087
- autoFocus: true
49088
- })));
49078
+ {
49079
+ var rawSelect = rowData[col.field];
49080
+ var isObjModeSelect = rawSelect !== null && rawSelect !== undefined && _typeof$g(rawSelect) === 'object' && 'value' in rawSelect;
49081
+ return /*#__PURE__*/React__default.createElement("div", {
49082
+ ref: containerRef
49083
+ }, /*#__PURE__*/React__default.createElement(Dropdown, _extends$J({}, DropdownPresets.Base, {
49084
+ value: isObjModeSelect ? localValue === null || localValue === void 0 ? void 0 : localValue.value : localValue,
49085
+ options: col.options,
49086
+ onChange: function onChange(e) {
49087
+ var _col$options$find, _col$options;
49088
+ return commit(isObjModeSelect ? (_col$options$find = (_col$options = col.options) === null || _col$options === void 0 ? void 0 : _col$options.find(function (o) {
49089
+ return o.value === e.value;
49090
+ })) !== null && _col$options$find !== void 0 ? _col$options$find : {
49091
+ value: e.value
49092
+ } : e.value);
49093
+ },
49094
+ withColor: true,
49095
+ autoFocus: true
49096
+ })));
49097
+ }
49089
49098
  case 'selectMultiple':
49090
- return /*#__PURE__*/React__default.createElement("div", {
49091
- ref: containerRef,
49092
- style: {
49093
- width: '100%',
49094
- maxWidth: '100%',
49095
- overflow: 'hidden'
49096
- },
49097
- onKeyDown: function onKeyDown(e) {
49098
- if (e.key === 'Enter') {
49099
- e.stopPropagation();
49100
- commit(localValueRef.current);
49099
+ {
49100
+ var rawMulti = rowData[col.field];
49101
+ var isObjModeMulti = Array.isArray(rawMulti) && rawMulti.length > 0 && rawMulti[0] !== null && _typeof$g(rawMulti[0]) === 'object' && 'value' in rawMulti[0];
49102
+ var flatValues = isObjModeMulti ? Array.isArray(localValue) ? localValue.map(function (v) {
49103
+ var _v$value;
49104
+ return (_v$value = v === null || v === void 0 ? void 0 : v.value) !== null && _v$value !== void 0 ? _v$value : v;
49105
+ }) : [] : localValue !== null && localValue !== void 0 ? localValue : [];
49106
+ return /*#__PURE__*/React__default.createElement("div", {
49107
+ ref: containerRef,
49108
+ style: {
49109
+ width: '100%',
49110
+ maxWidth: '100%',
49111
+ overflow: 'hidden'
49112
+ },
49113
+ onKeyDown: function onKeyDown(e) {
49114
+ if (e.key === 'Enter') {
49115
+ e.stopPropagation();
49116
+ commit(localValueRef.current);
49117
+ }
49101
49118
  }
49102
- }
49103
- }, /*#__PURE__*/React__default.createElement(MultiSelect, _extends$J({}, MultiSelectPresets.Base, {
49104
- value: localValue !== null && localValue !== void 0 ? localValue : [],
49105
- options: col.options,
49106
- onChange: function onChange(ids) {
49107
- return setLocalValue(ids);
49108
- },
49109
- onHide: function onHide() {
49110
- return commit(localValueRef.current);
49111
- }
49112
- })));
49119
+ }, /*#__PURE__*/React__default.createElement(MultiSelect, _extends$J({}, MultiSelectPresets.Base, {
49120
+ value: flatValues,
49121
+ options: col.options,
49122
+ onChange: function onChange(ids) {
49123
+ return setLocalValue(isObjModeMulti ? ids.map(function (id) {
49124
+ var _col$options$find2, _col$options2;
49125
+ return (_col$options$find2 = (_col$options2 = col.options) === null || _col$options2 === void 0 ? void 0 : _col$options2.find(function (o) {
49126
+ return o.value === id;
49127
+ })) !== null && _col$options$find2 !== void 0 ? _col$options$find2 : {
49128
+ value: id
49129
+ };
49130
+ }) : ids);
49131
+ },
49132
+ onHide: function onHide() {
49133
+ return commit(localValueRef.current);
49134
+ }
49135
+ })));
49136
+ }
49113
49137
  case 'date':
49114
49138
  {
49115
49139
  var dateObj = null;
@@ -49607,8 +49631,8 @@ var Table$1 = function Table(_ref13) {
49607
49631
  var initialFilters = useMemo(function () {
49608
49632
  var f = {};
49609
49633
  columns.forEach(function (col) {
49610
- var _col$options;
49611
- var hasOptions = ((_col$options = col.options) === null || _col$options === void 0 ? void 0 : _col$options.length) > 0;
49634
+ var _col$options3;
49635
+ var hasOptions = ((_col$options3 = col.options) === null || _col$options3 === void 0 ? void 0 : _col$options3.length) > 0;
49612
49636
  if (col.type === 'selectMultiple' && hasOptions) {
49613
49637
  f[col.field] = {
49614
49638
  value: null,
@@ -49756,27 +49780,37 @@ var Table$1 = function Table(_ref13) {
49756
49780
  }, []);
49757
49781
  var selectTemplate = useCallback(function (col) {
49758
49782
  return function (rowData) {
49759
- var _col$options2;
49783
+ var _col$options4;
49760
49784
  var val = rowData[col.field];
49761
- var opt = (_col$options2 = col.options) === null || _col$options2 === void 0 ? void 0 : _col$options2.find(function (o) {
49785
+ var opt = val !== null && val !== undefined && _typeof$g(val) === 'object' && 'value' in val ? val : (_col$options4 = col.options) === null || _col$options4 === void 0 ? void 0 : _col$options4.find(function (o) {
49762
49786
  return o.value === val;
49763
49787
  });
49764
49788
  if (!opt) return val !== null && val !== void 0 ? val : '';
49765
- if (!normalizeColor(opt.color)) return opt.label;
49789
+ var bg = normalizeColor(opt.color);
49766
49790
  return /*#__PURE__*/React__default.createElement("span", {
49767
49791
  className: "tab_label",
49768
49792
  style: {
49769
- backgroundColor: normalizeColor(opt.color),
49770
- color: textColorForBg(normalizeColor(opt.color))
49793
+ backgroundColor: bg !== null && bg !== void 0 ? bg : 'transparent',
49794
+ color: bg ? textColorForBg(bg) : 'inherit',
49795
+ display: 'inline-flex',
49796
+ alignItems: 'center',
49797
+ gap: '4px',
49798
+ border: bg ? 'none' : '1px solid #e5e7eb'
49799
+ }
49800
+ }, opt.icon && /*#__PURE__*/React__default.createElement("span", {
49801
+ className: "material-icons",
49802
+ style: {
49803
+ fontSize: '14px',
49804
+ lineHeight: 1
49771
49805
  }
49772
- }, opt.label);
49806
+ }, opt.icon), opt.label);
49773
49807
  };
49774
49808
  }, []);
49775
49809
  var lienFormulaireTemplate = useCallback(function (col) {
49776
49810
  return function (rowData) {
49777
- var _col$options3, _ref15, _opt$label, _ref16, _col$href2;
49811
+ var _col$options5, _ref15, _opt$label, _ref16, _col$href2;
49778
49812
  var val = rowData[col.field];
49779
- var opt = (_col$options3 = col.options) === null || _col$options3 === void 0 ? void 0 : _col$options3.find(function (o) {
49813
+ var opt = (_col$options5 = col.options) === null || _col$options5 === void 0 ? void 0 : _col$options5.find(function (o) {
49780
49814
  return o.value === val;
49781
49815
  });
49782
49816
  var label = (_ref15 = (_opt$label = opt === null || opt === void 0 ? void 0 : opt.label) !== null && _opt$label !== void 0 ? _opt$label : val) !== null && _ref15 !== void 0 ? _ref15 : '';
@@ -49829,18 +49863,40 @@ var Table$1 = function Table(_ref13) {
49829
49863
  };
49830
49864
  var colorTextTemplate = useCallback(function (col) {
49831
49865
  return function (rowData) {
49832
- var _rowData$col$hrefFiel, _col$href3;
49866
+ var _rowData, _rowData$col$hrefFiel, _col$href3;
49833
49867
  var text = rowData[col.field];
49834
49868
  if (!text) return '';
49835
49869
  var color = normalizeColor(rowData[col.field + 'Color']) || normalizeColor(col.defaultColor) || null;
49870
+ var icon = (_rowData = rowData[col.field + 'Icon']) !== null && _rowData !== void 0 ? _rowData : null;
49836
49871
  var href = col.hrefField ? (_rowData$col$hrefFiel = rowData[col.hrefField]) !== null && _rowData$col$hrefFiel !== void 0 ? _rowData$col$hrefFiel : '#' : (_col$href3 = col.href) !== null && _col$href3 !== void 0 ? _col$href3 : null;
49837
49872
  var inner = color ? /*#__PURE__*/React__default.createElement("span", {
49838
49873
  className: "tab_label",
49839
49874
  style: {
49840
49875
  backgroundColor: color,
49841
- color: textColorForBg(color)
49876
+ color: textColorForBg(color),
49877
+ display: 'inline-flex',
49878
+ alignItems: 'center',
49879
+ gap: '4px'
49880
+ }
49881
+ }, icon && /*#__PURE__*/React__default.createElement("span", {
49882
+ className: "material-icons",
49883
+ style: {
49884
+ fontSize: '14px',
49885
+ lineHeight: 1
49886
+ }
49887
+ }, icon), text) : /*#__PURE__*/React__default.createElement("span", {
49888
+ style: {
49889
+ display: 'inline-flex',
49890
+ alignItems: 'center',
49891
+ gap: '4px'
49892
+ }
49893
+ }, icon && /*#__PURE__*/React__default.createElement("span", {
49894
+ className: "material-icons",
49895
+ style: {
49896
+ fontSize: '14px',
49897
+ lineHeight: 1
49842
49898
  }
49843
- }, text) : /*#__PURE__*/React__default.createElement("span", null, text);
49899
+ }, icon), text);
49844
49900
  if (!href) return inner;
49845
49901
  return /*#__PURE__*/React__default.createElement("a", {
49846
49902
  href: href,
@@ -49923,9 +49979,9 @@ var Table$1 = function Table(_ref13) {
49923
49979
  }, []);
49924
49980
  var journalTemplate = useCallback(function (col) {
49925
49981
  return function (rowData) {
49926
- var _rowData$col$field5, _rowData;
49982
+ var _rowData$col$field5, _rowData2;
49927
49983
  var count = parseInt((_rowData$col$field5 = rowData[col.field]) !== null && _rowData$col$field5 !== void 0 ? _rowData$col$field5 : 0, 10);
49928
- var href = (_rowData = rowData[col.field + 'Url']) !== null && _rowData !== void 0 ? _rowData : '#';
49984
+ var href = (_rowData2 = rowData[col.field + 'Url']) !== null && _rowData2 !== void 0 ? _rowData2 : '#';
49929
49985
  return /*#__PURE__*/React__default.createElement("a", {
49930
49986
  href: href,
49931
49987
  title: "Journal",
@@ -50118,8 +50174,8 @@ var Table$1 = function Table(_ref13) {
50118
50174
  var vals = rowData[col.field];
50119
50175
  if (!(vals !== null && vals !== void 0 && vals.length)) return '';
50120
50176
  var opts = vals.map(function (v) {
50121
- var _col$options4;
50122
- return (_col$options4 = col.options) === null || _col$options4 === void 0 ? void 0 : _col$options4.find(function (o) {
50177
+ var _col$options6;
50178
+ return v !== null && v !== undefined && _typeof$g(v) === 'object' && 'value' in v ? v : (_col$options6 = col.options) === null || _col$options6 === void 0 ? void 0 : _col$options6.find(function (o) {
50123
50179
  return o.value === v;
50124
50180
  });
50125
50181
  }).filter(Boolean);
@@ -50301,8 +50357,8 @@ var Table$1 = function Table(_ref13) {
50301
50357
  if ((col === null || col === void 0 ? void 0 : col.type) === 'treeSelect' || (col === null || col === void 0 ? void 0 : col.type) === 'devise') return;
50302
50358
  var enrichedRow = newRowData;
50303
50359
  if (col !== null && col !== void 0 && col.updates) {
50304
- var _col$options5;
50305
- var option = (_col$options5 = col.options) === null || _col$options5 === void 0 ? void 0 : _col$options5.find(function (opt) {
50360
+ var _col$options7;
50361
+ var option = (_col$options7 = col.options) === null || _col$options7 === void 0 ? void 0 : _col$options7.find(function (opt) {
50306
50362
  return opt.value === newRowData[field];
50307
50363
  });
50308
50364
  if (option) {
@@ -50433,8 +50489,8 @@ var Table$1 = function Table(_ref13) {
50433
50489
  var _onCellChangeRef$curr2;
50434
50490
  var enrichedFields = _defineProperty$g({}, col.field, v);
50435
50491
  if (col.updates) {
50436
- var _col$options6;
50437
- var option = (_col$options6 = col.options) === null || _col$options6 === void 0 ? void 0 : _col$options6.find(function (opt) {
50492
+ var _col$options8;
50493
+ var option = (_col$options8 = col.options) === null || _col$options8 === void 0 ? void 0 : _col$options8.find(function (opt) {
50438
50494
  return opt.value === v;
50439
50495
  });
50440
50496
  if (option) {
@@ -50813,7 +50869,22 @@ var Table$1 = function Table(_ref13) {
50813
50869
  height: "calc(100vh - ".concat(headerH, "px)")
50814
50870
  };
50815
50871
  }() : undefined
50816
- }, /*#__PURE__*/React__default.createElement(DataTable, {
50872
+ }, onAdd && /*#__PURE__*/React__default.createElement("div", {
50873
+ style: {
50874
+ display: 'flex',
50875
+ justifyContent: 'flex-end',
50876
+ padding: '0 0 8px 0'
50877
+ }
50878
+ }, /*#__PURE__*/React__default.createElement("div", {
50879
+ className: "btn btn-add",
50880
+ onClick: onAdd,
50881
+ style: {
50882
+ border: '2px solid #1E976A',
50883
+ color: '#1E976A',
50884
+ padding: '5px 12px',
50885
+ cursor: 'pointer'
50886
+ }
50887
+ }, addLabel)), /*#__PURE__*/React__default.createElement(DataTable, {
50817
50888
  key: tableKey,
50818
50889
  value: data,
50819
50890
  header: header,
@@ -50841,22 +50912,6 @@ var Table$1 = function Table(_ref13) {
50841
50912
  editingRows: rowEdit ? editingRows : undefined,
50842
50913
  onRowEditChange: rowEdit ? onRowEditChange : undefined,
50843
50914
  onRowEditComplete: rowEdit ? onRowEditComplete : undefined,
50844
- footer: onAdd ? /*#__PURE__*/React__default.createElement("div", {
50845
- style: {
50846
- display: 'flex',
50847
- justifyContent: 'center',
50848
- padding: '8px 0'
50849
- }
50850
- }, /*#__PURE__*/React__default.createElement("div", {
50851
- className: "btn btn-add",
50852
- onClick: onAdd,
50853
- style: {
50854
- border: '2px solid #1E976A',
50855
- color: '#1E976A',
50856
- padding: '5px 12px',
50857
- cursor: 'pointer'
50858
- }
50859
- }, addLabel)) : null,
50860
50915
  dataKey: "id",
50861
50916
  tableClassName: 'arengi-table',
50862
50917
  resizableColumns: true,
@@ -51061,7 +51116,7 @@ var Table$1 = function Table(_ref13) {
51061
51116
  }
51062
51117
  });
51063
51118
  }(), visibleColumns.map(function (col, index) {
51064
- var _col$field, _col$options7, _col$minWidth;
51119
+ var _col$field, _col$options9, _col$minWidth;
51065
51120
  return /*#__PURE__*/React__default.createElement(Column, {
51066
51121
  key: (_col$field = col.field) !== null && _col$field !== void 0 ? _col$field : index,
51067
51122
  sortable: true,
@@ -51070,7 +51125,7 @@ var Table$1 = function Table(_ref13) {
51070
51125
  header: col.header,
51071
51126
  filter: filterVisible,
51072
51127
  filterField: col.field,
51073
- filterElement: (col.type === 'select' || col.type === 'label' || col.type === 'selectMultiple') && (_col$options7 = col.options) !== null && _col$options7 !== void 0 && _col$options7.length ? function (opts) {
51128
+ filterElement: (col.type === 'select' || col.type === 'label' || col.type === 'selectMultiple') && (_col$options9 = col.options) !== null && _col$options9 !== void 0 && _col$options9.length ? function (opts) {
51074
51129
  return selectFilterElement(opts, col);
51075
51130
  } : textFilterElement,
51076
51131
  showFilterMenu: false,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "arengibook",
3
3
  "private": false,
4
- "version": "2.1.1-table",
4
+ "version": "2.1.2-table",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
7
7
  "exports": {