@luminati-io/uikit 3.4.8 → 3.4.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -30447,11 +30447,14 @@ __webpack_require__.r(__webpack_exports__);
30447
30447
  /* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_2__);
30448
30448
  /* harmony import */ var _theme__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../theme */ "./src/theme.js");
30449
30449
  /* harmony import */ var _layout__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../layout */ "./src/layout/index.js");
30450
- /* harmony import */ var _code_snippet__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./code_snippet */ "./src/code/code_snippet.js");
30450
+ /* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../util */ "./src/util/index.js");
30451
+ /* harmony import */ var _code_snippet__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./code_snippet */ "./src/code/code_snippet.js");
30451
30452
  // LICENSE_CODE ZON
30452
30453
 
30453
30454
 
30454
30455
  /*jslint react:true*/
30456
+ 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); }
30457
+
30455
30458
 
30456
30459
 
30457
30460
 
@@ -30468,12 +30471,17 @@ var CodeBlock = function CodeBlock(props) {
30468
30471
  lineNumbers = props.lineNumbers,
30469
30472
  copyButton = props.copyButton,
30470
30473
  onCopy = props.onCopy;
30471
- return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(CodeBlockWrapper, {
30472
- className: className,
30474
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(CodeBlockWrapper, _extends({
30473
30475
  "data-testid": "code_block"
30474
- }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(CodeBlockHeader, {
30476
+ }, (0,_util__WEBPACK_IMPORTED_MODULE_5__.getCommonProps)(props)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(CodeBlockHeader, {
30477
+ className: (0,_util__WEBPACK_IMPORTED_MODULE_5__.classNames)(className, {
30478
+ header: true
30479
+ }),
30475
30480
  $theme: themeProp
30476
- }, header), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_code_snippet__WEBPACK_IMPORTED_MODULE_5__.CodeSnippet, {
30481
+ }, header), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_code_snippet__WEBPACK_IMPORTED_MODULE_6__.CodeSnippet, {
30482
+ className: (0,_util__WEBPACK_IMPORTED_MODULE_5__.classNames)(className, {
30483
+ snippet: true
30484
+ }),
30477
30485
  max_height: max_height,
30478
30486
  lang: lang,
30479
30487
  code: code,
@@ -30503,12 +30511,11 @@ var CodeBlockWrapper = styled_components__WEBPACK_IMPORTED_MODULE_1___default().
30503
30511
  })(["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
30512
  var CodeBlockHeader = styled_components__WEBPACK_IMPORTED_MODULE_1___default()(_layout__WEBPACK_IMPORTED_MODULE_4__.Flex).attrs({
30505
30513
  align_items: 'center',
30506
- justify_content: 'space-between',
30507
- padding: '0.9em 1em'
30514
+ justify_content: 'space-between'
30508
30515
  }).withConfig({
30509
30516
  displayName: "CodeBlockHeader",
30510
30517
  componentId: "sc-dgi5hi-1"
30511
- })(["", ""], function (props) {
30518
+ })(["padding:0.9em 1em;", ""], function (props) {
30512
30519
  if (props.$theme == 'white') {
30513
30520
  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);
30514
30521
  }
@@ -31765,7 +31772,7 @@ Icon.propTypes = {
31765
31772
  name: prop_types__WEBPACK_IMPORTED_MODULE_2___default().oneOf(_utils__WEBPACK_IMPORTED_MODULE_5__.iconNames).isRequired,
31766
31773
  color: prop_types__WEBPACK_IMPORTED_MODULE_2___default().oneOf(_utils__WEBPACK_IMPORTED_MODULE_5__.colorNames),
31767
31774
  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'])
31775
+ verticalAlign: prop_types__WEBPACK_IMPORTED_MODULE_2___default().oneOf(['top', 'middle', 'bottom', 'baseline', 'text-top', 'text-bottom', 'super', 'sub'])
31769
31776
  };
31770
31777
  var StyledSvg = styled_components__WEBPACK_IMPORTED_MODULE_1___default().svg.withConfig({
31771
31778
  displayName: "StyledSvg",
@@ -33193,7 +33200,7 @@ var DraggableItem = function DraggableItem(props) {
33193
33200
  Dragger = props.Dragger,
33194
33201
  isDragging = props.isDragging;
33195
33202
  return /*#__PURE__*/React.createElement(DraggedContainer, {
33196
- isDragging: isDragging
33203
+ $dragging: isDragging
33197
33204
  }, /*#__PURE__*/React.createElement(Dragger, null, !disableDrag && /*#__PURE__*/React.createElement(_icon__WEBPACK_IMPORTED_MODULE_3__.Icon, {
33198
33205
  name: "DragAndDrop",
33199
33206
  size: "xs",
@@ -33214,7 +33221,7 @@ var DraggedContainer = styled_components__WEBPACK_IMPORTED_MODULE_0___default()(
33214
33221
  displayName: "DraggedContainer",
33215
33222
  componentId: "sc-167vnen-0"
33216
33223
  })(["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);
33224
+ return props.$dragging && (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.css)(["background-color:", ";"], _theme__WEBPACK_IMPORTED_MODULE_4__["default"].color.gray_3);
33218
33225
  });
33219
33226
  var Truncated_label = styled_components__WEBPACK_IMPORTED_MODULE_0___default()(_typography__WEBPACK_IMPORTED_MODULE_2__.Label).withConfig({
33220
33227
  displayName: "Truncated_label",
@@ -33309,8 +33316,8 @@ var DroppableArea = function DroppableArea(props) {
33309
33316
  var DropComp = function DropComp(props) {
33310
33317
  return /*#__PURE__*/React.createElement(SectionFlex, {
33311
33318
  flex_direction: "column",
33312
- isLast: props.isLast,
33313
- containerDirection: props.containerDirection
33319
+ $last: props.isLast,
33320
+ $direction: props.containerDirection
33314
33321
  }, /*#__PURE__*/React.createElement(_typography__WEBPACK_IMPORTED_MODULE_4__.Label, {
33315
33322
  style: {
33316
33323
  marginTop: '6px',
@@ -33319,14 +33326,14 @@ var DropComp = function DropComp(props) {
33319
33326
  }, props.name || 'Section ' + props.index), props.children);
33320
33327
  };
33321
33328
  var borderProp = function borderProp(_ref) {
33322
- var containerDirection = _ref.containerDirection;
33323
- return 'border-' + (containerDirection == 'row' ? 'right' : 'bottom');
33329
+ var $direction = _ref.$direction;
33330
+ return 'border-' + ($direction == 'row' ? 'right' : 'bottom');
33324
33331
  };
33325
33332
  var SectionFlex = styled_components__WEBPACK_IMPORTED_MODULE_2___default()(_layout__WEBPACK_IMPORTED_MODULE_3__.Flex).withConfig({
33326
33333
  displayName: "SectionFlex",
33327
33334
  componentId: "sc-2htus7-0"
33328
33335
  })(["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);
33336
+ 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
33337
  });
33331
33338
  DroppableArea.displayName = 'DroppableArea';
33332
33339
  DropComp.displayName = 'DropComp';
@@ -37829,12 +37836,13 @@ __webpack_require__.r(__webpack_exports__);
37829
37836
  /* harmony import */ var _pinned_columns__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./pinned_columns */ "./src/table/pinned_columns.js");
37830
37837
  /* harmony import */ var _expandable_rows__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./expandable_rows */ "./src/table/expandable_rows.js");
37831
37838
  /* harmony import */ var _select_rows__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./select_rows */ "./src/table/select_rows.js");
37839
+ /* harmony import */ var _order_logic__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./order_logic */ "./src/table/order_logic.js");
37832
37840
  // LICENSE_CODE ZON
37833
37841
 
37834
37842
 
37835
37843
  /*jslint react:true*/
37836
37844
  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"];
37845
+ 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
37846
  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
37847
  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
37848
  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 +37871,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
37863
37871
 
37864
37872
 
37865
37873
 
37874
+
37866
37875
  var assign = Object.assign;
37867
37876
  var defaultPropGetter = function defaultPropGetter() {
37868
37877
  return {};
@@ -37921,6 +37930,8 @@ var Provider = function Provider(props) {
37921
37930
  _props$getFooterProps = props.getFooterProps,
37922
37931
  getFooterProps = _props$getFooterProps === void 0 ? defaultPropGetter : _props$getFooterProps,
37923
37932
  selectedRowIds = props.selectedRowIds,
37933
+ _props$canOrderColumn = props.canOrderColumns,
37934
+ canOrderColumns = _props$canOrderColumn === void 0 ? false : _props$canOrderColumn,
37924
37935
  rest = _objectWithoutProperties(props, _excluded);
37925
37936
  var _useState = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(0),
37926
37937
  _useState2 = _slicedToArray(_useState, 2),
@@ -37973,9 +37984,12 @@ var Provider = function Provider(props) {
37973
37984
  }, [manualPagination, totalCount, pageIndex, _pageSize]);
37974
37985
  var _LoadingComp = useComp(loadingText, LoadingComp);
37975
37986
  var _NoDataComp = useComp(noDataText, NoDataComp);
37987
+ var orderLogic = (0,_order_logic__WEBPACK_IMPORTED_MODULE_11__.useOrderLogic)(table);
37976
37988
  var value = _objectSpread(_objectSpread({
37977
37989
  columnsSort: columnsSort
37978
37990
  }, table), {}, {
37991
+ canOrderColumns: canOrderColumns,
37992
+ orderLogic: orderLogic,
37979
37993
  LoadingComp: _LoadingComp,
37980
37994
  NoDataComp: _NoDataComp
37981
37995
  });
@@ -38000,7 +38014,8 @@ Provider.defaultProps = {
38000
38014
  getRowProps: defaultPropGetter,
38001
38015
  getCellProps: defaultPropGetter,
38002
38016
  getFooterProps: defaultPropGetter,
38003
- rowDensity: 'busy_bee'
38017
+ rowDensity: 'busy_bee',
38018
+ canOrderColumns: false
38004
38019
  };
38005
38020
  Provider.propTypes = {
38006
38021
  columns: prop_types__WEBPACK_IMPORTED_MODULE_0___default().arrayOf(prop_types__WEBPACK_IMPORTED_MODULE_0___default().shape({
@@ -38052,7 +38067,8 @@ Provider.propTypes = {
38052
38067
  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
38068
  scrollTarget: (prop_types__WEBPACK_IMPORTED_MODULE_0___default().any),
38054
38069
  className: (prop_types__WEBPACK_IMPORTED_MODULE_0___default().string),
38055
- onSelectRows: (prop_types__WEBPACK_IMPORTED_MODULE_0___default().func)
38070
+ onSelectRows: (prop_types__WEBPACK_IMPORTED_MODULE_0___default().func),
38071
+ canOrderColumns: (prop_types__WEBPACK_IMPORTED_MODULE_0___default().bool)
38056
38072
  };
38057
38073
  var calcPageCount = function calcPageCount(totalCount, pageSize) {
38058
38074
  return Math.ceil(totalCount / pageSize);
@@ -38685,7 +38701,9 @@ var HeaderCell = function HeaderCell(props) {
38685
38701
  getColumnProps = _useTableContext2.getColumnProps,
38686
38702
  getHeaderProps = _useTableContext2.getHeaderProps,
38687
38703
  columnsSort = _useTableContext2.columnsSort,
38688
- fullWidth = _useTableContext2.fullWidth;
38704
+ fullWidth = _useTableContext2.fullWidth,
38705
+ canOrderColumns = _useTableContext2.canOrderColumns,
38706
+ orderLogic = _useTableContext2.orderLogic;
38689
38707
  var sort = columnsSort[id];
38690
38708
  var canSort = header.can_sort && header.on_sort;
38691
38709
  var handleSort = (0,react__WEBPACK_IMPORTED_MODULE_1__.useCallback)(function () {
@@ -38731,7 +38749,8 @@ var HeaderCell = function HeaderCell(props) {
38731
38749
  visible: hovered,
38732
38750
  onItemClick: function onItemClick() {
38733
38751
  return setHovered(false);
38734
- }
38752
+ },
38753
+ orderLogic: canOrderColumns && orderLogic
38735
38754
  }), canResize && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(HeaderCellResizer, _extends({}, getResizerProps(), {
38736
38755
  $isResizing: isResizing
38737
38756
  }))));
@@ -38813,7 +38832,8 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
38813
38832
  var HeaderFunctions = function HeaderFunctions(props) {
38814
38833
  var header = props.header,
38815
38834
  visible = props.visible,
38816
- onItemClick = props.onItemClick;
38835
+ onItemClick = props.onItemClick,
38836
+ orderLogic = props.orderLogic;
38817
38837
  var id = header.id,
38818
38838
  on_sort = header.on_sort,
38819
38839
  canHide = header.canHide,
@@ -38821,6 +38841,38 @@ var HeaderFunctions = function HeaderFunctions(props) {
38821
38841
  canPin = header.canPin;
38822
38842
  var canSort = header.can_sort && header.on_sort;
38823
38843
  var items = [];
38844
+ if (orderLogic) {
38845
+ var firsts = orderLogic.firsts,
38846
+ lasts = orderLogic.lasts,
38847
+ moveBackwards = orderLogic.moveBackwards,
38848
+ moveForward = orderLogic.moveForward;
38849
+ if (!Object.keys(firsts).includes(id)) {
38850
+ items.push({
38851
+ id: 'move_back',
38852
+ children: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(OrderColumn, {
38853
+ id: id,
38854
+ dir: "back",
38855
+ action: moveBackwards
38856
+ })
38857
+ });
38858
+ }
38859
+ if (!Object.keys(lasts).includes(id)) {
38860
+ items.push({
38861
+ id: 'move_forward',
38862
+ children: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(OrderColumn, {
38863
+ id: id,
38864
+ dir: "forward",
38865
+ action: moveForward
38866
+ })
38867
+ });
38868
+ }
38869
+ if ((canSort || canHide || canPin) && (!Object.keys(firsts).includes(id) || !Object.keys(lasts).includes(id))) {
38870
+ items.push({
38871
+ id: 'sep',
38872
+ $separator: true
38873
+ });
38874
+ }
38875
+ }
38824
38876
  if (canSort) {
38825
38877
  items.push({
38826
38878
  id: 'sort_asc',
@@ -38908,6 +38960,25 @@ var MenuItem = styled_components__WEBPACK_IMPORTED_MODULE_1___default().li.withC
38908
38960
  })(["list-style:none;&:hover{background-color:", ";}", ""], _theme__WEBPACK_IMPORTED_MODULE_5__["default"].color.gray_2, function (props) {
38909
38961
  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
38962
  });
38963
+ var OrderColumn = function OrderColumn(props) {
38964
+ var id = props.id,
38965
+ dir = props.dir,
38966
+ action = props.action;
38967
+ var text = dir == 'back' ? 'Column Left' : 'Column Right';
38968
+ var handleClick = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function () {
38969
+ return action(id);
38970
+ }, [id, action]);
38971
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(FunctionWrapper, {
38972
+ onClick: handleClick
38973
+ }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_icon__WEBPACK_IMPORTED_MODULE_3__.Icon, {
38974
+ name: dir == 'back' ? 'ArrowLeft' : 'ArrowRight',
38975
+ color: "gray_9",
38976
+ size: "xs"
38977
+ }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_typography__WEBPACK_IMPORTED_MODULE_6__.Label, {
38978
+ variant: "sm",
38979
+ color: "gray_11_50"
38980
+ }, text));
38981
+ };
38911
38982
  var SortColumn = function SortColumn(props) {
38912
38983
  var id = props.id,
38913
38984
  sort = props.sort,
@@ -39006,6 +39077,150 @@ _table__WEBPACK_IMPORTED_MODULE_3__["default"].plugins = _plugin__WEBPACK_IMPORT
39006
39077
 
39007
39078
  /***/ }),
39008
39079
 
39080
+ /***/ "./src/table/order_logic.js":
39081
+ /*!**********************************!*\
39082
+ !*** ./src/table/order_logic.js ***!
39083
+ \**********************************/
39084
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
39085
+
39086
+ "use strict";
39087
+ __webpack_require__.r(__webpack_exports__);
39088
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
39089
+ /* harmony export */ useOrderLogic: () => (/* binding */ useOrderLogic)
39090
+ /* harmony export */ });
39091
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
39092
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
39093
+ // LICENSE_CODE ZON
39094
+
39095
+
39096
+ /*jslint react:true*/
39097
+ 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); }
39098
+ 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; }
39099
+ 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; }
39100
+ 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; }
39101
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
39102
+ 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); }
39103
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
39104
+ 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."); }
39105
+ 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; } }
39106
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
39107
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
39108
+ 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."); }
39109
+ 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); }
39110
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
39111
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
39112
+ 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; }
39113
+
39114
+ var useOrderLogic = function useOrderLogic(table) {
39115
+ var _table$state = table.state,
39116
+ columnOrder = _table$state.columnOrder,
39117
+ hiddenColumns = _table$state.hiddenColumns,
39118
+ pinnedColumns = _table$state.pinnedColumns,
39119
+ setColumnOrder = table.setColumnOrder,
39120
+ setHiddenColumns = table.setHiddenColumns,
39121
+ setPinnedColumns = table.setPinnedColumns,
39122
+ allColumns = table.allColumns;
39123
+ var getColumnCategory = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (id) {
39124
+ if (hiddenColumns.includes(id)) return 'hidden';
39125
+ if (pinnedColumns.includes(id)) return 'pinned';
39126
+ return 'visible';
39127
+ }, [hiddenColumns, pinnedColumns]);
39128
+ var fullOrder = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () {
39129
+ var rest;
39130
+ if (columnOrder.length == allColumns.length) rest = [];else {
39131
+ rest = allColumns.filter(function (c) {
39132
+ return !columnOrder.includes(c.id);
39133
+ }).map(function (c) {
39134
+ return c.id;
39135
+ });
39136
+ }
39137
+ return [].concat(_toConsumableArray(columnOrder), _toConsumableArray(rest));
39138
+ }, [columnOrder, allColumns]);
39139
+ var orders = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () {
39140
+ var _orders = {
39141
+ visible: [],
39142
+ pinned: [],
39143
+ hidden: []
39144
+ };
39145
+ for (var i = 0, l = fullOrder.length; i < l; i++) _orders[getColumnCategory(fullOrder[i])].push(fullOrder[i]);
39146
+ return _orders;
39147
+ }, [fullOrder, getColumnCategory]);
39148
+ var firsts = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () {
39149
+ return Object.fromEntries(Object.entries(orders).map(function (_ref) {
39150
+ var _ref2 = _slicedToArray(_ref, 2),
39151
+ key = _ref2[0],
39152
+ _ref2$ = _slicedToArray(_ref2[1], 1),
39153
+ first = _ref2$[0];
39154
+ return first && [key, first];
39155
+ }).filter(Boolean));
39156
+ }, [orders]);
39157
+ var lasts = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () {
39158
+ return Object.fromEntries(Object.entries(orders).map(function (_ref3) {
39159
+ var _ref4 = _slicedToArray(_ref3, 2),
39160
+ key = _ref4[0],
39161
+ arr = _ref4[1];
39162
+ return arr.length && [key, arr[arr.length - 1]];
39163
+ }).filter(Boolean));
39164
+ }, [orders]);
39165
+ var setOrders = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (_ref5) {
39166
+ var pinned = _ref5.pinned,
39167
+ visible = _ref5.visible,
39168
+ hidden = _ref5.hidden;
39169
+ return setColumnOrder([].concat(_toConsumableArray(pinned), _toConsumableArray(visible), _toConsumableArray(hidden)));
39170
+ }, [setColumnOrder]);
39171
+ var moveBackwards = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (id) {
39172
+ var category = getColumnCategory(id);
39173
+ var arr = orders[category];
39174
+ var n = arr.indexOf(id);
39175
+ console.log('orders1', orders, category, n);
39176
+ if (n <= 0) return;
39177
+ var new_arr = arr.toSpliced(n, 1);
39178
+ new_arr.splice(n - 1, 0, id);
39179
+ var newOrder = _objectSpread({}, orders);
39180
+ newOrder[category] = new_arr;
39181
+ console.log('orders', orders, newOrder);
39182
+ setOrders(newOrder);
39183
+ }, [getColumnCategory, orders, setOrders]);
39184
+ var moveForward = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (id) {
39185
+ var category = getColumnCategory(id);
39186
+ var arr = orders[category];
39187
+ var n = arr.indexOf(id);
39188
+ if (n == -1 || n == arr.length - 1) return;
39189
+ var new_arr = arr.toSpliced(n, 1);
39190
+ new_arr.splice(n + 1, 0, id);
39191
+ var newOrder = _objectSpread({}, orders);
39192
+ newOrder[category] = new_arr;
39193
+ setOrders(newOrder);
39194
+ }, [getColumnCategory, orders, setOrders]);
39195
+ var moveColumn = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (id, cat, n) {
39196
+ var srcCat = getColumnCategory(id);
39197
+ if (srcCat == cat && orders[srcCat][n] == id) return;
39198
+ var newOrders = _objectSpread({}, orders);
39199
+ newOrders[srcCat] = newOrders[srcCat].filter(function (_id) {
39200
+ return _id != id;
39201
+ });
39202
+ newOrders[cat] = newOrders.toSpliced(n, 0, id);
39203
+ setOrders(newOrders);
39204
+ if (srcCat == cat) return;
39205
+ if (srcCat == 'hidden' || cat == 'hidden') setHiddenColumns(newOrders.hidden);
39206
+ if (srcCat == 'pinned' || cat == 'pinned') setPinnedColumns(newOrders.pinned);
39207
+ }, [getColumnCategory, orders, setOrders, setHiddenColumns, setPinnedColumns]);
39208
+ var res = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () {
39209
+ return {
39210
+ orders: orders,
39211
+ firsts: firsts,
39212
+ lasts: lasts,
39213
+ setOrders: setOrders,
39214
+ moveBackwards: moveBackwards,
39215
+ moveForward: moveForward,
39216
+ moveColumn: moveColumn
39217
+ };
39218
+ }, [orders, firsts, lasts, setOrders, moveBackwards, moveForward, moveColumn]);
39219
+ return res;
39220
+ };
39221
+
39222
+ /***/ }),
39223
+
39009
39224
  /***/ "./src/table/pagination.js":
39010
39225
  /*!*********************************!*\
39011
39226
  !*** ./src/table/pagination.js ***!