@kubex/zinc 1.0.99 → 1.0.101
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 +6 -6
- package/dist/vscode.html-custom-data.json +1 -1
- package/dist/web-types.json +3 -3
- package/dist/zn.d.ts +11 -5
- package/dist/zn.min.js +623 -602
- package/package.json +1 -1
- package/src/components/data-select/providers/currency-data-provider.ts +2 -1
- package/src/components/select/select.component.ts +8 -4
- package/src/components/translations/translations.component.ts +59 -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',
|
|
@@ -254,7 +255,7 @@ const currencyCodeToSymbol: { [key: string]: string } = {
|
|
|
254
255
|
'RSD': 'Дин.',
|
|
255
256
|
'RUB': '₽',
|
|
256
257
|
'RWF': 'R₣',
|
|
257
|
-
'SAR': '
|
|
258
|
+
'SAR': 'SAR',
|
|
258
259
|
'SBD': '$',
|
|
259
260
|
'SCR': '₨',
|
|
260
261
|
'SDG': 'ج.س.',
|
|
@@ -294,7 +294,7 @@ export default class ZnSelect extends ZincElement implements ZincFormControl {
|
|
|
294
294
|
|
|
295
295
|
/**
|
|
296
296
|
* By default, form controls are associated with the nearest containing `<form>` element. This attribute allows you
|
|
297
|
-
* to place the form control outside
|
|
297
|
+
* to place the form control outside a form and associate it with the form that has this `id`. The form must be in
|
|
298
298
|
* the same document or shadow root for this to work.
|
|
299
299
|
*/
|
|
300
300
|
@property({reflect: true}) form: string;
|
|
@@ -684,6 +684,10 @@ export default class ZnSelect extends ZincElement implements ZincFormControl {
|
|
|
684
684
|
this.emit('zn-clear');
|
|
685
685
|
this.emit('zn-input');
|
|
686
686
|
this.emit('zn-change');
|
|
687
|
+
|
|
688
|
+
if (this.triggerSubmit) {
|
|
689
|
+
this.formControlController.submit();
|
|
690
|
+
}
|
|
687
691
|
});
|
|
688
692
|
}
|
|
689
693
|
}
|
|
@@ -1336,11 +1340,11 @@ export default class ZnSelect extends ZincElement implements ZincFormControl {
|
|
|
1336
1340
|
const data: unknown = await response.json();
|
|
1337
1341
|
|
|
1338
1342
|
// Count raw results before maxResults limiting to determine exhaustiveness
|
|
1339
|
-
const rawCount = Array.isArray(data)
|
|
1340
|
-
? data.reduce((n
|
|
1343
|
+
const rawCount: number = Array.isArray(data)
|
|
1344
|
+
? (data as unknown[]).reduce<number>((n, item) => {
|
|
1341
1345
|
if (item && typeof item === 'object' && 'group' in (item as Record<string, unknown>)) {
|
|
1342
1346
|
const group = item as Record<string, unknown>;
|
|
1343
|
-
return n + (Array.isArray(group.options) ? group.options.length : 0);
|
|
1347
|
+
return n + (Array.isArray(group.options) ? (group.options as unknown[]).length : 0);
|
|
1344
1348
|
}
|
|
1345
1349
|
return n + 1;
|
|
1346
1350
|
}, 0)
|
|
@@ -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":""}';
|
|
@@ -147,6 +152,7 @@ export default class ZnTranslations extends ZincElement implements ZincFormContr
|
|
|
147
152
|
}
|
|
148
153
|
|
|
149
154
|
private handleLanguageAdd = (e: ZnMenuSelectEvent) => {
|
|
155
|
+
e.stopPropagation();
|
|
150
156
|
const element = e.detail.element as HTMLElement;
|
|
151
157
|
const languageCode = element.getAttribute('data-path');
|
|
152
158
|
if (languageCode) {
|
|
@@ -157,16 +163,9 @@ export default class ZnTranslations extends ZincElement implements ZincFormContr
|
|
|
157
163
|
}
|
|
158
164
|
};
|
|
159
165
|
|
|
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
|
-
}
|
|
166
|
+
private switchLanguage = (lang: string) => {
|
|
167
|
+
this._activeLanguage = lang;
|
|
168
|
+
this.requestUpdate();
|
|
170
169
|
};
|
|
171
170
|
|
|
172
171
|
private handleValueUpdate = (e: CustomEvent) => {
|
|
@@ -223,48 +222,67 @@ export default class ZnTranslations extends ZincElement implements ZincFormContr
|
|
|
223
222
|
visibleTabs.unshift('en');
|
|
224
223
|
}
|
|
225
224
|
|
|
226
|
-
const navigation = visibleTabs.map(code => ({
|
|
227
|
-
title: code.toUpperCase(),
|
|
228
|
-
active: code === this._activeLanguage,
|
|
229
|
-
tab: code
|
|
230
|
-
}));
|
|
231
|
-
|
|
232
225
|
const currentTranslation = this.values[this._activeLanguage] ?? '';
|
|
233
226
|
const isRTL = this.isRTLLanguage(this._activeLanguage);
|
|
234
227
|
|
|
235
228
|
const hasLabelSlot = this.hasSlotController.test('label');
|
|
236
229
|
const hasLabel = this.label ? true : hasLabelSlot;
|
|
230
|
+
const hasExpandSlot = this.hasSlotController.test('expand');
|
|
231
|
+
const hasMultipleLanguages = Object.keys(this.languages).length > 1;
|
|
232
|
+
const showActions = !this.grouped && (hasMultipleLanguages || hasExpandSlot);
|
|
237
233
|
|
|
238
234
|
return html`
|
|
239
235
|
<div part="form-control"
|
|
240
236
|
class="${classMap({
|
|
241
237
|
'translations': true,
|
|
242
238
|
'translations--grouped': this.grouped,
|
|
239
|
+
'translations--flush': this.flush,
|
|
243
240
|
'form-control': true,
|
|
244
241
|
'form-control--medium': true,
|
|
245
242
|
'form-control--has-label': hasLabel,
|
|
246
243
|
})}"
|
|
247
244
|
@keydown="${this.handleKeyDown}">
|
|
248
|
-
<
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
245
|
+
<div class="translations__header">
|
|
246
|
+
<label part="form-control-label" class="form-control__label" for="input"
|
|
247
|
+
aria-hidden=${hasLabel ? 'false' : 'true'}>
|
|
248
|
+
<slot name="label">${this.label}</slot>
|
|
249
|
+
</label>
|
|
250
|
+
${showActions ? html`
|
|
251
|
+
<div class="translations__actions">
|
|
252
|
+
${hasExpandSlot ? html`<slot name="expand"></slot>` : nothing}
|
|
253
|
+
${hasMultipleLanguages ? html`
|
|
254
|
+
<zn-button-group>
|
|
255
|
+
${visibleTabs.map(code => html`
|
|
256
|
+
<zn-button
|
|
257
|
+
size="x-small"
|
|
258
|
+
color="default"
|
|
259
|
+
?outline="${code !== this._activeLanguage}"
|
|
260
|
+
@click="${() => this.switchLanguage(code)}"
|
|
261
|
+
>${code.toUpperCase()}
|
|
262
|
+
</zn-button>
|
|
263
|
+
`)}
|
|
264
|
+
${availableLanguages.length > 0 ? html`
|
|
265
|
+
<zn-dropdown placement="bottom-end">
|
|
266
|
+
<zn-button
|
|
267
|
+
slot="trigger"
|
|
268
|
+
size="x-small"
|
|
269
|
+
color="default"
|
|
270
|
+
outline
|
|
271
|
+
>+
|
|
272
|
+
</zn-button>
|
|
273
|
+
<zn-menu
|
|
274
|
+
.actions=${availableLanguages}
|
|
275
|
+
@zn-menu-select="${this.handleLanguageAdd}"
|
|
276
|
+
></zn-menu>
|
|
277
|
+
</zn-dropdown>
|
|
278
|
+
` : nothing}
|
|
279
|
+
</zn-button-group>
|
|
280
|
+
` : nothing}
|
|
281
|
+
</div>
|
|
282
|
+
` : nothing}
|
|
283
|
+
</div>
|
|
284
|
+
|
|
285
|
+
<div part="form-control-input" class="translations__body">
|
|
268
286
|
${keyed(this._activeLanguage, html`
|
|
269
287
|
<zn-inline-edit
|
|
270
288
|
.value=${live(currentTranslation)}
|
|
@@ -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
|
}
|