@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,134 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: using-query-form
|
|
3
|
+
description: Use when building a schema-driven query or filter surface that should emit search state, support collapse, and optionally expose query-focused form instance methods.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Using QueryForm
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Use `QueryForm` for a **schema-driven search or filter form** where one `items` array should define the fields, the field type, and the initial filter state.
|
|
11
|
+
|
|
12
|
+
It is a page-level filter surface, not a generic replacement for every form. `QueryForm` is strongest when the main job is to collect query criteria, emit `search` and `reset` events, and optionally expose a small instance API for parent-driven filter control.
|
|
13
|
+
|
|
14
|
+
## Use it when
|
|
15
|
+
|
|
16
|
+
Use `QueryForm` when several of these are true:
|
|
17
|
+
|
|
18
|
+
- the page needs a compact search or filter panel
|
|
19
|
+
- one schema array should define the whole filter surface
|
|
20
|
+
- field choice should come from `valueType` instead of hand-written component branching
|
|
21
|
+
- filters may collapse when the list gets long
|
|
22
|
+
- parent code may need to read, restore, or set filter values programmatically
|
|
23
|
+
- the form may later pair with `../using-data-table/SKILL.md`
|
|
24
|
+
|
|
25
|
+
Strong signals this skill applies:
|
|
26
|
+
|
|
27
|
+
- admin search bars
|
|
28
|
+
- report filter panels
|
|
29
|
+
- list-page query areas
|
|
30
|
+
- reusable filter sections shared across tabs
|
|
31
|
+
|
|
32
|
+
## Prefer something else when
|
|
33
|
+
|
|
34
|
+
- the page also needs built-in result rendering, pagination, and refresh control
|
|
35
|
+
→ use `../using-data-table/SKILL.md`
|
|
36
|
+
- you are choosing field wrappers for a general-purpose create or edit form
|
|
37
|
+
→ use `../building-form-workflows/SKILL.md`
|
|
38
|
+
- the same filter surface should live inside an overlay shell instead of a normal page layout
|
|
39
|
+
→ use `../using-modal/SKILL.md` or `../using-drawer/SKILL.md` for the shell choice, then keep `QueryForm` as the inner filter shell
|
|
40
|
+
- the layout and validation flow are highly custom and should not be driven by `items`
|
|
41
|
+
- search buttons, collapse behavior, and tag-style overflow state are not part of the intended UX
|
|
42
|
+
|
|
43
|
+
## Decision guide
|
|
44
|
+
|
|
45
|
+
Use `QueryForm` if the answer is yes for **two or more** of these:
|
|
46
|
+
|
|
47
|
+
- Should one `items` array define most fields?
|
|
48
|
+
- Is the primary outcome a `search` event rather than a full submit workflow?
|
|
49
|
+
- Should the filter surface support collapse and overflow tags?
|
|
50
|
+
- Does parent code need `getFormData()`, `setFormData()`, or `restore()`?
|
|
51
|
+
- Should different field components be selected through `valueType`?
|
|
52
|
+
|
|
53
|
+
If not, a standard form workflow is usually a better fit.
|
|
54
|
+
|
|
55
|
+
## Start with
|
|
56
|
+
|
|
57
|
+
1. Define `items` around the real filters, not every possible field.
|
|
58
|
+
2. Pick the correct `valueType` for each item first.
|
|
59
|
+
3. Add `initialValues` only for defaults that matter to query behavior.
|
|
60
|
+
4. Tune `width`, `gutter`, and collapse settings after the field list is stable.
|
|
61
|
+
|
|
62
|
+
## Minimal patterns
|
|
63
|
+
|
|
64
|
+
### Standalone query surface
|
|
65
|
+
|
|
66
|
+
Use this when the page only needs to collect and emit filter state.
|
|
67
|
+
|
|
68
|
+
```vue
|
|
69
|
+
<QueryForm :items="items" @search="handleSearch" @reset="handleReset" />
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Schema-driven mixed fields
|
|
73
|
+
|
|
74
|
+
Use `valueType` to choose the field wrapper instead of branching in the template.
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
const items = [
|
|
78
|
+
{
|
|
79
|
+
label: 'Keyword',
|
|
80
|
+
prop: 'keyword',
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
label: 'Status',
|
|
84
|
+
prop: 'status',
|
|
85
|
+
valueType: 'select',
|
|
86
|
+
options: [
|
|
87
|
+
{ label: 'Enabled', value: 'enabled' },
|
|
88
|
+
{ label: 'Disabled', value: 'disabled' },
|
|
89
|
+
],
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
label: 'Created At',
|
|
93
|
+
prop: 'createdAt',
|
|
94
|
+
valueType: 'date',
|
|
95
|
+
type: 'daterange',
|
|
96
|
+
},
|
|
97
|
+
];
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Programmatic filter control
|
|
101
|
+
|
|
102
|
+
Use the instance only when parent code truly needs to coordinate the filter state.
|
|
103
|
+
|
|
104
|
+
Common methods:
|
|
105
|
+
|
|
106
|
+
- `getFormData()`
|
|
107
|
+
- `setFormData()`
|
|
108
|
+
- `restore()`
|
|
109
|
+
- `resetFields()`
|
|
110
|
+
- `validate()`
|
|
111
|
+
|
|
112
|
+
## Common mistakes
|
|
113
|
+
|
|
114
|
+
- treating `QueryForm` like a generic edit form instead of a query surface
|
|
115
|
+
- putting too many rarely used fields into `items` before validating the product need
|
|
116
|
+
- forgetting that `searchOnReset` defaults to running search after reset
|
|
117
|
+
- assuming all form-field props work for every `valueType`
|
|
118
|
+
- using programmatic control when simple `search` and `reset` events are enough
|
|
119
|
+
- tuning collapse widths before the field schema is settled
|
|
120
|
+
|
|
121
|
+
## Related skills
|
|
122
|
+
|
|
123
|
+
- Combined query and result shell: `../using-data-table/SKILL.md`
|
|
124
|
+
- General form-wrapper selection: `../building-form-workflows/SKILL.md`
|
|
125
|
+
- Wrapped select behavior behind common `valueType` choices: `../using-form-select/SKILL.md`
|
|
126
|
+
- Local select fields inside form schemas: `../using-select/SKILL.md`
|
|
127
|
+
- Remote or request-driven select fields: `../using-data-select/SKILL.md`
|
|
128
|
+
- Overlay shells that may host this filter surface: `../using-modal/SKILL.md`, `../using-drawer/SKILL.md`
|
|
129
|
+
|
|
130
|
+
## References
|
|
131
|
+
|
|
132
|
+
- Props: `./references/props.md`
|
|
133
|
+
- Examples: `./references/examples.md`
|
|
134
|
+
- Gotchas: `./references/gotchas.md`
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# QueryForm examples
|
|
2
|
+
|
|
3
|
+
## 1. Standalone list filter panel
|
|
4
|
+
|
|
5
|
+
Use `QueryForm` when the page needs a dedicated filter area but result rendering lives elsewhere.
|
|
6
|
+
|
|
7
|
+
Minimal pattern:
|
|
8
|
+
|
|
9
|
+
```vue
|
|
10
|
+
<QueryForm :items="items" @search="handleSearch" @reset="handleReset" />
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Typical fit:
|
|
14
|
+
|
|
15
|
+
- search bars above a custom chart or card list
|
|
16
|
+
- tab-level filter sections
|
|
17
|
+
- report filters that drive several downstream widgets
|
|
18
|
+
|
|
19
|
+
Recommended pattern:
|
|
20
|
+
|
|
21
|
+
- keep the schema in `items`
|
|
22
|
+
- react to `search` in parent code
|
|
23
|
+
- let the component own basic reset and validation flow
|
|
24
|
+
|
|
25
|
+
## 2. Pre-DataTable query surface
|
|
26
|
+
|
|
27
|
+
Use `QueryForm` when a page currently only needs filters, but may later grow into a combined list shell.
|
|
28
|
+
|
|
29
|
+
Minimal pattern:
|
|
30
|
+
|
|
31
|
+
```vue
|
|
32
|
+
<QueryForm :items="items" @search="handleSearch" />
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Typical fit:
|
|
36
|
+
|
|
37
|
+
- feature work that starts with filters first
|
|
38
|
+
- pages migrating toward `../../using-data-table/SKILL.md`
|
|
39
|
+
- custom layouts that still want standardized query controls
|
|
40
|
+
|
|
41
|
+
Keep field semantics and prop names stable so the page can later move into `DataTable` more easily.
|
|
42
|
+
|
|
43
|
+
## 3. Long filter set with collapse
|
|
44
|
+
|
|
45
|
+
Use collapse behavior when the default page view should stay compact.
|
|
46
|
+
|
|
47
|
+
Minimal pattern:
|
|
48
|
+
|
|
49
|
+
```vue
|
|
50
|
+
<QueryForm :items="items" collapsable :default-collapsed-rows="1" />
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Typical fit:
|
|
54
|
+
|
|
55
|
+
- advanced search panels
|
|
56
|
+
- internal admin pages with many optional filters
|
|
57
|
+
- responsive layouts where the number of visible filters changes by breakpoint
|
|
58
|
+
|
|
59
|
+
Recommended pattern:
|
|
60
|
+
|
|
61
|
+
- keep `collapsable` enabled
|
|
62
|
+
- tune `defaultCollapsedRows` after validating the field list
|
|
63
|
+
- use tag overflow as a summary, not as the primary way to understand active filters
|
|
64
|
+
|
|
65
|
+
## 4. Parent-controlled filter state
|
|
66
|
+
|
|
67
|
+
Use the instance API when toolbars, tabs, or route state need to coordinate the form.
|
|
68
|
+
|
|
69
|
+
Minimal pattern:
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
queryFormRef.value?.setFormData({ status: 'active' });
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Typical fit:
|
|
76
|
+
|
|
77
|
+
- clicking a dashboard card should preset filters
|
|
78
|
+
- tab changes should restore a previous filter state
|
|
79
|
+
- parent code needs to merge new params without recreating the schema
|
|
80
|
+
|
|
81
|
+
Recommended pattern:
|
|
82
|
+
|
|
83
|
+
- use `setFormData()` sparingly
|
|
84
|
+
- call `getFormData()` when parent code needs the current normalized query state
|
|
85
|
+
- reserve `restore()` for explicit rollback behavior
|
|
86
|
+
|
|
87
|
+
## 5. QueryForm inside an overlay shell
|
|
88
|
+
|
|
89
|
+
Use `QueryForm` inside `../../using-modal/SKILL.md` or `../../using-drawer/SKILL.md` when the overlay body needs filters but does not yet need a full `DataTable` shell.
|
|
90
|
+
|
|
91
|
+
Minimal pattern:
|
|
92
|
+
|
|
93
|
+
```vue
|
|
94
|
+
<Modal :model-value="visible" title="Advanced Filter" @cancel="visible = false">
|
|
95
|
+
<QueryForm :items="items" @search="handleSearch" />
|
|
96
|
+
</Modal>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Typical fit:
|
|
100
|
+
|
|
101
|
+
- advanced filter overlays
|
|
102
|
+
- side-panel filter refinement before applying changes
|
|
103
|
+
- modal query surfaces that drive custom cards or charts
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# QueryForm gotchas
|
|
2
|
+
|
|
3
|
+
- `searchOnReset` defaults to `true`
|
|
4
|
+
Reset can trigger a search immediately, so do not assume reset is a purely local UI action.
|
|
5
|
+
|
|
6
|
+
- Item `width` overrides form-level `width`
|
|
7
|
+
If one field looks misaligned, check `item.width` before changing the whole form layout.
|
|
8
|
+
|
|
9
|
+
- Missing `valueType` means text input
|
|
10
|
+
Omitting `valueType` does not produce an error. It falls back to the text field wrapper.
|
|
11
|
+
|
|
12
|
+
- Collapse behavior is width-based
|
|
13
|
+
`defaultCollapsedRows` works through width accumulation, not by counting a fixed number of items.
|
|
14
|
+
|
|
15
|
+
- `restore()` uses the shadow copy, not the original props
|
|
16
|
+
The restore target tracks the last shadow state, which changes after search or `setFormData()` when `setShadow` is enabled.
|
|
17
|
+
|
|
18
|
+
- Validation still follows Element Plus rules
|
|
19
|
+
`QueryForm` adds query behavior, but field rules and validation behavior still come from the underlying Element Plus form contract.
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# QueryForm props
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
`QueryForm` extends Element Plus form props and adds schema-driven filter configuration, responsive width control, and a small query-focused instance API.
|
|
6
|
+
|
|
7
|
+
Start by deciding the field schema and event flow first. Layout and collapse props are secondary.
|
|
8
|
+
|
|
9
|
+
## Minimum setup
|
|
10
|
+
|
|
11
|
+
Required:
|
|
12
|
+
|
|
13
|
+
- `items`
|
|
14
|
+
|
|
15
|
+
Typical optional props:
|
|
16
|
+
|
|
17
|
+
- `initialValues`
|
|
18
|
+
- `width`
|
|
19
|
+
- `gutter`
|
|
20
|
+
- `collapsable`
|
|
21
|
+
- `defaultCollapsed`
|
|
22
|
+
- `defaultCollapsedRows`
|
|
23
|
+
|
|
24
|
+
## Core props
|
|
25
|
+
|
|
26
|
+
### `items`
|
|
27
|
+
|
|
28
|
+
The source of truth for the filter surface.
|
|
29
|
+
|
|
30
|
+
Each item describes:
|
|
31
|
+
|
|
32
|
+
- `prop`
|
|
33
|
+
- `label`
|
|
34
|
+
- `valueType`
|
|
35
|
+
- field-specific props such as `options`, `placeholder`, `rules`, or `tooltip`
|
|
36
|
+
- optional layout overrides such as `width` and `colClassName`
|
|
37
|
+
|
|
38
|
+
Supported `valueType` values:
|
|
39
|
+
|
|
40
|
+
- `text`
|
|
41
|
+
- `number`
|
|
42
|
+
- `date`
|
|
43
|
+
- `time`
|
|
44
|
+
- `select`
|
|
45
|
+
- `switch`
|
|
46
|
+
- `radio`
|
|
47
|
+
- `checkbox`
|
|
48
|
+
- `cascade`
|
|
49
|
+
- `tree`
|
|
50
|
+
- `tag`
|
|
51
|
+
- `autocomplete`
|
|
52
|
+
|
|
53
|
+
If `valueType` is omitted, the component falls back to the text field wrapper.
|
|
54
|
+
|
|
55
|
+
### `initialValues`
|
|
56
|
+
|
|
57
|
+
Initial filter state copied into the internal form model.
|
|
58
|
+
|
|
59
|
+
Use this for meaningful default filters, not as a substitute for parent-owned state syncing.
|
|
60
|
+
|
|
61
|
+
### `width`
|
|
62
|
+
|
|
63
|
+
Controls the default field width.
|
|
64
|
+
|
|
65
|
+
Accepts:
|
|
66
|
+
|
|
67
|
+
- a number
|
|
68
|
+
- a responsive object with `xs`, `sm`, `md`, `lg`, `xl`, and `xxl`
|
|
69
|
+
|
|
70
|
+
Individual items can override this through `item.width`.
|
|
71
|
+
|
|
72
|
+
### `gutter`
|
|
73
|
+
|
|
74
|
+
Controls spacing between item wrappers.
|
|
75
|
+
|
|
76
|
+
Like `width`, this can be a number or a responsive object.
|
|
77
|
+
|
|
78
|
+
### `collapsable`
|
|
79
|
+
|
|
80
|
+
Enables expand and collapse behavior for long filter lists.
|
|
81
|
+
|
|
82
|
+
Default: `true`
|
|
83
|
+
|
|
84
|
+
### `defaultCollapsed`
|
|
85
|
+
|
|
86
|
+
Controls whether the form starts collapsed.
|
|
87
|
+
|
|
88
|
+
Default: `true`
|
|
89
|
+
|
|
90
|
+
### `defaultCollapsedRows`
|
|
91
|
+
|
|
92
|
+
Controls how much width is shown before the form collapses extra fields into the tag area.
|
|
93
|
+
|
|
94
|
+
Default: `1`
|
|
95
|
+
|
|
96
|
+
### `searchOnReset`
|
|
97
|
+
|
|
98
|
+
If `true`, reset emits `reset` and then triggers the same search path used by submit.
|
|
99
|
+
|
|
100
|
+
Default: `true`
|
|
101
|
+
|
|
102
|
+
### `hideLabel`
|
|
103
|
+
|
|
104
|
+
Hides the visual form labels while keeping the query controls and action row.
|
|
105
|
+
|
|
106
|
+
Default: `false`
|
|
107
|
+
|
|
108
|
+
## Events
|
|
109
|
+
|
|
110
|
+
`QueryForm` forwards Element Plus form events and adds query-specific ones.
|
|
111
|
+
|
|
112
|
+
Most important additions:
|
|
113
|
+
|
|
114
|
+
- `search`
|
|
115
|
+
- `reset`
|
|
116
|
+
- `change`
|
|
117
|
+
|
|
118
|
+
Use `search` as the main integration point for query execution.
|
|
119
|
+
|
|
120
|
+
## Instance API
|
|
121
|
+
|
|
122
|
+
The exposed instance combines Element Plus form methods with query helpers.
|
|
123
|
+
|
|
124
|
+
Available methods:
|
|
125
|
+
|
|
126
|
+
- `validate()`
|
|
127
|
+
- `validateField()`
|
|
128
|
+
- `resetFields()`
|
|
129
|
+
- `clearValidate()`
|
|
130
|
+
- `scrollToField()`
|
|
131
|
+
- `getFormData()`
|
|
132
|
+
- `restore()`
|
|
133
|
+
- `setFormData(values, options)`
|
|
134
|
+
|
|
135
|
+
`setFormData()` supports:
|
|
136
|
+
|
|
137
|
+
- `merge?: boolean` defaulting to `true`
|
|
138
|
+
- `setShadow?: boolean` defaulting to `true`
|
|
139
|
+
|
|
140
|
+
Use `restore()` when parent code should roll the form back to the last searched or shadow-copied state.
|
|
141
|
+
|
|
142
|
+
## Import
|
|
143
|
+
|
|
144
|
+
```ts
|
|
145
|
+
import { QueryForm } from '@hinen/pro-element-plus';
|
|
146
|
+
```
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: using-radio-group
|
|
3
|
+
description: Use when users should choose exactly one visible option from a short local set without hiding choices inside a dropdown or wrapper flow.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Using RadioGroup
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Use `RadioGroup` for a **visible single-choice control** when every option should stay on screen and the user should pick exactly one value.
|
|
11
|
+
|
|
12
|
+
It is the direct, non-wrapper counterpart to `../using-form-radio-group/SKILL.md`. Reach for it when the options are local, comparison matters, and the control does not need to live inside the `Form*` wrapper family.
|
|
13
|
+
|
|
14
|
+
## Use it when
|
|
15
|
+
|
|
16
|
+
Use `RadioGroup` when several of these are true:
|
|
17
|
+
|
|
18
|
+
- only one option can be chosen
|
|
19
|
+
- showing every option at once helps comparison
|
|
20
|
+
- a simple local `options` array is enough
|
|
21
|
+
- button-style or custom rendered radio options may help the UX
|
|
22
|
+
- the control does not need form-wrapper semantics
|
|
23
|
+
|
|
24
|
+
Strong signals this skill applies:
|
|
25
|
+
|
|
26
|
+
- short status sets
|
|
27
|
+
- mode pickers
|
|
28
|
+
- comparison-friendly small choice lists
|
|
29
|
+
- segmented-option style controls
|
|
30
|
+
|
|
31
|
+
## Prefer something else when
|
|
32
|
+
|
|
33
|
+
- users may select multiple options
|
|
34
|
+
→ use `../using-checkbox-group/SKILL.md`
|
|
35
|
+
- the same control belongs inside a form wrapper
|
|
36
|
+
→ use `../using-form-radio-group/SKILL.md`
|
|
37
|
+
- the option set is large enough that a dropdown is clearer
|
|
38
|
+
→ use `../using-select/SKILL.md`
|
|
39
|
+
|
|
40
|
+
## Decision guide
|
|
41
|
+
|
|
42
|
+
Use `RadioGroup` if the answer is yes for **two or more** of these:
|
|
43
|
+
|
|
44
|
+
- Should the user choose exactly one option?
|
|
45
|
+
- Does keeping all options visible improve comparison or speed?
|
|
46
|
+
- Is the option set small and local enough for an `options` array?
|
|
47
|
+
- Is a direct component clearer than introducing a form wrapper?
|
|
48
|
+
|
|
49
|
+
If not, `CheckboxGroup`, `Select`, or a form-wrapper version may fit better.
|
|
50
|
+
|
|
51
|
+
## Start with
|
|
52
|
+
|
|
53
|
+
1. Confirm that the choice is truly one-of-many.
|
|
54
|
+
2. Model the local option list as `options`.
|
|
55
|
+
3. Use the default rendering first.
|
|
56
|
+
4. Reach for slot-based custom option rendering only when labels alone are not enough.
|
|
57
|
+
|
|
58
|
+
## Minimal patterns
|
|
59
|
+
|
|
60
|
+
### Standard local radio group
|
|
61
|
+
|
|
62
|
+
```vue
|
|
63
|
+
<RadioGroup :options="options" v-model="value" />
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Disabled option set
|
|
67
|
+
|
|
68
|
+
Use `disabled` or per-option `disabled` values when availability should stay visible but not selectable.
|
|
69
|
+
|
|
70
|
+
### Custom option rendering
|
|
71
|
+
|
|
72
|
+
Use the default slot when the option body should render as radio buttons or richer content instead of plain labels.
|
|
73
|
+
|
|
74
|
+
## Common mistakes
|
|
75
|
+
|
|
76
|
+
- using `RadioGroup` when many values should be selectable
|
|
77
|
+
- using visible radios for long option lists that would be clearer as a select
|
|
78
|
+
- reaching for the direct component when the field really belongs in a wrapped form flow
|
|
79
|
+
- rebuilding the option body manually when the standard `options` shape already fits
|
|
80
|
+
|
|
81
|
+
## Related skills
|
|
82
|
+
|
|
83
|
+
- Visible multi-select counterpart: `../using-checkbox-group/SKILL.md`
|
|
84
|
+
- Wrapped single-choice version: `../using-form-radio-group/SKILL.md`
|
|
85
|
+
- Dropdown alternative for larger local sets: `../using-select/SKILL.md`
|
|
86
|
+
|
|
87
|
+
## References
|
|
88
|
+
|
|
89
|
+
- Props: `./references/props.md`
|
|
90
|
+
- Examples: `./references/examples.md`
|
|
91
|
+
- Gotchas: `./references/gotchas.md`
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# RadioGroup examples
|
|
2
|
+
|
|
3
|
+
## 1. Standard visible single-choice control
|
|
4
|
+
|
|
5
|
+
Use `RadioGroup` when users should pick exactly one value and comparing all options at once is useful.
|
|
6
|
+
|
|
7
|
+
Minimal pattern:
|
|
8
|
+
|
|
9
|
+
```vue
|
|
10
|
+
<RadioGroup :options="statusOptions" v-model="status" />
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Typical fit:
|
|
14
|
+
|
|
15
|
+
- status filters
|
|
16
|
+
- display mode toggles
|
|
17
|
+
- short enumerated choices
|
|
18
|
+
|
|
19
|
+
## 2. Disabled options remain visible
|
|
20
|
+
|
|
21
|
+
Use disabled group or option state when unavailable choices should still be visible for context.
|
|
22
|
+
|
|
23
|
+
Minimal pattern:
|
|
24
|
+
|
|
25
|
+
```vue
|
|
26
|
+
<RadioGroup :options="planOptions" v-model="plan" />
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Mark individual options disabled when users should see unavailable states without being able to pick them.
|
|
30
|
+
|
|
31
|
+
Typical fit:
|
|
32
|
+
|
|
33
|
+
- permission-limited modes
|
|
34
|
+
- unavailable plans
|
|
35
|
+
- gated product states
|
|
36
|
+
|
|
37
|
+
## 3. Custom radio rendering
|
|
38
|
+
|
|
39
|
+
Use the default slot when the option body should render as radio buttons or richer custom UI.
|
|
40
|
+
|
|
41
|
+
Minimal pattern:
|
|
42
|
+
|
|
43
|
+
```vue
|
|
44
|
+
<RadioGroup :options="modeOptions" v-model="mode">
|
|
45
|
+
<template #default="{ option }">
|
|
46
|
+
<span>{{ option.label }}</span>
|
|
47
|
+
</template>
|
|
48
|
+
</RadioGroup>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Typical fit:
|
|
52
|
+
|
|
53
|
+
- segmented controls
|
|
54
|
+
- icon-backed options
|
|
55
|
+
- emphasized current-mode selection
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# RadioGroup gotchas
|
|
2
|
+
|
|
3
|
+
- `RadioGroup` is for one-of-many choice
|
|
4
|
+
If many values can be selected, use `../using-checkbox-group/SKILL.md`.
|
|
5
|
+
|
|
6
|
+
- A binary state is usually not a radio group problem
|
|
7
|
+
If the field is really on or off, a switch-style control is often clearer than two visible radio options.
|
|
8
|
+
|
|
9
|
+
- Large option sets become noisy when always visible
|
|
10
|
+
If the list is too long, `../using-select/SKILL.md` is usually clearer.
|
|
11
|
+
|
|
12
|
+
- The direct component is not the form-wrapper version
|
|
13
|
+
If the control belongs in a wrapped schema or form flow, use `../using-form-radio-group/SKILL.md`.
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# RadioGroup props
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
`RadioGroup` stays close to Element Plus radio-group behavior and adds a first-class local `options` prop.
|
|
6
|
+
|
|
7
|
+
Use it when one visible local choice set should be rendered directly instead of through a dropdown.
|
|
8
|
+
|
|
9
|
+
## Minimum setup
|
|
10
|
+
|
|
11
|
+
A minimal working setup is usually just:
|
|
12
|
+
|
|
13
|
+
```vue
|
|
14
|
+
<RadioGroup :options="options" v-model="value" />
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
That is enough when the options are local and exactly one value should be selected.
|
|
18
|
+
|
|
19
|
+
Typical useful props:
|
|
20
|
+
|
|
21
|
+
- `options`
|
|
22
|
+
- `modelValue`
|
|
23
|
+
|
|
24
|
+
Common optional props:
|
|
25
|
+
|
|
26
|
+
- `disabled`
|
|
27
|
+
- `size`
|
|
28
|
+
- `fill`
|
|
29
|
+
- `textColor`
|
|
30
|
+
|
|
31
|
+
## Core props
|
|
32
|
+
|
|
33
|
+
### `options`
|
|
34
|
+
|
|
35
|
+
The main local option source.
|
|
36
|
+
|
|
37
|
+
Each option uses the shape:
|
|
38
|
+
|
|
39
|
+
- `label`
|
|
40
|
+
- `value`
|
|
41
|
+
- optional `disabled`
|
|
42
|
+
|
|
43
|
+
This is the real required input in normal usage. Without `options`, the component has nothing to render unless you fully replace rendering through slots.
|
|
44
|
+
|
|
45
|
+
### `modelValue`
|
|
46
|
+
|
|
47
|
+
The selected value.
|
|
48
|
+
|
|
49
|
+
Use this for the single current choice.
|
|
50
|
+
|
|
51
|
+
Match the value type to the option `value` shape. If the current value never equals an option value, nothing will appear selected.
|
|
52
|
+
|
|
53
|
+
### Group styling props
|
|
54
|
+
|
|
55
|
+
Useful inherited props include:
|
|
56
|
+
|
|
57
|
+
- `disabled`
|
|
58
|
+
- `size`
|
|
59
|
+
- `fill`
|
|
60
|
+
- `textColor`
|
|
61
|
+
|
|
62
|
+
These only matter after the one-of-many behavior is already correct.
|
|
63
|
+
|
|
64
|
+
## Slots
|
|
65
|
+
|
|
66
|
+
Useful slots include the default slot receiving `{ options }`.
|
|
67
|
+
|
|
68
|
+
Use this when the option body should render as custom radio content instead of the built-in label rendering.
|
|
69
|
+
|
|
70
|
+
If you customize the slot heavily, keep the one-of-many behavior obvious so the control still reads like a radio group instead of a generic button row.
|
|
71
|
+
|
|
72
|
+
## Events
|
|
73
|
+
|
|
74
|
+
Important events include:
|
|
75
|
+
|
|
76
|
+
- `update:modelValue`
|
|
77
|
+
- `change`
|
|
78
|
+
|
|
79
|
+
## Import
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
import { RadioGroup } from '@hinen/pro-element-plus';
|
|
83
|
+
```
|