@rainbow-oh/yee-c 0.2.0 → 0.3.0
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/dist/cjs/Button/button.js +2 -2
- package/dist/cjs/Button/style/index.less +23 -8
- package/dist/cjs/Card/demo/collapsible.js +2 -1
- package/dist/cjs/Carousel/demo/arrows.js +1 -1
- package/dist/cjs/Carousel/demo/autoplay.js +1 -1
- package/dist/cjs/Carousel/demo/effect.js +1 -1
- package/dist/cjs/Carousel/demo/position.js +1 -1
- package/dist/cjs/Config-Provider/interface.d.ts +4 -0
- package/dist/cjs/Form/Field.js +32 -10
- package/dist/cjs/Form/interface.d.ts +17 -1
- package/dist/cjs/Menu/style/index.less +2 -2
- package/dist/cjs/Radio/demo/button.js +1 -0
- package/dist/cjs/Radio/interface.d.ts +4 -0
- package/dist/cjs/Radio/radio-group.js +28 -14
- package/dist/cjs/Radio/radio.js +3 -1
- package/dist/cjs/Radio/style/index.less +19 -5
- package/dist/cjs/Segmented/demo/basic.d.ts +3 -0
- package/dist/cjs/Segmented/demo/basic.js +51 -0
- package/dist/cjs/Segmented/demo/block.d.ts +3 -0
- package/dist/cjs/Segmented/demo/block.js +49 -0
- package/dist/cjs/Segmented/demo/disabled.d.ts +3 -0
- package/dist/cjs/Segmented/demo/disabled.js +47 -0
- package/dist/cjs/Segmented/demo/size.d.ts +3 -0
- package/dist/cjs/Segmented/demo/size.js +37 -0
- package/dist/cjs/Segmented/index.d.ts +3 -0
- package/dist/cjs/Segmented/index.js +36 -0
- package/dist/cjs/Segmented/interface.d.ts +82 -0
- package/dist/cjs/Segmented/interface.js +17 -0
- package/dist/cjs/Segmented/segmented.d.ts +5 -0
- package/dist/cjs/Segmented/segmented.js +177 -0
- package/dist/cjs/Segmented/style/index.less +104 -0
- package/dist/cjs/Spin/spin.js +2 -1
- package/dist/cjs/Steps/step.js +1 -1
- package/dist/cjs/Steps/style/index.less +8 -2
- package/dist/cjs/Switch/demo/content.js +22 -1
- package/dist/cjs/Switch/style/index.less +16 -0
- package/dist/cjs/Switch/switch.js +9 -2
- package/dist/cjs/Table/interface.d.ts +5 -1
- package/dist/cjs/Table/theader/cell.js +4 -5
- package/dist/cjs/Tag/demo/size.js +1 -1
- package/dist/cjs/Tag/style/index.less +1 -0
- package/dist/cjs/Tour/demo/basic.d.ts +3 -0
- package/dist/cjs/Tour/demo/basic.js +69 -0
- package/dist/cjs/Tour/demo/indicators.d.ts +3 -0
- package/dist/cjs/Tour/demo/indicators.js +76 -0
- package/dist/cjs/Tour/demo/placement.d.ts +3 -0
- package/dist/cjs/Tour/demo/placement.js +80 -0
- package/dist/cjs/Tour/demo/scroll.d.ts +3 -0
- package/dist/cjs/Tour/demo/scroll.js +72 -0
- package/dist/cjs/Tour/index.d.ts +3 -0
- package/dist/cjs/Tour/index.js +36 -0
- package/dist/cjs/Tour/interface.d.ts +118 -0
- package/dist/cjs/Tour/interface.js +17 -0
- package/dist/cjs/Tour/style/index.less +103 -0
- package/dist/cjs/Tour/tour.d.ts +5 -0
- package/dist/cjs/Tour/tour.js +403 -0
- package/dist/cjs/Tree/demo/checkable.js +6 -6
- package/dist/cjs/index.d.ts +4 -0
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/locale/interface.d.ts +7 -0
- package/dist/cjs/locale/lang/en_US.js +6 -0
- package/dist/cjs/locale/lang/ja_JP.js +6 -0
- package/dist/cjs/locale/lang/zh_CN.js +6 -0
- package/dist/cjs/locale/lang/zh_TW.js +6 -0
- package/dist/cjs/style/color.blue.css +1 -1
- package/dist/cjs/style/color.crimson.css +1 -1
- package/dist/cjs/style/color.css +18 -1
- package/dist/cjs/style/size.css +38 -0
- package/dist/cjs/style/themes.css +3 -3
- package/dist/cjs/style/variables.css +57 -2
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/Button/button.js +2 -2
- package/dist/esm/Button/style/index.less +23 -8
- package/dist/esm/Card/demo/collapsible.js +2 -1
- package/dist/esm/Carousel/demo/arrows.js +1 -1
- package/dist/esm/Carousel/demo/autoplay.js +1 -1
- package/dist/esm/Carousel/demo/effect.js +1 -1
- package/dist/esm/Carousel/demo/position.js +1 -1
- package/dist/esm/Config-Provider/interface.d.ts +4 -0
- package/dist/esm/Form/Field.js +11 -4
- package/dist/esm/Form/interface.d.ts +17 -1
- package/dist/esm/Menu/style/index.less +2 -2
- package/dist/esm/Radio/demo/button.js +1 -0
- package/dist/esm/Radio/interface.d.ts +4 -0
- package/dist/esm/Radio/radio-group.js +9 -2
- package/dist/esm/Radio/radio.js +3 -1
- package/dist/esm/Radio/style/index.less +19 -5
- package/dist/esm/Segmented/demo/basic.d.ts +3 -0
- package/dist/esm/Segmented/demo/basic.js +33 -0
- package/dist/esm/Segmented/demo/block.d.ts +3 -0
- package/dist/esm/Segmented/demo/block.js +29 -0
- package/dist/esm/Segmented/demo/disabled.d.ts +3 -0
- package/dist/esm/Segmented/demo/disabled.js +22 -0
- package/dist/esm/Segmented/demo/size.d.ts +3 -0
- package/dist/esm/Segmented/demo/size.js +15 -0
- package/dist/esm/Segmented/index.d.ts +3 -0
- package/dist/esm/Segmented/index.js +2 -0
- package/dist/esm/Segmented/interface.d.ts +82 -0
- package/dist/esm/Segmented/interface.js +1 -0
- package/dist/esm/Segmented/segmented.d.ts +5 -0
- package/dist/esm/Segmented/segmented.js +110 -0
- package/dist/esm/Segmented/style/index.less +104 -0
- package/dist/esm/Spin/spin.js +2 -1
- package/dist/esm/Steps/step.js +4 -1
- package/dist/esm/Steps/style/index.less +8 -2
- package/dist/esm/Switch/demo/content.js +12 -3
- package/dist/esm/Switch/style/index.less +16 -0
- package/dist/esm/Switch/switch.js +7 -5
- package/dist/esm/Table/interface.d.ts +5 -1
- package/dist/esm/Table/theader/cell.js +2 -3
- package/dist/esm/Tag/demo/size.js +6 -2
- package/dist/esm/Tag/style/index.less +1 -0
- package/dist/esm/Tour/demo/basic.d.ts +3 -0
- package/dist/esm/Tour/demo/basic.js +69 -0
- package/dist/esm/Tour/demo/indicators.d.ts +3 -0
- package/dist/esm/Tour/demo/indicators.js +73 -0
- package/dist/esm/Tour/demo/placement.d.ts +3 -0
- package/dist/esm/Tour/demo/placement.js +53 -0
- package/dist/esm/Tour/demo/scroll.d.ts +3 -0
- package/dist/esm/Tour/demo/scroll.js +58 -0
- package/dist/esm/Tour/index.d.ts +3 -0
- package/dist/esm/Tour/index.js +2 -0
- package/dist/esm/Tour/interface.d.ts +118 -0
- package/dist/esm/Tour/interface.js +1 -0
- package/dist/esm/Tour/style/index.less +103 -0
- package/dist/esm/Tour/tour.d.ts +5 -0
- package/dist/esm/Tour/tour.js +383 -0
- package/dist/esm/Tree/demo/checkable.js +6 -6
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/locale/interface.d.ts +7 -0
- package/dist/esm/locale/lang/en_US.js +6 -0
- package/dist/esm/locale/lang/ja_JP.js +6 -0
- package/dist/esm/locale/lang/zh_CN.js +6 -0
- package/dist/esm/locale/lang/zh_TW.js +6 -0
- package/dist/esm/style/color.blue.css +1 -1
- package/dist/esm/style/color.crimson.css +1 -1
- package/dist/esm/style/color.css +18 -1
- package/dist/esm/style/size.css +38 -0
- package/dist/esm/style/themes.css +3 -3
- package/dist/esm/style/variables.css +57 -2
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/umd/yee-c.min.css +3 -3
- package/dist/umd/yee-c.min.js +1 -1
- package/package.json +1 -1
- package/src/Button/button.tsx +2 -2
- package/src/Button/style/index.less +23 -8
- package/src/Card/demo/collapsible.tsx +1 -0
- package/src/Carousel/demo/arrows.tsx +1 -1
- package/src/Carousel/demo/autoplay.tsx +1 -1
- package/src/Carousel/demo/effect.tsx +1 -1
- package/src/Carousel/demo/position.tsx +1 -1
- package/src/Config-Provider/index.en-US.md +2 -0
- package/src/Config-Provider/index.zh-CN.md +2 -0
- package/src/Config-Provider/interface.ts +4 -0
- package/src/Form/Field.tsx +30 -11
- package/src/Form/index.en-US.md +4 -0
- package/src/Form/index.zh-CN.md +4 -0
- package/src/Form/interface.ts +17 -1
- package/src/Menu/style/index.less +2 -2
- package/src/Radio/demo/button.tsx +1 -0
- package/src/Radio/index.en-US.md +2 -0
- package/src/Radio/index.zh-CN.md +2 -0
- package/src/Radio/interface.ts +4 -0
- package/src/Radio/radio-group.tsx +9 -1
- package/src/Radio/radio.tsx +2 -1
- package/src/Radio/style/index.less +19 -5
- package/src/Segmented/demo/basic.tsx +24 -0
- package/src/Segmented/demo/block.tsx +17 -0
- package/src/Segmented/demo/disabled.tsx +18 -0
- package/src/Segmented/demo/size.tsx +10 -0
- package/src/Segmented/index.en-US.md +47 -0
- package/src/Segmented/index.ts +12 -0
- package/src/Segmented/index.zh-CN.md +47 -0
- package/src/Segmented/interface.ts +87 -0
- package/src/Segmented/segmented.tsx +134 -0
- package/src/Segmented/style/index.less +104 -0
- package/src/Spin/spin.tsx +1 -0
- package/src/Steps/step.tsx +1 -1
- package/src/Steps/style/index.less +8 -2
- package/src/Switch/demo/content.tsx +15 -5
- package/src/Switch/style/index.less +16 -0
- package/src/Switch/switch.tsx +14 -6
- package/src/Table/index.en-US.md +1 -0
- package/src/Table/index.zh-CN.md +1 -0
- package/src/Table/interface.ts +5 -1
- package/src/Table/theader/cell.tsx +2 -9
- package/src/Tag/demo/size.tsx +2 -2
- package/src/Tag/style/index.less +1 -0
- package/src/Tour/demo/basic.tsx +52 -0
- package/src/Tour/demo/indicators.tsx +63 -0
- package/src/Tour/demo/placement.tsx +55 -0
- package/src/Tour/demo/scroll.tsx +49 -0
- package/src/Tour/index.en-US.md +61 -0
- package/src/Tour/index.ts +10 -0
- package/src/Tour/index.zh-CN.md +61 -0
- package/src/Tour/interface.ts +126 -0
- package/src/Tour/style/index.less +103 -0
- package/src/Tour/tour.tsx +399 -0
- package/src/Tree/demo/checkable.tsx +6 -6
- package/src/index.ts +6 -0
- package/src/locale/interface.ts +9 -0
- package/src/locale/lang/en_US.ts +7 -0
- package/src/locale/lang/ja_JP.ts +7 -0
- package/src/locale/lang/zh_CN.ts +7 -0
- package/src/locale/lang/zh_TW.ts +7 -0
- package/src/style/color.blue.css +1 -1
- package/src/style/color.crimson.css +1 -1
- package/src/style/color.css +18 -1
- package/src/style/size.css +38 -0
- package/src/version.ts +1 -1
- package/dist/cjs/utils/x.d.ts +0 -11
- package/dist/cjs/utils/x.js +0 -51
- package/dist/esm/utils/x.d.ts +0 -11
- package/dist/esm/utils/x.js +0 -49
- package/src/utils/x.ts +0 -33
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Button, Space, Tour } from '@rainbow-oh/yee-c';
|
|
2
|
+
import React, { useRef, useState } from 'react';
|
|
3
|
+
|
|
4
|
+
export default () => {
|
|
5
|
+
const [open, setOpen] = useState(false);
|
|
6
|
+
const aRef = useRef<HTMLDivElement>(null);
|
|
7
|
+
const bRef = useRef<HTMLDivElement>(null);
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<Space direction="vertical">
|
|
11
|
+
<Space>
|
|
12
|
+
<div ref={aRef} style={{ display: 'inline-block' }}>
|
|
13
|
+
<Button>导入</Button>
|
|
14
|
+
</div>
|
|
15
|
+
<div ref={bRef} style={{ display: 'inline-block' }}>
|
|
16
|
+
<Button>筛选</Button>
|
|
17
|
+
</div>
|
|
18
|
+
<Button type="primary" onClick={() => setOpen(true)}>
|
|
19
|
+
开始
|
|
20
|
+
</Button>
|
|
21
|
+
</Space>
|
|
22
|
+
|
|
23
|
+
<Tour
|
|
24
|
+
open={open}
|
|
25
|
+
onClose={() => setOpen(false)}
|
|
26
|
+
onFinish={() => setOpen(false)}
|
|
27
|
+
indicatorsRender={(current, total) => (
|
|
28
|
+
<>
|
|
29
|
+
{Array.from({ length: total }).map((_, i) => (
|
|
30
|
+
<span
|
|
31
|
+
key={i}
|
|
32
|
+
style={{
|
|
33
|
+
display: 'inline-block',
|
|
34
|
+
width: 8,
|
|
35
|
+
height: 8,
|
|
36
|
+
marginInlineEnd: 4,
|
|
37
|
+
borderRadius: '50%',
|
|
38
|
+
background:
|
|
39
|
+
i === current
|
|
40
|
+
? 'var(--yee-primary-color)'
|
|
41
|
+
: 'var(--yee-border-color)',
|
|
42
|
+
transition: 'background 0.2s',
|
|
43
|
+
}}
|
|
44
|
+
/>
|
|
45
|
+
))}
|
|
46
|
+
</>
|
|
47
|
+
)}
|
|
48
|
+
steps={[
|
|
49
|
+
{
|
|
50
|
+
target: () => aRef.current,
|
|
51
|
+
title: '导入',
|
|
52
|
+
description: '点击此处导入数据文件。',
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
target: () => bRef.current,
|
|
56
|
+
title: '筛选',
|
|
57
|
+
description: '在这里筛选你需要的数据。',
|
|
58
|
+
},
|
|
59
|
+
]}
|
|
60
|
+
/>
|
|
61
|
+
</Space>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Button, Space, Tour } from '@rainbow-oh/yee-c';
|
|
2
|
+
import React, { useRef, useState } from 'react';
|
|
3
|
+
|
|
4
|
+
const placements = ['top', 'right', 'bottom', 'left'] as const;
|
|
5
|
+
type P = (typeof placements)[number];
|
|
6
|
+
|
|
7
|
+
export default () => {
|
|
8
|
+
const [open, setOpen] = useState(false);
|
|
9
|
+
const [p, setP] = useState<P>('top');
|
|
10
|
+
const targetRef = useRef<HTMLDivElement>(null);
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<Space direction="vertical">
|
|
14
|
+
<Space>
|
|
15
|
+
{placements.map((pl) => (
|
|
16
|
+
<Button
|
|
17
|
+
key={pl}
|
|
18
|
+
type={p === pl ? 'primary' : 'default'}
|
|
19
|
+
onClick={() => {
|
|
20
|
+
setP(pl);
|
|
21
|
+
setOpen(true);
|
|
22
|
+
}}
|
|
23
|
+
>
|
|
24
|
+
{pl}
|
|
25
|
+
</Button>
|
|
26
|
+
))}
|
|
27
|
+
</Space>
|
|
28
|
+
|
|
29
|
+
<div
|
|
30
|
+
ref={targetRef}
|
|
31
|
+
style={{
|
|
32
|
+
display: 'inline-block',
|
|
33
|
+
padding: '16px 24px',
|
|
34
|
+
border: '1px dashed var(--yee-border-color)',
|
|
35
|
+
borderRadius: 6,
|
|
36
|
+
}}
|
|
37
|
+
>
|
|
38
|
+
目标元素
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
<Tour
|
|
42
|
+
open={open}
|
|
43
|
+
placement={p}
|
|
44
|
+
onClose={() => setOpen(false)}
|
|
45
|
+
steps={[
|
|
46
|
+
{
|
|
47
|
+
target: () => targetRef.current,
|
|
48
|
+
title: `placement: ${p}`,
|
|
49
|
+
description: '气泡卡片相对目标元素的位置;靠近视口边缘时会自动翻转。',
|
|
50
|
+
},
|
|
51
|
+
]}
|
|
52
|
+
/>
|
|
53
|
+
</Space>
|
|
54
|
+
);
|
|
55
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Button, Space, Tour } from '@rainbow-oh/yee-c';
|
|
2
|
+
import React, { useRef, useState } from 'react';
|
|
3
|
+
|
|
4
|
+
export default () => {
|
|
5
|
+
const [open, setOpen] = useState(false);
|
|
6
|
+
const farRef = useRef<HTMLDivElement>(null);
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<Space direction="vertical" style={{ width: '100%' }}>
|
|
10
|
+
<Button type="primary" onClick={() => setOpen(true)}>
|
|
11
|
+
开始引导(自动滚动定位)
|
|
12
|
+
</Button>
|
|
13
|
+
|
|
14
|
+
<div
|
|
15
|
+
style={{
|
|
16
|
+
height: 600,
|
|
17
|
+
padding: 24,
|
|
18
|
+
background: 'var(--yee-color-bg-layout)',
|
|
19
|
+
borderRadius: 8,
|
|
20
|
+
color: '#999',
|
|
21
|
+
}}
|
|
22
|
+
>
|
|
23
|
+
↓ 目标在下方,切换步骤时引导会自动滚动定位
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
<div ref={farRef} style={{ display: 'inline-block' }}>
|
|
27
|
+
<Button>远处的目标</Button>
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
<Tour
|
|
31
|
+
open={open}
|
|
32
|
+
onClose={() => setOpen(false)}
|
|
33
|
+
onFinish={() => setOpen(false)}
|
|
34
|
+
steps={[
|
|
35
|
+
{
|
|
36
|
+
target: () => farRef.current,
|
|
37
|
+
title: '滚动定位',
|
|
38
|
+
description: '切换到这一步时,目标会自动滚动到视口内。',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
target: '#tour-nonexistent-target',
|
|
42
|
+
title: '目标不存在',
|
|
43
|
+
description: '找不到目标元素时,卡片居中显示(无高亮)。',
|
|
44
|
+
},
|
|
45
|
+
]}
|
|
46
|
+
/>
|
|
47
|
+
</Space>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
---
|
|
2
|
+
category: Components
|
|
3
|
+
title: Tour
|
|
4
|
+
subtitle: Tour
|
|
5
|
+
group:
|
|
6
|
+
title: Feedback
|
|
7
|
+
order: 29
|
|
8
|
+
toc: 'content'
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Tour
|
|
12
|
+
|
|
13
|
+
Step-by-step guided tour: full-screen mask + highlighted target element + attached explanation card, with multi-step navigation, progress indicators, and automatic scroll-into-view. Commonly used for feature walkthroughs and new-user onboarding.
|
|
14
|
+
|
|
15
|
+
## Code Demo
|
|
16
|
+
|
|
17
|
+
<code src="./demo/basic.tsx" title="Basic" description="Multi-step tour, controlled open, with previous/next/finish/skip"></code>
|
|
18
|
+
<code src="./demo/placement.tsx" title="Placement" description="Card placement relative to the target; auto-flips near viewport edges"></code>
|
|
19
|
+
<code src="./demo/indicators.tsx" title="Custom Indicators" description="Customize step indicators via indicatorsRender"></code>
|
|
20
|
+
<code src="./demo/scroll.tsx" title="Scroll & Fallback" description="Auto scroll-into-view on step change; centered card when target is missing"></code>
|
|
21
|
+
|
|
22
|
+
## API
|
|
23
|
+
|
|
24
|
+
### TourProps
|
|
25
|
+
|
|
26
|
+
| Property | Type | Description | Default |
|
|
27
|
+
| --- | --- | --- | --- |
|
|
28
|
+
| open | `boolean` | Whether the tour is visible (controlled) | - |
|
|
29
|
+
| steps | `TourStep[]` | Tour steps | - |
|
|
30
|
+
| current | `number` | Controlled current step index | - |
|
|
31
|
+
| defaultCurrent | `number` | Default current step index | `0` |
|
|
32
|
+
| onClose | `() => void` | Callback when closed / skipped | - |
|
|
33
|
+
| onFinish | `() => void` | Callback when all steps are finished | - |
|
|
34
|
+
| onChange | `(current: number) => void` | Callback when current step changes | - |
|
|
35
|
+
| placement | `Placement` | Default card placement | `'bottom'` |
|
|
36
|
+
| arrow | `boolean` | Whether to show the card arrow | - |
|
|
37
|
+
| mask | `boolean` | Whether to show the mask (highlight cutout + click lock) | `true` |
|
|
38
|
+
| closable | `boolean` | Whether the top-right close button is shown | `true` |
|
|
39
|
+
| closeIcon | `React.ReactNode` | Custom close icon | - |
|
|
40
|
+
| maskClosable | `boolean` | Whether clicking the mask closes the tour | `false` |
|
|
41
|
+
| indicatorsRender | `(current: number, total: number) => React.ReactNode` | Custom step indicators | default `current+1 / total` |
|
|
42
|
+
| scrollIntoViewOptions | `boolean \| ScrollIntoViewOptions` | Options for target.scrollIntoView on each step | `true` |
|
|
43
|
+
| className / style | | Custom root class/style | - |
|
|
44
|
+
| classNames / styles | `Partial<Record<'highlight' \| 'content' \| 'header' \| 'body' \| 'footer', …>>` | Semantic structure class/style | - |
|
|
45
|
+
|
|
46
|
+
> `Placement` = `'top' \| 'right' \| 'bottom' \| 'left' \| 'topLeft' \| 'topRight' \| 'bottomLeft' \| 'bottomRight' \| 'leftTop' \| 'leftBottom' \| 'rightTop' \| 'rightBottom'`, same as `Trigger`.
|
|
47
|
+
|
|
48
|
+
### TourStep
|
|
49
|
+
|
|
50
|
+
| Property | Type | Description | Default |
|
|
51
|
+
| --- | --- | --- | --- |
|
|
52
|
+
| target | `(() => HTMLElement \| null) \| string \| HTMLElement` | Highlight target (finder function / CSS selector / element) | - |
|
|
53
|
+
| title | `React.ReactNode` | Card title | - |
|
|
54
|
+
| description | `React.ReactNode` | Card description | - |
|
|
55
|
+
| placement | `Placement` | Card placement for this step, overrides TourProps.placement | - |
|
|
56
|
+
| arrow | `boolean` | Whether to show the arrow for this step | - |
|
|
57
|
+
| className | `string` | Custom card class name for this step | - |
|
|
58
|
+
|
|
59
|
+
### Built-in text
|
|
60
|
+
|
|
61
|
+
Button labels (previous/next/finish/skip) come from `locale.tour` (`previous`/`next`/`finish`/`skip`) and follow the `ConfigProvider` locale; override via the language pack or `ConfigProvider.value.tour`.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
---
|
|
2
|
+
category: Components
|
|
3
|
+
title: Tour
|
|
4
|
+
subtitle: 新手引导
|
|
5
|
+
group:
|
|
6
|
+
title: 反馈
|
|
7
|
+
order: 29
|
|
8
|
+
toc: 'content'
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Tour 新手引导
|
|
12
|
+
|
|
13
|
+
步骤式新手引导:全屏遮罩 + 高亮目标元素 + 贴附说明卡片,支持多步推进、进度指示、自动滚动定位。常用于产品功能向导、新用户 onboarding。
|
|
14
|
+
|
|
15
|
+
## 代码演示
|
|
16
|
+
|
|
17
|
+
<code src="./demo/basic.tsx" title="基础用法" description="多步引导,受控 open,支持上一步/下一步/完成/跳过"></code>
|
|
18
|
+
<code src="./demo/placement.tsx" title="气泡位置" description="卡片相对目标的 placement,靠近视口边缘时自动翻转"></code>
|
|
19
|
+
<code src="./demo/indicators.tsx" title="自定义进度指示" description="通过 indicatorsRender 自定义步骤进度点"></code>
|
|
20
|
+
<code src="./demo/scroll.tsx" title="滚动定位与容错" description="切换步骤时自动滚动到目标;目标不存在时卡片居中"></code>
|
|
21
|
+
|
|
22
|
+
## API
|
|
23
|
+
|
|
24
|
+
### TourProps
|
|
25
|
+
|
|
26
|
+
| 属性名 | 类型 | 描述 | 默认值 |
|
|
27
|
+
| --- | --- | --- | --- |
|
|
28
|
+
| open | `boolean` | 是否显示引导(受控) | - |
|
|
29
|
+
| steps | `TourStep[]` | 引导步骤 | - |
|
|
30
|
+
| current | `number` | 受控当前步骤索引 | - |
|
|
31
|
+
| defaultCurrent | `number` | 默认当前步骤索引 | `0` |
|
|
32
|
+
| onClose | `() => void` | 关闭/跳过时的回调 | - |
|
|
33
|
+
| onFinish | `() => void` | 完成全部步骤时的回调 | - |
|
|
34
|
+
| onChange | `(current: number) => void` | 步骤变化时的回调 | - |
|
|
35
|
+
| placement | `Placement` | 卡片默认位置 | `'bottom'` |
|
|
36
|
+
| arrow | `boolean` | 是否显示卡片箭头 | - |
|
|
37
|
+
| mask | `boolean` | 是否显示遮罩(含高亮挖洞与点击锁定) | `true` |
|
|
38
|
+
| closable | `boolean` | 是否显示右上关闭按钮 | `true` |
|
|
39
|
+
| closeIcon | `React.ReactNode` | 自定义关闭图标 | - |
|
|
40
|
+
| maskClosable | `boolean` | 点击遮罩是否关闭 | `false` |
|
|
41
|
+
| indicatorsRender | `(current: number, total: number) => React.ReactNode` | 自定义进度指示 | 默认 `current+1 / total` |
|
|
42
|
+
| scrollIntoViewOptions | `boolean \| ScrollIntoViewOptions` | 切换步骤时目标 scrollIntoView 的参数 | `true` |
|
|
43
|
+
| className / style | | 自定义根类名/样式 | - |
|
|
44
|
+
| classNames / styles | `Partial<Record<'highlight' \| 'content' \| 'header' \| 'body' \| 'footer', …>>` | 语义化结构类名/样式 | - |
|
|
45
|
+
|
|
46
|
+
> `Placement` = `'top' \| 'right' \| 'bottom' \| 'left' \| 'topLeft' \| 'topRight' \| 'bottomLeft' \| 'bottomRight' \| 'leftTop' \| 'leftBottom' \| 'rightTop' \| 'rightBottom'`,与 `Trigger` 一致。
|
|
47
|
+
|
|
48
|
+
### TourStep
|
|
49
|
+
|
|
50
|
+
| 属性名 | 类型 | 描述 | 默认值 |
|
|
51
|
+
| --- | --- | --- | --- |
|
|
52
|
+
| target | `(() => HTMLElement \| null) \| string \| HTMLElement` | 高亮目标(查找函数 / CSS 选择器 / 元素) | - |
|
|
53
|
+
| title | `React.ReactNode` | 卡片标题 | - |
|
|
54
|
+
| description | `React.ReactNode` | 卡片描述 | - |
|
|
55
|
+
| placement | `Placement` | 该步卡片位置,覆盖 TourProps.placement | - |
|
|
56
|
+
| arrow | `boolean` | 该步是否显示箭头 | - |
|
|
57
|
+
| className | `string` | 该步卡片自定义类名 | - |
|
|
58
|
+
|
|
59
|
+
### 内置文案
|
|
60
|
+
|
|
61
|
+
按钮(上一步/下一步/完成/跳过)与进度文案取自 `locale.tour`(`previous`/`next`/`finish`/`skip`),随 `ConfigProvider` 的 locale 切换;可通过语言包或 `ConfigProvider.value.tour` 覆盖。
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import type { Placement } from '../Trigger/interface';
|
|
2
|
+
import type { DataAttributeProps } from '../utils/types';
|
|
3
|
+
|
|
4
|
+
export type TourTarget = (() => HTMLElement | null) | string | HTMLElement;
|
|
5
|
+
|
|
6
|
+
export type TourSemanticDOM =
|
|
7
|
+
| 'highlight'
|
|
8
|
+
| 'content'
|
|
9
|
+
| 'header'
|
|
10
|
+
| 'body'
|
|
11
|
+
| 'footer';
|
|
12
|
+
|
|
13
|
+
export interface TourStep {
|
|
14
|
+
/**
|
|
15
|
+
* The element to highlight, supports a finder function, a CSS selector string, or an HTMLElement
|
|
16
|
+
*/
|
|
17
|
+
target: TourTarget;
|
|
18
|
+
/**
|
|
19
|
+
* Card title
|
|
20
|
+
*/
|
|
21
|
+
title?: React.ReactNode;
|
|
22
|
+
/**
|
|
23
|
+
* Card description
|
|
24
|
+
*/
|
|
25
|
+
description?: React.ReactNode;
|
|
26
|
+
/**
|
|
27
|
+
* Card placement relative to the highlighted target
|
|
28
|
+
* @default 'bottom'
|
|
29
|
+
*/
|
|
30
|
+
placement?: Placement;
|
|
31
|
+
/**
|
|
32
|
+
* Whether to show the card arrow
|
|
33
|
+
*/
|
|
34
|
+
arrow?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Custom step class name
|
|
37
|
+
*/
|
|
38
|
+
className?: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface TourProps extends DataAttributeProps {
|
|
42
|
+
/**
|
|
43
|
+
* Custom prefix class name
|
|
44
|
+
*/
|
|
45
|
+
prefixCls?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Custom root class name
|
|
48
|
+
*/
|
|
49
|
+
className?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Custom root style
|
|
52
|
+
*/
|
|
53
|
+
style?: React.CSSProperties;
|
|
54
|
+
/**
|
|
55
|
+
* Semantic structure class names
|
|
56
|
+
*/
|
|
57
|
+
classNames?: Partial<Record<TourSemanticDOM, string>>;
|
|
58
|
+
/**
|
|
59
|
+
* Semantic structure styles
|
|
60
|
+
*/
|
|
61
|
+
styles?: Partial<Record<TourSemanticDOM, React.CSSProperties>>;
|
|
62
|
+
/**
|
|
63
|
+
* Whether the tour is visible (controlled)
|
|
64
|
+
*/
|
|
65
|
+
open: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Tour steps
|
|
68
|
+
*/
|
|
69
|
+
steps: TourStep[];
|
|
70
|
+
/**
|
|
71
|
+
* Controlled current step index
|
|
72
|
+
*/
|
|
73
|
+
current?: number;
|
|
74
|
+
/**
|
|
75
|
+
* Default current step index
|
|
76
|
+
*/
|
|
77
|
+
defaultCurrent?: number;
|
|
78
|
+
/**
|
|
79
|
+
* Callback when the tour is closed / skipped
|
|
80
|
+
*/
|
|
81
|
+
onClose?: () => void;
|
|
82
|
+
/**
|
|
83
|
+
* Callback when all steps are finished
|
|
84
|
+
*/
|
|
85
|
+
onFinish?: () => void;
|
|
86
|
+
/**
|
|
87
|
+
* Callback when current step changes
|
|
88
|
+
*/
|
|
89
|
+
onChange?: (current: number) => void;
|
|
90
|
+
/**
|
|
91
|
+
* Default card placement relative to the highlighted target
|
|
92
|
+
* @default 'bottom'
|
|
93
|
+
*/
|
|
94
|
+
placement?: Placement;
|
|
95
|
+
/**
|
|
96
|
+
* Whether to show the card arrow by default
|
|
97
|
+
*/
|
|
98
|
+
arrow?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Whether to show the mask layer (highlight cutout + click lock)
|
|
101
|
+
* @default true
|
|
102
|
+
*/
|
|
103
|
+
mask?: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Whether the close button is shown at the top-right of the card
|
|
106
|
+
* @default true
|
|
107
|
+
*/
|
|
108
|
+
closable?: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Custom close icon
|
|
111
|
+
*/
|
|
112
|
+
closeIcon?: React.ReactNode;
|
|
113
|
+
/**
|
|
114
|
+
* Whether clicking the mask closes the tour
|
|
115
|
+
* @default false
|
|
116
|
+
*/
|
|
117
|
+
maskClosable?: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Custom step indicators renderer, receives (current, total)
|
|
120
|
+
*/
|
|
121
|
+
indicatorsRender?: (current: number, total: number) => React.ReactNode;
|
|
122
|
+
/**
|
|
123
|
+
* Options passed to target.scrollIntoView on each step
|
|
124
|
+
*/
|
|
125
|
+
scrollIntoViewOptions?: boolean | ScrollIntoViewOptions;
|
|
126
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
@pls: .yee-tour;
|
|
2
|
+
|
|
3
|
+
@{pls} {
|
|
4
|
+
position: fixed;
|
|
5
|
+
inset: 0;
|
|
6
|
+
z-index: var(--yee-tour-mask-z-index);
|
|
7
|
+
pointer-events: none;
|
|
8
|
+
|
|
9
|
+
// ① click-intercept layer (box-shadow receives no pointer events, so a
|
|
10
|
+
// transparent full-screen layer is needed to lock interaction + carry maskClosable)
|
|
11
|
+
&-mask {
|
|
12
|
+
position: absolute;
|
|
13
|
+
inset: 0;
|
|
14
|
+
pointer-events: auto;
|
|
15
|
+
background-color: transparent;
|
|
16
|
+
|
|
17
|
+
// No target to cut out → the mask itself becomes the full-screen dim layer.
|
|
18
|
+
&-full {
|
|
19
|
+
background-color: var(--yee-tour-mask-color);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// ② highlight cutout via a huge box-shadow; top/left/width/height come from
|
|
24
|
+
// motion inline styles, position/shape/visuals from here
|
|
25
|
+
&-highlight {
|
|
26
|
+
position: fixed;
|
|
27
|
+
box-sizing: border-box;
|
|
28
|
+
border-radius: var(--yee-tour-highlight-border-radius);
|
|
29
|
+
box-shadow: 0 0 0 9999px var(--yee-tour-mask-color);
|
|
30
|
+
z-index: 1;
|
|
31
|
+
pointer-events: none;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// card
|
|
36
|
+
.yee-tour-content {
|
|
37
|
+
position: fixed;
|
|
38
|
+
z-index: 2;
|
|
39
|
+
pointer-events: auto;
|
|
40
|
+
box-sizing: border-box;
|
|
41
|
+
width: var(--yee-tour-content-width);
|
|
42
|
+
max-width: calc(100vw - 48px);
|
|
43
|
+
padding: var(--yee-tour-content-padding);
|
|
44
|
+
background-color: var(--yee-tour-content-bg-color);
|
|
45
|
+
border-radius: var(--yee-tour-content-border-radius);
|
|
46
|
+
box-shadow: var(--yee-tour-content-box-shadow);
|
|
47
|
+
|
|
48
|
+
.yee-tour-close {
|
|
49
|
+
position: absolute;
|
|
50
|
+
top: var(--yee-tour-close-top);
|
|
51
|
+
inset-inline-end: var(--yee-tour-close-right);
|
|
52
|
+
display: inline-flex;
|
|
53
|
+
align-items: center;
|
|
54
|
+
justify-content: center;
|
|
55
|
+
padding: 0;
|
|
56
|
+
border: none;
|
|
57
|
+
background: transparent;
|
|
58
|
+
color: var(--yee-tour-close-color);
|
|
59
|
+
cursor: pointer;
|
|
60
|
+
opacity: 0.55;
|
|
61
|
+
transition: opacity var(--yee-tour-transition-duration) linear;
|
|
62
|
+
|
|
63
|
+
&:hover {
|
|
64
|
+
opacity: 1;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.yee-tour-header {
|
|
69
|
+
margin-bottom: var(--yee-tour-header-margin-bottom);
|
|
70
|
+
padding-inline-end: var(--yee-tour-close-size);
|
|
71
|
+
color: var(--yee-tour-title-color);
|
|
72
|
+
font-size: var(--yee-tour-title-font-size);
|
|
73
|
+
font-weight: var(--yee-tour-title-font-weight);
|
|
74
|
+
line-height: var(--yee-tour-title-line-height);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.yee-tour-body {
|
|
78
|
+
color: var(--yee-tour-description-color);
|
|
79
|
+
font-size: var(--yee-tour-description-font-size);
|
|
80
|
+
line-height: var(--yee-tour-description-line-height);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.yee-tour-footer {
|
|
84
|
+
display: flex;
|
|
85
|
+
align-items: center;
|
|
86
|
+
justify-content: space-between;
|
|
87
|
+
gap: var(--yee-tour-button-gap);
|
|
88
|
+
margin-top: var(--yee-tour-footer-margin-top);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.yee-tour-indicators {
|
|
92
|
+
display: inline-flex;
|
|
93
|
+
align-items: center;
|
|
94
|
+
gap: var(--yee-tour-indicator-gap);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.yee-tour-buttons {
|
|
98
|
+
display: inline-flex;
|
|
99
|
+
align-items: center;
|
|
100
|
+
gap: var(--yee-tour-button-gap);
|
|
101
|
+
margin-left: auto;
|
|
102
|
+
}
|
|
103
|
+
}
|