@kubex/zinc 1.0.25 → 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 +1406 -891
- 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 -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 +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 -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,54 +1,354 @@
|
|
|
1
1
|
---
|
|
2
2
|
meta:
|
|
3
3
|
title: Translations
|
|
4
|
-
description: A component for managing multi-language text input.
|
|
4
|
+
description: A component for managing multi-language text input with a tabbed interface.
|
|
5
5
|
layout: component
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
The Translations component
|
|
9
|
-
|
|
8
|
+
The Translations component provides a user-friendly interface for managing multi-language text input. It features a tabbed navigation bar for switching between languages and supports inline editing of translations.
|
|
9
|
+
|
|
10
|
+
```html:preview
|
|
11
|
+
<zn-translations
|
|
12
|
+
languages='{"en":"English","fr":"French","de":"German"}'
|
|
13
|
+
values='{"en":"Welcome","fr":"Bienvenue","de":"Willkommen"}'
|
|
14
|
+
></zn-translations>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Examples
|
|
18
|
+
|
|
19
|
+
### Basic Usage
|
|
20
|
+
|
|
21
|
+
A simple translations component with default English language.
|
|
10
22
|
|
|
11
23
|
```html:preview
|
|
12
24
|
<zn-translations></zn-translations>
|
|
13
25
|
```
|
|
14
26
|
|
|
15
|
-
|
|
27
|
+
### With Label
|
|
16
28
|
|
|
17
|
-
|
|
18
|
-
|-------------|----------|---------------------------------------------------------------------------------------------|
|
|
19
|
-
| `languages` | `Object` | A key-value pair of language codes and names (e.g., `{ "en": "English", "fr": "French" }`). |
|
|
20
|
-
| `values` | `Object` | A key-value pair of language codes and translations. |
|
|
21
|
-
| `value` | `String` | A JSON string representing the current translations. |
|
|
29
|
+
Use the `label` attribute to add a descriptive label above the translations.
|
|
22
30
|
|
|
23
|
-
|
|
31
|
+
```html:preview
|
|
32
|
+
<zn-translations
|
|
33
|
+
label="Product Description"
|
|
34
|
+
languages='{"en":"English","fr":"French"}'
|
|
35
|
+
></zn-translations>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Label Slot
|
|
39
|
+
|
|
40
|
+
Use the `label` slot for rich HTML content in the label.
|
|
41
|
+
|
|
42
|
+
```html:preview
|
|
43
|
+
<zn-translations languages='{"en":"English","fr":"French"}'>
|
|
44
|
+
<span slot="label">
|
|
45
|
+
<strong>Description</strong>
|
|
46
|
+
<zn-icon src="translate" size="16" style="margin-inline-start: 4px;"></zn-icon>
|
|
47
|
+
</span>
|
|
48
|
+
</zn-translations>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Custom Languages
|
|
52
|
+
|
|
53
|
+
Provide a custom list of available languages via the `languages` property. Languages are displayed as tabs with their full names.
|
|
54
|
+
|
|
55
|
+
```html:preview
|
|
56
|
+
<zn-translations
|
|
57
|
+
label="Multi-Language Content"
|
|
58
|
+
languages='{"en":"English","fr":"French","de":"German","es":"Spanish","it":"Italian","pt":"Portuguese"}'
|
|
59
|
+
></zn-translations>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Pre-filled Values
|
|
63
|
+
|
|
64
|
+
Set initial translations using the `values` property.
|
|
65
|
+
|
|
66
|
+
```html:preview
|
|
67
|
+
<zn-translations
|
|
68
|
+
label="Welcome Message"
|
|
69
|
+
languages='{"en":"English","fr":"French","es":"Spanish"}'
|
|
70
|
+
values='{"en":"Hello World","fr":"Bonjour le monde","es":"Hola Mundo"}'
|
|
71
|
+
></zn-translations>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### JSON Value Attribute
|
|
24
75
|
|
|
25
|
-
|
|
76
|
+
Alternatively, use the `value` attribute with a JSON string.
|
|
26
77
|
|
|
27
78
|
```html:preview
|
|
79
|
+
<zn-translations
|
|
80
|
+
label="Description"
|
|
81
|
+
languages='{"en":"English","fr":"French"}'
|
|
82
|
+
value='{"en":"This is a product description","fr":"Ceci est une description de produit"}'
|
|
83
|
+
></zn-translations>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Required Field
|
|
87
|
+
|
|
88
|
+
Mark the translations as required for form validation.
|
|
89
|
+
|
|
90
|
+
```html:preview
|
|
91
|
+
<form>
|
|
92
|
+
<zn-translations
|
|
93
|
+
name="description"
|
|
94
|
+
label="Product Description"
|
|
95
|
+
required
|
|
96
|
+
languages='{"en":"English","fr":"French"}'
|
|
97
|
+
></zn-translations>
|
|
98
|
+
<br />
|
|
99
|
+
<zn-button type="submit" color="success">Submit</zn-button>
|
|
100
|
+
</form>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Disabled State
|
|
104
|
+
|
|
105
|
+
Disable editing of translations.
|
|
106
|
+
|
|
107
|
+
```html:preview
|
|
108
|
+
<zn-translations
|
|
109
|
+
label="System Message (Read-only)"
|
|
110
|
+
disabled
|
|
111
|
+
languages='{"en":"English","fr":"French"}'
|
|
112
|
+
values='{"en":"This cannot be edited","fr":"Cela ne peut pas être modifié"}'
|
|
113
|
+
></zn-translations>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Flush Layout
|
|
117
|
+
|
|
118
|
+
Remove padding for a more compact appearance.
|
|
119
|
+
|
|
120
|
+
```html:preview
|
|
121
|
+
<zn-translations
|
|
122
|
+
flush
|
|
123
|
+
languages='{"en":"English","fr":"French","de":"German"}'
|
|
124
|
+
values='{"en":"Compact layout","fr":"Mise en page compacte","de":"Kompaktes Layout"}'
|
|
125
|
+
></zn-translations>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### With Custom Action Button
|
|
129
|
+
|
|
130
|
+
Use the `expand` slot to add custom buttons or actions.
|
|
28
131
|
|
|
132
|
+
```html:preview
|
|
29
133
|
<zn-translations
|
|
30
134
|
label="Description"
|
|
31
|
-
languages='{
|
|
32
|
-
<zn-button slot="expand" size="x-small" color="transparent" icon="translate"
|
|
135
|
+
languages='{"en":"English","fr":"French","de":"German"}'>
|
|
136
|
+
<zn-button slot="expand" size="x-small" color="transparent" icon="translate">
|
|
137
|
+
Auto-Translate
|
|
138
|
+
</zn-button>
|
|
33
139
|
</zn-translations>
|
|
34
140
|
```
|
|
35
141
|
|
|
36
|
-
###
|
|
142
|
+
### Many Languages
|
|
37
143
|
|
|
38
|
-
|
|
144
|
+
The component handles many languages gracefully with scrollable tabs.
|
|
39
145
|
|
|
40
146
|
```html:preview
|
|
147
|
+
<zn-translations
|
|
148
|
+
label="International Content"
|
|
149
|
+
languages='{"en":"English","fr":"French","de":"German","es":"Spanish","it":"Italian","pt":"Portuguese","ru":"Russian","zh":"Chinese","ja":"Japanese","ar":"Arabic","hi":"Hindi","ko":"Korean"}'
|
|
150
|
+
values='{"en":"Hello","fr":"Bonjour","de":"Hallo","es":"Hola","it":"Ciao","pt":"Olá","ru":"Привет","zh":"你好","ja":"こんにちは","ar":"مرحبا","hi":"नमस्ते","ko":"안녕하세요"}'
|
|
151
|
+
></zn-translations>
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### RTL Language Support
|
|
41
155
|
|
|
156
|
+
The component automatically detects and applies right-to-left text direction for Arabic and Hebrew languages.
|
|
157
|
+
|
|
158
|
+
```html:preview
|
|
42
159
|
<zn-translations
|
|
43
|
-
|
|
160
|
+
label="RTL Languages"
|
|
161
|
+
languages='{"en":"English","ar":"Arabic","he":"Hebrew"}'
|
|
162
|
+
values='{"en":"Hello World","ar":"مرحبا بالعالم","he":"שלום עולם"}'
|
|
163
|
+
></zn-translations>
|
|
44
164
|
```
|
|
45
165
|
|
|
46
|
-
###
|
|
166
|
+
### Listening to Changes
|
|
167
|
+
|
|
168
|
+
The component emits `zn-change` events when translation values change.
|
|
47
169
|
|
|
48
170
|
```html:preview
|
|
171
|
+
<zn-translations
|
|
172
|
+
id="trans-events"
|
|
173
|
+
label="Translation Input"
|
|
174
|
+
languages='{"en":"English","fr":"French"}'
|
|
175
|
+
></zn-translations>
|
|
176
|
+
|
|
177
|
+
<div style="margin-top: 1rem; padding: 1rem; background: var(--zn-color-neutral-50); border-radius: 4px;">
|
|
178
|
+
<strong>Event Log:</strong>
|
|
179
|
+
<div id="event-log-trans" style="margin-top: 0.5rem; font-family: monospace; font-size: 0.875rem;"></div>
|
|
180
|
+
</div>
|
|
181
|
+
|
|
182
|
+
<script type="module">
|
|
183
|
+
const translations = document.getElementById('trans-events');
|
|
184
|
+
const eventLog = document.getElementById('event-log-trans');
|
|
185
|
+
|
|
186
|
+
translations.addEventListener('zn-change', (event) => {
|
|
187
|
+
const timestamp = new Date().toLocaleTimeString();
|
|
188
|
+
const value = JSON.parse(event.target.value);
|
|
189
|
+
eventLog.innerHTML = `[${timestamp}] Translation changed: ${JSON.stringify(value, null, 2)}`;
|
|
190
|
+
});
|
|
191
|
+
</script>
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Form Integration
|
|
195
|
+
|
|
196
|
+
Use with standard HTML forms for submission.
|
|
197
|
+
|
|
198
|
+
```html:preview
|
|
199
|
+
<form class="translations-form">
|
|
200
|
+
<zn-translations
|
|
201
|
+
name="content"
|
|
202
|
+
label="Article Content"
|
|
203
|
+
required
|
|
204
|
+
languages='{"en":"English","fr":"French","de":"German"}'
|
|
205
|
+
></zn-translations>
|
|
206
|
+
<br />
|
|
207
|
+
<zn-button type="submit" color="success">Submit Translations</zn-button>
|
|
208
|
+
</form>
|
|
209
|
+
|
|
210
|
+
<script type="module">
|
|
211
|
+
const form = document.querySelector('.translations-form');
|
|
212
|
+
|
|
213
|
+
await customElements.whenDefined('zn-translations');
|
|
214
|
+
|
|
215
|
+
form.addEventListener('submit', (e) => {
|
|
216
|
+
e.preventDefault();
|
|
217
|
+
const formData = new FormData(form);
|
|
218
|
+
const data = Object.fromEntries(formData);
|
|
219
|
+
alert('Form submitted!\n\n' + JSON.stringify(data, null, 2));
|
|
220
|
+
});
|
|
221
|
+
</script>
|
|
222
|
+
```
|
|
49
223
|
|
|
224
|
+
### Programmatic Control
|
|
225
|
+
|
|
226
|
+
Access and modify translation values via JavaScript.
|
|
227
|
+
|
|
228
|
+
```html:preview
|
|
50
229
|
<zn-translations
|
|
51
|
-
|
|
52
|
-
|
|
230
|
+
id="prog-trans"
|
|
231
|
+
label="Programmatic Translations"
|
|
232
|
+
languages='{"en":"English","fr":"French","es":"Spanish"}'
|
|
53
233
|
></zn-translations>
|
|
234
|
+
|
|
235
|
+
<div style="margin-top: 1rem;">
|
|
236
|
+
<zn-button id="set-values-btn" size="small">Set Sample Values</zn-button>
|
|
237
|
+
<zn-button id="get-values-btn" size="small" color="info">Get Values</zn-button>
|
|
238
|
+
<zn-button id="clear-values-btn" size="small" color="secondary">Clear All</zn-button>
|
|
239
|
+
</div>
|
|
240
|
+
|
|
241
|
+
<script type="module">
|
|
242
|
+
const trans = document.getElementById('prog-trans');
|
|
243
|
+
|
|
244
|
+
document.getElementById('set-values-btn').addEventListener('click', () => {
|
|
245
|
+
trans.values = {
|
|
246
|
+
en: 'Sample English text',
|
|
247
|
+
fr: 'Exemple de texte français',
|
|
248
|
+
es: 'Texto de muestra en español'
|
|
249
|
+
};
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
document.getElementById('get-values-btn').addEventListener('click', () => {
|
|
253
|
+
alert('Current values:\n\n' + JSON.stringify(trans.values, null, 2));
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
document.getElementById('clear-values-btn').addEventListener('click', () => {
|
|
257
|
+
trans.values = { en: '', fr: '', es: '' };
|
|
258
|
+
});
|
|
259
|
+
</script>
|
|
54
260
|
```
|
|
261
|
+
|
|
262
|
+
### Real-World Use Case: Content Management
|
|
263
|
+
|
|
264
|
+
A complete example showing product content management with translations.
|
|
265
|
+
|
|
266
|
+
```html:preview
|
|
267
|
+
<div style="max-width: 800px;">
|
|
268
|
+
<zn-panel caption="Product Details" icon="inventory_2">
|
|
269
|
+
<div style="display: flex; flex-direction: column; gap: 1rem;">
|
|
270
|
+
<zn-input
|
|
271
|
+
label="Product SKU"
|
|
272
|
+
value="PROD-12345"
|
|
273
|
+
readonly
|
|
274
|
+
></zn-input>
|
|
275
|
+
|
|
276
|
+
<zn-translations
|
|
277
|
+
name="name"
|
|
278
|
+
label="Product Name"
|
|
279
|
+
required
|
|
280
|
+
languages='{"en":"English","fr":"French","de":"German","es":"Spanish"}'
|
|
281
|
+
values='{"en":"Premium Wireless Headphones","fr":"Écouteurs sans fil premium","de":"Premium kabellose Kopfhörer","es":"Auriculares inalámbricos premium"}'
|
|
282
|
+
></zn-translations>
|
|
283
|
+
|
|
284
|
+
<zn-translations
|
|
285
|
+
name="description"
|
|
286
|
+
label="Product Description"
|
|
287
|
+
languages='{"en":"English","fr":"French","de":"German","es":"Spanish"}'
|
|
288
|
+
values='{"en":"High-quality wireless headphones with active noise cancellation","fr":"Écouteurs sans fil de haute qualité avec suppression active du bruit","de":"Hochwertige kabellose Kopfhörer mit aktiver Geräuschunterdrückung","es":"Auriculares inalámbricos de alta calidad con cancelación activa de ruido"}'
|
|
289
|
+
>
|
|
290
|
+
<zn-button slot="expand" size="x-small" color="transparent" icon="smart_toy">
|
|
291
|
+
AI Translate
|
|
292
|
+
</zn-button>
|
|
293
|
+
</zn-translations>
|
|
294
|
+
|
|
295
|
+
<zn-input
|
|
296
|
+
label="Price"
|
|
297
|
+
type="currency"
|
|
298
|
+
value="299.99"
|
|
299
|
+
></zn-input>
|
|
300
|
+
</div>
|
|
301
|
+
|
|
302
|
+
<div slot="footer" style="display: flex; gap: 0.5rem; justify-content: flex-end;">
|
|
303
|
+
<zn-button color="secondary">Cancel</zn-button>
|
|
304
|
+
<zn-button color="success">Save Product</zn-button>
|
|
305
|
+
</div>
|
|
306
|
+
</zn-panel>
|
|
307
|
+
</div>
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
## Properties
|
|
311
|
+
|
|
312
|
+
| Property | Type | Default | Description |
|
|
313
|
+
|-------------|-----------------------------|-----------------|----------------------------------------------------------------------|
|
|
314
|
+
| `name` | `string` | `''` | Form field name for submission |
|
|
315
|
+
| `value` | `string` | `'{"en":""}'` | JSON string of translations |
|
|
316
|
+
| `label` | `string` | `''` | Label displayed above the component |
|
|
317
|
+
| `disabled` | `boolean` | `false` | Disables editing of all translations |
|
|
318
|
+
| `required` | `boolean` | `false` | Makes the field required for form validation |
|
|
319
|
+
| `flush` | `boolean` | `false` | Removes padding for compact layout |
|
|
320
|
+
| `languages` | `Record<string, string>` | `{en: "EN"}` | Object mapping language codes to display names |
|
|
321
|
+
| `values` | `Record<string, string>` | `{}` | Object mapping language codes to translation text |
|
|
322
|
+
|
|
323
|
+
## Events
|
|
324
|
+
|
|
325
|
+
| Event | Description | Event Detail |
|
|
326
|
+
|-------------|----------------------------------------------------------|---------------------------|
|
|
327
|
+
| `zn-change` | Emitted when any translation value changes | `{value: string}` |
|
|
328
|
+
| `zn-input` | Emitted when translation input changes | None |
|
|
329
|
+
|
|
330
|
+
## Slots
|
|
331
|
+
|
|
332
|
+
| Slot | Description |
|
|
333
|
+
|-----------|------------------------------------------------------------------|
|
|
334
|
+
| `label` | Alternative to the `label` attribute for rich HTML content |
|
|
335
|
+
| `expand` | Action button displayed in the navbar (e.g., translate button) |
|
|
336
|
+
|
|
337
|
+
## Methods
|
|
338
|
+
|
|
339
|
+
| Method | Description |
|
|
340
|
+
|-------------------------------|------------------------------------------|
|
|
341
|
+
| `checkValidity()` | Checks form validity |
|
|
342
|
+
| `reportValidity()` | Checks validity and shows message |
|
|
343
|
+
| `setCustomValidity(message)` | Sets custom validation message |
|
|
344
|
+
| `getForm()` | Returns the parent form element |
|
|
345
|
+
|
|
346
|
+
## CSS Parts
|
|
347
|
+
|
|
348
|
+
The component uses `zn-navbar` and `zn-inline-edit` internally, which expose their own CSS parts for advanced styling.
|
|
349
|
+
|
|
350
|
+
## Accessibility
|
|
351
|
+
|
|
352
|
+
- The component automatically detects RTL languages (Arabic, Hebrew) and applies proper text direction
|
|
353
|
+
- Keyboard navigation is supported within the inline edit fields
|
|
354
|
+
- Form integration ensures proper submission behavior with the Enter key
|