@kubex/zinc 1.0.100 → 1.0.102
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/custom-elements.json +21 -4
- package/dist/vscode.html-custom-data.json +9 -0
- package/dist/web-types.json +12 -1
- package/dist/zn.d.ts +11 -4
- package/dist/zn.min.js +625 -603
- package/package.json +1 -1
- package/src/components/data-select/providers/currency-data-provider.ts +1 -0
- package/src/components/translation-group/translation-group.component.ts +1 -0
- package/src/components/translations/translations.component.ts +61 -41
- package/src/components/translations/translations.scss +23 -24
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@ import type {DataProviderOption, LocalDataProvider} from "./provider";
|
|
|
2
2
|
|
|
3
3
|
const currencyCodeToName: { [key: string]: string } = {
|
|
4
4
|
'ALL': 'Albania Lek',
|
|
5
|
+
'AED': 'United Arab Emirates Dirham',
|
|
5
6
|
'AFN': 'Afghanistan Afghani',
|
|
6
7
|
'ARS': 'Argentina Peso',
|
|
7
8
|
'AWG': 'Aruba Guilder',
|
|
@@ -149,6 +149,7 @@ export default class ZnTranslationGroup extends ZnPanel {
|
|
|
149
149
|
<div class="${classMap({
|
|
150
150
|
panel: true,
|
|
151
151
|
'panel--flush': this.flush,
|
|
152
|
+
'panel--transparent': this.transparent,
|
|
152
153
|
'panel--has-header': hasHeader,
|
|
153
154
|
'panel--has-actions': hasMultipleLanguages || hasActionSlot,
|
|
154
155
|
'panel--has-footer': hasFooterSlot,
|
|
@@ -6,26 +6,31 @@ import {keyed} from 'lit/directives/keyed.js';
|
|
|
6
6
|
import {live} from 'lit/directives/live.js';
|
|
7
7
|
import {property, state} from 'lit/decorators.js';
|
|
8
8
|
import ZincElement from '../../internal/zinc-element';
|
|
9
|
+
import ZnButton from '../button';
|
|
10
|
+
import ZnButtonGroup from '../button-group';
|
|
11
|
+
import ZnDropdown from '../dropdown';
|
|
9
12
|
import ZnInlineEdit from '../inline-edit';
|
|
10
13
|
import ZnInput from '../input';
|
|
11
|
-
import
|
|
14
|
+
import ZnMenu from '../menu';
|
|
12
15
|
import type {PropertyValues} from 'lit';
|
|
13
16
|
import type {ZincFormControl} from '../../internal/zinc-element';
|
|
14
17
|
import type {ZnMenuSelectEvent} from '../../events/zn-menu-select';
|
|
15
|
-
import type {ZnSelectEvent} from "../../events/zn-select";
|
|
16
18
|
|
|
17
19
|
import styles from './translations.scss';
|
|
18
20
|
|
|
19
21
|
export default class ZnTranslations extends ZincElement implements ZincFormControl {
|
|
20
22
|
static styles = unsafeCSS(styles);
|
|
21
23
|
static dependencies = {
|
|
22
|
-
'zn-
|
|
24
|
+
'zn-button': ZnButton,
|
|
25
|
+
'zn-button-group': ZnButtonGroup,
|
|
26
|
+
'zn-dropdown': ZnDropdown,
|
|
27
|
+
'zn-inline-edit': ZnInlineEdit,
|
|
23
28
|
'zn-input': ZnInput,
|
|
24
|
-
'zn-
|
|
29
|
+
'zn-menu': ZnMenu
|
|
25
30
|
};
|
|
26
31
|
|
|
27
32
|
private readonly formControlController: FormControlController = new FormControlController(this);
|
|
28
|
-
private readonly hasSlotController = new HasSlotController(this, 'label');
|
|
33
|
+
private readonly hasSlotController = new HasSlotController(this, 'label', 'expand');
|
|
29
34
|
|
|
30
35
|
@property() name = '';
|
|
31
36
|
@property() value = '{"en":""}';
|
|
@@ -33,6 +38,7 @@ export default class ZnTranslations extends ZincElement implements ZincFormContr
|
|
|
33
38
|
@property({type: Boolean, reflect: true}) disabled = false;
|
|
34
39
|
@property({type: Boolean, reflect: true}) required = false;
|
|
35
40
|
@property({type: Boolean, reflect: true}) flush = false;
|
|
41
|
+
@property({attribute: "input-type"}) inputType: 'select' | 'text' | 'number' | 'textarea' = 'text';
|
|
36
42
|
|
|
37
43
|
/** When true, hides the individual language navbar and defers language control to a parent zn-translation-group. */
|
|
38
44
|
@property({type: Boolean, reflect: true}) grouped = false;
|
|
@@ -147,6 +153,7 @@ export default class ZnTranslations extends ZincElement implements ZincFormContr
|
|
|
147
153
|
}
|
|
148
154
|
|
|
149
155
|
private handleLanguageAdd = (e: ZnMenuSelectEvent) => {
|
|
156
|
+
e.stopPropagation();
|
|
150
157
|
const element = e.detail.element as HTMLElement;
|
|
151
158
|
const languageCode = element.getAttribute('data-path');
|
|
152
159
|
if (languageCode) {
|
|
@@ -157,16 +164,9 @@ export default class ZnTranslations extends ZincElement implements ZincFormContr
|
|
|
157
164
|
}
|
|
158
165
|
};
|
|
159
166
|
|
|
160
|
-
private
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
if (li) {
|
|
164
|
-
const tab = li.getAttribute('tab') || li.getAttribute('data-tab');
|
|
165
|
-
if (tab) {
|
|
166
|
-
this._activeLanguage = tab;
|
|
167
|
-
this.requestUpdate();
|
|
168
|
-
}
|
|
169
|
-
}
|
|
167
|
+
private switchLanguage = (lang: string) => {
|
|
168
|
+
this._activeLanguage = lang;
|
|
169
|
+
this.requestUpdate();
|
|
170
170
|
};
|
|
171
171
|
|
|
172
172
|
private handleValueUpdate = (e: CustomEvent) => {
|
|
@@ -223,50 +223,70 @@ export default class ZnTranslations extends ZincElement implements ZincFormContr
|
|
|
223
223
|
visibleTabs.unshift('en');
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
-
const navigation = visibleTabs.map(code => ({
|
|
227
|
-
title: code.toUpperCase(),
|
|
228
|
-
active: code === this._activeLanguage,
|
|
229
|
-
tab: code
|
|
230
|
-
}));
|
|
231
|
-
|
|
232
226
|
const currentTranslation = this.values[this._activeLanguage] ?? '';
|
|
233
227
|
const isRTL = this.isRTLLanguage(this._activeLanguage);
|
|
234
228
|
|
|
235
229
|
const hasLabelSlot = this.hasSlotController.test('label');
|
|
236
230
|
const hasLabel = this.label ? true : hasLabelSlot;
|
|
231
|
+
const hasExpandSlot = this.hasSlotController.test('expand');
|
|
232
|
+
const hasMultipleLanguages = Object.keys(this.languages).length > 1;
|
|
233
|
+
const showActions = !this.grouped && (hasMultipleLanguages || hasExpandSlot);
|
|
237
234
|
|
|
238
235
|
return html`
|
|
239
236
|
<div part="form-control"
|
|
240
237
|
class="${classMap({
|
|
241
238
|
'translations': true,
|
|
242
239
|
'translations--grouped': this.grouped,
|
|
240
|
+
'translations--flush': this.flush,
|
|
243
241
|
'form-control': true,
|
|
244
242
|
'form-control--medium': true,
|
|
245
243
|
'form-control--has-label': hasLabel,
|
|
246
244
|
})}"
|
|
247
245
|
@keydown="${this.handleKeyDown}">
|
|
248
|
-
<
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
246
|
+
<div class="translations__header">
|
|
247
|
+
<label part="form-control-label" class="form-control__label" for="input"
|
|
248
|
+
aria-hidden=${hasLabel ? 'false' : 'true'}>
|
|
249
|
+
<slot name="label">${this.label}</slot>
|
|
250
|
+
</label>
|
|
251
|
+
${showActions ? html`
|
|
252
|
+
<div class="translations__actions">
|
|
253
|
+
${hasExpandSlot ? html`<slot name="expand"></slot>` : nothing}
|
|
254
|
+
${hasMultipleLanguages ? html`
|
|
255
|
+
<zn-button-group>
|
|
256
|
+
${visibleTabs.map(code => html`
|
|
257
|
+
<zn-button
|
|
258
|
+
size="x-small"
|
|
259
|
+
color="default"
|
|
260
|
+
?outline="${code !== this._activeLanguage}"
|
|
261
|
+
@click="${() => this.switchLanguage(code)}"
|
|
262
|
+
>${code.toUpperCase()}
|
|
263
|
+
</zn-button>
|
|
264
|
+
`)}
|
|
265
|
+
${availableLanguages.length > 0 ? html`
|
|
266
|
+
<zn-dropdown placement="bottom-end">
|
|
267
|
+
<zn-button
|
|
268
|
+
slot="trigger"
|
|
269
|
+
size="x-small"
|
|
270
|
+
color="default"
|
|
271
|
+
outline
|
|
272
|
+
>+
|
|
273
|
+
</zn-button>
|
|
274
|
+
<zn-menu
|
|
275
|
+
.actions=${availableLanguages}
|
|
276
|
+
@zn-menu-select="${this.handleLanguageAdd}"
|
|
277
|
+
></zn-menu>
|
|
278
|
+
</zn-dropdown>
|
|
279
|
+
` : nothing}
|
|
280
|
+
</zn-button-group>
|
|
281
|
+
` : nothing}
|
|
282
|
+
</div>
|
|
283
|
+
` : nothing}
|
|
284
|
+
</div>
|
|
285
|
+
|
|
286
|
+
<div part="form-control-input" class="translations__body">
|
|
268
287
|
${keyed(this._activeLanguage, html`
|
|
269
288
|
<zn-inline-edit
|
|
289
|
+
input-type=${this.inputType}
|
|
270
290
|
.value=${live(currentTranslation)}
|
|
271
291
|
name="${this.name}"
|
|
272
292
|
placeholder="Enter translation..."
|
|
@@ -5,41 +5,40 @@
|
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
.translations {
|
|
8
|
+
padding: var(--zn-spacing-small) var(--zn-spacing-medium);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.translations__header {
|
|
8
12
|
display: flex;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
gap: var(--zn-spacing-
|
|
13
|
+
align-items: center;
|
|
14
|
+
justify-content: space-between;
|
|
15
|
+
gap: var(--zn-spacing-small);
|
|
16
|
+
margin-bottom: var(--zn-spacing-2x-small);
|
|
17
|
+
min-height: var(--zn-input-height-small);
|
|
12
18
|
}
|
|
13
19
|
|
|
14
|
-
.
|
|
15
|
-
|
|
20
|
+
.translations__actions {
|
|
21
|
+
display: flex;
|
|
22
|
+
align-items: center;
|
|
23
|
+
gap: var(--zn-spacing-x-small);
|
|
24
|
+
margin-left: auto;
|
|
16
25
|
}
|
|
17
26
|
|
|
18
|
-
.
|
|
19
|
-
|
|
27
|
+
.translations__body {
|
|
28
|
+
display: block;
|
|
20
29
|
}
|
|
21
30
|
|
|
22
31
|
.form-control__label {
|
|
23
32
|
margin-bottom: 0 !important;
|
|
24
33
|
}
|
|
25
34
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
margin-top: var(--zn-spacing-x-small);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
zn-navbar::part(navbar) {
|
|
33
|
-
padding: 0 0 0 7px;
|
|
34
|
-
gap: 15px;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
zn-navbar::part(navbar-item) {
|
|
38
|
-
font-size: var(--zn-font-size-small);
|
|
39
|
-
|
|
40
|
-
--zn-spacing-medium: 7px;
|
|
35
|
+
.translations--flush,
|
|
36
|
+
.translations--grouped {
|
|
37
|
+
padding: 0;
|
|
41
38
|
}
|
|
42
39
|
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
.translations--grouped {
|
|
41
|
+
.translations__header {
|
|
42
|
+
margin-bottom: 0;
|
|
43
|
+
}
|
|
45
44
|
}
|