@yeepay/yee-boss-ui 0.1.18 → 0.1.19

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 CHANGED
@@ -37,7 +37,7 @@ pnpm add @yeepay/yee-boss-ui ant-design-vue vue
37
37
 
38
38
  ## 使用
39
39
 
40
- 根入口适合兼容已有接入;它会导出全部公共组件。新页面建议使用下方的 feature entry,让 bundler 只加载实际使用的功能。
40
+ 组件库同时支持根入口的按需导入和全量导入。根入口按名称导入时,ESM bundler 会通过 tree-shaking 移除未使用组件。
41
41
 
42
42
  ```vue
43
43
  <script setup lang="ts">
@@ -61,24 +61,54 @@ const theme: PlatformTheme = {
61
61
 
62
62
  Portal 负责决定当前主题并通过 Runtime Context 传给子应用;组件库只负责映射和消费。语言与 locale 继续由应用国际化层负责。
63
63
 
64
+ ### 全量引入
65
+
66
+ 如果希望一次注册全部公开组件,可以使用插件形式:
67
+
68
+ ```ts
69
+ import { createApp } from 'vue'
70
+ import YeeBossUI from '@yeepay/yee-boss-ui'
71
+ import '@yeepay/yee-boss-ui/style.css'
72
+
73
+ createApp(App).use(YeeBossUI).mount('#app')
74
+ ```
75
+
76
+ 组件库会自动注册 `YeeAppShell`、`YeeDescriptions`、`YeeEllipsisText`、`YeeFileUpload`、`YeeForm`、`YeeModal`、`YeePage`、`YeeSelect` 以及应用壳层组件。`useYeeGrid` 仍按组合式 API 使用,首次调用时会由组件库自动加载 Grid 样式。
77
+
78
+ 如果只希望在脚本中使用全部导出,也可以从包根入口统一导入:
79
+
80
+ ```ts
81
+ import {
82
+ PlatformConfigProvider,
83
+ YeeAppShell,
84
+ YeeDescriptions,
85
+ YeeEllipsisText,
86
+ YeeFileUpload,
87
+ YeeForm,
88
+ YeeFormApi,
89
+ YeeHeader,
90
+ YeeModal,
91
+ YeePage,
92
+ YeeSelect,
93
+ YeeSidebar,
94
+ YeeTabs,
95
+ useYeeGrid,
96
+ } from '@yeepay/yee-boss-ui'
97
+ ```
98
+
99
+ 根入口导出全部公共组件和公共类型;VXE 由 `yee-boss-ui` 作为运行时依赖提供,不需要业务项目重复声明。按需和全量场景都只需要引入 `@yeepay/yee-boss-ui/style.css`。
100
+
64
101
  ### 按需引入
65
102
 
66
- 根入口保留完整 API 兼容性;业务项目如果只使用部分能力,建议使用对应的 feature entry,避免把未使用的 Grid/VXE 代码带入页面:
103
+ 页面只使用少量能力、需要减少初始体积时,从根入口只导入实际使用的组件:
67
104
 
68
105
  ```ts
69
- import { YeeAppShell, YeeHeader, YeeSidebar, YeeTabs } from '@yeepay/yee-boss-ui/app-shell'
70
- import { PlatformConfigProvider } from '@yeepay/yee-boss-ui/core'
71
- import { YeeDescriptions } from '@yeepay/yee-boss-ui/descriptions'
72
- import { YeeEllipsisText } from '@yeepay/yee-boss-ui/ellipsis-text'
73
- import { YeeFileUpload } from '@yeepay/yee-boss-ui/file-upload'
74
- import { YeeForm, YeeFormApi } from '@yeepay/yee-boss-ui/form'
75
- import { useYeeGrid } from '@yeepay/yee-boss-ui/grid'
76
- import { YeeModal } from '@yeepay/yee-boss-ui/modal'
77
- import { YeePage } from '@yeepay/yee-boss-ui/page'
78
- import { YeeSelect } from '@yeepay/yee-boss-ui/select'
106
+ import { YeeModal, YeePage, YeeSelect } from '@yeepay/yee-boss-ui'
107
+ import type { YeeSelectOption } from '@yeepay/yee-boss-ui'
108
+ import '@yeepay/yee-boss-ui/style.css'
79
109
  ```
80
110
 
81
- `@yeepay/yee-boss-ui/grid` 仅在页面确实使用 `YeeGrid` 时引入;VXE 由 `yee-boss-ui` 作为运行时依赖提供,不需要业务项目重复声明。`app-shell`、`core` 及其它入口不会主动加载 Grid/VXE。所有入口共用 `@yeepay/yee-boss-ui/style.css`。
111
+ `style.css` 是唯一需要业务引入的组件样式入口。`useYeeGrid()` 首次执行时,组件库会自动加载内部 Grid 样式;业务不需要区分或引入其它样式文件。
82
112
 
83
113
  ### 应用壳层
84
114
 
@@ -92,7 +122,7 @@ import {
92
122
  YeeHeader,
93
123
  YeeSidebar,
94
124
  YeeTabs,
95
- } from '@yeepay/yee-boss-ui/app-shell'
125
+ } from '@yeepay/yee-boss-ui'
96
126
 
97
127
  const sidebarCollapsed = shallowRef(false)
98
128
  const activeTab = shallowRef('overview')
@@ -142,7 +172,7 @@ const tabs = [
142
172
  ```vue
143
173
  <script setup lang="ts">
144
174
  import { shallowRef } from 'vue'
145
- import type { YeeTabsExpose } from '@yeepay/yee-boss-ui/app-shell'
175
+ import type { YeeTabsExpose } from '@yeepay/yee-boss-ui'
146
176
 
147
177
  const tabsRef = shallowRef<YeeTabsExpose>()
148
178
  </script>
@@ -159,13 +189,13 @@ const tabsRef = shallowRef<YeeTabsExpose>()
159
189
 
160
190
  `YeeTabItem.pinned` 表示固定状态;固定标签不能关闭或拖拽,组件展示和 `getTabs` 返回值都会将固定标签置于未固定标签之前。实例方法包括 `activateTab`、`closeTab`、`closeLeftTabs`、`closeRightTabs`、`closeOtherTabs`、`closeAllTabs`、`getTabs`、`getTab`、`pinTab`、`refreshTab` 和 `openTabInNewWindow`。方法只发出操作事件并返回是否找到目标标签,标签数组和路由状态仍由调用方维护。
161
191
 
162
- 只需要公共主题、不使用组件时,可以只引入:
192
+ 即使只需要公共主题、不使用组件,也只引入统一样式入口:
163
193
 
164
194
  ```ts
165
- import '@yeepay/yee-boss-ui/theme.css'
195
+ import '@yeepay/yee-boss-ui/style.css'
166
196
  ```
167
197
 
168
- `theme.css` `:root` 提供 light 默认值,并同时支持 `html.dark` 和 `[data-theme="dark"]`。Portal 需要在根节点同步主题标识;子应用不自行维护另一套主题变量。
198
+ `style.css` 同时包含主题变量和公共组件样式,并在 `:root` 提供 light 默认值,同时支持 `html.dark` 和 `[data-theme="dark"]`。Portal 需要在根节点同步主题标识;子应用不自行维护另一套主题变量。
169
199
 
170
200
  所有公共变量统一使用 `--yee-*`,例如:
171
201
 
@@ -182,7 +212,7 @@ import '@yeepay/yee-boss-ui/theme.css'
182
212
 
183
213
  ## TypeScript 类型
184
214
 
185
- 组件的公共类型可以从包根入口或对应的 feature entry 导入。命名统一使用 `组件名 + Props / Emits / Slots`;存在组件实例方法时额外提供 `Expose`,例如 `YeeFileUploadExpose`。公共字段带中文 JSDoc,业务项目在编写 Props、监听事件、使用插槽或组件 `ref` 时可以直接获得 IDE 提示。
215
+ 组件的公共类型统一从包根入口导入。命名统一使用 `组件名 + Props / Emits / Slots`;存在组件实例方法时额外提供 `Expose`,例如 `YeeFileUploadExpose`。公共字段带中文 JSDoc,业务项目在编写 Props、监听事件、使用插槽或组件 `ref` 时可以直接获得 IDE 提示。
186
216
 
187
217
  ```ts
188
218
  import type {
@@ -258,7 +288,7 @@ export default {
258
288
  自动上传模式通过回调接入项目统一请求层:
259
289
 
260
290
  ```ts
261
- import type { YeeUploadRequestOptions } from '@yeepay/yee-boss-ui/file-upload'
291
+ import type { YeeUploadRequestOptions } from '@yeepay/yee-boss-ui'
262
292
 
263
293
  async function uploadFile(options: YeeUploadRequestOptions): Promise<void> {
264
294
  try {
@@ -281,7 +311,7 @@ import {
281
311
  type YeeFileSelectPayload,
282
312
  type YeeFileUploadExpose,
283
313
  type YeeUploadFile,
284
- } from '@yeepay/yee-boss-ui/file-upload'
314
+ } from '@yeepay/yee-boss-ui'
285
315
 
286
316
  const uploadRef = shallowRef<YeeFileUploadExpose>()
287
317
  const fileList = shallowRef<YeeUploadFile[]>([])
@@ -316,7 +346,7 @@ async function handleFileSelect({ file, uid }: YeeFileSelectPayload): Promise<vo
316
346
  ```vue
317
347
  <script setup lang="ts">
318
348
  import { shallowRef } from 'vue'
319
- import { YeeModal } from '@yeepay/yee-boss-ui/modal'
349
+ import { YeeModal } from '@yeepay/yee-boss-ui'
320
350
 
321
351
  const open = shallowRef(false)
322
352
  const submitting = shallowRef(false)
@@ -359,7 +389,7 @@ import {
359
389
  type YeeSelectExpose,
360
390
  type YeeSelectOption,
361
391
  type YeeSelectValue,
362
- } from '@yeepay/yee-boss-ui/select'
392
+ } from '@yeepay/yee-boss-ui'
363
393
 
364
394
  const status = shallowRef<YeeSelectValue>()
365
395
  const selectRef = shallowRef<YeeSelectExpose>()
@@ -405,7 +435,7 @@ import {
405
435
  YeeForm,
406
436
  YeeFormApi,
407
437
  type YeeFormOptions,
408
- } from '@yeepay/yee-boss-ui/form'
438
+ } from '@yeepay/yee-boss-ui'
409
439
 
410
440
  interface QueryValues {
411
441
  channel?: 'OFFLINE' | 'ONLINE'
@@ -461,14 +491,12 @@ function query(values: QueryValues): void {
461
491
 
462
492
  `YeeGrid` 在普通 `YeePage` 或未使用 `YeePage` 时按表格内容自然撑高;放在开启 `auto-content-height` 的 `YeePage` 中时会自动占满查询表单之后的剩余高度,工具栏和分页器固定在可用区域内,数据超出后由表格内部滚动。表头和单元格内容超出时默认省略并提供 Tooltip;列宽默认允许拖拽调整,可通过 `gridOptions.columnConfig.resizable: false` 关闭。显式传入 `gridOptions.height` 时仍以该配置为准。
463
493
 
464
- VXE Grid 样式已随公共 `style.css` 一起发布。使用 `YeeGrid` 或 `useYeeGrid` 时只需引入 `style.css`,无需额外加载样式文件。
494
+ `style.css` 提供公共主题和组件样式;使用 `YeeGrid` 或 `useYeeGrid` 时,组件库会在运行时自动加载内部 VXE Grid 样式。
465
495
 
466
496
  ```vue
467
497
  <script setup lang="ts">
468
- import type { YeeFormOptions } from '@yeepay/yee-boss-ui/form'
469
- import type { YeeGridOptions } from '@yeepay/yee-boss-ui/grid'
470
- import { useYeeGrid } from '@yeepay/yee-boss-ui/grid'
471
- import { YeePage } from '@yeepay/yee-boss-ui/page'
498
+ import type { YeeFormOptions, YeeGridOptions } from '@yeepay/yee-boss-ui'
499
+ import { useYeeGrid, YeePage } from '@yeepay/yee-boss-ui'
472
500
 
473
501
  interface OrderItem {
474
502
  orderNo: string
@@ -0,0 +1,160 @@
1
+ import { defineComponent as O, shallowRef as m, computed as p, onMounted as U, nextTick as D, onBeforeUnmount as z, openBlock as i, createElementBlock as d, withModifiers as L, createElementVNode as f, Fragment as G, renderList as K, toDisplayString as R, renderSlot as $, createBlock as F, resolveDynamicComponent as A, mergeProps as j, createCommentVNode as V, createVNode as x, unref as v, withCtx as y, createTextVNode as h } from "vue";
2
+ import { TreeSelect as q, TimeRangePicker as H, TimePicker as J, Textarea as Q, Switch as W, Slider as X, Select as Z, Segmented as ee, Rate as te, RangePicker as oe, RadioGroup as ne, Radio as ae, Mentions as ie, InputPassword as le, InputNumber as re, Input as se, DatePicker as ue, CheckboxGroup as ce, Checkbox as me, Cascader as pe, AutoComplete as de, Button as C } from "ant-design-vue";
3
+ import { Y as fe } from "./YeeFileUpload-BUFoWs8x.js";
4
+ import { _ as ve } from "./_plugin-vue_export-helper-CHgC5LLL.js";
5
+ const ye = {
6
+ AutoComplete: de,
7
+ Cascader: pe,
8
+ Checkbox: me,
9
+ CheckboxGroup: ce,
10
+ DatePicker: ue,
11
+ Input: se,
12
+ InputNumber: re,
13
+ InputPassword: le,
14
+ Mentions: ie,
15
+ Radio: ae,
16
+ RadioGroup: ne,
17
+ RangePicker: oe,
18
+ Rate: te,
19
+ Segmented: ee,
20
+ Select: Z,
21
+ Slider: X,
22
+ Switch: W,
23
+ Textarea: Q,
24
+ TimePicker: J,
25
+ TimeRangePicker: H,
26
+ TreeSelect: q,
27
+ Upload: fe
28
+ }, he = {
29
+ Checkbox: "checked",
30
+ Radio: "checked",
31
+ Switch: "checked",
32
+ Upload: "fileList"
33
+ }, Ce = { class: "yee-ui-form__label" }, ge = { class: "yee-ui-form__actions" }, ke = /* @__PURE__ */ O({
34
+ name: "YeeForm",
35
+ __name: "YeeForm",
36
+ props: {
37
+ api: {},
38
+ onReset: { type: Function },
39
+ onSubmit: { type: Function },
40
+ options: {}
41
+ },
42
+ setup(r) {
43
+ const t = r, a = m(t.options.collapsed ?? !0), g = m(3), l = m(null);
44
+ let s;
45
+ t.api.configure(t.options);
46
+ const k = p(() => t.api.schema.value.filter((e) => !e.hide)), B = p(() => Math.max(1, t.options.collapsedRows ?? 1) * g.value), P = p(() => !t.options.showCollapseButton || !a.value ? k.value : k.value.slice(0, B.value));
47
+ function b() {
48
+ const e = l.value;
49
+ if (!e) return;
50
+ const n = getComputedStyle(e).gridTemplateColumns.split(" ").map((o) => o.trim()).filter(Boolean);
51
+ n.length > 0 && (g.value = n.length);
52
+ }
53
+ U(async () => {
54
+ await D(), b(), typeof ResizeObserver < "u" && l.value && (s = new ResizeObserver(b), s.observe(l.value));
55
+ }), z(() => {
56
+ s?.disconnect();
57
+ });
58
+ function _(e) {
59
+ return t.api.getFieldValue(e.fieldName);
60
+ }
61
+ function w(e) {
62
+ return e !== "Custom";
63
+ }
64
+ function N(e) {
65
+ return w(e.component) ? ye[e.component] : void 0;
66
+ }
67
+ function M(e) {
68
+ return w(e.component) ? he[e.component] ?? "value" : "value";
69
+ }
70
+ function T(e) {
71
+ const n = _(e), o = M(e);
72
+ return {
73
+ ...e.componentProps,
74
+ ...n === void 0 ? {} : { [o]: n },
75
+ [`onUpdate:${o}`]: (c) => S(e, c)
76
+ };
77
+ }
78
+ function S(e, n) {
79
+ t.api.setFieldValue(
80
+ e.fieldName,
81
+ n
82
+ ), t.options.submitOnChange && u();
83
+ }
84
+ async function E() {
85
+ t.api.resetForm(), await t.onReset?.();
86
+ }
87
+ async function u() {
88
+ await t.onSubmit?.(t.api.getValues());
89
+ }
90
+ function Y(e) {
91
+ e.key === "Enter" && t.options.submitOnEnter && (e.preventDefault(), u());
92
+ }
93
+ function I() {
94
+ a.value = !a.value, t.options.handleCollapsedChange?.(a.value);
95
+ }
96
+ return (e, n) => (i(), d("form", {
97
+ class: "yee-ui-form",
98
+ onKeydown: Y,
99
+ onSubmit: L(u, ["prevent"])
100
+ }, [
101
+ f("div", {
102
+ ref_key: "fieldsElement",
103
+ ref: l,
104
+ class: "yee-ui-form__fields"
105
+ }, [
106
+ (i(!0), d(G, null, K(P.value, (o) => (i(), d("label", {
107
+ key: o.fieldName,
108
+ class: "yee-ui-form__field"
109
+ }, [
110
+ f("span", Ce, R(o.label), 1),
111
+ $(e.$slots, o.fieldName, {
112
+ field: o,
113
+ setValue: (c) => S(o, c),
114
+ value: _(o),
115
+ values: r.api.getValues()
116
+ }, () => [
117
+ o.component !== "Custom" ? (i(), F(A(N(o)), j({
118
+ key: 0,
119
+ ref_for: !0
120
+ }, T(o)), null, 16)) : V("", !0)
121
+ ], !0)
122
+ ]))), 128))
123
+ ], 512),
124
+ f("div", ge, [
125
+ x(v(C), {
126
+ "html-type": "button",
127
+ onClick: E
128
+ }, {
129
+ default: y(() => [...n[0] || (n[0] = [
130
+ h(" 重置 ", -1)
131
+ ])]),
132
+ _: 1
133
+ }),
134
+ x(v(C), {
135
+ type: "primary",
136
+ "html-type": "submit"
137
+ }, {
138
+ default: y(() => [...n[1] || (n[1] = [
139
+ h(" 查询 ", -1)
140
+ ])]),
141
+ _: 1
142
+ }),
143
+ r.options.showCollapseButton ? (i(), F(v(C), {
144
+ key: 0,
145
+ type: "link",
146
+ "html-type": "button",
147
+ onClick: I
148
+ }, {
149
+ default: y(() => [
150
+ h(R(a.value ? "展开" : "收起"), 1)
151
+ ]),
152
+ _: 1
153
+ })) : V("", !0)
154
+ ])
155
+ ], 32));
156
+ }
157
+ }), Re = /* @__PURE__ */ ve(ke, [["__scopeId", "data-v-13cadc25"]]);
158
+ export {
159
+ Re as Y
160
+ };