@lemon-fe/components 0.1.26 → 0.1.27

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.
@@ -193,6 +193,8 @@ var favoriteIcon = /*#__PURE__*/React.createElement("svg", {
193
193
  strokeDasharray: "0,0",
194
194
  mask: "url(#mask-2)"
195
195
  })))));
196
+ var WIDTH = 1280;
197
+ var FAVORITES_POPOVER = 'FAVORITES_POPOVER';
196
198
  export default function Menu(props) {
197
199
  var menus = props.data,
198
200
  onClick = props.onClick,
@@ -208,8 +210,9 @@ export default function Menu(props) {
208
210
 
209
211
  var popup = useRef(null);
210
212
  var drawer = useRef(null);
213
+ var clientWidth = useRef(document.body.clientWidth);
211
214
 
212
- var _useState3 = useState(document.body.clientWidth <= 1280),
215
+ var _useState3 = useState(clientWidth.current <= WIDTH),
213
216
  _useState4 = _slicedToArray(_useState3, 2),
214
217
  collapsed = _useState4[0],
215
218
  setCollapsed = _useState4[1];
@@ -224,7 +227,6 @@ export default function Menu(props) {
224
227
  top = _useState8[0],
225
228
  setTop = _useState8[1];
226
229
 
227
- var FAVORITES_POPOVER = 'FAVORITES_POPOVER';
228
230
  var activeMenu = useMemo(function () {
229
231
  var check = function check(path) {
230
232
  if (path) {
@@ -335,6 +337,22 @@ export default function Menu(props) {
335
337
  };
336
338
  }
337
339
  }, [visible]);
340
+ useEffect(function () {
341
+ var handleResize = function handleResize() {
342
+ var width = document.body.clientWidth;
343
+
344
+ if (clientWidth.current > WIDTH && width <= WIDTH) {
345
+ setCollapsed(true);
346
+ }
347
+
348
+ clientWidth.current = width;
349
+ };
350
+
351
+ window.addEventListener('resize', handleResize);
352
+ return function () {
353
+ window.removeEventListener('resize', handleResize);
354
+ };
355
+ }, []);
338
356
 
339
357
  var openDrawer = function openDrawer() {
340
358
  setVisible(true);
@@ -578,7 +596,7 @@ export default function Menu(props) {
578
596
  var target = e.currentTarget;
579
597
  toggle(function () {
580
598
  return openMenu({
581
- name: 'FAVORITES_POPOVER',
599
+ name: FAVORITES_POPOVER,
582
600
  children: _toConsumableArray(favoritesMap.values())
583
601
  }, target);
584
602
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lemon-fe/components",
3
- "version": "0.1.26",
3
+ "version": "0.1.27",
4
4
  "description": "> TODO: description",
5
5
  "author": "鲁盛杰 <lusj@cnlemon.net>",
6
6
  "homepage": "",
@@ -41,5 +41,5 @@
41
41
  "react": "^17.0.2",
42
42
  "react-dom": "^17.0.2"
43
43
  },
44
- "gitHead": "14dc8a92689ded718e70523282c3979784044154"
44
+ "gitHead": "227a3713f84228eef6b06d4553cf47d23af1be06"
45
45
  }