niuma-ui 1.3.0 → 1.3.2

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.
Files changed (54) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/components/RsButton.css +119 -61
  3. package/dist/components/RsButton.d.ts +3 -3
  4. package/dist/components/RsButton.impl.js +4 -12
  5. package/dist/components/RsButton.js +1 -1
  6. package/dist/components/RsDialog.css +1 -0
  7. package/dist/components/RsDialog.d.ts +5 -0
  8. package/dist/components/RsDialog.impl.js +4 -0
  9. package/dist/components/RsDrawer.css +1 -0
  10. package/dist/components/RsFieldset.css +92 -0
  11. package/dist/components/RsFieldset.d.ts +61 -0
  12. package/dist/components/RsFieldset.impl.js +78 -0
  13. package/dist/components/RsFieldset.js +8 -0
  14. package/dist/components/RsFormItem.css +19 -19
  15. package/dist/components/RsFormItem.d.ts +6 -4
  16. package/dist/components/RsFormItem.impl.js +12 -2
  17. package/dist/components/RsFormItem.js +1 -1
  18. package/dist/components/RsInput.css +78 -69
  19. package/dist/components/RsInput.js +1 -1
  20. package/dist/components/RsLog.css +198 -0
  21. package/dist/components/RsLog.d.ts +126 -0
  22. package/dist/components/RsLog.impl.js +619 -0
  23. package/dist/components/RsLog.js +8 -0
  24. package/dist/components/RsTable.impl.js +2 -1
  25. package/dist/components/RsTextarea.css +126 -0
  26. package/dist/components/RsTextarea.d.ts +114 -0
  27. package/dist/components/RsTextarea.impl.js +385 -0
  28. package/dist/components/RsTextarea.js +8 -0
  29. package/dist/components/RsTooltip.css +4 -3
  30. package/dist/components/RsTooltip.d.ts +2 -0
  31. package/dist/components/RsTooltip.impl.js +5 -2
  32. package/dist/components/RsVirtualList.css +6 -6
  33. package/dist/components/RsVirtualList.d.ts +1 -1
  34. package/dist/components/RsVirtualList.impl.js +9 -4
  35. package/dist/components/RsVirtualList.js +1 -1
  36. package/dist/components/button-utils.d.ts +19 -10
  37. package/dist/components/button-utils.js +22 -7
  38. package/dist/components/dialog-window.d.ts +2 -0
  39. package/dist/components/dialog-window.js +2 -1
  40. package/dist/components/fieldset-utils.d.ts +29 -0
  41. package/dist/components/fieldset-utils.js +12 -0
  42. package/dist/components/log-utils.d.ts +105 -0
  43. package/dist/components/log-utils.js +354 -0
  44. package/dist/components/table/rs-table-props.d.ts +8 -0
  45. package/dist/components/table/rs-table-props.js +1 -0
  46. package/dist/components/table/rs-table.css +7 -0
  47. package/dist/index.d.ts +10 -2
  48. package/dist/index.js +24 -0
  49. package/dist/lib/rs-dayjs.js +1 -1
  50. package/dist/locale/messages.js +42 -0
  51. package/dist/styles.css +37 -0
  52. package/dist/vite-plugins/niuma-ui-host.d.ts +8 -0
  53. package/dist/vite-plugins/niuma-ui-host.js +47 -9
  54. package/package.json +1 -1
@@ -1,29 +1,29 @@
1
1
 
2
- .rs-virtual-list[data-v-c2c4b7ba] {
2
+ .rs-virtual-list[data-v-808bf3fd] {
3
3
  overflow: auto;
4
4
  border: 1px solid var(--rs-border-subtle);
5
5
  border-radius: var(--rs-virtual-list-radius, var(--rs-radius-sm));
6
6
  }
7
- .rs-virtual-list--fill[data-v-c2c4b7ba] {
7
+ .rs-virtual-list--fill[data-v-808bf3fd] {
8
8
  flex: 1;
9
9
  align-self: stretch;
10
10
  width: 100%;
11
11
  min-height: 0;
12
12
  height: 0;
13
13
  }
14
- .rs-virtual-list__spacer[data-v-c2c4b7ba] {
14
+ .rs-virtual-list__spacer[data-v-808bf3fd] {
15
15
  position: relative;
16
16
  }
17
- .rs-virtual-list__items[data-v-c2c4b7ba] {
17
+ .rs-virtual-list__items[data-v-808bf3fd] {
18
18
  position: absolute;
19
19
  left: 0;
20
20
  right: 0;
21
21
  top: 0;
22
22
  }
23
- .rs-virtual-list__item[data-v-c2c4b7ba] {
23
+ .rs-virtual-list__item[data-v-808bf3fd] {
24
24
  box-sizing: border-box;
25
25
  }
26
- .rs-virtual-list__item--active[data-v-c2c4b7ba] {
26
+ .rs-virtual-list__item--active[data-v-808bf3fd] {
27
27
  background: color-mix(in srgb, var(--rs-primary) 14%, var(--rs-surface));
28
28
  box-shadow: inset 2px 0 0 var(--rs-primary);
29
29
  }
@@ -15,7 +15,7 @@ declare const __VLS_export: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_se
15
15
  __VLS_PROPS_FALLBACK: infer P;
16
16
  } ? P : {});
17
17
  expose: (exposed: import("vue").ShallowUnwrapRef<{
18
- scrollToIndex: (index: number) => void;
18
+ scrollToIndex: (index: number, align?: "nearest" | "center" | "start" | "end") => void;
19
19
  }>) => void;
20
20
  attrs: any;
21
21
  slots: {
@@ -89,17 +89,22 @@ var RsVirtualList_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ de
89
89
  })));
90
90
  const totalHeight = computed(() => props.items.length * fixedItemSize.value);
91
91
  const offsetY = computed(() => startIndex.value * fixedItemSize.value);
92
- function scrollToIndex(index) {
92
+ function scrollToIndex(index, align = "center") {
93
93
  const el = rootRef.value;
94
94
  if (!el || index < 0 || index >= props.items.length) return;
95
95
  const itemTop = index * fixedItemSize.value;
96
96
  const itemBottom = itemTop + fixedItemSize.value;
97
97
  const viewTop = el.scrollTop;
98
98
  const viewBottom = viewTop + el.clientHeight;
99
- if (itemTop >= viewTop && itemBottom <= viewBottom) return;
99
+ if (align === "nearest" && itemTop >= viewTop && itemBottom <= viewBottom) return;
100
100
  const maxScroll = Math.max(0, totalHeight.value - el.clientHeight);
101
- const centered = itemTop - (el.clientHeight - fixedItemSize.value) / 2;
102
- el.scrollTop = Math.min(maxScroll, Math.max(0, centered));
101
+ let next = itemTop - (el.clientHeight - fixedItemSize.value) / 2;
102
+ if (align === "start") next = itemTop;
103
+ if (align === "end") next = itemBottom - el.clientHeight;
104
+ if (align === "nearest") if (itemTop < viewTop) next = itemTop;
105
+ else if (itemBottom > viewBottom) next = itemBottom - el.clientHeight;
106
+ else return;
107
+ el.scrollTop = Math.min(maxScroll, Math.max(0, next));
103
108
  scrollTop.value = el.scrollTop;
104
109
  }
105
110
  watch(() => [props.activeIndex, props.items.length], async ([index, length]) => {
@@ -3,6 +3,6 @@ import _plugin_vue_export_helper_default from "../_virtual/_plugin-vue_export-he
3
3
  import RsVirtualList_vue_vue_type_script_setup_true_lang_default from "./RsVirtualList.impl.js";
4
4
 
5
5
  //#region src/components/RsVirtualList.vue
6
- var RsVirtualList_default = /*#__PURE__*/ _plugin_vue_export_helper_default(RsVirtualList_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-c2c4b7ba"]]);
6
+ var RsVirtualList_default = /*#__PURE__*/ _plugin_vue_export_helper_default(RsVirtualList_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-808bf3fd"]]);
7
7
  //#endregion
8
8
  export { RsVirtualList_default as default };
@@ -1,17 +1,26 @@
1
1
  /**
2
- * RsButton 外观变体
3
- * - primary / default / ghost / danger:常规控件按钮
4
- * - link:行内链接态(可带下划线)
5
- * - text:工具栏/表格操作等 quaternary 文字按钮(无底无边,靠 tone 着色)
2
+ * RsButton 外观变体(形态,与 tone 正交)
3
+ * - primary:实心
4
+ * - default / secondary:轮廓 + 浅底(secondary 等价 default)
5
+ * - ghost:透明底 + 描边
6
+ * - text:无底无边
7
+ * - link:行内链接
8
+ * - danger:兼容别名,等价 primary + tone="danger" 的历史实心底(保留独立样式)
6
9
  */
7
10
  export type RsButtonVariant = 'primary' | 'default' | 'secondary' | 'ghost' | 'danger' | 'link' | 'text';
8
11
  /**
9
- * RsButton 语义色调
10
- * 主要用于 text / ghost / link:只改文字与图标色,不改变填充形态。
11
- * 对 primary / default / danger 等填充变体将被忽略。
12
+ * RsButton 语义色(色相,与 variant 正交)
13
+ * 对齐 Ant Design color / Element Plus type / Naive UI type:
14
+ * `variant="default" tone="warning"` → 描边 + 浅底 + 警告色。
12
15
  */
13
16
  export type RsButtonTone = 'neutral' | 'primary' | 'danger' | 'success' | 'warning' | 'info';
14
- /** 填充类变体:已自带语义色,不再叠加 tone */
17
+ /** 规范化变体:未传为 primary;secondary 视为 default。 */
18
+ export declare function resolveRsButtonVariant(variant?: RsButtonVariant): Exclude<RsButtonVariant, 'secondary'>;
19
+ /**
20
+ * 解析语义色。未传 tone 时:primary/link 用 primary,danger 变体用 danger,其余 neutral。
21
+ */
22
+ export declare function resolveRsButtonTone(variant?: RsButtonVariant, tone?: RsButtonTone): RsButtonTone;
23
+ /** 实心/轮廓填充类变体(相对 text / ghost / link)。 */
15
24
  export declare function isRsButtonFilledVariant(variant: RsButtonVariant): boolean;
16
- /** text / ghost / link 可叠加 tone */
17
- export declare function supportsRsButtonTone(variant: RsButtonVariant): boolean;
25
+ /** 所有变体都可叠加 tone(形态 × 色相)。 */
26
+ export declare function supportsRsButtonTone(_variant?: RsButtonVariant): boolean;
@@ -1,13 +1,28 @@
1
1
  //#region src/components/button-utils.ts
2
- /** 填充类变体:已自带语义色,不再叠加 tone */
2
+ /** 规范化变体:未传为 primary;secondary 视为 default。 */
3
+ function resolveRsButtonVariant(variant) {
4
+ if (variant === "secondary") return "default";
5
+ if (!variant) return "primary";
6
+ return variant;
7
+ }
8
+ /**
9
+ * 解析语义色。未传 tone 时:primary/link 用 primary,danger 变体用 danger,其余 neutral。
10
+ */
11
+ function resolveRsButtonTone(variant, tone) {
12
+ if (tone) return tone;
13
+ const resolved = resolveRsButtonVariant(variant);
14
+ if (resolved === "danger") return "danger";
15
+ if (resolved === "primary" || resolved === "link") return "primary";
16
+ return "neutral";
17
+ }
18
+ /** 实心/轮廓填充类变体(相对 text / ghost / link)。 */
3
19
  function isRsButtonFilledVariant(variant) {
4
- const resolved = variant === "secondary" ? "default" : variant;
20
+ const resolved = resolveRsButtonVariant(variant);
5
21
  return resolved === "primary" || resolved === "default" || resolved === "danger";
6
22
  }
7
- /** text / ghost / link 可叠加 tone */
8
- function supportsRsButtonTone(variant) {
9
- const resolved = variant === "secondary" ? "default" : variant;
10
- return resolved === "text" || resolved === "ghost" || resolved === "link";
23
+ /** 所有变体都可叠加 tone(形态 × 色相)。 */
24
+ function supportsRsButtonTone(_variant) {
25
+ return true;
11
26
  }
12
27
  //#endregion
13
- export { isRsButtonFilledVariant, supportsRsButtonTone };
28
+ export { isRsButtonFilledVariant, resolveRsButtonTone, resolveRsButtonVariant, supportsRsButtonTone };
@@ -14,6 +14,8 @@ export declare function useRsDialogWindow(options: {
14
14
  widthPreset: Ref<RsDialogWidthPreset>;
15
15
  /** 自定义初始宽度(px);有值时优先于预设/比例 */
16
16
  initialWidth?: Ref<number | undefined>;
17
+ /** 自定义初始高度(px);有值时优先于默认 75% 视口高 */
18
+ initialHeight?: Ref<number | undefined>;
17
19
  draggable: Ref<boolean>;
18
20
  resizable: Ref<boolean>;
19
21
  compact?: Ref<boolean>;
@@ -62,9 +62,10 @@ function useRsDialogWindow(options) {
62
62
  function defaultWindowSize() {
63
63
  const { width: maxW, height: maxH } = dialogViewportSize();
64
64
  const customW = options.initialWidth?.value;
65
+ const customH = options.initialHeight?.value;
65
66
  return {
66
67
  width: customW != null && Number.isFinite(customW) && customW > 0 ? Math.min(maxW, Math.max(minWidth, Math.round(customW))) : Math.min(maxW, Math.max(minWidth, Math.round(maxW * defaultWidthRatio))),
67
- height: Math.min(maxH, Math.max(minHeight, Math.round(maxH * defaultHeightRatio)))
68
+ height: customH != null && Number.isFinite(customH) && customH > 0 ? Math.min(maxH, Math.max(minHeight, Math.round(customH))) : Math.min(maxH, Math.max(minHeight, Math.round(maxH * defaultHeightRatio)))
68
69
  };
69
70
  }
70
71
  function refreshCachedInsets() {
@@ -0,0 +1,29 @@
1
+ import type { RsFontSize, RsFontWeight } from '../theme/types';
2
+ /**
3
+ * 表单分组密度。只影响内边距与组内间距,不改变控件高度。
4
+ */
5
+ export type RsFieldsetSize = 'sm' | 'md';
6
+ /**
7
+ * 边框线型。对齐 CSS `border-style`(solid / dashed / dotted)。
8
+ */
9
+ export type RsFieldsetBorderStyle = 'solid' | 'dashed' | 'dotted';
10
+ /**
11
+ * 边框浓度。
12
+ * - default:主题分隔线
13
+ * - subtle:弱分隔
14
+ * - faded:虚化(降低不透明度)
15
+ */
16
+ export type RsFieldsetBorderTone = 'default' | 'subtle' | 'faded';
17
+ /**
18
+ * 标题对比(清晰度)。
19
+ * - strong:最高对比
20
+ * - default:正文色
21
+ * - muted:次要说明色
22
+ */
23
+ export type RsFieldsetTitleTone = 'strong' | 'default' | 'muted';
24
+ /** 分组标题字号,只开放 caption / 次要 / 正文三档。 */
25
+ export type RsFieldsetTitleSize = Extract<RsFontSize, 'xs' | 'sm' | 'base'>;
26
+ /** 解析标题字号 token。 */
27
+ export declare function resolveFieldsetTitleSize(size: RsFieldsetTitleSize): string;
28
+ /** 解析标题字重 token。 */
29
+ export declare function resolveFieldsetTitleWeight(weight: RsFontWeight): string;
@@ -0,0 +1,12 @@
1
+ import { RS_FONT_SIZE_CSS, RS_FONT_WEIGHT_CSS } from "../theme/types.js";
2
+ //#region src/components/fieldset-utils.ts
3
+ /** 解析标题字号 token。 */
4
+ function resolveFieldsetTitleSize(size) {
5
+ return RS_FONT_SIZE_CSS[size];
6
+ }
7
+ /** 解析标题字重 token。 */
8
+ function resolveFieldsetTitleWeight(weight) {
9
+ return RS_FONT_WEIGHT_CSS[weight];
10
+ }
11
+ //#endregion
12
+ export { resolveFieldsetTitleSize, resolveFieldsetTitleWeight };
@@ -0,0 +1,105 @@
1
+ /** 展示与过滤用的级别。success 是 UI 结果,不是 RFC 严重级别。 */
2
+ export type RsLogLevel = 'trace' | 'debug' | 'info' | 'notice' | 'success' | 'warn' | 'error' | 'fatal' | 'plain';
3
+ /** 数字严重级别的标尺。auto:0–7 当 syslog,更大当 OTel。 */
4
+ export type RsLogSeverityScale = 'syslog' | 'otel' | 'auto';
5
+ /** 调用方补充的成功 / 失败等标识。字符串按拉丁词边界匹配(中日韩按子串),也可传 RegExp。 */
6
+ export type RsLogMarker = string | RegExp;
7
+ /** 未写 level 时,在内置扫描之后用这些标识给正文上色。默认不启用。 */
8
+ export type RsLogInferMarkers = {
9
+ [K in Exclude<RsLogLevel, 'plain'>]?: readonly RsLogMarker[];
10
+ };
11
+ export type InferLogLevelOptions = {
12
+ markers?: RsLogInferMarkers;
13
+ };
14
+ /** 一条结构化日志。level 缺省时可由 infer / severity 得出。 */
15
+ export type RsLogLine = {
16
+ id?: string | number;
17
+ text: string;
18
+ /** 规范级别或别名(warning / critical…),由 parseRsLogLevel 收口 */
19
+ level?: string;
20
+ /** RFC 5424 0–7 或 OTel 1–24;未写 level 时参与解析 */
21
+ severity?: number;
22
+ time?: string | number | Date;
23
+ };
24
+ export type RsLogLineInput = string | RsLogLine;
25
+ /** 渲染用的归一化行。key 稳定,供虚拟列表复用。 */
26
+ export type RsNormalizedLogLine = {
27
+ key: string;
28
+ text: string;
29
+ level: RsLogLevel;
30
+ time?: string;
31
+ /** 裁剪后的 1-based 序号 */
32
+ seq: number;
33
+ /** RFC 5424 Severity,plain 为 null */
34
+ syslog: number | null;
35
+ /** OpenTelemetry severity number,plain 为 null */
36
+ otel: number | null;
37
+ };
38
+ export declare const RS_LOG_LEVELS: readonly RsLogLevel[];
39
+ /** 可过滤的级别(不含 plain)。 */
40
+ export declare const RS_LOG_FILTER_LEVELS: readonly RsLogLevel[];
41
+ export declare function isRsLogLevel(value: unknown): value is RsLogLevel;
42
+ /** RFC 5424 Severity(0–7)。plain 返回 null。 */
43
+ export declare function syslogSeverityOf(level: RsLogLevel): number | null;
44
+ /** OpenTelemetry severity number。plain 返回 null。 */
45
+ export declare function otelSeverityOf(level: RsLogLevel): number | null;
46
+ /**
47
+ * 把别名、syslog 0–7、OTel 1–24 收成规范级别。
48
+ * 无法识别时返回 undefined,由调用方决定是否再推断。
49
+ */
50
+ export declare function parseRsLogLevel(value: unknown, scale?: RsLogSeverityScale): RsLogLevel | undefined;
51
+ /** 把任意输入收成日志行数组:字符串按行拆,对象原样保留。 */
52
+ export declare function asLogLineInputs(input: string | RsLogLineInput | RsLogLineInput[]): RsLogLineInput[];
53
+ /** 拆成行。统一 CRLF;去掉末尾空行,避免 textarea 尾巴多一行。 */
54
+ export declare function splitLogText(text: string): string[];
55
+ /**
56
+ * 从一行正文推断语义色。
57
+ * 1. [error] / [ok] 等方括号级别(别名走 parseRsLogLevel)
58
+ * 2. 行首级别词,如 ERROR: / WARN
59
+ * 3. 工具链行首:BUILD SUCCESS / BUILD FAILURE / Exception in thread / panic:
60
+ * 4. 调用方 markers:成功 / 失败等产品标识(默认不扫)
61
+ * 行上已有 level / severity 时不会走到这里。
62
+ */
63
+ export declare function inferLogLevel(text: string, options?: InferLogLevelOptions): RsLogLevel;
64
+ /** 能解析的瞬间走 Intl;已是展示串则原样保留。 */
65
+ export declare function formatLogTime(value: string | number | Date | undefined, locale?: string, options?: Intl.DateTimeFormatOptions): string | undefined;
66
+ export type NormalizeLogLinesOptions = {
67
+ inferLevel?: boolean;
68
+ /** 传给 inferLogLevel 的成功 / 失败等标识。inferLevel 为 false 时不使用。 */
69
+ inferMarkers?: RsLogInferMarkers;
70
+ maxLines?: number;
71
+ severityScale?: RsLogSeverityScale;
72
+ locale?: string;
73
+ timeFormat?: Intl.DateTimeFormatOptions;
74
+ };
75
+ /** 把 string / 行对象收成渲染结构。inferLevel 默认开。 */
76
+ export declare function normalizeLogLines(source: string | RsLogLineInput[] | undefined | null, options?: NormalizeLogLinesOptions): RsNormalizedLogLine[];
77
+ /** 把一行收成可写回 v-model 的结构(字符串保持字符串)。 */
78
+ export declare function toLogLineInput(input: RsLogLineInput): RsLogLineInput;
79
+ export declare function joinLogLines(lines: Array<{
80
+ text: string;
81
+ }>): string;
82
+ export declare function clampLogCount<T>(items: T[], maxLines?: number): T[];
83
+ export declare function filterLogLines(lines: RsNormalizedLogLine[], options?: {
84
+ levels?: readonly RsLogLevel[];
85
+ search?: string;
86
+ }): RsNormalizedLogLine[];
87
+ export type RsLogHighlightPart = {
88
+ text: string;
89
+ hit: boolean;
90
+ };
91
+ /** 按查询切开正文,供搜索高亮。大小写不敏感。 */
92
+ export declare function splitLogHighlight(text: string, query: string): RsLogHighlightPart[];
93
+ export declare function resolveLogLive(live?: boolean | 'off' | 'polite' | 'assertive'): 'off' | 'polite' | 'assertive';
94
+ export declare function countDroppedLines(total: number, maxLines?: number): number;
95
+ export type RsLogCopySource = 'selection' | 'line' | 'visible' | 'all';
96
+ /** 复制优先级:选区 > 全文 > 当前行 > 可见行(含搜索过滤结果)。 */
97
+ export declare function resolveLogCopyText(options: {
98
+ selection?: string;
99
+ activeText?: string;
100
+ visibleTexts: string[];
101
+ allTexts?: string[];
102
+ }): {
103
+ text: string;
104
+ source: RsLogCopySource;
105
+ };