@robot-admin/naive-ui-components 0.29.2 → 0.29.3
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 +8 -0
- package/dist/C_ActionBar.css +49 -49
- package/dist/C_ActionBar2.cjs +1 -1
- package/dist/C_ActionBar2.js +1 -1
- package/dist/C_DataPicker.d.cts +2 -2
- package/dist/C_DataPicker.d.ts +2 -2
- package/dist/C_DataPicker2.cjs +1 -1
- package/dist/C_DataPicker2.js +1 -1
- package/dist/C_FormModal.css +49 -49
- package/dist/C_Table.base.css +49 -49
- package/dist/C_Table.css +49 -49
- package/dist/C_Table.d.cts +1 -1
- package/dist/C_Table.d.ts +1 -1
- package/dist/constants.d.cts +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants2.d.cts +1 -1
- package/dist/constants2.d.ts +1 -1
- package/dist/constants3.d.cts +1 -1
- package/dist/constants3.d.ts +1 -1
- package/dist/constants4.d.cts +6 -6
- package/dist/constants4.d.ts +6 -6
- package/dist/constants5.d.cts +2 -2
- package/dist/constants5.d.ts +2 -2
- package/dist/data2.d.cts +7 -7
- package/dist/data2.d.ts +7 -7
- package/dist/dateRange.d.cts +7 -2
- package/dist/dateRange.d.ts +7 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.vue.d.cts +2 -2
- package/dist/index.vue.d.ts +2 -2
- package/dist/index10.vue.d.cts +3 -3
- package/dist/index10.vue.d.ts +3 -3
- package/dist/index11.vue.d.cts +3 -3
- package/dist/index11.vue.d.ts +9 -4
- package/dist/index12.vue.d.cts +9 -4
- package/dist/index13.vue.d.ts +4 -4
- package/dist/index14.vue.d.cts +4 -4
- package/dist/index16.vue.d.ts +5 -5
- package/dist/index17.vue.d.cts +5 -5
- package/dist/index17.vue.d.ts +8 -8
- package/dist/index18.vue.d.cts +8 -8
- package/dist/index19.vue.d.ts +1 -1
- package/dist/index2.vue.d.cts +2 -2
- package/dist/index2.vue.d.ts +2 -2
- package/dist/index20.vue.d.cts +1 -1
- package/dist/index20.vue.d.ts +1 -1
- package/dist/index21.vue.d.cts +1 -1
- package/dist/index21.vue.d.ts +2 -2
- package/dist/index22.vue.d.cts +2 -2
- package/dist/index23.vue.d.cts +3 -3
- package/dist/index23.vue.d.ts +3 -3
- package/dist/index24.vue.d.cts +1 -1
- package/dist/index24.vue.d.ts +1 -1
- package/dist/index26.vue.d.cts +2 -2
- package/dist/index26.vue.d.ts +2 -2
- package/dist/index27.vue.d.cts +1 -1
- package/dist/index27.vue.d.ts +1 -1
- package/dist/index29.vue.d.cts +1 -1
- package/dist/index29.vue.d.ts +1 -1
- package/dist/index3.vue.d.cts +5 -5
- package/dist/index3.vue.d.ts +5 -5
- package/dist/index30.vue.d.cts +3 -3
- package/dist/index30.vue.d.ts +3 -3
- package/dist/index9.vue.d.ts +3 -3
- package/dist/mapUtils.d.cts +4 -4
- package/dist/mapUtils.d.ts +4 -4
- package/dist/presets.d.cts +1 -1
- package/dist/presets.d.ts +1 -1
- package/dist/style.css +49 -49
- package/dist/useCalendarEvents.d.cts +1 -1
- package/dist/useCalendarEvents.d.ts +1 -1
- package/dist/useCollapsePanel.d.cts +3 -3
- package/dist/useCollapsePanel.d.ts +3 -3
- package/dist/useCropperCore.d.cts +13 -13
- package/dist/useCropperCore.d.ts +13 -13
- package/dist/useEdgeInteraction.d.cts +3 -3
- package/dist/useEdgeInteraction.d.ts +3 -3
- package/dist/useFullscreen.d.cts +2 -2
- package/dist/useFullscreen.d.ts +2 -2
- package/dist/useGlobalSearch.d.cts +1 -1
- package/dist/useGlobalSearch.d.ts +1 -1
- package/dist/useInfiniteScroll.d.cts +4 -4
- package/dist/useInfiniteScroll.d.ts +4 -4
- package/dist/useQRCode.d.cts +2 -2
- package/dist/useQRCode.d.ts +2 -2
- package/dist/useSignatureHistory.d.cts +6 -6
- package/dist/useSignatureHistory.d.ts +6 -6
- package/dist/useSplitResize.d.cts +8 -8
- package/dist/useSplitResize.d.ts +8 -8
- package/dist/useTableQuery.d.cts +6 -6
- package/dist/useTableQuery.d.ts +6 -6
- package/dist/useWorkflowValidation.d.cts +33 -33
- package/dist/useWorkflowValidation.d.ts +33 -33
- package/dist/verification.d.cts +3 -3
- package/dist/verification.d.ts +3 -3
- package/docs/guides/data-picker.md +8 -8
- package/docs/guides/usage.en.md +16 -15
- package/docs/guides/usage.md +16 -15
- package/package.json +1 -1
package/docs/guides/usage.en.md
CHANGED
|
@@ -173,6 +173,15 @@ Inside `NConfigProvider`, the popover follows its light/dark theme and primary c
|
|
|
173
173
|
|
|
174
174
|
## Recommended C_Form / C_Table setup
|
|
175
175
|
|
|
176
|
+
Start with the smallest setup for common pages:
|
|
177
|
+
|
|
178
|
+
| Use case | Minimal setup |
|
|
179
|
+
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
180
|
+
| Basic edit form | `<C_Form v-model="draft" :options="fields" />`; initialize `draft` with all business fields needed at submit time, including those not rendered. Use `useCForm()` if you also need to read, write, or validate outside the template. |
|
|
181
|
+
| Search and remote table | Use `{ onSearch: setQuery }` for the search config and `v-bind="bindings"` for the table, both from one `useTableQuery()` instance. |
|
|
182
|
+
| Local table | `<C_Table :data="rows" :columns="columns" />`; omit `row-key` if each row has a stable `id`. |
|
|
183
|
+
| Common toolbar | `<C_ActionBar :actions="[{ key: 'refresh', onClick: reload }]" />`; compact sizing, the icon, and the label are already provided. |
|
|
184
|
+
|
|
176
185
|
Declare the business model once and keep nested field paths, values, column keys, callbacks, and exposed methods type-safe:
|
|
177
186
|
|
|
178
187
|
```ts
|
|
@@ -472,9 +481,7 @@ Use `C_FormSearch` with `v-model`; legacy `formParams` remains supported. Put re
|
|
|
472
481
|
import { ref } from 'vue'
|
|
473
482
|
import {
|
|
474
483
|
C_FormSearch,
|
|
475
|
-
type SearchConfig,
|
|
476
484
|
type SearchFormItem,
|
|
477
|
-
type SearchFormParams,
|
|
478
485
|
} from '@robot-admin/naive-ui-components/C_FormSearch'
|
|
479
486
|
import {
|
|
480
487
|
C_Table,
|
|
@@ -483,31 +490,25 @@ Use `C_FormSearch` with `v-model`; legacy `formParams` remains supported. Put re
|
|
|
483
490
|
import '@robot-admin/naive-ui-components/C_FormSearch/style.css'
|
|
484
491
|
import '@robot-admin/naive-ui-components/C_Table/base.css'
|
|
485
492
|
|
|
486
|
-
const
|
|
487
|
-
const
|
|
493
|
+
const initialQuery = { keyword: '' }
|
|
494
|
+
const filters = ref({ ...initialQuery })
|
|
495
|
+
const searchFields: SearchFormItem<typeof initialQuery>[] = [
|
|
488
496
|
{ type: 'input', prop: 'keyword', placeholder: 'Keyword' },
|
|
489
497
|
]
|
|
490
498
|
const { bindings, loading, setQuery } = useTableQuery({
|
|
491
|
-
initialQuery
|
|
499
|
+
initialQuery,
|
|
492
500
|
columns,
|
|
493
|
-
rowKey: 'id',
|
|
494
501
|
request: loadUsers,
|
|
495
502
|
})
|
|
496
|
-
const applyQuery = (params: SearchFormParams) =>
|
|
497
|
-
setQuery({ keyword: String(params.keyword ?? '') })
|
|
498
|
-
const searchConfig: SearchConfig = {
|
|
499
|
-
requireValue: false,
|
|
500
|
-
onSearch: applyQuery,
|
|
501
|
-
}
|
|
502
503
|
</script>
|
|
503
504
|
|
|
504
505
|
<template>
|
|
505
506
|
<C_FormSearch
|
|
506
507
|
v-model="filters"
|
|
507
508
|
:form-item-list="searchFields"
|
|
508
|
-
:config="
|
|
509
|
+
:config="{ requireValue: false, onSearch: setQuery }"
|
|
509
510
|
:loading="loading"
|
|
510
|
-
@reset="
|
|
511
|
+
@reset="setQuery"
|
|
511
512
|
/>
|
|
512
513
|
<C_Table v-bind="bindings" />
|
|
513
514
|
</template>
|
|
@@ -515,7 +516,7 @@ Use `C_FormSearch` with `v-model`; legacy `formParams` remains supported. Put re
|
|
|
515
516
|
|
|
516
517
|
The search button, native form submission (including Enter in an input), and exposed `searchFn()` share validation and duplicate prevention. Only currently mounted search controls participate in Naive form validation. Editing conditions, enabling external loading, or unmounting during async validation cancels dispatch; requests receive the successfully validated snapshot. At least one non-pagination value is required by default; set `requireValue: false` to allow an empty query.
|
|
517
518
|
|
|
518
|
-
The `reset(params)` event follows the synchronous v-model update and carries the complete reset snapshot. Existing no-argument handlers remain compatible. Reset restores field defaults while retaining `pageNum/pageSize`; it does not automatically request or debounce. This example
|
|
519
|
+
The `reset(params)` event follows the synchronous v-model update and carries the complete reset snapshot. Existing no-argument handlers remain compatible. Reset restores field defaults while retaining `pageNum/pageSize`; it does not automatically request or debounce. This example uses `@reset="setQuery"` to reload on the first page. For custom fields declared as `SearchFormItem<Query>`, `render` infers `value` and `updateValue` from `prop`; arbitrary named field slots still require narrowing the actual value.
|
|
519
520
|
|
|
520
521
|
### Action configuration and asynchronous work
|
|
521
522
|
|
package/docs/guides/usage.md
CHANGED
|
@@ -194,6 +194,15 @@ Cron 支持秒到星期的六个数字字段、范围、间隔、列表及日/
|
|
|
194
194
|
|
|
195
195
|
## C_Form / C_Table 推荐用法
|
|
196
196
|
|
|
197
|
+
高频页面先从最少配置开始:
|
|
198
|
+
|
|
199
|
+
| 场景 | 最短接入 |
|
|
200
|
+
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
201
|
+
| 普通编辑表单 | `<C_Form v-model="draft" :options="fields" />`;提交需要完整业务模型时,用 `draft` 提供包括未渲染字段在内的初值。需要在模板外统一读写或校验时,再用 `useCForm()`。 |
|
|
202
|
+
| 搜索远程表格 | 搜索配置直接用 `{ onSearch: setQuery }`,表格用 `v-bind="bindings"`;`setQuery` 和 `bindings` 来自同一个 `useTableQuery()`。 |
|
|
203
|
+
| 本地表格 | `<C_Table :data="rows" :columns="columns" />`;行键是 `id` 时可省略 `row-key`。 |
|
|
204
|
+
| 常见工具栏 | `<C_ActionBar :actions="[{ key: 'refresh', onClick: reload }]" />`;紧凑尺寸、图标和文字都有默认值,只写有业务含义的覆盖。 |
|
|
205
|
+
|
|
197
206
|
推荐使用类型助手和绑定助手:业务模型只声明一次,字段路径、字段值、列 key、保存回调和实例方法即可保持同一套类型推导。字段支持 `profile.name`、`contacts.0.email` 这类嵌套路径。
|
|
198
207
|
|
|
199
208
|
```vue
|
|
@@ -611,9 +620,7 @@ const filters: SearchFormItem[] = [
|
|
|
611
620
|
import { ref } from 'vue'
|
|
612
621
|
import {
|
|
613
622
|
C_FormSearch,
|
|
614
|
-
type SearchConfig,
|
|
615
623
|
type SearchFormItem,
|
|
616
|
-
type SearchFormParams,
|
|
617
624
|
} from '@robot-admin/naive-ui-components/C_FormSearch'
|
|
618
625
|
import {
|
|
619
626
|
C_Table,
|
|
@@ -622,31 +629,25 @@ const filters: SearchFormItem[] = [
|
|
|
622
629
|
import '@robot-admin/naive-ui-components/C_FormSearch/style.css'
|
|
623
630
|
import '@robot-admin/naive-ui-components/C_Table/base.css'
|
|
624
631
|
|
|
625
|
-
const
|
|
626
|
-
const
|
|
632
|
+
const initialQuery = { keyword: '' }
|
|
633
|
+
const filters = ref({ ...initialQuery })
|
|
634
|
+
const searchFields: SearchFormItem<typeof initialQuery>[] = [
|
|
627
635
|
{ type: 'input', prop: 'keyword', placeholder: '关键词' },
|
|
628
636
|
]
|
|
629
637
|
const { bindings, loading, setQuery } = useTableQuery({
|
|
630
|
-
initialQuery
|
|
638
|
+
initialQuery,
|
|
631
639
|
columns,
|
|
632
|
-
rowKey: 'id',
|
|
633
640
|
request: loadUsers,
|
|
634
641
|
})
|
|
635
|
-
const applyQuery = (params: SearchFormParams) =>
|
|
636
|
-
setQuery({ keyword: String(params.keyword ?? '') })
|
|
637
|
-
const searchConfig: SearchConfig = {
|
|
638
|
-
requireValue: false,
|
|
639
|
-
onSearch: applyQuery,
|
|
640
|
-
}
|
|
641
642
|
</script>
|
|
642
643
|
|
|
643
644
|
<template>
|
|
644
645
|
<C_FormSearch
|
|
645
646
|
v-model="filters"
|
|
646
647
|
:form-item-list="searchFields"
|
|
647
|
-
:config="
|
|
648
|
+
:config="{ requireValue: false, onSearch: setQuery }"
|
|
648
649
|
:loading="loading"
|
|
649
|
-
@reset="
|
|
650
|
+
@reset="setQuery"
|
|
650
651
|
/>
|
|
651
652
|
<C_Table v-bind="bindings" />
|
|
652
653
|
</template>
|
|
@@ -654,7 +655,7 @@ const filters: SearchFormItem[] = [
|
|
|
654
655
|
|
|
655
656
|
搜索按钮、原生表单提交(含输入框 Enter)和实例 `searchFn()` 走同一校验与防重路径;仅当前挂载的搜索控件参与 Naive 表单校验。异步校验期间条件改变、外部 loading 开启或组件卸载,会取消本次派发,成功校验的快照才进入请求。默认要求至少一个非分页条件;需要空条件查询时设置 `requireValue: false`。
|
|
656
657
|
|
|
657
|
-
`reset(params)` 事件先同步更新 v-model,再通知重置后的完整快照;不带参数的旧回调继续可用。默认仅恢复字段默认值并保留 `pageNum/pageSize`,不自动查询、不添加 debounce
|
|
658
|
+
`reset(params)` 事件先同步更新 v-model,再通知重置后的完整快照;不带参数的旧回调继续可用。默认仅恢复字段默认值并保留 `pageNum/pageSize`,不自动查询、不添加 debounce。上例直接用 `@reset="setQuery"` 刷新并回到第一页。自定义字段使用 `SearchFormItem<Query>` 的 `render` 时,`value` 和 `updateValue` 会随 `prop` 推导;任意命名的字段插槽仍需在使用侧按实际值缩窄类型。
|
|
658
659
|
|
|
659
660
|
### 动作配置与异步执行
|
|
660
661
|
|