@sheinx/base 3.1.12 → 3.1.13

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":"card.d.ts","sourceRoot":"","sources":["card.tsx"],"names":[],"mappings":";AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAG7C,QAAA,MAAM,IAAI,UAAW,SAAS,gBA0G7B,CAAC;AAEF,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"card.d.ts","sourceRoot":"","sources":["card.tsx"],"names":[],"mappings":";AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAG7C,QAAA,MAAM,IAAI,UAAW,SAAS,gBA8G7B,CAAC;AAEF,eAAe,IAAI,CAAC"}
package/cjs/card/card.js CHANGED
@@ -30,6 +30,7 @@ var Card = function Card(props) {
30
30
  style = _props$style === void 0 ? {} : _props$style;
31
31
  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
32
  var panelRef = (0, _react.useRef)(null);
33
+ var forceUpdate = (0, _hooks.useRender)();
33
34
  var _useRef = (0, _react.useRef)({
34
35
  id: undefined
35
36
  }),
@@ -49,9 +50,12 @@ var Card = function Card(props) {
49
50
  activeId = _useContext.activeId,
50
51
  getDefaultId = _useContext.getDefaultId,
51
52
  onActiveChange = _useContext.onActiveChange;
52
- if (context.id === undefined) {
53
- context.id = getDefaultId();
54
- }
53
+ (0, _react.useEffect)(function () {
54
+ if (context.id === undefined) {
55
+ context.id = getDefaultId();
56
+ forceUpdate();
57
+ }
58
+ }, []);
55
59
  var id = (_props$id = props.id) !== null && _props$id !== void 0 ? _props$id : context.id;
56
60
  var collapsible = props.collapsible || inAccordion;
57
61
  var getCollpased = function getCollpased() {
@@ -300,9 +300,9 @@ var Result = function Result(props) {
300
300
  mounted.current = true;
301
301
  }, [focus]);
302
302
  (0, _react.useEffect)(function () {
303
- handleResetMore();
303
+ setTimeout(handleResetMore);
304
304
  }, [valueProp, data]);
305
- (0, _react.useLayoutEffect)(function () {
305
+ (0, _react.useEffect)(function () {
306
306
  if (shouldResetMore && more === -1 && compressed && resultRef.current && (props.value || [].length)) {
307
307
  var tagClassName = ".".concat(styles.tag.split(' ')[0]);
308
308
  if (shouldResetMore && isArray(value) && (value || []).length) {
@@ -1 +1 @@
1
- {"version":3,"file":"tree-node.d.ts","sourceRoot":"","sources":["tree-node.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,OAAO,EAAiC,YAAY,EAAE,MAAM,eAAe,CAAC;AAkB5E,QAAA,MAAM,IAAI,gGAgST,CAAC;AAEF,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"tree-node.d.ts","sourceRoot":"","sources":["tree-node.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,OAAO,EAAiC,YAAY,EAAE,MAAM,eAAe,CAAC;AAkB5E,QAAA,MAAM,IAAI,gGAiST,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["tree.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAA4B,MAAM,eAAe,CAAC;AAEvE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAMxC,QAAA,MAAM,IAAI,4FAmOT,CAAC;AAEF,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["tree.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAA4B,MAAM,eAAe,CAAC;AAEvE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAMxC,QAAA,MAAM,IAAI,4FAyOT,CAAC;AAEF,eAAe,IAAI,CAAC"}
package/cjs/tree/tree.js CHANGED
@@ -75,6 +75,10 @@ var Tree = function Tree(props) {
75
75
  onDragStart = props.onDragStart,
76
76
  propsDatum = props.datum,
77
77
  rest = _objectWithoutProperties(props, _excluded);
78
+ var _useRef = (0, _react.useRef)({
79
+ mounted: false
80
+ }),
81
+ context = _useRef.current;
78
82
  var _useTree = (0, _hooks.useTree)({
79
83
  mode: mode,
80
84
  value: value,
@@ -190,6 +194,11 @@ var Tree = function Tree(props) {
190
194
  }
191
195
  };
192
196
  (0, _react.useEffect)(function () {
197
+ // 首次渲染不更新
198
+ if (!context.mounted) {
199
+ return;
200
+ }
201
+ if (!props.expanded) return;
193
202
  handleUpdateExpanded(expanded);
194
203
  }, [expanded]);
195
204
  (0, _react.useEffect)(function () {
@@ -198,6 +207,7 @@ var Tree = function Tree(props) {
198
207
  }, [active]);
199
208
  (0, _react.useEffect)(function () {
200
209
  if (getDatum) getDatum(datum);
210
+ context.mounted = true;
201
211
  }, []);
202
212
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({
203
213
  className: rootClass
@@ -1 +1 @@
1
- {"version":3,"file":"card.d.ts","sourceRoot":"","sources":["card.tsx"],"names":[],"mappings":";AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAG7C,QAAA,MAAM,IAAI,UAAW,SAAS,gBA0G7B,CAAC;AAEF,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"card.d.ts","sourceRoot":"","sources":["card.tsx"],"names":[],"mappings":";AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAG7C,QAAA,MAAM,IAAI,UAAW,SAAS,gBA8G7B,CAAC;AAEF,eAAe,IAAI,CAAC"}
package/esm/card/card.js CHANGED
@@ -10,8 +10,8 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
10
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
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
12
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
- import { useState, useMemo, useRef, useContext } from 'react';
14
- import { usePersistFn, useDragMove, useDragResize } from '@sheinx/hooks';
13
+ import { useState, useMemo, useRef, useContext, useEffect } from 'react';
14
+ import { usePersistFn, useDragMove, useDragResize, useRender } from '@sheinx/hooks';
15
15
  import classNames from 'classnames';
16
16
  import { CardContext } from "./card.context";
17
17
  import { CardAccordionContext, defualtCardAccordionContextValue } from "./card-accordion-context";
@@ -25,6 +25,7 @@ var Card = function Card(props) {
25
25
  style = _props$style === void 0 ? {} : _props$style;
26
26
  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
27
  var panelRef = useRef(null);
28
+ var forceUpdate = useRender();
28
29
  var _useRef = useRef({
29
30
  id: undefined
30
31
  }),
@@ -44,9 +45,12 @@ var Card = function Card(props) {
44
45
  activeId = _useContext.activeId,
45
46
  getDefaultId = _useContext.getDefaultId,
46
47
  onActiveChange = _useContext.onActiveChange;
47
- if (context.id === undefined) {
48
- context.id = getDefaultId();
49
- }
48
+ useEffect(function () {
49
+ if (context.id === undefined) {
50
+ context.id = getDefaultId();
51
+ forceUpdate();
52
+ }
53
+ }, []);
50
54
  var id = (_props$id = props.id) !== null && _props$id !== void 0 ? _props$id : context.id;
51
55
  var collapsible = props.collapsible || inAccordion;
52
56
  var getCollpased = function getCollpased() {
@@ -10,7 +10,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
10
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
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
12
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
- import React, { useState, useRef, useEffect, useLayoutEffect } from 'react';
13
+ import React, { useState, useRef, useEffect } from 'react';
14
14
  import classNames from 'classnames';
15
15
  import { util, addResizeObserver } from '@sheinx/hooks';
16
16
  import Input from "./result-input";
@@ -292,9 +292,9 @@ var Result = function Result(props) {
292
292
  mounted.current = true;
293
293
  }, [focus]);
294
294
  useEffect(function () {
295
- handleResetMore();
295
+ setTimeout(handleResetMore);
296
296
  }, [valueProp, data]);
297
- useLayoutEffect(function () {
297
+ useEffect(function () {
298
298
  if (shouldResetMore && more === -1 && compressed && resultRef.current && (props.value || [].length)) {
299
299
  var tagClassName = ".".concat(styles.tag.split(' ')[0]);
300
300
  if (shouldResetMore && isArray(value) && (value || []).length) {
@@ -1 +1 @@
1
- {"version":3,"file":"tree-node.d.ts","sourceRoot":"","sources":["tree-node.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,OAAO,EAAiC,YAAY,EAAE,MAAM,eAAe,CAAC;AAkB5E,QAAA,MAAM,IAAI,gGAgST,CAAC;AAEF,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"tree-node.d.ts","sourceRoot":"","sources":["tree-node.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,OAAO,EAAiC,YAAY,EAAE,MAAM,eAAe,CAAC;AAkB5E,QAAA,MAAM,IAAI,gGAiST,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["tree.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAA4B,MAAM,eAAe,CAAC;AAEvE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAMxC,QAAA,MAAM,IAAI,4FAmOT,CAAC;AAEF,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["tree.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAA4B,MAAM,eAAe,CAAC;AAEvE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAMxC,QAAA,MAAM,IAAI,4FAyOT,CAAC;AAEF,eAAe,IAAI,CAAC"}
package/esm/tree/tree.js CHANGED
@@ -13,7 +13,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
13
13
  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); }
14
14
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
15
15
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
16
- import { useEffect } from 'react';
16
+ import { useEffect, useRef } from 'react';
17
17
  import classNames from 'classnames';
18
18
  import { useTree, util } from '@sheinx/hooks';
19
19
  import RootTree from "./tree-root";
@@ -68,6 +68,10 @@ var Tree = function Tree(props) {
68
68
  onDragStart = props.onDragStart,
69
69
  propsDatum = props.datum,
70
70
  rest = _objectWithoutProperties(props, _excluded);
71
+ var _useRef = useRef({
72
+ mounted: false
73
+ }),
74
+ context = _useRef.current;
71
75
  var _useTree = useTree({
72
76
  mode: mode,
73
77
  value: value,
@@ -183,6 +187,11 @@ var Tree = function Tree(props) {
183
187
  }
184
188
  };
185
189
  useEffect(function () {
190
+ // 首次渲染不更新
191
+ if (!context.mounted) {
192
+ return;
193
+ }
194
+ if (!props.expanded) return;
186
195
  handleUpdateExpanded(expanded);
187
196
  }, [expanded]);
188
197
  useEffect(function () {
@@ -191,6 +200,7 @@ var Tree = function Tree(props) {
191
200
  }, [active]);
192
201
  useEffect(function () {
193
202
  if (getDatum) getDatum(datum);
203
+ context.mounted = true;
194
204
  }, []);
195
205
  return /*#__PURE__*/_jsx("div", _objectSpread(_objectSpread({
196
206
  className: rootClass
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sheinx/base",
3
- "version": "3.1.12",
3
+ "version": "3.1.13",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -10,10 +10,10 @@
10
10
  "module": "./esm/index.js",
11
11
  "typings": "./cjs/index.d.ts",
12
12
  "dependencies": {
13
- "@sheinx/hooks": "3.1.12",
13
+ "@sheinx/hooks": "3.1.13",
14
14
  "immer": "^10.0.0",
15
15
  "classnames": "^2.0.0",
16
- "@shined/reactive": "^0.1.2"
16
+ "@shined/reactive": "^0.1.3-alpha.0"
17
17
  },
18
18
  "peerDependencies": {
19
19
  "react": ">=16.8",