@dsh-plugin/dsh-ui-components 0.0.1 → 0.1.0-dev.43616582648
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/LICENSE +21 -21
- package/NOTICE +21 -21
- package/README.md +136 -136
- package/README.zh_CN.md +136 -136
- package/docs/tokens.md +67 -67
- package/lib/basic/form.js +49 -49
- package/lib/basic/styles.js +391 -391
- package/lib/composites/styles.js +427 -427
- package/lib/data/styles.js +257 -257
- package/lib/display/styles.js +310 -310
- package/lib/feedback/styles.js +228 -228
- package/lib/foundation/bridge.js +203 -203
- package/lib/navigation/styles.js +417 -417
- package/package.json +104 -104
- package/scripts/check-size.mjs +69 -69
- package/scripts/dump-npm-latest.mjs +59 -59
- package/scripts/gen-host-tokens.mjs +61 -61
- package/scripts/gen-icons.mjs +188 -178
- package/scripts/verify-no-literal-colors.mjs +63 -63
- package/scripts/verify-tokens.mjs +135 -135
- package/src/basic/button.tsx +76 -76
- package/src/basic/form.tsx +187 -187
- package/src/basic/icon-button.tsx +66 -66
- package/src/basic/index.ts +38 -38
- package/src/basic/input.tsx +140 -140
- package/src/basic/select.tsx +120 -120
- package/src/basic/styles.ts +412 -412
- package/src/basic/toggle.tsx +116 -116
- package/src/composites/data-view.tsx +189 -189
- package/src/composites/index.ts +11 -11
- package/src/composites/indicator.tsx +90 -90
- package/src/composites/menu-select.tsx +230 -230
- package/src/composites/panel.tsx +72 -72
- package/src/composites/settings.tsx +80 -80
- package/src/composites/styles.ts +450 -450
- package/src/data/collection.tsx +71 -71
- package/src/data/index.ts +39 -39
- package/src/data/info.tsx +89 -89
- package/src/data/picker.tsx +113 -113
- package/src/data/styles.ts +278 -278
- package/src/display/container.tsx +67 -67
- package/src/display/feedback.tsx +92 -92
- package/src/display/index.ts +44 -44
- package/src/display/label.tsx +165 -165
- package/src/display/overlay.tsx +103 -103
- package/src/display/styles.ts +332 -332
- package/src/feedback/global.tsx +110 -110
- package/src/feedback/index.ts +19 -19
- package/src/feedback/inline.tsx +50 -50
- package/src/feedback/panel.tsx +93 -93
- package/src/feedback/styles.ts +250 -250
- package/src/foundation/bridge.ts +318 -318
- package/src/foundation/icons.tsx +315 -315
- package/src/foundation/index.ts +33 -33
- package/src/foundation/palette.ts +153 -153
- package/src/foundation/provider.tsx +62 -62
- package/src/foundation/style.ts +63 -63
- package/src/foundation/tokens.ts +62 -62
- package/src/index.ts +18 -18
- package/src/navigation/hierarchy.tsx +82 -82
- package/src/navigation/index.ts +21 -21
- package/src/navigation/indicator.tsx +125 -125
- package/src/navigation/menu.tsx +94 -94
- package/src/navigation/segmented.tsx +136 -136
- package/src/navigation/styles.ts +438 -438
package/src/feedback/global.tsx
CHANGED
|
@@ -1,110 +1,110 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 全局提示:消息条、通知与确认气泡。
|
|
3
|
-
*
|
|
4
|
-
* `Message` 与 `Notification` 是命令式接口,默认挂到 body 层的容器上;容器带
|
|
5
|
-
* `.dsh-ui-overlay`,因此即使在 body 层也能读到同一套皮肤变量。Arco 的这两个
|
|
6
|
-
* 命名空间不读 `ConfigProvider` 的 `getPopupContainer`,所以每次调用都要显式
|
|
7
|
-
* 传 `getContainer`。
|
|
8
|
-
*
|
|
9
|
-
* @module @dsh-plugin/dsh-ui-components/feedback/global
|
|
10
|
-
*/
|
|
11
|
-
import { Arco } from '@dsh-plugin/dsh-loader/client'
|
|
12
|
-
import * as React from 'react'
|
|
13
|
-
import { ensureOverlayContainer } from '../foundation/style.js'
|
|
14
|
-
import { injectFeedbackStyles } from './styles.js'
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* 命令式浮层使用的容器解析函数。
|
|
18
|
-
*
|
|
19
|
-
* @returns 带皮肤变量的 body 级容器。
|
|
20
|
-
*/
|
|
21
|
-
function overlayContainer(): HTMLElement {
|
|
22
|
-
return ensureOverlayContainer() ?? document.body
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/** 是否已经把消息与通知指向了本包的容器。 */
|
|
26
|
-
let containerBound = false
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* 把消息条与通知挂到带皮肤变量的容器上。
|
|
30
|
-
*
|
|
31
|
-
* Arco 的这两个命名空间只接受 `config` 级别的 `getContainer`,不能在每次调用
|
|
32
|
-
* 时覆盖,所以首次使用时统一设置一次。
|
|
33
|
-
*/
|
|
34
|
-
function bindContainer(): void {
|
|
35
|
-
if (containerBound) return
|
|
36
|
-
Arco.Message.config({ getContainer: overlayContainer })
|
|
37
|
-
Arco.Notification.config({ getContainer: overlayContainer })
|
|
38
|
-
containerBound = true
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/** 消息条的可选项。 */
|
|
42
|
-
type MessageOptions = Parameters<typeof Arco.Message.info>[0]
|
|
43
|
-
|
|
44
|
-
/** 通知的可选项。 */
|
|
45
|
-
type NotificationOptions = Parameters<typeof Arco.Notification.info>[0]
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* 顶部居中的短消息,默认 3 秒后自动消失。
|
|
49
|
-
*
|
|
50
|
-
* @param options - 与 Arco 的 `Message` 一致。
|
|
51
|
-
* @returns 可用于手动关闭的句柄。
|
|
52
|
-
*/
|
|
53
|
-
export function message(options: MessageOptions): ReturnType<typeof Arco.Message.info> {
|
|
54
|
-
injectFeedbackStyles()
|
|
55
|
-
bindContainer()
|
|
56
|
-
return Arco.Message.info(options)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/** 成功消息。 */
|
|
60
|
-
export function messageSuccess(content: string): ReturnType<typeof Arco.Message.info> {
|
|
61
|
-
injectFeedbackStyles()
|
|
62
|
-
bindContainer()
|
|
63
|
-
return Arco.Message.success({ content })
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/** 失败消息。 */
|
|
67
|
-
export function messageError(content: string): ReturnType<typeof Arco.Message.info> {
|
|
68
|
-
injectFeedbackStyles()
|
|
69
|
-
bindContainer()
|
|
70
|
-
return Arco.Message.error({ content })
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/** 警告消息。 */
|
|
74
|
-
export function messageWarning(content: string): ReturnType<typeof Arco.Message.info> {
|
|
75
|
-
injectFeedbackStyles()
|
|
76
|
-
bindContainer()
|
|
77
|
-
return Arco.Message.warning({ content })
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* 右上角的通知卡片。
|
|
82
|
-
*
|
|
83
|
-
* @param options - 与 Arco 的 `Notification` 一致。
|
|
84
|
-
* @returns 用于手动关闭的句柄。
|
|
85
|
-
*/
|
|
86
|
-
export function notification(options: NotificationOptions): ReturnType<typeof Arco.Notification.info> {
|
|
87
|
-
injectFeedbackStyles()
|
|
88
|
-
bindContainer()
|
|
89
|
-
return Arco.Notification.info(options)
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/** {@link Message} 组件本身,供需要内联渲染的场景使用。 */
|
|
93
|
-
export const Message: typeof Arco.Message = Arco.Message
|
|
94
|
-
|
|
95
|
-
/** {@link Notification} 命名空间,命令式通知。 */
|
|
96
|
-
export const Notification: typeof Arco.Notification = Arco.Notification
|
|
97
|
-
|
|
98
|
-
/** {@link Popconfirm} 的 props。 */
|
|
99
|
-
export type PopconfirmProps = React.ComponentPropsWithoutRef<typeof Arco.Popconfirm>
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* 气泡确认框,浮层由 `DshProvider` 的容器设置接管。
|
|
103
|
-
*
|
|
104
|
-
* @param props - 见 {@link PopconfirmProps}。
|
|
105
|
-
* @returns 确认气泡元素。
|
|
106
|
-
*/
|
|
107
|
-
export function Popconfirm(props: PopconfirmProps): React.ReactElement {
|
|
108
|
-
injectFeedbackStyles()
|
|
109
|
-
return <Arco.Popconfirm {...props} />
|
|
110
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* 全局提示:消息条、通知与确认气泡。
|
|
3
|
+
*
|
|
4
|
+
* `Message` 与 `Notification` 是命令式接口,默认挂到 body 层的容器上;容器带
|
|
5
|
+
* `.dsh-ui-overlay`,因此即使在 body 层也能读到同一套皮肤变量。Arco 的这两个
|
|
6
|
+
* 命名空间不读 `ConfigProvider` 的 `getPopupContainer`,所以每次调用都要显式
|
|
7
|
+
* 传 `getContainer`。
|
|
8
|
+
*
|
|
9
|
+
* @module @dsh-plugin/dsh-ui-components/feedback/global
|
|
10
|
+
*/
|
|
11
|
+
import { Arco } from '@dsh-plugin/dsh-loader/client'
|
|
12
|
+
import * as React from 'react'
|
|
13
|
+
import { ensureOverlayContainer } from '../foundation/style.js'
|
|
14
|
+
import { injectFeedbackStyles } from './styles.js'
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 命令式浮层使用的容器解析函数。
|
|
18
|
+
*
|
|
19
|
+
* @returns 带皮肤变量的 body 级容器。
|
|
20
|
+
*/
|
|
21
|
+
function overlayContainer(): HTMLElement {
|
|
22
|
+
return ensureOverlayContainer() ?? document.body
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** 是否已经把消息与通知指向了本包的容器。 */
|
|
26
|
+
let containerBound = false
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 把消息条与通知挂到带皮肤变量的容器上。
|
|
30
|
+
*
|
|
31
|
+
* Arco 的这两个命名空间只接受 `config` 级别的 `getContainer`,不能在每次调用
|
|
32
|
+
* 时覆盖,所以首次使用时统一设置一次。
|
|
33
|
+
*/
|
|
34
|
+
function bindContainer(): void {
|
|
35
|
+
if (containerBound) return
|
|
36
|
+
Arco.Message.config({ getContainer: overlayContainer })
|
|
37
|
+
Arco.Notification.config({ getContainer: overlayContainer })
|
|
38
|
+
containerBound = true
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** 消息条的可选项。 */
|
|
42
|
+
type MessageOptions = Parameters<typeof Arco.Message.info>[0]
|
|
43
|
+
|
|
44
|
+
/** 通知的可选项。 */
|
|
45
|
+
type NotificationOptions = Parameters<typeof Arco.Notification.info>[0]
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 顶部居中的短消息,默认 3 秒后自动消失。
|
|
49
|
+
*
|
|
50
|
+
* @param options - 与 Arco 的 `Message` 一致。
|
|
51
|
+
* @returns 可用于手动关闭的句柄。
|
|
52
|
+
*/
|
|
53
|
+
export function message(options: MessageOptions): ReturnType<typeof Arco.Message.info> {
|
|
54
|
+
injectFeedbackStyles()
|
|
55
|
+
bindContainer()
|
|
56
|
+
return Arco.Message.info(options)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** 成功消息。 */
|
|
60
|
+
export function messageSuccess(content: string): ReturnType<typeof Arco.Message.info> {
|
|
61
|
+
injectFeedbackStyles()
|
|
62
|
+
bindContainer()
|
|
63
|
+
return Arco.Message.success({ content })
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** 失败消息。 */
|
|
67
|
+
export function messageError(content: string): ReturnType<typeof Arco.Message.info> {
|
|
68
|
+
injectFeedbackStyles()
|
|
69
|
+
bindContainer()
|
|
70
|
+
return Arco.Message.error({ content })
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** 警告消息。 */
|
|
74
|
+
export function messageWarning(content: string): ReturnType<typeof Arco.Message.info> {
|
|
75
|
+
injectFeedbackStyles()
|
|
76
|
+
bindContainer()
|
|
77
|
+
return Arco.Message.warning({ content })
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* 右上角的通知卡片。
|
|
82
|
+
*
|
|
83
|
+
* @param options - 与 Arco 的 `Notification` 一致。
|
|
84
|
+
* @returns 用于手动关闭的句柄。
|
|
85
|
+
*/
|
|
86
|
+
export function notification(options: NotificationOptions): ReturnType<typeof Arco.Notification.info> {
|
|
87
|
+
injectFeedbackStyles()
|
|
88
|
+
bindContainer()
|
|
89
|
+
return Arco.Notification.info(options)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** {@link Message} 组件本身,供需要内联渲染的场景使用。 */
|
|
93
|
+
export const Message: typeof Arco.Message = Arco.Message
|
|
94
|
+
|
|
95
|
+
/** {@link Notification} 命名空间,命令式通知。 */
|
|
96
|
+
export const Notification: typeof Arco.Notification = Arco.Notification
|
|
97
|
+
|
|
98
|
+
/** {@link Popconfirm} 的 props。 */
|
|
99
|
+
export type PopconfirmProps = React.ComponentPropsWithoutRef<typeof Arco.Popconfirm>
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* 气泡确认框,浮层由 `DshProvider` 的容器设置接管。
|
|
103
|
+
*
|
|
104
|
+
* @param props - 见 {@link PopconfirmProps}。
|
|
105
|
+
* @returns 确认气泡元素。
|
|
106
|
+
*/
|
|
107
|
+
export function Popconfirm(props: PopconfirmProps): React.ReactElement {
|
|
108
|
+
injectFeedbackStyles()
|
|
109
|
+
return <Arco.Popconfirm {...props} />
|
|
110
|
+
}
|
package/src/feedback/index.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 反馈与浮层出口。
|
|
3
|
-
*
|
|
4
|
-
* @module @dsh-plugin/dsh-ui-components/feedback
|
|
5
|
-
*/
|
|
6
|
-
export {
|
|
7
|
-
Message,
|
|
8
|
-
Notification,
|
|
9
|
-
Popconfirm,
|
|
10
|
-
message,
|
|
11
|
-
messageError,
|
|
12
|
-
messageSuccess,
|
|
13
|
-
messageWarning,
|
|
14
|
-
notification,
|
|
15
|
-
type PopconfirmProps,
|
|
16
|
-
} from './global.js'
|
|
17
|
-
export { Alert, Progress, Result, type AlertProps, type ProgressProps, type ResultProps } from './inline.js'
|
|
18
|
-
export { Drawer, Modal, confirm, type DrawerProps, type ModalConfirmOptions, type ModalProps } from './panel.js'
|
|
19
|
-
export { FEEDBACK_CSS, injectFeedbackStyles } from './styles.js'
|
|
1
|
+
/**
|
|
2
|
+
* 反馈与浮层出口。
|
|
3
|
+
*
|
|
4
|
+
* @module @dsh-plugin/dsh-ui-components/feedback
|
|
5
|
+
*/
|
|
6
|
+
export {
|
|
7
|
+
Message,
|
|
8
|
+
Notification,
|
|
9
|
+
Popconfirm,
|
|
10
|
+
message,
|
|
11
|
+
messageError,
|
|
12
|
+
messageSuccess,
|
|
13
|
+
messageWarning,
|
|
14
|
+
notification,
|
|
15
|
+
type PopconfirmProps,
|
|
16
|
+
} from './global.js'
|
|
17
|
+
export { Alert, Progress, Result, type AlertProps, type ProgressProps, type ResultProps } from './inline.js'
|
|
18
|
+
export { Drawer, Modal, confirm, type DrawerProps, type ModalConfirmOptions, type ModalProps } from './panel.js'
|
|
19
|
+
export { FEEDBACK_CSS, injectFeedbackStyles } from './styles.js'
|
package/src/feedback/inline.tsx
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 容器内的反馈组件:提示条、进度、结果。
|
|
3
|
-
*
|
|
4
|
-
* @module @dsh-plugin/dsh-ui-components/feedback/inline
|
|
5
|
-
*/
|
|
6
|
-
import * as React from 'react'
|
|
7
|
-
import { Arco } from '@dsh-plugin/dsh-loader/client'
|
|
8
|
-
import { injectFeedbackStyles } from './styles.js'
|
|
9
|
-
|
|
10
|
-
/** {@link Alert} 的 props。 */
|
|
11
|
-
export type AlertProps = React.ComponentPropsWithoutRef<typeof Arco.Alert>
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* 页面内的提示条,用于需要常驻的说明与警告。
|
|
15
|
-
*
|
|
16
|
-
* @param props - 见 {@link AlertProps}。
|
|
17
|
-
* @returns 提示条元素。
|
|
18
|
-
*/
|
|
19
|
-
export function Alert(props: AlertProps): React.ReactElement {
|
|
20
|
-
injectFeedbackStyles()
|
|
21
|
-
return <Arco.Alert {...props} />
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/** {@link Progress} 的 props。 */
|
|
25
|
-
export type ProgressProps = React.ComponentPropsWithoutRef<typeof Arco.Progress>
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* 进度条。
|
|
29
|
-
*
|
|
30
|
-
* @param props - 见 {@link ProgressProps}。
|
|
31
|
-
* @returns 进度条元素。
|
|
32
|
-
*/
|
|
33
|
-
export function Progress(props: ProgressProps): React.ReactElement {
|
|
34
|
-
injectFeedbackStyles()
|
|
35
|
-
return <Arco.Progress {...props} />
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/** {@link Result} 的 props。 */
|
|
39
|
-
export type ResultProps = React.ComponentPropsWithoutRef<typeof Arco.Result>
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* 结果页,用于操作完成、失败或无权限等终态。
|
|
43
|
-
*
|
|
44
|
-
* @param props - 见 {@link ResultProps}。
|
|
45
|
-
* @returns 结果页元素。
|
|
46
|
-
*/
|
|
47
|
-
export function Result(props: ResultProps): React.ReactElement {
|
|
48
|
-
injectFeedbackStyles()
|
|
49
|
-
return <Arco.Result {...props} />
|
|
50
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* 容器内的反馈组件:提示条、进度、结果。
|
|
3
|
+
*
|
|
4
|
+
* @module @dsh-plugin/dsh-ui-components/feedback/inline
|
|
5
|
+
*/
|
|
6
|
+
import * as React from 'react'
|
|
7
|
+
import { Arco } from '@dsh-plugin/dsh-loader/client'
|
|
8
|
+
import { injectFeedbackStyles } from './styles.js'
|
|
9
|
+
|
|
10
|
+
/** {@link Alert} 的 props。 */
|
|
11
|
+
export type AlertProps = React.ComponentPropsWithoutRef<typeof Arco.Alert>
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 页面内的提示条,用于需要常驻的说明与警告。
|
|
15
|
+
*
|
|
16
|
+
* @param props - 见 {@link AlertProps}。
|
|
17
|
+
* @returns 提示条元素。
|
|
18
|
+
*/
|
|
19
|
+
export function Alert(props: AlertProps): React.ReactElement {
|
|
20
|
+
injectFeedbackStyles()
|
|
21
|
+
return <Arco.Alert {...props} />
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** {@link Progress} 的 props。 */
|
|
25
|
+
export type ProgressProps = React.ComponentPropsWithoutRef<typeof Arco.Progress>
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 进度条。
|
|
29
|
+
*
|
|
30
|
+
* @param props - 见 {@link ProgressProps}。
|
|
31
|
+
* @returns 进度条元素。
|
|
32
|
+
*/
|
|
33
|
+
export function Progress(props: ProgressProps): React.ReactElement {
|
|
34
|
+
injectFeedbackStyles()
|
|
35
|
+
return <Arco.Progress {...props} />
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** {@link Result} 的 props。 */
|
|
39
|
+
export type ResultProps = React.ComponentPropsWithoutRef<typeof Arco.Result>
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 结果页,用于操作完成、失败或无权限等终态。
|
|
43
|
+
*
|
|
44
|
+
* @param props - 见 {@link ResultProps}。
|
|
45
|
+
* @returns 结果页元素。
|
|
46
|
+
*/
|
|
47
|
+
export function Result(props: ResultProps): React.ReactElement {
|
|
48
|
+
injectFeedbackStyles()
|
|
49
|
+
return <Arco.Result {...props} />
|
|
50
|
+
}
|
package/src/feedback/panel.tsx
CHANGED
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 弹窗与抽屉。
|
|
3
|
-
*
|
|
4
|
-
* 两者都按全局规范处理尺寸:与窗口顶部、底部各留至少 120px,最大高度
|
|
5
|
-
* `calc(100dvh - 240px)`,超出部分在内部滚动,标题与操作行保持可见。样式
|
|
6
|
-
* 已由 `feedback/styles` 落实,组件这一层只负责把 Arco 的 API 接到 DSH 的
|
|
7
|
-
* 语义上:`title`、`footer`、`content` 三个位置固定,`scroll` 打开时内容区
|
|
8
|
-
* 换成宿主统一的滚动容器。
|
|
9
|
-
*
|
|
10
|
-
* @module @dsh-plugin/dsh-ui-components/feedback/panel
|
|
11
|
-
*/
|
|
12
|
-
import * as React from 'react'
|
|
13
|
-
import { Arco, Scrollbar } from '@dsh-plugin/dsh-loader/client'
|
|
14
|
-
import { ensureOverlayContainer } from '../foundation/style.js'
|
|
15
|
-
import { injectFeedbackStyles } from './styles.js'
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* 把浮层挂到带皮肤变量的容器上。
|
|
19
|
-
*
|
|
20
|
-
* Arco 的 `Modal` 与 `Drawer` 自带 `getPopupContainer` 默认值,它直接返回
|
|
21
|
-
* `document.body` 且不读 `ConfigProvider`,因此这两类组件必须逐次传入,否则
|
|
22
|
-
* 弹层会在 body 层渲染,拿不到 `.dsh-ui` 上的 DSH 变量。
|
|
23
|
-
*
|
|
24
|
-
* @returns 浮层容器;服务端渲染时退回 `document.body`。
|
|
25
|
-
*/
|
|
26
|
-
function overlayContainer(): HTMLElement {
|
|
27
|
-
return ensureOverlayContainer() ?? document.body
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/** {@link Modal} 的 props。 */
|
|
31
|
-
export type ModalProps = Omit<React.ComponentPropsWithoutRef<typeof Arco.Modal>, 'children'> & {
|
|
32
|
-
/** 弹窗标题。 */
|
|
33
|
-
title?: React.ReactNode
|
|
34
|
-
/** 内容。 */
|
|
35
|
-
children?: React.ReactNode
|
|
36
|
-
/** 底部操作行。 */
|
|
37
|
-
footer?: React.ReactNode
|
|
38
|
-
/** 内容超出高度时是否启用宿主统一的滚动容器,默认启用。 */
|
|
39
|
-
scroll?: boolean
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* 居中弹窗。
|
|
44
|
-
*
|
|
45
|
-
* @param props - 见 {@link ModalProps}。
|
|
46
|
-
* @returns 弹窗元素。
|
|
47
|
-
*/
|
|
48
|
-
export function Modal({ title, children, footer, scroll = true, getPopupContainer, ...rest }: ModalProps): React.ReactElement {
|
|
49
|
-
injectFeedbackStyles()
|
|
50
|
-
const body = scroll === true ? <Scrollbar style={{ maxHeight: '100%' }}>{children}</Scrollbar> : children
|
|
51
|
-
return (
|
|
52
|
-
<Arco.Modal
|
|
53
|
-
{...rest}
|
|
54
|
-
getPopupContainer={getPopupContainer ?? overlayContainer}
|
|
55
|
-
title={title}
|
|
56
|
-
footer={footer}
|
|
57
|
-
alignCenter
|
|
58
|
-
>
|
|
59
|
-
{body}
|
|
60
|
-
</Arco.Modal>
|
|
61
|
-
)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/** {@link Modal.confirm} 的参数。 */
|
|
65
|
-
export type ModalConfirmOptions = Parameters<typeof Arco.Modal.confirm>[0]
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* 打开一个确认弹窗。
|
|
69
|
-
*
|
|
70
|
-
* @param options - 与 Arco 的 `Modal.confirm` 一致。
|
|
71
|
-
* @returns 可用于手动关闭的句柄。
|
|
72
|
-
*/
|
|
73
|
-
export function confirm(options: ModalConfirmOptions): ReturnType<typeof Arco.Modal.confirm> {
|
|
74
|
-
injectFeedbackStyles()
|
|
75
|
-
return Arco.Modal.confirm({
|
|
76
|
-
getPopupContainer: overlayContainer,
|
|
77
|
-
...options,
|
|
78
|
-
})
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/** {@link Drawer} 的 props。 */
|
|
82
|
-
export type DrawerProps = React.ComponentPropsWithoutRef<typeof Arco.Drawer>
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* 侧边抽屉,高度同样受 240px 上下留白约束。
|
|
86
|
-
*
|
|
87
|
-
* @param props - 见 {@link DrawerProps}。
|
|
88
|
-
* @returns 抽屉元素。
|
|
89
|
-
*/
|
|
90
|
-
export function Drawer({ getPopupContainer, ...props }: DrawerProps): React.ReactElement {
|
|
91
|
-
injectFeedbackStyles()
|
|
92
|
-
return <Arco.Drawer {...props} getPopupContainer={getPopupContainer ?? overlayContainer} />
|
|
93
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* 弹窗与抽屉。
|
|
3
|
+
*
|
|
4
|
+
* 两者都按全局规范处理尺寸:与窗口顶部、底部各留至少 120px,最大高度
|
|
5
|
+
* `calc(100dvh - 240px)`,超出部分在内部滚动,标题与操作行保持可见。样式
|
|
6
|
+
* 已由 `feedback/styles` 落实,组件这一层只负责把 Arco 的 API 接到 DSH 的
|
|
7
|
+
* 语义上:`title`、`footer`、`content` 三个位置固定,`scroll` 打开时内容区
|
|
8
|
+
* 换成宿主统一的滚动容器。
|
|
9
|
+
*
|
|
10
|
+
* @module @dsh-plugin/dsh-ui-components/feedback/panel
|
|
11
|
+
*/
|
|
12
|
+
import * as React from 'react'
|
|
13
|
+
import { Arco, Scrollbar } from '@dsh-plugin/dsh-loader/client'
|
|
14
|
+
import { ensureOverlayContainer } from '../foundation/style.js'
|
|
15
|
+
import { injectFeedbackStyles } from './styles.js'
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 把浮层挂到带皮肤变量的容器上。
|
|
19
|
+
*
|
|
20
|
+
* Arco 的 `Modal` 与 `Drawer` 自带 `getPopupContainer` 默认值,它直接返回
|
|
21
|
+
* `document.body` 且不读 `ConfigProvider`,因此这两类组件必须逐次传入,否则
|
|
22
|
+
* 弹层会在 body 层渲染,拿不到 `.dsh-ui` 上的 DSH 变量。
|
|
23
|
+
*
|
|
24
|
+
* @returns 浮层容器;服务端渲染时退回 `document.body`。
|
|
25
|
+
*/
|
|
26
|
+
function overlayContainer(): HTMLElement {
|
|
27
|
+
return ensureOverlayContainer() ?? document.body
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** {@link Modal} 的 props。 */
|
|
31
|
+
export type ModalProps = Omit<React.ComponentPropsWithoutRef<typeof Arco.Modal>, 'children'> & {
|
|
32
|
+
/** 弹窗标题。 */
|
|
33
|
+
title?: React.ReactNode
|
|
34
|
+
/** 内容。 */
|
|
35
|
+
children?: React.ReactNode
|
|
36
|
+
/** 底部操作行。 */
|
|
37
|
+
footer?: React.ReactNode
|
|
38
|
+
/** 内容超出高度时是否启用宿主统一的滚动容器,默认启用。 */
|
|
39
|
+
scroll?: boolean
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* 居中弹窗。
|
|
44
|
+
*
|
|
45
|
+
* @param props - 见 {@link ModalProps}。
|
|
46
|
+
* @returns 弹窗元素。
|
|
47
|
+
*/
|
|
48
|
+
export function Modal({ title, children, footer, scroll = true, getPopupContainer, ...rest }: ModalProps): React.ReactElement {
|
|
49
|
+
injectFeedbackStyles()
|
|
50
|
+
const body = scroll === true ? <Scrollbar style={{ maxHeight: '100%' }}>{children}</Scrollbar> : children
|
|
51
|
+
return (
|
|
52
|
+
<Arco.Modal
|
|
53
|
+
{...rest}
|
|
54
|
+
getPopupContainer={getPopupContainer ?? overlayContainer}
|
|
55
|
+
title={title}
|
|
56
|
+
footer={footer}
|
|
57
|
+
alignCenter
|
|
58
|
+
>
|
|
59
|
+
{body}
|
|
60
|
+
</Arco.Modal>
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** {@link Modal.confirm} 的参数。 */
|
|
65
|
+
export type ModalConfirmOptions = Parameters<typeof Arco.Modal.confirm>[0]
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* 打开一个确认弹窗。
|
|
69
|
+
*
|
|
70
|
+
* @param options - 与 Arco 的 `Modal.confirm` 一致。
|
|
71
|
+
* @returns 可用于手动关闭的句柄。
|
|
72
|
+
*/
|
|
73
|
+
export function confirm(options: ModalConfirmOptions): ReturnType<typeof Arco.Modal.confirm> {
|
|
74
|
+
injectFeedbackStyles()
|
|
75
|
+
return Arco.Modal.confirm({
|
|
76
|
+
getPopupContainer: overlayContainer,
|
|
77
|
+
...options,
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** {@link Drawer} 的 props。 */
|
|
82
|
+
export type DrawerProps = React.ComponentPropsWithoutRef<typeof Arco.Drawer>
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* 侧边抽屉,高度同样受 240px 上下留白约束。
|
|
86
|
+
*
|
|
87
|
+
* @param props - 见 {@link DrawerProps}。
|
|
88
|
+
* @returns 抽屉元素。
|
|
89
|
+
*/
|
|
90
|
+
export function Drawer({ getPopupContainer, ...props }: DrawerProps): React.ReactElement {
|
|
91
|
+
injectFeedbackStyles()
|
|
92
|
+
return <Arco.Drawer {...props} getPopupContainer={getPopupContainer ?? overlayContainer} />
|
|
93
|
+
}
|