@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.
Files changed (100) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/C_ActionBar.css +49 -49
  3. package/dist/C_ActionBar2.cjs +1 -1
  4. package/dist/C_ActionBar2.js +1 -1
  5. package/dist/C_DataPicker.d.cts +2 -2
  6. package/dist/C_DataPicker.d.ts +2 -2
  7. package/dist/C_DataPicker2.cjs +1 -1
  8. package/dist/C_DataPicker2.js +1 -1
  9. package/dist/C_FormModal.css +49 -49
  10. package/dist/C_Table.base.css +49 -49
  11. package/dist/C_Table.css +49 -49
  12. package/dist/C_Table.d.cts +1 -1
  13. package/dist/C_Table.d.ts +1 -1
  14. package/dist/constants.d.cts +1 -1
  15. package/dist/constants.d.ts +1 -1
  16. package/dist/constants2.d.cts +1 -1
  17. package/dist/constants2.d.ts +1 -1
  18. package/dist/constants3.d.cts +1 -1
  19. package/dist/constants3.d.ts +1 -1
  20. package/dist/constants4.d.cts +6 -6
  21. package/dist/constants4.d.ts +6 -6
  22. package/dist/constants5.d.cts +2 -2
  23. package/dist/constants5.d.ts +2 -2
  24. package/dist/data2.d.cts +7 -7
  25. package/dist/data2.d.ts +7 -7
  26. package/dist/dateRange.d.cts +7 -2
  27. package/dist/dateRange.d.ts +7 -2
  28. package/dist/index.d.cts +2 -2
  29. package/dist/index.d.ts +2 -2
  30. package/dist/index.vue.d.cts +2 -2
  31. package/dist/index.vue.d.ts +2 -2
  32. package/dist/index10.vue.d.cts +3 -3
  33. package/dist/index10.vue.d.ts +3 -3
  34. package/dist/index11.vue.d.cts +3 -3
  35. package/dist/index11.vue.d.ts +9 -4
  36. package/dist/index12.vue.d.cts +9 -4
  37. package/dist/index13.vue.d.ts +4 -4
  38. package/dist/index14.vue.d.cts +4 -4
  39. package/dist/index16.vue.d.ts +5 -5
  40. package/dist/index17.vue.d.cts +5 -5
  41. package/dist/index17.vue.d.ts +8 -8
  42. package/dist/index18.vue.d.cts +8 -8
  43. package/dist/index19.vue.d.ts +1 -1
  44. package/dist/index2.vue.d.cts +2 -2
  45. package/dist/index2.vue.d.ts +2 -2
  46. package/dist/index20.vue.d.cts +1 -1
  47. package/dist/index20.vue.d.ts +1 -1
  48. package/dist/index21.vue.d.cts +1 -1
  49. package/dist/index21.vue.d.ts +2 -2
  50. package/dist/index22.vue.d.cts +2 -2
  51. package/dist/index23.vue.d.cts +3 -3
  52. package/dist/index23.vue.d.ts +3 -3
  53. package/dist/index24.vue.d.cts +1 -1
  54. package/dist/index24.vue.d.ts +1 -1
  55. package/dist/index26.vue.d.cts +2 -2
  56. package/dist/index26.vue.d.ts +2 -2
  57. package/dist/index27.vue.d.cts +1 -1
  58. package/dist/index27.vue.d.ts +1 -1
  59. package/dist/index29.vue.d.cts +1 -1
  60. package/dist/index29.vue.d.ts +1 -1
  61. package/dist/index3.vue.d.cts +5 -5
  62. package/dist/index3.vue.d.ts +5 -5
  63. package/dist/index30.vue.d.cts +3 -3
  64. package/dist/index30.vue.d.ts +3 -3
  65. package/dist/index9.vue.d.ts +3 -3
  66. package/dist/mapUtils.d.cts +4 -4
  67. package/dist/mapUtils.d.ts +4 -4
  68. package/dist/presets.d.cts +1 -1
  69. package/dist/presets.d.ts +1 -1
  70. package/dist/style.css +49 -49
  71. package/dist/useCalendarEvents.d.cts +1 -1
  72. package/dist/useCalendarEvents.d.ts +1 -1
  73. package/dist/useCollapsePanel.d.cts +3 -3
  74. package/dist/useCollapsePanel.d.ts +3 -3
  75. package/dist/useCropperCore.d.cts +13 -13
  76. package/dist/useCropperCore.d.ts +13 -13
  77. package/dist/useEdgeInteraction.d.cts +3 -3
  78. package/dist/useEdgeInteraction.d.ts +3 -3
  79. package/dist/useFullscreen.d.cts +2 -2
  80. package/dist/useFullscreen.d.ts +2 -2
  81. package/dist/useGlobalSearch.d.cts +1 -1
  82. package/dist/useGlobalSearch.d.ts +1 -1
  83. package/dist/useInfiniteScroll.d.cts +4 -4
  84. package/dist/useInfiniteScroll.d.ts +4 -4
  85. package/dist/useQRCode.d.cts +2 -2
  86. package/dist/useQRCode.d.ts +2 -2
  87. package/dist/useSignatureHistory.d.cts +6 -6
  88. package/dist/useSignatureHistory.d.ts +6 -6
  89. package/dist/useSplitResize.d.cts +8 -8
  90. package/dist/useSplitResize.d.ts +8 -8
  91. package/dist/useTableQuery.d.cts +6 -6
  92. package/dist/useTableQuery.d.ts +6 -6
  93. package/dist/useWorkflowValidation.d.cts +33 -33
  94. package/dist/useWorkflowValidation.d.ts +33 -33
  95. package/dist/verification.d.cts +3 -3
  96. package/dist/verification.d.ts +3 -3
  97. package/docs/guides/data-picker.md +8 -8
  98. package/docs/guides/usage.en.md +16 -15
  99. package/docs/guides/usage.md +16 -15
  100. package/package.json +1 -1
@@ -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 filters = ref<SearchFormParams>({ keyword: '' })
487
- const searchFields: SearchFormItem[] = [
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: { keyword: '' },
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="searchConfig"
509
+ :config="{ requireValue: false, onSearch: setQuery }"
509
510
  :loading="loading"
510
- @reset="applyQuery"
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 explicitly reloads through `@reset="applyQuery"`, and `setQuery()` resets the table page. Avoid reading a separately maintained stale query in the reset handler.
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
 
@@ -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 filters = ref<SearchFormParams>({ keyword: '' })
626
- const searchFields: SearchFormItem[] = [
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: { keyword: '' },
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="searchConfig"
648
+ :config="{ requireValue: false, onSearch: setQuery }"
648
649
  :loading="loading"
649
- @reset="applyQuery"
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。上例通过显式 `@reset="applyQuery"` 刷新,并由 `setQuery()` 将表格页码归一;不要在重置回调里读取一份另行维护的旧查询对象。
658
+ `reset(params)` 事件先同步更新 v-model,再通知重置后的完整快照;不带参数的旧回调继续可用。默认仅恢复字段默认值并保留 `pageNum/pageSize`,不自动查询、不添加 debounce。上例直接用 `@reset="setQuery"` 刷新并回到第一页。自定义字段使用 `SearchFormItem<Query>` 的 `render` 时,`value` 和 `updateValue` 会随 `prop` 推导;任意命名的字段插槽仍需在使用侧按实际值缩窄类型。
658
659
 
659
660
  ### 动作配置与异步执行
660
661
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.29.2",
6
+ "version": "0.29.3",
7
7
  "description": "基于 Naive UI 的 Vue 3 组件库",
8
8
  "packageManager": "bun@1.4.2",
9
9
  "engines": {