@kubex/zinc 1.0.25 → 1.0.99
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 +13575 -8856
- package/dist/vscode.html-custom-data.json +583 -48
- package/dist/web-types.json +1441 -181
- package/dist/zn.d.ts +1645 -660
- package/dist/zn.min.css +1 -1
- package/dist/zn.min.js +1412 -893
- 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/item.md +18 -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 -19
- 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 +81 -22
- 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 +324 -5
- package/src/components/input/input.scss +87 -0
- 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 +24 -3
- package/src/components/item/item.scss +18 -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 -11
- 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 -44
- package/src/components/translations/translations.scss +4 -0
- 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
|
@@ -1,41 +1,809 @@
|
|
|
1
1
|
---
|
|
2
2
|
meta:
|
|
3
3
|
title: Inline Edit
|
|
4
|
-
description:
|
|
4
|
+
description: Inline edit allows users to edit content directly in place, switching between view and edit modes.
|
|
5
5
|
layout: component
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
+
Inline edit components provide a seamless way for users to edit content without leaving the current context or
|
|
9
|
+
navigating to a separate form. They display content normally and reveal input controls when the user clicks an edit
|
|
10
|
+
button or the content area itself.
|
|
11
|
+
|
|
8
12
|
```html:preview
|
|
13
|
+
<div class="form-spacing">
|
|
14
|
+
<zn-inline-edit name="title" value="Click edit to change this text" placeholder="Enter title"></zn-inline-edit>
|
|
9
15
|
|
|
10
|
-
<zn-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
<zn-inline-edit name="description" value="This example uses a textarea input type" input-type="textarea" placeholder="Enter description"></zn-inline-edit>
|
|
17
|
+
|
|
18
|
+
<zn-inline-edit
|
|
19
|
+
name="status"
|
|
20
|
+
value="active"
|
|
21
|
+
options='{"active": "Active", "inactive": "Inactive", "pending": "Pending"}'>
|
|
16
22
|
</zn-inline-edit>
|
|
17
|
-
|
|
18
|
-
</zn-sp>
|
|
23
|
+
</div>
|
|
19
24
|
```
|
|
20
25
|
|
|
26
|
+
:::tip
|
|
27
|
+
This component works with standard `<form>` elements. Please refer to the section
|
|
28
|
+
on [form controls](/getting-started/form-controls) to learn more about form submission and client-side validation.
|
|
29
|
+
:::
|
|
30
|
+
|
|
21
31
|
## Examples
|
|
22
32
|
|
|
23
|
-
###
|
|
33
|
+
### Basic Text Input
|
|
34
|
+
|
|
35
|
+
The default input type is text. Click the edit button to activate edit mode.
|
|
24
36
|
|
|
25
37
|
```html:preview
|
|
38
|
+
<div class="form-spacing">
|
|
39
|
+
<zn-inline-edit name="username" value="john.doe" placeholder="Enter username"></zn-inline-edit>
|
|
26
40
|
|
|
27
|
-
<zn-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
41
|
+
<zn-inline-edit name="email" value="john.doe@example.com" placeholder="Enter email"></zn-inline-edit>
|
|
42
|
+
</div>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Custom Edit Button Text
|
|
46
|
+
|
|
47
|
+
Use the `edit-text` attribute to customize the edit button text instead of showing the default edit icon.
|
|
48
|
+
|
|
49
|
+
```html:preview
|
|
50
|
+
<div class="form-spacing">
|
|
51
|
+
<zn-inline-edit name="title" value="Custom edit button" edit-text="Edit"></zn-inline-edit>
|
|
52
|
+
|
|
53
|
+
<zn-inline-edit name="description" value="Another example" edit-text="Modify"></zn-inline-edit>
|
|
54
|
+
</div>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Textarea Input Type
|
|
58
|
+
|
|
59
|
+
Use `input-type="textarea"` for multi-line text content.
|
|
60
|
+
|
|
61
|
+
```html:preview
|
|
62
|
+
<div class="form-spacing">
|
|
63
|
+
<zn-inline-edit
|
|
64
|
+
name="bio"
|
|
65
|
+
value="This is a longer piece of text that spans multiple lines. Click edit to modify this content in a textarea."
|
|
66
|
+
input-type="textarea"
|
|
67
|
+
placeholder="Enter your bio">
|
|
68
|
+
</zn-inline-edit>
|
|
69
|
+
|
|
70
|
+
<zn-inline-edit
|
|
71
|
+
name="notes"
|
|
72
|
+
value="Short note"
|
|
73
|
+
input-type="textarea"
|
|
74
|
+
edit-text="Edit notes">
|
|
75
|
+
</zn-inline-edit>
|
|
76
|
+
</div>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Number Input Type
|
|
80
|
+
|
|
81
|
+
Use `input-type="number"` for numeric values.
|
|
82
|
+
|
|
83
|
+
```html:preview
|
|
84
|
+
<div class="form-spacing">
|
|
85
|
+
<zn-inline-edit
|
|
86
|
+
name="quantity"
|
|
87
|
+
value="42"
|
|
88
|
+
input-type="number"
|
|
89
|
+
placeholder="Enter quantity">
|
|
90
|
+
</zn-inline-edit>
|
|
91
|
+
|
|
92
|
+
<zn-inline-edit
|
|
93
|
+
name="price"
|
|
94
|
+
value="99.99"
|
|
95
|
+
input-type="number"
|
|
96
|
+
edit-text="Edit price">
|
|
97
|
+
</zn-inline-edit>
|
|
98
|
+
</div>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Select Input with Options
|
|
102
|
+
|
|
103
|
+
Provide an `options` object to automatically create a select input. The object uses values as keys and labels as values.
|
|
104
|
+
|
|
105
|
+
```html:preview
|
|
106
|
+
<div class="form-spacing">
|
|
107
|
+
<zn-inline-edit
|
|
108
|
+
name="status"
|
|
109
|
+
value="active"
|
|
110
|
+
options='{"active": "Active", "inactive": "Inactive", "pending": "Pending", "archived": "Archived"}'>
|
|
111
|
+
</zn-inline-edit>
|
|
112
|
+
|
|
113
|
+
<zn-inline-edit
|
|
114
|
+
name="priority"
|
|
115
|
+
value="medium"
|
|
116
|
+
edit-text="Change"
|
|
117
|
+
options='{"low": "Low Priority", "medium": "Medium Priority", "high": "High Priority", "urgent": "Urgent"}'>
|
|
118
|
+
</zn-inline-edit>
|
|
119
|
+
</div>
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Searchable Select
|
|
123
|
+
|
|
124
|
+
Add the `search` attribute to enable filtering on select inputs. Users can type to narrow down the list of options.
|
|
125
|
+
|
|
126
|
+
```html:preview
|
|
127
|
+
<div class="form-spacing">
|
|
128
|
+
<zn-inline-edit
|
|
129
|
+
name="country"
|
|
130
|
+
value="us"
|
|
131
|
+
input-type="select"
|
|
132
|
+
search>
|
|
133
|
+
<zn-option value="au">Australia</zn-option>
|
|
134
|
+
<zn-option value="br">Brazil</zn-option>
|
|
135
|
+
<zn-option value="ca">Canada</zn-option>
|
|
136
|
+
<zn-option value="fr">France</zn-option>
|
|
137
|
+
<zn-option value="de">Germany</zn-option>
|
|
138
|
+
<zn-option value="in">India</zn-option>
|
|
139
|
+
<zn-option value="jp">Japan</zn-option>
|
|
140
|
+
<zn-option value="mx">Mexico</zn-option>
|
|
141
|
+
<zn-option value="uk">United Kingdom</zn-option>
|
|
142
|
+
<zn-option value="us">United States</zn-option>
|
|
143
|
+
</zn-inline-edit>
|
|
144
|
+
|
|
145
|
+
<zn-inline-edit
|
|
146
|
+
name="department"
|
|
147
|
+
value="engineering"
|
|
148
|
+
search
|
|
149
|
+
options='{"engineering": "Engineering", "design": "Design", "marketing": "Marketing", "sales": "Sales", "finance": "Finance", "hr": "Human Resources", "legal": "Legal", "operations": "Operations"}'>
|
|
150
|
+
</zn-inline-edit>
|
|
151
|
+
</div>
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Data Select with Provider
|
|
155
|
+
|
|
156
|
+
Use the `provider` attribute to integrate with data select providers like countries, currencies, or colors.
|
|
157
|
+
|
|
158
|
+
```html:preview
|
|
159
|
+
<div class="form-spacing">
|
|
160
|
+
<zn-inline-edit
|
|
161
|
+
name="country"
|
|
162
|
+
value="gb"
|
|
163
|
+
provider="country"
|
|
164
|
+
edit-text="Change country">
|
|
165
|
+
</zn-inline-edit>
|
|
166
|
+
|
|
167
|
+
<zn-inline-edit
|
|
168
|
+
name="currency"
|
|
169
|
+
value="usd"
|
|
170
|
+
provider="currency">
|
|
171
|
+
</zn-inline-edit>
|
|
172
|
+
|
|
173
|
+
<zn-inline-edit
|
|
174
|
+
name="color"
|
|
175
|
+
value="blue"
|
|
176
|
+
provider="color"
|
|
177
|
+
edit-text="Pick color">
|
|
178
|
+
</zn-inline-edit>
|
|
179
|
+
</div>
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Data Select with Icon Position
|
|
183
|
+
|
|
184
|
+
When using a data select provider, you can control the icon position with the `icon-position` attribute.
|
|
185
|
+
|
|
186
|
+
```html:preview
|
|
187
|
+
<div class="form-spacing">
|
|
188
|
+
<zn-inline-edit
|
|
189
|
+
name="country"
|
|
190
|
+
value="us"
|
|
191
|
+
provider="country"
|
|
192
|
+
icon-position="start">
|
|
193
|
+
</zn-inline-edit>
|
|
194
|
+
|
|
195
|
+
<zn-inline-edit
|
|
196
|
+
name="country2"
|
|
197
|
+
value="fr"
|
|
198
|
+
provider="country"
|
|
199
|
+
icon-position="end">
|
|
200
|
+
</zn-inline-edit>
|
|
201
|
+
</div>
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Help Text
|
|
205
|
+
|
|
206
|
+
Add descriptive help text to guide users with the `help-text` attribute. The help text appears below the input when in
|
|
207
|
+
edit mode.
|
|
208
|
+
|
|
209
|
+
```html:preview
|
|
210
|
+
<div class="form-spacing">
|
|
211
|
+
<zn-inline-edit
|
|
212
|
+
name="username"
|
|
213
|
+
value="john_doe"
|
|
214
|
+
help-text="Username must be lowercase with no spaces"
|
|
215
|
+
placeholder="Enter username">
|
|
216
|
+
</zn-inline-edit>
|
|
217
|
+
|
|
218
|
+
<zn-inline-edit
|
|
219
|
+
name="slug"
|
|
220
|
+
value="my-page-title"
|
|
221
|
+
help-text="Use hyphens to separate words"
|
|
222
|
+
input-type="text"
|
|
223
|
+
edit-text="Edit slug">
|
|
224
|
+
</zn-inline-edit>
|
|
225
|
+
</div>
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### Placeholders
|
|
229
|
+
|
|
230
|
+
Use the `placeholder` attribute to show placeholder text when the value is empty.
|
|
231
|
+
|
|
232
|
+
```html:preview
|
|
233
|
+
<div class="form-spacing">
|
|
234
|
+
<zn-inline-edit
|
|
235
|
+
name="title"
|
|
236
|
+
value=""
|
|
237
|
+
placeholder="Click edit to add a title">
|
|
238
|
+
</zn-inline-edit>
|
|
239
|
+
|
|
240
|
+
<zn-inline-edit
|
|
241
|
+
name="description"
|
|
242
|
+
value=""
|
|
243
|
+
input-type="textarea"
|
|
244
|
+
placeholder="Add a description..."
|
|
245
|
+
edit-text="Add">
|
|
246
|
+
</zn-inline-edit>
|
|
247
|
+
</div>
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### Required Fields
|
|
251
|
+
|
|
252
|
+
Use the `required` attribute to make the field required for form submission.
|
|
253
|
+
|
|
254
|
+
```html:preview
|
|
255
|
+
<form class="inline-edit-form">
|
|
256
|
+
<div class="form-spacing">
|
|
257
|
+
<zn-inline-edit
|
|
258
|
+
name="firstName"
|
|
259
|
+
value=""
|
|
260
|
+
required
|
|
261
|
+
placeholder="First name (required)"
|
|
262
|
+
help-text="This field is required">
|
|
263
|
+
</zn-inline-edit>
|
|
264
|
+
|
|
265
|
+
<zn-inline-edit
|
|
266
|
+
name="lastName"
|
|
267
|
+
value=""
|
|
268
|
+
required
|
|
269
|
+
placeholder="Last name (required)"
|
|
270
|
+
edit-text="Edit">
|
|
271
|
+
</zn-inline-edit>
|
|
272
|
+
|
|
273
|
+
<zn-button type="submit" variant="primary">Submit Form</zn-button>
|
|
274
|
+
</div>
|
|
275
|
+
</form>
|
|
276
|
+
|
|
277
|
+
<script type="module">
|
|
278
|
+
const form = document.querySelector('.inline-edit-form');
|
|
279
|
+
|
|
280
|
+
await customElements.whenDefined('zn-button');
|
|
281
|
+
await customElements.whenDefined('zn-inline-edit');
|
|
282
|
+
|
|
283
|
+
form.addEventListener('submit', (e) => {
|
|
284
|
+
e.preventDefault();
|
|
285
|
+
const formData = new FormData(form);
|
|
286
|
+
const data = Object.fromEntries(formData);
|
|
287
|
+
alert('Form submitted!\n\n' + JSON.stringify(data, null, 2));
|
|
288
|
+
});
|
|
289
|
+
</script>
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### Pattern Validation
|
|
293
|
+
|
|
294
|
+
Use the `pattern` attribute to validate input against a regular expression.
|
|
295
|
+
|
|
296
|
+
```html:preview
|
|
297
|
+
<form class="pattern-form">
|
|
298
|
+
<div class="form-spacing">
|
|
299
|
+
<zn-inline-edit
|
|
300
|
+
name="zipCode"
|
|
301
|
+
value="12345"
|
|
302
|
+
pattern="[0-9]{5}"
|
|
303
|
+
help-text="Must be a 5-digit ZIP code">
|
|
304
|
+
</zn-inline-edit>
|
|
305
|
+
|
|
306
|
+
<zn-inline-edit
|
|
307
|
+
name="productCode"
|
|
308
|
+
value="ABC-123"
|
|
309
|
+
pattern="[A-Z]{3}-[0-9]{3}"
|
|
310
|
+
help-text="Format: ABC-123"
|
|
311
|
+
edit-text="Edit">
|
|
312
|
+
</zn-inline-edit>
|
|
313
|
+
|
|
314
|
+
<zn-button type="submit" variant="primary">Validate</zn-button>
|
|
315
|
+
</div>
|
|
316
|
+
</form>
|
|
317
|
+
|
|
318
|
+
<script type="module">
|
|
319
|
+
const form = document.querySelector('.pattern-form');
|
|
320
|
+
|
|
321
|
+
await customElements.whenDefined('zn-button');
|
|
322
|
+
await customElements.whenDefined('zn-inline-edit');
|
|
323
|
+
|
|
324
|
+
form.addEventListener('submit', (e) => {
|
|
325
|
+
e.preventDefault();
|
|
326
|
+
if (form.checkValidity()) {
|
|
327
|
+
alert('All fields are valid!');
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
</script>
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
### Sizes
|
|
334
|
+
|
|
335
|
+
Use the `size` attribute to change the inline edit size. Available sizes are `small`, `medium` (default), and `large`.
|
|
336
|
+
|
|
337
|
+
```html:preview
|
|
338
|
+
<div class="form-spacing">
|
|
339
|
+
<zn-inline-edit
|
|
340
|
+
name="small"
|
|
341
|
+
value="Small size"
|
|
342
|
+
size="small">
|
|
343
|
+
</zn-inline-edit>
|
|
344
|
+
|
|
345
|
+
<zn-inline-edit
|
|
346
|
+
name="medium"
|
|
347
|
+
value="Medium size (default)"
|
|
348
|
+
size="medium">
|
|
349
|
+
</zn-inline-edit>
|
|
350
|
+
|
|
351
|
+
<zn-inline-edit
|
|
352
|
+
name="large"
|
|
353
|
+
value="Large size"
|
|
354
|
+
size="large">
|
|
355
|
+
</zn-inline-edit>
|
|
356
|
+
</div>
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
### Disabled State
|
|
360
|
+
|
|
361
|
+
Use the `disabled` attribute to disable the inline edit component.
|
|
362
|
+
|
|
363
|
+
```html:preview
|
|
364
|
+
<div class="form-spacing">
|
|
365
|
+
<zn-inline-edit
|
|
366
|
+
name="disabled1"
|
|
367
|
+
value="This field is disabled"
|
|
368
|
+
disabled>
|
|
369
|
+
</zn-inline-edit>
|
|
370
|
+
|
|
371
|
+
<zn-inline-edit
|
|
372
|
+
name="disabled2"
|
|
373
|
+
value="Cannot edit this"
|
|
374
|
+
disabled
|
|
375
|
+
edit-text="Edit">
|
|
376
|
+
</zn-inline-edit>
|
|
377
|
+
</div>
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
### Inline Layout
|
|
381
|
+
|
|
382
|
+
Use the `inline` attribute to display the inline edit component in a more compact, inline layout.
|
|
383
|
+
|
|
384
|
+
```html:preview
|
|
385
|
+
<div class="form-spacing">
|
|
386
|
+
<zn-inline-edit
|
|
387
|
+
name="title"
|
|
388
|
+
value="Inline layout example"
|
|
389
|
+
inline>
|
|
390
|
+
</zn-inline-edit>
|
|
391
|
+
|
|
392
|
+
<zn-inline-edit
|
|
393
|
+
name="status"
|
|
394
|
+
value="active"
|
|
395
|
+
inline
|
|
396
|
+
options='{"active": "Active", "inactive": "Inactive"}'>
|
|
397
|
+
</zn-inline-edit>
|
|
398
|
+
|
|
399
|
+
<zn-inline-edit
|
|
400
|
+
name="description"
|
|
401
|
+
value="Short description"
|
|
402
|
+
input-type="textarea"
|
|
403
|
+
inline
|
|
404
|
+
edit-text="Edit">
|
|
405
|
+
</zn-inline-edit>
|
|
406
|
+
</div>
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
### Padded Layout
|
|
410
|
+
|
|
411
|
+
Use the `padded` attribute to add padding around the component.
|
|
412
|
+
|
|
413
|
+
```html:preview
|
|
414
|
+
<div class="form-spacing">
|
|
415
|
+
<zn-inline-edit
|
|
416
|
+
name="padded1"
|
|
417
|
+
value="This has padding"
|
|
418
|
+
padded>
|
|
419
|
+
</zn-inline-edit>
|
|
420
|
+
|
|
421
|
+
<zn-inline-edit
|
|
422
|
+
name="padded2"
|
|
423
|
+
value="Another padded example"
|
|
424
|
+
padded
|
|
425
|
+
edit-text="Edit">
|
|
426
|
+
</zn-inline-edit>
|
|
427
|
+
</div>
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
### Text Direction
|
|
431
|
+
|
|
432
|
+
Use the `dir` attribute to control text direction. Useful for right-to-left languages.
|
|
433
|
+
|
|
434
|
+
```html:preview
|
|
435
|
+
<div class="form-spacing">
|
|
436
|
+
<zn-inline-edit
|
|
437
|
+
name="rtl"
|
|
438
|
+
value="مرحبا بك"
|
|
439
|
+
dir="rtl"
|
|
440
|
+
placeholder="أدخل النص">
|
|
441
|
+
</zn-inline-edit>
|
|
442
|
+
|
|
443
|
+
<zn-inline-edit
|
|
444
|
+
name="ltr"
|
|
445
|
+
value="Hello world"
|
|
446
|
+
dir="ltr"
|
|
447
|
+
placeholder="Enter text">
|
|
448
|
+
</zn-inline-edit>
|
|
449
|
+
</div>
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
### Form Integration
|
|
453
|
+
|
|
454
|
+
Inline edit components work seamlessly with standard HTML forms. Multiple inline edits can be used together in a form.
|
|
455
|
+
|
|
456
|
+
```html:preview
|
|
457
|
+
<form id="profile-form">
|
|
458
|
+
<div class="form-spacing">
|
|
459
|
+
<zn-inline-edit
|
|
460
|
+
name="fullName"
|
|
461
|
+
value="John Doe"
|
|
462
|
+
required
|
|
463
|
+
placeholder="Full name"
|
|
464
|
+
help-text="Your full legal name">
|
|
465
|
+
</zn-inline-edit>
|
|
466
|
+
|
|
467
|
+
<zn-inline-edit
|
|
468
|
+
name="jobTitle"
|
|
469
|
+
value="Senior Developer"
|
|
470
|
+
placeholder="Job title">
|
|
471
|
+
</zn-inline-edit>
|
|
472
|
+
|
|
473
|
+
<zn-inline-edit
|
|
474
|
+
name="department"
|
|
475
|
+
value="engineering"
|
|
476
|
+
options='{"engineering": "Engineering", "design": "Design", "marketing": "Marketing", "sales": "Sales"}'>
|
|
477
|
+
</zn-inline-edit>
|
|
478
|
+
|
|
479
|
+
<zn-inline-edit
|
|
480
|
+
name="location"
|
|
481
|
+
value="us"
|
|
482
|
+
provider="country"
|
|
483
|
+
icon-position="start">
|
|
484
|
+
</zn-inline-edit>
|
|
485
|
+
|
|
486
|
+
<zn-inline-edit
|
|
487
|
+
name="bio"
|
|
488
|
+
value="I love building great software and working with talented teams."
|
|
489
|
+
input-type="textarea"
|
|
490
|
+
placeholder="Short bio">
|
|
491
|
+
</zn-inline-edit>
|
|
492
|
+
|
|
493
|
+
<zn-button type="submit" variant="primary">Save Profile</zn-button>
|
|
494
|
+
<zn-button type="reset">Reset</zn-button>
|
|
495
|
+
</div>
|
|
496
|
+
</form>
|
|
497
|
+
|
|
498
|
+
<script type="module">
|
|
499
|
+
const form = document.getElementById('profile-form');
|
|
500
|
+
|
|
501
|
+
await customElements.whenDefined('zn-button');
|
|
502
|
+
await customElements.whenDefined('zn-inline-edit');
|
|
503
|
+
|
|
504
|
+
form.addEventListener('submit', (e) => {
|
|
505
|
+
e.preventDefault();
|
|
506
|
+
const formData = new FormData(form);
|
|
507
|
+
const data = Object.fromEntries(formData);
|
|
508
|
+
alert('Profile saved!\n\n' + JSON.stringify(data, null, 2));
|
|
509
|
+
});
|
|
510
|
+
</script>
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
### Keyboard Interactions
|
|
514
|
+
|
|
515
|
+
The inline edit component supports several keyboard interactions for better accessibility:
|
|
516
|
+
|
|
517
|
+
- **Enter** - When in edit mode (not textarea), submits the changes and exits edit mode
|
|
518
|
+
- **Shift + Enter** - In edit mode, allows Enter to be used for its normal purpose (like line breaks in textarea)
|
|
519
|
+
- **Escape** - Cancels editing and reverts to the original value
|
|
520
|
+
- **Click outside** - Commits changes and exits edit mode
|
|
521
|
+
|
|
522
|
+
```html:preview
|
|
523
|
+
<div class="form-spacing">
|
|
524
|
+
<p><strong>Try these keyboard shortcuts:</strong></p>
|
|
525
|
+
<ul style="margin-bottom: 1rem;">
|
|
526
|
+
<li>Click edit, then press <kbd>Enter</kbd> to save</li>
|
|
527
|
+
<li>Click edit, then press <kbd>Escape</kbd> to cancel</li>
|
|
528
|
+
<li>Click edit, make changes, then click outside to save</li>
|
|
529
|
+
</ul>
|
|
530
|
+
|
|
531
|
+
<zn-inline-edit
|
|
532
|
+
name="keyboardDemo"
|
|
533
|
+
value="Edit me and try the keyboard shortcuts"
|
|
534
|
+
help-text="Press Enter to save, Escape to cancel">
|
|
33
535
|
</zn-inline-edit>
|
|
34
|
-
|
|
536
|
+
|
|
537
|
+
<zn-inline-edit
|
|
538
|
+
name="textareaDemo"
|
|
539
|
+
value="For textareas, use Shift+Enter or click the check button to save"
|
|
540
|
+
input-type="textarea"
|
|
541
|
+
help-text="Enter adds new lines, use check button to save">
|
|
542
|
+
</zn-inline-edit>
|
|
543
|
+
</div>
|
|
35
544
|
```
|
|
36
545
|
|
|
37
|
-
###
|
|
546
|
+
### Events
|
|
547
|
+
|
|
548
|
+
The inline edit component emits several events you can listen to:
|
|
549
|
+
|
|
550
|
+
```html:preview
|
|
551
|
+
<div class="form-spacing">
|
|
552
|
+
<zn-inline-edit
|
|
553
|
+
id="event-example"
|
|
554
|
+
name="eventDemo"
|
|
555
|
+
value="Interact with this field to see events">
|
|
556
|
+
</zn-inline-edit>
|
|
557
|
+
|
|
558
|
+
<div style="margin-top: 1rem; padding: 1rem; background: var(--zn-color-neutral-100); border-radius: 4px;">
|
|
559
|
+
<strong>Event Log:</strong>
|
|
560
|
+
<div id="event-log" style="margin-top: 0.5rem; font-family: monospace; font-size: 0.875rem;"></div>
|
|
561
|
+
</div>
|
|
562
|
+
</div>
|
|
563
|
+
|
|
564
|
+
<script type="module">
|
|
565
|
+
const inlineEdit = document.getElementById('event-example');
|
|
566
|
+
const eventLog = document.getElementById('event-log');
|
|
38
567
|
|
|
39
|
-
|
|
568
|
+
await customElements.whenDefined('zn-inline-edit');
|
|
569
|
+
|
|
570
|
+
function logEvent(eventName, detail) {
|
|
571
|
+
const time = new Date().toLocaleTimeString();
|
|
572
|
+
const message = `[${time}] ${eventName}${detail ? ': ' + JSON.stringify(detail) : ''}`;
|
|
573
|
+
eventLog.innerHTML = message + '<br>' + eventLog.innerHTML;
|
|
574
|
+
const lines = eventLog.innerHTML.split('<br>');
|
|
575
|
+
if (lines.length > 5) {
|
|
576
|
+
eventLog.innerHTML = lines.slice(0, 5).join('<br>');
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
inlineEdit.addEventListener('zn-input', (e) => logEvent('zn-input'));
|
|
581
|
+
inlineEdit.addEventListener('zn-change', (e) => logEvent('zn-change', { value: e.target.value }));
|
|
582
|
+
inlineEdit.addEventListener('zn-submit', (e) => logEvent('zn-submit', { value: e.detail.value }));
|
|
583
|
+
inlineEdit.addEventListener('zn-blur', (e) => logEvent('zn-blur'));
|
|
584
|
+
</script>
|
|
585
|
+
```
|
|
40
586
|
|
|
587
|
+
### Practical Use Cases
|
|
588
|
+
|
|
589
|
+
#### Editable Profile Information
|
|
590
|
+
|
|
591
|
+
```html:preview
|
|
592
|
+
<div style="max-width: 600px; padding: 1.5rem; border: 1px solid var(--zn-color-neutral-200); border-radius: 8px;">
|
|
593
|
+
<h3 style="margin-top: 0;">User Profile</h3>
|
|
594
|
+
|
|
595
|
+
<form id="user-profile">
|
|
596
|
+
<div class="form-spacing">
|
|
597
|
+
<div style="display: grid; gap: 0.5rem;">
|
|
598
|
+
<div style="display: flex; gap: 1rem; align-items: center;">
|
|
599
|
+
<strong style="min-width: 120px;">Name:</strong>
|
|
600
|
+
<zn-inline-edit name="name" value="Sarah Johnson" inline></zn-inline-edit>
|
|
601
|
+
</div>
|
|
602
|
+
|
|
603
|
+
<div style="display: flex; gap: 1rem; align-items: center;">
|
|
604
|
+
<strong style="min-width: 120px;">Email:</strong>
|
|
605
|
+
<zn-inline-edit name="email" value="sarah.j@example.com" inline></zn-inline-edit>
|
|
606
|
+
</div>
|
|
607
|
+
|
|
608
|
+
<div style="display: flex; gap: 1rem; align-items: center;">
|
|
609
|
+
<strong style="min-width: 120px;">Role:</strong>
|
|
610
|
+
<zn-inline-edit
|
|
611
|
+
name="role"
|
|
612
|
+
value="developer"
|
|
613
|
+
inline
|
|
614
|
+
options='{"developer": "Developer", "designer": "Designer", "manager": "Manager", "admin": "Administrator"}'>
|
|
615
|
+
</zn-inline-edit>
|
|
616
|
+
</div>
|
|
617
|
+
|
|
618
|
+
<div style="display: flex; gap: 1rem; align-items: center;">
|
|
619
|
+
<strong style="min-width: 120px;">Country:</strong>
|
|
620
|
+
<zn-inline-edit
|
|
621
|
+
name="country"
|
|
622
|
+
value="us"
|
|
623
|
+
provider="country"
|
|
624
|
+
icon-position="start"
|
|
625
|
+
inline>
|
|
626
|
+
</zn-inline-edit>
|
|
627
|
+
</div>
|
|
628
|
+
</div>
|
|
629
|
+
</div>
|
|
630
|
+
</form>
|
|
631
|
+
</div>
|
|
632
|
+
```
|
|
633
|
+
|
|
634
|
+
#### Editable Table Cells
|
|
635
|
+
|
|
636
|
+
```html:preview
|
|
637
|
+
<table style="width: 100%; border-collapse: collapse;">
|
|
638
|
+
<thead>
|
|
639
|
+
<tr style="background: var(--zn-color-neutral-100); border-bottom: 2px solid var(--zn-color-neutral-300);">
|
|
640
|
+
<th style="padding: 0.75rem; text-align: left;">Product</th>
|
|
641
|
+
<th style="padding: 0.75rem; text-align: left;">Status</th>
|
|
642
|
+
<th style="padding: 0.75rem; text-align: left;">Quantity</th>
|
|
643
|
+
<th style="padding: 0.75rem; text-align: left;">Notes</th>
|
|
644
|
+
</tr>
|
|
645
|
+
</thead>
|
|
646
|
+
<tbody>
|
|
647
|
+
<tr style="border-bottom: 1px solid var(--zn-color-neutral-200);">
|
|
648
|
+
<td style="padding: 0.75rem;">
|
|
649
|
+
<zn-inline-edit name="product1" value="Widget A" inline></zn-inline-edit>
|
|
650
|
+
</td>
|
|
651
|
+
<td style="padding: 0.75rem;">
|
|
652
|
+
<zn-inline-edit
|
|
653
|
+
name="status1"
|
|
654
|
+
value="active"
|
|
655
|
+
inline
|
|
656
|
+
options='{"active": "Active", "inactive": "Inactive", "discontinued": "Discontinued"}'>
|
|
657
|
+
</zn-inline-edit>
|
|
658
|
+
</td>
|
|
659
|
+
<td style="padding: 0.75rem;">
|
|
660
|
+
<zn-inline-edit name="qty1" value="150" input-type="number" inline></zn-inline-edit>
|
|
661
|
+
</td>
|
|
662
|
+
<td style="padding: 0.75rem;">
|
|
663
|
+
<zn-inline-edit name="notes1" value="In stock" inline></zn-inline-edit>
|
|
664
|
+
</td>
|
|
665
|
+
</tr>
|
|
666
|
+
<tr style="border-bottom: 1px solid var(--zn-color-neutral-200);">
|
|
667
|
+
<td style="padding: 0.75rem;">
|
|
668
|
+
<zn-inline-edit name="product2" value="Widget B" inline></zn-inline-edit>
|
|
669
|
+
</td>
|
|
670
|
+
<td style="padding: 0.75rem;">
|
|
671
|
+
<zn-inline-edit
|
|
672
|
+
name="status2"
|
|
673
|
+
value="inactive"
|
|
674
|
+
inline
|
|
675
|
+
options='{"active": "Active", "inactive": "Inactive", "discontinued": "Discontinued"}'>
|
|
676
|
+
</zn-inline-edit>
|
|
677
|
+
</td>
|
|
678
|
+
<td style="padding: 0.75rem;">
|
|
679
|
+
<zn-inline-edit name="qty2" value="45" input-type="number" inline></zn-inline-edit>
|
|
680
|
+
</td>
|
|
681
|
+
<td style="padding: 0.75rem;">
|
|
682
|
+
<zn-inline-edit name="notes2" value="Low stock" inline></zn-inline-edit>
|
|
683
|
+
</td>
|
|
684
|
+
</tr>
|
|
685
|
+
</tbody>
|
|
686
|
+
</table>
|
|
687
|
+
```
|
|
41
688
|
|
|
689
|
+
#### Settings Panel
|
|
690
|
+
|
|
691
|
+
```html:preview
|
|
692
|
+
<div style="max-width: 700px; padding: 1.5rem; border: 1px solid var(--zn-color-neutral-200); border-radius: 8px; background: var(--zn-color-neutral-50);">
|
|
693
|
+
<h3 style="margin-top: 0;">Application Settings</h3>
|
|
694
|
+
|
|
695
|
+
<form id="settings-form">
|
|
696
|
+
<div class="form-spacing">
|
|
697
|
+
<div style="margin-bottom: 1.5rem;">
|
|
698
|
+
<h4 style="margin-bottom: 0.5rem;">General</h4>
|
|
699
|
+
<zn-inline-edit
|
|
700
|
+
name="appName"
|
|
701
|
+
value="My Application"
|
|
702
|
+
placeholder="Application name"
|
|
703
|
+
padded>
|
|
704
|
+
</zn-inline-edit>
|
|
705
|
+
|
|
706
|
+
<zn-inline-edit
|
|
707
|
+
name="tagline"
|
|
708
|
+
value="The best app for your needs"
|
|
709
|
+
placeholder="Tagline"
|
|
710
|
+
padded>
|
|
711
|
+
</zn-inline-edit>
|
|
712
|
+
</div>
|
|
713
|
+
|
|
714
|
+
<div style="margin-bottom: 1.5rem;">
|
|
715
|
+
<h4 style="margin-bottom: 0.5rem;">Localization</h4>
|
|
716
|
+
<zn-inline-edit
|
|
717
|
+
name="language"
|
|
718
|
+
value="en"
|
|
719
|
+
provider="country"
|
|
720
|
+
icon-position="start"
|
|
721
|
+
edit-text="Change"
|
|
722
|
+
padded>
|
|
723
|
+
</zn-inline-edit>
|
|
724
|
+
|
|
725
|
+
<zn-inline-edit
|
|
726
|
+
name="currency"
|
|
727
|
+
value="usd"
|
|
728
|
+
provider="currency"
|
|
729
|
+
icon-position="start"
|
|
730
|
+
padded>
|
|
731
|
+
</zn-inline-edit>
|
|
732
|
+
</div>
|
|
733
|
+
|
|
734
|
+
<div>
|
|
735
|
+
<h4 style="margin-bottom: 0.5rem;">Description</h4>
|
|
736
|
+
<zn-inline-edit
|
|
737
|
+
name="description"
|
|
738
|
+
value="A comprehensive solution for managing your business operations efficiently."
|
|
739
|
+
input-type="textarea"
|
|
740
|
+
placeholder="Enter a description"
|
|
741
|
+
edit-text="Edit"
|
|
742
|
+
padded>
|
|
743
|
+
</zn-inline-edit>
|
|
744
|
+
</div>
|
|
745
|
+
|
|
746
|
+
<zn-button type="submit" variant="primary" style="margin-top: 1rem;">Save Settings</zn-button>
|
|
747
|
+
</div>
|
|
748
|
+
</form>
|
|
749
|
+
</div>
|
|
750
|
+
|
|
751
|
+
<script type="module">
|
|
752
|
+
const form = document.getElementById('settings-form');
|
|
753
|
+
|
|
754
|
+
await customElements.whenDefined('zn-button');
|
|
755
|
+
await customElements.whenDefined('zn-inline-edit');
|
|
756
|
+
|
|
757
|
+
form.addEventListener('submit', (e) => {
|
|
758
|
+
e.preventDefault();
|
|
759
|
+
const formData = new FormData(form);
|
|
760
|
+
const data = Object.fromEntries(formData);
|
|
761
|
+
alert('Settings saved!\n\n' + JSON.stringify(data, null, 2));
|
|
762
|
+
});
|
|
763
|
+
</script>
|
|
764
|
+
```
|
|
765
|
+
|
|
766
|
+
### Programmatic Control
|
|
767
|
+
|
|
768
|
+
You can control the inline edit component programmatically using its methods:
|
|
769
|
+
|
|
770
|
+
```html:preview
|
|
771
|
+
<div class="form-spacing">
|
|
772
|
+
<zn-inline-edit
|
|
773
|
+
id="programmatic-demo"
|
|
774
|
+
name="demo"
|
|
775
|
+
value="Control me programmatically">
|
|
776
|
+
</zn-inline-edit>
|
|
777
|
+
|
|
778
|
+
<div style="margin-top: 1rem; display: flex; gap: 0.5rem; flex-wrap: wrap;">
|
|
779
|
+
<zn-button id="check-validity-btn" size="small">Check Validity</zn-button>
|
|
780
|
+
<zn-button id="set-value-btn" size="small">Set Value</zn-button>
|
|
781
|
+
<zn-button id="focus-btn" size="small">Focus</zn-button>
|
|
782
|
+
<zn-button id="get-value-btn" size="small">Get Value</zn-button>
|
|
783
|
+
</div>
|
|
784
|
+
</div>
|
|
785
|
+
|
|
786
|
+
<script type="module">
|
|
787
|
+
const inlineEdit = document.getElementById('programmatic-demo');
|
|
788
|
+
|
|
789
|
+
await customElements.whenDefined('zn-button');
|
|
790
|
+
await customElements.whenDefined('zn-inline-edit');
|
|
791
|
+
|
|
792
|
+
document.getElementById('check-validity-btn').addEventListener('click', () => {
|
|
793
|
+
const isValid = inlineEdit.checkValidity();
|
|
794
|
+
alert('Valid: ' + isValid);
|
|
795
|
+
});
|
|
796
|
+
|
|
797
|
+
document.getElementById('set-value-btn').addEventListener('click', () => {
|
|
798
|
+
inlineEdit.value = 'New value set at ' + new Date().toLocaleTimeString();
|
|
799
|
+
});
|
|
800
|
+
|
|
801
|
+
document.getElementById('focus-btn').addEventListener('click', () => {
|
|
802
|
+
inlineEdit.focus();
|
|
803
|
+
});
|
|
804
|
+
|
|
805
|
+
document.getElementById('get-value-btn').addEventListener('click', () => {
|
|
806
|
+
alert('Current value: ' + inlineEdit.value);
|
|
807
|
+
});
|
|
808
|
+
</script>
|
|
809
|
+
```
|