bhd-components 0.2.8 → 0.3.0

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.
@@ -74,6 +74,7 @@ var getParentWidth = function(node) {
74
74
  };
75
75
  // const defaultWidthRang: widthRangType = [180, 240, 320]; //默认自适应的值 [最小值,最佳值,最大值]
76
76
  //传入的参数为onCell==>需要进行函数合并
77
+ /* 记录的滚动条宽度 */ var recordScrollBarWidth = 0;
77
78
  var Table = function(props) {
78
79
  var tableRef = useRef(null);
79
80
  var timerRef = useRef({
@@ -90,8 +91,8 @@ var Table = function(props) {
90
91
  var initColumns = function() {
91
92
  var scrollBarDom = tableRef.current.getElementsByClassName("bhd-table-cell-scrollbar")[0];
92
93
  var scrollBarWidth = scrollBarDom ? scrollBarDom.clientWidth : 0;
93
- var tableWidth = bordered ? tableRef.current.offsetWidth - 2 - scrollBarWidth : tableRef.current.offsetWidth - scrollBarWidth;
94
- console.log("gaodug", scrollBarWidth);
94
+ recordScrollBarWidth = scrollBarWidth || recordScrollBarWidth;
95
+ var tableWidth = bordered ? tableRef.current.offsetWidth - 2 - recordScrollBarWidth : tableRef.current.offsetWidth - recordScrollBarWidth;
95
96
  var _initColumnsWidth = initColumnsWidth(props.columns, tableWidth), selfColumns = _initColumnsWidth.columns;
96
97
  setColumns(selfColumns);
97
98
  var obj = scrollObject ? scrollObject : {};
@@ -240,6 +241,11 @@ var Table = function(props) {
240
241
  }, [
241
242
  props.columns
242
243
  ]);
244
+ useEffect(function() {
245
+ setScrollObject(props.scroll || undefined);
246
+ }, [
247
+ props.scroll
248
+ ]);
243
249
  var config = _object_spread_props(_object_spread({
244
250
  bordered: false
245
251
  }, props), {
@@ -1 +1 @@
1
- import{_ as t,j as e,a as n,b as o,T as i,c as r}from"./ae211df8.esm.es5.production.js";import{useState as l,useRef as a,useEffect as d}from"react";import"react/jsx-runtime";import"react-dom";var u={Table:"index_module_Table__5278674b",SmallTable:"index_module_SmallTable__5278674b",columnTootipClassName:"index_module_columnTootipClassName__5278674b"},c=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:14,n=0,o=document.createElement("div");return o.style.position="absolute",o.style.whiteSpace="nowrap",o.style.fontSize=e+"px",o.style.opacity="0",o.innerText=t,document.body.append(o),n=o.getBoundingClientRect().width,document.body.removeChild(o),n},s=function(r){var a=r.children,d=r.title,u=r.width,s=t(l(!1),2),m=s[0],h=s[1];return e(i,n(o({},r),{open:m,children:e("span",{onMouseEnter:function(t){var e=0;(e="function"==typeof u?u(t):u)?h(!(c(d)<e)):h(!0)},onMouseLeave:function(){h(!1)},children:a})}))},m=/^\d+%$/,h=/^\d+px$/,w=function(t){var e={};return parseFloat((e=window.getComputedStyle?getComputedStyle(t,null):t.currentStyle)["padding-left"])+parseFloat(e["padding-right"])},f=function(t){try{for(;t&&"TD"!==t.nodeName;)t=t.parentElement;var e=w(t);return t.clientWidth-e}catch(t){return null}},p=function(i){var c=a(null),w=a({timer:null}),p=i.defaultWidthRang,C=void 0===p?[180,240,320]:p,g=i.isFixedLeft,v=void 0===g||g,T=i.isFixedRight,E=void 0===T||T,N=i.bordered,_=void 0!==N&&N,y=i.kind,b=t(l(i.columns||[]),2),L=b[0],x=b[1],S=t(l(i.scroll||void 0),2),R=S[0],O=S[1],F=i.columnTootipClassName,I=i.columnTootipColor,W=function(){var t=c.current.getElementsByClassName("bhd-table-cell-scrollbar")[0],e=t?t.clientWidth:0,r=_?c.current.offsetWidth-2-e:c.current.offsetWidth-e;console.log("gaodug",e);var l=M(i.columns,r).columns;x(l);var a=R||{};a=n(o({},a),{x:r}),O(a)},M=function(t,i){var r=0,l=0,a=0;t=t.map(function(t){return t.width=t.width||"auto",m.test(t.width)?t.width=parseFloat(t.width)>=100?"auto":i*parseFloat(t.width)/100:"number"==typeof t.width?t.width=t.width:h.test(t.width)?t.width=parseFloat(t.width):t.width="auto","auto"===t.width?(r+=1,t.widthRang||(t.widthRang=C),l+=t.widthRang[0],a+=t.widthRang[1]):(l+=t.width,a+=t.width),t.onColumnCell||(t.onColumnCell=t.onCell||function(){return{}}),t.render||(t.ellipsis={showTitle:!1},t.render=function(t){return e(s,{width:function(t){return f(t.target)},title:t,trigger:"hover",overlayClassName:F||u.columnTootipClassName,color:I||"#FFF",children:e("span",{children:t})})}),t});var d=i-l;if(d>0){var c=0;t=(t=t.map(function(t){return"auto"===t.width&&(t.width=t.widthRang[0]+d/r,t.width>t.widthRang[2]&&(c+=t.width-t.widthRang[2],t.width=t.widthRang[2])),t})).map(function(e,n){return c>0&&n!==t.length-1&&(e.width+=c/t.length-1),e})}else t=d<0?t.map(function(e,n){return v&&0===n&&(e.fixed="left"),E&&n===t.length-1&&(e.fixed="right"),"auto"===e.width&&(e.width=e.widthRang[1]),e}):t.map(function(t){return"auto"===t.width&&(t.width=t.widthRang[0]),t});return t.map(function(t){return t.onCell=function(e,i){var r="function"==typeof t.onColumnCell?t.onColumnCell(e,i):{};return r.style=r.style?r.style:{},n(o({},r),{style:o({maxWidth:t.width+"px"},r.style)})},t}),{columns:t,scrollWidth:a}},A=function(){clearTimeout(w.current.timer),w.current.timer=setTimeout(function(){W()},1e3)};d(function(){return W(),window.addEventListener("resize",A),function(){clearTimeout(w.current.timer),window.removeEventListener("resize",A)}},[i.columns]);var U=n(o({bordered:!1},i),{columns:L,scroll:R||{x:"auto"}});return e("div",{className:"".concat(u.Table," ").concat("simple"===y?u.SmallTable:""),ref:c,children:e(r,o({},U))})};p.SELECTION_COLUMN=r.SELECTION_COLUMN,p.EXPAND_COLUMN=r.EXPAND_COLUMN,p.SELECTION_ALL=r.SELECTION_ALL,p.SELECTION_INVERT=r.SELECTION_INVERT,p.SELECTION_NONE=r.SELECTION_NONE,p.Column=r.Column,p.ColumnGroup=r.ColumnGroup;export{p as default};
1
+ import{_ as t,j as e,a as n,b as i,T as o,c as r}from"./ae211df8.esm.es5.production.js";import{useState as l,useRef as a,useEffect as d}from"react";import"react/jsx-runtime";import"react-dom";var u={Table:"index_module_Table__5278674b",SmallTable:"index_module_SmallTable__5278674b",columnTootipClassName:"index_module_columnTootipClassName__5278674b"},c=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:14,n=0,i=document.createElement("div");return i.style.position="absolute",i.style.whiteSpace="nowrap",i.style.fontSize=e+"px",i.style.opacity="0",i.innerText=t,document.body.append(i),n=i.getBoundingClientRect().width,document.body.removeChild(i),n},s=function(r){var a=r.children,d=r.title,u=r.width,s=t(l(!1),2),m=s[0],h=s[1];return e(o,n(i({},r),{open:m,children:e("span",{onMouseEnter:function(t){var e=0;(e="function"==typeof u?u(t):u)?h(!(c(d)<e)):h(!0)},onMouseLeave:function(){h(!1)},children:a})}))},m=/^\d+%$/,h=/^\d+px$/,w=function(t){var e={};return parseFloat((e=window.getComputedStyle?getComputedStyle(t,null):t.currentStyle)["padding-left"])+parseFloat(e["padding-right"])},f=function(t){try{for(;t&&"TD"!==t.nodeName;)t=t.parentElement;var e=w(t);return t.clientWidth-e}catch(t){return null}},p=0,C=function(o){var c=a(null),w=a({timer:null}),C=o.defaultWidthRang,v=void 0===C?[180,240,320]:C,T=o.isFixedLeft,g=void 0===T||T,E=o.isFixedRight,N=void 0===E||E,_=o.bordered,y=void 0!==_&&_,b=o.kind,L=t(l(o.columns||[]),2),x=L[0],S=L[1],R=t(l(o.scroll||void 0),2),O=R[0],F=R[1],I=o.columnTootipClassName,W=o.columnTootipColor,M=function(){var t=c.current.getElementsByClassName("bhd-table-cell-scrollbar")[0];p=(t?t.clientWidth:0)||p;var e=y?c.current.offsetWidth-2-p:c.current.offsetWidth-p,r=A(o.columns,e).columns;S(r);var l=O||{};l=n(i({},l),{x:e}),F(l)},A=function(t,o){var r=0,l=0,a=0;t=t.map(function(t){return t.width=t.width||"auto",m.test(t.width)?t.width=parseFloat(t.width)>=100?"auto":o*parseFloat(t.width)/100:"number"==typeof t.width?t.width=t.width:h.test(t.width)?t.width=parseFloat(t.width):t.width="auto","auto"===t.width?(r+=1,t.widthRang||(t.widthRang=v),l+=t.widthRang[0],a+=t.widthRang[1]):(l+=t.width,a+=t.width),t.onColumnCell||(t.onColumnCell=t.onCell||function(){return{}}),t.render||(t.ellipsis={showTitle:!1},t.render=function(t){return e(s,{width:function(t){return f(t.target)},title:t,trigger:"hover",overlayClassName:I||u.columnTootipClassName,color:W||"#FFF",children:e("span",{children:t})})}),t});var d=o-l;if(d>0){var c=0;t=(t=t.map(function(t){return"auto"===t.width&&(t.width=t.widthRang[0]+d/r,t.width>t.widthRang[2]&&(c+=t.width-t.widthRang[2],t.width=t.widthRang[2])),t})).map(function(e,n){return c>0&&n!==t.length-1&&(e.width+=c/t.length-1),e})}else t=d<0?t.map(function(e,n){return g&&0===n&&(e.fixed="left"),N&&n===t.length-1&&(e.fixed="right"),"auto"===e.width&&(e.width=e.widthRang[1]),e}):t.map(function(t){return"auto"===t.width&&(t.width=t.widthRang[0]),t});return t.map(function(t){return t.onCell=function(e,o){var r="function"==typeof t.onColumnCell?t.onColumnCell(e,o):{};return r.style=r.style?r.style:{},n(i({},r),{style:i({maxWidth:t.width+"px"},r.style)})},t}),{columns:t,scrollWidth:a}},U=function(){clearTimeout(w.current.timer),w.current.timer=setTimeout(function(){M()},1e3)};d(function(){return M(),window.addEventListener("resize",U),function(){clearTimeout(w.current.timer),window.removeEventListener("resize",U)}},[o.columns]),d(function(){F(o.scroll||void 0)},[o.scroll]);var j=n(i({bordered:!1},o),{columns:x,scroll:O||{x:"auto"}});return e("div",{className:"".concat(u.Table," ").concat("simple"===b?u.SmallTable:""),ref:c,children:e(r,i({},j))})};C.SELECTION_COLUMN=r.SELECTION_COLUMN,C.EXPAND_COLUMN=r.EXPAND_COLUMN,C.SELECTION_ALL=r.SELECTION_ALL,C.SELECTION_INVERT=r.SELECTION_INVERT,C.SELECTION_NONE=r.SELECTION_NONE,C.Column=r.Column,C.ColumnGroup=r.ColumnGroup;export{C as default};
@@ -31,6 +31,7 @@ const getParentWidth = (node)=>{
31
31
  };
32
32
  // const defaultWidthRang: widthRangType = [180, 240, 320]; //默认自适应的值 [最小值,最佳值,最大值]
33
33
  //传入的参数为onCell==>需要进行函数合并
34
+ /* 记录的滚动条宽度 */ let recordScrollBarWidth = 0;
34
35
  const Table = (props)=>{
35
36
  const tableRef = useRef(null);
36
37
  const timerRef = useRef({
@@ -47,8 +48,8 @@ const Table = (props)=>{
47
48
  const initColumns = ()=>{
48
49
  let scrollBarDom = tableRef.current.getElementsByClassName("bhd-table-cell-scrollbar")[0];
49
50
  const scrollBarWidth = scrollBarDom ? scrollBarDom.clientWidth : 0;
50
- const tableWidth = bordered ? tableRef.current.offsetWidth - 2 - scrollBarWidth : tableRef.current.offsetWidth - scrollBarWidth;
51
- console.log("gaodug", scrollBarWidth);
51
+ recordScrollBarWidth = scrollBarWidth || recordScrollBarWidth;
52
+ const tableWidth = bordered ? tableRef.current.offsetWidth - 2 - recordScrollBarWidth : tableRef.current.offsetWidth - recordScrollBarWidth;
52
53
  let { columns: selfColumns } = initColumnsWidth(props.columns, tableWidth);
53
54
  setColumns(selfColumns);
54
55
  let obj = scrollObject ? scrollObject : {};
@@ -193,6 +194,11 @@ const Table = (props)=>{
193
194
  }, [
194
195
  props.columns
195
196
  ]);
197
+ useEffect(()=>{
198
+ setScrollObject(props.scroll || undefined);
199
+ }, [
200
+ props.scroll
201
+ ]);
196
202
  let config = _object_spread_props(_object_spread({
197
203
  bordered: false
198
204
  }, props), {
@@ -202,7 +208,7 @@ const Table = (props)=>{
202
208
  }
203
209
  });
204
210
  return /*#__PURE__*/ _jsx("div", {
205
- className: `${styles.Table} ${kind === "simple" ? styles.SmallTable : ''}`,
211
+ className: `${styles.Table} ${kind === "simple" ? styles.SmallTable : ""}`,
206
212
  ref: tableRef,
207
213
  children: /*#__PURE__*/ _jsx(AntdTable, _object_spread({}, config))
208
214
  });
@@ -6,13 +6,14 @@ import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
6
6
  import { jsx as _jsx } from "@ice/jsx-runtime/jsx-runtime";
7
7
  import * as React from "react";
8
8
  import { useRef } from "react";
9
+ import { CaretDownOutlined } from "../icons/index";
9
10
  import { Select } from "antd";
10
11
  //import type { SelectProps } from 'antd';
11
12
  import styles from "./index.module.less";
12
13
  const BhdTableSelect = (props)=>{
13
14
  const { // initOption=[],
14
15
  // initOptionType='default',
15
- className ='' , popupClassName ='' , dropdownStyle ={} , children } = props;
16
+ className ='' , popupClassName ='' , dropdownStyle ={} , suffixIcon =null , children } = props;
16
17
  const tableSelectRef = useRef(null);
17
18
  // const handleTypeSwitchOption=()=>{
18
19
  // switch(initOptionType){
@@ -58,6 +59,7 @@ const BhdTableSelect = (props)=>{
58
59
  borderRadius: 4,
59
60
  border: '1px solid rgba(0,0,0,0.15)'
60
61
  }),
62
+ suffixIcon: suffixIcon ? suffixIcon : /*#__PURE__*/ _jsx(CaretDownOutlined, {}),
61
63
  popupClassName: popupClassName ? `${popupClassName} ${styles.BhdTableSelect_popup}` : styles.BhdTableSelect_popup
62
64
  });
63
65
  return /*#__PURE__*/ _jsx("div", {
@@ -32,6 +32,7 @@ var getParentWidth = function(node) {
32
32
  };
33
33
  // const defaultWidthRang: widthRangType = [180, 240, 320]; //默认自适应的值 [最小值,最佳值,最大值]
34
34
  //传入的参数为onCell==>需要进行函数合并
35
+ /* 记录的滚动条宽度 */ var recordScrollBarWidth = 0;
35
36
  var Table = function(props) {
36
37
  var tableRef = useRef(null);
37
38
  var timerRef = useRef({
@@ -48,8 +49,8 @@ var Table = function(props) {
48
49
  var initColumns = function() {
49
50
  var scrollBarDom = tableRef.current.getElementsByClassName("bhd-table-cell-scrollbar")[0];
50
51
  var scrollBarWidth = scrollBarDom ? scrollBarDom.clientWidth : 0;
51
- var tableWidth = bordered ? tableRef.current.offsetWidth - 2 - scrollBarWidth : tableRef.current.offsetWidth - scrollBarWidth;
52
- console.log("gaodug", scrollBarWidth);
52
+ recordScrollBarWidth = scrollBarWidth || recordScrollBarWidth;
53
+ var tableWidth = bordered ? tableRef.current.offsetWidth - 2 - recordScrollBarWidth : tableRef.current.offsetWidth - recordScrollBarWidth;
53
54
  var _initColumnsWidth = initColumnsWidth(props.columns, tableWidth), selfColumns = _initColumnsWidth.columns;
54
55
  setColumns(selfColumns);
55
56
  var obj = scrollObject ? scrollObject : {};
@@ -198,6 +199,11 @@ var Table = function(props) {
198
199
  }, [
199
200
  props.columns
200
201
  ]);
202
+ useEffect(function() {
203
+ setScrollObject(props.scroll || undefined);
204
+ }, [
205
+ props.scroll
206
+ ]);
201
207
  var config = _object_spread_props(_object_spread({
202
208
  bordered: false
203
209
  }, props), {
@@ -6,13 +6,14 @@ import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
6
6
  import { jsx as _jsx } from "@ice/jsx-runtime/jsx-runtime";
7
7
  import * as React from "react";
8
8
  import { useRef } from "react";
9
+ import { CaretDownOutlined } from "../icons/index";
9
10
  import { Select } from "antd";
10
11
  //import type { SelectProps } from 'antd';
11
12
  import styles from "./index.module.less";
12
13
  var BhdTableSelect = function(props) {
13
14
  var _props_className = props.// initOption=[],
14
15
  // initOptionType='default',
15
- className, className = _props_className === void 0 ? "" : _props_className, _props_popupClassName = props.popupClassName, popupClassName = _props_popupClassName === void 0 ? "" : _props_popupClassName, _props_dropdownStyle = props.dropdownStyle, dropdownStyle = _props_dropdownStyle === void 0 ? {} : _props_dropdownStyle, children = props.children;
16
+ className, className = _props_className === void 0 ? "" : _props_className, _props_popupClassName = props.popupClassName, popupClassName = _props_popupClassName === void 0 ? "" : _props_popupClassName, _props_dropdownStyle = props.dropdownStyle, dropdownStyle = _props_dropdownStyle === void 0 ? {} : _props_dropdownStyle, _props_suffixIcon = props.suffixIcon, suffixIcon = _props_suffixIcon === void 0 ? null : _props_suffixIcon, children = props.children;
16
17
  var tableSelectRef = useRef(null);
17
18
  // const handleTypeSwitchOption=()=>{
18
19
  // switch(initOptionType){
@@ -58,6 +59,7 @@ var BhdTableSelect = function(props) {
58
59
  borderRadius: 4,
59
60
  border: "1px solid rgba(0,0,0,0.15)"
60
61
  }),
62
+ suffixIcon: suffixIcon ? suffixIcon : /*#__PURE__*/ _jsx(CaretDownOutlined, {}),
61
63
  popupClassName: popupClassName ? "".concat(popupClassName, " ").concat(styles.BhdTableSelect_popup) : styles.BhdTableSelect_popup
62
64
  });
63
65
  return /*#__PURE__*/ _jsx("div", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bhd-components",
3
- "version": "0.2.8",
3
+ "version": "0.3.0",
4
4
  "description": "组件功能描述",
5
5
  "files": [
6
6
  "esm",