@hinen/pro-element-plus 1.7.17 → 1.8.1
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/dist/components/DataTable/DataTable.vue.d.ts +24 -6
- package/dist/components/DataTable/DataTable.vue.d.ts.map +1 -1
- package/dist/components/DataTable/props.d.ts +11 -2
- package/dist/components/DataTable/props.d.ts.map +1 -1
- package/dist/components/DataTable/types.d.ts +14 -1
- package/dist/components/DataTable/types.d.ts.map +1 -1
- package/dist/components/DataTable/useDataTable.d.ts.map +1 -1
- package/dist/components/FormFields/FormCascadeSelect/FormCascadeSelect.test.d.ts +2 -0
- package/dist/components/FormFields/FormCascadeSelect/FormCascadeSelect.test.d.ts.map +1 -0
- package/dist/components/FormFields/FormCascadeSelect/FormCascadeSelect.vue.d.ts +136 -146
- package/dist/components/FormFields/FormCascadeSelect/FormCascadeSelect.vue.d.ts.map +1 -1
- package/dist/components/FormFields/FormCascadeSelect/props.d.ts +112 -114
- package/dist/components/FormFields/FormCascadeSelect/props.d.ts.map +1 -1
- package/dist/components/FormFields/FormCascadeSelect/types.d.ts +24 -1
- package/dist/components/FormFields/FormCascadeSelect/types.d.ts.map +1 -1
- package/dist/components/FormFields/FormTagInput/FormTagInput.vue.d.ts.map +1 -1
- package/dist/components/FormFields/FormTreeSelect/props.d.ts +3 -1
- package/dist/components/FormFields/FormTreeSelect/props.d.ts.map +1 -1
- package/dist/index.cjs +14 -14
- package/dist/index.js +2613 -2203
- package/dist/skills/building-form-workflows/SKILL.md +77 -0
- package/dist/skills/building-form-workflows/references/examples.md +47 -0
- package/dist/skills/building-form-workflows/references/field-selection.md +16 -0
- package/dist/skills/building-form-workflows/references/gotchas.md +10 -0
- package/dist/skills/building-form-workflows/references/workflow.md +21 -0
- package/dist/skills/building-modal-workflows/SKILL.md +79 -0
- package/dist/skills/building-modal-workflows/references/examples.md +104 -0
- package/dist/skills/building-modal-workflows/references/gotchas.md +19 -0
- package/dist/skills/building-modal-workflows/references/workflow.md +17 -0
- package/dist/skills/building-query-pages/SKILL.md +81 -0
- package/dist/skills/building-query-pages/references/examples.md +64 -0
- package/dist/skills/building-query-pages/references/field-selection.md +24 -0
- package/dist/skills/building-query-pages/references/gotchas.md +10 -0
- package/dist/skills/building-query-pages/references/workflow.md +22 -0
- package/dist/skills/building-selection-inputs/SKILL.md +85 -0
- package/dist/skills/building-selection-inputs/references/examples.md +87 -0
- package/dist/skills/building-selection-inputs/references/gotchas.md +19 -0
- package/dist/skills/building-selection-inputs/references/selection-guide.md +47 -0
- package/dist/skills/choosing-components/SKILL.md +78 -0
- package/dist/skills/choosing-components/references/component-groups.md +37 -0
- package/dist/skills/choosing-components/references/examples.md +91 -0
- package/dist/skills/choosing-components/references/gotchas.md +10 -0
- package/dist/skills/choosing-components/references/selection-guide.md +40 -0
- package/dist/skills/optimizing-component-skills/REVIEW.md +775 -0
- package/dist/skills/using-checkbox-group/SKILL.md +91 -0
- package/dist/skills/using-checkbox-group/references/examples.md +55 -0
- package/dist/skills/using-checkbox-group/references/gotchas.md +13 -0
- package/dist/skills/using-checkbox-group/references/props.md +83 -0
- package/dist/skills/using-config-provider/SKILL.md +96 -0
- package/dist/skills/using-config-provider/references/examples.md +38 -0
- package/dist/skills/using-config-provider/references/gotchas.md +13 -0
- package/dist/skills/using-config-provider/references/props.md +38 -0
- package/dist/skills/using-data-select/SKILL.md +127 -0
- package/dist/skills/using-data-select/references/examples.md +67 -0
- package/dist/skills/using-data-select/references/gotchas.md +19 -0
- package/dist/skills/using-data-select/references/props.md +126 -0
- package/dist/skills/using-data-table/SKILL.md +289 -0
- package/dist/skills/using-data-table/references/examples.md +347 -0
- package/dist/skills/using-data-table/references/gotchas.md +114 -0
- package/dist/skills/using-data-table/references/props.md +375 -0
- package/dist/skills/using-drawer/SKILL.md +104 -0
- package/dist/skills/using-drawer/references/examples.md +109 -0
- package/dist/skills/using-drawer/references/gotchas.md +16 -0
- package/dist/skills/using-drawer/references/props.md +105 -0
- package/dist/skills/using-ellipsis-text/SKILL.md +105 -0
- package/dist/skills/using-ellipsis-text/references/examples.md +71 -0
- package/dist/skills/using-ellipsis-text/references/gotchas.md +19 -0
- package/dist/skills/using-ellipsis-text/references/props.md +97 -0
- package/dist/skills/using-form-autocomplete/SKILL.md +87 -0
- package/dist/skills/using-form-autocomplete/references/examples.md +62 -0
- package/dist/skills/using-form-autocomplete/references/gotchas.md +13 -0
- package/dist/skills/using-form-autocomplete/references/props.md +100 -0
- package/dist/skills/using-form-cascade-select/SKILL.md +82 -0
- package/dist/skills/using-form-cascade-select/references/examples.md +59 -0
- package/dist/skills/using-form-cascade-select/references/gotchas.md +13 -0
- package/dist/skills/using-form-cascade-select/references/props.md +138 -0
- package/dist/skills/using-form-checkbox-group/SKILL.md +83 -0
- package/dist/skills/using-form-checkbox-group/references/examples.md +61 -0
- package/dist/skills/using-form-checkbox-group/references/gotchas.md +13 -0
- package/dist/skills/using-form-checkbox-group/references/props.md +85 -0
- package/dist/skills/using-form-date-picker/SKILL.md +79 -0
- package/dist/skills/using-form-date-picker/references/examples.md +54 -0
- package/dist/skills/using-form-date-picker/references/gotchas.md +10 -0
- package/dist/skills/using-form-date-picker/references/props.md +99 -0
- package/dist/skills/using-form-fields/SKILL.md +101 -0
- package/dist/skills/using-form-fields/references/examples.md +45 -0
- package/dist/skills/using-form-fields/references/gotchas.md +6 -0
- package/dist/skills/using-form-fields/references/props.md +57 -0
- package/dist/skills/using-form-item/SKILL.md +92 -0
- package/dist/skills/using-form-item/references/examples.md +59 -0
- package/dist/skills/using-form-item/references/gotchas.md +13 -0
- package/dist/skills/using-form-item/references/props.md +85 -0
- package/dist/skills/using-form-number/SKILL.md +82 -0
- package/dist/skills/using-form-number/references/examples.md +66 -0
- package/dist/skills/using-form-number/references/gotchas.md +13 -0
- package/dist/skills/using-form-number/references/props.md +82 -0
- package/dist/skills/using-form-radio-group/SKILL.md +83 -0
- package/dist/skills/using-form-radio-group/references/examples.md +53 -0
- package/dist/skills/using-form-radio-group/references/gotchas.md +13 -0
- package/dist/skills/using-form-radio-group/references/props.md +81 -0
- package/dist/skills/using-form-rate/SKILL.md +86 -0
- package/dist/skills/using-form-rate/references/examples.md +60 -0
- package/dist/skills/using-form-rate/references/gotchas.md +16 -0
- package/dist/skills/using-form-rate/references/props.md +88 -0
- package/dist/skills/using-form-select/SKILL.md +94 -0
- package/dist/skills/using-form-select/references/examples.md +67 -0
- package/dist/skills/using-form-select/references/gotchas.md +13 -0
- package/dist/skills/using-form-select/references/props.md +87 -0
- package/dist/skills/using-form-switch/SKILL.md +81 -0
- package/dist/skills/using-form-switch/references/examples.md +54 -0
- package/dist/skills/using-form-switch/references/gotchas.md +10 -0
- package/dist/skills/using-form-switch/references/props.md +83 -0
- package/dist/skills/using-form-tag-input/SKILL.md +83 -0
- package/dist/skills/using-form-tag-input/references/examples.md +53 -0
- package/dist/skills/using-form-tag-input/references/gotchas.md +13 -0
- package/dist/skills/using-form-tag-input/references/props.md +80 -0
- package/dist/skills/using-form-text/SKILL.md +82 -0
- package/dist/skills/using-form-text/references/examples.md +66 -0
- package/dist/skills/using-form-text/references/gotchas.md +13 -0
- package/dist/skills/using-form-text/references/props.md +98 -0
- package/dist/skills/using-form-time-picker/SKILL.md +78 -0
- package/dist/skills/using-form-time-picker/references/examples.md +53 -0
- package/dist/skills/using-form-time-picker/references/gotchas.md +10 -0
- package/dist/skills/using-form-time-picker/references/props.md +89 -0
- package/dist/skills/using-form-tree-select/SKILL.md +82 -0
- package/dist/skills/using-form-tree-select/references/examples.md +55 -0
- package/dist/skills/using-form-tree-select/references/gotchas.md +13 -0
- package/dist/skills/using-form-tree-select/references/props.md +86 -0
- package/dist/skills/using-image/SKILL.md +88 -0
- package/dist/skills/using-image/references/examples.md +31 -0
- package/dist/skills/using-image/references/gotchas.md +13 -0
- package/dist/skills/using-image/references/props.md +91 -0
- package/dist/skills/using-modal/SKILL.md +113 -0
- package/dist/skills/using-modal/references/examples.md +122 -0
- package/dist/skills/using-modal/references/gotchas.md +16 -0
- package/dist/skills/using-modal/references/props.md +100 -0
- package/dist/skills/using-query-form/SKILL.md +134 -0
- package/dist/skills/using-query-form/references/examples.md +103 -0
- package/dist/skills/using-query-form/references/gotchas.md +19 -0
- package/dist/skills/using-query-form/references/props.md +146 -0
- package/dist/skills/using-radio-group/SKILL.md +91 -0
- package/dist/skills/using-radio-group/references/examples.md +55 -0
- package/dist/skills/using-radio-group/references/gotchas.md +13 -0
- package/dist/skills/using-radio-group/references/props.md +83 -0
- package/dist/skills/using-select/SKILL.md +93 -0
- package/dist/skills/using-select/references/examples.md +50 -0
- package/dist/skills/using-select/references/gotchas.md +13 -0
- package/dist/skills/using-select/references/props.md +90 -0
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
# DataTable props
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
`DataTable` supports two primary modes:
|
|
6
|
+
|
|
7
|
+
1. **Remote mode** — pass `queryFn`
|
|
8
|
+
2. **Static mode** — pass `data`
|
|
9
|
+
|
|
10
|
+
Start by choosing the mode. Do not assume every `DataTable` should fetch remotely.
|
|
11
|
+
|
|
12
|
+
## Minimum setup
|
|
13
|
+
|
|
14
|
+
### Remote mode
|
|
15
|
+
|
|
16
|
+
Use this when the component should own querying, pagination, sorting, and refresh.
|
|
17
|
+
|
|
18
|
+
Required:
|
|
19
|
+
|
|
20
|
+
- `columns`
|
|
21
|
+
- `queryFn`
|
|
22
|
+
|
|
23
|
+
`queryFn` must return:
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
{
|
|
27
|
+
data: RecordType[],
|
|
28
|
+
total: number,
|
|
29
|
+
success: boolean,
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Static mode
|
|
34
|
+
|
|
35
|
+
Use this when rows already exist in memory.
|
|
36
|
+
|
|
37
|
+
Required:
|
|
38
|
+
|
|
39
|
+
- `columns`
|
|
40
|
+
- `data`
|
|
41
|
+
|
|
42
|
+
Typical optional prop:
|
|
43
|
+
|
|
44
|
+
- `pagination: false`
|
|
45
|
+
|
|
46
|
+
## Mode-specific behavior
|
|
47
|
+
|
|
48
|
+
| Prop / API | Remote mode | Static mode |
|
|
49
|
+
| --------------------------------- | ------------------------------------- | ------------------- |
|
|
50
|
+
| `queryFn` | used | not needed |
|
|
51
|
+
| `data` | optional override only if intentional | primary data source |
|
|
52
|
+
| `refresh()` | supported | not supported |
|
|
53
|
+
| `refetch()` | supported | not supported |
|
|
54
|
+
| `enabled` | meaningful | usually irrelevant |
|
|
55
|
+
| `queryKey` | meaningful | usually irrelevant |
|
|
56
|
+
| `initialData` / `placeholderData` | meaningful | not needed |
|
|
57
|
+
|
|
58
|
+
If `data` is passed, do not design parent code around remote query APIs.
|
|
59
|
+
|
|
60
|
+
## Core props
|
|
61
|
+
|
|
62
|
+
### `columns`
|
|
63
|
+
|
|
64
|
+
The main source of truth.
|
|
65
|
+
|
|
66
|
+
`columns` controls:
|
|
67
|
+
|
|
68
|
+
- rendered table columns
|
|
69
|
+
- generated query form items
|
|
70
|
+
- query field ordering
|
|
71
|
+
- value enum mapping
|
|
72
|
+
- custom cell rendering
|
|
73
|
+
- visibility in table and form
|
|
74
|
+
|
|
75
|
+
Common fields:
|
|
76
|
+
|
|
77
|
+
- `prop`
|
|
78
|
+
- `label`
|
|
79
|
+
- `hideInForm`
|
|
80
|
+
- `hideInTable`
|
|
81
|
+
- `valueType`
|
|
82
|
+
- `valueEnum`
|
|
83
|
+
- `formItemProps`
|
|
84
|
+
- `formItemOrder`
|
|
85
|
+
- `renderCell`
|
|
86
|
+
- `renderHeaderCell`
|
|
87
|
+
- `renderFilterIcon`
|
|
88
|
+
- `ellipsis`
|
|
89
|
+
|
|
90
|
+
### `queryFn`
|
|
91
|
+
|
|
92
|
+
Async loader for remote mode.
|
|
93
|
+
|
|
94
|
+
It receives:
|
|
95
|
+
|
|
96
|
+
- current search params
|
|
97
|
+
- `currentPage`
|
|
98
|
+
- `pageSize`
|
|
99
|
+
- sort info
|
|
100
|
+
|
|
101
|
+
It must return:
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
{
|
|
105
|
+
data,
|
|
106
|
+
total,
|
|
107
|
+
success,
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Use this when `DataTable` should own fetching.
|
|
112
|
+
|
|
113
|
+
### `data`
|
|
114
|
+
|
|
115
|
+
Static row array.
|
|
116
|
+
|
|
117
|
+
Use this when:
|
|
118
|
+
|
|
119
|
+
- rows are already available
|
|
120
|
+
- built-in remote querying is unnecessary
|
|
121
|
+
- the page still benefits from the standard table shell
|
|
122
|
+
|
|
123
|
+
### `pagination`
|
|
124
|
+
|
|
125
|
+
Controls pager rendering.
|
|
126
|
+
|
|
127
|
+
- pass `false` to disable
|
|
128
|
+
- pass an object to customize pagination props
|
|
129
|
+
- omit it to use built-in defaults
|
|
130
|
+
|
|
131
|
+
Check `hidePaginationWhenEmpty` before assuming the pager will always render.
|
|
132
|
+
|
|
133
|
+
### `form`
|
|
134
|
+
|
|
135
|
+
Query form configuration.
|
|
136
|
+
|
|
137
|
+
Use this for:
|
|
138
|
+
|
|
139
|
+
- `initialValues`
|
|
140
|
+
- label and layout behavior
|
|
141
|
+
- other QueryForm-level config
|
|
142
|
+
|
|
143
|
+
The query form only appears if `columns` can generate at least one form item.
|
|
144
|
+
|
|
145
|
+
### `enabled`
|
|
146
|
+
|
|
147
|
+
Boolean or function for gating remote queries.
|
|
148
|
+
|
|
149
|
+
Use this when querying should wait for prerequisites such as:
|
|
150
|
+
|
|
151
|
+
- route params
|
|
152
|
+
- async dictionaries
|
|
153
|
+
- parent state
|
|
154
|
+
- active tab state
|
|
155
|
+
|
|
156
|
+
### `selectionBar`
|
|
157
|
+
|
|
158
|
+
Controls selected-row affordance.
|
|
159
|
+
|
|
160
|
+
- `true` enables the default selected-row bar
|
|
161
|
+
- `false` disables it
|
|
162
|
+
- object form customizes bar props
|
|
163
|
+
- slot form replaces the built-in review UI
|
|
164
|
+
|
|
165
|
+
The built-in checkbox review keeps cross-page state internally only when `rowKey` is provided.
|
|
166
|
+
|
|
167
|
+
- `selectionChange` remains current-page oriented
|
|
168
|
+
- `getSelectionRows()` remains current-page oriented
|
|
169
|
+
- `reviewPopoverProps` customizes the built-in 查看已选 popover
|
|
170
|
+
- use the `selectionBar` slot only when the page should replace the built-in review UI entirely
|
|
171
|
+
|
|
172
|
+
### `selectedRowKeys` / `v-model:selectedRowKeys`
|
|
173
|
+
|
|
174
|
+
Controls selection state from parent (controlled mode).
|
|
175
|
+
|
|
176
|
+
Type: `DataTableSelectionKeyType[]` (string or number)
|
|
177
|
+
|
|
178
|
+
Use this when:
|
|
179
|
+
|
|
180
|
+
- parent needs reactive access to selected row keys
|
|
181
|
+
- selection should sync with external state (URL, storage, other components)
|
|
182
|
+
- programmatic selection control is required
|
|
183
|
+
|
|
184
|
+
When provided, `DataTable` operates in controlled mode:
|
|
185
|
+
|
|
186
|
+
- the component emits `update:selectedRowKeys` on selection changes
|
|
187
|
+
- parent state becomes the source of truth
|
|
188
|
+
- internal selection state defers to the prop
|
|
189
|
+
|
|
190
|
+
Cross-page selection works with `selectedRowKeys` when `rowKey` is defined. The prop accepts keys from any page, not just the current one.
|
|
191
|
+
|
|
192
|
+
```vue
|
|
193
|
+
<DataTable
|
|
194
|
+
v-model:selectedRowKeys="selectedKeys"
|
|
195
|
+
:columns="columns"
|
|
196
|
+
:query-fn="queryFn"
|
|
197
|
+
row-key="id"
|
|
198
|
+
row-selection
|
|
199
|
+
/>
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
```ts
|
|
203
|
+
const selectedKeys = ref<DataTableSelectionKeyType[]>([]);
|
|
204
|
+
|
|
205
|
+
// Set programmatically
|
|
206
|
+
selectedKeys.value = ['id1', 'id2'];
|
|
207
|
+
|
|
208
|
+
// Clear
|
|
209
|
+
selectedKeys.value = [];
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### `selection`
|
|
213
|
+
|
|
214
|
+
Customizes built-in cross-page checkbox review items. For state control, use `v-model:selectedRowKeys` instead.
|
|
215
|
+
|
|
216
|
+
Use this prop only for customization, never for state management.
|
|
217
|
+
|
|
218
|
+
Common fields:
|
|
219
|
+
|
|
220
|
+
- `formatter(row)` customizes the default review tag text
|
|
221
|
+
- `render(...)` customizes each built-in review item
|
|
222
|
+
|
|
223
|
+
Use `rowKey` with this when checkbox review should stay correct across pages.
|
|
224
|
+
|
|
225
|
+
### `fixedHeader` / `fixedHeaderOffset`
|
|
226
|
+
|
|
227
|
+
Use when the header should stay visible while the user scrolls.
|
|
228
|
+
|
|
229
|
+
### `fixedFooter` / `fixedFooterOffset`
|
|
230
|
+
|
|
231
|
+
Use when pagination should stay accessible near the viewport bottom.
|
|
232
|
+
|
|
233
|
+
### `hidePaginationWhenEmpty`
|
|
234
|
+
|
|
235
|
+
Use intentionally.
|
|
236
|
+
|
|
237
|
+
If `true`, empty results can hide pagination completely.
|
|
238
|
+
|
|
239
|
+
### `loading`
|
|
240
|
+
|
|
241
|
+
External loading flag.
|
|
242
|
+
|
|
243
|
+
Use this when the page has prerequisite loading that is separate from the table's own remote query loading.
|
|
244
|
+
|
|
245
|
+
### `highlightCurrentRow`
|
|
246
|
+
|
|
247
|
+
In `DataTable`, this prop now does more than turn on native Element Plus highlighting.
|
|
248
|
+
|
|
249
|
+
When `highlightCurrentRow` is `true`, `DataTable` enters its built-in single-select mode:
|
|
250
|
+
|
|
251
|
+
- a leading radio column is rendered
|
|
252
|
+
- the current row stays visually highlighted
|
|
253
|
+
- radio click becomes the selection trigger
|
|
254
|
+
- row click still emits `rowClick`, but does not change the current row
|
|
255
|
+
|
|
256
|
+
Use this only when the page intentionally wants radio-driven single selection.
|
|
257
|
+
|
|
258
|
+
### `rowKey`
|
|
259
|
+
|
|
260
|
+
`rowKey` becomes especially important when single-select mode is controlled.
|
|
261
|
+
|
|
262
|
+
Use `rowKey` when:
|
|
263
|
+
|
|
264
|
+
- using built-in cross-page checkbox review through `selection`
|
|
265
|
+
- passing `currentRowKey`
|
|
266
|
+
- expecting current-row state to survive data replacement
|
|
267
|
+
- needing stable single-select identity beyond row index
|
|
268
|
+
|
|
269
|
+
Without `rowKey`, built-in checkbox review cannot aggregate rows across pages correctly.
|
|
270
|
+
|
|
271
|
+
### `currentRowKey`
|
|
272
|
+
|
|
273
|
+
Use `currentRowKey` together with `rowKey` for controlled current-row sync in single-select mode.
|
|
274
|
+
|
|
275
|
+
Notes:
|
|
276
|
+
|
|
277
|
+
- it is meaningful only when `rowKey` is provided
|
|
278
|
+
- setting it to a matching key selects and highlights that row
|
|
279
|
+
- setting it to `undefined` clears the current single-select row in `DataTable`
|
|
280
|
+
- setting it to a defined but unmatched key also clears the current single-select row
|
|
281
|
+
- this empty-key clearing behavior is a `DataTable` wrapper convention, not a documented Element Plus `current-row-key` contract
|
|
282
|
+
|
|
283
|
+
## Exported helpers
|
|
284
|
+
|
|
285
|
+
These are exported with `DataTable`:
|
|
286
|
+
|
|
287
|
+
- `defineDataTableColumns`
|
|
288
|
+
- `defineDataTableEnabled`
|
|
289
|
+
- `defineDataTableInitialData`
|
|
290
|
+
- `defineDataTablePlaceholderData`
|
|
291
|
+
- `defineDataTableQueryFn`
|
|
292
|
+
- `defineDataTableQueryKey`
|
|
293
|
+
- `useDataTable`
|
|
294
|
+
|
|
295
|
+
Use them when stronger typing or reusable table configuration improves clarity.
|
|
296
|
+
|
|
297
|
+
## Instance API
|
|
298
|
+
|
|
299
|
+
Use `useDataTable()` when parent code needs imperative control.
|
|
300
|
+
|
|
301
|
+
Common methods:
|
|
302
|
+
|
|
303
|
+
- `setSearchParams()`
|
|
304
|
+
- `getSearchParams()`
|
|
305
|
+
- `getFormData()`
|
|
306
|
+
- `setFormData()`
|
|
307
|
+
- `resetForm()`
|
|
308
|
+
- `resetPagination()`
|
|
309
|
+
- `resetAll()`
|
|
310
|
+
- `setCurrentPage()`
|
|
311
|
+
- `setPageSize()`
|
|
312
|
+
- `getDataSource()`
|
|
313
|
+
- `clearSelection()`
|
|
314
|
+
- `refresh()`
|
|
315
|
+
- `refetch()`
|
|
316
|
+
|
|
317
|
+
Current-row related methods:
|
|
318
|
+
|
|
319
|
+
- `setCurrentRow(row)` selects the current row in single-select mode
|
|
320
|
+
- `setCurrentRow()` clears the current single-select row
|
|
321
|
+
- `clearSelection()` clears checkbox selection, not single-select current-row state
|
|
322
|
+
|
|
323
|
+
Selection notes:
|
|
324
|
+
|
|
325
|
+
- `getSelectionRows()` returns current-page checkbox rows
|
|
326
|
+
- cross-page checkbox review state is internal, not exposed through a new instance method
|
|
327
|
+
|
|
328
|
+
Notes:
|
|
329
|
+
|
|
330
|
+
- `refresh()` and `refetch()` are for remote mode only
|
|
331
|
+
- form methods assume a generated query form actually exists
|
|
332
|
+
|
|
333
|
+
## Events
|
|
334
|
+
|
|
335
|
+
`DataTable` re-emits table events and adds query-related events.
|
|
336
|
+
|
|
337
|
+
Useful additions:
|
|
338
|
+
|
|
339
|
+
- `formDataChange`
|
|
340
|
+
- `searchParamsChange`
|
|
341
|
+
|
|
342
|
+
Use them when parent code should observe search-state changes without replacing the component shell.
|
|
343
|
+
|
|
344
|
+
## Slots
|
|
345
|
+
|
|
346
|
+
Available extension points:
|
|
347
|
+
|
|
348
|
+
- `toolbar`
|
|
349
|
+
- `selectionBar`
|
|
350
|
+
- `append`
|
|
351
|
+
- `empty`
|
|
352
|
+
- `error`
|
|
353
|
+
|
|
354
|
+
Use these before building a custom shell around `ElTable`.
|
|
355
|
+
|
|
356
|
+
`selectionBar` slot notes:
|
|
357
|
+
|
|
358
|
+
- it replaces the built-in review UI
|
|
359
|
+
- in cross-page checkbox mode, its `selection` slot prop is the aggregated selected rows
|
|
360
|
+
- `clear` still clears the full checkbox selection state
|
|
361
|
+
|
|
362
|
+
## Import
|
|
363
|
+
|
|
364
|
+
```ts
|
|
365
|
+
import {
|
|
366
|
+
DataTable,
|
|
367
|
+
defineDataTableColumns,
|
|
368
|
+
defineDataTableEnabled,
|
|
369
|
+
defineDataTableInitialData,
|
|
370
|
+
defineDataTablePlaceholderData,
|
|
371
|
+
defineDataTableQueryFn,
|
|
372
|
+
defineDataTableQueryKey,
|
|
373
|
+
useDataTable,
|
|
374
|
+
} from '@hinen/pro-element-plus';
|
|
375
|
+
```
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: using-drawer
|
|
3
|
+
description: Use when an edge-attached overlay should keep Element Plus drawer behavior while adding standard confirm and cancel actions, confirm loading state, and size presets.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Using Drawer
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Use `Drawer` for a **side-panel workflow** that should preserve Element Plus drawer behavior while adding standard confirm and cancel actions, size presets, scroll-shadow treatment, and an opinionated footer model.
|
|
11
|
+
|
|
12
|
+
It fits workflows that need more room or should stay visually connected to the current page. Like `Modal`, it is more than a thin shell because it bakes in action semantics and sizing conventions.
|
|
13
|
+
|
|
14
|
+
## Use it when
|
|
15
|
+
|
|
16
|
+
Use `Drawer` when several of these are true:
|
|
17
|
+
|
|
18
|
+
- the interaction needs more horizontal or vertical space than a centered dialog
|
|
19
|
+
- the workflow should feel attached to the current page rather than interrupt it completely
|
|
20
|
+
- confirm and cancel are still the main actions
|
|
21
|
+
- built-in footer behavior is preferable to custom action scaffolding
|
|
22
|
+
- direction and edge attachment matter to the UX
|
|
23
|
+
|
|
24
|
+
Strong signals this skill applies:
|
|
25
|
+
|
|
26
|
+
- side-panel editors
|
|
27
|
+
- review and approve panels
|
|
28
|
+
- nested overlay workflows
|
|
29
|
+
- detail panels with richer body content
|
|
30
|
+
|
|
31
|
+
## Prefer something else when
|
|
32
|
+
|
|
33
|
+
- the interaction is short, centered, and dialog-like
|
|
34
|
+
→ use `../using-modal/SKILL.md`
|
|
35
|
+
- you are still choosing the right overlay shell
|
|
36
|
+
→ use `../building-modal-workflows/SKILL.md`
|
|
37
|
+
- the flow has no meaningful confirm/cancel model
|
|
38
|
+
- the feature should not consume edge-attached page space
|
|
39
|
+
|
|
40
|
+
## Decision guide
|
|
41
|
+
|
|
42
|
+
Use `Drawer` if the answer is yes for **two or more** of these:
|
|
43
|
+
|
|
44
|
+
- Should the panel attach to an edge instead of appearing centered?
|
|
45
|
+
- Does the content need more room than a modal usually gets?
|
|
46
|
+
- Should the workflow keep standard confirm and cancel actions?
|
|
47
|
+
- Do direction and opening side matter to the experience?
|
|
48
|
+
- Would a standard footer save custom shell work?
|
|
49
|
+
|
|
50
|
+
If not, `Modal` or a lower-level drawer composition may be a better fit.
|
|
51
|
+
|
|
52
|
+
## Start with
|
|
53
|
+
|
|
54
|
+
1. Control visibility through `modelValue`.
|
|
55
|
+
2. Use the default footer unless the action layout is truly custom.
|
|
56
|
+
3. Prefer `size` presets before hard-coding `width`.
|
|
57
|
+
4. Treat `ok` and `cancel` as business events that still need close logic.
|
|
58
|
+
|
|
59
|
+
## Minimal patterns
|
|
60
|
+
|
|
61
|
+
### Standard side-panel workflow
|
|
62
|
+
|
|
63
|
+
```vue
|
|
64
|
+
<Drawer
|
|
65
|
+
:model-value="visible"
|
|
66
|
+
title="Edit Project"
|
|
67
|
+
:confirm-loading="saving"
|
|
68
|
+
@update:model-value="visible = $event"
|
|
69
|
+
@cancel="visible = false"
|
|
70
|
+
@ok="handleSubmit"
|
|
71
|
+
>
|
|
72
|
+
<ProjectForm />
|
|
73
|
+
</Drawer>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Custom header or footer
|
|
77
|
+
|
|
78
|
+
Use header and footer slots only when the built-in structure is not sufficient.
|
|
79
|
+
|
|
80
|
+
### Direction-aware drawer
|
|
81
|
+
|
|
82
|
+
Use `direction` intentionally when the overlay should come from the left, right, top, or bottom.
|
|
83
|
+
|
|
84
|
+
## Common mistakes
|
|
85
|
+
|
|
86
|
+
- choosing `Drawer` just because the content is large, even when a centered modal would still communicate better
|
|
87
|
+
- assuming `ok` or `cancel` closes the drawer automatically
|
|
88
|
+
- overriding the footer too early for a standard submit flow
|
|
89
|
+
- forgetting that `appendToBody` defaults to `true`
|
|
90
|
+
- assuming `size` and `width` are interchangeable
|
|
91
|
+
- ignoring `withHeader` when the design intentionally removes the header area
|
|
92
|
+
|
|
93
|
+
## Related skills
|
|
94
|
+
|
|
95
|
+
- Centered dialog workflow shell: `../using-modal/SKILL.md`
|
|
96
|
+
- Overlay-pattern selection: `../building-modal-workflows/SKILL.md`
|
|
97
|
+
- Form workflow when the body is an editor or wrapped form: `../building-form-workflows/SKILL.md`
|
|
98
|
+
- Query or list shells when the body is filter-plus-results content: `../using-query-form/SKILL.md`, `../using-data-table/SKILL.md`
|
|
99
|
+
|
|
100
|
+
## References
|
|
101
|
+
|
|
102
|
+
- Props: `./references/props.md`
|
|
103
|
+
- Examples: `./references/examples.md`
|
|
104
|
+
- Gotchas: `./references/gotchas.md`
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Drawer examples
|
|
2
|
+
|
|
3
|
+
## 1. Side-panel editor
|
|
4
|
+
|
|
5
|
+
Use `Drawer` when the content needs more room than a centered modal but should still behave like one workflow.
|
|
6
|
+
|
|
7
|
+
Minimal pattern:
|
|
8
|
+
|
|
9
|
+
```vue
|
|
10
|
+
<Drawer
|
|
11
|
+
:model-value="visible"
|
|
12
|
+
title="Edit Project"
|
|
13
|
+
@cancel="visible = false"
|
|
14
|
+
@ok="handleSave"
|
|
15
|
+
>
|
|
16
|
+
<ProjectForm />
|
|
17
|
+
</Drawer>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Typical fit:
|
|
21
|
+
|
|
22
|
+
- project editors
|
|
23
|
+
- user-detail edit panels
|
|
24
|
+
- multi-section settings panels
|
|
25
|
+
|
|
26
|
+
Recommended pattern:
|
|
27
|
+
|
|
28
|
+
- keep the form in the body slot
|
|
29
|
+
- use the built-in footer first
|
|
30
|
+
- close only after the parent updates `modelValue`
|
|
31
|
+
|
|
32
|
+
## 2. Review and approve panel
|
|
33
|
+
|
|
34
|
+
Use `Drawer` when users should keep page context while reviewing detail content and deciding whether to confirm or cancel.
|
|
35
|
+
|
|
36
|
+
Minimal pattern:
|
|
37
|
+
|
|
38
|
+
```vue
|
|
39
|
+
<Drawer
|
|
40
|
+
:model-value="visible"
|
|
41
|
+
title="Review"
|
|
42
|
+
@cancel="visible = false"
|
|
43
|
+
@ok="handleApprove"
|
|
44
|
+
>
|
|
45
|
+
<ReviewPanel />
|
|
46
|
+
</Drawer>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Typical fit:
|
|
50
|
+
|
|
51
|
+
- audit review panels
|
|
52
|
+
- approval sidebars
|
|
53
|
+
- edge-attached detail inspection
|
|
54
|
+
|
|
55
|
+
The default footer is a strong fit here because the workflow is still basically confirm or cancel.
|
|
56
|
+
|
|
57
|
+
## 3. Nested drawer flow
|
|
58
|
+
|
|
59
|
+
Use `Drawer` when a larger parent panel may open a secondary panel.
|
|
60
|
+
|
|
61
|
+
Minimal pattern:
|
|
62
|
+
|
|
63
|
+
```vue
|
|
64
|
+
<Drawer :model-value="visible" title="Parent Panel">
|
|
65
|
+
<NestedTask />
|
|
66
|
+
</Drawer>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Typical fit:
|
|
70
|
+
|
|
71
|
+
- choosing related entities from inside an editor
|
|
72
|
+
- step-in detail inspection
|
|
73
|
+
- nested configuration tasks
|
|
74
|
+
|
|
75
|
+
Account for `appendToBody` and visibility state intentionally in these flows.
|
|
76
|
+
|
|
77
|
+
## 4. Direction-specific layouts
|
|
78
|
+
|
|
79
|
+
Use `direction` when the drawer’s opening edge communicates meaning or fits the page layout better.
|
|
80
|
+
|
|
81
|
+
Minimal pattern:
|
|
82
|
+
|
|
83
|
+
```vue
|
|
84
|
+
<Drawer :model-value="visible" direction="rtl" title="Details" />
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Typical fit:
|
|
88
|
+
|
|
89
|
+
- right-side detail drawers
|
|
90
|
+
- left-side navigation-adjacent panels
|
|
91
|
+
- top or bottom temporary panels for shorter content
|
|
92
|
+
|
|
93
|
+
## 5. Drawer with query or list content
|
|
94
|
+
|
|
95
|
+
Use `Drawer` when the overlay body is really a query/list workflow and the user benefits from more room or stronger page context.
|
|
96
|
+
|
|
97
|
+
Minimal pattern:
|
|
98
|
+
|
|
99
|
+
```vue
|
|
100
|
+
<Drawer :model-value="visible" title="Select Project" @cancel="visible = false">
|
|
101
|
+
<DataTable :columns="columns" :query-fn="queryFn" />
|
|
102
|
+
</Drawer>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Typical fit:
|
|
106
|
+
|
|
107
|
+
- select-from-list drawers
|
|
108
|
+
- side-panel result review
|
|
109
|
+
- wider filter-plus-results overlays
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Drawer gotchas
|
|
2
|
+
|
|
3
|
+
- `appendToBody` defaults to `true`
|
|
4
|
+
This changes layering and portal behavior compared with assuming Element Plus defaults unchanged.
|
|
5
|
+
|
|
6
|
+
- `ok` and `cancel` do not close the drawer automatically
|
|
7
|
+
They are workflow events, not implicit visibility updates.
|
|
8
|
+
|
|
9
|
+
- `okButtonProps.type` takes precedence over `okType`
|
|
10
|
+
If the confirm button style is surprising, check both settings.
|
|
11
|
+
|
|
12
|
+
- `size` behaves differently by direction
|
|
13
|
+
Left and right drawers use width-oriented sizing. Top and bottom drawers use height-oriented sizing.
|
|
14
|
+
|
|
15
|
+
- Removing the header changes the scroll-shadow experience
|
|
16
|
+
If `withHeader` is `false`, do not assume the overlay still behaves like the standard headered shell.
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Drawer props
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
`Drawer` extends Element Plus drawer props and adds a standard footer action model, size presets, confirm loading state, and a default `appendToBody: true` behavior.
|
|
6
|
+
|
|
7
|
+
Choose the edge-attached workflow first, then decide whether the default footer is enough.
|
|
8
|
+
|
|
9
|
+
## Minimum setup
|
|
10
|
+
|
|
11
|
+
Required in normal usage:
|
|
12
|
+
|
|
13
|
+
- `modelValue`
|
|
14
|
+
|
|
15
|
+
Typical optional props:
|
|
16
|
+
|
|
17
|
+
- `title`
|
|
18
|
+
- `direction`
|
|
19
|
+
- `size`
|
|
20
|
+
- `width`
|
|
21
|
+
- `footer`
|
|
22
|
+
- `confirmLoading`
|
|
23
|
+
|
|
24
|
+
## Core props
|
|
25
|
+
|
|
26
|
+
### `modelValue`
|
|
27
|
+
|
|
28
|
+
Controls drawer visibility.
|
|
29
|
+
|
|
30
|
+
### `direction`
|
|
31
|
+
|
|
32
|
+
Inherited from Element Plus drawer props.
|
|
33
|
+
|
|
34
|
+
Use it to choose where the drawer enters from.
|
|
35
|
+
|
|
36
|
+
### `size`
|
|
37
|
+
|
|
38
|
+
Library-level preset sizing.
|
|
39
|
+
|
|
40
|
+
Supported values:
|
|
41
|
+
|
|
42
|
+
- `small`
|
|
43
|
+
- `default`
|
|
44
|
+
- `large`
|
|
45
|
+
|
|
46
|
+
Default: `default`
|
|
47
|
+
|
|
48
|
+
The preset affects max width for left or right drawers and max height for top or bottom drawers.
|
|
49
|
+
|
|
50
|
+
### `width`
|
|
51
|
+
|
|
52
|
+
Explicit drawer size override.
|
|
53
|
+
|
|
54
|
+
If present, it becomes the main sizing input instead of relying on presets alone.
|
|
55
|
+
|
|
56
|
+
### `footer`
|
|
57
|
+
|
|
58
|
+
Controls whether the built-in footer is rendered.
|
|
59
|
+
|
|
60
|
+
Default: `true`
|
|
61
|
+
|
|
62
|
+
### `confirmLoading`
|
|
63
|
+
|
|
64
|
+
Shows loading on the built-in confirm button.
|
|
65
|
+
|
|
66
|
+
Default: `false`
|
|
67
|
+
|
|
68
|
+
### `okText`, `cancelText`, `okType`, `okButtonProps`, `cancelButtonProps`
|
|
69
|
+
|
|
70
|
+
Customize the built-in action buttons without replacing the whole footer.
|
|
71
|
+
|
|
72
|
+
### `appendToBody`
|
|
73
|
+
|
|
74
|
+
Overridden default: `true`
|
|
75
|
+
|
|
76
|
+
This differs from treating it as just another inherited Element Plus prop, so account for it explicitly in nested or portal-heavy layouts.
|
|
77
|
+
|
|
78
|
+
### `withHeader`
|
|
79
|
+
|
|
80
|
+
Inherited from Element Plus drawer props.
|
|
81
|
+
|
|
82
|
+
Use this when the header should be hidden entirely.
|
|
83
|
+
|
|
84
|
+
## Events
|
|
85
|
+
|
|
86
|
+
`Drawer` keeps Element Plus drawer events and adds:
|
|
87
|
+
|
|
88
|
+
- `ok`
|
|
89
|
+
- `cancel`
|
|
90
|
+
|
|
91
|
+
These are business-action events and do not close the drawer on their own.
|
|
92
|
+
|
|
93
|
+
## Slots
|
|
94
|
+
|
|
95
|
+
Useful slots:
|
|
96
|
+
|
|
97
|
+
- default body slot
|
|
98
|
+
- `header`
|
|
99
|
+
- `footer`
|
|
100
|
+
|
|
101
|
+
## Import
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
import { Drawer } from '@hinen/pro-element-plus';
|
|
105
|
+
```
|