@arco-design/mobile-react 2.30.8 → 2.30.10
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/CHANGELOG.md +25 -0
- package/README.en-US.md +70 -2
- package/README.md +69 -2
- package/cjs/_helpers/render.d.ts +6 -1
- package/cjs/_helpers/render.js +24 -2
- package/cjs/carousel/index.js +3 -0
- package/cjs/image/style/index.less +2 -4
- package/cjs/image-preview/methods.js +2 -7
- package/cjs/masking/methods.js +12 -6
- package/cjs/picker/index.js +3 -2
- package/cjs/picker/type.d.ts +1 -1
- package/cjs/picker-view/components/cascader.d.ts +1 -0
- package/cjs/picker-view/components/cascader.js +8 -1
- package/cjs/picker-view/components/picker-cell.d.ts +1 -0
- package/cjs/picker-view/components/picker-cell.js +6 -1
- package/cjs/picker-view/index.d.ts +6 -1
- package/cjs/picker-view/index.js +25 -13
- package/cjs/skeleton/type.d.ts +1 -1
- package/cjs/skeleton/type.js +1 -6
- package/cjs/tabs/tab-cell.js +54 -29
- package/cjs/tabs/type.d.ts +5 -0
- package/dist/index.js +137 -58
- package/dist/index.min.js +3 -3
- package/esm/_helpers/render.d.ts +6 -1
- package/esm/_helpers/render.js +21 -1
- package/esm/carousel/index.js +3 -0
- package/esm/image/style/index.less +2 -4
- package/esm/image-preview/methods.js +2 -7
- package/esm/masking/methods.js +13 -7
- package/esm/picker/index.js +3 -2
- package/esm/picker/type.d.ts +1 -1
- package/esm/picker-view/components/cascader.d.ts +1 -0
- package/esm/picker-view/components/cascader.js +8 -1
- package/esm/picker-view/components/picker-cell.d.ts +1 -0
- package/esm/picker-view/components/picker-cell.js +6 -1
- package/esm/picker-view/index.d.ts +6 -1
- package/esm/picker-view/index.js +26 -13
- package/esm/skeleton/type.d.ts +1 -1
- package/esm/skeleton/type.js +1 -2
- package/esm/tabs/tab-cell.js +55 -29
- package/esm/tabs/type.d.ts +5 -0
- package/package.json +3 -3
- package/umd/_helpers/render.d.ts +6 -1
- package/umd/_helpers/render.js +23 -2
- package/umd/carousel/index.js +3 -0
- package/umd/image/style/index.less +2 -4
- package/umd/image-preview/methods.js +2 -7
- package/umd/masking/methods.js +12 -6
- package/umd/picker/index.js +3 -2
- package/umd/picker/type.d.ts +1 -1
- package/umd/picker-view/components/cascader.d.ts +1 -0
- package/umd/picker-view/components/cascader.js +8 -1
- package/umd/picker-view/components/picker-cell.d.ts +1 -0
- package/umd/picker-view/components/picker-cell.js +6 -1
- package/umd/picker-view/index.d.ts +6 -1
- package/umd/picker-view/index.js +25 -13
- package/umd/skeleton/type.d.ts +1 -1
- package/umd/skeleton/type.js +4 -6
- package/umd/tabs/tab-cell.js +54 -29
- package/umd/tabs/type.d.ts +5 -0
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,31 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
+
## [2.30.10](https://github.com/arco-design/arco-design-mobile/compare/@arco-design/mobile-react@2.30.9...@arco-design/mobile-react@2.30.10) (2024-03-04)
|
7
|
+
|
8
|
+
|
9
|
+
### Bug Fixes
|
10
|
+
|
11
|
+
* `Carousel` reset transforms when loop status changes ([#243](https://github.com/arco-design/arco-design-mobile/issues/243)) ([3983669](https://github.com/arco-design/arco-design-mobile/commit/398366920556ea4eb91ee87035f62443ad8db1d1))
|
12
|
+
* `Picker` onOk method adds new parameters ([#237](https://github.com/arco-design/arco-design-mobile/issues/237)) ([ef2e800](https://github.com/arco-design/arco-design-mobile/commit/ef2e8001c390174a12ca8b815e96c71436420e94))
|
13
|
+
* `Tabs` tab-cell support "updateLayout" method ([#234](https://github.com/arco-design/arco-design-mobile/issues/234)) ([1f17383](https://github.com/arco-design/arco-design-mobile/commit/1f17383592be7917a3f8392025ada60c788738f4))
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
## [2.30.9](https://github.com/arco-design/arco-design-mobile/compare/@arco-design/mobile-react@2.30.8...@arco-design/mobile-react@2.30.9) (2024-02-27)
|
20
|
+
|
21
|
+
|
22
|
+
### Bug Fixes
|
23
|
+
|
24
|
+
* export type from `Skeleton` ([#233](https://github.com/arco-design/arco-design-mobile/issues/233)) ([7514ed9](https://github.com/arco-design/arco-design-mobile/commit/7514ed9baceccaf8f46c90b046bfe06594a66a59))
|
25
|
+
* warning for repeatedly calling createRoot in react18 of masking related components ([#231](https://github.com/arco-design/arco-design-mobile/issues/231)) ([6879ad7](https://github.com/arco-design/arco-design-mobile/commit/6879ad7f6225128b87bbf82aad34ba5836d4ac18))
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
|
6
31
|
## [2.30.8](https://github.com/arco-design/arco-design-mobile/compare/@arco-design/mobile-react@2.30.7...@arco-design/mobile-react@2.30.8) (2024-01-31)
|
7
32
|
|
8
33
|
|
package/README.en-US.md
CHANGED
@@ -59,8 +59,8 @@ React & ReactDOM: **<a href="https://reactjs.org/docs/cdn-links.html" target="_b
|
|
59
59
|
React Transition Group: **<a href="https://reactcommunity.org/react-transition-group/" target="_blank">Click here</a>**
|
60
60
|
|
61
61
|
```
|
62
|
-
<link ref="stylesheet" href="https://unpkg.com/@arco-design/mobile-react@2.30.
|
63
|
-
<script src="https://unpkg.com/@arco-design/mobile-react@2.30.
|
62
|
+
<link ref="stylesheet" href="https://unpkg.com/@arco-design/mobile-react@2.30.9/dist/style.min.css">
|
63
|
+
<script src="https://unpkg.com/@arco-design/mobile-react@2.30.9/dist/index.min.js"></script>
|
64
64
|
```
|
65
65
|
|
66
66
|
## Full import
|
@@ -134,6 +134,74 @@ import { Button as ArcoButton } from '@arco-design/mobile-react';
|
|
134
134
|
import { IconAsk, IconBack } from '@arco-design/mobile-react/esm/icon';
|
135
135
|
```
|
136
136
|
|
137
|
+
|
138
|
+
## Partial import(Vite)
|
139
|
+
|
140
|
+
It is recommended to use `vite-plugin-importer` to import(**<a href="https://www.npmjs.com/package/vite-plugin-importer" target="_blank">Click here</a>** to know more from this plugin):
|
141
|
+
|
142
|
+
```
|
143
|
+
npm install vite-plugin-importer -D
|
144
|
+
```
|
145
|
+
|
146
|
+
### Import components on demand
|
147
|
+
|
148
|
+
**vite.config.ts** :
|
149
|
+
|
150
|
+
```js
|
151
|
+
import usePluginImport from 'vite-plugin-importer'
|
152
|
+
|
153
|
+
export default defineConfig({
|
154
|
+
plugins: [
|
155
|
+
usePluginImport({
|
156
|
+
libraryName: "@arco-design/mobile-react",
|
157
|
+
libraryDirectory: "esm",
|
158
|
+
style: (path) => `${path}/style`,
|
159
|
+
})
|
160
|
+
]
|
161
|
+
})
|
162
|
+
```
|
163
|
+
|
164
|
+
### Import icons on demand
|
165
|
+
|
166
|
+
**vite.config.ts** :
|
167
|
+
|
168
|
+
```js
|
169
|
+
import usePluginImport from 'vite-plugin-importer'
|
170
|
+
|
171
|
+
export default defineConfig({
|
172
|
+
plugins: [
|
173
|
+
usePluginImport({
|
174
|
+
libraryName: "@arco-design/mobile-react/esm/icon",
|
175
|
+
libraryDirectory: "",
|
176
|
+
camel2DashComponentName: false,
|
177
|
+
})
|
178
|
+
]
|
179
|
+
})
|
180
|
+
```
|
181
|
+
|
182
|
+
If both component and Icon need to be imported on demand, you just declare all and do not need any change.
|
183
|
+
|
184
|
+
**vite.config.ts** :
|
185
|
+
|
186
|
+
```js
|
187
|
+
import usePluginImport from 'vite-plugin-importer'
|
188
|
+
|
189
|
+
export default defineConfig({
|
190
|
+
plugins: [
|
191
|
+
usePluginImport({
|
192
|
+
libraryName: "@arco-design/mobile-react",
|
193
|
+
libraryDirectory: "esm",
|
194
|
+
style: (path) => `${path}/style`,
|
195
|
+
}),
|
196
|
+
usePluginImport({
|
197
|
+
libraryName: "@arco-design/mobile-react/esm/icon",
|
198
|
+
libraryDirectory: "",
|
199
|
+
camel2DashComponentName: false,
|
200
|
+
})
|
201
|
+
]
|
202
|
+
})
|
203
|
+
```
|
204
|
+
|
137
205
|
## Partial import (manual)
|
138
206
|
|
139
207
|
If you don't use babel-plugin-import, you need to import js and css files manually. The following example has the same effect as the import statement above:
|
package/README.md
CHANGED
@@ -59,8 +59,8 @@ React & ReactDOM: **<a href="https://reactjs.org/docs/cdn-links.html" target="
|
|
59
59
|
React Transition Group: **<a href="https://reactcommunity.org/react-transition-group/" target="_blank">戳这里获取</a>**
|
60
60
|
|
61
61
|
```
|
62
|
-
<link ref="stylesheet" href="https://unpkg.com/@arco-design/mobile-react@2.30.
|
63
|
-
<script src="https://unpkg.com/@arco-design/mobile-react@2.30.
|
62
|
+
<link ref="stylesheet" href="https://unpkg.com/@arco-design/mobile-react@2.30.9/dist/style.min.css">
|
63
|
+
<script src="https://unpkg.com/@arco-design/mobile-react@2.30.9/dist/index.min.js"></script>
|
64
64
|
```
|
65
65
|
|
66
66
|
## 引入全部
|
@@ -134,6 +134,73 @@ import { Button as ArcoButton } from '@arco-design/mobile-react';
|
|
134
134
|
import { IconAsk, IconBack } from '@arco-design/mobile-react/esm/icon';
|
135
135
|
```
|
136
136
|
|
137
|
+
## 部分引入(Vite)
|
138
|
+
|
139
|
+
如果是 Vite 构建工具的话,则推荐使用 `vite-plugin-importer` 引入(该插件具体使用 **<a href="https://www.npmjs.com/package/vite-plugin-importer" target="_blank">戳这里</a>** ):
|
140
|
+
|
141
|
+
```
|
142
|
+
npm install vite-plugin-importer -D
|
143
|
+
```
|
144
|
+
|
145
|
+
### 组件按需引入
|
146
|
+
|
147
|
+
**vite.config.ts** 中配置:
|
148
|
+
|
149
|
+
```js
|
150
|
+
import usePluginImport from 'vite-plugin-importer'
|
151
|
+
|
152
|
+
export default defineConfig({
|
153
|
+
plugins: [
|
154
|
+
usePluginImport({
|
155
|
+
libraryName: "@arco-design/mobile-react",
|
156
|
+
libraryDirectory: "esm",
|
157
|
+
style: (path) => `${path}/style`,
|
158
|
+
})
|
159
|
+
]
|
160
|
+
})
|
161
|
+
```
|
162
|
+
|
163
|
+
### Icon 按需引入
|
164
|
+
|
165
|
+
**vite.config.ts** 中配置:
|
166
|
+
|
167
|
+
```js
|
168
|
+
import usePluginImport from 'vite-plugin-importer'
|
169
|
+
|
170
|
+
export default defineConfig({
|
171
|
+
plugins: [
|
172
|
+
usePluginImport({
|
173
|
+
libraryName: "@arco-design/mobile-react/esm/icon",
|
174
|
+
libraryDirectory: "",
|
175
|
+
camel2DashComponentName: false,
|
176
|
+
})
|
177
|
+
]
|
178
|
+
})
|
179
|
+
```
|
180
|
+
|
181
|
+
如果同时存在 组件 和 Icon 的按需引入方式,不需要做改动,可以同时声明
|
182
|
+
|
183
|
+
**vite.config.ts** 中配置:
|
184
|
+
|
185
|
+
```js
|
186
|
+
import usePluginImport from 'vite-plugin-importer'
|
187
|
+
|
188
|
+
export default defineConfig({
|
189
|
+
plugins: [
|
190
|
+
usePluginImport({
|
191
|
+
libraryName: "@arco-design/mobile-react",
|
192
|
+
libraryDirectory: "esm",
|
193
|
+
style: (path) => `${path}/style`,
|
194
|
+
}),
|
195
|
+
usePluginImport({
|
196
|
+
libraryName: "@arco-design/mobile-react/esm/icon",
|
197
|
+
libraryDirectory: "",
|
198
|
+
camel2DashComponentName: false,
|
199
|
+
})
|
200
|
+
]
|
201
|
+
})
|
202
|
+
```
|
203
|
+
|
137
204
|
## 部分引入(手动)
|
138
205
|
|
139
206
|
如果不使用babel-plugin-import,则需要手动引入js和css文件。下方例子效果等同于上方引入语句:
|
package/cjs/_helpers/render.d.ts
CHANGED
@@ -1,12 +1,17 @@
|
|
1
1
|
import { FunctionComponent } from 'react';
|
2
2
|
import { RootType } from './react-dom';
|
3
3
|
import { GlobalContextParams } from '../context-provider';
|
4
|
+
export declare const renderRootCache: Record<string, RootType | undefined>;
|
4
5
|
export declare class ReactDOMRender {
|
5
6
|
root: RootType | undefined;
|
6
7
|
app: FunctionComponent;
|
7
8
|
container: Element | DocumentFragment;
|
8
9
|
context: GlobalContextParams | undefined;
|
9
|
-
|
10
|
+
rootCacheId: string | undefined;
|
11
|
+
constructor(app: FunctionComponent, container: Element | DocumentFragment, context?: GlobalContextParams, rootCacheId?: string, // root id in cache
|
12
|
+
root?: RootType);
|
10
13
|
render: (props: any) => void;
|
14
|
+
setRootCache: () => void;
|
15
|
+
clearRootCache: () => void;
|
11
16
|
unmount: () => void;
|
12
17
|
}
|
package/cjs/_helpers/render.js
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
4
|
|
5
5
|
exports.__esModule = true;
|
6
|
-
exports.ReactDOMRender = void 0;
|
6
|
+
exports.renderRootCache = exports.ReactDOMRender = void 0;
|
7
7
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
9
9
|
|
@@ -11,13 +11,19 @@ var _react = _interopRequireDefault(require("react"));
|
|
11
11
|
|
12
12
|
var _reactDom = require("./react-dom");
|
13
13
|
|
14
|
-
var
|
14
|
+
var renderRootCache = {};
|
15
|
+
exports.renderRootCache = renderRootCache;
|
16
|
+
|
17
|
+
var ReactDOMRender = function ReactDOMRender(app, container, context, rootCacheId, // root id in cache
|
18
|
+
root // use root in cache
|
19
|
+
) {
|
15
20
|
var _this = this;
|
16
21
|
|
17
22
|
this.root = void 0;
|
18
23
|
this.app = void 0;
|
19
24
|
this.container = void 0;
|
20
25
|
this.context = void 0;
|
26
|
+
this.rootCacheId = void 0;
|
21
27
|
|
22
28
|
this.render = function (props) {
|
23
29
|
var CustomApp = _this.app;
|
@@ -32,16 +38,32 @@ var ReactDOMRender = function ReactDOMRender(app, container, context) {
|
|
32
38
|
}
|
33
39
|
};
|
34
40
|
|
41
|
+
this.setRootCache = function () {
|
42
|
+
if (_this.rootCacheId) {
|
43
|
+
renderRootCache[_this.rootCacheId] = _this.root;
|
44
|
+
}
|
45
|
+
};
|
46
|
+
|
47
|
+
this.clearRootCache = function () {
|
48
|
+
if (_this.rootCacheId) {
|
49
|
+
delete renderRootCache[_this.rootCacheId];
|
50
|
+
}
|
51
|
+
};
|
52
|
+
|
35
53
|
this.unmount = function () {
|
36
54
|
var _this$root;
|
37
55
|
|
38
56
|
(_this$root = _this.root) == null ? void 0 : _this$root._unmount();
|
39
57
|
_this.root = undefined;
|
58
|
+
|
59
|
+
_this.clearRootCache();
|
40
60
|
};
|
41
61
|
|
42
62
|
this.app = app;
|
43
63
|
this.container = container;
|
44
64
|
this.context = context;
|
65
|
+
this.rootCacheId = rootCacheId;
|
66
|
+
this.root = root;
|
45
67
|
};
|
46
68
|
|
47
69
|
exports.ReactDOMRender = ReactDOMRender;
|
package/cjs/carousel/index.js
CHANGED
@@ -655,6 +655,9 @@ var Carousel = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
655
655
|
|
656
656
|
function getFakeChild() {
|
657
657
|
if (noLoop) {
|
658
|
+
// 循环状态从有到无时,重置 transforms
|
659
|
+
// @en reset transforms when loop status changes to false
|
660
|
+
setTransforms([]);
|
658
661
|
return;
|
659
662
|
}
|
660
663
|
|
@@ -1,11 +1,11 @@
|
|
1
|
-
@import
|
1
|
+
@import '../../../style/mixin.less';
|
2
2
|
|
3
3
|
.@{prefix}-image {
|
4
4
|
display: inline-block;
|
5
5
|
position: relative;
|
6
6
|
|
7
7
|
&.preview {
|
8
|
-
transition: all .3s ease-in-out;
|
8
|
+
transition: all 0.3s ease-in-out;
|
9
9
|
|
10
10
|
.image-container,
|
11
11
|
.image-loading-container .image-loading,
|
@@ -109,7 +109,6 @@
|
|
109
109
|
}
|
110
110
|
|
111
111
|
.image-error-container {
|
112
|
-
|
113
112
|
.image-retry-load {
|
114
113
|
position: absolute;
|
115
114
|
top: 0;
|
@@ -127,7 +126,6 @@
|
|
127
126
|
}
|
128
127
|
|
129
128
|
.image-loading-container {
|
130
|
-
|
131
129
|
.image-loading {
|
132
130
|
position: absolute;
|
133
131
|
top: 0;
|
@@ -13,9 +13,7 @@ var _render = require("../_helpers/render");
|
|
13
13
|
|
14
14
|
function open(Component) {
|
15
15
|
return function (config, context) {
|
16
|
-
var baseProps = (0, _extends2.default)({
|
17
|
-
unmountOnExit: true
|
18
|
-
}, config || {}, {
|
16
|
+
var baseProps = (0, _extends2.default)({}, config || {}, {
|
19
17
|
close: function close() {}
|
20
18
|
}); // 不同的key用不同的容器挂载
|
21
19
|
// @en Different keys are mounted in different containers
|
@@ -51,10 +49,7 @@ function open(Component) {
|
|
51
49
|
|
52
50
|
dynamicProps.onClose = function () {
|
53
51
|
baseProps.onClose && baseProps.onClose();
|
54
|
-
|
55
|
-
if (baseProps.unmountOnExit) {
|
56
|
-
(0, _mobileUtils.removeElement)(div);
|
57
|
-
}
|
52
|
+
(0, _mobileUtils.removeElement)(div);
|
58
53
|
};
|
59
54
|
|
60
55
|
dynamicProps.openIndex = -1;
|
package/cjs/masking/methods.js
CHANGED
@@ -28,14 +28,14 @@ function getOpenMethod(Component, containerId, normalize) {
|
|
28
28
|
}); // 不同的key用不同的容器挂载
|
29
29
|
|
30
30
|
var id = "_" + (containerId || 'ARCO_MASKING') + "_DIV_" + (config.key || '') + "_";
|
31
|
-
|
32
|
-
var
|
33
|
-
div = _appendElementById.child;
|
34
|
-
|
31
|
+
var existedDiv = baseProps.unmountOnExit ? null : document.getElementById(id);
|
32
|
+
var div = existedDiv || (0, _mobileUtils.appendElementById)(id, baseProps.getContainer).child;
|
35
33
|
var leaving = false;
|
36
34
|
|
37
|
-
var _ReactDOMRender = new _render.ReactDOMRender(Component, div, context),
|
38
|
-
render = _ReactDOMRender.render
|
35
|
+
var _ReactDOMRender = new _render.ReactDOMRender(Component, div, context, id, existedDiv ? _render.renderRootCache[id] : undefined),
|
36
|
+
render = _ReactDOMRender.render,
|
37
|
+
unmount = _ReactDOMRender.unmount,
|
38
|
+
setRootCache = _ReactDOMRender.setRootCache;
|
39
39
|
|
40
40
|
var dynamicProps = (0, _extends2.default)({}, baseProps, {
|
41
41
|
getContainer: function getContainer() {
|
@@ -60,11 +60,17 @@ function getOpenMethod(Component, containerId, normalize) {
|
|
60
60
|
baseProps.onClose && baseProps.onClose(scene);
|
61
61
|
|
62
62
|
if (baseProps.unmountOnExit) {
|
63
|
+
unmount();
|
63
64
|
(0, _mobileUtils.removeElement)(div);
|
64
65
|
}
|
65
66
|
};
|
66
67
|
|
67
68
|
render(dynamicProps);
|
69
|
+
|
70
|
+
if (!baseProps.unmountOnExit) {
|
71
|
+
setRootCache();
|
72
|
+
}
|
73
|
+
|
68
74
|
(0, _mobileUtils.nextTick)(function () {
|
69
75
|
if (leaving) return;
|
70
76
|
dynamicProps.visible = true;
|
package/cjs/picker/index.js
CHANGED
@@ -129,12 +129,13 @@ var Picker = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
129
129
|
|
130
130
|
(_pickerViewRef$curren6 = pickerViewRef.current) == null ? void 0 : _pickerViewRef$curren6.scrollToCurrentIndex();
|
131
131
|
(0, _mobileUtils.nextTick)(function () {
|
132
|
-
var _pickerViewRef$curren7;
|
132
|
+
var _pickerViewRef$curren7, _pickerViewRef$curren8;
|
133
133
|
|
134
134
|
var val = ((_pickerViewRef$curren7 = pickerViewRef.current) == null ? void 0 : _pickerViewRef$curren7.getAllColumnValues()) || scrollValueRef.current || [];
|
135
|
+
var selectedData = ((_pickerViewRef$curren8 = pickerViewRef.current) == null ? void 0 : _pickerViewRef$curren8.getAllColumnData()) || [];
|
135
136
|
|
136
137
|
if (onOk) {
|
137
|
-
onOk(val);
|
138
|
+
onOk(val, selectedData);
|
138
139
|
}
|
139
140
|
|
140
141
|
if (onChange) {
|
package/cjs/picker/type.d.ts
CHANGED
@@ -81,7 +81,7 @@ export interface PickerProps extends Omit<PopupProps, 'visible' | 'close' | 'chi
|
|
81
81
|
* 点击选中时执行的回调
|
82
82
|
* @en Callback when clicking on Ok
|
83
83
|
*/
|
84
|
-
onOk?: (value: ValueType[]) => void;
|
84
|
+
onOk?: (value: ValueType[], data: PickerData[]) => void;
|
85
85
|
/**
|
86
86
|
* 点击取消时执行的回调
|
87
87
|
* @en Callback when clicking to cancel
|
@@ -19,6 +19,7 @@ export interface CascaderRef {
|
|
19
19
|
getCellMovingStatus: () => PickerCellMovingStatus[];
|
20
20
|
scrollToCurrentIndex: () => void;
|
21
21
|
getAllCellsValue: () => ValueType[];
|
22
|
+
getAllCellsData: () => PickerData[];
|
22
23
|
}
|
23
24
|
declare const Cascader: React.ForwardRefExoticComponent<CascaderProps & React.RefAttributes<CascaderRef>>;
|
24
25
|
export default Cascader;
|
@@ -37,7 +37,8 @@ var Cascader = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
37
37
|
return {
|
38
38
|
getCellMovingStatus: getCellMovingStatus,
|
39
39
|
scrollToCurrentIndex: scrollToCurrentIndex,
|
40
|
-
getAllCellsValue: getAllCellsValue
|
40
|
+
getAllCellsValue: getAllCellsValue,
|
41
|
+
getAllCellsData: getAllCellsData
|
41
42
|
};
|
42
43
|
});
|
43
44
|
|
@@ -59,6 +60,12 @@ var Cascader = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
59
60
|
});
|
60
61
|
}
|
61
62
|
|
63
|
+
function getAllCellsData() {
|
64
|
+
return pickerCellsRef.current.map(function (cell) {
|
65
|
+
return cell.getCurrentCellData();
|
66
|
+
});
|
67
|
+
}
|
68
|
+
|
62
69
|
function _onValueChange(value, index, newData) {
|
63
70
|
var children = (0, _mobileUtils.arrayTreeFilter)(data, function (item, level) {
|
64
71
|
return level <= index && item.value === value[level];
|
@@ -22,6 +22,7 @@ export interface PickerCellRef {
|
|
22
22
|
movingStatus: PickerCellMovingStatus;
|
23
23
|
scrollToCurrentIndex: () => void;
|
24
24
|
getCurrentCellValue: () => ValueType;
|
25
|
+
getCurrentCellData: () => PickerData;
|
25
26
|
}
|
26
27
|
declare const PickerCell: React.ForwardRefExoticComponent<PickerCellProps & React.RefAttributes<PickerCellRef>>;
|
27
28
|
export default PickerCell;
|
@@ -304,6 +304,10 @@ var PickerCell = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
304
304
|
return (_data$currentIndex = data[currentIndex]) == null ? void 0 : _data$currentIndex.value;
|
305
305
|
}
|
306
306
|
|
307
|
+
function getCurrentCellData() {
|
308
|
+
return data[currentIndex];
|
309
|
+
}
|
310
|
+
|
307
311
|
function _clearTimer() {
|
308
312
|
timeRef.current && clearTimeout(timeRef.current);
|
309
313
|
timeRef.current = null;
|
@@ -369,7 +373,8 @@ var PickerCell = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
369
373
|
return {
|
370
374
|
movingStatus: movingStatusRef.current,
|
371
375
|
scrollToCurrentIndex: scrollToCurrentIndex,
|
372
|
-
getCurrentCellValue: getCurrentCellValue
|
376
|
+
getCurrentCellValue: getCurrentCellValue,
|
377
|
+
getCurrentCellData: getCurrentCellData
|
373
378
|
};
|
374
379
|
});
|
375
380
|
return !hideEmptyCols || data && data.length ? /*#__PURE__*/_react.default.createElement("div", {
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
2
2
|
import MultiPicker from '../picker-view/components/multi-picker';
|
3
3
|
import PickerCell from '../picker-view/components/picker-cell';
|
4
4
|
import Cascader from '../picker-view/components/cascader';
|
5
|
-
import { PickerViewProps, ValueType, PickerCellMovingStatus } from './type';
|
5
|
+
import { PickerViewProps, ValueType, PickerData, PickerCellMovingStatus } from './type';
|
6
6
|
export * from './type';
|
7
7
|
export { MultiPicker, PickerCell, Cascader };
|
8
8
|
export interface PickerViewRef {
|
@@ -41,6 +41,11 @@ export interface PickerViewRef {
|
|
41
41
|
* @en Jump directly to the current most recent line (will break scrolling when called)
|
42
42
|
*/
|
43
43
|
scrollToCurrentIndex: () => void;
|
44
|
+
/**
|
45
|
+
* 获取所有列的 data
|
46
|
+
* @en Get all column data
|
47
|
+
*/
|
48
|
+
getAllColumnData: () => PickerData[];
|
44
49
|
}
|
45
50
|
declare const _default: React.ForwardRefExoticComponent<PickerViewProps & React.RefAttributes<PickerViewRef>> & {
|
46
51
|
displayName?: string | undefined;
|
package/cjs/picker-view/index.js
CHANGED
@@ -45,6 +45,14 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
45
45
|
|
46
46
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
47
47
|
|
48
|
+
var isArray = function isArray(dt) {
|
49
|
+
return dt ? Array.isArray(dt[0]) : false;
|
50
|
+
};
|
51
|
+
|
52
|
+
var isStrOrNum = function isStrOrNum(dt) {
|
53
|
+
return typeof dt[0][0] === 'string' || typeof dt[0][0] === 'number';
|
54
|
+
};
|
55
|
+
|
48
56
|
var PickerView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
49
57
|
var _props$className = props.className,
|
50
58
|
className = _props$className === void 0 ? '' : _props$className,
|
@@ -94,14 +102,6 @@ var PickerView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
94
102
|
var innerData = (0, _react.useMemo)(function () {
|
95
103
|
var newData;
|
96
104
|
|
97
|
-
var isArray = function isArray(dt) {
|
98
|
-
return dt ? Array.isArray(dt[0]) : false;
|
99
|
-
};
|
100
|
-
|
101
|
-
var isStrOrNum = function isStrOrNum(dt) {
|
102
|
-
return typeof dt[0][0] === 'string' || typeof dt[0][0] === 'number';
|
103
|
-
};
|
104
|
-
|
105
105
|
if (isArray(data)) {
|
106
106
|
if (isStrOrNum(data)) {
|
107
107
|
newData = data.map(function (item) {
|
@@ -135,6 +135,17 @@ var PickerView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
135
135
|
});
|
136
136
|
};
|
137
137
|
|
138
|
+
var getAllColumnData = function getAllColumnData() {
|
139
|
+
var _cascaderRef$current2;
|
140
|
+
|
141
|
+
var curValues = cascade ? ((_cascaderRef$current2 = cascaderRef.current) == null ? void 0 : _cascaderRef$current2.getAllCellsData()) || [] : pickerCellsRef.current.map(function (cell) {
|
142
|
+
return cell.getCurrentCellData();
|
143
|
+
});
|
144
|
+
return curValues.filter(function (v) {
|
145
|
+
return v !== undefined;
|
146
|
+
});
|
147
|
+
};
|
148
|
+
|
138
149
|
function getColumnValue(index) {
|
139
150
|
if (index === void 0) {
|
140
151
|
index = 0;
|
@@ -144,18 +155,18 @@ var PickerView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
144
155
|
}
|
145
156
|
|
146
157
|
function getCellMovingStatus() {
|
147
|
-
var _cascaderRef$
|
158
|
+
var _cascaderRef$current3;
|
148
159
|
|
149
|
-
return cascade ? ((_cascaderRef$
|
160
|
+
return cascade ? ((_cascaderRef$current3 = cascaderRef.current) == null ? void 0 : _cascaderRef$current3.getCellMovingStatus()) || [] : pickerCellsRef.current.map(function (cell) {
|
150
161
|
return cell.movingStatus;
|
151
162
|
});
|
152
163
|
}
|
153
164
|
|
154
165
|
function scrollToCurrentIndex() {
|
155
166
|
if (cascade) {
|
156
|
-
var _cascaderRef$
|
167
|
+
var _cascaderRef$current4;
|
157
168
|
|
158
|
-
(_cascaderRef$
|
169
|
+
(_cascaderRef$current4 = cascaderRef.current) == null ? void 0 : _cascaderRef$current4.scrollToCurrentIndex();
|
159
170
|
return;
|
160
171
|
}
|
161
172
|
|
@@ -172,7 +183,8 @@ var PickerView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
172
183
|
getColumnValue: getColumnValue,
|
173
184
|
updateLayout: updateLayout,
|
174
185
|
resetValue: resetValue,
|
175
|
-
scrollToCurrentIndex: scrollToCurrentIndex
|
186
|
+
scrollToCurrentIndex: scrollToCurrentIndex,
|
187
|
+
getAllColumnData: getAllColumnData
|
176
188
|
};
|
177
189
|
});
|
178
190
|
|
package/cjs/skeleton/type.d.ts
CHANGED