@luminati-io/uikit 3.4.8 → 3.4.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -30467,11 +30467,13 @@ var CodeBlock = function CodeBlock(props) {
30467
30467
  themeProp = props.theme,
30468
30468
  lineNumbers = props.lineNumbers,
30469
30469
  copyButton = props.copyButton,
30470
- onCopy = props.onCopy;
30470
+ onCopy = props.onCopy,
30471
+ with_dropdown = props.with_dropdown;
30471
30472
  return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(CodeBlockWrapper, {
30472
30473
  className: className,
30473
30474
  "data-testid": "code_block"
30474
30475
  }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(CodeBlockHeader, {
30476
+ $with_dropdown: with_dropdown,
30475
30477
  $theme: themeProp
30476
30478
  }, header), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_code_snippet__WEBPACK_IMPORTED_MODULE_5__.CodeSnippet, {
30477
30479
  max_height: max_height,
@@ -30503,16 +30505,16 @@ var CodeBlockWrapper = styled_components__WEBPACK_IMPORTED_MODULE_1___default().
30503
30505
  })(["border-radius:4px;overflow:hidden;font-family:", ";font-size:", ";"], _theme__WEBPACK_IMPORTED_MODULE_3__["default"].font_family.sans, _theme__WEBPACK_IMPORTED_MODULE_3__["default"].font_size.md);
30504
30506
  var CodeBlockHeader = styled_components__WEBPACK_IMPORTED_MODULE_1___default()(_layout__WEBPACK_IMPORTED_MODULE_4__.Flex).attrs({
30505
30507
  align_items: 'center',
30506
- justify_content: 'space-between',
30507
- padding: '0.9em 1em'
30508
+ justify_content: 'space-between'
30508
30509
  }).withConfig({
30509
30510
  displayName: "CodeBlockHeader",
30510
30511
  componentId: "sc-dgi5hi-1"
30511
30512
  })(["", ""], function (props) {
30513
+ var padding = props.$with_dropdown ? '0.5em 0.8em' : '0.9em 1em';
30512
30514
  if (props.$theme == 'white') {
30513
- return (0,styled_components__WEBPACK_IMPORTED_MODULE_1__.css)(["background-color:", ";color:", ";border-bottom:1px solid ", ";"], _theme__WEBPACK_IMPORTED_MODULE_3__["default"].color.gray_2, _theme__WEBPACK_IMPORTED_MODULE_3__["default"].color.gray_9, _theme__WEBPACK_IMPORTED_MODULE_3__["default"].color.gray_5);
30515
+ return (0,styled_components__WEBPACK_IMPORTED_MODULE_1__.css)(["padding:", ";background-color:", ";color:", ";border-bottom:1px solid ", ";"], padding, _theme__WEBPACK_IMPORTED_MODULE_3__["default"].color.gray_2, _theme__WEBPACK_IMPORTED_MODULE_3__["default"].color.gray_9, _theme__WEBPACK_IMPORTED_MODULE_3__["default"].color.gray_5);
30514
30516
  }
30515
- return (0,styled_components__WEBPACK_IMPORTED_MODULE_1__.css)(["background-color:", ";color:", ";"], _theme__WEBPACK_IMPORTED_MODULE_3__["default"].color.gray_11_50, _theme__WEBPACK_IMPORTED_MODULE_3__["default"].color.gray_9);
30517
+ return (0,styled_components__WEBPACK_IMPORTED_MODULE_1__.css)(["padding:", ";background-color:", ";color:", ";"], padding, _theme__WEBPACK_IMPORTED_MODULE_3__["default"].color.gray_11_50, _theme__WEBPACK_IMPORTED_MODULE_3__["default"].color.gray_9);
30516
30518
  });
30517
30519
 
30518
30520
  /***/ }),
@@ -31765,7 +31767,7 @@ Icon.propTypes = {
31765
31767
  name: prop_types__WEBPACK_IMPORTED_MODULE_2___default().oneOf(_utils__WEBPACK_IMPORTED_MODULE_5__.iconNames).isRequired,
31766
31768
  color: prop_types__WEBPACK_IMPORTED_MODULE_2___default().oneOf(_utils__WEBPACK_IMPORTED_MODULE_5__.colorNames),
31767
31769
  size: prop_types__WEBPACK_IMPORTED_MODULE_2___default().oneOf(['xxs', 'xs', 'sm', 'md', 'lg', 'xl']),
31768
- verticalAlign: prop_types__WEBPACK_IMPORTED_MODULE_2___default().oneOf(['top', 'middle', 'bottom', 'baseline', 'text-top', 'text-bottom', 'super'])
31770
+ verticalAlign: prop_types__WEBPACK_IMPORTED_MODULE_2___default().oneOf(['top', 'middle', 'bottom', 'baseline', 'text-top', 'text-bottom', 'super', 'sub'])
31769
31771
  };
31770
31772
  var StyledSvg = styled_components__WEBPACK_IMPORTED_MODULE_1___default().svg.withConfig({
31771
31773
  displayName: "StyledSvg",
@@ -33193,7 +33195,7 @@ var DraggableItem = function DraggableItem(props) {
33193
33195
  Dragger = props.Dragger,
33194
33196
  isDragging = props.isDragging;
33195
33197
  return /*#__PURE__*/React.createElement(DraggedContainer, {
33196
- isDragging: isDragging
33198
+ $dragging: isDragging
33197
33199
  }, /*#__PURE__*/React.createElement(Dragger, null, !disableDrag && /*#__PURE__*/React.createElement(_icon__WEBPACK_IMPORTED_MODULE_3__.Icon, {
33198
33200
  name: "DragAndDrop",
33199
33201
  size: "xs",
@@ -33214,7 +33216,7 @@ var DraggedContainer = styled_components__WEBPACK_IMPORTED_MODULE_0___default()(
33214
33216
  displayName: "DraggedContainer",
33215
33217
  componentId: "sc-167vnen-0"
33216
33218
  })(["border-radius:4px;&:hover{background-color:", ";}", ""], _theme__WEBPACK_IMPORTED_MODULE_4__["default"].color.gray_2, function (props) {
33217
- return props.isDragging && (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.css)(["background-color:", ";"], _theme__WEBPACK_IMPORTED_MODULE_4__["default"].color.gray_3);
33219
+ return props.$dragging && (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.css)(["background-color:", ";"], _theme__WEBPACK_IMPORTED_MODULE_4__["default"].color.gray_3);
33218
33220
  });
33219
33221
  var Truncated_label = styled_components__WEBPACK_IMPORTED_MODULE_0___default()(_typography__WEBPACK_IMPORTED_MODULE_2__.Label).withConfig({
33220
33222
  displayName: "Truncated_label",
@@ -33309,8 +33311,8 @@ var DroppableArea = function DroppableArea(props) {
33309
33311
  var DropComp = function DropComp(props) {
33310
33312
  return /*#__PURE__*/React.createElement(SectionFlex, {
33311
33313
  flex_direction: "column",
33312
- isLast: props.isLast,
33313
- containerDirection: props.containerDirection
33314
+ $last: props.isLast,
33315
+ $direction: props.containerDirection
33314
33316
  }, /*#__PURE__*/React.createElement(_typography__WEBPACK_IMPORTED_MODULE_4__.Label, {
33315
33317
  style: {
33316
33318
  marginTop: '6px',
@@ -33319,14 +33321,14 @@ var DropComp = function DropComp(props) {
33319
33321
  }, props.name || 'Section ' + props.index), props.children);
33320
33322
  };
33321
33323
  var borderProp = function borderProp(_ref) {
33322
- var containerDirection = _ref.containerDirection;
33323
- return 'border-' + (containerDirection == 'row' ? 'right' : 'bottom');
33324
+ var $direction = _ref.$direction;
33325
+ return 'border-' + ($direction == 'row' ? 'right' : 'bottom');
33324
33326
  };
33325
33327
  var SectionFlex = styled_components__WEBPACK_IMPORTED_MODULE_2___default()(_layout__WEBPACK_IMPORTED_MODULE_3__.Flex).withConfig({
33326
33328
  displayName: "SectionFlex",
33327
33329
  componentId: "sc-2htus7-0"
33328
33330
  })(["padding-right:8px;padding-left:8px;", ""], function (props) {
33329
- return !props.isLast && (0,styled_components__WEBPACK_IMPORTED_MODULE_2__.css)(["", ":1px solid ", ";"], borderProp(props), _theme__WEBPACK_IMPORTED_MODULE_5__["default"].color.gray_4);
33331
+ return !props.$last && (0,styled_components__WEBPACK_IMPORTED_MODULE_2__.css)(["", ":1px solid ", ";"], borderProp(props), _theme__WEBPACK_IMPORTED_MODULE_5__["default"].color.gray_4);
33330
33332
  });
33331
33333
  DroppableArea.displayName = 'DroppableArea';
33332
33334
  DropComp.displayName = 'DropComp';
@@ -37829,12 +37831,13 @@ __webpack_require__.r(__webpack_exports__);
37829
37831
  /* harmony import */ var _pinned_columns__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./pinned_columns */ "./src/table/pinned_columns.js");
37830
37832
  /* harmony import */ var _expandable_rows__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./expandable_rows */ "./src/table/expandable_rows.js");
37831
37833
  /* harmony import */ var _select_rows__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./select_rows */ "./src/table/select_rows.js");
37834
+ /* harmony import */ var _order_logic__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./order_logic */ "./src/table/order_logic.js");
37832
37835
  // LICENSE_CODE ZON
37833
37836
 
37834
37837
 
37835
37838
  /*jslint react:true*/
37836
37839
  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); }
37837
- var _excluded = ["data", "columnsSort", "pageSize", "pageSizes", "children", "stateManager", "hooks", "NoDataComp", "LoadingComp", "ExpandHandleComp", "noDataText", "loadingText", "isLoading", "onPageChange", "manualPagination", "totalCount", "paginateExpandedRows", "getHeaderProps", "getColumnProps", "getRowProps", "getCellProps", "getFooterProps", "selectedRowIds"];
37840
+ var _excluded = ["data", "columnsSort", "pageSize", "pageSizes", "children", "stateManager", "hooks", "NoDataComp", "LoadingComp", "ExpandHandleComp", "noDataText", "loadingText", "isLoading", "onPageChange", "manualPagination", "totalCount", "paginateExpandedRows", "getHeaderProps", "getColumnProps", "getRowProps", "getCellProps", "getFooterProps", "selectedRowIds", "canOrderColumns"];
37838
37841
  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; }
37839
37842
  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; }
37840
37843
  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; }
@@ -37863,6 +37866,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
37863
37866
 
37864
37867
 
37865
37868
 
37869
+
37866
37870
  var assign = Object.assign;
37867
37871
  var defaultPropGetter = function defaultPropGetter() {
37868
37872
  return {};
@@ -37921,6 +37925,8 @@ var Provider = function Provider(props) {
37921
37925
  _props$getFooterProps = props.getFooterProps,
37922
37926
  getFooterProps = _props$getFooterProps === void 0 ? defaultPropGetter : _props$getFooterProps,
37923
37927
  selectedRowIds = props.selectedRowIds,
37928
+ _props$canOrderColumn = props.canOrderColumns,
37929
+ canOrderColumns = _props$canOrderColumn === void 0 ? false : _props$canOrderColumn,
37924
37930
  rest = _objectWithoutProperties(props, _excluded);
37925
37931
  var _useState = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(0),
37926
37932
  _useState2 = _slicedToArray(_useState, 2),
@@ -37973,9 +37979,12 @@ var Provider = function Provider(props) {
37973
37979
  }, [manualPagination, totalCount, pageIndex, _pageSize]);
37974
37980
  var _LoadingComp = useComp(loadingText, LoadingComp);
37975
37981
  var _NoDataComp = useComp(noDataText, NoDataComp);
37982
+ var orderLogic = (0,_order_logic__WEBPACK_IMPORTED_MODULE_11__.useOrderLogic)(table);
37976
37983
  var value = _objectSpread(_objectSpread({
37977
37984
  columnsSort: columnsSort
37978
37985
  }, table), {}, {
37986
+ canOrderColumns: canOrderColumns,
37987
+ orderLogic: orderLogic,
37979
37988
  LoadingComp: _LoadingComp,
37980
37989
  NoDataComp: _NoDataComp
37981
37990
  });
@@ -38000,7 +38009,8 @@ Provider.defaultProps = {
38000
38009
  getRowProps: defaultPropGetter,
38001
38010
  getCellProps: defaultPropGetter,
38002
38011
  getFooterProps: defaultPropGetter,
38003
- rowDensity: 'busy_bee'
38012
+ rowDensity: 'busy_bee',
38013
+ canOrderColumns: false
38004
38014
  };
38005
38015
  Provider.propTypes = {
38006
38016
  columns: prop_types__WEBPACK_IMPORTED_MODULE_0___default().arrayOf(prop_types__WEBPACK_IMPORTED_MODULE_0___default().shape({
@@ -38052,7 +38062,8 @@ Provider.propTypes = {
38052
38062
  stickyHeader: prop_types__WEBPACK_IMPORTED_MODULE_0___default().oneOfType([(prop_types__WEBPACK_IMPORTED_MODULE_0___default().bool), (prop_types__WEBPACK_IMPORTED_MODULE_0___default().object)]),
38053
38063
  scrollTarget: (prop_types__WEBPACK_IMPORTED_MODULE_0___default().any),
38054
38064
  className: (prop_types__WEBPACK_IMPORTED_MODULE_0___default().string),
38055
- onSelectRows: (prop_types__WEBPACK_IMPORTED_MODULE_0___default().func)
38065
+ onSelectRows: (prop_types__WEBPACK_IMPORTED_MODULE_0___default().func),
38066
+ canOrderColumns: (prop_types__WEBPACK_IMPORTED_MODULE_0___default().bool)
38056
38067
  };
38057
38068
  var calcPageCount = function calcPageCount(totalCount, pageSize) {
38058
38069
  return Math.ceil(totalCount / pageSize);
@@ -38685,7 +38696,9 @@ var HeaderCell = function HeaderCell(props) {
38685
38696
  getColumnProps = _useTableContext2.getColumnProps,
38686
38697
  getHeaderProps = _useTableContext2.getHeaderProps,
38687
38698
  columnsSort = _useTableContext2.columnsSort,
38688
- fullWidth = _useTableContext2.fullWidth;
38699
+ fullWidth = _useTableContext2.fullWidth,
38700
+ canOrderColumns = _useTableContext2.canOrderColumns,
38701
+ orderLogic = _useTableContext2.orderLogic;
38689
38702
  var sort = columnsSort[id];
38690
38703
  var canSort = header.can_sort && header.on_sort;
38691
38704
  var handleSort = (0,react__WEBPACK_IMPORTED_MODULE_1__.useCallback)(function () {
@@ -38731,7 +38744,8 @@ var HeaderCell = function HeaderCell(props) {
38731
38744
  visible: hovered,
38732
38745
  onItemClick: function onItemClick() {
38733
38746
  return setHovered(false);
38734
- }
38747
+ },
38748
+ orderLogic: canOrderColumns && orderLogic
38735
38749
  }), canResize && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(HeaderCellResizer, _extends({}, getResizerProps(), {
38736
38750
  $isResizing: isResizing
38737
38751
  }))));
@@ -38813,7 +38827,8 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
38813
38827
  var HeaderFunctions = function HeaderFunctions(props) {
38814
38828
  var header = props.header,
38815
38829
  visible = props.visible,
38816
- onItemClick = props.onItemClick;
38830
+ onItemClick = props.onItemClick,
38831
+ orderLogic = props.orderLogic;
38817
38832
  var id = header.id,
38818
38833
  on_sort = header.on_sort,
38819
38834
  canHide = header.canHide,
@@ -38821,6 +38836,38 @@ var HeaderFunctions = function HeaderFunctions(props) {
38821
38836
  canPin = header.canPin;
38822
38837
  var canSort = header.can_sort && header.on_sort;
38823
38838
  var items = [];
38839
+ if (orderLogic) {
38840
+ var firsts = orderLogic.firsts,
38841
+ lasts = orderLogic.lasts,
38842
+ moveBackwards = orderLogic.moveBackwards,
38843
+ moveForward = orderLogic.moveForward;
38844
+ if (!Object.keys(firsts).includes(id)) {
38845
+ items.push({
38846
+ id: 'move_back',
38847
+ children: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(OrderColumn, {
38848
+ id: id,
38849
+ dir: "back",
38850
+ action: moveBackwards
38851
+ })
38852
+ });
38853
+ }
38854
+ if (!Object.keys(lasts).includes(id)) {
38855
+ items.push({
38856
+ id: 'move_forward',
38857
+ children: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(OrderColumn, {
38858
+ id: id,
38859
+ dir: "forward",
38860
+ action: moveForward
38861
+ })
38862
+ });
38863
+ }
38864
+ if ((canSort || canHide || canPin) && (!Object.keys(firsts).includes(id) || !Object.keys(lasts).includes(id))) {
38865
+ items.push({
38866
+ id: 'sep',
38867
+ $separator: true
38868
+ });
38869
+ }
38870
+ }
38824
38871
  if (canSort) {
38825
38872
  items.push({
38826
38873
  id: 'sort_asc',
@@ -38908,6 +38955,25 @@ var MenuItem = styled_components__WEBPACK_IMPORTED_MODULE_1___default().li.withC
38908
38955
  })(["list-style:none;&:hover{background-color:", ";}", ""], _theme__WEBPACK_IMPORTED_MODULE_5__["default"].color.gray_2, function (props) {
38909
38956
  return props.$separator && (0,styled_components__WEBPACK_IMPORTED_MODULE_1__.css)(["padding:0;height:1px;background-color:", ";&:hover{background-color:", ";}"], _theme__WEBPACK_IMPORTED_MODULE_5__["default"].color.gray_4, _theme__WEBPACK_IMPORTED_MODULE_5__["default"].color.gray_4);
38910
38957
  });
38958
+ var OrderColumn = function OrderColumn(props) {
38959
+ var id = props.id,
38960
+ dir = props.dir,
38961
+ action = props.action;
38962
+ var text = dir == 'back' ? 'Column Left' : 'Column Right';
38963
+ var handleClick = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function () {
38964
+ return action(id);
38965
+ }, [id, action]);
38966
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(FunctionWrapper, {
38967
+ onClick: handleClick
38968
+ }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_icon__WEBPACK_IMPORTED_MODULE_3__.Icon, {
38969
+ name: dir == 'back' ? 'ArrowLeft' : 'ArrowRight',
38970
+ color: "gray_9",
38971
+ size: "xs"
38972
+ }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_typography__WEBPACK_IMPORTED_MODULE_6__.Label, {
38973
+ variant: "sm",
38974
+ color: "gray_11_50"
38975
+ }, text));
38976
+ };
38911
38977
  var SortColumn = function SortColumn(props) {
38912
38978
  var id = props.id,
38913
38979
  sort = props.sort,
@@ -39006,6 +39072,150 @@ _table__WEBPACK_IMPORTED_MODULE_3__["default"].plugins = _plugin__WEBPACK_IMPORT
39006
39072
 
39007
39073
  /***/ }),
39008
39074
 
39075
+ /***/ "./src/table/order_logic.js":
39076
+ /*!**********************************!*\
39077
+ !*** ./src/table/order_logic.js ***!
39078
+ \**********************************/
39079
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
39080
+
39081
+ "use strict";
39082
+ __webpack_require__.r(__webpack_exports__);
39083
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
39084
+ /* harmony export */ useOrderLogic: () => (/* binding */ useOrderLogic)
39085
+ /* harmony export */ });
39086
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
39087
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
39088
+ // LICENSE_CODE ZON
39089
+
39090
+
39091
+ /*jslint react:true*/
39092
+ 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); }
39093
+ 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; }
39094
+ 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; }
39095
+ 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; }
39096
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
39097
+ 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); }
39098
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
39099
+ 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."); }
39100
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
39101
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
39102
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
39103
+ 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."); }
39104
+ 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); }
39105
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
39106
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
39107
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
39108
+
39109
+ var useOrderLogic = function useOrderLogic(table) {
39110
+ var _table$state = table.state,
39111
+ columnOrder = _table$state.columnOrder,
39112
+ hiddenColumns = _table$state.hiddenColumns,
39113
+ pinnedColumns = _table$state.pinnedColumns,
39114
+ setColumnOrder = table.setColumnOrder,
39115
+ setHiddenColumns = table.setHiddenColumns,
39116
+ setPinnedColumns = table.setPinnedColumns,
39117
+ allColumns = table.allColumns;
39118
+ var getColumnCategory = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (id) {
39119
+ if (hiddenColumns.includes(id)) return 'hidden';
39120
+ if (pinnedColumns.includes(id)) return 'pinned';
39121
+ return 'visible';
39122
+ }, [hiddenColumns, pinnedColumns]);
39123
+ var fullOrder = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () {
39124
+ var rest;
39125
+ if (columnOrder.length == allColumns.length) rest = [];else {
39126
+ rest = allColumns.filter(function (c) {
39127
+ return !columnOrder.includes(c.id);
39128
+ }).map(function (c) {
39129
+ return c.id;
39130
+ });
39131
+ }
39132
+ return [].concat(_toConsumableArray(columnOrder), _toConsumableArray(rest));
39133
+ }, [columnOrder, allColumns]);
39134
+ var orders = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () {
39135
+ var _orders = {
39136
+ visible: [],
39137
+ pinned: [],
39138
+ hidden: []
39139
+ };
39140
+ for (var i = 0, l = fullOrder.length; i < l; i++) _orders[getColumnCategory(fullOrder[i])].push(fullOrder[i]);
39141
+ return _orders;
39142
+ }, [fullOrder, getColumnCategory]);
39143
+ var firsts = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () {
39144
+ return Object.fromEntries(Object.entries(orders).map(function (_ref) {
39145
+ var _ref2 = _slicedToArray(_ref, 2),
39146
+ key = _ref2[0],
39147
+ _ref2$ = _slicedToArray(_ref2[1], 1),
39148
+ first = _ref2$[0];
39149
+ return first && [key, first];
39150
+ }).filter(Boolean));
39151
+ }, [orders]);
39152
+ var lasts = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () {
39153
+ return Object.fromEntries(Object.entries(orders).map(function (_ref3) {
39154
+ var _ref4 = _slicedToArray(_ref3, 2),
39155
+ key = _ref4[0],
39156
+ arr = _ref4[1];
39157
+ return arr.length && [key, arr[arr.length - 1]];
39158
+ }).filter(Boolean));
39159
+ }, [orders]);
39160
+ var setOrders = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (_ref5) {
39161
+ var pinned = _ref5.pinned,
39162
+ visible = _ref5.visible,
39163
+ hidden = _ref5.hidden;
39164
+ return setColumnOrder([].concat(_toConsumableArray(pinned), _toConsumableArray(visible), _toConsumableArray(hidden)));
39165
+ }, [setColumnOrder]);
39166
+ var moveBackwards = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (id) {
39167
+ var category = getColumnCategory(id);
39168
+ var arr = orders[category];
39169
+ var n = arr.indexOf(id);
39170
+ console.log('orders1', orders, category, n);
39171
+ if (n <= 0) return;
39172
+ var new_arr = arr.toSpliced(n, 1);
39173
+ new_arr.splice(n - 1, 0, id);
39174
+ var newOrder = _objectSpread({}, orders);
39175
+ newOrder[category] = new_arr;
39176
+ console.log('orders', orders, newOrder);
39177
+ setOrders(newOrder);
39178
+ }, [getColumnCategory, orders, setOrders]);
39179
+ var moveForward = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (id) {
39180
+ var category = getColumnCategory(id);
39181
+ var arr = orders[category];
39182
+ var n = arr.indexOf(id);
39183
+ if (n == -1 || n == arr.length - 1) return;
39184
+ var new_arr = arr.toSpliced(n, 1);
39185
+ new_arr.splice(n + 1, 0, id);
39186
+ var newOrder = _objectSpread({}, orders);
39187
+ newOrder[category] = new_arr;
39188
+ setOrders(newOrder);
39189
+ }, [getColumnCategory, orders, setOrders]);
39190
+ var moveColumn = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (id, cat, n) {
39191
+ var srcCat = getColumnCategory(id);
39192
+ if (srcCat == cat && orders[srcCat][n] == id) return;
39193
+ var newOrders = _objectSpread({}, orders);
39194
+ newOrders[srcCat] = newOrders[srcCat].filter(function (_id) {
39195
+ return _id != id;
39196
+ });
39197
+ newOrders[cat] = newOrders.toSpliced(n, 0, id);
39198
+ setOrders(newOrders);
39199
+ if (srcCat == cat) return;
39200
+ if (srcCat == 'hidden' || cat == 'hidden') setHiddenColumns(newOrders.hidden);
39201
+ if (srcCat == 'pinned' || cat == 'pinned') setPinnedColumns(newOrders.pinned);
39202
+ }, [getColumnCategory, orders, setOrders, setHiddenColumns, setPinnedColumns]);
39203
+ var res = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () {
39204
+ return {
39205
+ orders: orders,
39206
+ firsts: firsts,
39207
+ lasts: lasts,
39208
+ setOrders: setOrders,
39209
+ moveBackwards: moveBackwards,
39210
+ moveForward: moveForward,
39211
+ moveColumn: moveColumn
39212
+ };
39213
+ }, [orders, firsts, lasts, setOrders, moveBackwards, moveForward, moveColumn]);
39214
+ return res;
39215
+ };
39216
+
39217
+ /***/ }),
39218
+
39009
39219
  /***/ "./src/table/pagination.js":
39010
39220
  /*!*********************************!*\
39011
39221
  !*** ./src/table/pagination.js ***!