tycho-components 0.28.1 → 0.28.3

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.
@@ -1,4 +1,4 @@
1
- export type EditionTierGroup = 'semiDiplomatic' | 'modernized';
1
+ export type EditionTierGroup = '' | 'semiDiplomatic' | 'modernized';
2
2
  export type EditionTierDefinition = {
3
3
  symbol: string;
4
4
  label: string;
@@ -11,6 +11,7 @@ declare const EditionTierUtils: {
11
11
  getTierLabel: (symbol: string, corpus?: Corpus | null, t?: (key: string) => string) => string;
12
12
  isUnderSelected: (selected: string, tier: string, corpus?: Corpus | null) => boolean;
13
13
  buildEditionGroups: (corpus?: Corpus | null) => EditionGroup[];
14
+ getUngroupedEditionTiers: (corpus?: Corpus | null) => string[];
14
15
  findGroupForTier: (tier: string, corpus?: Corpus | null) => EditionGroup | undefined;
15
16
  isAbbreviationTier: (symbol: string, corpus?: Corpus | null) => boolean;
16
17
  validateEditionTiers: (tiers: EditionTierDefinition[]) => string | null;
@@ -54,20 +54,31 @@ const buildEditionGroups = (corpus) => {
54
54
  tiers: [StructuralEditionTiers.ORIGINAL],
55
55
  defaultTier: StructuralEditionTiers.ORIGINAL,
56
56
  },
57
- {
58
- id: 'semiDiplomatic',
59
- labelKey: 'edition.group.semiDiplomatic',
60
- tiers: semi,
61
- defaultTier: semi[semi.length - 1] || EditionTiers.ILLEGIBLE,
62
- },
63
- {
64
- id: 'modernized',
65
- labelKey: 'edition.group.modernized',
66
- tiers: modern,
67
- defaultTier: modern[modern.length - 1] || EditionTiers.INFLECTION,
68
- },
57
+ ...(semi.length > 0
58
+ ? [
59
+ {
60
+ id: 'semiDiplomatic',
61
+ labelKey: 'edition.group.semiDiplomatic',
62
+ tiers: semi,
63
+ defaultTier: semi[semi.length - 1],
64
+ },
65
+ ]
66
+ : []),
67
+ ...(modern.length > 0
68
+ ? [
69
+ {
70
+ id: 'modernized',
71
+ labelKey: 'edition.group.modernized',
72
+ tiers: modern,
73
+ defaultTier: modern[modern.length - 1],
74
+ },
75
+ ]
76
+ : []),
69
77
  ];
70
78
  };
79
+ const getUngroupedEditionTiers = (corpus) => getCorpusEditionTiers(corpus)
80
+ .filter((tier) => tier.group !== 'semiDiplomatic' && tier.group !== 'modernized')
81
+ .map((tier) => tier.symbol);
71
82
  const findGroupForTier = (tier, corpus) => buildEditionGroups(corpus).find((group) => group.tiers.includes(tier));
72
83
  const isAbbreviationTier = (symbol, corpus) => getCorpusEditionTiers(corpus).some((tier) => tier.symbol === symbol && tier.abbreviation);
73
84
  const validateEditionTiers = (tiers) => {
@@ -83,9 +94,6 @@ const validateEditionTiers = (tiers) => {
83
94
  return 'edition.tiers.duplicate.symbol';
84
95
  }
85
96
  symbols.add(tier.symbol);
86
- if (tier.group !== 'semiDiplomatic' && tier.group !== 'modernized') {
87
- return 'edition.tiers.group.invalid';
88
- }
89
97
  }
90
98
  return null;
91
99
  };
@@ -117,6 +125,7 @@ const EditionTierUtils = {
117
125
  getTierLabel,
118
126
  isUnderSelected,
119
127
  buildEditionGroups,
128
+ getUngroupedEditionTiers,
120
129
  findGroupForTier,
121
130
  isAbbreviationTier,
122
131
  validateEditionTiers,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tycho-components",
3
3
  "private": false,
4
- "version": "0.28.1",
4
+ "version": "0.28.3",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {