@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.
@@ -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 the source, so it is neither
66
- counted nor marked as a translation.
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubex/zinc",
3
- "version": "1.1.120",
3
+ "version": "1.1.121",
4
4
  "description": "A collection of web components for building web applications based off of @shoelace-style/Shoelace",
5
5
  "keywords": [
6
6
  "web components",
@@ -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 is the source
36
- * rather than a translation, so it is also left out of the `n of m translated` count beside the label.
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}/${targets.length}`,
231
- type: translated === targets.length ? 'success' : translated > 0 ? 'warning' : 'error'
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('1/1');
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('1/3');
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 target language is translated', async () => {
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('1/1');
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, not English', async () => {
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('1/2');
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('0/1');
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('1/1');
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 targets = languageCodes.filter(code => code !== 'en');
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}/${targets.length}`,
452
- type: translated === targets.length ? 'success' : translated > 0 ? 'warning' : 'error'
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('1/2');
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')];