@bigbinary/neeto-molecules 1.9.1 → 1.9.3

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.
@@ -1,13 +1,13 @@
1
1
  import * as React from 'react';
2
- import React__default, { forwardRef, useRef, useState } from 'react';
2
+ import React__default, { forwardRef, useMemo, useRef, useState } from 'react';
3
3
  import { isNotPresent, isNotEmpty, noop, snakeToCamelCase } from '@bigbinary/neeto-cist';
4
4
  import useDebounce from '@bigbinary/neeto-commons-frontend/react-utils/useDebounce';
5
5
  import { Typography, Button, Alert, Dropdown as Dropdown$1, Tooltip, Tag, Callout, Input, Pane, Label, Table, NoData } from '@bigbinary/neetoui';
6
6
  import { useTranslation, Trans } from 'react-i18next';
7
7
  import classnames from 'classnames';
8
- import { not, mergeRight } from 'ramda';
8
+ import { pluck, not, mergeRight } from 'ramda';
9
9
  import { Column, Download, Filter, MenuHorizontal, MenuVertical, Info, Check } from '@bigbinary/neeto-icons';
10
- import ManageColumns from '@bigbinary/neeto-molecules/Columns';
10
+ import ManageColumns, { useHiddenColumns } from '@bigbinary/neeto-molecules/Columns';
11
11
  import { Filters } from '@bigbinary/neeto-filters-frontend';
12
12
  import { PLURAL, SINGULAR } from '@bigbinary/neeto-commons-frontend/constants';
13
13
  import withT from '@bigbinary/neeto-commons-frontend/react-utils/withT';
@@ -1452,18 +1452,48 @@ function _defineProperty(obj, key, value) {
1452
1452
  return obj;
1453
1453
  }
1454
1454
 
1455
- var _excluded$4 = ["buttonProps"];
1455
+ var _excluded$4 = ["buttonProps", "columnData", "localStorageKey", "fixedColumns"];
1456
1456
  function ownKeys$5(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; }
1457
1457
  function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$5(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$5(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1458
1458
  var Columns = /*#__PURE__*/forwardRef(function (_ref, ref) {
1459
1459
  var _ref$buttonProps = _ref.buttonProps,
1460
1460
  buttonProps = _ref$buttonProps === void 0 ? {} : _ref$buttonProps,
1461
+ columnData = _ref.columnData,
1462
+ localStorageKey = _ref.localStorageKey,
1463
+ fixedColumns = _ref.fixedColumns,
1461
1464
  props = _objectWithoutProperties(_ref, _excluded$4);
1462
1465
  var _useTranslation = useTranslation(),
1463
1466
  t = _useTranslation.t;
1467
+ var columnDataIndex = useMemo(function () {
1468
+ return pluck("dataIndex", (columnData || []).filter(function (column) {
1469
+ return !(fixedColumns !== null && fixedColumns !== void 0 && fixedColumns.includes(column.dataIndex));
1470
+ }));
1471
+ }, [columnData, fixedColumns]);
1472
+ var _useHiddenColumns = useHiddenColumns(localStorageKey),
1473
+ hideColumn = _useHiddenColumns.hideColumn,
1474
+ showColumn = _useHiddenColumns.showColumn;
1464
1475
  return /*#__PURE__*/React__default.createElement("div", {
1465
1476
  className: "neeto-molecules-subheader__columns"
1466
1477
  }, /*#__PURE__*/React__default.createElement(ManageColumns, _extends$1({
1478
+ isSearchable: true,
1479
+ className: "neeto-ui-dropdown--manage-columns",
1480
+ actionBlock: /*#__PURE__*/React__default.createElement("div", {
1481
+ className: "grid grid-cols-2 gap-2 px-4 py-3"
1482
+ }, /*#__PURE__*/React__default.createElement(Button, {
1483
+ className: "col-span-1 justify-center",
1484
+ label: "Hide all",
1485
+ style: "secondary",
1486
+ onClick: function onClick() {
1487
+ return hideColumn(columnDataIndex);
1488
+ }
1489
+ }), /*#__PURE__*/React__default.createElement(Button, {
1490
+ className: "col-span-1 justify-center",
1491
+ label: "Show all",
1492
+ style: "secondary",
1493
+ onClick: function onClick() {
1494
+ return showColumn(columnDataIndex);
1495
+ }
1496
+ })),
1467
1497
  buttonProps: _objectSpread$5({
1468
1498
  icon: Column,
1469
1499
  label: null,
@@ -1474,7 +1504,10 @@ var Columns = /*#__PURE__*/forwardRef(function (_ref, ref) {
1474
1504
  "data-testid": "columns-button",
1475
1505
  "data-cy": "columns-dropdown-button"
1476
1506
  }, buttonProps)
1477
- }, _objectSpread$5(_objectSpread$5({}, props), {}, {
1507
+ }, _objectSpread$5(_objectSpread$5({
1508
+ columnData: columnData,
1509
+ localStorageKey: localStorageKey
1510
+ }, props), {}, {
1478
1511
  ref: ref
1479
1512
  }))));
1480
1513
  });
@@ -1542,7 +1575,7 @@ var RightBlock = function RightBlock(_ref) {
1542
1575
  }, downloadButtonProps && /*#__PURE__*/React__default.createElement(DownloadButton, downloadButtonProps), columnsButtonProps && /*#__PURE__*/React__default.createElement(Columns, columnsButtonProps), filterProps && /*#__PURE__*/React__default.createElement(FilterButton, filterProps));
1543
1576
  };
1544
1577
 
1545
- var css$1 = ":root{--neeto-molecules-sub-header-height:37px;--neeto-molecules-sub-header-bottom-margin:20px}.neeto-molecules-subheader{align-items:center;background-color:rgb(var(--neeto-ui-white));display:flex;flex-direction:row;flex-shrink:0;gap:16px;justify-content:space-between;margin-bottom:20px;margin-bottom:var(--neeto-molecules-sub-header-bottom-margin);min-height:37px;min-height:var(--neeto-molecules-sub-header-height);width:100%}@media screen and (max-width:768px){.neeto-molecules-subheader{flex-wrap:wrap}}.neeto-molecules-subheader .neeto-molecules-subheader__left-wrapper{display:flex;flex-grow:1}.neeto-molecules-subheader .neeto-molecules-subheader__left-wrapper .neeto-molecules-subheader__left{align-items:center;display:flex;flex-direction:row;justify-content:flex-start}.neeto-molecules-subheader .neeto-molecules-subheader__left-wrapper .neeto-molecules-subheader__left .neeto-molecules-input__prefix{color:rgb(var(--neeto-ui-gray-400))}@media screen and (max-width:360px){.neeto-molecules-subheader .neeto-molecules-subheader__left-wrapper .neeto-molecules-subheader__left h4{font-size:14px}}.neeto-molecules-subheader .neeto-molecules-subheader__left-wrapper .neeto-ui-btn{flex-shrink:0}.neeto-molecules-subheader .neeto-molecules-subheader__right{align-items:center;display:flex;flex-direction:row;gap:12px;justify-content:flex-end}@media screen and (max-width:768px){.neeto-molecules-subheader .neeto-molecules-subheader__right{margin-left:auto}}.neeto-molecules-subheader .neeto-molecules-subheader__right-actions{align-items:center;display:flex;flex-direction:row;gap:8px;justify-content:flex-end}.neeto-molecules-subheader .neeto-molecules-subheader__right-actions>:not([hidden])~:not([hidden]){border-left:thin solid rgb(var(--neeto-ui-gray-300));padding-left:8px}.neeto-molecules-subheader__download{position:relative}.neeto-molecules-subheader__download-count{align-items:center;background-color:rgb(var(--neeto-ui-primary-500));border-radius:var(--neeto-ui-rounded-full);color:rgb(var(--neeto-ui-white));display:inline-flex;font-size:10px;justify-content:center;min-height:16px;min-width:16px;position:absolute;right:-2px;text-align:center;top:-2px;z-index:1}.neeto-molecules-subheader__columns .neeto-ui-dropdown__popup{max-height:calc(100vh - var(--neeto-molecules-main-header-with-breadcrumbs-height) - 57px);max-height:calc(100vh - var(--neeto-molecules-main-header-with-breadcrumbs-height) - var(--neeto-molecules-sub-header-height) - var(--neeto-molecules-sub-header-bottom-margin))}";
1578
+ var css$1 = ":root{--neeto-molecules-sub-header-height:37px;--neeto-molecules-sub-header-bottom-margin:20px}.neeto-molecules-subheader{align-items:center;background-color:rgb(var(--neeto-ui-white));display:flex;flex-direction:row;flex-shrink:0;gap:16px;justify-content:space-between;margin-bottom:20px;margin-bottom:var(--neeto-molecules-sub-header-bottom-margin);min-height:37px;min-height:var(--neeto-molecules-sub-header-height);width:100%}@media screen and (max-width:768px){.neeto-molecules-subheader{flex-wrap:wrap}}.neeto-molecules-subheader .neeto-molecules-subheader__left-wrapper{display:flex;flex-grow:1}.neeto-molecules-subheader .neeto-molecules-subheader__left-wrapper .neeto-molecules-subheader__left{align-items:center;display:flex;flex-direction:row;justify-content:flex-start}.neeto-molecules-subheader .neeto-molecules-subheader__left-wrapper .neeto-molecules-subheader__left .neeto-molecules-input__prefix{color:rgb(var(--neeto-ui-gray-400))}@media screen and (max-width:360px){.neeto-molecules-subheader .neeto-molecules-subheader__left-wrapper .neeto-molecules-subheader__left h4{font-size:14px}}.neeto-molecules-subheader .neeto-molecules-subheader__left-wrapper .neeto-ui-btn{flex-shrink:0}.neeto-molecules-subheader .neeto-molecules-subheader__right{align-items:center;display:flex;flex-direction:row;gap:12px;justify-content:flex-end}@media screen and (max-width:768px){.neeto-molecules-subheader .neeto-molecules-subheader__right{margin-left:auto}}.neeto-molecules-subheader .neeto-molecules-subheader__right-actions{align-items:center;display:flex;flex-direction:row;gap:8px;justify-content:flex-end}.neeto-molecules-subheader .neeto-molecules-subheader__right-actions>:not([hidden])~:not([hidden]){border-left:thin solid rgb(var(--neeto-ui-gray-300));padding-left:8px}.neeto-molecules-subheader__download{position:relative}.neeto-molecules-subheader__download-count{align-items:center;background-color:rgb(var(--neeto-ui-primary-500));border-radius:var(--neeto-ui-rounded-full);color:rgb(var(--neeto-ui-white));display:inline-flex;font-size:10px;justify-content:center;min-height:16px;min-width:16px;position:absolute;right:-2px;text-align:center;top:-2px;z-index:1}.neeto-molecules-subheader__columns .neeto-ui-dropdown__popup{max-height:calc(100vh - var(--neeto-molecules-main-header-with-breadcrumbs-height) - 57px);max-height:calc(100vh - var(--neeto-molecules-main-header-with-breadcrumbs-height) - var(--neeto-molecules-sub-header-height) - var(--neeto-molecules-sub-header-bottom-margin));min-width:320px}";
1546
1579
  n(css$1,{});
1547
1580
 
1548
1581
  var SubHeader = function SubHeader(_ref) {