@mtn-ui/components 0.0.6 → 0.0.7

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 (46) hide show
  1. package/dist/button/index.js +1 -1
  2. package/dist/chunks/{Button.vue_vue_type_script_setup_true_lang-CfbO8ovs.js → Button.vue_vue_type_script_setup_true_lang-C2Vc6-OE.js} +965 -927
  3. package/dist/chunks/{Button.vue_vue_type_script_setup_true_lang-CfbO8ovs.js.map → Button.vue_vue_type_script_setup_true_lang-C2Vc6-OE.js.map} +1 -1
  4. package/dist/index/index.js +33419 -9303
  5. package/dist/index/index.js.map +1 -1
  6. package/dist/index/style.css +1 -1
  7. package/dist/resolver/index.js +33 -20
  8. package/dist/resolver/index.js.map +1 -1
  9. package/dist/types/auto-tooltip/AutoTooltip.d.ts +61 -0
  10. package/dist/types/auto-tooltip/index.d.ts +2 -0
  11. package/dist/types/auto-tooltip/types.d.ts +14 -0
  12. package/dist/types/content-container/ContentContainer.d.ts +48 -0
  13. package/dist/types/content-container/index.d.ts +2 -0
  14. package/dist/types/content-container/types.d.ts +12 -0
  15. package/dist/types/dict-badge/DictBadge.d.ts +48 -0
  16. package/dist/types/dict-badge/index.d.ts +2 -0
  17. package/dist/types/dict-badge/types.d.ts +23 -0
  18. package/dist/types/dict-checkbox/DictCheckbox.d.ts +54 -0
  19. package/dist/types/dict-checkbox/index.d.ts +2 -0
  20. package/dist/types/dict-checkbox/types.d.ts +23 -0
  21. package/dist/types/dict-radio/DictRadio.d.ts +57 -0
  22. package/dist/types/dict-radio/index.d.ts +2 -0
  23. package/dist/types/dict-radio/types.d.ts +25 -0
  24. package/dist/types/dict-select/DictSelect.d.ts +61 -0
  25. package/dist/types/dict-select/index.d.ts +2 -0
  26. package/dist/types/dict-select/types.d.ts +22 -0
  27. package/dist/types/dict-tag/DictTag.d.ts +48 -0
  28. package/dist/types/dict-tag/index.d.ts +2 -0
  29. package/dist/types/dict-tag/types.d.ts +23 -0
  30. package/dist/types/form-item/FormItem.d.ts +39 -0
  31. package/dist/types/form-item/constants.d.ts +9 -0
  32. package/dist/types/form-item/index.d.ts +4 -0
  33. package/dist/types/form-item/types.d.ts +46 -0
  34. package/dist/types/form-item/validator.d.ts +1 -0
  35. package/dist/types/form-renderer/FormRenderer.d.ts +37 -0
  36. package/dist/types/form-renderer/helpers.d.ts +9 -0
  37. package/dist/types/form-renderer/index.d.ts +3 -0
  38. package/dist/types/form-renderer/types.d.ts +13 -0
  39. package/dist/types/form-row/FormRow.d.ts +33 -0
  40. package/dist/types/form-row/index.d.ts +2 -0
  41. package/dist/types/form-row/types.d.ts +11 -0
  42. package/dist/types/index.d.ts +22 -0
  43. package/dist/types/search-bar/SearchBar.d.ts +60 -0
  44. package/dist/types/search-bar/index.d.ts +2 -0
  45. package/dist/types/search-bar/types.d.ts +58 -0
  46. package/package.json +2 -2
@@ -0,0 +1,23 @@
1
+ import { DictItem } from '@mtn-ui/utils';
2
+
3
+ export type { DictItem };
4
+ export interface DictTagProps {
5
+ /** 要展示的字典值(dictValue),根据此值在字典中查找 label 与 color */
6
+ value?: string | number;
7
+ /** 字典列表,优先级高于 dictType */
8
+ options?: DictItem[];
9
+ /** 字典类型,从 localStorage 读取(key = storageKeyPrefix + dictType) */
10
+ dictType?: string;
11
+ /** 展示字段名 */
12
+ labelKey?: string;
13
+ /** 值字段名 */
14
+ valueKey?: string;
15
+ /** 颜色字段名,用于 Tag 的 color */
16
+ colorKey?: string;
17
+ /** localStorage 的 key 前缀 */
18
+ storageKeyPrefix?: string;
19
+ /** 未匹配到字典项时展示的占位文案 */
20
+ placeholder?: string;
21
+ /** 自定义类名 */
22
+ class?: string;
23
+ }
@@ -0,0 +1,39 @@
1
+ import { FormItemProps } from './types';
2
+
3
+ declare function __VLS_template(): {
4
+ append?(_: {}): any;
5
+ };
6
+ declare const __VLS_component: import('vue').DefineComponent<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<FormItemProps>, {
7
+ show: boolean;
8
+ showLabel: boolean;
9
+ }>>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<FormItemProps>, {
10
+ show: boolean;
11
+ showLabel: boolean;
12
+ }>>> & Readonly<{}>, {
13
+ showLabel: boolean;
14
+ show: boolean;
15
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
16
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
17
+ export default _default;
18
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
19
+ type __VLS_TypePropsToRuntimeProps<T> = {
20
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
21
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
22
+ } : {
23
+ type: import('vue').PropType<T[K]>;
24
+ required: true;
25
+ };
26
+ };
27
+ type __VLS_WithDefaults<P, D> = {
28
+ [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
29
+ default: D[K];
30
+ }> : P[K];
31
+ };
32
+ type __VLS_Prettify<T> = {
33
+ [K in keyof T]: T[K];
34
+ } & {};
35
+ type __VLS_WithTemplateSlots<T, S> = T & {
36
+ new (): {
37
+ $slots: S;
38
+ };
39
+ };
@@ -0,0 +1,9 @@
1
+ import { FormItemType } from './types';
2
+
3
+ export declare const COMPONENT_MAP: Partial<Record<Exclude<FormItemType, 'custom'>, unknown>>;
4
+ /** 不传给 a-form-item 的 props;label 需传给 a-form-item 以便在无 #label 插槽时正常显示 */
5
+ export declare const OMIT_PROPS: readonly ["hidden", "validate", "type", "itemProps", "itemEvents", "span", "labelSpan", "wrapperCol", "name", "formData", "required", "placeholder", "showLabel"];
6
+ export declare const DEFAULT_LAYOUT: {
7
+ readonly labelSpan: 6;
8
+ readonly wrapperCol: 18;
9
+ };
@@ -0,0 +1,4 @@
1
+ export { default as FormItem } from './FormItem';
2
+ export type { FormItemType, FormItemTypeBase, FormItemTypeExtended, FormItemConfig, FormItemProps } from './types';
3
+ export { COMPONENT_MAP, DEFAULT_LAYOUT, OMIT_PROPS } from './constants';
4
+ export { validateCondition } from './validator';
@@ -0,0 +1,46 @@
1
+ /**
2
+ * FormItem 表单项类型定义
3
+ * 参考 MxFormItem,支持可配置 type、嵌套路径、校验等
4
+ */
5
+ /** 基础表单项类型(Ant Design Vue 组件) */
6
+ export type FormItemTypeBase = 'input' | 'text-area' | 'select' | 'radio' | 'checkbox' | 'date-picker' | 'input-number' | 'input-search';
7
+ /** 扩展类型 */
8
+ export type FormItemTypeExtended = 'tree-select' | 'custom';
9
+ /** 表单项 type 枚举 */
10
+ export type FormItemType = FormItemTypeBase | FormItemTypeExtended;
11
+ /** 表单项基础配置 */
12
+ export interface FormItemConfig {
13
+ label: string;
14
+ /** 字段名,字符串为单层路径,数组为嵌套路径如 ['user','address','city'] */
15
+ name?: string | string[];
16
+ /** 占位文案;不传时根据 type 与 label 自动生成(请选择/请输入 + label) */
17
+ placeholder?: string;
18
+ /** 是否显示 label;false 时不渲染标签列(如 SearchBar 仅用 label 参与 placeholder 生成) */
19
+ showLabel?: boolean;
20
+ span?: 24 | 12 | 8;
21
+ labelSpan?: number;
22
+ wrapperCol?: number;
23
+ required?: boolean;
24
+ disabled?: boolean;
25
+ show?: boolean;
26
+ tooltip?: string;
27
+ rules?: Array<Record<string, unknown>>;
28
+ validate?: Array<{
29
+ condition: string;
30
+ message: string;
31
+ }>;
32
+ }
33
+ /** FormItem 组件 Props(内部 + 扩展) */
34
+ export interface FormItemProps extends FormItemConfig {
35
+ type: FormItemType;
36
+ customComponent?: unknown;
37
+ itemProps?: Record<string, unknown>;
38
+ itemEvents?: Record<string, (...args: unknown[]) => void>;
39
+ showStr?: string | string[];
40
+ defaultValue?: unknown;
41
+ prefixName?: string[];
42
+ /** 表单数据对象或 ref,用于内部双向绑定 */
43
+ formData?: Record<string, unknown> | {
44
+ value: Record<string, unknown>;
45
+ };
46
+ }
@@ -0,0 +1 @@
1
+ export declare function validateCondition(condition: string, value: unknown): boolean;
@@ -0,0 +1,37 @@
1
+ import { FormRendererProps } from './types';
2
+
3
+ declare function __VLS_template(): Partial<Record<string, (_: {}) => any>>;
4
+ declare const __VLS_component: import('vue').DefineComponent<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<FormRendererProps>, {
5
+ cols: number;
6
+ gutter: number;
7
+ }>>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<FormRendererProps>, {
8
+ cols: number;
9
+ gutter: number;
10
+ }>>> & Readonly<{}>, {
11
+ cols: number;
12
+ gutter: number | [number, number];
13
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
14
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
15
+ export default _default;
16
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
17
+ type __VLS_TypePropsToRuntimeProps<T> = {
18
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
19
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
20
+ } : {
21
+ type: import('vue').PropType<T[K]>;
22
+ required: true;
23
+ };
24
+ };
25
+ type __VLS_WithDefaults<P, D> = {
26
+ [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
27
+ default: D[K];
28
+ }> : P[K];
29
+ };
30
+ type __VLS_Prettify<T> = {
31
+ [K in keyof T]: T[K];
32
+ } & {};
33
+ type __VLS_WithTemplateSlots<T, S> = T & {
34
+ new (): {
35
+ $slots: S;
36
+ };
37
+ };
@@ -0,0 +1,9 @@
1
+ /** 带 show/showStr 的字段项,用于 processHiddenFields(仅约束必要属性,便于 FormItemProps 等传入) */
2
+ export interface FormFieldWithShow {
3
+ show?: boolean;
4
+ showStr?: string | string[];
5
+ }
6
+ /**
7
+ * 处理隐藏字段:根据 formData 与 showStr 计算每项的 show,并过滤出需要展示的字段
8
+ */
9
+ export declare function processHiddenFields<T extends FormFieldWithShow>(fields: T[], formData: Record<string, unknown>): T[];
@@ -0,0 +1,3 @@
1
+ export { default as FormRenderer } from './FormRenderer';
2
+ export type { FormRendererProps, FormRendererFieldConfig } from './types';
3
+ export { processHiddenFields } from './helpers';
@@ -0,0 +1,13 @@
1
+ import { FormItemProps } from '../form-item/types';
2
+
3
+ export type FormRendererFieldConfig = FormItemProps;
4
+ export interface FormRendererProps {
5
+ /** 表单字段配置 */
6
+ fields: FormRendererFieldConfig[];
7
+ /** 表单数据(与 FormItem 双向绑定) */
8
+ formData: Record<string, unknown>;
9
+ /** 列数(传给 FormRow) */
10
+ cols?: number;
11
+ /** 列间距(传给 FormRow) */
12
+ gutter?: number | [number, number];
13
+ }
@@ -0,0 +1,33 @@
1
+ import { FormRowProps } from './types';
2
+
3
+ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<FormRowProps>, {
4
+ cols: number;
5
+ gutter: number;
6
+ class: undefined;
7
+ }>>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<FormRowProps>, {
8
+ cols: number;
9
+ gutter: number;
10
+ class: undefined;
11
+ }>>> & Readonly<{}>, {
12
+ class: string;
13
+ cols: number;
14
+ gutter: number | [number, number];
15
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
16
+ export default _default;
17
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
18
+ type __VLS_TypePropsToRuntimeProps<T> = {
19
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
20
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
21
+ } : {
22
+ type: import('vue').PropType<T[K]>;
23
+ required: true;
24
+ };
25
+ };
26
+ type __VLS_WithDefaults<P, D> = {
27
+ [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
28
+ default: D[K];
29
+ }> : P[K];
30
+ };
31
+ type __VLS_Prettify<T> = {
32
+ [K in keyof T]: T[K];
33
+ } & {};
@@ -0,0 +1,2 @@
1
+ export { default as FormRow } from './FormRow';
2
+ export type { FormRowProps } from './types';
@@ -0,0 +1,11 @@
1
+ /**
2
+ * FormRow 表单行布局组件类型
3
+ */
4
+ export interface FormRowProps {
5
+ /** 每行显示的列数(1-24) */
6
+ cols?: number;
7
+ /** 列间距 */
8
+ gutter?: number | [number, number];
9
+ /** 自定义类名 */
10
+ class?: string;
11
+ }
@@ -10,6 +10,28 @@ export * from './delete-button';
10
10
  export type * from './delete-button/types';
11
11
  export * from './color-picker';
12
12
  export type * from './color-picker/types';
13
+ export * from './form-item';
14
+ export type * from './form-item/types';
15
+ export * from './form-row';
16
+ export type * from './form-row/types';
17
+ export * from './form-renderer';
18
+ export type * from './form-renderer/types';
19
+ export * from './content-container';
20
+ export type * from './content-container/types';
21
+ export * from './auto-tooltip';
22
+ export type * from './auto-tooltip/types';
23
+ export { DictSelect } from './dict-select';
24
+ export type { DictItem, DictSelectProps } from './dict-select/types';
25
+ export { DictRadio } from './dict-radio';
26
+ export type { DictRadioProps } from './dict-radio/types';
27
+ export { DictCheckbox } from './dict-checkbox';
28
+ export type { DictCheckboxProps } from './dict-checkbox/types';
29
+ export { DictBadge } from './dict-badge';
30
+ export type { DictBadgeProps } from './dict-badge/types';
31
+ export { DictTag } from './dict-tag';
32
+ export type { DictTagProps } from './dict-tag/types';
33
+ export { SearchBar } from './search-bar';
34
+ export type { SearchBarProps, SearchConfigItem } from './search-bar/types';
13
35
  export type * from './button/types';
14
36
  /**
15
37
  * MTN UI Vue Plugin
@@ -0,0 +1,60 @@
1
+ import { SearchBarProps, SearchConfigItem } from './types';
2
+
3
+ declare function __VLS_template(): {
4
+ default?(_: {}): any;
5
+ };
6
+ declare const __VLS_component: import('vue').DefineComponent<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<SearchBarProps>, {
7
+ searchList: () => never[];
8
+ cols: number;
9
+ gutter: number;
10
+ searchText: string;
11
+ resetText: string;
12
+ expandText: () => [string, string];
13
+ validateBeforeSearch: boolean;
14
+ }>>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
15
+ reset: () => void;
16
+ search: (values: Record<string, unknown>) => void;
17
+ }, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<SearchBarProps>, {
18
+ searchList: () => never[];
19
+ cols: number;
20
+ gutter: number;
21
+ searchText: string;
22
+ resetText: string;
23
+ expandText: () => [string, string];
24
+ validateBeforeSearch: boolean;
25
+ }>>> & Readonly<{
26
+ onReset?: (() => any) | undefined;
27
+ onSearch?: ((values: Record<string, unknown>) => any) | undefined;
28
+ }>, {
29
+ cols: number;
30
+ gutter: number | [number, number];
31
+ searchList: SearchConfigItem[];
32
+ searchText: string;
33
+ resetText: string;
34
+ expandText: [string, string];
35
+ validateBeforeSearch: boolean;
36
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
37
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
38
+ export default _default;
39
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
40
+ type __VLS_TypePropsToRuntimeProps<T> = {
41
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
42
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
43
+ } : {
44
+ type: import('vue').PropType<T[K]>;
45
+ required: true;
46
+ };
47
+ };
48
+ type __VLS_WithDefaults<P, D> = {
49
+ [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
50
+ default: D[K];
51
+ }> : P[K];
52
+ };
53
+ type __VLS_Prettify<T> = {
54
+ [K in keyof T]: T[K];
55
+ } & {};
56
+ type __VLS_WithTemplateSlots<T, S> = T & {
57
+ new (): {
58
+ $slots: S;
59
+ };
60
+ };
@@ -0,0 +1,2 @@
1
+ export { default as SearchBar } from './SearchBar';
2
+ export type { SearchBarProps, SearchConfigItem } from './types';
@@ -0,0 +1,58 @@
1
+ /**
2
+ * 配置化搜索项:用于 searchList,支持基础/高级(isHidden)与多种控件类型
3
+ */
4
+ export interface SearchConfigItem {
5
+ /** 字段名,对应 model 的 key */
6
+ key: string;
7
+ /** 控件类型 */
8
+ type: 'input' | 'search' | 'select' | 'date' | 'dateRange' | 'custom';
9
+ /** 展示名称(高级区域表单项 label) */
10
+ name?: string;
11
+ /** 占位文案 */
12
+ placeholder?: string;
13
+ /** 下拉选项(type=select 时) */
14
+ options?: Array<{
15
+ label: string;
16
+ value: string | number;
17
+ }>;
18
+ /** true 时放入高级搜索折叠区 */
19
+ isHidden?: boolean;
20
+ /** 默认值 */
21
+ defaultValue?: unknown;
22
+ /** 控件宽度(像素) */
23
+ width?: number;
24
+ /** 控件样式 */
25
+ style?: Record<string, string | number>;
26
+ /** 透传给控件的 props */
27
+ props?: Record<string, unknown>;
28
+ /** 自定义渲染(type=custom 时),返回 VNode 或组件 */
29
+ render?: (ctx: {
30
+ value: unknown;
31
+ onChange: (v: unknown) => void;
32
+ item: SearchConfigItem;
33
+ }) => import('vue').VNode | import('vue').Component;
34
+ }
35
+ /**
36
+ * SearchBar 组件 Props
37
+ * 用于表格上方搜索区。支持两种用法:1)插槽 + FormItem;2)配置 searchList(基础 + 高级展开),不含操作按钮区。
38
+ */
39
+ export interface SearchBarProps {
40
+ /** 表单数据对象(与内部 FormItem 的 form-data 或配置项绑定共用) */
41
+ model: Record<string, unknown>;
42
+ /** 配置化搜索项列表;有值时使用配置化 UI(基础行 + 高级展开),无值时使用默认插槽 */
43
+ searchList?: SearchConfigItem[];
44
+ /** 每行表单项列数(仅插槽模式生效,传给 FormRow) */
45
+ cols?: number;
46
+ /** 列间距(仅插槽模式生效) */
47
+ gutter?: number | [number, number];
48
+ /** 查询按钮文案 */
49
+ searchText?: string;
50
+ /** 重置按钮文案 */
51
+ resetText?: string;
52
+ /** 展开/收起文案,[展开, 收起] */
53
+ expandText?: [string, string];
54
+ /** 是否在点击查询前进行表单校验 */
55
+ validateBeforeSearch?: boolean;
56
+ /** 自定义类名 */
57
+ class?: string;
58
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mtn-ui/components",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "MTN UI Components",
5
5
  "type": "module",
6
6
  "main": "./dist/index/index.js",
@@ -80,7 +80,7 @@
80
80
  "class-variance-authority": "^0.7.1",
81
81
  "clsx": "^2.1.1",
82
82
  "tailwind-merge": "^3.4.0",
83
- "@mtn-ui/utils": "0.0.5"
83
+ "@mtn-ui/utils": "0.0.6"
84
84
  },
85
85
  "scripts": {
86
86
  "build": "vite build",