@luminati-io/uikit 3.4.10 → 3.4.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -33111,7 +33111,18 @@ var DragDrop = function DragDrop(props) {
33111
33111
  matrix = _removeItem.matrix,
33112
33112
  item = _removeItem.item;
33113
33113
  var newValue = addItem(matrix, dst_drop_id, +destination.index, item);
33114
- if (onChange) onChange(newValue);
33114
+ var info = {
33115
+ id: item,
33116
+ source: {
33117
+ section: src_drop_id,
33118
+ index: source.index
33119
+ },
33120
+ destination: {
33121
+ section: dst_drop_id,
33122
+ index: destination.index
33123
+ }
33124
+ };
33125
+ onChange(newValue, info);
33115
33126
  }, [value, onChange]);
33116
33127
  var itemsMap = (0,react__WEBPACK_IMPORTED_MODULE_1__.useMemo)(function () {
33117
33128
  return items.reduce(function (acc, item) {
@@ -33135,7 +33146,8 @@ var DragDrop = function DragDrop(props) {
33135
33146
  isLast: i == value.length - 1,
33136
33147
  containerDirection: direction,
33137
33148
  Comp: props.CustomDrop,
33138
- DragComp: props.CustomDrag
33149
+ DragComp: props.CustomDrag,
33150
+ EmptyComp: props.EmptyComp
33139
33151
  });
33140
33152
  })));
33141
33153
  };
@@ -33284,6 +33296,7 @@ var DroppableArea = function DroppableArea(props) {
33284
33296
  containerDirection = props.containerDirection;
33285
33297
  var Comp = props.Comp || DropComp;
33286
33298
  var DragComp = props.DragComp || _draggable__WEBPACK_IMPORTED_MODULE_6__.DraggableItem;
33299
+ var EmptyComp = props.EmptyComp || EmptyDrop;
33287
33300
  var get_draggable = (0,react__WEBPACK_IMPORTED_MODULE_1__.useCallback)(function (provided, snapshot, item) {
33288
33301
  return /*#__PURE__*/React.createElement("div", _extends({}, provided.draggableProps, {
33289
33302
  ref: provided.innerRef
@@ -33302,7 +33315,7 @@ var DroppableArea = function DroppableArea(props) {
33302
33315
  }, function (drop_provided, drop_snapshot) {
33303
33316
  return /*#__PURE__*/React.createElement("div", _extends({}, drop_provided.droppableProps, {
33304
33317
  ref: drop_provided.innerRef
33305
- }), items.map(function (item, i) {
33318
+ }), !(items !== null && items !== void 0 && items.length) && /*#__PURE__*/React.createElement(EmptyComp, null), items.map(function (item, i) {
33306
33319
  return /*#__PURE__*/React.createElement(react_beautiful_dnd__WEBPACK_IMPORTED_MODULE_7__.Draggable, {
33307
33320
  key: item.id,
33308
33321
  draggableId: item.id,
@@ -33310,9 +33323,19 @@ var DroppableArea = function DroppableArea(props) {
33310
33323
  }, function (provided, snapshot) {
33311
33324
  return snapshot.isDragging && portal ? /*#__PURE__*/react_dom__WEBPACK_IMPORTED_MODULE_0___default().createPortal(get_draggable(provided, snapshot, item), portal.current) : get_draggable(provided, snapshot, item);
33312
33325
  });
33313
- }));
33326
+ }), drop_provided.placeholder);
33314
33327
  }));
33315
33328
  };
33329
+ var EmptyDrop = function EmptyDrop() {
33330
+ return /*#__PURE__*/React.createElement(_typography__WEBPACK_IMPORTED_MODULE_4__.Label, {
33331
+ color: "gray_8",
33332
+ variant: "xs",
33333
+ style: {
33334
+ fontStyle: 'italic',
33335
+ padding: '12px'
33336
+ }
33337
+ }, "Empty");
33338
+ };
33316
33339
  var DropComp = function DropComp(props) {
33317
33340
  return /*#__PURE__*/React.createElement(SectionFlex, {
33318
33341
  flex_direction: "column",
@@ -38141,12 +38164,15 @@ __webpack_require__.r(__webpack_exports__);
38141
38164
 
38142
38165
  /*jslint react:true*/
38143
38166
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
38167
+ var _excluded = ["Dragger", "isDragging"];
38168
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
38169
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
38170
+ 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); }
38144
38171
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
38145
38172
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
38146
38173
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
38147
38174
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
38148
38175
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
38149
- 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); }
38150
38176
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
38151
38177
  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."); }
38152
38178
  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); }
@@ -38167,7 +38193,9 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
38167
38193
 
38168
38194
  var CustomizeButton = function CustomizeButton(props) {
38169
38195
  var _useTableContext = (0,_context__WEBPACK_IMPORTED_MODULE_11__.useTableContext)(),
38170
- allColumns = _useTableContext.allColumns;
38196
+ allColumns = _useTableContext.allColumns,
38197
+ canOrderColumns = _useTableContext.canOrderColumns,
38198
+ orderLogic = _useTableContext.orderLogic;
38171
38199
  var _useState = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(''),
38172
38200
  _useState2 = _slicedToArray(_useState, 2),
38173
38201
  search = _useState2[0],
@@ -38180,16 +38208,13 @@ var CustomizeButton = function CustomizeButton(props) {
38180
38208
  });
38181
38209
  if (!columns.length) return null;
38182
38210
  var filtered = columns.filter(searchColumn(search));
38183
- var items = filtered.map(function (c) {
38184
- return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(CustomizeButtonItem, _extends({
38185
- key: c.id
38186
- }, c));
38187
- });
38211
+ var orderProps = canOrderColumns && orderLogic;
38188
38212
  return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(CustomizeButtonWithPopover, {
38189
38213
  popoverProps: _objectSpread(_objectSpread({}, props), {}, {
38190
- items: items,
38214
+ items: filtered,
38191
38215
  search: search,
38192
- setSearch: setSearch
38216
+ setSearch: setSearch,
38217
+ orderProps: orderProps
38193
38218
  })
38194
38219
  });
38195
38220
  };
@@ -38247,13 +38272,20 @@ var CustomizeButtonPopover = function CustomizeButtonPopover(props) {
38247
38272
  search = props.search,
38248
38273
  setSearch = props.setSearch,
38249
38274
  maxMenuHeight = props.maxMenuHeight,
38250
- items = props.items;
38275
+ items = props.items,
38276
+ orderProps = props.orderProps;
38277
+ var maxHeight = Number.parseInt(maxMenuHeight);
38278
+ var _maxMenuHeight = orderProps && (!maxHeight || maxHeight < 600) ? 600 : maxMenuHeight;
38251
38279
  return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(PopoverContainer, null, searchable && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(Search, {
38252
38280
  search: search,
38253
38281
  setSearch: setSearch
38254
38282
  }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(ItemsWrapper, {
38255
- $maxMenuHeight: maxMenuHeight
38256
- }, items));
38283
+ $maxMenuHeight: _maxMenuHeight
38284
+ }, orderProps ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(CustomizeButtonDraggableItems, _extends({
38285
+ items: items
38286
+ }, orderProps)) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(CustomizeButtonStaticItems, {
38287
+ items: items
38288
+ })));
38257
38289
  };
38258
38290
  CustomizeButtonPopover.displayName = 'CustomizeButtonPopover';
38259
38291
  var CustomizeButtonWithPopover = (0,_hoc__WEBPACK_IMPORTED_MODULE_3__.withPopover)(function (p) {
@@ -38265,6 +38297,82 @@ var CustomizeButtonWithPopover = (0,_hoc__WEBPACK_IMPORTED_MODULE_3__.withPopove
38265
38297
  }, CustomizeButtonPopover, {
38266
38298
  placement: 'bottom'
38267
38299
  });
38300
+ var CustomizeButtonStaticItems = function CustomizeButtonStaticItems(_ref) {
38301
+ var items = _ref.items;
38302
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement((react__WEBPACK_IMPORTED_MODULE_1___default().Fragment), null, items.map(function (c) {
38303
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(CustomizeButtonItem, _extends({
38304
+ key: c.id
38305
+ }, c));
38306
+ }));
38307
+ };
38308
+ var CustomizeButtonDraggableItems = function CustomizeButtonDraggableItems(props) {
38309
+ var items = props.items,
38310
+ orders = props.orders,
38311
+ moveColumn = props.moveColumn;
38312
+ var sections = (0,react__WEBPACK_IMPORTED_MODULE_1__.useMemo)(function () {
38313
+ var _orders$pinned;
38314
+ return [((_orders$pinned = orders.pinned) === null || _orders$pinned === void 0 ? void 0 : _orders$pinned.length) && {
38315
+ name: 'Pinned',
38316
+ sectionId: 'pinned'
38317
+ }, {
38318
+ name: 'Visible',
38319
+ sectionId: 'visible'
38320
+ }, {
38321
+ name: 'Hidden',
38322
+ sectionId: 'hidden'
38323
+ }].filter(Boolean);
38324
+ }, [orders]);
38325
+ var sectionIds = (0,react__WEBPACK_IMPORTED_MODULE_1__.useMemo)(function () {
38326
+ return sections.map(function (sec) {
38327
+ return sec.sectionId;
38328
+ });
38329
+ }, [sections]);
38330
+ var value = (0,react__WEBPACK_IMPORTED_MODULE_1__.useMemo)(function () {
38331
+ var filtered = new Set(items.map(function (it) {
38332
+ return it.id;
38333
+ }));
38334
+ return sectionIds.map(function (sec) {
38335
+ return orders[sec].filter(function (id) {
38336
+ return filtered.has(id);
38337
+ });
38338
+ });
38339
+ }, [items, sectionIds, orders]);
38340
+ var onChange = (0,react__WEBPACK_IMPORTED_MODULE_1__.useCallback)(function (newOrder, info) {
38341
+ var n,
38342
+ id = info.id,
38343
+ cat = sectionIds[info.destination.section];
38344
+ var dstIndex = info.destination.index;
38345
+ if (dstIndex == value[info.destination.section].length) n = orders[cat].length;else {
38346
+ var currentItem = value[info.destination.section][dstIndex];
38347
+ n = orders[cat].indexOf(currentItem);
38348
+ }
38349
+ moveColumn(id, cat, n);
38350
+ }, [sectionIds, value, orders, moveColumn]);
38351
+ var _items = (0,react__WEBPACK_IMPORTED_MODULE_1__.useMemo)(function () {
38352
+ return items.map(function (it) {
38353
+ return _objectSpread({
38354
+ name: it.id
38355
+ }, it);
38356
+ });
38357
+ }, [items]);
38358
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_input__WEBPACK_IMPORTED_MODULE_6__.DragDrop, {
38359
+ value: value,
38360
+ onChange: onChange,
38361
+ items: _items,
38362
+ sections: sections,
38363
+ direction: "column",
38364
+ CustomDrag: CustomizeButtonDraggableItem
38365
+ });
38366
+ };
38367
+ var CustomizeButtonDraggableItem = function CustomizeButtonDraggableItem(props) {
38368
+ var Dragger = props.Dragger,
38369
+ isDragging = props.isDragging,
38370
+ itemProps = _objectWithoutProperties(props, _excluded);
38371
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_input__WEBPACK_IMPORTED_MODULE_6__.DragDrop.DraggableItem, {
38372
+ Dragger: Dragger,
38373
+ isDragging: isDragging
38374
+ }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(CustomizeButtonItem, itemProps));
38375
+ };
38268
38376
  var CustomizeButtonItem = function CustomizeButtonItem(props) {
38269
38377
  var id = props.id,
38270
38378
  name = props.name,
@@ -39118,7 +39226,7 @@ var useOrderLogic = function useOrderLogic(table) {
39118
39226
  pinnedColumns = _table$state.pinnedColumns,
39119
39227
  setColumnOrder = table.setColumnOrder,
39120
39228
  setHiddenColumns = table.setHiddenColumns,
39121
- setPinnedColumns = table.setPinnedColumns,
39229
+ togglePinColumn = table.togglePinColumn,
39122
39230
  allColumns = table.allColumns;
39123
39231
  var getColumnCategory = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (id) {
39124
39232
  if (hiddenColumns.includes(id)) return 'hidden';
@@ -39172,13 +39280,11 @@ var useOrderLogic = function useOrderLogic(table) {
39172
39280
  var category = getColumnCategory(id);
39173
39281
  var arr = orders[category];
39174
39282
  var n = arr.indexOf(id);
39175
- console.log('orders1', orders, category, n);
39176
39283
  if (n <= 0) return;
39177
39284
  var new_arr = arr.toSpliced(n, 1);
39178
39285
  new_arr.splice(n - 1, 0, id);
39179
39286
  var newOrder = _objectSpread({}, orders);
39180
39287
  newOrder[category] = new_arr;
39181
- console.log('orders', orders, newOrder);
39182
39288
  setOrders(newOrder);
39183
39289
  }, [getColumnCategory, orders, setOrders]);
39184
39290
  var moveForward = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (id) {
@@ -39199,12 +39305,12 @@ var useOrderLogic = function useOrderLogic(table) {
39199
39305
  newOrders[srcCat] = newOrders[srcCat].filter(function (_id) {
39200
39306
  return _id != id;
39201
39307
  });
39202
- newOrders[cat] = newOrders.toSpliced(n, 0, id);
39308
+ newOrders[cat] = newOrders[cat].toSpliced(n, 0, id);
39203
39309
  setOrders(newOrders);
39204
39310
  if (srcCat == cat) return;
39205
39311
  if (srcCat == 'hidden' || cat == 'hidden') setHiddenColumns(newOrders.hidden);
39206
- if (srcCat == 'pinned' || cat == 'pinned') setPinnedColumns(newOrders.pinned);
39207
- }, [getColumnCategory, orders, setOrders, setHiddenColumns, setPinnedColumns]);
39312
+ if (srcCat == 'pinned' || cat == 'pinned') togglePinColumn(id, cat == 'pinned');
39313
+ }, [getColumnCategory, orders, setOrders, setHiddenColumns]);
39208
39314
  var res = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () {
39209
39315
  return {
39210
39316
  orders: orders,