@ihabdevteam/core 0.427.0 → 0.428.0
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/CHANGELOG.md +32 -0
- package/dist/components.cjs.js +3 -3
- package/dist/hooks.cjs.js +5 -5
- package/dist/i18n.cjs.js +3 -3
- package/dist/ihabdevteam-core.cjs.js +185 -185
- package/dist/ihabdevteam-core.d.ts +11 -1
- package/dist/packages/core/src/hooks/useWordAttributeFilter.js +16 -4
- package/dist/packages/core/src/i18n/locales/en.json +1 -0
- package/dist/packages/core/src/i18n/locales/ko.json +1 -0
- package/dist/packages/core/src/utils/wordAttributeFilterCodes.d.ts +10 -0
- package/dist/packages/core/src/utils/wordAttributeFilterCodes.js +78 -3
- package/dist/packages/core/src/version.d.ts +1 -1
- package/dist/packages/core/src/version.js +1 -1
- package/dist/utils.cjs.js +15 -15
- package/package.json +1 -1
|
@@ -2118,7 +2118,7 @@ export declare function copyText(text: string): Promise<boolean>;
|
|
|
2118
2118
|
*
|
|
2119
2119
|
* 값은 손으로 적고 `test/coreVersion.test.ts` 가 package.json 과 어긋나면 운다.
|
|
2120
2120
|
*/
|
|
2121
|
-
export declare const CORE_VERSION = "0.
|
|
2121
|
+
export declare const CORE_VERSION = "0.428.0";
|
|
2122
2122
|
|
|
2123
2123
|
/** @public */
|
|
2124
2124
|
declare const coreDefault: Record<string, unknown>;
|
|
@@ -7122,6 +7122,8 @@ declare interface ResolvedGradeBand {
|
|
|
7122
7122
|
minAge: number;
|
|
7123
7123
|
maxAge: number | null;
|
|
7124
7124
|
showAge: boolean;
|
|
7125
|
+
/** 칩 이름 — `showAge: false` 이고 이름을 받았을 때만 */
|
|
7126
|
+
label?: string;
|
|
7125
7127
|
}
|
|
7126
7128
|
|
|
7127
7129
|
/**
|
|
@@ -12156,6 +12158,14 @@ export declare interface WordGradeBand {
|
|
|
12156
12158
|
maxAge: number | null;
|
|
12157
12159
|
/** 난이도 칩을 나이로 보일지 — `true` 면 `N세` 칩들(열린 묶음은 `N세 이상` 하나), `false` 면 `N등급` 하나 */
|
|
12158
12160
|
showAge: boolean;
|
|
12161
|
+
/**
|
|
12162
|
+
* 칩 이름 — `showAge: false` 묶음에서만 읽는다. 주면 `N등급` 대신 이 글자가 선다(`초등 저학년`).
|
|
12163
|
+
*
|
|
12164
|
+
* 사장님 지시 2026-11-10: *"난이도를 등급으로 표현하지 않기로 했어"*. **칩 코드는 그대로
|
|
12165
|
+
* `'2'`** 다 — 낱말의 `grade` 와 맞대는 쪽이라. 이름표가 곧 거르개의 열쇠이므로 이 글자는
|
|
12166
|
+
* **코드로 되읽힌다**(`wordAttributeValueCodeOf`). 빈 글자는 안 준 것으로 본다.
|
|
12167
|
+
*/
|
|
12168
|
+
label?: string;
|
|
12159
12169
|
}
|
|
12160
12170
|
|
|
12161
12171
|
/**
|
|
@@ -48,7 +48,7 @@ export function buildGradeSection(t, keys, opts) {
|
|
|
48
48
|
label: keys.difficulty,
|
|
49
49
|
/* 칩 글자는 `wordAttributeFilterCodes` 의 사전과 **같은 열쇠·같은 틀**로 짓는다 — 거기서
|
|
50
50
|
코드로 못 읽으면 칩은 켜져 보이는데 한 낱말도 안 걸린다(`없음` 이 밟았던 꼴) */
|
|
51
|
-
items: [...gradeBandCodes(resolved).map(code => gradeChipLabel(t, code)), t('wordSearch.filter.gradeNone', '없음')],
|
|
51
|
+
items: [...gradeBandCodes(resolved).map(code => gradeChipLabel(t, code, resolved)), t('wordSearch.filter.gradeNone', '없음')],
|
|
52
52
|
multiple: true,
|
|
53
53
|
allOption: true,
|
|
54
54
|
allLabel: opts?.allLabel,
|
|
@@ -85,8 +85,14 @@ export function buildGradeSection(t, keys, opts) {
|
|
|
85
85
|
},
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
|
-
/**
|
|
89
|
-
|
|
88
|
+
/**
|
|
89
|
+
* 등급 칩 코드 → 지금 언어의 글자. 사전(`wordAttributeFilterCodes`)과 같은 열쇠·같은 틀이다.
|
|
90
|
+
* 묶음이 이름을 가졌으면(`초등 저학년`) 그 이름 — 되읽기는 `resolveGradeBands` 가 적어 둔 이름표가 한다.
|
|
91
|
+
*/
|
|
92
|
+
function gradeChipLabel(t, code, bands) {
|
|
93
|
+
const named = bands.find(b => b.label && String(b.grade) === code)?.label;
|
|
94
|
+
if (named)
|
|
95
|
+
return named;
|
|
90
96
|
const age = ageOfGradeCode(code);
|
|
91
97
|
if (age != null)
|
|
92
98
|
return t('wordSearch.filter.age', { n: age, defaultValue: `${age}세` });
|
|
@@ -107,15 +113,21 @@ function gradeChipLabel(t, code) {
|
|
|
107
113
|
* 단어훈련 화면도 이것을 부른다(묶음을 받았을 때).
|
|
108
114
|
*/
|
|
109
115
|
export function gradeBandDescriptions(t, bands) {
|
|
116
|
+
/* 묶음이 이름을 가졌으면 **등급이라는 말을 안 쓴다**(사장님 지시 2026-11-10: *"난이도를 등급으로
|
|
117
|
+
표현하지 않기로 했어"*). 나이로 보이는 묶음은 이름을 안 받으므로 이름 있는 묶음과 섞이면
|
|
118
|
+
`1등급 낱말을…` 이 남는데, 그러면 칩에는 없는 `등급` 이 설명에만 나온다. */
|
|
119
|
+
const named = bands.some(b => b.label);
|
|
110
120
|
const lines = bands.map((band) => {
|
|
111
121
|
const ages = band.maxAge == null
|
|
112
122
|
? t('wordSearch.filter.agePlus', { n: band.minAge, defaultValue: `${band.minAge}세 이상` })
|
|
113
123
|
: band.minAge === band.maxAge
|
|
114
124
|
? t('wordSearch.filter.age', { n: band.minAge, defaultValue: `${band.minAge}세` })
|
|
115
125
|
: t('wordSearch.filter.ageRange', { from: band.minAge, to: band.maxAge, defaultValue: `${band.minAge}세~${band.maxAge}세` });
|
|
116
|
-
const grade = t('wordSearch.filter.grade', { n: band.grade, defaultValue: `${band.grade}등급` });
|
|
126
|
+
const grade = band.label ?? t('wordSearch.filter.grade', { n: band.grade, defaultValue: `${band.grade}등급` });
|
|
117
127
|
if (!band.showAge)
|
|
118
128
|
return t('wordSearch.filter.difficultyInfoBandGrade', { grade, ages, defaultValue: `${grade}: ${ages} 낱말입니다.` });
|
|
129
|
+
if (named)
|
|
130
|
+
return t('wordSearch.filter.difficultyInfoBandAgeNamed', { ages, defaultValue: `${ages}: 나이로 나눈 낱말입니다.` });
|
|
119
131
|
if (band.maxAge != null && band.maxAge > band.minAge) {
|
|
120
132
|
return t('wordSearch.filter.difficultyInfoBandAge', { grade, ages, defaultValue: `${ages}: ${grade} 낱말을 나이별로 나눈 것입니다.` });
|
|
121
133
|
}
|
|
@@ -717,6 +717,7 @@
|
|
|
717
717
|
"difficultyInfoBandAge": "{{ages}}: {{grade}} words, split by age.",
|
|
718
718
|
"difficultyInfoBandAgeOne": "{{ages}}: {{grade}} words.",
|
|
719
719
|
"difficultyInfoBandGrade": "{{grade}}: words for {{ages}}.",
|
|
720
|
+
"difficultyInfoBandAgeNamed": "{{ages}}: words split by age.",
|
|
720
721
|
"gradeNone": "None",
|
|
721
722
|
"syllables": "Syllables",
|
|
722
723
|
"syllable": "{{n}} Syll.",
|
|
@@ -703,6 +703,7 @@
|
|
|
703
703
|
"difficultyInfoBandAge": "{{ages}}: {{grade}} 낱말을 나이별로 나눈 것입니다.",
|
|
704
704
|
"difficultyInfoBandAgeOne": "{{ages}}: {{grade}} 낱말입니다.",
|
|
705
705
|
"difficultyInfoBandGrade": "{{grade}}: {{ages}} 낱말입니다.",
|
|
706
|
+
"difficultyInfoBandAgeNamed": "{{ages}}: 나이로 나눈 낱말입니다.",
|
|
706
707
|
"gradeNone": "없음",
|
|
707
708
|
"syllables": "음절 수",
|
|
708
709
|
"syllable": "{{n}}음절",
|
|
@@ -78,6 +78,14 @@ export interface WordGradeBand {
|
|
|
78
78
|
maxAge: number | null;
|
|
79
79
|
/** 난이도 칩을 나이로 보일지 — `true` 면 `N세` 칩들(열린 묶음은 `N세 이상` 하나), `false` 면 `N등급` 하나 */
|
|
80
80
|
showAge: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* 칩 이름 — `showAge: false` 묶음에서만 읽는다. 주면 `N등급` 대신 이 글자가 선다(`초등 저학년`).
|
|
83
|
+
*
|
|
84
|
+
* 사장님 지시 2026-11-10: *"난이도를 등급으로 표현하지 않기로 했어"*. **칩 코드는 그대로
|
|
85
|
+
* `'2'`** 다 — 낱말의 `grade` 와 맞대는 쪽이라. 이름표가 곧 거르개의 열쇠이므로 이 글자는
|
|
86
|
+
* **코드로 되읽힌다**(`wordAttributeValueCodeOf`). 빈 글자는 안 준 것으로 본다.
|
|
87
|
+
*/
|
|
88
|
+
label?: string;
|
|
81
89
|
}
|
|
82
90
|
/** 묶음 하나를 나이 범위로 편 것 */
|
|
83
91
|
export interface ResolvedGradeBand {
|
|
@@ -85,6 +93,8 @@ export interface ResolvedGradeBand {
|
|
|
85
93
|
minAge: number;
|
|
86
94
|
maxAge: number | null;
|
|
87
95
|
showAge: boolean;
|
|
96
|
+
/** 칩 이름 — `showAge: false` 이고 이름을 받았을 때만 */
|
|
97
|
+
label?: string;
|
|
88
98
|
}
|
|
89
99
|
/**
|
|
90
100
|
* 묶음 목록을 나이 범위로 편다. **꼴이 어긋나면 `null`** — 부르는 쪽은 묶음이 없는 것처럼 간다.
|
|
@@ -154,20 +154,84 @@ export function resolveGradeBands(bands) {
|
|
|
154
154
|
const band = bands[i];
|
|
155
155
|
if (!band || band.grade !== i + 1 || typeof band.showAge !== 'boolean')
|
|
156
156
|
return null;
|
|
157
|
+
const label = band.showAge ? undefined : bandLabelOf(band.label);
|
|
158
|
+
if (label === null)
|
|
159
|
+
return null;
|
|
160
|
+
const resolved = { grade: band.grade, minAge, maxAge: null, showAge: band.showAge };
|
|
161
|
+
if (label)
|
|
162
|
+
resolved.label = label;
|
|
157
163
|
if (i === bands.length - 1) {
|
|
158
164
|
if (band.maxAge !== null)
|
|
159
165
|
return null;
|
|
160
|
-
out.push(
|
|
166
|
+
out.push(resolved);
|
|
161
167
|
break;
|
|
162
168
|
}
|
|
163
169
|
const max = band.maxAge;
|
|
164
170
|
if (typeof max !== 'number' || !Number.isInteger(max) || max < minAge || max >= MAX_AGE)
|
|
165
171
|
return null;
|
|
166
|
-
|
|
172
|
+
resolved.maxAge = max;
|
|
173
|
+
out.push(resolved);
|
|
167
174
|
minAge = max + 1;
|
|
168
175
|
}
|
|
176
|
+
/* 이름표끼리 같으면 하나로 되읽혀 다른 칩을 켠다 */
|
|
177
|
+
const labels = out.flatMap(b => (b.label ? [b.label] : []));
|
|
178
|
+
if (new Set(labels).size !== labels.length)
|
|
179
|
+
return null;
|
|
180
|
+
rememberBandLabels(out);
|
|
169
181
|
return out;
|
|
170
182
|
}
|
|
183
|
+
/**
|
|
184
|
+
* 묶음 이름 하나를 본다 — 안 줬거나 빈 글자면 `undefined`(이름 없음), **쓸 수 없는 이름이면 `null`**
|
|
185
|
+
* (묶음 전체가 꼴 어긋남).
|
|
186
|
+
*
|
|
187
|
+
* 쓸 수 없는 이름은 **다른 칩의 글자와 겹치는 것**이다 — `3세`·`2등급`·`없음`·`'4'` 같은 것.
|
|
188
|
+
* 이름표가 곧 열쇠라 겹치면 되읽을 때 엉뚱한 코드가 나온다. 나이 꼴(`10세 이상`)도 막는다.
|
|
189
|
+
*/
|
|
190
|
+
function bandLabelOf(raw) {
|
|
191
|
+
if (raw === undefined || raw === null)
|
|
192
|
+
return undefined;
|
|
193
|
+
if (typeof raw !== 'string')
|
|
194
|
+
return null;
|
|
195
|
+
const label = raw.trim();
|
|
196
|
+
if (!label)
|
|
197
|
+
return undefined;
|
|
198
|
+
if (isGradeCode(label) || AGE_LIKE.test(label))
|
|
199
|
+
return null;
|
|
200
|
+
for (const lng of languages())
|
|
201
|
+
if (dictFor(lng).reverse.grade.has(label))
|
|
202
|
+
return null;
|
|
203
|
+
return label;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* **지금 묶음의 이름표** — 코드 ↔ 이름(청 (389)+, 사장님 지시 2026-11-10).
|
|
207
|
+
*
|
|
208
|
+
* 이름표 → 코드 되읽기(`wordAttributeValueCodeOf`)와 코드 → 이름표(`wordAttributeValueLabelOf`·
|
|
209
|
+
* `wordAttributeFilterFromCodes`)는 **묶음을 안 받는다** — 부르는 자리가 많고(낱말 2만여 개마다
|
|
210
|
+
* 불리는 `matchesFilters` 까지) 다 묶음을 넘기게 바꿀 수 없다. 그래서 `resolveGradeBands` 가
|
|
211
|
+
* **꼴이 맞는 묶음을 볼 때마다 여기를 갈아 끼운다.** 묶음은 앱에 하나(`app_config`)라 화면끼리
|
|
212
|
+
* 다툴 일이 없다.
|
|
213
|
+
*
|
|
214
|
+
* 묶음이 없거나 어긋날 때는 **비우지 않는다** — 묶음을 안 넘기는 화면 하나가 다른 화면의 이름표를
|
|
215
|
+
* 지우면, 그 화면의 켜진 칩이 되읽히지 않는다(켜져 보이는데 0건). 이름 없는 칩(`2등급`)은 사전이
|
|
216
|
+
* 늘 읽으므로 남은 이름표가 해를 끼치지 않는다.
|
|
217
|
+
*/
|
|
218
|
+
const bandLabelByCode = new Map();
|
|
219
|
+
const bandCodeByLabel = new Map();
|
|
220
|
+
function rememberBandLabels(bands) {
|
|
221
|
+
/* **코드 → 이름은 갈아 끼우고, 이름 → 코드는 쌓는다.** 앱이 지금 언어의 사전 이름을 label 로
|
|
222
|
+
붙여 넘기므로(말귀, 2026-11-10 사장님: *"이거 번역도 되어야 하잖아"*) 언어를 바꾸면 이름이
|
|
223
|
+
바뀐다. 이름 → 코드까지 갈아 끼우면 바꾸기 전에 켜 둔 `초등 저학년` 이 `Early elementary`
|
|
224
|
+
화면에서 안 읽혀 **켜져 보이는데 0건**이 된다(재 봤다). 사전이 지금 언어·ko·en 을 다 읽는
|
|
225
|
+
것과 같은 까닭이다. 쌓인 옛 이름은 제 코드로만 읽히고, 같은 이름이 다른 코드로 오면 새 것이
|
|
226
|
+
이긴다. */
|
|
227
|
+
bandLabelByCode.clear();
|
|
228
|
+
for (const band of bands) {
|
|
229
|
+
if (!band.label)
|
|
230
|
+
continue;
|
|
231
|
+
bandLabelByCode.set(String(band.grade), band.label);
|
|
232
|
+
bandCodeByLabel.set(band.label, String(band.grade));
|
|
233
|
+
}
|
|
234
|
+
}
|
|
171
235
|
/**
|
|
172
236
|
* 편 묶음 → 난이도 칩 **코드**(그 차례대로). `없음` 은 넣지 않는다 — 부르는 쪽이 맨 끝에 둔다.
|
|
173
237
|
*
|
|
@@ -315,6 +379,12 @@ export function wordAttributeValueCodeOf(section, value) {
|
|
|
315
379
|
return value;
|
|
316
380
|
if (isSectionValueCode(section, value))
|
|
317
381
|
return value;
|
|
382
|
+
/* 묶음 이름표(`초등 저학년` → `'2'`) — 사전보다 먼저. 숫자 길로 가면 `초등 3학년` 이 3등급이 된다 */
|
|
383
|
+
if (section === 'grade') {
|
|
384
|
+
const hit = bandCodeByLabel.get(value.trim());
|
|
385
|
+
if (hit)
|
|
386
|
+
return hit;
|
|
387
|
+
}
|
|
318
388
|
for (const lng of languages()) {
|
|
319
389
|
const hit = dictFor(lng).reverse[section].get(value);
|
|
320
390
|
if (hit)
|
|
@@ -351,6 +421,11 @@ export function wordAttributeValueCodeOf(section, value) {
|
|
|
351
421
|
const AGE_LIKE = /(^age\s*\d)|((세|살|years?\s*old|yrs?)(\s*(이상|\+|or\s+(older|above|more)))?$)/i;
|
|
352
422
|
/** 코드 → 지금 언어의 라벨. `'none'` 도 사전 꼴로 나온다(숫자 틀 `{{n}}등급` 에 넣으면 `NaN등급` 이 된다). 모르는 코드는 그대로. */
|
|
353
423
|
export function wordAttributeValueLabelOf(section, code, lng = i18n.language) {
|
|
424
|
+
if (section === 'grade') {
|
|
425
|
+
const named = bandLabelByCode.get(code);
|
|
426
|
+
if (named)
|
|
427
|
+
return named;
|
|
428
|
+
}
|
|
354
429
|
return dictFor(lng).value[section][code] ?? code;
|
|
355
430
|
}
|
|
356
431
|
const toArray = (v) => (Array.isArray(v) ? v.filter((x) => typeof x === 'string') : typeof v === 'string' && v ? [v] : []);
|
|
@@ -383,7 +458,7 @@ export function wordAttributeFilterFromCodes(codes, lng = i18n.language) {
|
|
|
383
458
|
const out = {};
|
|
384
459
|
for (const s of sectionCodes) {
|
|
385
460
|
/* 자유 절은 값이 곧 라벨이다 — 사전에 없다고 버리면 저장했다 되읽을 때 사라진다 */
|
|
386
|
-
const labels = (codes?.[s] ?? []).map((c) => d.value[s][c] ?? (FREE_VALUE_SECTIONS.has(s) ? c : undefined)).filter((x) => !!x);
|
|
461
|
+
const labels = (codes?.[s] ?? []).map((c) => (s === 'grade' ? bandLabelByCode.get(c) : undefined) ?? d.value[s][c] ?? (FREE_VALUE_SECTIONS.has(s) ? c : undefined)).filter((x) => !!x);
|
|
387
462
|
if (labels.length)
|
|
388
463
|
out[d.section[s]] = labels;
|
|
389
464
|
}
|