antd-mobile 5.11.0 → 5.11.1
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/2x/cjs/components/cascade-picker/cascade-picker-utils.d.ts +2 -2
- package/2x/cjs/components/cascade-picker/cascade-picker-utils.js +37 -16
- package/2x/cjs/components/cascade-picker/cascade-picker.js +2 -7
- package/2x/cjs/components/cascade-picker-view/cascade-picker-view.js +2 -7
- package/2x/cjs/components/swiper/index.d.ts +16 -1
- package/2x/cjs/components/swiper/swiper.d.ts +16 -1
- package/2x/es/components/cascade-picker/cascade-picker-utils.d.ts +2 -2
- package/2x/es/components/cascade-picker/cascade-picker-utils.js +35 -15
- package/2x/es/components/cascade-picker/cascade-picker.js +3 -7
- package/2x/es/components/cascade-picker-view/cascade-picker-view.js +3 -7
- package/2x/es/components/swiper/index.d.ts +16 -1
- package/2x/es/components/swiper/swiper.d.ts +16 -1
- package/2x/package.json +1 -1
- package/bundle/antd-mobile.cjs.js +34 -47
- package/bundle/antd-mobile.es.js +34 -47
- package/cjs/components/cascade-picker/cascade-picker-utils.d.ts +2 -2
- package/cjs/components/cascade-picker/cascade-picker-utils.js +37 -16
- package/cjs/components/cascade-picker/cascade-picker.js +2 -7
- package/cjs/components/cascade-picker-view/cascade-picker-view.js +2 -7
- package/cjs/components/swiper/index.d.ts +16 -1
- package/cjs/components/swiper/swiper.d.ts +16 -1
- package/es/components/cascade-picker/cascade-picker-utils.d.ts +2 -2
- package/es/components/cascade-picker/cascade-picker-utils.js +35 -15
- package/es/components/cascade-picker/cascade-picker.js +3 -7
- package/es/components/cascade-picker-view/cascade-picker-view.js +3 -7
- package/es/components/swiper/index.d.ts +16 -1
- package/es/components/swiper/swiper.d.ts +16 -1
- package/package.json +1 -1
- package/umd/antd-mobile.js +1 -1
- package/2x/cjs/components/cascade-picker/use-cascade-picker-options.d.ts +0 -5
- package/2x/cjs/components/cascade-picker/use-cascade-picker-options.js +0 -40
- package/2x/es/components/cascade-picker/use-cascade-picker-options.d.ts +0 -5
- package/2x/es/components/cascade-picker/use-cascade-picker-options.js +0 -32
- package/cjs/components/cascade-picker/use-cascade-picker-options.d.ts +0 -5
- package/cjs/components/cascade-picker/use-cascade-picker-options.js +0 -40
- package/es/components/cascade-picker/use-cascade-picker-options.d.ts +0 -5
- package/es/components/cascade-picker/use-cascade-picker-options.js +0 -32
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { PickerColumn } from '../picker-view';
|
|
1
|
+
import { PickerColumn, PickerValue } from '../picker-view';
|
|
2
2
|
import { CascadePickerOption } from './cascade-picker';
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function useColumnsFn(options: CascadePickerOption[]): (selected: PickerValue[]) => PickerColumn[];
|
|
@@ -3,28 +3,49 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.useColumnsFn = useColumnsFn;
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
const columns = [];
|
|
10
|
-
columns.push(options.map(option => ({
|
|
11
|
-
label: option.label,
|
|
12
|
-
value: option.value
|
|
13
|
-
})));
|
|
8
|
+
var _react = require("react");
|
|
14
9
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
function useColumnsFn(options) {
|
|
11
|
+
const depth = (0, _react.useMemo)(() => {
|
|
12
|
+
let depth = 0;
|
|
18
13
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
function traverse(options, currentDepth) {
|
|
15
|
+
if (currentDepth > depth) depth = currentDepth;
|
|
16
|
+
const nextDepth = currentDepth + 1;
|
|
17
|
+
options.forEach(option => {
|
|
18
|
+
if (option.children) {
|
|
19
|
+
traverse(option.children, nextDepth);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
traverse(options, 1);
|
|
25
|
+
return depth;
|
|
26
|
+
}, [options]);
|
|
27
|
+
return selected => {
|
|
28
|
+
const columns = [];
|
|
29
|
+
let currentOptions = options;
|
|
30
|
+
let i = 0;
|
|
31
|
+
|
|
32
|
+
while (true) {
|
|
33
|
+
columns.push(currentOptions.map(option => ({
|
|
23
34
|
label: option.label,
|
|
24
35
|
value: option.value
|
|
25
36
|
})));
|
|
37
|
+
const x = selected[i];
|
|
38
|
+
const targetOptions = currentOptions.find(option => option.value === x);
|
|
39
|
+
if (!targetOptions || !targetOptions.children) break;
|
|
40
|
+
currentOptions = targetOptions.children;
|
|
41
|
+
i++;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
while (i < depth - 1) {
|
|
45
|
+
columns.push([]);
|
|
46
|
+
i++;
|
|
26
47
|
}
|
|
27
|
-
}
|
|
28
48
|
|
|
29
|
-
|
|
49
|
+
return columns;
|
|
50
|
+
};
|
|
30
51
|
}
|
|
@@ -11,8 +11,6 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
11
11
|
|
|
12
12
|
var _picker = _interopRequireDefault(require("../picker"));
|
|
13
13
|
|
|
14
|
-
var _useCascadePickerOptions = require("./use-cascade-picker-options");
|
|
15
|
-
|
|
16
14
|
var _cascadePickerUtils = require("./cascade-picker-utils");
|
|
17
15
|
|
|
18
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -22,12 +20,9 @@ const CascadePicker = props => {
|
|
|
22
20
|
options
|
|
23
21
|
} = props,
|
|
24
22
|
pickerProps = (0, _tslib.__rest)(props, ["options"]);
|
|
25
|
-
const
|
|
26
|
-
depth,
|
|
27
|
-
subOptionsRecord
|
|
28
|
-
} = (0, _useCascadePickerOptions.useCascadePickerOptions)(options);
|
|
23
|
+
const columnsFn = (0, _cascadePickerUtils.useColumnsFn)(options);
|
|
29
24
|
return _react.default.createElement(_picker.default, Object.assign({}, pickerProps, {
|
|
30
|
-
columns:
|
|
25
|
+
columns: columnsFn
|
|
31
26
|
}));
|
|
32
27
|
};
|
|
33
28
|
|
|
@@ -11,8 +11,6 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
11
11
|
|
|
12
12
|
var _pickerView = _interopRequireDefault(require("../picker-view"));
|
|
13
13
|
|
|
14
|
-
var _useCascadePickerOptions = require("../cascade-picker/use-cascade-picker-options");
|
|
15
|
-
|
|
16
14
|
var _cascadePickerUtils = require("../cascade-picker/cascade-picker-utils");
|
|
17
15
|
|
|
18
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -22,12 +20,9 @@ const CascadePickerView = props => {
|
|
|
22
20
|
options
|
|
23
21
|
} = props,
|
|
24
22
|
pickerProps = (0, _tslib.__rest)(props, ["options"]);
|
|
25
|
-
const
|
|
26
|
-
depth,
|
|
27
|
-
subOptionsRecord
|
|
28
|
-
} = (0, _useCascadePickerOptions.useCascadePickerOptions)(options);
|
|
23
|
+
const columnsFn = (0, _cascadePickerUtils.useColumnsFn)(options);
|
|
29
24
|
return _react.default.createElement(_pickerView.default, Object.assign({}, pickerProps, {
|
|
30
|
-
columns:
|
|
25
|
+
columns: columnsFn
|
|
31
26
|
}));
|
|
32
27
|
};
|
|
33
28
|
|
|
@@ -1,7 +1,22 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import './swiper.less';
|
|
3
3
|
export type { SwiperProps, SwiperRef } from './swiper';
|
|
4
|
-
declare const _default: import("react").ForwardRefExoticComponent<
|
|
4
|
+
declare const _default: import("react").ForwardRefExoticComponent<{
|
|
5
|
+
defaultIndex?: number | undefined;
|
|
6
|
+
allowTouchMove?: boolean | undefined;
|
|
7
|
+
autoplay?: boolean | undefined;
|
|
8
|
+
autoplayInterval?: number | undefined;
|
|
9
|
+
loop?: boolean | undefined;
|
|
10
|
+
direction?: "vertical" | "horizontal" | undefined;
|
|
11
|
+
onIndexChange?: ((index: number) => void) | undefined;
|
|
12
|
+
indicatorProps?: Pick<import("../page-indicator").PageIndicatorProps, "style" | "className" | "color"> | undefined;
|
|
13
|
+
indicator?: ((total: number, current: number) => import("react").ReactNode) | undefined;
|
|
14
|
+
slideSize?: number | undefined;
|
|
15
|
+
trackOffset?: number | undefined;
|
|
16
|
+
stuckAtBoundary?: boolean | undefined;
|
|
17
|
+
rubberband?: boolean | undefined;
|
|
18
|
+
children?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>[] | undefined;
|
|
19
|
+
} & import("../../utils/native-props").NativeProps<"--border-radius" | "--width" | "--height" | "--track-padding"> & import("react").RefAttributes<import("./swiper").SwiperRef>> & {
|
|
5
20
|
Item: import("react").FC<{
|
|
6
21
|
onClick?: ((e: import("react").MouseEvent<HTMLDivElement, MouseEvent>) => void) | undefined;
|
|
7
22
|
children?: import("react").ReactNode;
|
|
@@ -22,4 +22,19 @@ export declare type SwiperProps = {
|
|
|
22
22
|
rubberband?: boolean;
|
|
23
23
|
children?: ReactElement | ReactElement[];
|
|
24
24
|
} & NativeProps<'--height' | '--width' | '--border-radius' | '--track-padding'>;
|
|
25
|
-
export declare const Swiper: React.ForwardRefExoticComponent<
|
|
25
|
+
export declare const Swiper: React.ForwardRefExoticComponent<{
|
|
26
|
+
defaultIndex?: number | undefined;
|
|
27
|
+
allowTouchMove?: boolean | undefined;
|
|
28
|
+
autoplay?: boolean | undefined;
|
|
29
|
+
autoplayInterval?: number | undefined;
|
|
30
|
+
loop?: boolean | undefined;
|
|
31
|
+
direction?: "vertical" | "horizontal" | undefined;
|
|
32
|
+
onIndexChange?: ((index: number) => void) | undefined;
|
|
33
|
+
indicatorProps?: Pick<PageIndicatorProps, "style" | "className" | "color"> | undefined;
|
|
34
|
+
indicator?: ((total: number, current: number) => ReactNode) | undefined;
|
|
35
|
+
slideSize?: number | undefined;
|
|
36
|
+
trackOffset?: number | undefined;
|
|
37
|
+
stuckAtBoundary?: boolean | undefined;
|
|
38
|
+
rubberband?: boolean | undefined;
|
|
39
|
+
children?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactElement<any, string | React.JSXElementConstructor<any>>[] | undefined;
|
|
40
|
+
} & NativeProps<"--border-radius" | "--width" | "--height" | "--track-padding"> & React.RefAttributes<SwiperRef>>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { PickerColumn } from '../picker-view';
|
|
1
|
+
import { PickerColumn, PickerValue } from '../picker-view';
|
|
2
2
|
import { CascadePickerOption } from './cascade-picker';
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function useColumnsFn(options: CascadePickerOption[]): (selected: PickerValue[]) => PickerColumn[];
|
|
@@ -1,23 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
value: option.value
|
|
6
|
-
})));
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
export function useColumnsFn(options) {
|
|
3
|
+
const depth = useMemo(() => {
|
|
4
|
+
let depth = 0;
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
function traverse(options, currentDepth) {
|
|
7
|
+
if (currentDepth > depth) depth = currentDepth;
|
|
8
|
+
const nextDepth = currentDepth + 1;
|
|
9
|
+
options.forEach(option => {
|
|
10
|
+
if (option.children) {
|
|
11
|
+
traverse(option.children, nextDepth);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
}
|
|
11
15
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
traverse(options, 1);
|
|
17
|
+
return depth;
|
|
18
|
+
}, [options]);
|
|
19
|
+
return selected => {
|
|
20
|
+
const columns = [];
|
|
21
|
+
let currentOptions = options;
|
|
22
|
+
let i = 0;
|
|
23
|
+
|
|
24
|
+
while (true) {
|
|
25
|
+
columns.push(currentOptions.map(option => ({
|
|
16
26
|
label: option.label,
|
|
17
27
|
value: option.value
|
|
18
28
|
})));
|
|
29
|
+
const x = selected[i];
|
|
30
|
+
const targetOptions = currentOptions.find(option => option.value === x);
|
|
31
|
+
if (!targetOptions || !targetOptions.children) break;
|
|
32
|
+
currentOptions = targetOptions.children;
|
|
33
|
+
i++;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
while (i < depth - 1) {
|
|
37
|
+
columns.push([]);
|
|
38
|
+
i++;
|
|
19
39
|
}
|
|
20
|
-
}
|
|
21
40
|
|
|
22
|
-
|
|
41
|
+
return columns;
|
|
42
|
+
};
|
|
23
43
|
}
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import Picker from '../picker';
|
|
4
|
-
import {
|
|
5
|
-
import { generateCascadePickerColumns } from './cascade-picker-utils';
|
|
4
|
+
import { useColumnsFn } from './cascade-picker-utils';
|
|
6
5
|
export const CascadePicker = props => {
|
|
7
6
|
const {
|
|
8
7
|
options
|
|
9
8
|
} = props,
|
|
10
9
|
pickerProps = __rest(props, ["options"]);
|
|
11
10
|
|
|
12
|
-
const
|
|
13
|
-
depth,
|
|
14
|
-
subOptionsRecord
|
|
15
|
-
} = useCascadePickerOptions(options);
|
|
11
|
+
const columnsFn = useColumnsFn(options);
|
|
16
12
|
return React.createElement(Picker, Object.assign({}, pickerProps, {
|
|
17
|
-
columns:
|
|
13
|
+
columns: columnsFn
|
|
18
14
|
}));
|
|
19
15
|
};
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import PickerView from '../picker-view';
|
|
4
|
-
import {
|
|
5
|
-
import { generateCascadePickerColumns } from '../cascade-picker/cascade-picker-utils';
|
|
4
|
+
import { useColumnsFn } from '../cascade-picker/cascade-picker-utils';
|
|
6
5
|
export const CascadePickerView = props => {
|
|
7
6
|
const {
|
|
8
7
|
options
|
|
9
8
|
} = props,
|
|
10
9
|
pickerProps = __rest(props, ["options"]);
|
|
11
10
|
|
|
12
|
-
const
|
|
13
|
-
depth,
|
|
14
|
-
subOptionsRecord
|
|
15
|
-
} = useCascadePickerOptions(options);
|
|
11
|
+
const columnsFn = useColumnsFn(options);
|
|
16
12
|
return React.createElement(PickerView, Object.assign({}, pickerProps, {
|
|
17
|
-
columns:
|
|
13
|
+
columns: columnsFn
|
|
18
14
|
}));
|
|
19
15
|
};
|
|
@@ -1,7 +1,22 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import './swiper.less';
|
|
3
3
|
export type { SwiperProps, SwiperRef } from './swiper';
|
|
4
|
-
declare const _default: import("react").ForwardRefExoticComponent<
|
|
4
|
+
declare const _default: import("react").ForwardRefExoticComponent<{
|
|
5
|
+
defaultIndex?: number | undefined;
|
|
6
|
+
allowTouchMove?: boolean | undefined;
|
|
7
|
+
autoplay?: boolean | undefined;
|
|
8
|
+
autoplayInterval?: number | undefined;
|
|
9
|
+
loop?: boolean | undefined;
|
|
10
|
+
direction?: "vertical" | "horizontal" | undefined;
|
|
11
|
+
onIndexChange?: ((index: number) => void) | undefined;
|
|
12
|
+
indicatorProps?: Pick<import("../page-indicator").PageIndicatorProps, "style" | "className" | "color"> | undefined;
|
|
13
|
+
indicator?: ((total: number, current: number) => import("react").ReactNode) | undefined;
|
|
14
|
+
slideSize?: number | undefined;
|
|
15
|
+
trackOffset?: number | undefined;
|
|
16
|
+
stuckAtBoundary?: boolean | undefined;
|
|
17
|
+
rubberband?: boolean | undefined;
|
|
18
|
+
children?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>[] | undefined;
|
|
19
|
+
} & import("../../utils/native-props").NativeProps<"--border-radius" | "--width" | "--height" | "--track-padding"> & import("react").RefAttributes<import("./swiper").SwiperRef>> & {
|
|
5
20
|
Item: import("react").FC<{
|
|
6
21
|
onClick?: ((e: import("react").MouseEvent<HTMLDivElement, MouseEvent>) => void) | undefined;
|
|
7
22
|
children?: import("react").ReactNode;
|
|
@@ -22,4 +22,19 @@ export declare type SwiperProps = {
|
|
|
22
22
|
rubberband?: boolean;
|
|
23
23
|
children?: ReactElement | ReactElement[];
|
|
24
24
|
} & NativeProps<'--height' | '--width' | '--border-radius' | '--track-padding'>;
|
|
25
|
-
export declare const Swiper: React.ForwardRefExoticComponent<
|
|
25
|
+
export declare const Swiper: React.ForwardRefExoticComponent<{
|
|
26
|
+
defaultIndex?: number | undefined;
|
|
27
|
+
allowTouchMove?: boolean | undefined;
|
|
28
|
+
autoplay?: boolean | undefined;
|
|
29
|
+
autoplayInterval?: number | undefined;
|
|
30
|
+
loop?: boolean | undefined;
|
|
31
|
+
direction?: "vertical" | "horizontal" | undefined;
|
|
32
|
+
onIndexChange?: ((index: number) => void) | undefined;
|
|
33
|
+
indicatorProps?: Pick<PageIndicatorProps, "style" | "className" | "color"> | undefined;
|
|
34
|
+
indicator?: ((total: number, current: number) => ReactNode) | undefined;
|
|
35
|
+
slideSize?: number | undefined;
|
|
36
|
+
trackOffset?: number | undefined;
|
|
37
|
+
stuckAtBoundary?: boolean | undefined;
|
|
38
|
+
rubberband?: boolean | undefined;
|
|
39
|
+
children?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactElement<any, string | React.JSXElementConstructor<any>>[] | undefined;
|
|
40
|
+
} & NativeProps<"--border-radius" | "--width" | "--height" | "--track-padding"> & React.RefAttributes<SwiperRef>>;
|
package/2x/package.json
CHANGED
|
@@ -10016,62 +10016,52 @@ function prompt$3(props) {
|
|
|
10016
10016
|
var Picker = attachPropertiesToComponent(Picker$1, {
|
|
10017
10017
|
prompt: prompt$3
|
|
10018
10018
|
});
|
|
10019
|
-
function
|
|
10020
|
-
|
|
10021
|
-
let
|
|
10022
|
-
|
|
10023
|
-
|
|
10024
|
-
|
|
10025
|
-
return;
|
|
10026
|
-
}
|
|
10027
|
-
subOptionsRecord[option.value] = option.children;
|
|
10019
|
+
function useColumnsFn(options) {
|
|
10020
|
+
const depth = React$1.useMemo(() => {
|
|
10021
|
+
let depth2 = 0;
|
|
10022
|
+
function traverse(options2, currentDepth) {
|
|
10023
|
+
if (currentDepth > depth2)
|
|
10024
|
+
depth2 = currentDepth;
|
|
10028
10025
|
const nextDepth = currentDepth + 1;
|
|
10029
|
-
|
|
10030
|
-
|
|
10031
|
-
|
|
10032
|
-
|
|
10033
|
-
traverse(option2, nextDepth);
|
|
10026
|
+
options2.forEach((option) => {
|
|
10027
|
+
if (option.children) {
|
|
10028
|
+
traverse(option.children, nextDepth);
|
|
10029
|
+
}
|
|
10034
10030
|
});
|
|
10035
10031
|
}
|
|
10036
|
-
options
|
|
10037
|
-
|
|
10038
|
-
});
|
|
10039
|
-
return {
|
|
10040
|
-
depth,
|
|
10041
|
-
subOptionsRecord
|
|
10042
|
-
};
|
|
10032
|
+
traverse(options, 1);
|
|
10033
|
+
return depth2;
|
|
10043
10034
|
}, [options]);
|
|
10044
|
-
|
|
10045
|
-
|
|
10046
|
-
|
|
10047
|
-
|
|
10048
|
-
|
|
10049
|
-
|
|
10050
|
-
})));
|
|
10051
|
-
for (let i = 0; i < depth - 1; i++) {
|
|
10052
|
-
const x = value[i];
|
|
10053
|
-
const subOptions = subOptionsRecord[x];
|
|
10054
|
-
if (!subOptions) {
|
|
10055
|
-
columns.push([]);
|
|
10056
|
-
} else {
|
|
10057
|
-
columns.push(subOptions.map((option) => ({
|
|
10035
|
+
return (selected) => {
|
|
10036
|
+
const columns = [];
|
|
10037
|
+
let currentOptions = options;
|
|
10038
|
+
let i = 0;
|
|
10039
|
+
while (true) {
|
|
10040
|
+
columns.push(currentOptions.map((option) => ({
|
|
10058
10041
|
label: option.label,
|
|
10059
10042
|
value: option.value
|
|
10060
10043
|
})));
|
|
10044
|
+
const x = selected[i];
|
|
10045
|
+
const targetOptions = currentOptions.find((option) => option.value === x);
|
|
10046
|
+
if (!targetOptions || !targetOptions.children)
|
|
10047
|
+
break;
|
|
10048
|
+
currentOptions = targetOptions.children;
|
|
10049
|
+
i++;
|
|
10061
10050
|
}
|
|
10062
|
-
|
|
10063
|
-
|
|
10051
|
+
while (i < depth - 1) {
|
|
10052
|
+
columns.push([]);
|
|
10053
|
+
i++;
|
|
10054
|
+
}
|
|
10055
|
+
return columns;
|
|
10056
|
+
};
|
|
10064
10057
|
}
|
|
10065
10058
|
const CascadePicker = (props) => {
|
|
10066
10059
|
const {
|
|
10067
10060
|
options
|
|
10068
10061
|
} = props, pickerProps = tslib.__rest(props, ["options"]);
|
|
10069
|
-
const
|
|
10070
|
-
depth,
|
|
10071
|
-
subOptionsRecord
|
|
10072
|
-
} = useCascadePickerOptions(options);
|
|
10062
|
+
const columnsFn = useColumnsFn(options);
|
|
10073
10063
|
return React__default["default"].createElement(Picker, Object.assign({}, pickerProps, {
|
|
10074
|
-
columns:
|
|
10064
|
+
columns: columnsFn
|
|
10075
10065
|
}));
|
|
10076
10066
|
};
|
|
10077
10067
|
function prompt$2(props) {
|
|
@@ -10111,12 +10101,9 @@ const CascadePickerView = (props) => {
|
|
|
10111
10101
|
const {
|
|
10112
10102
|
options
|
|
10113
10103
|
} = props, pickerProps = tslib.__rest(props, ["options"]);
|
|
10114
|
-
const
|
|
10115
|
-
depth,
|
|
10116
|
-
subOptionsRecord
|
|
10117
|
-
} = useCascadePickerOptions(options);
|
|
10104
|
+
const columnsFn = useColumnsFn(options);
|
|
10118
10105
|
return React__default["default"].createElement(PickerView, Object.assign({}, pickerProps, {
|
|
10119
|
-
columns:
|
|
10106
|
+
columns: columnsFn
|
|
10120
10107
|
}));
|
|
10121
10108
|
};
|
|
10122
10109
|
var cascaderView = "";
|
package/bundle/antd-mobile.es.js
CHANGED
|
@@ -10006,62 +10006,52 @@ function prompt$3(props) {
|
|
|
10006
10006
|
var Picker = attachPropertiesToComponent(Picker$1, {
|
|
10007
10007
|
prompt: prompt$3
|
|
10008
10008
|
});
|
|
10009
|
-
function
|
|
10010
|
-
|
|
10011
|
-
let
|
|
10012
|
-
|
|
10013
|
-
|
|
10014
|
-
|
|
10015
|
-
return;
|
|
10016
|
-
}
|
|
10017
|
-
subOptionsRecord[option.value] = option.children;
|
|
10009
|
+
function useColumnsFn(options) {
|
|
10010
|
+
const depth = useMemo(() => {
|
|
10011
|
+
let depth2 = 0;
|
|
10012
|
+
function traverse(options2, currentDepth) {
|
|
10013
|
+
if (currentDepth > depth2)
|
|
10014
|
+
depth2 = currentDepth;
|
|
10018
10015
|
const nextDepth = currentDepth + 1;
|
|
10019
|
-
|
|
10020
|
-
|
|
10021
|
-
|
|
10022
|
-
|
|
10023
|
-
traverse(option2, nextDepth);
|
|
10016
|
+
options2.forEach((option) => {
|
|
10017
|
+
if (option.children) {
|
|
10018
|
+
traverse(option.children, nextDepth);
|
|
10019
|
+
}
|
|
10024
10020
|
});
|
|
10025
10021
|
}
|
|
10026
|
-
options
|
|
10027
|
-
|
|
10028
|
-
});
|
|
10029
|
-
return {
|
|
10030
|
-
depth,
|
|
10031
|
-
subOptionsRecord
|
|
10032
|
-
};
|
|
10022
|
+
traverse(options, 1);
|
|
10023
|
+
return depth2;
|
|
10033
10024
|
}, [options]);
|
|
10034
|
-
|
|
10035
|
-
|
|
10036
|
-
|
|
10037
|
-
|
|
10038
|
-
|
|
10039
|
-
|
|
10040
|
-
})));
|
|
10041
|
-
for (let i = 0; i < depth - 1; i++) {
|
|
10042
|
-
const x = value[i];
|
|
10043
|
-
const subOptions = subOptionsRecord[x];
|
|
10044
|
-
if (!subOptions) {
|
|
10045
|
-
columns.push([]);
|
|
10046
|
-
} else {
|
|
10047
|
-
columns.push(subOptions.map((option) => ({
|
|
10025
|
+
return (selected) => {
|
|
10026
|
+
const columns = [];
|
|
10027
|
+
let currentOptions = options;
|
|
10028
|
+
let i = 0;
|
|
10029
|
+
while (true) {
|
|
10030
|
+
columns.push(currentOptions.map((option) => ({
|
|
10048
10031
|
label: option.label,
|
|
10049
10032
|
value: option.value
|
|
10050
10033
|
})));
|
|
10034
|
+
const x = selected[i];
|
|
10035
|
+
const targetOptions = currentOptions.find((option) => option.value === x);
|
|
10036
|
+
if (!targetOptions || !targetOptions.children)
|
|
10037
|
+
break;
|
|
10038
|
+
currentOptions = targetOptions.children;
|
|
10039
|
+
i++;
|
|
10051
10040
|
}
|
|
10052
|
-
|
|
10053
|
-
|
|
10041
|
+
while (i < depth - 1) {
|
|
10042
|
+
columns.push([]);
|
|
10043
|
+
i++;
|
|
10044
|
+
}
|
|
10045
|
+
return columns;
|
|
10046
|
+
};
|
|
10054
10047
|
}
|
|
10055
10048
|
const CascadePicker = (props) => {
|
|
10056
10049
|
const {
|
|
10057
10050
|
options
|
|
10058
10051
|
} = props, pickerProps = __rest(props, ["options"]);
|
|
10059
|
-
const
|
|
10060
|
-
depth,
|
|
10061
|
-
subOptionsRecord
|
|
10062
|
-
} = useCascadePickerOptions(options);
|
|
10052
|
+
const columnsFn = useColumnsFn(options);
|
|
10063
10053
|
return React$1.createElement(Picker, Object.assign({}, pickerProps, {
|
|
10064
|
-
columns:
|
|
10054
|
+
columns: columnsFn
|
|
10065
10055
|
}));
|
|
10066
10056
|
};
|
|
10067
10057
|
function prompt$2(props) {
|
|
@@ -10101,12 +10091,9 @@ const CascadePickerView = (props) => {
|
|
|
10101
10091
|
const {
|
|
10102
10092
|
options
|
|
10103
10093
|
} = props, pickerProps = __rest(props, ["options"]);
|
|
10104
|
-
const
|
|
10105
|
-
depth,
|
|
10106
|
-
subOptionsRecord
|
|
10107
|
-
} = useCascadePickerOptions(options);
|
|
10094
|
+
const columnsFn = useColumnsFn(options);
|
|
10108
10095
|
return React$1.createElement(PickerView, Object.assign({}, pickerProps, {
|
|
10109
|
-
columns:
|
|
10096
|
+
columns: columnsFn
|
|
10110
10097
|
}));
|
|
10111
10098
|
};
|
|
10112
10099
|
var cascaderView = "";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { PickerColumn } from '../picker-view';
|
|
1
|
+
import { PickerColumn, PickerValue } from '../picker-view';
|
|
2
2
|
import { CascadePickerOption } from './cascade-picker';
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function useColumnsFn(options: CascadePickerOption[]): (selected: PickerValue[]) => PickerColumn[];
|
|
@@ -3,28 +3,49 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.useColumnsFn = useColumnsFn;
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
const columns = [];
|
|
10
|
-
columns.push(options.map(option => ({
|
|
11
|
-
label: option.label,
|
|
12
|
-
value: option.value
|
|
13
|
-
})));
|
|
8
|
+
var _react = require("react");
|
|
14
9
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
function useColumnsFn(options) {
|
|
11
|
+
const depth = (0, _react.useMemo)(() => {
|
|
12
|
+
let depth = 0;
|
|
18
13
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
function traverse(options, currentDepth) {
|
|
15
|
+
if (currentDepth > depth) depth = currentDepth;
|
|
16
|
+
const nextDepth = currentDepth + 1;
|
|
17
|
+
options.forEach(option => {
|
|
18
|
+
if (option.children) {
|
|
19
|
+
traverse(option.children, nextDepth);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
traverse(options, 1);
|
|
25
|
+
return depth;
|
|
26
|
+
}, [options]);
|
|
27
|
+
return selected => {
|
|
28
|
+
const columns = [];
|
|
29
|
+
let currentOptions = options;
|
|
30
|
+
let i = 0;
|
|
31
|
+
|
|
32
|
+
while (true) {
|
|
33
|
+
columns.push(currentOptions.map(option => ({
|
|
23
34
|
label: option.label,
|
|
24
35
|
value: option.value
|
|
25
36
|
})));
|
|
37
|
+
const x = selected[i];
|
|
38
|
+
const targetOptions = currentOptions.find(option => option.value === x);
|
|
39
|
+
if (!targetOptions || !targetOptions.children) break;
|
|
40
|
+
currentOptions = targetOptions.children;
|
|
41
|
+
i++;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
while (i < depth - 1) {
|
|
45
|
+
columns.push([]);
|
|
46
|
+
i++;
|
|
26
47
|
}
|
|
27
|
-
}
|
|
28
48
|
|
|
29
|
-
|
|
49
|
+
return columns;
|
|
50
|
+
};
|
|
30
51
|
}
|
|
@@ -11,8 +11,6 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
11
11
|
|
|
12
12
|
var _picker = _interopRequireDefault(require("../picker"));
|
|
13
13
|
|
|
14
|
-
var _useCascadePickerOptions = require("./use-cascade-picker-options");
|
|
15
|
-
|
|
16
14
|
var _cascadePickerUtils = require("./cascade-picker-utils");
|
|
17
15
|
|
|
18
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -22,12 +20,9 @@ const CascadePicker = props => {
|
|
|
22
20
|
options
|
|
23
21
|
} = props,
|
|
24
22
|
pickerProps = (0, _tslib.__rest)(props, ["options"]);
|
|
25
|
-
const
|
|
26
|
-
depth,
|
|
27
|
-
subOptionsRecord
|
|
28
|
-
} = (0, _useCascadePickerOptions.useCascadePickerOptions)(options);
|
|
23
|
+
const columnsFn = (0, _cascadePickerUtils.useColumnsFn)(options);
|
|
29
24
|
return _react.default.createElement(_picker.default, Object.assign({}, pickerProps, {
|
|
30
|
-
columns:
|
|
25
|
+
columns: columnsFn
|
|
31
26
|
}));
|
|
32
27
|
};
|
|
33
28
|
|