@robot-admin/naive-ui-components 0.25.0 → 0.27.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/CHANGELOG.md +14 -0
- package/README.md +7 -9
- package/README_EN.md +6 -8
- package/dist/C_Form.base.css +31 -13
- package/dist/C_Form.css +31 -13
- package/dist/C_Form.d.cts +3 -2
- package/dist/C_Form.d.ts +3 -19
- package/dist/C_FormModal.d.cts +1 -1
- package/dist/C_FormModal.d.ts +2 -17
- package/dist/C_FormSearch.css +79 -79
- package/dist/C_FormSearch.d.cts +2 -1
- package/dist/C_FormSearch.d.ts +2 -2
- package/dist/C_FormulaEditor.d.cts +1 -1
- package/dist/C_FormulaEditor.d.ts +1 -1
- package/dist/C_Guide.d.cts +1 -1
- package/dist/C_Guide.d.ts +1 -1
- package/dist/C_Icon.d.cts +1 -1
- package/dist/C_Icon.d.ts +1 -1
- package/dist/C_Language.d.cts +1 -1
- package/dist/C_Language.d.ts +1 -1
- package/dist/C_Loading.d.cts +1 -1
- package/dist/C_Loading.d.ts +1 -1
- package/dist/C_Login.d.cts +1 -1
- package/dist/C_Login.d.ts +1 -1
- package/dist/C_Markdown.d.cts +1 -1
- package/dist/C_Markdown.d.ts +1 -1
- package/dist/C_Menu.d.ts +1 -1
- package/dist/C_OrgChart.d.cts +1 -1
- package/dist/C_OrgChart.d.ts +1 -1
- package/dist/C_Progress.d.cts +1 -1
- package/dist/C_Progress.d.ts +1 -1
- package/dist/C_SectionNav.d.cts +1 -1
- package/dist/C_SectionNav.d.ts +1 -1
- package/dist/C_Skeleton.d.cts +1 -1
- package/dist/C_Skeleton.d.ts +1 -1
- package/dist/C_Steps.d.cts +1 -1
- package/dist/C_Steps.d.ts +1 -1
- package/dist/C_Table.base.css +140 -135
- package/dist/C_Table.css +109 -122
- package/dist/C_Table.d.cts +1 -1
- package/dist/C_Table.d.ts +7 -5
- package/dist/C_Table2.cjs +3 -3
- package/dist/C_Table2.js +3 -3
- package/dist/C_TagsView.d.cts +1 -1
- package/dist/C_TagsView.d.ts +1 -1
- package/dist/C_Theme.d.cts +1 -1
- package/dist/C_Theme.d.ts +1 -1
- package/dist/C_Timeline.d.cts +1 -1
- package/dist/C_Timeline.d.ts +1 -1
- package/dist/C_Transfer.d.cts +1 -1
- package/dist/C_Transfer.d.ts +1 -1
- package/dist/C_Tree.d.cts +1 -1
- package/dist/C_Tree.d.ts +7 -5
- package/dist/C_Upload.d.cts +1 -1
- package/dist/C_Upload.d.ts +1 -1
- package/dist/config.cjs +1 -1
- package/dist/config.d.cts +1 -4
- package/dist/config.d.ts +1 -4
- package/dist/config.js +1 -1
- package/dist/constants.d.cts +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants2.d.cts +173 -402
- package/dist/constants2.d.ts +173 -402
- package/dist/constants3.d.cts +3 -3
- package/dist/constants3.d.ts +3 -3
- package/dist/constants4.d.cts +402 -173
- package/dist/constants4.d.ts +402 -173
- package/dist/constants5.d.cts +4 -4
- package/dist/constants5.d.ts +4 -4
- package/dist/data.cjs +1 -1
- package/dist/data.d.cts +1 -2
- package/dist/data.d.ts +1 -2
- package/dist/data.js +1 -1
- package/dist/data2.d.cts +10 -10
- package/dist/data2.d.ts +10 -10
- package/dist/dateRange.d.cts +3 -2
- package/dist/dateRange.d.ts +3 -2
- package/dist/helpers.cjs +1 -1
- package/dist/helpers.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +34 -34
- package/dist/index.d.ts +41 -42
- package/dist/index.js +1 -1
- package/dist/index.vue.d.cts +4 -4
- package/dist/index.vue.d.ts +4 -4
- package/dist/index10.vue.d.cts +4 -4
- package/dist/index10.vue.d.ts +3 -3
- package/dist/index11.vue.d.cts +3 -3
- package/dist/index11.vue.d.ts +7 -6
- package/dist/index12.vue.d.cts +7 -6
- package/dist/index13.vue.d.ts +5 -5
- package/dist/index14.vue.d.cts +5 -5
- package/dist/index15.vue.d.ts +52 -54
- package/dist/index16.vue.d.cts +52 -54
- package/dist/index16.vue.d.ts +125 -13
- package/dist/index17.vue.d.cts +125 -13
- package/dist/index17.vue.d.ts +51 -123
- package/dist/index18.vue.d.cts +51 -123
- package/dist/index18.vue.d.ts +26 -47
- package/dist/index19.vue.d.cts +26 -47
- package/dist/index19.vue.d.ts +13 -38
- package/dist/index20.vue.d.cts +13 -38
- package/dist/index20.vue.d.ts +128 -11
- package/dist/index21.vue.d.cts +128 -11
- package/dist/index21.vue.d.ts +75 -25
- package/dist/index22.vue.d.cts +75 -25
- package/dist/index22.vue.d.ts +72 -78
- package/dist/index23.vue.d.cts +97 -75
- package/dist/index23.vue.d.ts +96 -68
- package/dist/index24.vue.d.cts +47 -89
- package/dist/index24.vue.d.ts +47 -89
- package/dist/index25.vue.d.cts +19 -127
- package/dist/index25.vue.d.ts +19 -127
- package/dist/index26.vue.d.cts +87 -94
- package/dist/index26.vue.d.ts +87 -94
- package/dist/index27.vue.d.cts +36 -66
- package/dist/index27.vue.d.ts +36 -66
- package/dist/index28.vue.d.cts +12 -96
- package/dist/index28.vue.d.ts +12 -96
- package/dist/index29.vue.d.cts +85 -94
- package/dist/index29.vue.d.ts +85 -94
- package/dist/index3.vue.d.cts +3 -3
- package/dist/index3.vue.d.ts +3 -3
- package/dist/index30.vue.d.cts +103 -21
- package/dist/index30.vue.d.ts +103 -21
- package/dist/index31.vue.d.cts +75 -0
- package/dist/index31.vue.d.ts +75 -0
- package/dist/index5.vue.d.cts +3 -3
- package/dist/index7.vue.d.ts +1 -1
- package/dist/index8.vue.d.cts +1 -1
- package/dist/index9.vue.d.ts +4 -4
- package/dist/mapUtils.d.cts +4 -4
- package/dist/mapUtils.d.ts +4 -4
- package/dist/options.cjs +1 -0
- package/dist/options.d.cts +9 -0
- package/dist/options.js +1 -0
- package/dist/serializeSearch.cjs +1 -1
- package/dist/serializeSearch.js +1 -1
- package/dist/style.css +219 -214
- package/dist/useCollapsePanel.d.cts +4 -4
- package/dist/useCollapsePanel.d.ts +4 -4
- package/dist/useComponentLocale.cjs +1 -1
- package/dist/useComponentLocale.js +1 -1
- package/dist/useCropperCore.d.cts +6 -6
- package/dist/useCropperCore.d.ts +6 -6
- package/dist/useDynamicFormState.d.cts +12 -970
- package/dist/useDynamicFormState.d.ts +12 -960
- package/dist/useEdgeInteraction.d.cts +1 -1
- package/dist/useEdgeInteraction.d.ts +1 -1
- package/dist/useFormConfig.d.cts +5 -5
- package/dist/useFormConfig.d.ts +13 -6
- package/dist/useFullscreen.d.cts +2 -2
- package/dist/useFullscreen.d.ts +2 -2
- package/dist/useInfiniteScroll.d.cts +1 -1
- package/dist/useInfiniteScroll.d.ts +1 -1
- package/dist/useQRCode.d.cts +4 -4
- package/dist/useQRCode.d.ts +4 -4
- package/dist/useSignatureHistory.d.cts +4 -4
- package/dist/useSignatureHistory.d.ts +4 -4
- package/dist/useSplitResize.d.cts +7 -7
- package/dist/useSplitResize.d.ts +7 -7
- package/dist/useTableQuery.d.cts +899 -0
- package/dist/useTableQuery.d.ts +889 -0
- package/dist/useWorkflowValidation.d.cts +4 -4
- package/dist/useWorkflowValidation.d.ts +4 -4
- package/dist/verification.d.cts +2 -2
- package/dist/verification.d.ts +2 -2
- package/docs/guides/data-workflows.md +8 -38
- package/docs/guides/search-workflows.md +3 -5
- package/docs/guides/table-density.md +9 -1
- package/package.json +1 -1
- package/dist/dictionary.cjs +0 -1
- package/dist/dictionary.d.cts +0 -47
- package/dist/dictionary.d.ts +0 -47
- package/dist/dictionary.js +0 -1
- package/dist/useDictionary.cjs +0 -1
- package/dist/useDictionary.js +0 -1
|
@@ -261,17 +261,17 @@ declare const __VLS_export: vue.DefineComponent<WorkflowProps, {
|
|
|
261
261
|
}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
|
|
262
262
|
"update:modelValue": (value: WorkflowData) => any;
|
|
263
263
|
change: (value: WorkflowData) => any;
|
|
264
|
-
"node-click": (node: WorkflowNode<NodeType>) => any;
|
|
265
|
-
"edge-click": (edge: WorkflowEdge) => any;
|
|
266
264
|
save: (data: WorkflowData) => any;
|
|
267
265
|
"validate-error": (errors: ValidationError[]) => any;
|
|
266
|
+
"node-click": (node: WorkflowNode<NodeType>) => any;
|
|
267
|
+
"edge-click": (edge: WorkflowEdge) => any;
|
|
268
268
|
}, string, vue.PublicProps, Readonly<WorkflowProps> & Readonly<{
|
|
269
269
|
"onUpdate:modelValue"?: ((value: WorkflowData) => any) | undefined;
|
|
270
270
|
onChange?: ((value: WorkflowData) => any) | undefined;
|
|
271
|
-
"onNode-click"?: ((node: WorkflowNode<NodeType>) => any) | undefined;
|
|
272
|
-
"onEdge-click"?: ((edge: WorkflowEdge) => any) | undefined;
|
|
273
271
|
onSave?: ((data: WorkflowData) => any) | undefined;
|
|
274
272
|
"onValidate-error"?: ((errors: ValidationError[]) => any) | undefined;
|
|
273
|
+
"onNode-click"?: ((node: WorkflowNode<NodeType>) => any) | undefined;
|
|
274
|
+
"onEdge-click"?: ((edge: WorkflowEdge) => any) | undefined;
|
|
275
275
|
}>, {
|
|
276
276
|
theme: "light" | "dark";
|
|
277
277
|
readonly: boolean;
|
|
@@ -261,17 +261,17 @@ declare const __VLS_export: vue.DefineComponent<WorkflowProps, {
|
|
|
261
261
|
}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
|
|
262
262
|
"update:modelValue": (value: WorkflowData) => any;
|
|
263
263
|
change: (value: WorkflowData) => any;
|
|
264
|
-
"node-click": (node: WorkflowNode<NodeType>) => any;
|
|
265
|
-
"edge-click": (edge: WorkflowEdge) => any;
|
|
266
264
|
save: (data: WorkflowData) => any;
|
|
267
265
|
"validate-error": (errors: ValidationError[]) => any;
|
|
266
|
+
"node-click": (node: WorkflowNode<NodeType>) => any;
|
|
267
|
+
"edge-click": (edge: WorkflowEdge) => any;
|
|
268
268
|
}, string, vue.PublicProps, Readonly<WorkflowProps> & Readonly<{
|
|
269
269
|
"onUpdate:modelValue"?: ((value: WorkflowData) => any) | undefined;
|
|
270
270
|
onChange?: ((value: WorkflowData) => any) | undefined;
|
|
271
|
-
"onNode-click"?: ((node: WorkflowNode<NodeType>) => any) | undefined;
|
|
272
|
-
"onEdge-click"?: ((edge: WorkflowEdge) => any) | undefined;
|
|
273
271
|
onSave?: ((data: WorkflowData) => any) | undefined;
|
|
274
272
|
"onValidate-error"?: ((errors: ValidationError[]) => any) | undefined;
|
|
273
|
+
"onNode-click"?: ((node: WorkflowNode<NodeType>) => any) | undefined;
|
|
274
|
+
"onEdge-click"?: ((edge: WorkflowEdge) => any) | undefined;
|
|
275
275
|
}>, {
|
|
276
276
|
theme: "light" | "dark";
|
|
277
277
|
readonly: boolean;
|
package/dist/verification.d.cts
CHANGED
|
@@ -79,17 +79,17 @@ declare const __VLS_export: vue.DefineComponent<CaptchaProps, {
|
|
|
79
79
|
change: (valid: boolean) => any;
|
|
80
80
|
reset: () => any;
|
|
81
81
|
success: (data: CaptchaSuccessPayload) => any;
|
|
82
|
+
"load-error": (error: unknown) => any;
|
|
82
83
|
fail: (error: string) => any;
|
|
83
84
|
"verify-error": (error: unknown) => any;
|
|
84
|
-
"load-error": (error: unknown) => any;
|
|
85
85
|
"visible-change": (visible: boolean) => any;
|
|
86
86
|
}, string, vue.PublicProps, Readonly<CaptchaProps> & Readonly<{
|
|
87
87
|
onChange?: ((valid: boolean) => any) | undefined;
|
|
88
88
|
onReset?: (() => any) | undefined;
|
|
89
89
|
onSuccess?: ((data: CaptchaSuccessPayload) => any) | undefined;
|
|
90
|
+
"onLoad-error"?: ((error: unknown) => any) | undefined;
|
|
90
91
|
onFail?: ((error: string) => any) | undefined;
|
|
91
92
|
"onVerify-error"?: ((error: unknown) => any) | undefined;
|
|
92
|
-
"onLoad-error"?: ((error: unknown) => any) | undefined;
|
|
93
93
|
"onVisible-change"?: ((visible: boolean) => any) | undefined;
|
|
94
94
|
}>, {
|
|
95
95
|
theme: "light" | "dark";
|
package/dist/verification.d.ts
CHANGED
|
@@ -79,17 +79,17 @@ declare const __VLS_export: vue.DefineComponent<CaptchaProps, {
|
|
|
79
79
|
change: (valid: boolean) => any;
|
|
80
80
|
reset: () => any;
|
|
81
81
|
success: (data: CaptchaSuccessPayload) => any;
|
|
82
|
+
"load-error": (error: unknown) => any;
|
|
82
83
|
fail: (error: string) => any;
|
|
83
84
|
"verify-error": (error: unknown) => any;
|
|
84
|
-
"load-error": (error: unknown) => any;
|
|
85
85
|
"visible-change": (visible: boolean) => any;
|
|
86
86
|
}, string, vue.PublicProps, Readonly<CaptchaProps> & Readonly<{
|
|
87
87
|
onChange?: ((valid: boolean) => any) | undefined;
|
|
88
88
|
onReset?: (() => any) | undefined;
|
|
89
89
|
onSuccess?: ((data: CaptchaSuccessPayload) => any) | undefined;
|
|
90
|
+
"onLoad-error"?: ((error: unknown) => any) | undefined;
|
|
90
91
|
onFail?: ((error: string) => any) | undefined;
|
|
91
92
|
"onVerify-error"?: ((error: unknown) => any) | undefined;
|
|
92
|
-
"onLoad-error"?: ((error: unknown) => any) | undefined;
|
|
93
93
|
"onVisible-change"?: ((visible: boolean) => any) | undefined;
|
|
94
94
|
}>, {
|
|
95
95
|
theme: "light" | "dark";
|
|
@@ -2,47 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
搜索、表单和表格共享值语义,应用保留接口、权限、缓存和业务事务。新增能力均按需接入;未配置时沿用既有行为。
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## 外部选项与格式化
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
import Components from '@robot-admin/naive-ui-components'
|
|
9
|
-
import type { DictionarySource } from '@robot-admin/naive-ui-components/config'
|
|
10
|
-
|
|
11
|
-
const planState: DictionarySource = {
|
|
12
|
-
getOptions: () => [
|
|
13
|
-
{ value: 'released', label: '已下达' },
|
|
14
|
-
{ value: 'running', label: '执行中' },
|
|
15
|
-
],
|
|
16
|
-
}
|
|
17
|
-
app.use(Components, {
|
|
18
|
-
dictionaries: {
|
|
19
|
-
getDictionary: name => (name === 'planState' ? planState : undefined),
|
|
20
|
-
},
|
|
21
|
-
})
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
字段只写 `dictionary: 'planState'`。C_Form 的 `children`、`asyncOptions`,C_FormSearch 的显式 `list/attrs.options`,C_Table 的 `render/formatter/editProps.options` 仍按各自既有优先级生效,未使用的字典不会被加载。
|
|
25
|
-
|
|
26
|
-
按需安装可通过 `/config` 导出的 `DICTIONARY_PROVIDER_KEY` 注入同一个 Provider。不要因为使用表单而导入 MachTable 根包。
|
|
27
|
-
|
|
28
|
-
`DictionarySource` 支持:
|
|
29
|
-
|
|
30
|
-
- `getOptions()`:同步快照,编码保留 string/number/boolean 类型。
|
|
31
|
-
- `load({ signal })`:可选的异步准备;视图会忽略已失效的请求。
|
|
32
|
-
- `subscribe(listener)`:可选的更新通知,返回取消订阅函数。
|
|
33
|
-
- `getState()`:可选的共享状态快照,`status` 为 `idle/loading/ready/empty/error`,失败时可带 `error`。提供它时,订阅同时通知状态变化;源应先更新快照再通知。未提供时保持原有协议。
|
|
34
|
-
|
|
35
|
-
状态快照可选带 `options`,这代表该数组不可变,并且与 `getOptions()` 返回同一份数据。此时仅加载/失败变化不会复制选项或重建翻译索引。未提供这个承诺的旧源仍支持修改原数组后发出订阅通知。
|
|
36
|
-
|
|
37
|
-
初次绑定调用 `load({ signal })`,字段或表格的显式重试调用 `load({ signal, force: true })`。源负责合并同一字典的并发请求,某个控件卸载仅取消自己的等待,不能打断其他使用者。空数组是成功的空字典,不应通过抛错表示空结果。
|
|
38
|
-
|
|
39
|
-
表单和搜索就地显示失败与重试,表格只显示一条按字典源去重的状态条;失败保留旧标签和原值,不逐单元格弹消息。`C_Form.getDictionaryError(field)` 可读取诊断,显式 `config.onError` 仍可观测表单异常。组件不把字典错误当作字段业务校验错误,也不会覆盖校验提示。表格的显式 `feedback.error` 继续可选接管诊断。
|
|
7
|
+
组件库不注册、加载或订阅字典,也不约定第三方插件的字段或注入协议。项目可使用任意数据服务,组合成组件已有的普通配置:
|
|
40
8
|
|
|
41
|
-
|
|
9
|
+
- C_Form:`children` 为选项数组;`attrs.loading` 或 `optionsState.loading` 表示加载。
|
|
10
|
+
- C_FormSearch:`list` / `attrs.options` 为选项数组。
|
|
11
|
+
- C_Table:`formatter` / `render` 负责显示,`filterOptions` 负责筛选,`editType: 'select'` 和 `editProps.options` 负责编辑。
|
|
42
12
|
|
|
43
|
-
|
|
13
|
+
表单与搜索的 `optionsState` 只呈现外部受控的 `loading/error/retry`,不会主动调用重试或查询来源。错误就地显示,不修改业务模型或覆盖校验反馈;请求、共享缓存、身份切换与取消由项目的数据服务负责。组件自有 `asyncOptions` 保留原有取消和生命周期管理,`reloadOptions` 只重新加载这些字段。
|
|
44
14
|
|
|
45
|
-
|
|
15
|
+
布尔值只在原生选择器边界编码,提交仍保留 `false/true`;字符串、数字和前导零编码保持原样。配置项变化不会覆盖搜索草稿。
|
|
46
16
|
|
|
47
17
|
## 数值:存储、显示和校验分别定义
|
|
48
18
|
|
|
@@ -65,7 +35,7 @@ weight.format('12.5004') // '12.500 t',只舍入显示,不改原值
|
|
|
65
35
|
|
|
66
36
|
`fractionDigits: 0` 有效;HALF_UP 处理负数中点。parse 接收普通十进制原始值,format 可加千分位、前后缀;带单位/货币符号的显示文本不是接口值。合计、精确排序、汇率和税费按业务数值策略处理,不拿格式化文本计算。
|
|
67
37
|
|
|
68
|
-
MachTable 使用侧可在全局列类型中一次接入 `valueParser` 和 `valueFormatter`;精确字符串字段提供相应业务 comparator
|
|
38
|
+
MachTable 使用侧可在全局列类型中一次接入 `valueParser` 和 `valueFormatter`;精确字符串字段提供相应业务 comparator。输出策略通过公开的列格式化与导出选项定义,`summarizeRows` 可注入已有精确运算策略。Naive 库不会依赖或代替网格内核。
|
|
69
39
|
|
|
70
40
|
## 主从资源:本地空值与迟到响应
|
|
71
41
|
|
|
@@ -118,17 +118,15 @@
|
|
|
118
118
|
|
|
119
119
|
`select` 保留字符串、数字、布尔值及多选数组的业务类型。内部布尔编码仅用于适配原生选择器,提交的 `false` 不会变成字符串或 `0`。
|
|
120
120
|
|
|
121
|
-
##
|
|
121
|
+
## 外部选项与自定义控件
|
|
122
122
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
显式 `list`(包括空数组)和 `attrs.options` 优先于字典,且不会加载未使用的字典。加载失败在选择器中显示重试入口;字典标签更新不会重置输入草稿。组织切换和字典加载策略仍由应用 Provider 决定。
|
|
123
|
+
字段通过 `list` 或 `attrs.options` 接收普通选项数组。外部加载状态可传 `optionsState: { loading, error, retry }`,选择器就地呈现错误和重试入口;组件不会查询、注册或订阅外部来源。重试只在用户点击时调用,接口、取消与共享缓存由项目负责。
|
|
126
124
|
|
|
127
125
|
`custom` 可使用 `slot` 或 `render(context)`;必须声明类型正确的 `defaultValue`,使 reset 和 clear 有确定语义。上下文提供 `value`、只读 `model`、`prop`、`size`、`disabled`、`readonly` 和 `updateValue`。修改走 `updateValue`;`fixed`、`readonly`、`disabled` 字段会拦截控件回写。自定义按钮使用 `type="button"`,避免误触发表单提交。
|
|
128
126
|
|
|
129
127
|
## 草稿、执行结果和重置
|
|
130
128
|
|
|
131
|
-
- `v-model` / `formParams`
|
|
129
|
+
- `v-model` / `formParams` 是可编辑草稿;字段配置或外部选项变化不拿旧 props 覆盖未提交输入。
|
|
132
130
|
- `@search` 是经过校验的执行通知,保留原有时机;它不表示后台查询成功。
|
|
133
131
|
- 使用 `config.onSearch` 返回任务 Promise 后,只有成功完成才更新 `appliedParams` 并发出 `@applied`。回调拒绝或显式返回 `false` 时,`searchFn()` 返回 `false`,保留上一次成功条件并允许重试。可直接返回 `useDataResource.reload()` 的 boolean 结果;接入自行收拢错误的其它控制器时,回调应检查其错误状态并返回 `false`。
|
|
134
132
|
- 仅使用旧 `@search` 的接入无法观察事件监听器异步结果,因此不会伪造 `appliedParams`;需要成功快照时使用 `onSearch`。
|
|
@@ -100,7 +100,15 @@ const columns: TableColumn<Order>[] = [
|
|
|
100
100
|
const columns = [
|
|
101
101
|
{ type: 'index' },
|
|
102
102
|
{ key: 'customer', title: '客户', maxWidth: 280 },
|
|
103
|
-
{
|
|
103
|
+
{
|
|
104
|
+
key: 'status',
|
|
105
|
+
title: '状态',
|
|
106
|
+
formatter: {
|
|
107
|
+
type: 'enum',
|
|
108
|
+
fn: value => statusLabels[value] ?? String(value ?? ''),
|
|
109
|
+
},
|
|
110
|
+
status: true,
|
|
111
|
+
},
|
|
104
112
|
{
|
|
105
113
|
key: 'planStatus',
|
|
106
114
|
title: '计划状态',
|
package/package.json
CHANGED
package/dist/dictionary.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function e(e){let t=new Map;for(let n of e)t.has(n.value)||t.set(n.value,n.label);let n=e=>t.get(e)??String(e??``);return e=>Array.isArray(e)?e.map(n).join(`、`):n(e)}function t(t,n){return Array.isArray(t)?e(n)(t):n.find(e=>Object.is(e.value,t))?.label??String(t??``)}function n(e,t){let n=t.find(t=>Object.is(t.value,e));if(n)return{ok:!0,value:n.value};if(typeof e!=`string`)return{ok:!1,reason:`unknown`,input:e};let r=t.filter(t=>String(t.value)===e),i=r.length?r:t.filter(t=>t.label===e);return i.length===1?{ok:!0,value:i[0].value}:{ok:!1,reason:i.length?`ambiguous`:`unknown`,input:e}}function r(e){return Array.isArray(e)?e.map(r):typeof e==`string`||typeof e==`number`||typeof e==`boolean`?JSON.stringify([typeof e,e]):e}function i(e){if(Array.isArray(e))return e.map(i);if(typeof e!=`string`)return e;try{let t=JSON.parse(e);if(Array.isArray(t)&&t.length===2&&[`string`,`number`,`boolean`].includes(t[0])&&typeof t[1]===t[0])return t[1]}catch{}return e}function a(e){return e.map(e=>({...e,value:r(e.value)}))}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return e}});
|
package/dist/dictionary.d.cts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
//#region src/core/dictionary.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* 字典值协议与纯转换工具。数据缓存、请求与租户隔离由应用 Provider 负责。
|
|
4
|
-
* 此模块不依赖 Vue、UI、DOM 或任何表格实现,可用于导入、导出和适配层。
|
|
5
|
-
*/
|
|
6
|
-
type DictionaryValue = string | number | boolean;
|
|
7
|
-
interface DictionaryOption {
|
|
8
|
-
value: DictionaryValue;
|
|
9
|
-
label: string;
|
|
10
|
-
disabled?: boolean;
|
|
11
|
-
}
|
|
12
|
-
interface DictionarySource {
|
|
13
|
-
getOptions(): readonly DictionaryOption[];
|
|
14
|
-
load?(context: {
|
|
15
|
-
signal: AbortSignal;
|
|
16
|
-
force?: boolean;
|
|
17
|
-
}): Promise<readonly DictionaryOption[]>;
|
|
18
|
-
/** 可选的共享加载状态;订阅同时通知数据和状态更新。 */
|
|
19
|
-
getState?(): DictionaryState;
|
|
20
|
-
subscribe?(listener: () => void): () => void;
|
|
21
|
-
}
|
|
22
|
-
interface DictionaryState {
|
|
23
|
-
status: 'idle' | 'loading' | 'ready' | 'empty' | 'error';
|
|
24
|
-
error?: unknown;
|
|
25
|
-
/** 可选的不可变数据快照;仅状态变化时应复用同一数组,不可原地修改。 */
|
|
26
|
-
options?: readonly DictionaryOption[];
|
|
27
|
-
}
|
|
28
|
-
interface DictionaryProvider {
|
|
29
|
-
getDictionary(name: string): DictionarySource | undefined;
|
|
30
|
-
}
|
|
31
|
-
type DictionaryBinding = string | DictionarySource;
|
|
32
|
-
type DictionaryParseResult = {
|
|
33
|
-
ok: true;
|
|
34
|
-
value: DictionaryValue;
|
|
35
|
-
} | {
|
|
36
|
-
ok: false;
|
|
37
|
-
reason: 'unknown' | 'ambiguous';
|
|
38
|
-
input: unknown;
|
|
39
|
-
};
|
|
40
|
-
/** 每份选项快照只建一次索引,表格单元格解析不重复遍历整份字典。 */
|
|
41
|
-
declare function createDictionaryLabelResolver(options: readonly DictionaryOption[]): (value: unknown) => string;
|
|
42
|
-
/** 原值比较保留 boolean、数值和带前导零的字符串编码,不回写展示标签。 */
|
|
43
|
-
declare function getDictionaryLabel(value: unknown, options: readonly DictionaryOption[]): string;
|
|
44
|
-
/** 原码优先于标签;多义标签或字符串化编码必须交由使用侧明确处理。 */
|
|
45
|
-
declare function parseDictionaryValue(input: unknown, options: readonly DictionaryOption[]): DictionaryParseResult;
|
|
46
|
-
//#endregion
|
|
47
|
-
export { DictionarySource as a, createDictionaryLabelResolver as c, DictionaryProvider as i, getDictionaryLabel as l, DictionaryOption as n, DictionaryState as o, DictionaryParseResult as r, DictionaryValue as s, DictionaryBinding as t, parseDictionaryValue as u };
|
package/dist/dictionary.d.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
//#region src/core/dictionary.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* 字典值协议与纯转换工具。数据缓存、请求与租户隔离由应用 Provider 负责。
|
|
4
|
-
* 此模块不依赖 Vue、UI、DOM 或任何表格实现,可用于导入、导出和适配层。
|
|
5
|
-
*/
|
|
6
|
-
type DictionaryValue = string | number | boolean;
|
|
7
|
-
interface DictionaryOption {
|
|
8
|
-
value: DictionaryValue;
|
|
9
|
-
label: string;
|
|
10
|
-
disabled?: boolean;
|
|
11
|
-
}
|
|
12
|
-
interface DictionarySource {
|
|
13
|
-
getOptions(): readonly DictionaryOption[];
|
|
14
|
-
load?(context: {
|
|
15
|
-
signal: AbortSignal;
|
|
16
|
-
force?: boolean;
|
|
17
|
-
}): Promise<readonly DictionaryOption[]>;
|
|
18
|
-
/** 可选的共享加载状态;订阅同时通知数据和状态更新。 */
|
|
19
|
-
getState?(): DictionaryState;
|
|
20
|
-
subscribe?(listener: () => void): () => void;
|
|
21
|
-
}
|
|
22
|
-
interface DictionaryState {
|
|
23
|
-
status: 'idle' | 'loading' | 'ready' | 'empty' | 'error';
|
|
24
|
-
error?: unknown;
|
|
25
|
-
/** 可选的不可变数据快照;仅状态变化时应复用同一数组,不可原地修改。 */
|
|
26
|
-
options?: readonly DictionaryOption[];
|
|
27
|
-
}
|
|
28
|
-
interface DictionaryProvider {
|
|
29
|
-
getDictionary(name: string): DictionarySource | undefined;
|
|
30
|
-
}
|
|
31
|
-
type DictionaryBinding = string | DictionarySource;
|
|
32
|
-
type DictionaryParseResult = {
|
|
33
|
-
ok: true;
|
|
34
|
-
value: DictionaryValue;
|
|
35
|
-
} | {
|
|
36
|
-
ok: false;
|
|
37
|
-
reason: 'unknown' | 'ambiguous';
|
|
38
|
-
input: unknown;
|
|
39
|
-
};
|
|
40
|
-
/** 每份选项快照只建一次索引,表格单元格解析不重复遍历整份字典。 */
|
|
41
|
-
declare function createDictionaryLabelResolver(options: readonly DictionaryOption[]): (value: unknown) => string;
|
|
42
|
-
/** 原值比较保留 boolean、数值和带前导零的字符串编码,不回写展示标签。 */
|
|
43
|
-
declare function getDictionaryLabel(value: unknown, options: readonly DictionaryOption[]): string;
|
|
44
|
-
/** 原码优先于标签;多义标签或字符串化编码必须交由使用侧明确处理。 */
|
|
45
|
-
declare function parseDictionaryValue(input: unknown, options: readonly DictionaryOption[]): DictionaryParseResult;
|
|
46
|
-
//#endregion
|
|
47
|
-
export { DictionarySource as a, createDictionaryLabelResolver as c, DictionaryProvider as i, getDictionaryLabel as l, DictionaryOption as n, DictionaryState as o, DictionaryParseResult as r, DictionaryValue as s, DictionaryBinding as t, parseDictionaryValue as u };
|
package/dist/dictionary.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function e(e){let t=new Map;for(let n of e)t.has(n.value)||t.set(n.value,n.label);let n=e=>t.get(e)??String(e??``);return e=>Array.isArray(e)?e.map(n).join(`、`):n(e)}function t(t,n){return Array.isArray(t)?e(n)(t):n.find(e=>Object.is(e.value,t))?.label??String(t??``)}function n(e,t){let n=t.find(t=>Object.is(t.value,e));if(n)return{ok:!0,value:n.value};if(typeof e!=`string`)return{ok:!1,reason:`unknown`,input:e};let r=t.filter(t=>String(t.value)===e),i=r.length?r:t.filter(t=>t.label===e);return i.length===1?{ok:!0,value:i[0].value}:{ok:!1,reason:i.length?`ambiguous`:`unknown`,input:e}}function r(e){return Array.isArray(e)?e.map(r):typeof e==`string`||typeof e==`number`||typeof e==`boolean`?JSON.stringify([typeof e,e]):e}function i(e){if(Array.isArray(e))return e.map(i);if(typeof e!=`string`)return e;try{let t=JSON.parse(e);if(Array.isArray(t)&&t.length===2&&[`string`,`number`,`boolean`].includes(t[0])&&typeof t[1]===t[0])return t[1]}catch{}return e}function a(e){return e.map(e=>({...e,value:r(e.value)}))}export{n as a,t as i,i as n,a as o,r,e as t};
|
package/dist/useDictionary.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require(`./chunk.cjs`);const e=require(`./dictionary.cjs`),t=require(`./observer.cjs`),n=require(`./config.cjs`);let r=require(`vue`);const i=Object.freeze([]);function a(e,t){let n=e.getState?.()?.options;return n===t?n:void 0}function o(e){return typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&Number.isFinite(e)}function s(e,t){if(!e||typeof e.label!=`string`||!o(e.value))throw TypeError(`[dictionary] 选项必须有字符串 label 和有限的原始 value`);if(e.disabled!==void 0&&typeof e.disabled!=`boolean`)throw TypeError(`[dictionary] disabled 必须是 boolean`);if(t.has(e.value))throw TypeError(`[dictionary] 选项 value 不得重复`);return t.add(e.value),{...e}}function c(o,c={}){let l=(0,r.getCurrentInstance)()?(0,r.inject)(n.DICTIONARY_PROVIDER_KEY,void 0):void 0,u=new Map,d=(0,r.shallowReactive)(new Map),f=(0,r.shallowReactive)(new Map),p=(0,r.shallowReactive)(new Map),m=(0,r.shallowReactive)(new Map),h=!1,g=(e,t)=>!h&&u.get(e)===t,_=(e,t,n)=>g(e,t)&&!n.signal.aborted&&t.controller===n,v=(e,n,r)=>{h||r&&!g(e,r)||(n??=`[dictionary] 字典加载失败`,!(p.has(e)&&Object.is(p.get(e),n))&&(p.set(e,n),!h&&(!r||g(e,r))&&t.t(()=>c.onError?.(n,e))))},y=e=>{if(!Array.isArray(e))throw TypeError(`[dictionary] 选项源必须返回数组`);let t=new Set;return e.map(e=>s(e,t))},b=(t,n,r)=>{if(!g(t,n))return!1;let i=a(n.source,r);if(i&&n.immutableSnapshot===i)return g(t,n);let o=y(r);return!g(t,n)||(d.set(t,o),!g(t,n))?!1:(m.set(t,e.t(o)),g(t,n)&&(n.immutableSnapshot=i),g(t,n))};function x(e,t,n=!1){if(!g(e,t))return;let r=t.source.getState?.();if(g(e,t)){if(!r){n&&p.delete(e);return}f.set(e,r.status===`loading`),g(e,t)&&(r.status===`error`?v(e,r.error??`[dictionary] 字典加载失败`,t):p.delete(e))}}function S(e,t){if(g(e,t))try{b(e,t,t.source.getOptions())&&x(e,t,!0)}catch(n){v(e,n,t)}}function C(e,t,n){if(g(e,t)&&t.controller===n){if(t.controller=void 0,f.set(e,!1),t.controller)return;try{x(e,t)}catch(n){v(e,n,t)}}}async function w(e,t,n,r){let i=new AbortController;t.controller=i;let{revision:a}=t;if(f.set(e,!0),_(e,t,i)&&(p.delete(e),_(e,t,i)))try{let o=await n.call(t.source,{signal:i.signal,...r?{force:!0}:{}});if(!_(e,t,i))return;b(e,t,a===t.revision?o:t.source.getOptions()),x(e,t)}catch(n){_(e,t,i)&&v(e,n,t)}finally{C(e,t,i)}}async function T(e,t,n=!1){if(!g(e,t))return;let r=t.controller;if(t.controller=void 0,r?.abort(),!g(e,t)||t.controller)return;let i=t.source.load;i?await w(e,t,i,n):S(e,t)}function E(e,n){if(S(e,n),g(e,n)){try{let r=n.source.subscribe?.(()=>{g(e,n)&&(n.revision++,S(e,n))});g(e,n)?n.unsubscribe=r:t.t(()=>r?.())}catch(t){v(e,t,n)}n.source.load&&T(e,n)}}function D({key:e,binding:t,source:n,error:r}){if(h)return;let i=u.get(e);if(i&&i.source===n&&i.binding===t||(O(e),h))return;if(!n){t!==void 0&&v(e,r??Error(`[dictionary] 未注册字典: ${String(t)}`));return}let a={binding:t,source:n,revision:0};u.set(e,a),E(e,a)}function O(e){let t=u.get(e);u.delete(e),t?.controller?.abort();try{t?.unsubscribe?.()}catch(t){h||v(e,t)}d.delete(e),f.delete(e),p.delete(e),m.delete(e)}let k=()=>{};(0,r.getCurrentScope)()&&(0,r.onScopeDispose)(A),k=(0,r.watch)(()=>[...(0,r.toValue)(o)].map(([e,t])=>{try{return{key:e,binding:t,source:typeof t==`string`?l?.getDictionary(t):t}}catch(n){return{key:e,binding:t,source:void 0,error:n}}}),e=>{let t=new Set(e.map(e=>e.key));for(let e of new Set([...u.keys(),...p.keys()]))t.has(e)||O(e);e.forEach(D)},{immediate:!0}),h&&k();function A(){if(!h){h=!0,k();for(let e of new Set([...u.keys(),...p.keys()]))O(e)}}return{dispose:A,getOptions:e=>d.get(e)??i,getLabel:(e,t)=>m.get(e)?.(t)??String(t??``),isLoading:e=>f.get(e)??!1,getError:e=>p.get(e),getSource:e=>u.get(e)?.source,async reload(e){let t=e===void 0?[...u]:u.has(e)?[[e,u.get(e)]]:[];await Promise.all(t.map(([e,t])=>T(e,t,!0)))}}}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return c}});
|
package/dist/useDictionary.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./dictionary.js";import{t}from"./observer.js";import{DICTIONARY_PROVIDER_KEY as n}from"./config.js";import{getCurrentInstance as r,getCurrentScope as i,inject as a,onScopeDispose as o,shallowReactive as s,toValue as c,watch as l}from"vue";const u=Object.freeze([]);function d(e,t){let n=e.getState?.()?.options;return n===t?n:void 0}function f(e){return typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&Number.isFinite(e)}function p(e,t){if(!e||typeof e.label!=`string`||!f(e.value))throw TypeError(`[dictionary] 选项必须有字符串 label 和有限的原始 value`);if(e.disabled!==void 0&&typeof e.disabled!=`boolean`)throw TypeError(`[dictionary] disabled 必须是 boolean`);if(t.has(e.value))throw TypeError(`[dictionary] 选项 value 不得重复`);return t.add(e.value),{...e}}function m(f,m={}){let h=r()?a(n,void 0):void 0,g=new Map,_=s(new Map),v=s(new Map),y=s(new Map),b=s(new Map),x=!1,S=(e,t)=>!x&&g.get(e)===t,C=(e,t,n)=>S(e,t)&&!n.signal.aborted&&t.controller===n,w=(e,n,r)=>{x||r&&!S(e,r)||(n??=`[dictionary] 字典加载失败`,!(y.has(e)&&Object.is(y.get(e),n))&&(y.set(e,n),!x&&(!r||S(e,r))&&t(()=>m.onError?.(n,e))))},T=e=>{if(!Array.isArray(e))throw TypeError(`[dictionary] 选项源必须返回数组`);let t=new Set;return e.map(e=>p(e,t))},E=(t,n,r)=>{if(!S(t,n))return!1;let i=d(n.source,r);if(i&&n.immutableSnapshot===i)return S(t,n);let a=T(r);return!S(t,n)||(_.set(t,a),!S(t,n))?!1:(b.set(t,e(a)),S(t,n)&&(n.immutableSnapshot=i),S(t,n))};function D(e,t,n=!1){if(!S(e,t))return;let r=t.source.getState?.();if(S(e,t)){if(!r){n&&y.delete(e);return}v.set(e,r.status===`loading`),S(e,t)&&(r.status===`error`?w(e,r.error??`[dictionary] 字典加载失败`,t):y.delete(e))}}function O(e,t){if(S(e,t))try{E(e,t,t.source.getOptions())&&D(e,t,!0)}catch(n){w(e,n,t)}}function k(e,t,n){if(S(e,t)&&t.controller===n){if(t.controller=void 0,v.set(e,!1),t.controller)return;try{D(e,t)}catch(n){w(e,n,t)}}}async function A(e,t,n,r){let i=new AbortController;t.controller=i;let{revision:a}=t;if(v.set(e,!0),C(e,t,i)&&(y.delete(e),C(e,t,i)))try{let o=await n.call(t.source,{signal:i.signal,...r?{force:!0}:{}});if(!C(e,t,i))return;E(e,t,a===t.revision?o:t.source.getOptions()),D(e,t)}catch(n){C(e,t,i)&&w(e,n,t)}finally{k(e,t,i)}}async function j(e,t,n=!1){if(!S(e,t))return;let r=t.controller;if(t.controller=void 0,r?.abort(),!S(e,t)||t.controller)return;let i=t.source.load;i?await A(e,t,i,n):O(e,t)}function M(e,n){if(O(e,n),S(e,n)){try{let r=n.source.subscribe?.(()=>{S(e,n)&&(n.revision++,O(e,n))});S(e,n)?n.unsubscribe=r:t(()=>r?.())}catch(t){w(e,t,n)}n.source.load&&j(e,n)}}function N({key:e,binding:t,source:n,error:r}){if(x)return;let i=g.get(e);if(i&&i.source===n&&i.binding===t||(P(e),x))return;if(!n){t!==void 0&&w(e,r??Error(`[dictionary] 未注册字典: ${String(t)}`));return}let a={binding:t,source:n,revision:0};g.set(e,a),M(e,a)}function P(e){let t=g.get(e);g.delete(e),t?.controller?.abort();try{t?.unsubscribe?.()}catch(t){x||w(e,t)}_.delete(e),v.delete(e),y.delete(e),b.delete(e)}let F=()=>{};i()&&o(I),F=l(()=>[...c(f)].map(([e,t])=>{try{return{key:e,binding:t,source:typeof t==`string`?h?.getDictionary(t):t}}catch(n){return{key:e,binding:t,source:void 0,error:n}}}),e=>{let t=new Set(e.map(e=>e.key));for(let e of new Set([...g.keys(),...y.keys()]))t.has(e)||P(e);e.forEach(N)},{immediate:!0}),x&&F();function I(){if(!x){x=!0,F();for(let e of new Set([...g.keys(),...y.keys()]))P(e)}}return{dispose:I,getOptions:e=>_.get(e)??u,getLabel:(e,t)=>b.get(e)?.(t)??String(t??``),isLoading:e=>v.get(e)??!1,getError:e=>y.get(e),getSource:e=>g.get(e)?.source,async reload(e){let t=e===void 0?[...g]:g.has(e)?[[e,g.get(e)]]:[];await Promise.all(t.map(([e,t])=>j(e,t,!0)))}}}export{m as t};
|