@kubex/zinc 1.0.24 → 1.0.98
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/.claude/project.md +556 -0
- package/.github/workflows/js_build_and_deploy.yaml +9 -10
- package/dist/custom-elements.json +13431 -8728
- package/dist/vscode.html-custom-data.json +571 -37
- package/dist/web-types.json +1439 -181
- package/dist/zn.d.ts +1642 -661
- package/dist/zn.min.css +1 -1
- package/dist/zn.min.js +1407 -887
- package/docs/_utilities/code-previews.cjs +10 -1
- package/docs/assets/scripts/docs.js +42 -18
- package/docs/data/data-table.json +229 -66
- package/docs/data/empty.json +6 -0
- package/docs/data/products-table.json +41 -193
- package/docs/pages/components/action-bar.md +121 -6
- package/docs/pages/components/alert.md +118 -15
- package/docs/pages/components/animated-button.md +299 -0
- package/docs/pages/components/audio-select.md +534 -0
- package/docs/pages/components/bulk-actions.md +79 -5
- package/docs/pages/components/button-group.md +235 -27
- package/docs/pages/components/button.md +139 -1
- package/docs/pages/components/chart.md +365 -9
- package/docs/pages/components/checkbox.md +387 -58
- package/docs/pages/components/chip.md +253 -33
- package/docs/pages/components/collapsible.md +393 -46
- package/docs/pages/components/cols.md +152 -30
- package/docs/pages/components/confirm.md +182 -16
- package/docs/pages/components/copy-button.md +169 -6
- package/docs/pages/components/data-select.md +194 -15
- package/docs/pages/components/data-table-filter.md +96 -5
- package/docs/pages/components/data-table-search.md +451 -0
- package/docs/pages/components/data-table-sort.md +66 -5
- package/docs/pages/components/data-table.md +727 -66
- package/docs/pages/components/datepicker.md +402 -7
- package/docs/pages/components/defined-label.md +120 -5
- package/docs/pages/components/dialog.md +339 -59
- package/docs/pages/components/dropdown.md +366 -11
- package/docs/pages/components/editor.md +604 -7
- package/docs/pages/components/empty-state.md +315 -16
- package/docs/pages/components/expanding-action.md +212 -28
- package/docs/pages/components/file.md +421 -12
- package/docs/pages/components/filter-container.md +158 -5
- package/docs/pages/components/filter-wrapper.md +167 -6
- package/docs/pages/components/form-group.md +383 -6
- package/docs/pages/components/hover-container.md +237 -6
- package/docs/pages/components/icon-picker.md +121 -0
- package/docs/pages/components/icon.md +454 -48
- package/docs/pages/components/inline-edit.md +787 -19
- package/docs/pages/components/input-group.md +207 -13
- package/docs/pages/components/input.md +194 -0
- package/docs/pages/components/key-container.md +115 -0
- package/docs/pages/components/key.md +101 -0
- package/docs/pages/components/menu.md +512 -6
- package/docs/pages/components/note.md +239 -36
- package/docs/pages/components/opt-group.md +107 -0
- package/docs/pages/components/pagination.md +332 -6
- package/docs/pages/components/pane.md +222 -6
- package/docs/pages/components/panel.md +213 -26
- package/docs/pages/components/popup.md +1354 -6
- package/docs/pages/components/priority-list.md +233 -0
- package/docs/pages/components/progress-bar.md +387 -6
- package/docs/pages/components/radio-group.md +242 -5
- package/docs/pages/components/radio.md +474 -6
- package/docs/pages/components/rating.md +331 -7
- package/docs/pages/components/reveal.md +524 -6
- package/docs/pages/components/scroll-container.md +552 -6
- package/docs/pages/components/select.md +762 -160
- package/docs/pages/components/skeleton.md +473 -30
- package/docs/pages/components/slideout.md +261 -5
- package/docs/pages/components/sp.md +99 -41
- package/docs/pages/components/split-button.md +347 -9
- package/docs/pages/components/split-pane.md +445 -6
- package/docs/pages/components/stat.md +549 -9
- package/docs/pages/components/status-indicator.md +230 -1
- package/docs/pages/components/stepper.md +563 -6
- package/docs/pages/components/tabs.md +439 -13
- package/docs/pages/components/textarea.md +415 -17
- package/docs/pages/components/tile.md +385 -26
- package/docs/pages/components/toggle.md +424 -6
- package/docs/pages/components/tooltip.md +367 -0
- package/docs/pages/components/translation-group.md +210 -0
- package/docs/pages/components/translations.md +319 -18
- package/docs/pages/components/vertical-stepper.md +401 -8
- package/docs/pages/components/well.md +300 -3
- package/docs/pages/getting-started/form-controls.md +162 -0
- package/docs/pages/index.md +116 -15
- package/package.json +5 -6
- package/scss/_global-spacing.scss +4 -0
- package/scss/_root.scss +2 -2
- package/scss/boot.scss +19 -0
- package/scss/shared/layout.scss +5 -0
- package/scss/themes/_light.scss +3 -3
- package/src/components/alert/alert.scss +1 -0
- package/src/components/animated-button/README.md +306 -0
- package/src/components/animated-button/animated-button.component.ts +229 -0
- package/src/components/animated-button/animated-button.scss +228 -0
- package/src/components/animated-button/animated-button.test.ts +143 -0
- package/src/components/animated-button/index.ts +12 -0
- package/src/components/button/button.component.ts +5 -0
- package/src/components/button-group/button-group.component.ts +25 -13
- package/src/components/button-group/button-group.scss +6 -0
- package/src/components/checkbox/checkbox.component.ts +4 -0
- package/src/components/checkbox/checkbox.scss +7 -4
- package/src/components/checkbox-group/checkbox-group.scss +7 -0
- package/src/components/chip/chip.component.ts +7 -2
- package/src/components/chip/chip.scss +16 -2
- package/src/components/collapsible/collapsible.component.ts +27 -20
- package/src/components/cols/cols.component.ts +14 -2
- package/src/components/cols/cols.scss +6 -12
- package/src/components/confirm/confirm.component.ts +7 -0
- package/src/components/copy-button/copy-button.component.ts +12 -11
- package/src/components/data-select/data-select.component.ts +215 -44
- package/src/components/data-select/data-select.scss +66 -6
- package/src/components/data-select/providers/currency-data-provider.ts +20 -6
- package/src/components/data-select/providers/provider.ts +1 -0
- package/src/components/data-select/providers/us-state-data-provider.ts +68 -0
- package/src/components/data-table/data-table.component.ts +82 -23
- package/src/components/data-table-search/data-table-search.component.ts +184 -0
- package/src/components/data-table-search/data-table-search.scss +17 -0
- package/src/components/data-table-search/data-table-search.test.ts +11 -0
- package/src/components/data-table-search/index.ts +12 -0
- package/src/components/datepicker/datepicker.component.ts +347 -13
- package/src/components/dialog/dialog.component.ts +1 -1
- package/src/components/empty-state/empty-state.scss +6 -1
- package/src/components/header/header.scss +3 -3
- package/src/components/icon/icon.component.ts +23 -1
- package/src/components/icon/icon.scss +23 -0
- package/src/components/icon-picker/brand-icons.ts +24 -0
- package/src/components/icon-picker/icon-picker.component.ts +407 -0
- package/src/components/icon-picker/icon-picker.scss +205 -0
- package/src/components/icon-picker/index.ts +12 -0
- package/src/components/icon-picker/line-icons.ts +612 -0
- package/src/components/icon-picker/material-icons.ts +14543 -0
- package/src/components/inline-edit/inline-edit.component.ts +190 -46
- package/src/components/inline-edit/inline-edit.scss +29 -0
- package/src/components/inline-edit/inline-edit.test.ts +314 -1
- package/src/components/input/input.component.ts +328 -5
- package/src/components/input/input.scss +100 -4
- package/src/components/input-group/input-group.component.ts +28 -7
- package/src/components/input-group/input-group.scss +48 -10
- package/src/components/item/item.component.ts +11 -2
- package/src/components/item/item.scss +7 -0
- package/src/components/key/index.ts +12 -0
- package/src/components/key/key.component.ts +47 -0
- package/src/components/key/key.scss +38 -0
- package/src/components/key-container/index.ts +12 -0
- package/src/components/key-container/key-container.component.ts +142 -0
- package/src/components/key-container/key-container.scss +33 -0
- package/src/components/menu-item/menu-item.component.ts +20 -0
- package/src/components/menu-item/menu-item.scss +69 -2
- package/src/components/navbar/navbar.component.ts +103 -8
- package/src/components/navbar/navbar.scss +6 -1
- package/src/components/opt-group/index.ts +12 -0
- package/src/components/opt-group/opt-group.component.ts +74 -0
- package/src/components/opt-group/opt-group.scss +37 -0
- package/src/components/opt-group/opt-group.test.ts +27 -0
- package/src/components/option/option.component.ts +1 -16
- package/src/components/option/option.scss +4 -0
- package/src/components/panel/panel.component.ts +10 -8
- package/src/components/panel/panel.scss +20 -0
- package/src/components/priority-list/index.ts +12 -0
- package/src/components/priority-list/priority-list.component.ts +611 -0
- package/src/components/priority-list/priority-list.scss +185 -0
- package/src/components/priority-list/priority-list.test.ts +139 -0
- package/src/components/progress-bar/progress-bar.component.ts +22 -16
- package/src/components/radio/radio.scss +10 -3
- package/src/components/select/select.component.ts +812 -72
- package/src/components/select/select.scss +108 -2
- package/src/components/select/select.test.ts +147 -2
- package/src/components/settings-container/settings-container.component.ts +44 -19
- package/src/components/settings-container/settings-container.scss +1 -1
- package/src/components/skeleton/skeleton.component.ts +6 -1
- package/src/components/slideout/slideout.scss +8 -3
- package/src/components/sp/sp.component.ts +3 -1
- package/src/components/sp/sp.scss +19 -0
- package/src/components/stepper/stepper.component.ts +16 -10
- package/src/components/textarea/textarea.scss +0 -4
- package/src/components/tile/tile.component.ts +12 -3
- package/src/components/tile/tile.scss +1 -1
- package/src/components/timer/timer.component.ts +15 -2
- package/src/components/toggle/toggle.component.ts +29 -26
- package/src/components/toggle/toggle.scss +13 -1
- package/src/components/translation-group/index.ts +12 -0
- package/src/components/translation-group/translation-group.component.ts +207 -0
- package/src/components/translation-group/translation-group.scss +8 -0
- package/src/components/translations/translations.component.ts +90 -42
- package/src/components/translations/translations.scss +5 -1
- package/src/components/vertical-stepper/vertical-stepper.component.ts +14 -9
- package/src/events/events.ts +12 -7
- package/src/events/zn-language-change.ts +7 -0
- package/src/events/zn-purchase.ts +11 -0
- package/src/events/zn-redirect.ts +7 -0
- package/src/events/zn-reorder.ts +7 -0
- package/src/events/zn-search-change.ts +11 -0
- package/src/events/zn-submit.ts +1 -1
- package/src/form-control.scss +4 -0
- package/src/internal/form-navigation.ts +510 -0
- package/src/internal/form.ts +6 -0
- package/src/zinc.ts +91 -83
|
@@ -9,78 +9,216 @@ layout: component
|
|
|
9
9
|
|
|
10
10
|
### Basic Dialog
|
|
11
11
|
|
|
12
|
-
This is a basic dialog. It has a trigger button that opens the dialog. The dialog has a close button and two buttons in
|
|
13
|
-
the footer.
|
|
12
|
+
This is a basic dialog. It has a trigger button that opens the dialog. The dialog has a close button and two buttons in the footer.
|
|
14
13
|
|
|
15
14
|
```html:preview
|
|
16
|
-
|
|
17
15
|
<zn-button id="dialog-trigger">Open Basic dialog</zn-button>
|
|
18
16
|
<zn-dialog class="dialog-basic" trigger="dialog-trigger" label="Dialog">
|
|
19
|
-
This is the dialog
|
|
17
|
+
This is the dialog's body.
|
|
20
18
|
|
|
21
19
|
<zn-button color="default" slot="footer">Do Something</zn-button>
|
|
22
20
|
<zn-button color="secondary" slot="footer" dialog-closer>Close Dialog</zn-button>
|
|
23
21
|
</zn-dialog>
|
|
24
22
|
```
|
|
25
23
|
|
|
26
|
-
###
|
|
24
|
+
### Labels
|
|
27
25
|
|
|
28
|
-
|
|
26
|
+
The dialog's label is displayed in the header and is required for proper accessibility. Use the `label` attribute to set the label text.
|
|
29
27
|
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
```html:preview
|
|
29
|
+
<zn-button id="dialog-label-trigger">Open Dialog</zn-button>
|
|
30
|
+
<zn-dialog trigger="dialog-label-trigger" label="Important Information">
|
|
31
|
+
This dialog has a label in the header that describes its purpose.
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
<zn-button color="secondary" slot="footer" dialog-closer>Close</zn-button>
|
|
34
|
+
</zn-dialog>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
For HTML content in the label, use the `label` slot instead.
|
|
36
38
|
|
|
37
39
|
```html:preview
|
|
40
|
+
<zn-button id="dialog-label-slot-trigger">Open Dialog</zn-button>
|
|
41
|
+
<zn-dialog trigger="dialog-label-slot-trigger">
|
|
42
|
+
<span slot="label">Important <em>Information</em></span>
|
|
43
|
+
This dialog uses the label slot for HTML content.
|
|
44
|
+
|
|
45
|
+
<zn-button color="secondary" slot="footer" dialog-closer>Close</zn-button>
|
|
46
|
+
</zn-dialog>
|
|
47
|
+
```
|
|
38
48
|
|
|
39
|
-
|
|
40
|
-
|
|
49
|
+
### Dialog Variants
|
|
50
|
+
|
|
51
|
+
Dialogs come in three variants: `default`, `warning`, and `announcement`. Set the `variant` attribute to apply the appropriate theme.
|
|
52
|
+
|
|
53
|
+
Use the `header-icon` slot to display an icon to the left of the dialog header label. The icon color is automatically styled based on the dialog variant.
|
|
54
|
+
|
|
55
|
+
#### Default Variant
|
|
56
|
+
|
|
57
|
+
Use the default variant for confirmation of neutral actions like submitting a form or displaying informational content.
|
|
58
|
+
|
|
59
|
+
```html:preview
|
|
60
|
+
<zn-button id="dialog-default-trigger">Open Default Dialog</zn-button>
|
|
61
|
+
<zn-dialog trigger="dialog-default-trigger" label="Confirm Submission" variant="default">
|
|
41
62
|
<zn-icon src="info" slot="header-icon"></zn-icon>
|
|
42
63
|
If you need to, you can cancel this request after submitting it. Are you sure you want to submit it now?
|
|
43
64
|
|
|
44
|
-
<zn-button color="secondary" slot="footer" dialog-closer>
|
|
45
|
-
<zn-button color="default" slot="footer"
|
|
65
|
+
<zn-button color="secondary" slot="footer" dialog-closer>Cancel</zn-button>
|
|
66
|
+
<zn-button color="default" slot="footer">Submit</zn-button>
|
|
46
67
|
</zn-dialog>
|
|
68
|
+
```
|
|
47
69
|
|
|
48
|
-
|
|
49
|
-
<zn-dialog class="dialog-basic" trigger="dialog-trigger-2" label="Dialog" variant="warning">
|
|
50
|
-
<zn-icon src="info" slot="header-icon"></zn-icon>
|
|
51
|
-
If you need to, you can cancel this request after submitting it. Are you sure you want to submit it now?
|
|
70
|
+
#### Warning Variant
|
|
52
71
|
|
|
53
|
-
|
|
54
|
-
|
|
72
|
+
Use the warning variant for confirmation of destructive actions like deleting or canceling something.
|
|
73
|
+
|
|
74
|
+
```html:preview
|
|
75
|
+
<zn-button id="dialog-warning-trigger">Open Warning Dialog</zn-button>
|
|
76
|
+
<zn-dialog trigger="dialog-warning-trigger" label="Delete Item" variant="warning">
|
|
77
|
+
<zn-icon src="warning" slot="header-icon"></zn-icon>
|
|
78
|
+
This action cannot be undone. Are you sure you want to delete this item?
|
|
79
|
+
|
|
80
|
+
<zn-button color="secondary" slot="footer" dialog-closer>Cancel</zn-button>
|
|
81
|
+
<zn-button color="warning" slot="footer">Delete</zn-button>
|
|
55
82
|
</zn-dialog>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
#### Announcement Variant
|
|
56
86
|
|
|
57
|
-
|
|
58
|
-
|
|
87
|
+
Use the announcement variant for special announcements, feature introductions, or welcome messages. This variant supports additional slots for intro text and footer text.
|
|
88
|
+
|
|
89
|
+
```html:preview
|
|
90
|
+
<zn-button id="dialog-announcement-trigger">Open Announcement</zn-button>
|
|
91
|
+
<zn-dialog trigger="dialog-announcement-trigger" label="Meet your new Monthly Numbers dashboard" variant="announcement">
|
|
59
92
|
<div slot="announcement-intro">Welcome!</div>
|
|
60
|
-
<zn-icon src="
|
|
61
|
-
|
|
93
|
+
<zn-icon src="celebration" slot="header-icon"></zn-icon>
|
|
94
|
+
We've redesigned the Monthly Numbers dashboard with new features and improved performance. Take a tour to see what's new.
|
|
62
95
|
|
|
63
|
-
<zn-button color="secondary" slot="footer" dialog-closer>
|
|
64
|
-
<zn-button color="default" slot="footer">
|
|
96
|
+
<zn-button color="secondary" slot="footer" dialog-closer>Skip Tour</zn-button>
|
|
97
|
+
<zn-button color="default" slot="footer">Start Tour</zn-button>
|
|
65
98
|
<div slot="footer-text"><a href="#">Learn more about Monthly Numbers</a></div>
|
|
66
99
|
</zn-dialog>
|
|
67
100
|
```
|
|
68
101
|
|
|
102
|
+
### Dialog Sizes
|
|
103
|
+
|
|
104
|
+
Dialogs come in three different sizes: `small`, `medium`, and `large`. The default size is `medium`. Use the `size` attribute to control the dialog width.
|
|
105
|
+
|
|
106
|
+
```html:preview
|
|
107
|
+
<zn-button id="dialog-small-trigger">Open Small Dialog</zn-button>
|
|
108
|
+
<zn-dialog trigger="dialog-small-trigger" label="Small Dialog" size="small">
|
|
109
|
+
<zn-icon src="info" slot="header-icon"></zn-icon>
|
|
110
|
+
This is a small dialog, ideal for simple confirmations.
|
|
111
|
+
|
|
112
|
+
<zn-button color="secondary" slot="footer" dialog-closer>Close</zn-button>
|
|
113
|
+
<zn-button color="default" slot="footer">Confirm</zn-button>
|
|
114
|
+
</zn-dialog>
|
|
115
|
+
|
|
116
|
+
<zn-button id="dialog-medium-trigger">Open Medium Dialog</zn-button>
|
|
117
|
+
<zn-dialog trigger="dialog-medium-trigger" label="Medium Dialog">
|
|
118
|
+
<zn-icon src="info" slot="header-icon"></zn-icon>
|
|
119
|
+
This is a medium dialog, the default size. It works well for most content.
|
|
120
|
+
|
|
121
|
+
<zn-button color="secondary" slot="footer" dialog-closer>Close</zn-button>
|
|
122
|
+
<zn-button color="default" slot="footer">Confirm</zn-button>
|
|
123
|
+
</zn-dialog>
|
|
124
|
+
|
|
125
|
+
<zn-button id="dialog-large-trigger">Open Large Dialog</zn-button>
|
|
126
|
+
<zn-dialog trigger="dialog-large-trigger" label="Large Dialog" size="large">
|
|
127
|
+
<zn-icon src="info" slot="header-icon"></zn-icon>
|
|
128
|
+
This is a large dialog, suitable for complex forms or detailed content.
|
|
129
|
+
|
|
130
|
+
<zn-button color="secondary" slot="footer" dialog-closer>Close</zn-button>
|
|
131
|
+
<zn-button color="default" slot="footer">Confirm</zn-button>
|
|
132
|
+
</zn-dialog>
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Custom Width
|
|
136
|
+
|
|
137
|
+
You can set a custom dialog width using the `--width` CSS custom property. Note that the dialog will automatically shrink to accommodate smaller screens.
|
|
138
|
+
|
|
139
|
+
```html:preview
|
|
140
|
+
<zn-button id="dialog-custom-width-trigger">Open Custom Width Dialog</zn-button>
|
|
141
|
+
<zn-dialog trigger="dialog-custom-width-trigger" label="Custom Width" style="--width: 800px;">
|
|
142
|
+
<zn-icon src="info" slot="header-icon"></zn-icon>
|
|
143
|
+
This dialog has a custom width of 800px set using the --width CSS property.
|
|
144
|
+
|
|
145
|
+
<zn-button color="secondary" slot="footer" dialog-closer>Close</zn-button>
|
|
146
|
+
</zn-dialog>
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Scrolling Content
|
|
150
|
+
|
|
151
|
+
When the dialog content is longer than the viewport, the body area automatically becomes scrollable while keeping the header and footer fixed.
|
|
152
|
+
|
|
153
|
+
```html:preview
|
|
154
|
+
<zn-button id="dialog-scrolling-trigger">Open Scrolling Dialog</zn-button>
|
|
155
|
+
<zn-dialog trigger="dialog-scrolling-trigger" label="Scrolling Content">
|
|
156
|
+
<zn-icon src="info" slot="header-icon"></zn-icon>
|
|
157
|
+
<p>This dialog has a lot of content that requires scrolling.</p>
|
|
158
|
+
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
|
|
159
|
+
<p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
|
|
160
|
+
<p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p>
|
|
161
|
+
<p>Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
|
162
|
+
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
|
|
163
|
+
<p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
|
|
164
|
+
<p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p>
|
|
165
|
+
<p>Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
|
166
|
+
|
|
167
|
+
<zn-button color="secondary" slot="footer" dialog-closer>Close</zn-button>
|
|
168
|
+
<zn-button color="default" slot="footer">Save</zn-button>
|
|
169
|
+
</zn-dialog>
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### No Header
|
|
173
|
+
|
|
174
|
+
Use the `no-header` attribute to hide the header, including the default close button. When using this option, ensure you provide an accessible way for users to close the dialog.
|
|
175
|
+
|
|
176
|
+
:::warning
|
|
177
|
+
**Note:** Even when using `no-header`, you should still provide a `label` attribute for proper accessibility. The label is used for screen readers even when visually hidden.
|
|
178
|
+
:::
|
|
179
|
+
|
|
180
|
+
```html:preview
|
|
181
|
+
<zn-button id="dialog-no-header-trigger">Open No Header Dialog</zn-button>
|
|
182
|
+
<zn-dialog trigger="dialog-no-header-trigger" label="Dialog without header" no-header>
|
|
183
|
+
<p>This dialog has no header. Notice there's no close button, so we've added one in the footer.</p>
|
|
184
|
+
<p>The label attribute is still required for accessibility, even though it's not visible.</p>
|
|
185
|
+
|
|
186
|
+
<zn-button color="default" slot="footer">Continue</zn-button>
|
|
187
|
+
<zn-button color="secondary" slot="footer" dialog-closer>Close</zn-button>
|
|
188
|
+
</zn-dialog>
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Header Actions
|
|
192
|
+
|
|
193
|
+
Use the `header-actions` slot to add buttons or other interactive elements to the header, next to the close button.
|
|
194
|
+
|
|
195
|
+
```html:preview
|
|
196
|
+
<zn-button id="dialog-header-actions-trigger">Open Dialog</zn-button>
|
|
197
|
+
<zn-dialog trigger="dialog-header-actions-trigger" label="Document Settings">
|
|
198
|
+
<zn-button icon="refresh" color="transparent" size="content" slot="header-actions"></zn-button>
|
|
199
|
+
<zn-button icon="settings" color="transparent" size="content" slot="header-actions"></zn-button>
|
|
200
|
+
|
|
201
|
+
<p>This dialog has action buttons in the header for quick access to common functions.</p>
|
|
202
|
+
|
|
203
|
+
<zn-button color="secondary" slot="footer" dialog-closer>Close</zn-button>
|
|
204
|
+
<zn-button color="default" slot="footer">Save</zn-button>
|
|
205
|
+
</zn-dialog>
|
|
206
|
+
```
|
|
207
|
+
|
|
69
208
|
### Dialogs as Forms
|
|
70
209
|
|
|
71
210
|
Use dialogs as forms when you need to collect information from users. This example shows a dialog with a form inside it.
|
|
72
211
|
|
|
73
212
|
```html:preview
|
|
74
|
-
|
|
75
213
|
<form method="post" action="#" style="display: inline-block">
|
|
76
|
-
<zn-button id="dialog-trigger">Open Form Dialog</zn-button>
|
|
77
|
-
<zn-dialog
|
|
78
|
-
<zn-icon src="
|
|
214
|
+
<zn-button id="dialog-form-trigger">Open Form Dialog</zn-button>
|
|
215
|
+
<zn-dialog trigger="dialog-form-trigger" label="Edit Profile" size="large">
|
|
216
|
+
<zn-icon src="person" slot="header-icon"></zn-icon>
|
|
79
217
|
|
|
80
218
|
<zn-form-group
|
|
81
|
-
label="Profile"
|
|
82
|
-
label-tooltip="
|
|
83
|
-
help-text="
|
|
219
|
+
label="Profile Information"
|
|
220
|
+
label-tooltip="This information will be displayed on your public profile"
|
|
221
|
+
help-text="All fields marked with an asterisk are required">
|
|
84
222
|
|
|
85
223
|
<div class="form-spacing">
|
|
86
224
|
<zn-input type="text" name="name" label="Name" required></zn-input>
|
|
@@ -91,55 +229,197 @@ Use dialogs as forms when you need to collect information from users. This examp
|
|
|
91
229
|
<zn-option value="other">Other</zn-option>
|
|
92
230
|
</zn-select>
|
|
93
231
|
|
|
94
|
-
<zn-textarea name="comment" label="
|
|
232
|
+
<zn-textarea name="comment" label="Bio" required></zn-textarea>
|
|
95
233
|
|
|
96
|
-
<zn-checkbox required>
|
|
234
|
+
<zn-checkbox required>I agree to the terms and conditions</zn-checkbox>
|
|
97
235
|
|
|
98
236
|
<br>
|
|
99
|
-
<zn-checkbox-group label="
|
|
237
|
+
<zn-checkbox-group label="Interests" help-text="Select at least one" label-tooltip="Choose your areas of interest"
|
|
100
238
|
required>
|
|
101
|
-
<zn-checkbox value="
|
|
102
|
-
<zn-checkbox value="
|
|
103
|
-
<zn-checkbox value="
|
|
239
|
+
<zn-checkbox value="technology">Technology</zn-checkbox>
|
|
240
|
+
<zn-checkbox value="sports">Sports</zn-checkbox>
|
|
241
|
+
<zn-checkbox value="music">Music</zn-checkbox>
|
|
104
242
|
</zn-checkbox-group>
|
|
105
243
|
</div>
|
|
106
244
|
</zn-form-group>
|
|
107
245
|
|
|
108
|
-
<zn-button color="secondary" slot="footer" dialog-closer>
|
|
109
|
-
<zn-button color="default" slot="footer" type="submit">
|
|
246
|
+
<zn-button color="secondary" slot="footer" dialog-closer>Cancel</zn-button>
|
|
247
|
+
<zn-button color="default" slot="footer" type="submit">Save Profile</zn-button>
|
|
110
248
|
</zn-dialog>
|
|
249
|
+
</form>
|
|
111
250
|
```
|
|
112
251
|
|
|
113
|
-
###
|
|
252
|
+
### Programmatic Control
|
|
114
253
|
|
|
115
|
-
Dialogs
|
|
254
|
+
Dialogs can be controlled programmatically using the `show()` and `hide()` methods. You can also check or set the `open` property to manage the dialog state.
|
|
116
255
|
|
|
117
256
|
```html:preview
|
|
257
|
+
<div>
|
|
258
|
+
<zn-button class="dialog-show">Show Dialog</zn-button>
|
|
259
|
+
<zn-button class="dialog-hide">Hide Dialog</zn-button>
|
|
260
|
+
<zn-button class="dialog-toggle">Toggle Dialog</zn-button>
|
|
261
|
+
</div>
|
|
118
262
|
|
|
119
|
-
<zn-
|
|
120
|
-
<zn-dialog class="dialog-basic" trigger="dialog-trigger" label="Dialog" size="small">
|
|
263
|
+
<zn-dialog class="dialog-programmatic" label="Programmatic Control">
|
|
121
264
|
<zn-icon src="info" slot="header-icon"></zn-icon>
|
|
122
|
-
This is
|
|
265
|
+
This dialog is controlled programmatically using JavaScript methods.
|
|
123
266
|
|
|
124
|
-
<zn-button color="secondary" slot="footer" dialog-closer>Close
|
|
125
|
-
<zn-button color="default" slot="footer">Do Something</zn-button>
|
|
267
|
+
<zn-button color="secondary" slot="footer" dialog-closer>Close</zn-button>
|
|
126
268
|
</zn-dialog>
|
|
127
269
|
|
|
128
|
-
<
|
|
129
|
-
|
|
270
|
+
<script type="module">
|
|
271
|
+
const dialog = document.querySelector('.dialog-programmatic');
|
|
272
|
+
const showButton = document.querySelector('.dialog-show');
|
|
273
|
+
const hideButton = document.querySelector('.dialog-hide');
|
|
274
|
+
const toggleButton = document.querySelector('.dialog-toggle');
|
|
275
|
+
|
|
276
|
+
showButton.addEventListener('click', () => dialog.show());
|
|
277
|
+
hideButton.addEventListener('click', () => dialog.hide());
|
|
278
|
+
toggleButton.addEventListener('click', () => {
|
|
279
|
+
if (dialog.open) {
|
|
280
|
+
dialog.hide();
|
|
281
|
+
} else {
|
|
282
|
+
dialog.show();
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
</script>
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### Listening to Events
|
|
289
|
+
|
|
290
|
+
The dialog emits several events that you can listen to: `zn-show` when opened, `zn-close` when closed, and `zn-request-close` when a close is requested.
|
|
291
|
+
|
|
292
|
+
```html:preview
|
|
293
|
+
<zn-button id="dialog-events-trigger">Open Dialog</zn-button>
|
|
294
|
+
<zn-dialog class="dialog-events" trigger="dialog-events-trigger" label="Dialog Events">
|
|
130
295
|
<zn-icon src="info" slot="header-icon"></zn-icon>
|
|
131
|
-
|
|
296
|
+
Open the browser console to see events logged as you interact with this dialog.
|
|
132
297
|
|
|
133
|
-
<zn-button color="secondary" slot="footer" dialog-closer>Close
|
|
134
|
-
|
|
298
|
+
<zn-button color="secondary" slot="footer" dialog-closer>Close</zn-button>
|
|
299
|
+
</zn-dialog>
|
|
300
|
+
|
|
301
|
+
<script type="module">
|
|
302
|
+
const dialog = document.querySelector('.dialog-events');
|
|
303
|
+
|
|
304
|
+
dialog.addEventListener('zn-show', () => {
|
|
305
|
+
console.log('Dialog opened');
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
dialog.addEventListener('zn-close', () => {
|
|
309
|
+
console.log('Dialog closed');
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
dialog.addEventListener('zn-request-close', (event) => {
|
|
313
|
+
console.log('Close requested from:', event.detail.source);
|
|
314
|
+
});
|
|
315
|
+
</script>
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
### Preventing Close
|
|
319
|
+
|
|
320
|
+
The `zn-request-close` event can be cancelled to prevent the dialog from closing. This is useful when you need to validate data or confirm an action before allowing the dialog to close.
|
|
321
|
+
|
|
322
|
+
:::warning
|
|
323
|
+
**Note:** Use this feature sparingly and only when closing the dialog would result in destructive behavior such as data loss. Preventing close can be frustrating for users if overused.
|
|
324
|
+
:::
|
|
325
|
+
|
|
326
|
+
```html:preview
|
|
327
|
+
<zn-button id="dialog-prevent-close-trigger">Open Dialog</zn-button>
|
|
328
|
+
<zn-dialog class="dialog-prevent-close" trigger="dialog-prevent-close-trigger" label="Unsaved Changes">
|
|
329
|
+
<zn-icon src="warning" slot="header-icon"></zn-icon>
|
|
330
|
+
<p>Try closing this dialog using the close button, clicking the overlay, or pressing Escape.</p>
|
|
331
|
+
<p>You'll need to click the "I'm Sure" button to actually close it.</p>
|
|
332
|
+
|
|
333
|
+
<zn-button color="warning" slot="footer" class="close-allowed">I'm Sure</zn-button>
|
|
135
334
|
</zn-dialog>
|
|
136
335
|
|
|
137
|
-
<
|
|
138
|
-
|
|
336
|
+
<script type="module">
|
|
337
|
+
const dialog = document.querySelector('.dialog-prevent-close');
|
|
338
|
+
const confirmButton = document.querySelector('.close-allowed');
|
|
339
|
+
|
|
340
|
+
// Prevent all close attempts
|
|
341
|
+
dialog.addEventListener('zn-request-close', (event) => {
|
|
342
|
+
event.preventDefault();
|
|
343
|
+
alert('Please click "I\'m Sure" to close this dialog.');
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
// Allow close when clicking the confirmation button
|
|
347
|
+
confirmButton.addEventListener('click', () => {
|
|
348
|
+
dialog.hide();
|
|
349
|
+
});
|
|
350
|
+
</script>
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
You can also prevent close from specific sources by checking the `event.detail.source` property.
|
|
354
|
+
|
|
355
|
+
```html:preview
|
|
356
|
+
<zn-button id="dialog-prevent-specific-trigger">Open Dialog</zn-button>
|
|
357
|
+
<zn-dialog class="dialog-prevent-specific" trigger="dialog-prevent-specific-trigger" label="Selective Close Prevention">
|
|
139
358
|
<zn-icon src="info" slot="header-icon"></zn-icon>
|
|
140
|
-
This
|
|
359
|
+
<p>This dialog prevents closing via the overlay or Escape key, but allows the close button to work.</p>
|
|
141
360
|
|
|
142
|
-
<zn-button color="secondary" slot="footer" dialog-closer>Close
|
|
143
|
-
|
|
361
|
+
<zn-button color="secondary" slot="footer" dialog-closer>Close</zn-button>
|
|
362
|
+
</zn-dialog>
|
|
363
|
+
|
|
364
|
+
<script type="module">
|
|
365
|
+
const dialog = document.querySelector('.dialog-prevent-specific');
|
|
366
|
+
|
|
367
|
+
dialog.addEventListener('zn-request-close', (event) => {
|
|
368
|
+
// Prevent close from overlay and keyboard, but allow close button
|
|
369
|
+
if (event.detail.source === 'overlay' || event.detail.source === 'keyboard') {
|
|
370
|
+
event.preventDefault();
|
|
371
|
+
alert('Please use the close button to dismiss this dialog.');
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
</script>
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
### Dialog Closer Attribute
|
|
378
|
+
|
|
379
|
+
Add the `dialog-closer` attribute to any element inside the dialog to make it close the dialog when clicked. This is commonly used with buttons in the footer.
|
|
380
|
+
|
|
381
|
+
```html:preview
|
|
382
|
+
<zn-button id="dialog-closer-trigger">Open Dialog</zn-button>
|
|
383
|
+
<zn-dialog trigger="dialog-closer-trigger" label="Dialog Closer">
|
|
384
|
+
<zn-icon src="info" slot="header-icon"></zn-icon>
|
|
385
|
+
<p>Any element with the dialog-closer attribute will close this dialog when clicked.</p>
|
|
386
|
+
|
|
387
|
+
<zn-button color="default" slot="footer">This Won't Close</zn-button>
|
|
388
|
+
<zn-button color="secondary" slot="footer" dialog-closer>This Will Close</zn-button>
|
|
389
|
+
</zn-dialog>
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
### Cosmic Effect
|
|
393
|
+
|
|
394
|
+
Add the `cosmic` attribute to apply a special visual effect to the dialog backdrop.
|
|
395
|
+
|
|
396
|
+
```html:preview
|
|
397
|
+
<zn-button id="dialog-cosmic-trigger">Open Cosmic Dialog</zn-button>
|
|
398
|
+
<zn-dialog trigger="dialog-cosmic-trigger" label="Cosmic Dialog" cosmic>
|
|
399
|
+
<zn-icon src="star" slot="header-icon"></zn-icon>
|
|
400
|
+
This dialog has the cosmic effect applied to the backdrop.
|
|
401
|
+
|
|
402
|
+
<zn-button color="secondary" slot="footer" dialog-closer>Close</zn-button>
|
|
403
|
+
</zn-dialog>
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
### Customizing Spacing
|
|
407
|
+
|
|
408
|
+
Use CSS custom properties to customize the padding in different areas of the dialog.
|
|
409
|
+
|
|
410
|
+
```html:preview
|
|
411
|
+
<zn-button id="dialog-spacing-trigger">Open Dialog</zn-button>
|
|
412
|
+
<zn-dialog
|
|
413
|
+
trigger="dialog-spacing-trigger"
|
|
414
|
+
label="Custom Spacing"
|
|
415
|
+
style="
|
|
416
|
+
--header-spacing: 2rem;
|
|
417
|
+
--body-spacing: 3rem;
|
|
418
|
+
--footer-spacing: 2rem;
|
|
419
|
+
">
|
|
420
|
+
<zn-icon src="info" slot="header-icon"></zn-icon>
|
|
421
|
+
This dialog has custom spacing applied using CSS properties.
|
|
422
|
+
|
|
423
|
+
<zn-button color="secondary" slot="footer" dialog-closer>Close</zn-button>
|
|
144
424
|
</zn-dialog>
|
|
145
425
|
```
|