@sheinx/base 3.4.5-beta.2 → 3.4.5-beta.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 +1 @@
1
- {"version":3,"file":"item.d.ts","sourceRoot":"","sources":["item.tsx"],"names":[],"mappings":";AAOA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,QAAA,MAAM,IAAI,kDAiDT,CAAC;AAEF,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"item.d.ts","sourceRoot":"","sources":["item.tsx"],"names":[],"mappings":";AAOA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,QAAA,MAAM,IAAI,kDAiET,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+ 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); }
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
@@ -14,20 +15,32 @@ var _jsxRuntime = require("react/jsx-runtime");
14
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
16
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
16
17
  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; }
17
- 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); }
18
18
  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; }
19
19
  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; }
20
20
  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; }
21
21
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
22
22
  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); }
23
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
24
+ 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."); }
25
+ 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); }
26
+ 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; }
27
+ 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; } }
28
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
23
29
  var Item = function Item(props) {
24
30
  var _props$jssStyle, _props$jssStyle$cardG;
25
31
  var _useContext = (0, _react.useContext)(_cardGroupContext.CardGroupContext),
26
32
  container = _useContext.container;
27
33
  var classes = (_props$jssStyle = props.jssStyle) === null || _props$jssStyle === void 0 || (_props$jssStyle$cardG = _props$jssStyle.cardGroup) === null || _props$jssStyle$cardG === void 0 ? void 0 : _props$jssStyle$cardG.call(_props$jssStyle);
28
- var _useInView = (0, _hooks.useInView)(),
34
+ var _useInView = (0, _hooks.useInView)({
35
+ root: container,
36
+ rootMargin: "".concat((container === null || container === void 0 ? void 0 : container.clientHeight) || 100, "px")
37
+ }),
29
38
  itemRef = _useInView.ref,
30
39
  isInView = _useInView.isInView;
40
+ var _useState = (0, _react.useState)(0),
41
+ _useState2 = _slicedToArray(_useState, 2),
42
+ itemHeight = _useState2[0],
43
+ setItemHeight = _useState2[1];
31
44
  var handleChange = (0, _hooks.usePersistFn)(function (_, checked) {
32
45
  if (props.onChange) props.onChange(checked, props.value);
33
46
  });
@@ -52,11 +65,22 @@ var Item = function Item(props) {
52
65
  className: classes === null || classes === void 0 ? void 0 : classes.checkbox
53
66
  })]
54
67
  });
55
- var itemStyle = (0, _react.useMemo)(function () {
56
- return _objectSpread(_objectSpread({}, props.style), {}, {
68
+ (0, _react.useEffect)(function () {
69
+ if (isInView) {
70
+ var _itemRef$current;
71
+ setItemHeight(((_itemRef$current = itemRef.current) === null || _itemRef$current === void 0 ? void 0 : _itemRef$current.clientHeight) || 0);
72
+ }
73
+ }, [isInView]);
74
+ var hiddenStyle = (0, _react.useMemo)(function () {
75
+ return isInView ? {} : {
76
+ height: itemHeight,
77
+ overflow: 'hidden',
57
78
  visibility: isInView ? 'visible' : 'hidden'
58
- });
59
- }, [isInView, props.style]);
79
+ };
80
+ }, [isInView, itemHeight]);
81
+ var itemStyle = (0, _react.useMemo)(function () {
82
+ return _objectSpread(_objectSpread({}, props.style), hiddenStyle);
83
+ }, [hiddenStyle, props.style]);
60
84
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
61
85
  ref: itemRef,
62
86
  className: cls,
@@ -1 +1 @@
1
- {"version":3,"file":"item.d.ts","sourceRoot":"","sources":["item.tsx"],"names":[],"mappings":";AAOA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,QAAA,MAAM,IAAI,kDAiDT,CAAC;AAEF,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"item.d.ts","sourceRoot":"","sources":["item.tsx"],"names":[],"mappings":";AAOA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,QAAA,MAAM,IAAI,kDAiET,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -4,7 +4,13 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
4
  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; }
5
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
6
  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); }
7
- import React, { useContext, useMemo } from 'react';
7
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
+ 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."); }
9
+ 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); }
10
+ 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; }
11
+ 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; } }
12
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
+ import React, { useContext, useEffect, useMemo, useState } from 'react';
8
14
  import { useInView, usePersistFn } from '@sheinx/hooks';
9
15
  import classNames from 'classnames';
10
16
  import { CardGroupContext } from "./card-group-context";
@@ -18,9 +24,16 @@ var Item = function Item(props) {
18
24
  var _useContext = useContext(CardGroupContext),
19
25
  container = _useContext.container;
20
26
  var classes = (_props$jssStyle = props.jssStyle) === null || _props$jssStyle === void 0 || (_props$jssStyle$cardG = _props$jssStyle.cardGroup) === null || _props$jssStyle$cardG === void 0 ? void 0 : _props$jssStyle$cardG.call(_props$jssStyle);
21
- var _useInView = useInView(),
27
+ var _useInView = useInView({
28
+ root: container,
29
+ rootMargin: "".concat((container === null || container === void 0 ? void 0 : container.clientHeight) || 100, "px")
30
+ }),
22
31
  itemRef = _useInView.ref,
23
32
  isInView = _useInView.isInView;
33
+ var _useState = useState(0),
34
+ _useState2 = _slicedToArray(_useState, 2),
35
+ itemHeight = _useState2[0],
36
+ setItemHeight = _useState2[1];
24
37
  var handleChange = usePersistFn(function (_, checked) {
25
38
  if (props.onChange) props.onChange(checked, props.value);
26
39
  });
@@ -45,11 +58,22 @@ var Item = function Item(props) {
45
58
  className: classes === null || classes === void 0 ? void 0 : classes.checkbox
46
59
  })]
47
60
  });
48
- var itemStyle = useMemo(function () {
49
- return _objectSpread(_objectSpread({}, props.style), {}, {
61
+ useEffect(function () {
62
+ if (isInView) {
63
+ var _itemRef$current;
64
+ setItemHeight(((_itemRef$current = itemRef.current) === null || _itemRef$current === void 0 ? void 0 : _itemRef$current.clientHeight) || 0);
65
+ }
66
+ }, [isInView]);
67
+ var hiddenStyle = useMemo(function () {
68
+ return isInView ? {} : {
69
+ height: itemHeight,
70
+ overflow: 'hidden',
50
71
  visibility: isInView ? 'visible' : 'hidden'
51
- });
52
- }, [isInView, props.style]);
72
+ };
73
+ }, [isInView, itemHeight]);
74
+ var itemStyle = useMemo(function () {
75
+ return _objectSpread(_objectSpread({}, props.style), hiddenStyle);
76
+ }, [hiddenStyle, props.style]);
53
77
  return /*#__PURE__*/_jsx("div", {
54
78
  ref: itemRef,
55
79
  className: cls,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sheinx/base",
3
- "version": "3.4.5-beta.2",
3
+ "version": "3.4.5-beta.3",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -10,7 +10,7 @@
10
10
  "module": "./esm/index.js",
11
11
  "typings": "./cjs/index.d.ts",
12
12
  "dependencies": {
13
- "@sheinx/hooks": "3.4.5-beta.2",
13
+ "@sheinx/hooks": "3.4.5-beta.3",
14
14
  "immer": "^10.0.0",
15
15
  "classnames": "^2.0.0",
16
16
  "@shined/reactive": "^0.1.3-alpha.0"