@kubex/zinc 1.1.120 → 1.1.121
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 +3152 -3152
- package/dist/vscode.html-custom-data.json +217 -217
- package/dist/web-types.json +629 -629
- package/dist/zn.d.ts +2 -2
- package/dist/zn.min.js +205 -205
- package/docs/pages/components/translation-group.md +2 -2
- package/package.json +1 -1
- package/src/components/translation-group/translation-group.component.ts +5 -7
- package/src/components/translation-group/translation-group.test.ts +8 -8
- package/src/components/translations/translations.component.ts +3 -4
- package/src/components/translations/translations.test.ts +1 -1
|
@@ -62,8 +62,8 @@ select's accessible name — it is not shown, since the caption names the sectio
|
|
|
62
62
|
### Pre-filled Values
|
|
63
63
|
|
|
64
64
|
Set initial translations on each child. A language every child has a value for is marked `Translated`; one only some
|
|
65
|
-
children have is `Partial`; one no child has falls back to English. English itself is
|
|
66
|
-
|
|
65
|
+
children have is `Partial`; one no child has falls back to English. English itself is marked `Empty` rather than
|
|
66
|
+
falling back, having nothing to fall back to, and counts towards the total like any other language.
|
|
67
67
|
|
|
68
68
|
```html:preview
|
|
69
69
|
<zn-translation-group
|
package/package.json
CHANGED
|
@@ -32,8 +32,8 @@ import styles from './translation-group.scss';
|
|
|
32
32
|
* - `Partial` — only some children do
|
|
33
33
|
* - `English` — none do, so all of them fall back to the English text
|
|
34
34
|
*
|
|
35
|
-
* `Empty` replaces the last of those for English itself, which has nothing to fall back to. English
|
|
36
|
-
*
|
|
35
|
+
* `Empty` replaces the last of those for English itself, which has nothing to fall back to. English counts towards
|
|
36
|
+
* the `n of m` beside the label like any other language.
|
|
37
37
|
*
|
|
38
38
|
* The children own their values; this component only chooses which language is shown and reports on what they hold.
|
|
39
39
|
* It reads them back on every child `zn-change`, so the chips and the count follow an edit as it is typed.
|
|
@@ -221,14 +221,12 @@ export default class ZnTranslationGroup extends ZnPanel {
|
|
|
221
221
|
const languageCodes = [...Object.keys(this.languages), ...extra];
|
|
222
222
|
const hasMultipleLanguages = languageCodes.length > 1;
|
|
223
223
|
|
|
224
|
-
// English is the source every other language falls back to, so it is not itself one of the translations counted.
|
|
225
|
-
const targets = languageCodes.filter(code => code !== 'en');
|
|
226
|
-
const translated = targets.filter(code => this.languageState(code).type === 'success').length;
|
|
227
224
|
// Closed, the select answers "how much is left to do" rather than the state of the one language on show — that
|
|
228
225
|
// is what the options are for.
|
|
226
|
+
const translated = languageCodes.filter(code => this.languageState(code).type === 'success').length;
|
|
229
227
|
const summary = {
|
|
230
|
-
label: `${translated}/${
|
|
231
|
-
type: translated ===
|
|
228
|
+
label: `${translated}/${languageCodes.length}`,
|
|
229
|
+
type: translated === languageCodes.length ? 'success' : translated > 0 ? 'warning' : 'error'
|
|
232
230
|
};
|
|
233
231
|
|
|
234
232
|
return html`
|
|
@@ -188,7 +188,7 @@ describe('<zn-translation-group>', () => {
|
|
|
188
188
|
expect(label.textContent?.trim(), 'nothing else rides the caption').to.equal('Content');
|
|
189
189
|
|
|
190
190
|
const summary = selectOf(group).querySelector('zn-chip[slot="suffix"]')!;
|
|
191
|
-
expect(summary.textContent?.trim()).to.equal('
|
|
191
|
+
expect(summary.textContent?.trim()).to.equal('2/2');
|
|
192
192
|
});
|
|
193
193
|
|
|
194
194
|
it('wears the same chrome as any other select', async () => {
|
|
@@ -327,19 +327,19 @@ describe('<zn-translation-group>', () => {
|
|
|
327
327
|
['{"en":"Hello","fr":"Bonjour","de":"Hallo"}', '{"en":"Hi","fr":"Salut"}']);
|
|
328
328
|
|
|
329
329
|
const summary = selectOf(group).querySelector('zn-chip[slot="suffix"]')!;
|
|
330
|
-
expect(summary.textContent?.trim()).to.equal('
|
|
330
|
+
expect(summary.textContent?.trim()).to.equal('2/4');
|
|
331
331
|
expect(summary.getAttribute('type')).to.equal('warning');
|
|
332
332
|
|
|
333
333
|
expect(chipsOf(group)).to.deep.equal(['Translated', 'Translated', 'Partial', 'English']);
|
|
334
334
|
});
|
|
335
335
|
|
|
336
|
-
it('marks the summary chip done once every
|
|
336
|
+
it('marks the summary chip done once every language is translated', async () => {
|
|
337
337
|
const group = await groupFixture(
|
|
338
338
|
{en: 'English', fr: 'French'},
|
|
339
339
|
['{"en":"Hello","fr":"Bonjour"}']);
|
|
340
340
|
|
|
341
341
|
const summary = selectOf(group).querySelector('zn-chip[slot="suffix"]')!;
|
|
342
|
-
expect(summary.textContent?.trim()).to.equal('
|
|
342
|
+
expect(summary.textContent?.trim()).to.equal('2/2');
|
|
343
343
|
expect(summary.getAttribute('type')).to.equal('success');
|
|
344
344
|
});
|
|
345
345
|
|
|
@@ -351,13 +351,13 @@ describe('<zn-translation-group>', () => {
|
|
|
351
351
|
expect(chipsOf(group)).to.deep.equal(['Translated', 'English']);
|
|
352
352
|
});
|
|
353
353
|
|
|
354
|
-
it('counts the target languages
|
|
354
|
+
it('counts English alongside the target languages', async () => {
|
|
355
355
|
const group = await groupFixture(
|
|
356
356
|
{en: 'English', fr: 'French', de: 'German'},
|
|
357
357
|
['{"en":"Hello","fr":"Bonjour"}']);
|
|
358
358
|
|
|
359
359
|
const summary = selectOf(group).querySelector('zn-chip[slot="suffix"]')!;
|
|
360
|
-
expect(summary.textContent?.trim()).to.equal('
|
|
360
|
+
expect(summary.textContent?.trim()).to.equal('2/3');
|
|
361
361
|
});
|
|
362
362
|
|
|
363
363
|
it('switches every child when the select changes', async () => {
|
|
@@ -416,14 +416,14 @@ describe('<zn-translation-group>', () => {
|
|
|
416
416
|
await group.updateComplete;
|
|
417
417
|
|
|
418
418
|
const summary = () => group.shadowRoot!.querySelector('zn-select zn-chip[slot="suffix"]')!.textContent?.trim();
|
|
419
|
-
expect(summary()).to.equal('
|
|
419
|
+
expect(summary()).to.equal('1/2');
|
|
420
420
|
|
|
421
421
|
form.reset();
|
|
422
422
|
await new Promise(resolve => requestAnimationFrame(() => resolve(null)));
|
|
423
423
|
await group.updateComplete;
|
|
424
424
|
|
|
425
425
|
expect(child.values).to.deep.equal({en: 'Hello', fr: 'Bonjour'});
|
|
426
|
-
expect(summary()).to.equal('
|
|
426
|
+
expect(summary()).to.equal('2/2');
|
|
427
427
|
});
|
|
428
428
|
});
|
|
429
429
|
});
|
|
@@ -445,11 +445,10 @@ export default class ZnTranslations extends ZincElement implements ZincFormContr
|
|
|
445
445
|
];
|
|
446
446
|
// Closed, the select answers "how much is left to do" rather than the state of the one language on show — that
|
|
447
447
|
// is what the options are for.
|
|
448
|
-
const
|
|
449
|
-
const translated = targets.filter(code => this.hasTranslation(code)).length;
|
|
448
|
+
const translated = languageCodes.filter(code => this.hasTranslation(code)).length;
|
|
450
449
|
const summary = {
|
|
451
|
-
label: `${translated}/${
|
|
452
|
-
type: translated ===
|
|
450
|
+
label: `${translated}/${languageCodes.length}`,
|
|
451
|
+
type: translated === languageCodes.length ? 'success' : translated > 0 ? 'warning' : 'error'
|
|
453
452
|
};
|
|
454
453
|
|
|
455
454
|
const currentTranslation = this.values[this._activeLanguage] ?? '';
|
|
@@ -95,7 +95,7 @@ describe('<zn-translations>', () => {
|
|
|
95
95
|
await el.updateComplete;
|
|
96
96
|
|
|
97
97
|
const summary = selectOf(el)!.querySelector('zn-chip[slot="suffix"]')!;
|
|
98
|
-
expect(summary.textContent?.trim()).to.equal('
|
|
98
|
+
expect(summary.textContent?.trim()).to.equal('2/3');
|
|
99
99
|
expect(summary.getAttribute('type')).to.equal('warning');
|
|
100
100
|
|
|
101
101
|
const options = [...selectOf(el)!.querySelectorAll('zn-option zn-chip')];
|