@nutui/nutui-react-taro 1.5.11-beta.0 → 1.5.11-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.
@@ -1,13 +1,13 @@
1
- import { M as MenuItem } from './menuitem.taro-fed68a19.js';
1
+ import { M as MenuItem } from './menuitem.taro-fee49a85.js';
2
2
  import 'react';
3
+ import '@tarojs/taro';
4
+ import '@tarojs/components';
3
5
  import 'classnames';
4
6
  import 'react-transition-group';
5
- import '@tarojs/taro';
6
7
  import './icon.taro-296a1bec.js';
7
8
  import './bem-350c1702.js';
8
9
  import '@bem-react/classname';
9
10
  import './overlay.taro-21e87fb1.js';
10
- import '@tarojs/components';
11
11
  import './typings-b9828dba.js';
12
12
 
13
13
 
@@ -1,7 +1,8 @@
1
- import React__default, { forwardRef, useState, useEffect, useImperativeHandle } from 'react';
1
+ import React__default, { forwardRef, useState, useEffect, useMemo, useCallback, useImperativeHandle } from 'react';
2
+ import { getSystemInfoSync, usePageScroll } from '@tarojs/taro';
3
+ import { View } from '@tarojs/components';
2
4
  import classNames from 'classnames';
3
5
  import { CSSTransition } from 'react-transition-group';
4
- import { getSystemInfoSync } from '@tarojs/taro';
5
6
  import { I as Icon } from './icon.taro-296a1bec.js';
6
7
  import { O as Overlay } from './overlay.taro-21e87fb1.js';
7
8
  import { C as ComponentDefaults } from './typings-b9828dba.js';
@@ -34,6 +35,19 @@ const MenuItem = forwardRef((props, ref) => {
34
35
  useEffect(() => {
35
36
  getParentOffset();
36
37
  }, [_showPopup]);
38
+ const windowHeight = useMemo(() => getSystemInfoSync().windowHeight, []);
39
+ const updateItemOffset = useCallback(() => {
40
+ const p = parent.parent().current;
41
+ p.getBoundingClientRect().then((rect) => {
42
+ if (rect) {
43
+ setPosition({
44
+ height: rect.height,
45
+ top: rect.top,
46
+ });
47
+ }
48
+ });
49
+ }, [direction, windowHeight]);
50
+ usePageScroll(updateItemOffset);
37
51
  useImperativeHandle(ref, () => ({
38
52
  toggle: parent.toggleItemShow,
39
53
  }));
@@ -75,47 +89,45 @@ const MenuItem = forwardRef((props, ref) => {
75
89
  };
76
90
  const getPosition = () => {
77
91
  return direction === 'down'
78
- ? { position: 'absolute', height: `${window.innerHeight}px` }
92
+ ? { top: `${position.top + position.height}px` }
79
93
  : {
80
- position: 'absolute',
81
- bottom: '100%',
82
- top: 'auto',
83
- height: `${window.innerHeight}px`,
94
+ bottom: `${getSystemInfoSync().windowHeight - position.top}px`,
95
+ top: '0',
96
+ height: 'initial',
84
97
  };
85
98
  };
86
99
  const placeholderStyle = () => {
87
100
  if (direction === 'down') {
88
101
  return {
89
102
  height: `${position.top + position.height}px`,
90
- top: 'auto',
91
- bottom: '-100%',
92
103
  ...isShow(),
104
+ ...style,
93
105
  };
94
106
  }
95
107
  return {
96
108
  height: `${getSystemInfoSync().windowHeight - position.top}px`,
97
- bottom: `auto`,
98
- top: '0',
109
+ top: 'auto',
99
110
  ...isShow(),
111
+ ...style,
100
112
  };
101
113
  };
102
- return (React__default.createElement("div", { className: "nut-menu-item-container", style: { position: 'absolute', left: 0, right: 0 } },
103
- React__default.createElement("div", { className: `placeholder-element ${classNames({
114
+ return (React__default.createElement(React__default.Fragment, null,
115
+ React__default.createElement(View, { className: `placeholder-element ${classNames({
104
116
  up: direction === 'up',
105
117
  })}`, style: placeholderStyle(), onClick: () => parent.toggleItemShow(orderKey) }),
106
118
  React__default.createElement(Overlay, { overlayClass: "nut-menu__overlay", style: getPosition(), lockScroll: parent.lockScroll, visible: _showPopup, closeOnClickOverlay: parent.closeOnClickOverlay, onClick: () => {
107
119
  parent.closeOnClickOverlay && parent.toggleItemShow(orderKey);
108
120
  } }),
109
- React__default.createElement("div", { className: direction === 'down'
121
+ React__default.createElement(View, { className: direction === 'down'
110
122
  ? 'nut-menu-item__wrap'
111
123
  : 'nut-menu-item__wrap-up', style: {
112
124
  // ...getPosition(),
113
125
  ...isShow(),
114
126
  } },
115
127
  React__default.createElement(CSSTransition, { in: _showPopup, timeout: 100, classNames: direction === 'down' ? 'menu-item' : 'menu-item-up' },
116
- React__default.createElement("div", { className: "nut-menu-item__content" },
128
+ React__default.createElement(View, { className: "nut-menu-item__content" },
117
129
  options?.map((item, index) => {
118
- return (React__default.createElement("div", { className: `nut-menu-item__option ${classNames({
130
+ return (React__default.createElement(View, { className: `nut-menu-item__option ${classNames({
119
131
  active: item.value === _value,
120
132
  })}`, key: item.text, style: {
121
133
  flexBasis: `${100 / columns}%`,
@@ -123,7 +135,7 @@ const MenuItem = forwardRef((props, ref) => {
123
135
  handleClick(item);
124
136
  } },
125
137
  item.value === _value ? (React__default.createElement(Icon, { classPrefix: iconClassPrefix, fontClassName: iconFontClassName, className: getIconCName(item.value, value), name: optionsIcon, color: activeColor })) : null,
126
- React__default.createElement("div", { className: getIconCName(item.value, value), style: {
138
+ React__default.createElement(View, { className: getIconCName(item.value, value), style: {
127
139
  color: `${item.value === _value ? activeColor : ''}`,
128
140
  } }, item.text)));
129
141
  }),
@@ -17,7 +17,7 @@ export { E as Elevator } from './elevator.taro-a883f7ad.js';
17
17
  export { F as FixedNav } from './fixednav.taro-1f05acaf.js';
18
18
  export { I as Indicator } from './indicator.taro-cba8b010.js';
19
19
  export { M as Menu } from './menu.taro-7e4038a1.js';
20
- export { M as MenuItem } from './menuitem.taro-fed68a19.js';
20
+ export { M as MenuItem } from './menuitem.taro-fee49a85.js';
21
21
  export { N as NavBar } from './navbar.taro-777c4705.js';
22
22
  export { P as Pagination } from './pagination.taro-715a173b.js';
23
23
  export { S as SideNavBar } from './sidenavbar.taro-c307b35e.js';
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react-taro v1.5.11-beta.0 Wed Jul 05 2023 10:56:09 GMT+0800 (中国标准时间)
2
+ * @nutui/nutui-react-taro v1.5.11 Thu Jul 06 2023 16:48:08 GMT+0800 (China Standard Time)
3
3
  * (c) 2023 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react-taro v1.5.11-beta.0 Wed Jul 05 2023 10:56:09 GMT+0800 (中国标准时间)
2
+ * @nutui/nutui-react-taro v1.5.11 Thu Jul 06 2023 16:48:08 GMT+0800 (China Standard Time)
3
3
  * (c) 2023 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react-taro v1.5.11-beta.0 Wed Jul 05 2023 10:56:09 GMT+0800 (中国标准时间)
2
+ * @nutui/nutui-react-taro v1.5.11 Thu Jul 06 2023 16:48:08 GMT+0800 (China Standard Time)
3
3
  * (c) 2023 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react-taro v1.5.11-beta.0 Wed Jul 05 2023 10:56:09 GMT+0800 (中国标准时间)
2
+ * @nutui/nutui-react-taro v1.5.11 Thu Jul 06 2023 16:48:08 GMT+0800 (China Standard Time)
3
3
  * (c) 2023 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react-taro v1.5.11-beta.0 Wed Jul 05 2023 10:56:09 GMT+0800 (中国标准时间)
2
+ * @nutui/nutui-react-taro v1.5.11 Thu Jul 06 2023 16:48:08 GMT+0800 (China Standard Time)
3
3
  * (c) 2023 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react-taro v1.5.11-beta.0 Wed Jul 05 2023 10:56:09 GMT+0800 (中国标准时间)
2
+ * @nutui/nutui-react-taro v1.5.11 Thu Jul 06 2023 16:48:08 GMT+0800 (China Standard Time)
3
3
  * (c) 2023 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */