es-grid-template 1.4.7 → 1.4.8

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.
@@ -21,7 +21,7 @@ import withReactContent from "sweetalert2-react-content";
21
21
  import { Tooltip } from "react-tooltip";
22
22
  import classNames from "classnames";
23
23
  import HeaderContent from "./hooks/content/HeaderContent";
24
- import { ArrowDown, ArrowUp, FilterFill } from "becoxy-icons";
24
+ import { ArrowDown, ArrowUp, FilterFill, SortCancel } from "becoxy-icons";
25
25
  import { Select } from "rc-master-ui";
26
26
  import { Button, Space } from "antd";
27
27
  import { SearchOutlined } from "@ant-design/icons";
@@ -223,17 +223,17 @@ const InternalTable = props => {
223
223
  }, [dataSource]);
224
224
  const [columns, setColumns] = React.useState([]);
225
225
  React.useEffect(() => {
226
- // setTimeout(() => {
227
- const table = document.querySelector(`#${id}`);
228
- const title = table?.querySelector(`.ui-rc-table-title`);
229
- const header = table?.querySelector(`.ui-rc-table-header`);
230
- const paginationE = table?.querySelector(`.ui-rc-pagination`);
231
- const toolbar = table?.querySelector(`.ui-rc-toolbar-bottom`);
232
- const summaryE = table?.querySelector(`.ui-rc-table-summary`);
233
- const scrollbar = table?.querySelector(`.ui-rc-table-tbody-virtual-scrollbar.ui-rc-table-tbody-virtual-scrollbar-horizontal`);
234
- const hhh = (propsHeight ?? 0) - (title ? title.offsetHeight : 0) - (header ? header.offsetHeight : 0) - (paginationE ? paginationE.offsetHeight : 0) - (toolbar ? toolbar.offsetHeight : 0) - (summaryE ? summaryE.offsetHeight : 0) - (scrollbar ? scrollbar.offsetHeight : 0);
235
- setHeight(hhh);
236
- // })
226
+ if (propsHeight) {
227
+ const table = document.querySelector(`#${id}`);
228
+ const title = table?.querySelector(`.ui-rc-table-title`);
229
+ const header = table?.querySelector(`.ui-rc-table-header`);
230
+ const paginationE = table?.querySelector(`.ui-rc-pagination`);
231
+ const toolbar = table?.querySelector(`.ui-rc-toolbar-bottom`);
232
+ const summaryE = table?.querySelector(`.ui-rc-table-summary`);
233
+ const scrollbar = table?.querySelector(`.ui-rc-table-tbody-virtual-scrollbar.ui-rc-table-tbody-virtual-scrollbar-horizontal`);
234
+ const hhh = (propsHeight ?? 0) - (title ? title.offsetHeight : 0) - (header ? header.offsetHeight : 0) - (paginationE ? paginationE.offsetHeight : 0) - (toolbar ? toolbar.offsetHeight : 0) - (summaryE ? summaryE.offsetHeight : 0) - (scrollbar ? scrollbar.offsetHeight : 0);
235
+ setHeight(hhh > 0 ? hhh : 0);
236
+ }
237
237
  }, [id, propsHeight, columns, editAble]);
238
238
  const tableRef = React.useRef(null);
239
239
  React.useEffect(() => {
@@ -382,7 +382,8 @@ const InternalTable = props => {
382
382
  column: {
383
383
  ...column
384
384
  },
385
- t: t
385
+ t: t,
386
+ id: id
386
387
  })),
387
388
  ellipsis: column.ellipsis !== false,
388
389
  align: column.textAlign ?? column.align,
@@ -440,7 +441,7 @@ const InternalTable = props => {
440
441
  const {
441
442
  sortOrder
442
443
  } = args;
443
- return /*#__PURE__*/React.createElement(Fragment, null, !sortOrder && /*#__PURE__*/React.createElement(ArrowUp, {
444
+ return /*#__PURE__*/React.createElement(Fragment, null, !sortOrder && /*#__PURE__*/React.createElement(SortCancel, {
444
445
  fontSize: 15,
445
446
  style: {
446
447
  display: 'flex',
@@ -846,10 +847,14 @@ const InternalTable = props => {
846
847
  // scroll={{ y: 300 - 41 - 7 }} // scroll height auto, không quá 600
847
848
  // scroll={{ y: scrollHeight - (summary ? 0 : 7) }} // scroll height auto, không quá 600
848
849
  ,
849
- scroll: {
850
+
851
+ scroll: scrollHeight - (summary ? 1 : 1) < 0 ? {
852
+ y: 500
853
+ } : {
850
854
  y: scrollHeight - (summary ? 1 : 1)
851
855
  } // scroll height auto, không quá 600
852
856
  ,
857
+
853
858
  height: propsHeight,
854
859
  scrollHeight: scrollHeight,
855
860
  components: {
@@ -873,12 +878,12 @@ const InternalTable = props => {
873
878
  fontWeight: 500
874
879
  }
875
880
  }, columns[columns.findIndex(i => i.field === dragIndex.active)]?.headerText))), /*#__PURE__*/React.createElement(Tooltip, {
876
- id: "tooltip-form-error",
881
+ id: `${id}-tooltip-form-error`,
877
882
  style: {
878
883
  zIndex: 1999
879
884
  }
880
885
  }), /*#__PURE__*/React.createElement(Tooltip, {
881
- id: "tooltip-cell-content",
886
+ id: `${id}-tooltip-cell-content`,
882
887
  style: {
883
888
  zIndex: 1999
884
889
  },
@@ -131,6 +131,7 @@ const useStyle = createStyles(({
131
131
  const EMPTY_LIST = [];
132
132
  const TableGrid = props => {
133
133
  const {
134
+ id,
134
135
  columns,
135
136
  tableRef,
136
137
  dataSource,
@@ -517,7 +518,7 @@ const TableGrid = props => {
517
518
  ,
518
519
  showTotal: (total, range) => `${range[0]}-${range[1]} / ${total} ${t ? t(pagination?.locale?.items ?? 'items') : 'items'}`
519
520
  }, pagination)), bottomToolbar?.(), /*#__PURE__*/React.createElement(Tooltip, {
520
- id: "tooltip-header",
521
+ id: `${id}-tooltip-header`,
521
522
  style: {
522
523
  zIndex: 1999
523
524
  }
@@ -2,6 +2,7 @@ import React from "react";
2
2
  import type { ColumnTable } from "../../type";
3
3
  type Props = {
4
4
  t?: any;
5
+ id?: string;
5
6
  content?: string;
6
7
  column?: ColumnTable;
7
8
  template?: React.ReactElement | React.ReactNode | (() => React.ReactElement | React.ReactNode);
@@ -1,23 +1,10 @@
1
1
  import React, { Fragment } from "react";
2
2
  import classnames from "classnames";
3
-
4
- // import styled from "styled-components";
5
3
  import { getTemplate } from "../utils";
6
- // const TooltipStyle = styled.div`
7
- // width: max-content;
8
- // background-color: #444;
9
- // color: white;
10
- // font-size: 90%;
11
- // padding: 4px 8px;
12
- // border-radius: 4px;
13
- // opacity: 0.9;
14
- // z-index: 9999;
15
- // max-width: 450px;
16
- // `
17
-
18
4
  const HeaderContent = props => {
19
5
  const {
20
- t
6
+ t,
7
+ id
21
8
  } = props;
22
9
  const {
23
10
  headerTooltip,
@@ -31,43 +18,9 @@ const HeaderContent = props => {
31
18
  const tooltip = React.useMemo(() => {
32
19
  return headerTooltip ?? t ? t(columnGroupText ?? headerText) : columnGroupText ?? headerText;
33
20
  }, [columnGroupText, headerText, headerTooltip, t]);
34
- //
35
- //
36
- // const [isOpen, setIsOpen] = useState(false)
37
- //
38
- // const { refs, floatingStyles, context } = useFloating({
39
- // open: isOpen,
40
- // onOpenChange: setIsOpen,
41
- // placement: "top",
42
- // whileElementsMounted: autoUpdate,
43
- // middleware: [
44
- // offset(5),
45
- // flip({
46
- // fallbackAxisSideDirection: "start"
47
- // }),
48
- // shift()
49
- // ]
50
- // })
51
- //
52
- // const hover = useHover(context, { move: false })
53
- // const focus = useFocus(context)
54
- // const dismiss = useDismiss(context)
55
- // const role = useRole(context, { role: "tooltip" })
56
- //
57
- // const { getReferenceProps, getFloatingProps } = useInteractions([
58
- // hover,
59
- // focus,
60
- // dismiss,
61
- // role
62
- // ])
63
-
64
21
  return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
65
- // ref={refs.setReference}
66
- // tabIndex={-1}
67
- // style={{flex: 1, overflow: 'hidden', textOverflow: 'ellipsis', wordBreak: 'keep-all'}}
68
- // style={{flex: 1}}
69
22
  className: classnames('', {}),
70
- "data-tooltip-id": "tooltip-header",
23
+ "data-tooltip-id": `${id}-tooltip-header`,
71
24
  "data-tooltip-content": tooltip,
72
25
  "data-tooltip-offset": 16
73
26
  }, headerTemplate ? getTemplate(headerTemplate) : t ? t(text) : text));
@@ -294,6 +294,16 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
294
294
 
295
295
  .#{$prefix}-table-cell {
296
296
 
297
+ .ui-rc-table-column-sorter{
298
+ line-height: normal !important;
299
+ }
300
+
301
+ &:hover {
302
+ .ui-rc-table-column-sorter-up.active {
303
+ opacity: 1 !important;
304
+ }
305
+ }
306
+
297
307
  .ui-rc-table-cell-content {
298
308
  line-height: 22px;
299
309
  }
@@ -234,17 +234,17 @@ const InternalTable = props => {
234
234
  }, [dataSource]);
235
235
  const [columns, setColumns] = _react.default.useState([]);
236
236
  _react.default.useEffect(() => {
237
- // setTimeout(() => {
238
- const table = document.querySelector(`#${id}`);
239
- const title = table?.querySelector(`.ui-rc-table-title`);
240
- const header = table?.querySelector(`.ui-rc-table-header`);
241
- const paginationE = table?.querySelector(`.ui-rc-pagination`);
242
- const toolbar = table?.querySelector(`.ui-rc-toolbar-bottom`);
243
- const summaryE = table?.querySelector(`.ui-rc-table-summary`);
244
- const scrollbar = table?.querySelector(`.ui-rc-table-tbody-virtual-scrollbar.ui-rc-table-tbody-virtual-scrollbar-horizontal`);
245
- const hhh = (propsHeight ?? 0) - (title ? title.offsetHeight : 0) - (header ? header.offsetHeight : 0) - (paginationE ? paginationE.offsetHeight : 0) - (toolbar ? toolbar.offsetHeight : 0) - (summaryE ? summaryE.offsetHeight : 0) - (scrollbar ? scrollbar.offsetHeight : 0);
246
- setHeight(hhh);
247
- // })
237
+ if (propsHeight) {
238
+ const table = document.querySelector(`#${id}`);
239
+ const title = table?.querySelector(`.ui-rc-table-title`);
240
+ const header = table?.querySelector(`.ui-rc-table-header`);
241
+ const paginationE = table?.querySelector(`.ui-rc-pagination`);
242
+ const toolbar = table?.querySelector(`.ui-rc-toolbar-bottom`);
243
+ const summaryE = table?.querySelector(`.ui-rc-table-summary`);
244
+ const scrollbar = table?.querySelector(`.ui-rc-table-tbody-virtual-scrollbar.ui-rc-table-tbody-virtual-scrollbar-horizontal`);
245
+ const hhh = (propsHeight ?? 0) - (title ? title.offsetHeight : 0) - (header ? header.offsetHeight : 0) - (paginationE ? paginationE.offsetHeight : 0) - (toolbar ? toolbar.offsetHeight : 0) - (summaryE ? summaryE.offsetHeight : 0) - (scrollbar ? scrollbar.offsetHeight : 0);
246
+ setHeight(hhh > 0 ? hhh : 0);
247
+ }
248
248
  }, [id, propsHeight, columns, editAble]);
249
249
  const tableRef = _react.default.useRef(null);
250
250
  _react.default.useEffect(() => {
@@ -393,7 +393,8 @@ const InternalTable = props => {
393
393
  column: {
394
394
  ...column
395
395
  },
396
- t: t
396
+ t: t,
397
+ id: id
397
398
  })),
398
399
  ellipsis: column.ellipsis !== false,
399
400
  align: column.textAlign ?? column.align,
@@ -451,7 +452,7 @@ const InternalTable = props => {
451
452
  const {
452
453
  sortOrder
453
454
  } = args;
454
- return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, !sortOrder && /*#__PURE__*/_react.default.createElement(_becoxyIcons.ArrowUp, {
455
+ return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, !sortOrder && /*#__PURE__*/_react.default.createElement(_becoxyIcons.SortCancel, {
455
456
  fontSize: 15,
456
457
  style: {
457
458
  display: 'flex',
@@ -857,10 +858,14 @@ const InternalTable = props => {
857
858
  // scroll={{ y: 300 - 41 - 7 }} // scroll height auto, không quá 600
858
859
  // scroll={{ y: scrollHeight - (summary ? 0 : 7) }} // scroll height auto, không quá 600
859
860
  ,
860
- scroll: {
861
+
862
+ scroll: scrollHeight - (summary ? 1 : 1) < 0 ? {
863
+ y: 500
864
+ } : {
861
865
  y: scrollHeight - (summary ? 1 : 1)
862
866
  } // scroll height auto, không quá 600
863
867
  ,
868
+
864
869
  height: propsHeight,
865
870
  scrollHeight: scrollHeight,
866
871
  components: {
@@ -884,12 +889,12 @@ const InternalTable = props => {
884
889
  fontWeight: 500
885
890
  }
886
891
  }, columns[columns.findIndex(i => i.field === dragIndex.active)]?.headerText))), /*#__PURE__*/_react.default.createElement(_reactTooltip.Tooltip, {
887
- id: "tooltip-form-error",
892
+ id: `${id}-tooltip-form-error`,
888
893
  style: {
889
894
  zIndex: 1999
890
895
  }
891
896
  }), /*#__PURE__*/_react.default.createElement(_reactTooltip.Tooltip, {
892
- id: "tooltip-cell-content",
897
+ id: `${id}-tooltip-cell-content`,
893
898
  style: {
894
899
  zIndex: 1999
895
900
  },
@@ -131,6 +131,7 @@ const useStyle = (0, _antdStyle.createStyles)(({
131
131
  const EMPTY_LIST = [];
132
132
  const TableGrid = props => {
133
133
  const {
134
+ id,
134
135
  columns,
135
136
  tableRef,
136
137
  dataSource,
@@ -517,7 +518,7 @@ const TableGrid = props => {
517
518
  ,
518
519
  showTotal: (total, range) => `${range[0]}-${range[1]} / ${total} ${t ? t(pagination?.locale?.items ?? 'items') : 'items'}`
519
520
  }, pagination)), bottomToolbar?.(), /*#__PURE__*/_react.default.createElement(_reactTooltip.Tooltip, {
520
- id: "tooltip-header",
521
+ id: `${id}-tooltip-header`,
521
522
  style: {
522
523
  zIndex: 1999
523
524
  }
@@ -2,6 +2,7 @@ import React from "react";
2
2
  import type { ColumnTable } from "../../type";
3
3
  type Props = {
4
4
  t?: any;
5
+ id?: string;
5
6
  content?: string;
6
7
  column?: ColumnTable;
7
8
  template?: React.ReactElement | React.ReactNode | (() => React.ReactElement | React.ReactNode);
@@ -10,23 +10,10 @@ var _classnames = _interopRequireDefault(require("classnames"));
10
10
  var _utils = require("../utils");
11
11
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
12
12
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
13
- // import styled from "styled-components";
14
-
15
- // const TooltipStyle = styled.div`
16
- // width: max-content;
17
- // background-color: #444;
18
- // color: white;
19
- // font-size: 90%;
20
- // padding: 4px 8px;
21
- // border-radius: 4px;
22
- // opacity: 0.9;
23
- // z-index: 9999;
24
- // max-width: 450px;
25
- // `
26
-
27
13
  const HeaderContent = props => {
28
14
  const {
29
- t
15
+ t,
16
+ id
30
17
  } = props;
31
18
  const {
32
19
  headerTooltip,
@@ -40,43 +27,9 @@ const HeaderContent = props => {
40
27
  const tooltip = _react.default.useMemo(() => {
41
28
  return headerTooltip ?? t ? t(columnGroupText ?? headerText) : columnGroupText ?? headerText;
42
29
  }, [columnGroupText, headerText, headerTooltip, t]);
43
- //
44
- //
45
- // const [isOpen, setIsOpen] = useState(false)
46
- //
47
- // const { refs, floatingStyles, context } = useFloating({
48
- // open: isOpen,
49
- // onOpenChange: setIsOpen,
50
- // placement: "top",
51
- // whileElementsMounted: autoUpdate,
52
- // middleware: [
53
- // offset(5),
54
- // flip({
55
- // fallbackAxisSideDirection: "start"
56
- // }),
57
- // shift()
58
- // ]
59
- // })
60
- //
61
- // const hover = useHover(context, { move: false })
62
- // const focus = useFocus(context)
63
- // const dismiss = useDismiss(context)
64
- // const role = useRole(context, { role: "tooltip" })
65
- //
66
- // const { getReferenceProps, getFloatingProps } = useInteractions([
67
- // hover,
68
- // focus,
69
- // dismiss,
70
- // role
71
- // ])
72
-
73
30
  return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
74
- // ref={refs.setReference}
75
- // tabIndex={-1}
76
- // style={{flex: 1, overflow: 'hidden', textOverflow: 'ellipsis', wordBreak: 'keep-all'}}
77
- // style={{flex: 1}}
78
31
  className: (0, _classnames.default)('', {}),
79
- "data-tooltip-id": "tooltip-header",
32
+ "data-tooltip-id": `${id}-tooltip-header`,
80
33
  "data-tooltip-content": tooltip,
81
34
  "data-tooltip-offset": 16
82
35
  }, headerTemplate ? (0, _utils.getTemplate)(headerTemplate) : t ? t(text) : text));
@@ -294,6 +294,16 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
294
294
 
295
295
  .#{$prefix}-table-cell {
296
296
 
297
+ .ui-rc-table-column-sorter{
298
+ line-height: normal !important;
299
+ }
300
+
301
+ &:hover {
302
+ .ui-rc-table-column-sorter-up.active {
303
+ opacity: 1 !important;
304
+ }
305
+ }
306
+
297
307
  .ui-rc-table-cell-content {
298
308
  line-height: 22px;
299
309
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "es-grid-template",
3
- "version": "1.4.7",
3
+ "version": "1.4.8",
4
4
  "description": "es-grid-template",
5
5
  "keywords": [
6
6
  "react",