@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/composites/panel.tsx
CHANGED
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 弹出层外壳。
|
|
3
|
-
*
|
|
4
|
-
* 插件自己实现的弹窗、面板、配置编辑器都用它,从而自动满足全局规范:与窗口
|
|
5
|
-
* 上下各留 120px、最大高度 `calc(100dvh - 240px)`、内容区内部滚动、标题与
|
|
6
|
-
* 操作行固定可见。内容滚动统一用 loader 的 `Scrollbar`。
|
|
7
|
-
*
|
|
8
|
-
* @module @dsh-plugin/dsh-ui-components/composites/panel
|
|
9
|
-
*/
|
|
10
|
-
import * as React from 'react'
|
|
11
|
-
import { Scrollbar } from '@dsh-plugin/dsh-loader/client'
|
|
12
|
-
import { cx } from '../foundation/style.js'
|
|
13
|
-
import { IconButton } from '../basic/icon-button.js'
|
|
14
|
-
import { Icon } from '../foundation/icons.js'
|
|
15
|
-
import { injectCompositeStyles } from './styles.js'
|
|
16
|
-
|
|
17
|
-
/** {@link PanelShell} 的 props。 */
|
|
18
|
-
export interface PanelShellProps {
|
|
19
|
-
/** 面板标题。 */
|
|
20
|
-
title?: React.ReactNode
|
|
21
|
-
/** 标题右侧关闭按钮的可访问名称;省略时不渲染关闭按钮。 */
|
|
22
|
-
closeLabel?: string
|
|
23
|
-
/** 关闭时回调。 */
|
|
24
|
-
onClose?: () => void
|
|
25
|
-
/** 底部操作区。 */
|
|
26
|
-
footer?: React.ReactNode
|
|
27
|
-
/** 内容。 */
|
|
28
|
-
children?: React.ReactNode
|
|
29
|
-
/** 追加类名。 */
|
|
30
|
-
className?: string
|
|
31
|
-
/** 关闭时是否渲染遮罩,默认渲染。 */
|
|
32
|
-
mask?: boolean
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* 一个居中的弹出面板,自带规范要求的留白与滚动行为。
|
|
37
|
-
*
|
|
38
|
-
* @param props - 见 {@link PanelShellProps}。
|
|
39
|
-
* @returns 面板元素。
|
|
40
|
-
*/
|
|
41
|
-
export function PanelShell({
|
|
42
|
-
title,
|
|
43
|
-
closeLabel,
|
|
44
|
-
onClose,
|
|
45
|
-
footer,
|
|
46
|
-
children,
|
|
47
|
-
className,
|
|
48
|
-
mask = true,
|
|
49
|
-
}: PanelShellProps): React.ReactElement {
|
|
50
|
-
injectCompositeStyles()
|
|
51
|
-
return (
|
|
52
|
-
<div className={cx('dsh-panel-shell', className)} role="dialog" aria-modal="true" aria-label={typeof title === 'string' ? title : undefined}>
|
|
53
|
-
{mask ? <div className="dsh-panel-shell__mask" onClick={onClose} /> : null}
|
|
54
|
-
<div className="dsh-panel-shell__card">
|
|
55
|
-
{title === undefined && closeLabel === undefined
|
|
56
|
-
? null
|
|
57
|
-
: (
|
|
58
|
-
<div className="dsh-panel-shell__header">
|
|
59
|
-
{title === undefined ? <span /> : <h2 className="dsh-panel-shell__title">{title}</h2>}
|
|
60
|
-
{closeLabel === undefined
|
|
61
|
-
? null
|
|
62
|
-
: <IconButton icon={<Icon name="Close" />} label={closeLabel} onClick={onClose} />}
|
|
63
|
-
</div>
|
|
64
|
-
)}
|
|
65
|
-
<div className="dsh-panel-shell__body">
|
|
66
|
-
<Scrollbar style={{ maxHeight: '100%' }}>{children}</Scrollbar>
|
|
67
|
-
</div>
|
|
68
|
-
{footer === undefined ? null : <div className="dsh-panel-shell__footer">{footer}</div>}
|
|
69
|
-
</div>
|
|
70
|
-
</div>
|
|
71
|
-
)
|
|
72
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* 弹出层外壳。
|
|
3
|
+
*
|
|
4
|
+
* 插件自己实现的弹窗、面板、配置编辑器都用它,从而自动满足全局规范:与窗口
|
|
5
|
+
* 上下各留 120px、最大高度 `calc(100dvh - 240px)`、内容区内部滚动、标题与
|
|
6
|
+
* 操作行固定可见。内容滚动统一用 loader 的 `Scrollbar`。
|
|
7
|
+
*
|
|
8
|
+
* @module @dsh-plugin/dsh-ui-components/composites/panel
|
|
9
|
+
*/
|
|
10
|
+
import * as React from 'react'
|
|
11
|
+
import { Scrollbar } from '@dsh-plugin/dsh-loader/client'
|
|
12
|
+
import { cx } from '../foundation/style.js'
|
|
13
|
+
import { IconButton } from '../basic/icon-button.js'
|
|
14
|
+
import { Icon } from '../foundation/icons.js'
|
|
15
|
+
import { injectCompositeStyles } from './styles.js'
|
|
16
|
+
|
|
17
|
+
/** {@link PanelShell} 的 props。 */
|
|
18
|
+
export interface PanelShellProps {
|
|
19
|
+
/** 面板标题。 */
|
|
20
|
+
title?: React.ReactNode
|
|
21
|
+
/** 标题右侧关闭按钮的可访问名称;省略时不渲染关闭按钮。 */
|
|
22
|
+
closeLabel?: string
|
|
23
|
+
/** 关闭时回调。 */
|
|
24
|
+
onClose?: () => void
|
|
25
|
+
/** 底部操作区。 */
|
|
26
|
+
footer?: React.ReactNode
|
|
27
|
+
/** 内容。 */
|
|
28
|
+
children?: React.ReactNode
|
|
29
|
+
/** 追加类名。 */
|
|
30
|
+
className?: string
|
|
31
|
+
/** 关闭时是否渲染遮罩,默认渲染。 */
|
|
32
|
+
mask?: boolean
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 一个居中的弹出面板,自带规范要求的留白与滚动行为。
|
|
37
|
+
*
|
|
38
|
+
* @param props - 见 {@link PanelShellProps}。
|
|
39
|
+
* @returns 面板元素。
|
|
40
|
+
*/
|
|
41
|
+
export function PanelShell({
|
|
42
|
+
title,
|
|
43
|
+
closeLabel,
|
|
44
|
+
onClose,
|
|
45
|
+
footer,
|
|
46
|
+
children,
|
|
47
|
+
className,
|
|
48
|
+
mask = true,
|
|
49
|
+
}: PanelShellProps): React.ReactElement {
|
|
50
|
+
injectCompositeStyles()
|
|
51
|
+
return (
|
|
52
|
+
<div className={cx('dsh-panel-shell', className)} role="dialog" aria-modal="true" aria-label={typeof title === 'string' ? title : undefined}>
|
|
53
|
+
{mask ? <div className="dsh-panel-shell__mask" onClick={onClose} /> : null}
|
|
54
|
+
<div className="dsh-panel-shell__card">
|
|
55
|
+
{title === undefined && closeLabel === undefined
|
|
56
|
+
? null
|
|
57
|
+
: (
|
|
58
|
+
<div className="dsh-panel-shell__header">
|
|
59
|
+
{title === undefined ? <span /> : <h2 className="dsh-panel-shell__title">{title}</h2>}
|
|
60
|
+
{closeLabel === undefined
|
|
61
|
+
? null
|
|
62
|
+
: <IconButton icon={<Icon name="Close" />} label={closeLabel} onClick={onClose} />}
|
|
63
|
+
</div>
|
|
64
|
+
)}
|
|
65
|
+
<div className="dsh-panel-shell__body">
|
|
66
|
+
<Scrollbar style={{ maxHeight: '100%' }}>{children}</Scrollbar>
|
|
67
|
+
</div>
|
|
68
|
+
{footer === undefined ? null : <div className="dsh-panel-shell__footer">{footer}</div>}
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
)
|
|
72
|
+
}
|
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 设置页卡片与设置行。
|
|
3
|
-
*
|
|
4
|
-
* 这两个组件对应宿主设置页的实际结构:一张卡片包住若干行「标签 + 说明 +
|
|
5
|
-
* 控件」,卡片用宿主的设置卡填充与描边令牌。插件写配置页时用它们,比直接用
|
|
6
|
-
* `Card` 更贴近宿主外观。
|
|
7
|
-
*
|
|
8
|
-
* @module @dsh-plugin/dsh-ui-components/composites/settings
|
|
9
|
-
*/
|
|
10
|
-
import * as React from 'react'
|
|
11
|
-
import { cx } from '../foundation/style.js'
|
|
12
|
-
import { injectCompositeStyles } from './styles.js'
|
|
13
|
-
|
|
14
|
-
/** {@link SettingsCard} 的 props。 */
|
|
15
|
-
export interface SettingsCardProps {
|
|
16
|
-
/** 卡片标题。 */
|
|
17
|
-
title?: React.ReactNode
|
|
18
|
-
/** 标题下方的说明。 */
|
|
19
|
-
description?: React.ReactNode
|
|
20
|
-
/** 卡片底部操作区,通常是保存与重置按钮。 */
|
|
21
|
-
footer?: React.ReactNode
|
|
22
|
-
/** 卡片内容,一般是一组 {@link SettingsRow}。 */
|
|
23
|
-
children?: React.ReactNode
|
|
24
|
-
/** 追加类名。 */
|
|
25
|
-
className?: string
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* 设置页中的一张卡片。
|
|
30
|
-
*
|
|
31
|
-
* @param props - 见 {@link SettingsCardProps}。
|
|
32
|
-
* @returns 卡片元素。
|
|
33
|
-
*/
|
|
34
|
-
export function SettingsCard({ title, description, footer, children, className }: SettingsCardProps): React.ReactElement {
|
|
35
|
-
injectCompositeStyles()
|
|
36
|
-
return (
|
|
37
|
-
<section className={cx('dsh-settings-card', className)}>
|
|
38
|
-
{title === undefined ? null : <h3 className="dsh-settings-card__title">{title}</h3>}
|
|
39
|
-
{description === undefined ? null : <p className="dsh-settings-card__desc">{description}</p>}
|
|
40
|
-
<div className="dsh-settings-card__body">{children}</div>
|
|
41
|
-
{footer === undefined ? null : <div className="dsh-settings-card__footer">{footer}</div>}
|
|
42
|
-
</section>
|
|
43
|
-
)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/** {@link SettingsRow} 的 props。 */
|
|
47
|
-
export interface SettingsRowProps {
|
|
48
|
-
/** 行标签。 */
|
|
49
|
-
label: React.ReactNode
|
|
50
|
-
/** 标签下方的说明。 */
|
|
51
|
-
description?: React.ReactNode
|
|
52
|
-
/** 控件。 */
|
|
53
|
-
children?: React.ReactNode
|
|
54
|
-
/**
|
|
55
|
-
* 布局。`inline` 让控件靠右,适合开关与短选择器;`stack` 让控件占满一行,
|
|
56
|
-
* 适合输入框与文本域。
|
|
57
|
-
*/
|
|
58
|
-
layout?: 'inline' | 'stack'
|
|
59
|
-
/** 追加类名。 */
|
|
60
|
-
className?: string
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* 设置页中的一行。
|
|
65
|
-
*
|
|
66
|
-
* @param props - 见 {@link SettingsRowProps}。
|
|
67
|
-
* @returns 设置行元素。
|
|
68
|
-
*/
|
|
69
|
-
export function SettingsRow({ label, description, children, layout = 'inline', className }: SettingsRowProps): React.ReactElement {
|
|
70
|
-
injectCompositeStyles()
|
|
71
|
-
return (
|
|
72
|
-
<div className={cx('dsh-settings-row', layout === 'stack' && 'dsh-settings-row--stack', className)}>
|
|
73
|
-
<div className="dsh-settings-row__text">
|
|
74
|
-
<span className="dsh-settings-row__label">{label}</span>
|
|
75
|
-
{description === undefined ? null : <span className="dsh-settings-row__desc">{description}</span>}
|
|
76
|
-
</div>
|
|
77
|
-
{children === undefined ? null : <div className="dsh-settings-row__control">{children}</div>}
|
|
78
|
-
</div>
|
|
79
|
-
)
|
|
80
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* 设置页卡片与设置行。
|
|
3
|
+
*
|
|
4
|
+
* 这两个组件对应宿主设置页的实际结构:一张卡片包住若干行「标签 + 说明 +
|
|
5
|
+
* 控件」,卡片用宿主的设置卡填充与描边令牌。插件写配置页时用它们,比直接用
|
|
6
|
+
* `Card` 更贴近宿主外观。
|
|
7
|
+
*
|
|
8
|
+
* @module @dsh-plugin/dsh-ui-components/composites/settings
|
|
9
|
+
*/
|
|
10
|
+
import * as React from 'react'
|
|
11
|
+
import { cx } from '../foundation/style.js'
|
|
12
|
+
import { injectCompositeStyles } from './styles.js'
|
|
13
|
+
|
|
14
|
+
/** {@link SettingsCard} 的 props。 */
|
|
15
|
+
export interface SettingsCardProps {
|
|
16
|
+
/** 卡片标题。 */
|
|
17
|
+
title?: React.ReactNode
|
|
18
|
+
/** 标题下方的说明。 */
|
|
19
|
+
description?: React.ReactNode
|
|
20
|
+
/** 卡片底部操作区,通常是保存与重置按钮。 */
|
|
21
|
+
footer?: React.ReactNode
|
|
22
|
+
/** 卡片内容,一般是一组 {@link SettingsRow}。 */
|
|
23
|
+
children?: React.ReactNode
|
|
24
|
+
/** 追加类名。 */
|
|
25
|
+
className?: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 设置页中的一张卡片。
|
|
30
|
+
*
|
|
31
|
+
* @param props - 见 {@link SettingsCardProps}。
|
|
32
|
+
* @returns 卡片元素。
|
|
33
|
+
*/
|
|
34
|
+
export function SettingsCard({ title, description, footer, children, className }: SettingsCardProps): React.ReactElement {
|
|
35
|
+
injectCompositeStyles()
|
|
36
|
+
return (
|
|
37
|
+
<section className={cx('dsh-settings-card', className)}>
|
|
38
|
+
{title === undefined ? null : <h3 className="dsh-settings-card__title">{title}</h3>}
|
|
39
|
+
{description === undefined ? null : <p className="dsh-settings-card__desc">{description}</p>}
|
|
40
|
+
<div className="dsh-settings-card__body">{children}</div>
|
|
41
|
+
{footer === undefined ? null : <div className="dsh-settings-card__footer">{footer}</div>}
|
|
42
|
+
</section>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** {@link SettingsRow} 的 props。 */
|
|
47
|
+
export interface SettingsRowProps {
|
|
48
|
+
/** 行标签。 */
|
|
49
|
+
label: React.ReactNode
|
|
50
|
+
/** 标签下方的说明。 */
|
|
51
|
+
description?: React.ReactNode
|
|
52
|
+
/** 控件。 */
|
|
53
|
+
children?: React.ReactNode
|
|
54
|
+
/**
|
|
55
|
+
* 布局。`inline` 让控件靠右,适合开关与短选择器;`stack` 让控件占满一行,
|
|
56
|
+
* 适合输入框与文本域。
|
|
57
|
+
*/
|
|
58
|
+
layout?: 'inline' | 'stack'
|
|
59
|
+
/** 追加类名。 */
|
|
60
|
+
className?: string
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* 设置页中的一行。
|
|
65
|
+
*
|
|
66
|
+
* @param props - 见 {@link SettingsRowProps}。
|
|
67
|
+
* @returns 设置行元素。
|
|
68
|
+
*/
|
|
69
|
+
export function SettingsRow({ label, description, children, layout = 'inline', className }: SettingsRowProps): React.ReactElement {
|
|
70
|
+
injectCompositeStyles()
|
|
71
|
+
return (
|
|
72
|
+
<div className={cx('dsh-settings-row', layout === 'stack' && 'dsh-settings-row--stack', className)}>
|
|
73
|
+
<div className="dsh-settings-row__text">
|
|
74
|
+
<span className="dsh-settings-row__label">{label}</span>
|
|
75
|
+
{description === undefined ? null : <span className="dsh-settings-row__desc">{description}</span>}
|
|
76
|
+
</div>
|
|
77
|
+
{children === undefined ? null : <div className="dsh-settings-row__control">{children}</div>}
|
|
78
|
+
</div>
|
|
79
|
+
)
|
|
80
|
+
}
|