@yeepay/yee-boss-ui 0.1.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/README.md ADDED
@@ -0,0 +1,155 @@
1
+ # @yeepay/yee-boss-ui
2
+
3
+ 运营后台平台公共 UI、主题和轻量列表页基础能力。
4
+
5
+ ## 当前范围
6
+
7
+ 当前提供:
8
+
9
+ - light/dark 语义化 Theme Tokens。
10
+ - `--yee-*` 全量公共 CSS Variables。
11
+ - Ant Design Vue Theme Token 映射。
12
+ - `PlatformConfigProvider`。
13
+ - `usePlatformTheme` 只读主题上下文。
14
+ - `YeePage` 页面容器。
15
+ - `YeeForm` Schema 查询表单。
16
+ - `useYeeGrid` 与 `gridApi/formApi`。
17
+ - Tailwind CSS 语义主题 preset。
18
+
19
+ 不提供主题切换器、业务组件或对 Ant Design Vue 基础组件的机械封装,也不依赖任何 `@vben-*` 包。
20
+
21
+ ## 安装
22
+
23
+ ```bash
24
+ pnpm add @yeepay/yee-boss-ui ant-design-vue vue vxe-table vxe-pc-ui
25
+ ```
26
+
27
+ ## 使用
28
+
29
+ ```vue
30
+ <script setup lang="ts">
31
+ import {
32
+ PlatformConfigProvider,
33
+ type PlatformTheme,
34
+ } from '@yeepay/yee-boss-ui'
35
+ import '@yeepay/yee-boss-ui/style.css'
36
+
37
+ const theme: PlatformTheme = {
38
+ mode: 'light',
39
+ }
40
+ </script>
41
+
42
+ <template>
43
+ <PlatformConfigProvider :theme="theme">
44
+ <RouterView />
45
+ </PlatformConfigProvider>
46
+ </template>
47
+ ```
48
+
49
+ Portal 负责决定当前主题并通过 Runtime Context 传给子应用;组件库只负责映射和消费。语言与 locale 继续由应用国际化层负责。
50
+
51
+ 只需要公共主题、不使用组件时,可以只引入:
52
+
53
+ ```ts
54
+ import '@yeepay/yee-boss-ui/theme.css'
55
+ ```
56
+
57
+ `theme.css` 在 `:root` 提供 light 默认值,并同时支持 `html.dark` 和 `[data-theme="dark"]`。Portal 需要在根节点同步主题标识;子应用不自行维护另一套主题变量。
58
+
59
+ 所有公共变量统一使用 `--yee-*`,例如:
60
+
61
+ ```css
62
+ .custom-card {
63
+ color: var(--yee-card-foreground);
64
+ background: var(--yee-card);
65
+ border: 1px solid var(--yee-border);
66
+ border-radius: var(--yee-radius);
67
+ }
68
+ ```
69
+
70
+ ## Tailwind CSS
71
+
72
+ ```js
73
+ // tailwind.config.mjs
74
+ import bossUiTailwindPreset from '@yeepay/yee-boss-ui/tailwind-preset'
75
+
76
+ export default {
77
+ presets: [bossUiTailwindPreset],
78
+ content: ['./index.html', './src/**/*.{vue,ts}'],
79
+ }
80
+ ```
81
+
82
+ 业务页面可以直接使用 `bg-background`、`bg-background-deep`、`bg-card`、`bg-accent`、`text-foreground`、`text-muted-foreground` 和 `border-border`,底层统一映射到 `--yee-*`。
83
+
84
+ ## YeePage 与 VXE Grid
85
+
86
+ ```vue
87
+ <script setup lang="ts">
88
+ import type {
89
+ YeeFormOptions,
90
+ YeeGridOptions,
91
+ } from '@yeepay/yee-boss-ui'
92
+ import {
93
+ YeePage,
94
+ useYeeGrid,
95
+ } from '@yeepay/yee-boss-ui'
96
+
97
+ interface OrderItem {
98
+ orderNo: string
99
+ }
100
+
101
+ interface QueryValues {
102
+ orderNo?: string
103
+ }
104
+
105
+ const formOptions: YeeFormOptions<QueryValues> = {
106
+ schema: [
107
+ {
108
+ component: 'Input',
109
+ componentProps: { allowClear: true },
110
+ fieldName: 'orderNo',
111
+ label: '订单号',
112
+ },
113
+ ],
114
+ }
115
+
116
+ const gridOptions: YeeGridOptions<OrderItem, QueryValues> = {
117
+ columns: [{ field: 'orderNo', title: '订单号' }],
118
+ pagerConfig: {},
119
+ proxyConfig: {
120
+ ajax: {
121
+ query: async ({ page }, formValues) => {
122
+ return getOrderPage({
123
+ ...formValues,
124
+ pageNo: page.currentPage,
125
+ pageSize: page.pageSize,
126
+ })
127
+ },
128
+ },
129
+ },
130
+ }
131
+
132
+ const [YeeGrid, gridApi] = useYeeGrid({
133
+ formOptions,
134
+ gridOptions,
135
+ })
136
+
137
+ defineExpose({ reload: gridApi.reload })
138
+ </script>
139
+
140
+ <template>
141
+ <yee-page auto-content-height>
142
+ <yee-grid table-title="订单明细" />
143
+ </yee-page>
144
+ </template>
145
+ ```
146
+
147
+ 组件的 TypeScript 导出使用 `YeeForm`、`YeeGrid`、`YeePage`,Vue 模板标签对应 `yee-form`、`yee-grid`、`yee-page`。新代码统一使用 `useYeeGrid`,不提供旧命名兼容别名。查询接口统一返回 `{ items, total }`。
148
+
149
+ ## 开发
150
+
151
+ ```bash
152
+ pnpm install
153
+ pnpm check
154
+ pnpm pack --dry-run
155
+ ```
@@ -0,0 +1,23 @@
1
+ import { PlatformTheme } from '../theme/types';
2
+ interface Props {
3
+ theme?: PlatformTheme;
4
+ }
5
+ declare function __VLS_template(): {
6
+ attrs: Partial<{}>;
7
+ slots: {
8
+ default?(_: {}): any;
9
+ };
10
+ refs: {};
11
+ rootEl: any;
12
+ };
13
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
14
+ declare const __VLS_component: import('vue').DefineComponent<Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<Props> & Readonly<{}>, {
15
+ theme: PlatformTheme;
16
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
17
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
18
+ export default _default;
19
+ type __VLS_WithTemplateSlots<T, S> = T & {
20
+ new (): {
21
+ $slots: S;
22
+ };
23
+ };
@@ -0,0 +1,14 @@
1
+ import { YeeFormValues, YeeFormProps } from './types';
2
+ declare const _default: <TValues extends object = YeeFormValues>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
3
+ props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, never> & YeeFormProps<TValues> & Partial<{}>> & import('vue').PublicProps;
4
+ expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
5
+ attrs: any;
6
+ slots: {};
7
+ emit: {};
8
+ }>) => import('vue').VNode & {
9
+ __ctx?: Awaited<typeof __VLS_setup>;
10
+ };
11
+ export default _default;
12
+ type __VLS_PrettifyLocal<T> = {
13
+ [K in keyof T]: T[K];
14
+ } & {};
@@ -0,0 +1,14 @@
1
+ import { ShallowRef } from 'vue';
2
+ import { YeeFormOptions, YeeFormSchema, YeeFormSchemaUpdate, YeeFormValues } from './types';
3
+ export declare class YeeFormApi<TValues extends object = YeeFormValues> {
4
+ readonly schema: ShallowRef<readonly YeeFormSchema<TValues>[]>;
5
+ private initialValues;
6
+ private readonly values;
7
+ configure(options: YeeFormOptions<TValues>): void;
8
+ getFieldValue(fieldName: keyof TValues & string): unknown;
9
+ getValues(): TValues;
10
+ resetForm(): void;
11
+ setFieldValue(fieldName: keyof TValues & string, value: unknown): void;
12
+ setValues(values: Partial<TValues>): void;
13
+ updateSchema(updates: readonly YeeFormSchemaUpdate<TValues>[]): void;
14
+ }
@@ -0,0 +1,3 @@
1
+ export { default as YeeForm } from './YeeForm.vue';
2
+ export { YeeFormApi } from './form-api';
3
+ export type { YeeFormComponent, YeeFormOptions, YeeFormSchema, YeeFormSchemaUpdate, YeeFormValues, YeeFormProps, } from './types';
@@ -0,0 +1,28 @@
1
+ export type YeeFormComponent = 'Input' | 'RangePicker' | 'Select';
2
+ export type YeeFormValues = Record<string, unknown>;
3
+ export interface YeeFormSchema<TValues extends object = YeeFormValues> {
4
+ component: YeeFormComponent;
5
+ componentProps?: Record<string, unknown>;
6
+ fieldName: keyof TValues & string;
7
+ hide?: boolean;
8
+ label: string;
9
+ }
10
+ export interface YeeFormSchemaUpdate<TValues extends object = YeeFormValues> extends Partial<Omit<YeeFormSchema<TValues>, 'fieldName'>> {
11
+ fieldName: keyof TValues & string;
12
+ }
13
+ export interface YeeFormOptions<TValues extends object = YeeFormValues> {
14
+ collapsed?: boolean;
15
+ collapsedRows?: number;
16
+ handleCollapsedChange?: (collapsed: boolean) => void;
17
+ initialValues?: Partial<TValues>;
18
+ schema: readonly YeeFormSchema<TValues>[];
19
+ showCollapseButton?: boolean;
20
+ submitOnChange?: boolean;
21
+ submitOnEnter?: boolean;
22
+ }
23
+ export interface YeeFormProps<TValues extends object = YeeFormValues> {
24
+ api: import('./form-api').YeeFormApi<TValues>;
25
+ onReset?: () => Promise<void> | void;
26
+ onSubmit?: (values: TValues) => Promise<void> | void;
27
+ options: YeeFormOptions<TValues>;
28
+ }
@@ -0,0 +1,134 @@
1
+ import { VxeGridProps } from 'vxe-table';
2
+ import { YeeGridInternalProps } from './types';
3
+ declare function __VLS_template(): {
4
+ attrs: Partial<{}>;
5
+ slots: Partial<Record<string, (_: {
6
+ [key: string]: any;
7
+ $table: import('vxe-table').VxeTableConstructor<any>;
8
+ $grid: import('vxe-table').VxeGridConstructor<any> | null | undefined;
9
+ $gantt: import('vxe-pc-ui').VxeGanttConstructor<any> | null | undefined;
10
+ rowid: string;
11
+ row: any;
12
+ rowIndex: number;
13
+ $rowIndex: number;
14
+ _rowIndex: number;
15
+ column: import("vxe-table").VxeTableDefines.ColumnInfo<any>;
16
+ columnIndex: number;
17
+ $columnIndex: number;
18
+ _columnIndex: number;
19
+ option: import("vxe-table").VxeColumnPropTypes.FilterItem;
20
+ type: string;
21
+ fixed: import("vxe-table").VxeColumnPropTypes.Fixed;
22
+ checked: boolean;
23
+ indeterminate: boolean;
24
+ seq: string | number;
25
+ level: number;
26
+ isEdit: boolean;
27
+ isHidden: boolean;
28
+ field: string;
29
+ item: any;
30
+ data: any;
31
+ tooltipContent: string;
32
+ groupContent: string;
33
+ groupField: string;
34
+ childCount: number;
35
+ groupValues: number;
36
+ aggValue: number;
37
+ visibleData: any[];
38
+ items: any[];
39
+ }) => any>> & {
40
+ 'table-title'?(_: {}): any;
41
+ 'toolbar-actions'?(_: {
42
+ [key: string]: any;
43
+ $table: import('vxe-table').VxeTableConstructor<any>;
44
+ $grid: import('vxe-table').VxeGridConstructor<any> | null | undefined;
45
+ $gantt: import('vxe-pc-ui').VxeGanttConstructor<any> | null | undefined;
46
+ rowid: string;
47
+ row: any;
48
+ rowIndex: number;
49
+ $rowIndex: number;
50
+ _rowIndex: number;
51
+ column: import("vxe-table").VxeTableDefines.ColumnInfo<any>;
52
+ columnIndex: number;
53
+ $columnIndex: number;
54
+ _columnIndex: number;
55
+ option: import("vxe-table").VxeColumnPropTypes.FilterItem;
56
+ type: string;
57
+ fixed: import("vxe-table").VxeColumnPropTypes.Fixed;
58
+ checked: boolean;
59
+ indeterminate: boolean;
60
+ seq: string | number;
61
+ level: number;
62
+ isEdit: boolean;
63
+ isHidden: boolean;
64
+ field: string;
65
+ item: any;
66
+ data: any;
67
+ tooltipContent: string;
68
+ groupContent: string;
69
+ groupField: string;
70
+ childCount: number;
71
+ groupValues: number;
72
+ aggValue: number;
73
+ visibleData: any[];
74
+ items: any[];
75
+ }): any;
76
+ 'toolbar-tools'?(_: {
77
+ [key: string]: any;
78
+ $table: import('vxe-table').VxeTableConstructor<any>;
79
+ $grid: import('vxe-table').VxeGridConstructor<any> | null | undefined;
80
+ $gantt: import('vxe-pc-ui').VxeGanttConstructor<any> | null | undefined;
81
+ rowid: string;
82
+ row: any;
83
+ rowIndex: number;
84
+ $rowIndex: number;
85
+ _rowIndex: number;
86
+ column: import("vxe-table").VxeTableDefines.ColumnInfo<any>;
87
+ columnIndex: number;
88
+ $columnIndex: number;
89
+ _columnIndex: number;
90
+ option: import("vxe-table").VxeColumnPropTypes.FilterItem;
91
+ type: string;
92
+ fixed: import("vxe-table").VxeColumnPropTypes.Fixed;
93
+ checked: boolean;
94
+ indeterminate: boolean;
95
+ seq: string | number;
96
+ level: number;
97
+ isEdit: boolean;
98
+ isHidden: boolean;
99
+ field: string;
100
+ item: any;
101
+ data: any;
102
+ tooltipContent: string;
103
+ groupContent: string;
104
+ groupField: string;
105
+ childCount: number;
106
+ groupValues: number;
107
+ aggValue: number;
108
+ visibleData: any[];
109
+ items: any[];
110
+ }): any;
111
+ empty?(_: {}): any;
112
+ };
113
+ refs: {
114
+ gridRef: (import('vxe-table').VxeGridMethods<any> & {
115
+ $props: VxeGridProps<any> & import('vxe-table').VxeGridEventProps<any>;
116
+ $slots: import('vxe-table').VxeGridSlots<any>;
117
+ }) | null;
118
+ };
119
+ rootEl: HTMLElement;
120
+ };
121
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
122
+ declare const __VLS_component: import('vue').DefineComponent<YeeGridInternalProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<YeeGridInternalProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
123
+ gridRef: (import('vxe-table').VxeGridMethods<any> & {
124
+ $props: VxeGridProps<any> & import('vxe-table').VxeGridEventProps<any>;
125
+ $slots: import('vxe-table').VxeGridSlots<any>;
126
+ }) | null;
127
+ }, HTMLElement>;
128
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
129
+ export default _default;
130
+ type __VLS_WithTemplateSlots<T, S> = T & {
131
+ new (): {
132
+ $slots: S;
133
+ };
134
+ };
@@ -0,0 +1,4 @@
1
+ export { YeeGridApi } from './yee-grid-api';
2
+ export { useYeeGrid } from './use-yee-grid';
3
+ export type { YeeGridPage, YeeGridQuery, YeeGridQueryParams, YeeGridToolbarConfig, YeeGridOptions, UseYeeGridOptions, } from './types';
4
+ export type { VxeGridDefines, VxeGridListeners, VxeGridPropTypes, VxeTableDefines, } from 'vxe-table';
@@ -0,0 +1,42 @@
1
+ import { VxeGridInstance, VxeGridListeners, VxeGridProps as NativeVxeGridProps } from 'vxe-table';
2
+ import { YeeFormOptions, YeeFormValues } from '../form';
3
+ import { YeeGridApi } from './yee-grid-api';
4
+ type NativeProxyConfig<T> = NonNullable<NativeVxeGridProps<T>['proxyConfig']>;
5
+ type NativeProxyAjax<T> = NonNullable<NativeProxyConfig<T>['ajax']>;
6
+ type NativeProxyQuery<T> = NonNullable<NativeProxyAjax<T>['query']>;
7
+ export type YeeGridQueryParams<T> = Parameters<NativeProxyQuery<T>>[0];
8
+ export interface YeeGridPage<T> {
9
+ items: readonly T[];
10
+ total: number;
11
+ }
12
+ export type YeeGridQuery<T, TFormValues extends object = YeeFormValues> = (params: YeeGridQueryParams<T>, formValues: TFormValues) => Promise<YeeGridPage<T>>;
13
+ type YeeGridProxyAjax<T, TFormValues extends object> = Omit<NativeProxyAjax<T>, 'query'> & {
14
+ query?: YeeGridQuery<T, TFormValues>;
15
+ };
16
+ type YeeGridProxyConfig<T, TFormValues extends object> = Omit<NativeProxyConfig<T>, 'ajax'> & {
17
+ ajax?: YeeGridProxyAjax<T, TFormValues>;
18
+ };
19
+ type NativeToolbarConfig<T> = NonNullable<NativeVxeGridProps<T>['toolbarConfig']>;
20
+ export type YeeGridToolbarConfig<T> = NativeToolbarConfig<T> & {
21
+ search?: boolean;
22
+ };
23
+ export type YeeGridOptions<T = Record<string, unknown>, TFormValues extends object = YeeFormValues> = Omit<NativeVxeGridProps<T>, 'proxyConfig' | 'toolbarConfig'> & {
24
+ proxyConfig?: YeeGridProxyConfig<T, TFormValues>;
25
+ toolbarConfig?: YeeGridToolbarConfig<T>;
26
+ };
27
+ export interface UseYeeGridOptions<T = Record<string, unknown>, TFormValues extends object = YeeFormValues> {
28
+ formOptions?: YeeFormOptions<TFormValues>;
29
+ gridEvents?: VxeGridListeners<T>;
30
+ gridOptions: YeeGridOptions<T, TFormValues>;
31
+ separator?: boolean;
32
+ showSearchForm?: boolean;
33
+ }
34
+ export interface YeeGridRuntimeProps {
35
+ tableTitle?: string;
36
+ tableTitleHelp?: string;
37
+ }
38
+ export interface YeeGridInternalProps extends YeeGridRuntimeProps {
39
+ api: YeeGridApi;
40
+ }
41
+ export type YeeGridRef<T> = VxeGridInstance<T>;
42
+ export {};
@@ -0,0 +1,5 @@
1
+ import { DefineComponent } from 'vue';
2
+ import { YeeFormValues } from '../form';
3
+ import { YeeGridApi } from './yee-grid-api';
4
+ import { YeeGridRuntimeProps, UseYeeGridOptions } from './types';
5
+ export declare function useYeeGrid<T = Record<string, unknown>, TFormValues extends object = YeeFormValues>(options: UseYeeGridOptions<T, TFormValues>): readonly [DefineComponent<YeeGridRuntimeProps>, YeeGridApi<T, TFormValues>];
@@ -0,0 +1 @@
1
+ export declare function initializeVxeTable(): void;
@@ -0,0 +1,18 @@
1
+ import { ShallowRef } from 'vue';
2
+ import { YeeFormApi, YeeFormValues } from '../form';
3
+ import { YeeGridOptions, YeeGridRef, UseYeeGridOptions } from './types';
4
+ export declare class YeeGridApi<T = Record<string, unknown>, TFormValues extends object = YeeFormValues> {
5
+ readonly formApi: YeeFormApi<TFormValues>;
6
+ readonly searchFormVisible: ShallowRef<boolean>;
7
+ readonly state: ShallowRef<UseYeeGridOptions<T, TFormValues>>;
8
+ private grid;
9
+ constructor(options: UseYeeGridOptions<T, TFormValues>);
10
+ mount(grid: YeeGridRef<T>): void;
11
+ query: (values?: Partial<TFormValues>) => Promise<unknown>;
12
+ reload: (values?: Partial<TFormValues>) => Promise<unknown>;
13
+ setGridOptions(options: Partial<YeeGridOptions<T, TFormValues>>): void;
14
+ setLoading(loading: boolean): void;
15
+ setState(state: Partial<UseYeeGridOptions<T, TFormValues>>): void;
16
+ toggleSearchForm(show?: boolean): boolean;
17
+ unmount(): void;
18
+ }
@@ -0,0 +1,25 @@
1
+ import { YeePageProps } from './types';
2
+ declare function __VLS_template(): {
3
+ attrs: Partial<{}>;
4
+ slots: {
5
+ title?(_: {}): any;
6
+ description?(_: {}): any;
7
+ extra?(_: {}): any;
8
+ default?(_: {}): any;
9
+ footer?(_: {}): any;
10
+ };
11
+ refs: {};
12
+ rootEl: HTMLElement;
13
+ };
14
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
15
+ declare const __VLS_component: import('vue').DefineComponent<YeePageProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<YeePageProps> & Readonly<{}>, {
16
+ autoContentHeight: boolean;
17
+ heightOffset: number | string;
18
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLElement>;
19
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
20
+ export default _default;
21
+ type __VLS_WithTemplateSlots<T, S> = T & {
22
+ new (): {
23
+ $slots: S;
24
+ };
25
+ };
@@ -0,0 +1,2 @@
1
+ export { default as YeePage } from './YeePage.vue';
2
+ export type { YeePageProps } from './types';
@@ -0,0 +1,9 @@
1
+ export interface YeePageProps {
2
+ autoContentHeight?: boolean;
3
+ contentClass?: string;
4
+ description?: string;
5
+ footerClass?: string;
6
+ headerClass?: string;
7
+ heightOffset?: number | string;
8
+ title?: string;
9
+ }
@@ -0,0 +1,9 @@
1
+ export { default as PlatformConfigProvider } from './components/PlatformConfigProvider.vue';
2
+ export * from './components/form';
3
+ export * from './components/grid';
4
+ export * from './components/page';
5
+ export { toAntDesignTheme } from './theme/ant-theme';
6
+ export { platformThemeKey, usePlatformTheme } from './theme/context';
7
+ export { toPlatformCssVariables } from './theme/css-variables';
8
+ export { darkThemeTokens, lightThemeTokens, resolvePlatformTheme, } from './theme/tokens';
9
+ export type { PlatformTheme, PlatformThemeMode, PlatformThemeTokens, ResolvedPlatformTheme, } from './theme/types';