@hinen/pro-element-plus 1.7.16 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +13 -1
- package/dist/components/DataTable/types.d.ts.map +1 -1
- package/dist/components/DataTable/useDataTable.d.ts.map +1 -1
- package/dist/components/DataTable/useFixedScrollbar.d.ts.map +1 -1
- 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 +32 -32
- package/dist/index.js +2950 -2565
- 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,86 @@
|
|
|
1
|
+
# FormTreeSelect props
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
`FormTreeSelect` combines `FormItem` props with Element Plus tree-select props.
|
|
6
|
+
|
|
7
|
+
Use it when visible tree-node selection should stay inside the shared form-wrapper family.
|
|
8
|
+
|
|
9
|
+
## Minimum setup
|
|
10
|
+
|
|
11
|
+
Typical useful props:
|
|
12
|
+
|
|
13
|
+
- `label`
|
|
14
|
+
- `prop`
|
|
15
|
+
- `data`
|
|
16
|
+
|
|
17
|
+
Common optional field props:
|
|
18
|
+
|
|
19
|
+
- `props`
|
|
20
|
+
- `showCheckbox`
|
|
21
|
+
- `multiple`
|
|
22
|
+
- `filterable`
|
|
23
|
+
- `lazy`
|
|
24
|
+
|
|
25
|
+
## Core props
|
|
26
|
+
|
|
27
|
+
### Wrapper props from `FormItem`
|
|
28
|
+
|
|
29
|
+
Includes wrapper-level props such as:
|
|
30
|
+
|
|
31
|
+
- `label`
|
|
32
|
+
- `prop`
|
|
33
|
+
- `rules`
|
|
34
|
+
- `required`
|
|
35
|
+
- `tooltip`
|
|
36
|
+
|
|
37
|
+
### `data`
|
|
38
|
+
|
|
39
|
+
The tree node source.
|
|
40
|
+
|
|
41
|
+
Use this when the visible tree structure is known up front.
|
|
42
|
+
|
|
43
|
+
### Tree interaction props
|
|
44
|
+
|
|
45
|
+
Useful field props include:
|
|
46
|
+
|
|
47
|
+
- `showCheckbox`
|
|
48
|
+
- `checkStrictly`
|
|
49
|
+
- `multiple`
|
|
50
|
+
- `filterable`
|
|
51
|
+
- `renderContent`
|
|
52
|
+
|
|
53
|
+
### Mapping and lazy-loading props
|
|
54
|
+
|
|
55
|
+
Use tree mapping and lazy-loading props when the node shape or loading strategy needs configuration.
|
|
56
|
+
|
|
57
|
+
## Slots
|
|
58
|
+
|
|
59
|
+
Useful slots include wrapper-level `label` and `error`, plus tree node customization slots for richer node rendering.
|
|
60
|
+
|
|
61
|
+
## Instance API
|
|
62
|
+
|
|
63
|
+
The exposed instance combines:
|
|
64
|
+
|
|
65
|
+
- `formItem`
|
|
66
|
+
- `field`
|
|
67
|
+
|
|
68
|
+
## Events
|
|
69
|
+
|
|
70
|
+
Important events include:
|
|
71
|
+
|
|
72
|
+
- `update:modelValue`
|
|
73
|
+
- `change`
|
|
74
|
+
- `focus`
|
|
75
|
+
- `blur`
|
|
76
|
+
- `clear`
|
|
77
|
+
- `visibleChange`
|
|
78
|
+
- `removeTag`
|
|
79
|
+
- `popupScroll`
|
|
80
|
+
- tree node interaction events such as `nodeClick`, `checkChange`, `check`, `nodeExpand`, and `nodeCollapse`
|
|
81
|
+
|
|
82
|
+
## Import
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
import { FormTreeSelect } from '@hinen/pro-element-plus';
|
|
86
|
+
```
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: using-image
|
|
3
|
+
description: Use when you need richer image loading, preview, placeholder, and failure handling than a bare image tag provides.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Using Image
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Use `Image` for a **stateful image primitive** that keeps Element Plus image behavior while adding preview defaults, a built-in reload affordance after failure, and empty-state handling when no source is present.
|
|
11
|
+
|
|
12
|
+
It is strongest when image loading, preview, failure recovery, or placeholder behavior are part of the product flow rather than afterthoughts.
|
|
13
|
+
|
|
14
|
+
## Use it when
|
|
15
|
+
|
|
16
|
+
Use `Image` when several of these are true:
|
|
17
|
+
|
|
18
|
+
- images need preview behavior
|
|
19
|
+
- failure and reload states matter to the workflow
|
|
20
|
+
- loading, preview, or error UI needs slot-level customization
|
|
21
|
+
- empty-state behavior matters when `src` may be missing
|
|
22
|
+
- the default reload control and preview affordances are useful
|
|
23
|
+
|
|
24
|
+
Strong signals this skill applies:
|
|
25
|
+
|
|
26
|
+
- thumbnail galleries
|
|
27
|
+
- avatar or cover-image cards
|
|
28
|
+
- image-heavy detail views
|
|
29
|
+
- media lists with recoverable load failures
|
|
30
|
+
|
|
31
|
+
## Prefer something else when
|
|
32
|
+
|
|
33
|
+
- you only need text truncation around media metadata
|
|
34
|
+
→ use `../using-ellipsis-text/SKILL.md`
|
|
35
|
+
- a plain browser image tag is sufficient and preview or retry behavior does not matter
|
|
36
|
+
|
|
37
|
+
## Decision guide
|
|
38
|
+
|
|
39
|
+
Use `Image` if the answer is yes for **two or more** of these:
|
|
40
|
+
|
|
41
|
+
- Should the image support preview or gallery viewing?
|
|
42
|
+
- Should failed loads offer an in-place reload action?
|
|
43
|
+
- Do placeholder, error, or empty states need customization?
|
|
44
|
+
- Is missing or unstable image data part of normal usage?
|
|
45
|
+
|
|
46
|
+
If not, a plain image element may be enough.
|
|
47
|
+
|
|
48
|
+
## Start with
|
|
49
|
+
|
|
50
|
+
1. Decide whether preview is part of the workflow.
|
|
51
|
+
2. Decide whether the default error text and reload control are enough.
|
|
52
|
+
3. Set `src` and optional `previewSrcList` first.
|
|
53
|
+
4. Add slots only when the default states do not fit the product requirement.
|
|
54
|
+
|
|
55
|
+
## Minimal patterns
|
|
56
|
+
|
|
57
|
+
### Thumbnail with preview
|
|
58
|
+
|
|
59
|
+
```vue
|
|
60
|
+
<Image :src="src" :preview="true" />
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Failed image with reload
|
|
64
|
+
|
|
65
|
+
Use the built-in reload affordance when users should be able to retry a failed asset without reloading the page.
|
|
66
|
+
|
|
67
|
+
### Empty image placeholder
|
|
68
|
+
|
|
69
|
+
Use the empty state when `src` may be missing and the layout should still reserve image space cleanly.
|
|
70
|
+
|
|
71
|
+
## Common mistakes
|
|
72
|
+
|
|
73
|
+
- turning off the built-in reload control and then expecting users to recover from load failures in place
|
|
74
|
+
- overlooking that preview is enabled by default here
|
|
75
|
+
- treating empty `src` and failed `src` as the same state
|
|
76
|
+
- adding custom slots before confirming whether the built-in image states already fit
|
|
77
|
+
|
|
78
|
+
When reading package-facing docs, prefer the documented behavior over memorizing one term: this component's public story is about a reload control after failure, even if different docs use slightly different labels for that control.
|
|
79
|
+
|
|
80
|
+
## Related skills
|
|
81
|
+
|
|
82
|
+
- Truncating related long text content: `../using-ellipsis-text/SKILL.md`
|
|
83
|
+
|
|
84
|
+
## References
|
|
85
|
+
|
|
86
|
+
- Props: `./references/props.md`
|
|
87
|
+
- Examples: `./references/examples.md`
|
|
88
|
+
- Gotchas: `./references/gotchas.md`
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Image examples
|
|
2
|
+
|
|
3
|
+
## 1. Thumbnail with preview
|
|
4
|
+
|
|
5
|
+
Use `preview` and `previewSrcList` when the same image should expand into a viewer or gallery flow.
|
|
6
|
+
|
|
7
|
+
Typical fit:
|
|
8
|
+
|
|
9
|
+
- product galleries
|
|
10
|
+
- avatar preview
|
|
11
|
+
- image-heavy detail pages
|
|
12
|
+
|
|
13
|
+
## 2. Retryable image load
|
|
14
|
+
|
|
15
|
+
Keep `showRefresh` enabled when users should be able to retry a failed asset without reloading the page.
|
|
16
|
+
|
|
17
|
+
Typical fit:
|
|
18
|
+
|
|
19
|
+
- unstable remote assets
|
|
20
|
+
- user-uploaded content
|
|
21
|
+
- CDN-backed thumbnails
|
|
22
|
+
|
|
23
|
+
## 3. Custom failure or empty state
|
|
24
|
+
|
|
25
|
+
Use the `error`, `refreshButton`, `placeholder`, or `empty` slots when the fallback UI needs product-specific language or styling.
|
|
26
|
+
|
|
27
|
+
Typical fit:
|
|
28
|
+
|
|
29
|
+
- branded empty states
|
|
30
|
+
- custom retry buttons
|
|
31
|
+
- loading placeholders matched to layout skeletons
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Image gotchas
|
|
2
|
+
|
|
3
|
+
- `preview` defaults to `true` here
|
|
4
|
+
If preview should be disabled, set it explicitly.
|
|
5
|
+
|
|
6
|
+
- `previewTeleported` defaults to `true`
|
|
7
|
+
This affects where the preview viewer renders.
|
|
8
|
+
|
|
9
|
+
- Setting `showRefresh` to `false` removes the retry affordance
|
|
10
|
+
After a failed load, users will have no built-in recovery action.
|
|
11
|
+
|
|
12
|
+
- Empty `src` and failed `src` are different states
|
|
13
|
+
Missing source shows the empty-state path; failed source shows the error-state path.
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Image props
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
`Image` extends Element Plus image behavior with retry, preview defaults, and explicit empty-state handling.
|
|
6
|
+
|
|
7
|
+
Use it when loading-state behavior is part of the component choice, not just the image URL itself.
|
|
8
|
+
|
|
9
|
+
## Minimum setup
|
|
10
|
+
|
|
11
|
+
Typical useful props:
|
|
12
|
+
|
|
13
|
+
- `src`
|
|
14
|
+
|
|
15
|
+
Common optional props:
|
|
16
|
+
|
|
17
|
+
- `preview`
|
|
18
|
+
- `previewSrcList`
|
|
19
|
+
- `showRefresh`
|
|
20
|
+
- `showError`
|
|
21
|
+
- `errorText`
|
|
22
|
+
|
|
23
|
+
## Core props
|
|
24
|
+
|
|
25
|
+
### `src`
|
|
26
|
+
|
|
27
|
+
The image source URL.
|
|
28
|
+
|
|
29
|
+
If `src` is empty, the component renders its empty state instead of trying to load an image.
|
|
30
|
+
|
|
31
|
+
### `preview`
|
|
32
|
+
|
|
33
|
+
Toggles preview behavior.
|
|
34
|
+
|
|
35
|
+
Default: `true`
|
|
36
|
+
|
|
37
|
+
### `previewSrcList`
|
|
38
|
+
|
|
39
|
+
Preview gallery source list.
|
|
40
|
+
|
|
41
|
+
If preview is enabled and no list is provided, the component falls back to the current computed source.
|
|
42
|
+
|
|
43
|
+
### `showRefresh`
|
|
44
|
+
|
|
45
|
+
Shows a reload action after failure.
|
|
46
|
+
|
|
47
|
+
Default: `true`
|
|
48
|
+
|
|
49
|
+
### `showError`
|
|
50
|
+
|
|
51
|
+
Controls whether the error text is shown.
|
|
52
|
+
|
|
53
|
+
Default: `true`
|
|
54
|
+
|
|
55
|
+
### `errorText`
|
|
56
|
+
|
|
57
|
+
Overrides the default localized error text.
|
|
58
|
+
|
|
59
|
+
### `previewTeleported`
|
|
60
|
+
|
|
61
|
+
Controls preview viewer teleport behavior.
|
|
62
|
+
|
|
63
|
+
Default: `true`
|
|
64
|
+
|
|
65
|
+
## Slots
|
|
66
|
+
|
|
67
|
+
Useful slots include:
|
|
68
|
+
|
|
69
|
+
- `error`
|
|
70
|
+
- `refreshButton`
|
|
71
|
+
- `placeholder`
|
|
72
|
+
- `empty`
|
|
73
|
+
- `viewer`
|
|
74
|
+
- `progress`
|
|
75
|
+
- `toolbar`
|
|
76
|
+
|
|
77
|
+
## Events
|
|
78
|
+
|
|
79
|
+
Important events include:
|
|
80
|
+
|
|
81
|
+
- `load`
|
|
82
|
+
- `error`
|
|
83
|
+
- `switch`
|
|
84
|
+
- `close`
|
|
85
|
+
- `show`
|
|
86
|
+
|
|
87
|
+
## Import
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
import { Image } from '@hinen/pro-element-plus';
|
|
91
|
+
```
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: using-modal
|
|
3
|
+
description: Use when a centered overlay should keep Element Plus dialog behavior while adding standard confirm and cancel actions, confirm loading state, and size presets.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Using Modal
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Use `Modal` for a **centered dialog workflow** that should keep Element Plus dialog behavior while adding a standard footer, size presets, confirm loading state, and scroll-shadow treatment for long content.
|
|
11
|
+
|
|
12
|
+
It is best for short, focused overlay flows where confirm and cancel are first-class actions. It is not just a visual wrapper around `ElDialog`; it adds a stronger default action model.
|
|
13
|
+
|
|
14
|
+
## Use it when
|
|
15
|
+
|
|
16
|
+
Use `Modal` when several of these are true:
|
|
17
|
+
|
|
18
|
+
- the interaction fits a centered dialog
|
|
19
|
+
- the flow should expose standard confirm and cancel buttons
|
|
20
|
+
- async submit state should appear on the confirm button
|
|
21
|
+
- size presets are preferable to ad hoc widths
|
|
22
|
+
- the content may overflow and still needs a stable shell
|
|
23
|
+
|
|
24
|
+
Strong signals this skill applies:
|
|
25
|
+
|
|
26
|
+
- confirmation dialogs with meaningful body content
|
|
27
|
+
- small record editors
|
|
28
|
+
- detail review dialogs
|
|
29
|
+
- one-step approval or submit flows
|
|
30
|
+
|
|
31
|
+
## Prefer something else when
|
|
32
|
+
|
|
33
|
+
- the workflow needs a side panel or should stay anchored to the viewport edge
|
|
34
|
+
→ use `../using-drawer/SKILL.md`
|
|
35
|
+
- you are still choosing the right overlay pattern
|
|
36
|
+
→ use `../building-modal-workflows/SKILL.md`
|
|
37
|
+
- the interaction is so small that plain Element Plus dialog usage is clearer than the added footer semantics
|
|
38
|
+
- the feature needs highly custom actions with no confirm/cancel model
|
|
39
|
+
|
|
40
|
+
## Decision guide
|
|
41
|
+
|
|
42
|
+
Use `Modal` if the answer is yes for **two or more** of these:
|
|
43
|
+
|
|
44
|
+
- Should the overlay be centered rather than edge-attached?
|
|
45
|
+
- Do confirm and cancel represent the core business actions?
|
|
46
|
+
- Should submit loading live on the confirm button?
|
|
47
|
+
- Will a `small`, `default`, or `large` preset be enough for sizing?
|
|
48
|
+
- Should the feature keep standard dialog lifecycle events while gaining a stronger footer contract?
|
|
49
|
+
|
|
50
|
+
If not, `Drawer` or a lower-level dialog composition may fit better.
|
|
51
|
+
|
|
52
|
+
## Start with
|
|
53
|
+
|
|
54
|
+
1. Control visibility through `modelValue`.
|
|
55
|
+
2. Use the built-in footer for standard confirm and cancel flows.
|
|
56
|
+
3. Choose `size` before reaching for explicit `width`.
|
|
57
|
+
4. Keep close behavior in business code by handling `cancel`, `ok`, and `update:modelValue` explicitly.
|
|
58
|
+
|
|
59
|
+
## Minimal patterns
|
|
60
|
+
|
|
61
|
+
### Standard confirm and cancel flow
|
|
62
|
+
|
|
63
|
+
```vue
|
|
64
|
+
<Modal
|
|
65
|
+
:model-value="visible"
|
|
66
|
+
title="Edit User"
|
|
67
|
+
:confirm-loading="saving"
|
|
68
|
+
@update:model-value="visible = $event"
|
|
69
|
+
@cancel="visible = false"
|
|
70
|
+
@ok="handleSubmit"
|
|
71
|
+
>
|
|
72
|
+
<UserForm />
|
|
73
|
+
</Modal>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Hide the default footer
|
|
77
|
+
|
|
78
|
+
Use this when the content manages its own actions.
|
|
79
|
+
|
|
80
|
+
```vue
|
|
81
|
+
<Modal
|
|
82
|
+
:model-value="visible"
|
|
83
|
+
:footer="false"
|
|
84
|
+
@update:model-value="visible = $event"
|
|
85
|
+
>
|
|
86
|
+
<CustomWorkflow />
|
|
87
|
+
</Modal>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Custom footer slot
|
|
91
|
+
|
|
92
|
+
Use the slot only when the default two-button action model is not enough.
|
|
93
|
+
|
|
94
|
+
## Common mistakes
|
|
95
|
+
|
|
96
|
+
- assuming `ok` or `cancel` automatically closes the modal
|
|
97
|
+
- using exact `width` immediately instead of trying `size` first
|
|
98
|
+
- forgetting that `okButtonProps.type` can override `okType`
|
|
99
|
+
- rebuilding footer actions from scratch for a standard submit flow
|
|
100
|
+
- using `Modal` for long, panel-like workflows that should really be drawers
|
|
101
|
+
|
|
102
|
+
## Related skills
|
|
103
|
+
|
|
104
|
+
- Side-panel workflow shell: `../using-drawer/SKILL.md`
|
|
105
|
+
- Overlay-pattern selection: `../building-modal-workflows/SKILL.md`
|
|
106
|
+
- Form workflow when the body is an editor or wrapped form: `../building-form-workflows/SKILL.md`
|
|
107
|
+
- Query or list shells when the body is filter-plus-results content: `../using-query-form/SKILL.md`, `../using-data-table/SKILL.md`
|
|
108
|
+
|
|
109
|
+
## References
|
|
110
|
+
|
|
111
|
+
- Props: `./references/props.md`
|
|
112
|
+
- Examples: `./references/examples.md`
|
|
113
|
+
- Gotchas: `./references/gotchas.md`
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# Modal examples
|
|
2
|
+
|
|
3
|
+
## 1. Standard confirm dialog
|
|
4
|
+
|
|
5
|
+
Use `Modal` when the main job is confirming or cancelling a short workflow with meaningful body content.
|
|
6
|
+
|
|
7
|
+
Minimal pattern:
|
|
8
|
+
|
|
9
|
+
```vue
|
|
10
|
+
<Modal
|
|
11
|
+
:model-value="visible"
|
|
12
|
+
title="Confirm"
|
|
13
|
+
@cancel="visible = false"
|
|
14
|
+
@ok="handleConfirm"
|
|
15
|
+
/>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Typical fit:
|
|
19
|
+
|
|
20
|
+
- delete confirmations with extra context
|
|
21
|
+
- approval dialogs
|
|
22
|
+
- one-step submit flows
|
|
23
|
+
|
|
24
|
+
Recommended pattern:
|
|
25
|
+
|
|
26
|
+
- keep the default footer
|
|
27
|
+
- wire `cancel` and `ok` in parent code
|
|
28
|
+
- use `confirmLoading` for async work
|
|
29
|
+
|
|
30
|
+
## 2. Small record editor
|
|
31
|
+
|
|
32
|
+
Use `Modal` when a compact editor should stay centered and focused.
|
|
33
|
+
|
|
34
|
+
Minimal pattern:
|
|
35
|
+
|
|
36
|
+
```vue
|
|
37
|
+
<Modal
|
|
38
|
+
:model-value="visible"
|
|
39
|
+
title="Rename"
|
|
40
|
+
@cancel="visible = false"
|
|
41
|
+
@ok="handleSave"
|
|
42
|
+
>
|
|
43
|
+
<RenameForm />
|
|
44
|
+
</Modal>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Typical fit:
|
|
48
|
+
|
|
49
|
+
- rename dialogs
|
|
50
|
+
- status-change dialogs
|
|
51
|
+
- lightweight metadata editors
|
|
52
|
+
|
|
53
|
+
Recommended pattern:
|
|
54
|
+
|
|
55
|
+
- start with `size="small"` or `size="default"`
|
|
56
|
+
- keep the form inside the body slot
|
|
57
|
+
- close on successful submit, not on button click alone
|
|
58
|
+
|
|
59
|
+
## 3. Overflowing long-form content
|
|
60
|
+
|
|
61
|
+
Use `Modal` when the body may scroll but the shell should stay stable.
|
|
62
|
+
|
|
63
|
+
Minimal pattern:
|
|
64
|
+
|
|
65
|
+
```vue
|
|
66
|
+
<Modal
|
|
67
|
+
:model-value="visible"
|
|
68
|
+
title="Review Terms"
|
|
69
|
+
@cancel="visible = false"
|
|
70
|
+
@ok="handleAccept"
|
|
71
|
+
>
|
|
72
|
+
<LongContent />
|
|
73
|
+
</Modal>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Typical fit:
|
|
77
|
+
|
|
78
|
+
- policy review dialogs
|
|
79
|
+
- long explanations with a final confirm action
|
|
80
|
+
- large read-only detail content that still behaves like a dialog
|
|
81
|
+
|
|
82
|
+
The component already handles scrollable body rendering and header or footer shadow transitions.
|
|
83
|
+
|
|
84
|
+
## 4. Custom action layout
|
|
85
|
+
|
|
86
|
+
Use the `footer` slot when the default two-button pattern cannot express the workflow.
|
|
87
|
+
|
|
88
|
+
Minimal pattern:
|
|
89
|
+
|
|
90
|
+
```vue
|
|
91
|
+
<Modal :model-value="visible">
|
|
92
|
+
<template #footer>
|
|
93
|
+
<CustomActions />
|
|
94
|
+
</template>
|
|
95
|
+
</Modal>
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Typical fit:
|
|
99
|
+
|
|
100
|
+
- three-way decision flows
|
|
101
|
+
- secondary destructive action next to save
|
|
102
|
+
- multi-step footer controls
|
|
103
|
+
|
|
104
|
+
Prefer the built-in footer until the product flow genuinely needs more than confirm and cancel.
|
|
105
|
+
|
|
106
|
+
## 5. Modal with query or list content
|
|
107
|
+
|
|
108
|
+
Use `Modal` when the overlay stays centered, but the inner body is really a query/list workflow rather than a simple editor.
|
|
109
|
+
|
|
110
|
+
Minimal pattern:
|
|
111
|
+
|
|
112
|
+
```vue
|
|
113
|
+
<Modal :model-value="visible" title="Choose User" @cancel="visible = false">
|
|
114
|
+
<QueryForm :items="items" @search="handleSearch" />
|
|
115
|
+
</Modal>
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Typical fit:
|
|
119
|
+
|
|
120
|
+
- centered search-and-pick dialogs
|
|
121
|
+
- short review-history overlays
|
|
122
|
+
- quick filter panels that should not become full drawers
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Modal gotchas
|
|
2
|
+
|
|
3
|
+
- `size` is a library-level preset
|
|
4
|
+
It is not part of Element Plus dialog props, so treat it as the preferred convenience layer here.
|
|
5
|
+
|
|
6
|
+
- `width` and `size` are not the same decision
|
|
7
|
+
Reach for `width` only when the presets do not match product intent.
|
|
8
|
+
|
|
9
|
+
- `ok` and `cancel` do not close the modal automatically
|
|
10
|
+
Parent code still needs to update `modelValue` or handle the dialog lifecycle explicitly.
|
|
11
|
+
|
|
12
|
+
- `okButtonProps` can override `okType`
|
|
13
|
+
If the confirm button style looks wrong, check both values.
|
|
14
|
+
|
|
15
|
+
- Hiding the footer removes the built-in action model
|
|
16
|
+
Once `footer` is `false` or the slot replaces it, your own content must provide the workflow affordances.
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# Modal props
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
`Modal` extends Element Plus dialog props and adds a standard footer contract, size presets, and button-level loading state.
|
|
6
|
+
|
|
7
|
+
Choose the action model first, then choose sizing.
|
|
8
|
+
|
|
9
|
+
## Minimum setup
|
|
10
|
+
|
|
11
|
+
Required in normal usage:
|
|
12
|
+
|
|
13
|
+
- `modelValue`
|
|
14
|
+
|
|
15
|
+
Typical optional props:
|
|
16
|
+
|
|
17
|
+
- `title`
|
|
18
|
+
- `size`
|
|
19
|
+
- `footer`
|
|
20
|
+
- `confirmLoading`
|
|
21
|
+
|
|
22
|
+
## Core props
|
|
23
|
+
|
|
24
|
+
### `modelValue`
|
|
25
|
+
|
|
26
|
+
Controls visibility.
|
|
27
|
+
|
|
28
|
+
Use `update:modelValue` to keep parent state in sync.
|
|
29
|
+
|
|
30
|
+
### `size`
|
|
31
|
+
|
|
32
|
+
Library-level preset sizing.
|
|
33
|
+
|
|
34
|
+
Supported values:
|
|
35
|
+
|
|
36
|
+
- `small`
|
|
37
|
+
- `default`
|
|
38
|
+
- `large`
|
|
39
|
+
|
|
40
|
+
Default: `default`
|
|
41
|
+
|
|
42
|
+
If `width` is provided, use that intentionally instead of relying on the preset alone.
|
|
43
|
+
|
|
44
|
+
### `width`
|
|
45
|
+
|
|
46
|
+
Inherited from Element Plus dialog props.
|
|
47
|
+
|
|
48
|
+
Use this only when the preset sizes are not sufficient.
|
|
49
|
+
|
|
50
|
+
### `footer`
|
|
51
|
+
|
|
52
|
+
Controls whether the default footer is rendered.
|
|
53
|
+
|
|
54
|
+
Default: `true`
|
|
55
|
+
|
|
56
|
+
### `confirmLoading`
|
|
57
|
+
|
|
58
|
+
Shows loading on the built-in confirm button.
|
|
59
|
+
|
|
60
|
+
Default: `false`
|
|
61
|
+
|
|
62
|
+
### `okText` and `cancelText`
|
|
63
|
+
|
|
64
|
+
Override the localized button labels.
|
|
65
|
+
|
|
66
|
+
### `okType`
|
|
67
|
+
|
|
68
|
+
Sets the built-in confirm button type.
|
|
69
|
+
|
|
70
|
+
Default: `primary`
|
|
71
|
+
|
|
72
|
+
### `okButtonProps` and `cancelButtonProps`
|
|
73
|
+
|
|
74
|
+
Pass partial Element Plus button props into the built-in footer actions.
|
|
75
|
+
|
|
76
|
+
Use these for fine-grained button overrides without replacing the whole footer.
|
|
77
|
+
|
|
78
|
+
## Events
|
|
79
|
+
|
|
80
|
+
`Modal` keeps Element Plus dialog events and adds:
|
|
81
|
+
|
|
82
|
+
- `ok`
|
|
83
|
+
- `cancel`
|
|
84
|
+
|
|
85
|
+
These are business-action events. They do not automatically close the modal.
|
|
86
|
+
|
|
87
|
+
## Slots
|
|
88
|
+
|
|
89
|
+
Useful slots:
|
|
90
|
+
|
|
91
|
+
- default body slot
|
|
92
|
+
- `footer`
|
|
93
|
+
|
|
94
|
+
All other dialog slots still pass through.
|
|
95
|
+
|
|
96
|
+
## Import
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
import { Modal } from '@hinen/pro-element-plus';
|
|
100
|
+
```
|