@sheinx/hooks 3.9.0-beta.4 → 3.9.0-beta.5
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.
- package/cjs/components/use-table/use-table-virtual.d.ts +1 -0
 - package/cjs/components/use-table/use-table-virtual.d.ts.map +1 -1
 - package/cjs/components/use-table/use-table-virtual.js +11 -6
 - package/esm/components/use-table/use-table-virtual.d.ts +1 -0
 - package/esm/components/use-table/use-table-virtual.d.ts.map +1 -1
 - package/esm/components/use-table/use-table-virtual.js +11 -6
 - package/package.json +1 -1
 
| 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            {"version":3,"file":"use-table-virtual.d.ts","sourceRoot":"","sources":["use-table-virtual.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAWrD,UAAU,oBAAoB;IAC5B,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC3C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;IAClC,QAAQ,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,EAAE,CAAC;IAC1C,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB;AACD,QAAA,MAAM,eAAe,UAAW,oBAAoB;;;;;; 
     | 
| 
      
 1 
     | 
    
         
            +
            {"version":3,"file":"use-table-virtual.d.ts","sourceRoot":"","sources":["use-table-virtual.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAWrD,UAAU,oBAAoB;IAC5B,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC3C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;IAClC,QAAQ,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,EAAE,CAAC;IAC1C,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB;AACD,QAAA,MAAM,eAAe,UAAW,oBAAoB;;;;;;oBA0LpC,MAAM;mBACP,MAAM;WACd,MAAM;gBACD,MAAM;kBACJ,OAAO;;0BAnGuB,MAAM,UAAU,MAAM;2BAsIrB,MAAM,aAAa,MAAM,IAAI;qCAoBnB,MAAM;mCAUR,MAAM,GAAG,MAAM;;;;;CA2GnE,CAAC;AAEF,eAAe,eAAe,CAAC"}
         
     | 
| 
         @@ -39,7 +39,9 @@ var useTableVirtual = function useTableVirtual(props) { 
     | 
|
| 
       39 
39 
     | 
    
         
             
                _useState2 = _slicedToArray(_useState, 2),
         
     | 
| 
       40 
40 
     | 
    
         
             
                innerTop = _useState2[0],
         
     | 
| 
       41 
41 
     | 
    
         
             
                setTop = _useState2[1];
         
     | 
| 
       42 
     | 
    
         
            -
              var  
     | 
| 
      
 42 
     | 
    
         
            +
              var strictRowHeight = props.strictRowHeight ? props.strictRowHeight : 0;
         
     | 
| 
      
 43 
     | 
    
         
            +
              var defaultScrollHeight = strictRowHeight ? props.data.length * strictRowHeight : props.data.length * props.rowHeight;
         
     | 
| 
      
 44 
     | 
    
         
            +
              var _useState3 = (0, _react.useState)(defaultScrollHeight),
         
     | 
| 
       43 
45 
     | 
    
         
             
                _useState4 = _slicedToArray(_useState3, 2),
         
     | 
| 
       44 
46 
     | 
    
         
             
                scrollHeight = _useState4[0],
         
     | 
| 
       45 
47 
     | 
    
         
             
                setHeight = _useState4[1];
         
     | 
| 
         @@ -125,6 +127,9 @@ var useTableVirtual = function useTableVirtual(props) { 
     | 
|
| 
       125 
127 
     | 
    
         
             
                context = _useRef.current;
         
     | 
| 
       126 
128 
     | 
    
         
             
              var getContentHeight = function getContentHeight(index) {
         
     | 
| 
       127 
129 
     | 
    
         
             
                if (props.disabled) return 0;
         
     | 
| 
      
 130 
     | 
    
         
            +
                if (strictRowHeight) {
         
     | 
| 
      
 131 
     | 
    
         
            +
                  return strictRowHeight * (index + 1) + props.theadHeight + props.tfootHeight;
         
     | 
| 
      
 132 
     | 
    
         
            +
                }
         
     | 
| 
       128 
133 
     | 
    
         
             
                var sum = 0;
         
     | 
| 
       129 
134 
     | 
    
         
             
                for (var i = 0; i <= index; i++) {
         
     | 
| 
       130 
135 
     | 
    
         
             
                  sum += context.cachedHeight[i] || props.rowHeight;
         
     | 
| 
         @@ -160,7 +165,7 @@ var useTableVirtual = function useTableVirtual(props) { 
     | 
|
| 
       160 
165 
     | 
    
         
             
                var scrollContainerHeight = Math.max(((_props$scrollRef$curr = props.scrollRef.current) === null || _props$scrollRef$curr === void 0 ? void 0 : _props$scrollRef$curr.clientHeight) || 0, 200);
         
     | 
| 
       161 
166 
     | 
    
         
             
                for (var i = 0; i <= maxIndex; i++) {
         
     | 
| 
       162 
167 
     | 
    
         
             
                  context.rowSpanRows = 0;
         
     | 
| 
       163 
     | 
    
         
            -
                  var currentRowHeight = context.cachedHeight[i] || props.rowHeight;
         
     | 
| 
      
 168 
     | 
    
         
            +
                  var currentRowHeight = strictRowHeight || context.cachedHeight[i] || props.rowHeight;
         
     | 
| 
       164 
169 
     | 
    
         
             
                  sum += currentRowHeight;
         
     | 
| 
       165 
170 
     | 
    
         
             
                  var rowSpanHeight = 0;
         
     | 
| 
       166 
171 
     | 
    
         
             
                  if (rowSpanInfo) {
         
     | 
| 
         @@ -175,13 +180,13 @@ var useTableVirtual = function useTableVirtual(props) { 
     | 
|
| 
       175 
180 
     | 
    
         
             
                      if (rowSpanHeight < scrollContainerHeight) {
         
     | 
| 
       176 
181 
     | 
    
         
             
                        var index = siblingsIndexs[j];
         
     | 
| 
       177 
182 
     | 
    
         
             
                        context.rowSpanRows += 1;
         
     | 
| 
       178 
     | 
    
         
            -
                        rowSpanHeight += context.cachedHeight[index] || props.rowHeight;
         
     | 
| 
      
 183 
     | 
    
         
            +
                        rowSpanHeight += strictRowHeight || context.cachedHeight[index] || props.rowHeight;
         
     | 
| 
       179 
184 
     | 
    
         
             
                      }
         
     | 
| 
       180 
185 
     | 
    
         
             
                    }
         
     | 
| 
       181 
186 
     | 
    
         
             
                  }
         
     | 
| 
       182 
187 
     | 
    
         
             
                  if (scrollTop < sum + rowSpanHeight || i === maxIndex) {
         
     | 
| 
       183 
188 
     | 
    
         
             
                    currentIndex = i;
         
     | 
| 
       184 
     | 
    
         
            -
                    var beforeHeight = i === 0 ? 0 : sum - (context.cachedHeight[i] || props.rowHeight);
         
     | 
| 
      
 189 
     | 
    
         
            +
                    var beforeHeight = i === 0 ? 0 : sum - (strictRowHeight || context.cachedHeight[i] || props.rowHeight);
         
     | 
| 
       185 
190 
     | 
    
         
             
                    top = scrollTop - beforeHeight;
         
     | 
| 
       186 
191 
     | 
    
         
             
                    break;
         
     | 
| 
       187 
192 
     | 
    
         
             
                  }
         
     | 
| 
         @@ -314,10 +319,10 @@ var useTableVirtual = function useTableVirtual(props) { 
     | 
|
| 
       314 
319 
     | 
    
         
             
                  var addonHeight = 0;
         
     | 
| 
       315 
320 
     | 
    
         
             
                  var addonCount = 0;
         
     | 
| 
       316 
321 
     | 
    
         
             
                  for (var i = startIndex + rowsInView; i < props.data.length; i++) {
         
     | 
| 
       317 
     | 
    
         
            -
                    var height = context.cachedHeight[i] || props.rowHeight;
         
     | 
| 
      
 322 
     | 
    
         
            +
                    var height = strictRowHeight || context.cachedHeight[i] || props.rowHeight;
         
     | 
| 
       318 
323 
     | 
    
         
             
                    addonHeight += height;
         
     | 
| 
       319 
324 
     | 
    
         
             
                    addonCount += 1;
         
     | 
| 
       320 
     | 
    
         
            -
                    if (addonHeight >= remainHeight + context.cachedHeight[0]) break;
         
     | 
| 
      
 325 
     | 
    
         
            +
                    if (addonHeight >= remainHeight + (strictRowHeight || context.cachedHeight[0])) break;
         
     | 
| 
       321 
326 
     | 
    
         
             
                  }
         
     | 
| 
       322 
327 
     | 
    
         
             
                  if (addonCount > 0) {
         
     | 
| 
       323 
328 
     | 
    
         
             
                    context.autoAddRows = addonCount;
         
     | 
| 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            {"version":3,"file":"use-table-virtual.d.ts","sourceRoot":"","sources":["use-table-virtual.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAWrD,UAAU,oBAAoB;IAC5B,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC3C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;IAClC,QAAQ,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,EAAE,CAAC;IAC1C,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB;AACD,QAAA,MAAM,eAAe,UAAW,oBAAoB;;;;;; 
     | 
| 
      
 1 
     | 
    
         
            +
            {"version":3,"file":"use-table-virtual.d.ts","sourceRoot":"","sources":["use-table-virtual.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAWrD,UAAU,oBAAoB;IAC5B,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC3C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;IAClC,QAAQ,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,EAAE,CAAC;IAC1C,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB;AACD,QAAA,MAAM,eAAe,UAAW,oBAAoB;;;;;;oBA0LpC,MAAM;mBACP,MAAM;WACd,MAAM;gBACD,MAAM;kBACJ,OAAO;;0BAnGuB,MAAM,UAAU,MAAM;2BAsIrB,MAAM,aAAa,MAAM,IAAI;qCAoBnB,MAAM;mCAUR,MAAM,GAAG,MAAM;;;;;CA2GnE,CAAC;AAEF,eAAe,eAAe,CAAC"}
         
     | 
| 
         @@ -33,7 +33,9 @@ var useTableVirtual = function useTableVirtual(props) { 
     | 
|
| 
       33 
33 
     | 
    
         
             
                _useState2 = _slicedToArray(_useState, 2),
         
     | 
| 
       34 
34 
     | 
    
         
             
                innerTop = _useState2[0],
         
     | 
| 
       35 
35 
     | 
    
         
             
                setTop = _useState2[1];
         
     | 
| 
       36 
     | 
    
         
            -
              var  
     | 
| 
      
 36 
     | 
    
         
            +
              var strictRowHeight = props.strictRowHeight ? props.strictRowHeight : 0;
         
     | 
| 
      
 37 
     | 
    
         
            +
              var defaultScrollHeight = strictRowHeight ? props.data.length * strictRowHeight : props.data.length * props.rowHeight;
         
     | 
| 
      
 38 
     | 
    
         
            +
              var _useState3 = useState(defaultScrollHeight),
         
     | 
| 
       37 
39 
     | 
    
         
             
                _useState4 = _slicedToArray(_useState3, 2),
         
     | 
| 
       38 
40 
     | 
    
         
             
                scrollHeight = _useState4[0],
         
     | 
| 
       39 
41 
     | 
    
         
             
                setHeight = _useState4[1];
         
     | 
| 
         @@ -119,6 +121,9 @@ var useTableVirtual = function useTableVirtual(props) { 
     | 
|
| 
       119 
121 
     | 
    
         
             
                context = _useRef.current;
         
     | 
| 
       120 
122 
     | 
    
         
             
              var getContentHeight = function getContentHeight(index) {
         
     | 
| 
       121 
123 
     | 
    
         
             
                if (props.disabled) return 0;
         
     | 
| 
      
 124 
     | 
    
         
            +
                if (strictRowHeight) {
         
     | 
| 
      
 125 
     | 
    
         
            +
                  return strictRowHeight * (index + 1) + props.theadHeight + props.tfootHeight;
         
     | 
| 
      
 126 
     | 
    
         
            +
                }
         
     | 
| 
       122 
127 
     | 
    
         
             
                var sum = 0;
         
     | 
| 
       123 
128 
     | 
    
         
             
                for (var i = 0; i <= index; i++) {
         
     | 
| 
       124 
129 
     | 
    
         
             
                  sum += context.cachedHeight[i] || props.rowHeight;
         
     | 
| 
         @@ -154,7 +159,7 @@ var useTableVirtual = function useTableVirtual(props) { 
     | 
|
| 
       154 
159 
     | 
    
         
             
                var scrollContainerHeight = Math.max(((_props$scrollRef$curr = props.scrollRef.current) === null || _props$scrollRef$curr === void 0 ? void 0 : _props$scrollRef$curr.clientHeight) || 0, 200);
         
     | 
| 
       155 
160 
     | 
    
         
             
                for (var i = 0; i <= maxIndex; i++) {
         
     | 
| 
       156 
161 
     | 
    
         
             
                  context.rowSpanRows = 0;
         
     | 
| 
       157 
     | 
    
         
            -
                  var currentRowHeight = context.cachedHeight[i] || props.rowHeight;
         
     | 
| 
      
 162 
     | 
    
         
            +
                  var currentRowHeight = strictRowHeight || context.cachedHeight[i] || props.rowHeight;
         
     | 
| 
       158 
163 
     | 
    
         
             
                  sum += currentRowHeight;
         
     | 
| 
       159 
164 
     | 
    
         
             
                  var rowSpanHeight = 0;
         
     | 
| 
       160 
165 
     | 
    
         
             
                  if (rowSpanInfo) {
         
     | 
| 
         @@ -169,13 +174,13 @@ var useTableVirtual = function useTableVirtual(props) { 
     | 
|
| 
       169 
174 
     | 
    
         
             
                      if (rowSpanHeight < scrollContainerHeight) {
         
     | 
| 
       170 
175 
     | 
    
         
             
                        var index = siblingsIndexs[j];
         
     | 
| 
       171 
176 
     | 
    
         
             
                        context.rowSpanRows += 1;
         
     | 
| 
       172 
     | 
    
         
            -
                        rowSpanHeight += context.cachedHeight[index] || props.rowHeight;
         
     | 
| 
      
 177 
     | 
    
         
            +
                        rowSpanHeight += strictRowHeight || context.cachedHeight[index] || props.rowHeight;
         
     | 
| 
       173 
178 
     | 
    
         
             
                      }
         
     | 
| 
       174 
179 
     | 
    
         
             
                    }
         
     | 
| 
       175 
180 
     | 
    
         
             
                  }
         
     | 
| 
       176 
181 
     | 
    
         
             
                  if (scrollTop < sum + rowSpanHeight || i === maxIndex) {
         
     | 
| 
       177 
182 
     | 
    
         
             
                    currentIndex = i;
         
     | 
| 
       178 
     | 
    
         
            -
                    var beforeHeight = i === 0 ? 0 : sum - (context.cachedHeight[i] || props.rowHeight);
         
     | 
| 
      
 183 
     | 
    
         
            +
                    var beforeHeight = i === 0 ? 0 : sum - (strictRowHeight || context.cachedHeight[i] || props.rowHeight);
         
     | 
| 
       179 
184 
     | 
    
         
             
                    top = scrollTop - beforeHeight;
         
     | 
| 
       180 
185 
     | 
    
         
             
                    break;
         
     | 
| 
       181 
186 
     | 
    
         
             
                  }
         
     | 
| 
         @@ -308,10 +313,10 @@ var useTableVirtual = function useTableVirtual(props) { 
     | 
|
| 
       308 
313 
     | 
    
         
             
                  var addonHeight = 0;
         
     | 
| 
       309 
314 
     | 
    
         
             
                  var addonCount = 0;
         
     | 
| 
       310 
315 
     | 
    
         
             
                  for (var i = startIndex + rowsInView; i < props.data.length; i++) {
         
     | 
| 
       311 
     | 
    
         
            -
                    var height = context.cachedHeight[i] || props.rowHeight;
         
     | 
| 
      
 316 
     | 
    
         
            +
                    var height = strictRowHeight || context.cachedHeight[i] || props.rowHeight;
         
     | 
| 
       312 
317 
     | 
    
         
             
                    addonHeight += height;
         
     | 
| 
       313 
318 
     | 
    
         
             
                    addonCount += 1;
         
     | 
| 
       314 
     | 
    
         
            -
                    if (addonHeight >= remainHeight + context.cachedHeight[0]) break;
         
     | 
| 
      
 319 
     | 
    
         
            +
                    if (addonHeight >= remainHeight + (strictRowHeight || context.cachedHeight[0])) break;
         
     | 
| 
       315 
320 
     | 
    
         
             
                  }
         
     | 
| 
       316 
321 
     | 
    
         
             
                  if (addonCount > 0) {
         
     | 
| 
       317 
322 
     | 
    
         
             
                    context.autoAddRows = addonCount;
         
     |