@sheinx/base 3.4.4 → 3.4.5-beta.2

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/card/card.js CHANGED
@@ -27,7 +27,9 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
27
27
  var Card = function Card(props) {
28
28
  var _props$jssStyle, _props$jssStyle$card, _props$id;
29
29
  var _props$style = props.style,
30
- style = _props$style === void 0 ? {} : _props$style;
30
+ style = _props$style === void 0 ? {} : _props$style,
31
+ _props$defaultCollaps = props.defaultCollapsed,
32
+ defaultCollapsed = _props$defaultCollaps === void 0 ? true : _props$defaultCollaps;
31
33
  var cardClasses = (_props$jssStyle = props.jssStyle) === null || _props$jssStyle === void 0 || (_props$jssStyle$card = _props$jssStyle.card) === null || _props$jssStyle$card === void 0 ? void 0 : _props$jssStyle$card.call(_props$jssStyle);
32
34
  var panelRef = (0, _react.useRef)(null);
33
35
  var forceUpdate = (0, _hooks.useRender)();
@@ -35,7 +37,7 @@ var Card = function Card(props) {
35
37
  id: undefined
36
38
  }),
37
39
  context = _useRef.current;
38
- var _useState = (0, _react.useState)(props.defaultCollapsed),
40
+ var _useState = (0, _react.useState)(defaultCollapsed),
39
41
  _useState2 = _slicedToArray(_useState, 2),
40
42
  collapsed = _useState2[0],
41
43
  setCollapsed = _useState2[1];
@@ -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,kDAyCT,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,kDAiDT,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -1,6 +1,5 @@
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); }
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
@@ -15,11 +14,20 @@ var _jsxRuntime = require("react/jsx-runtime");
15
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
15
  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); }
17
16
  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
+ 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
+ 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
+ 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
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
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); }
18
23
  var Item = function Item(props) {
19
24
  var _props$jssStyle, _props$jssStyle$cardG;
20
25
  var _useContext = (0, _react.useContext)(_cardGroupContext.CardGroupContext),
21
26
  container = _useContext.container;
22
27
  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)(),
29
+ itemRef = _useInView.ref,
30
+ isInView = _useInView.isInView;
23
31
  var handleChange = (0, _hooks.usePersistFn)(function (_, checked) {
24
32
  if (props.onChange) props.onChange(checked, props.value);
25
33
  });
@@ -29,6 +37,7 @@ var Item = function Item(props) {
29
37
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_lazyload.default, {
30
38
  container: container,
31
39
  placeholder: props.placeholder,
40
+ isInView: isInView,
32
41
  children: content
33
42
  });
34
43
  };
@@ -43,9 +52,15 @@ var Item = function Item(props) {
43
52
  className: classes === null || classes === void 0 ? void 0 : classes.checkbox
44
53
  })]
45
54
  });
55
+ var itemStyle = (0, _react.useMemo)(function () {
56
+ return _objectSpread(_objectSpread({}, props.style), {}, {
57
+ visibility: isInView ? 'visible' : 'hidden'
58
+ });
59
+ }, [isInView, props.style]);
46
60
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
61
+ ref: itemRef,
47
62
  className: cls,
48
- style: props.style,
63
+ style: itemStyle,
49
64
  children: renderChildren(content)
50
65
  });
51
66
  };
@@ -4,6 +4,7 @@ export interface LazyloadProps {
4
4
  placeholder?: React.ReactNode;
5
5
  container?: HTMLElement;
6
6
  offset?: number;
7
+ isInView?: boolean;
7
8
  }
8
9
  declare const Lazyload: (props: LazyloadProps) => JSX.Element;
9
10
  export default Lazyload;
@@ -1 +1 @@
1
- {"version":3,"file":"lazyload.d.ts","sourceRoot":"","sources":["lazyload.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAK3D,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,QAAA,MAAM,QAAQ,UAAW,aAAa,gBAyBrC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"lazyload.d.ts","sourceRoot":"","sources":["lazyload.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAK3D,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,QAAA,MAAM,QAAQ,UAAW,aAAa,gBAyBrC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -38,7 +38,7 @@ var Lazyload = function Lazyload(props) {
38
38
  removeStack(lazyId);
39
39
  };
40
40
  }, []);
41
- if (ready) return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
41
+ if (ready && props.isInView) return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
42
42
  children: props.children
43
43
  });
44
44
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
package/esm/card/card.js CHANGED
@@ -22,7 +22,9 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
22
22
  var Card = function Card(props) {
23
23
  var _props$jssStyle, _props$jssStyle$card, _props$id;
24
24
  var _props$style = props.style,
25
- style = _props$style === void 0 ? {} : _props$style;
25
+ style = _props$style === void 0 ? {} : _props$style,
26
+ _props$defaultCollaps = props.defaultCollapsed,
27
+ defaultCollapsed = _props$defaultCollaps === void 0 ? true : _props$defaultCollaps;
26
28
  var cardClasses = (_props$jssStyle = props.jssStyle) === null || _props$jssStyle === void 0 || (_props$jssStyle$card = _props$jssStyle.card) === null || _props$jssStyle$card === void 0 ? void 0 : _props$jssStyle$card.call(_props$jssStyle);
27
29
  var panelRef = useRef(null);
28
30
  var forceUpdate = useRender();
@@ -30,7 +32,7 @@ var Card = function Card(props) {
30
32
  id: undefined
31
33
  }),
32
34
  context = _useRef.current;
33
- var _useState = useState(props.defaultCollapsed),
35
+ var _useState = useState(defaultCollapsed),
34
36
  _useState2 = _slicedToArray(_useState, 2),
35
37
  collapsed = _useState2[0],
36
38
  setCollapsed = _useState2[1];
@@ -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,kDAyCT,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,kDAiDT,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -1,5 +1,11 @@
1
- import React, { useContext } from 'react';
2
- import { usePersistFn } from '@sheinx/hooks';
1
+ 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); }
2
+ 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; }
3
+ 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; }
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
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
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';
8
+ import { useInView, usePersistFn } from '@sheinx/hooks';
3
9
  import classNames from 'classnames';
4
10
  import { CardGroupContext } from "./card-group-context";
5
11
  import Lazyload from "./lazyload";
@@ -12,6 +18,9 @@ var Item = function Item(props) {
12
18
  var _useContext = useContext(CardGroupContext),
13
19
  container = _useContext.container;
14
20
  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(),
22
+ itemRef = _useInView.ref,
23
+ isInView = _useInView.isInView;
15
24
  var handleChange = usePersistFn(function (_, checked) {
16
25
  if (props.onChange) props.onChange(checked, props.value);
17
26
  });
@@ -21,6 +30,7 @@ var Item = function Item(props) {
21
30
  return /*#__PURE__*/_jsx(Lazyload, {
22
31
  container: container,
23
32
  placeholder: props.placeholder,
33
+ isInView: isInView,
24
34
  children: content
25
35
  });
26
36
  };
@@ -35,9 +45,15 @@ var Item = function Item(props) {
35
45
  className: classes === null || classes === void 0 ? void 0 : classes.checkbox
36
46
  })]
37
47
  });
48
+ var itemStyle = useMemo(function () {
49
+ return _objectSpread(_objectSpread({}, props.style), {}, {
50
+ visibility: isInView ? 'visible' : 'hidden'
51
+ });
52
+ }, [isInView, props.style]);
38
53
  return /*#__PURE__*/_jsx("div", {
54
+ ref: itemRef,
39
55
  className: cls,
40
- style: props.style,
56
+ style: itemStyle,
41
57
  children: renderChildren(content)
42
58
  });
43
59
  };
@@ -4,6 +4,7 @@ export interface LazyloadProps {
4
4
  placeholder?: React.ReactNode;
5
5
  container?: HTMLElement;
6
6
  offset?: number;
7
+ isInView?: boolean;
7
8
  }
8
9
  declare const Lazyload: (props: LazyloadProps) => JSX.Element;
9
10
  export default Lazyload;
@@ -1 +1 @@
1
- {"version":3,"file":"lazyload.d.ts","sourceRoot":"","sources":["lazyload.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAK3D,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,QAAA,MAAM,QAAQ,UAAW,aAAa,gBAyBrC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"lazyload.d.ts","sourceRoot":"","sources":["lazyload.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAK3D,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,QAAA,MAAM,QAAQ,UAAW,aAAa,gBAyBrC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -30,7 +30,7 @@ var Lazyload = function Lazyload(props) {
30
30
  removeStack(lazyId);
31
31
  };
32
32
  }, []);
33
- if (ready) return /*#__PURE__*/_jsx(_Fragment, {
33
+ if (ready && props.isInView) return /*#__PURE__*/_jsx(_Fragment, {
34
34
  children: props.children
35
35
  });
36
36
  return /*#__PURE__*/_jsx("span", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sheinx/base",
3
- "version": "3.4.4",
3
+ "version": "3.4.5-beta.2",
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.4",
13
+ "@sheinx/hooks": "3.4.5-beta.2",
14
14
  "immer": "^10.0.0",
15
15
  "classnames": "^2.0.0",
16
16
  "@shined/reactive": "^0.1.3-alpha.0"