@ihabdevteam/core 0.464.0 → 0.466.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.
@@ -2279,7 +2279,7 @@ export declare function copyText(text: string): Promise<boolean>;
2279
2279
  *
2280
2280
  * 값은 손으로 적고 `test/coreVersion.test.ts` 가 package.json 과 어긋나면 운다.
2281
2281
  */
2282
- export declare const CORE_VERSION = "0.464.0";
2282
+ export declare const CORE_VERSION = "0.466.0";
2283
2283
 
2284
2284
  /** @public */
2285
2285
  declare const coreDefault: Record<string, unknown>;
@@ -2413,6 +2413,30 @@ export declare interface CountTileProps {
2413
2413
  onMouseLeave?: (e: MouseEvent_2) => void;
2414
2414
  }
2415
2415
 
2416
+ /**
2417
+ * 문장훈련 한 판의 문제 수 — `countTrainingQuestionsDetail` 의 수만. 셀 수 없으면 `null`.
2418
+ *
2419
+ * @public
2420
+ */
2421
+ export declare function countTrainingQuestions(typeKey: string | null | undefined, trainingData: unknown): number | null;
2422
+
2423
+ /**
2424
+ * 문장훈련 한 판의 문제 수를 센다 — `TrainingBlockButton` 의 「N문제 · N문장」 이 쓰는 그 셈이다.
2425
+ *
2426
+ * 갈래마다 세는 자리가 다르다.
2427
+ * - `LISTEN_IN_NOISE`(소음 하 문장 듣기): `items` → `sentences` 의 수. 문장 단위.
2428
+ * - `SHORT_STORY`(짧은 이야기): `items` → `raw.items` → `questions` → `sentences`. 문제 단위.
2429
+ * - `LONG_STORY`(긴 이야기): 각 item 의 `questionItems`(없으면 `questions`) 합. 합이 0 이면 item 수.
2430
+ * - `ORDERING_SENTENCE`(문장 순서화): `items` → `sentences`. 문장 단위.
2431
+ * - 그 밖: `items` 가 있으면 그 수. 문제 단위.
2432
+ *
2433
+ * 셀 수 없으면(자료가 없거나 그 밖 갈래에 items 가 비었으면) `null` — 가짜 기본값을 내지 않는다.
2434
+ * 단추와 앱(숙제 진행률)이 **같은 함수**를 불러 카드의 수와 진행률의 분모가 갈리지 않게 한다(말귀 청 (467)).
2435
+ *
2436
+ * @public
2437
+ */
2438
+ export declare function countTrainingQuestionsDetail(typeKey: string | null | undefined, trainingData: unknown): TrainingQuestionCount | null;
2439
+
2416
2440
  /** @public */
2417
2441
  export declare function CouponInputPopup({ onApply, onCancel }: CouponInputPopupProps): JSX.Element;
2418
2442
 
@@ -11396,6 +11420,18 @@ declare interface TrainingProblem {
11396
11420
  dropped?: string;
11397
11421
  }
11398
11422
 
11423
+ /**
11424
+ * 문장훈련 한 판의 **문제 수**와 그 단위.
11425
+ *
11426
+ * `unit` 은 단추가 붙이는 말이다 — `'sentence'` 면 「N문장」, `'question'` 이면 「N문제」.
11427
+ *
11428
+ * @public
11429
+ */
11430
+ export declare interface TrainingQuestionCount {
11431
+ n: number;
11432
+ unit: 'question' | 'sentence';
11433
+ }
11434
+
11399
11435
  /** @public */
11400
11436
  export declare function TrainingResultPopup(props: TrainingResultPopupProps): JSX.Element;
11401
11437
 
@@ -14,6 +14,7 @@ import { useWindowEvent } from '../../hooks/useWindowEvent';
14
14
  import './TrainingBlockButton.css';
15
15
  import { useAudioPreview } from './useAudioPreview';
16
16
  import { extractProblemText } from './trainingBlockButtonTypes';
17
+ import { countTrainingQuestionsDetail } from '../../utils/trainingQuestionCount';
17
18
  // ─── 컴포넌트 ─────────────────────────────────────────────────────────────────
18
19
  /** @public */
19
20
  export default function TrainingBlockButton(props) {
@@ -111,66 +112,12 @@ export default function TrainingBlockButton(props) {
111
112
  const q = (n) => t('training.countQuestions', { n, count: n });
112
113
  const s = (n) => t('training.countSentences', { n, count: n });
113
114
  // 문항수가 정해지지 않으면(계산 불가) 가짜 기본값을 보이지 않도록 빈 값으로 둔다.
115
+ /* 셈은 `countTrainingQuestionsDetail` 한 곳에 있다 — 앱의 숙제 진행률도 같은 함수를 부른다(말귀 청 (467)) */
114
116
  let countLabel = '';
115
117
  try {
116
- if (topic) {
117
- if (type?.key === 'LISTEN_IN_NOISE') {
118
- let n = 0;
119
- if (Array.isArray(topic.items) && topic.items.length > 0)
120
- n = topic.items.length;
121
- else if (Array.isArray(topic.sentences) && topic.sentences.length > 0)
122
- n = topic.sentences.length;
123
- else if (topic.sentences)
124
- n = 1;
125
- countLabel = s(n);
126
- }
127
- else if (type?.key === 'SHORT_STORY') {
128
- let n = 1;
129
- if (Array.isArray(trainingData?.items))
130
- n = trainingData.items.length;
131
- else if (Array.isArray(trainingData?.raw && trainingData.raw?.items))
132
- n = trainingData.raw.items.length;
133
- else if (Array.isArray(topic?.questions))
134
- n = topic.questions.length;
135
- else if (Array.isArray(topic?.sentences))
136
- n = topic.sentences.length;
137
- countLabel = q(n);
138
- }
139
- else if (type?.key === 'LONG_STORY') {
140
- // 긴 이야기 문제는 각 item의 questionItems 배열에 담김 → 전체 문제 수로 합산.
141
- let n = 1;
142
- if (Array.isArray(topic.items) && topic.items.length > 0) {
143
- const totalQ = topic.items.reduce((acc, it) => {
144
- const qi = it.questionItems;
145
- if (Array.isArray(qi))
146
- return acc + qi.length;
147
- if (Array.isArray(it.questions))
148
- return acc + it.questions.length;
149
- return acc;
150
- }, 0);
151
- n = totalQ > 0 ? totalQ : topic.items.length;
152
- }
153
- else if (Array.isArray(topic.questions) && topic.questions.length > 0) {
154
- n = topic.questions.length;
155
- }
156
- else if (Array.isArray(topic.sentences) && topic.sentences.length > 0) {
157
- n = topic.sentences.length;
158
- }
159
- countLabel = q(n);
160
- }
161
- else if (type?.key === 'ORDERING_SENTENCE') {
162
- // 순서화 문제의 문장은 items 배열에 담김(각 항목이 한 문장). sentences는 폴백.
163
- let n = 1;
164
- if (Array.isArray(topic.items) && topic.items.length > 0)
165
- n = topic.items.length;
166
- else if (Array.isArray(topic.sentences) && topic.sentences.length > 0)
167
- n = topic.sentences.length;
168
- countLabel = s(n);
169
- }
170
- else if (Array.isArray(topic.items)) {
171
- countLabel = topic.items.length > 0 ? q(topic.items.length) : '';
172
- }
173
- }
118
+ const counted = countTrainingQuestionsDetail(type?.key, topic);
119
+ if (counted)
120
+ countLabel = counted.unit === 'sentence' ? s(counted.n) : q(counted.n);
174
121
  }
175
122
  catch (_) { }
176
123
  const isRow = size === 'row';
@@ -167,7 +167,7 @@ export const PLAN_LIMITS = {
167
167
  free: { sentenceTrainingDaily: 2, wordTrainingDaily: 2, gameDaily: 1 },
168
168
  personal_standard: { sentenceTrainingDaily: null, wordTrainingDaily: null, gameDaily: null },
169
169
  // ── 매니저 ──
170
- mgr_free: { sentenceTrainingDaily: 2, wordTrainingDaily: 2, gameDaily: 1, trainingItemMax: 5, customerMax: 5, homeworkSendDaily: 1, smsDaily: 2, smsMonthly: 10 },
170
+ mgr_free: { sentenceTrainingDaily: 2, wordTrainingDaily: 2, gameDaily: 1, trainingItemMax: 5, customerMax: 5, homeworkSendDaily: 1 }, // 문자 없음 — 말귀 청 (466), 요금제 시트 ✗
171
171
  lite: { sentenceTrainingDaily: 5, wordTrainingDaily: 5, gameDaily: 5, trainingItemMax: 10, customerMax: 10, homeworkSendDaily: 10, smsDaily: 10, smsMonthly: 50 },
172
172
  standard: { sentenceTrainingDaily: null, wordTrainingDaily: null, gameDaily: null, trainingItemMax: 30, customerMax: 30, homeworkSendDaily: 30, smsDaily: 20, smsMonthly: 100 },
173
173
  pro: { sentenceTrainingDaily: null, wordTrainingDaily: null, gameDaily: null, trainingItemMax: null, customerMax: 50, homeworkSendDaily: 50, smsDaily: 30, smsMonthly: 150 },
@@ -0,0 +1,33 @@
1
+ /**
2
+ * 문장훈련 한 판의 **문제 수**와 그 단위.
3
+ *
4
+ * `unit` 은 단추가 붙이는 말이다 — `'sentence'` 면 「N문장」, `'question'` 이면 「N문제」.
5
+ *
6
+ * @public
7
+ */
8
+ export interface TrainingQuestionCount {
9
+ n: number;
10
+ unit: 'question' | 'sentence';
11
+ }
12
+ /**
13
+ * 문장훈련 한 판의 문제 수를 센다 — `TrainingBlockButton` 의 「N문제 · N문장」 이 쓰는 그 셈이다.
14
+ *
15
+ * 갈래마다 세는 자리가 다르다.
16
+ * - `LISTEN_IN_NOISE`(소음 하 문장 듣기): `items` → `sentences` 의 수. 문장 단위.
17
+ * - `SHORT_STORY`(짧은 이야기): `items` → `raw.items` → `questions` → `sentences`. 문제 단위.
18
+ * - `LONG_STORY`(긴 이야기): 각 item 의 `questionItems`(없으면 `questions`) 합. 합이 0 이면 item 수.
19
+ * - `ORDERING_SENTENCE`(문장 순서화): `items` → `sentences`. 문장 단위.
20
+ * - 그 밖: `items` 가 있으면 그 수. 문제 단위.
21
+ *
22
+ * 셀 수 없으면(자료가 없거나 그 밖 갈래에 items 가 비었으면) `null` — 가짜 기본값을 내지 않는다.
23
+ * 단추와 앱(숙제 진행률)이 **같은 함수**를 불러 카드의 수와 진행률의 분모가 갈리지 않게 한다(말귀 청 (467)).
24
+ *
25
+ * @public
26
+ */
27
+ export declare function countTrainingQuestionsDetail(typeKey: string | null | undefined, trainingData: unknown): TrainingQuestionCount | null;
28
+ /**
29
+ * 문장훈련 한 판의 문제 수 — `countTrainingQuestionsDetail` 의 수만. 셀 수 없으면 `null`.
30
+ *
31
+ * @public
32
+ */
33
+ export declare function countTrainingQuestions(typeKey: string | null | undefined, trainingData: unknown): number | null;
@@ -0,0 +1,89 @@
1
+ const arr = (v) => (Array.isArray(v) ? v : null);
2
+ /**
3
+ * 문장훈련 한 판의 문제 수를 센다 — `TrainingBlockButton` 의 「N문제 · N문장」 이 쓰는 그 셈이다.
4
+ *
5
+ * 갈래마다 세는 자리가 다르다.
6
+ * - `LISTEN_IN_NOISE`(소음 하 문장 듣기): `items` → `sentences` 의 수. 문장 단위.
7
+ * - `SHORT_STORY`(짧은 이야기): `items` → `raw.items` → `questions` → `sentences`. 문제 단위.
8
+ * - `LONG_STORY`(긴 이야기): 각 item 의 `questionItems`(없으면 `questions`) 합. 합이 0 이면 item 수.
9
+ * - `ORDERING_SENTENCE`(문장 순서화): `items` → `sentences`. 문장 단위.
10
+ * - 그 밖: `items` 가 있으면 그 수. 문제 단위.
11
+ *
12
+ * 셀 수 없으면(자료가 없거나 그 밖 갈래에 items 가 비었으면) `null` — 가짜 기본값을 내지 않는다.
13
+ * 단추와 앱(숙제 진행률)이 **같은 함수**를 불러 카드의 수와 진행률의 분모가 갈리지 않게 한다(말귀 청 (467)).
14
+ *
15
+ * @public
16
+ */
17
+ export function countTrainingQuestionsDetail(typeKey, trainingData) {
18
+ if (!trainingData || typeof trainingData !== 'object')
19
+ return null;
20
+ const topic = trainingData;
21
+ const items = arr(topic.items);
22
+ const sentences = topic.sentences;
23
+ const questions = arr(topic.questions);
24
+ if (typeKey === 'LISTEN_IN_NOISE') {
25
+ let n = 0;
26
+ if (items && items.length > 0)
27
+ n = items.length;
28
+ else if (Array.isArray(sentences) && sentences.length > 0)
29
+ n = sentences.length;
30
+ else if (sentences)
31
+ n = 1;
32
+ return { n, unit: 'sentence' };
33
+ }
34
+ if (typeKey === 'SHORT_STORY') {
35
+ let n = 1;
36
+ const rawItems = arr(topic.raw?.items);
37
+ if (items)
38
+ n = items.length;
39
+ else if (rawItems)
40
+ n = rawItems.length;
41
+ else if (questions)
42
+ n = questions.length;
43
+ else if (Array.isArray(sentences))
44
+ n = sentences.length;
45
+ return { n, unit: 'question' };
46
+ }
47
+ if (typeKey === 'LONG_STORY') {
48
+ let n = 1;
49
+ if (items && items.length > 0) {
50
+ const total = items.reduce((acc, it) => {
51
+ const rec = (it ?? {});
52
+ const qi = arr(rec.questionItems);
53
+ if (qi)
54
+ return acc + qi.length;
55
+ const qs = arr(rec.questions);
56
+ if (qs)
57
+ return acc + qs.length;
58
+ return acc;
59
+ }, 0);
60
+ n = total > 0 ? total : items.length;
61
+ }
62
+ else if (questions && questions.length > 0) {
63
+ n = questions.length;
64
+ }
65
+ else if (Array.isArray(sentences) && sentences.length > 0) {
66
+ n = sentences.length;
67
+ }
68
+ return { n, unit: 'question' };
69
+ }
70
+ if (typeKey === 'ORDERING_SENTENCE') {
71
+ let n = 1;
72
+ if (items && items.length > 0)
73
+ n = items.length;
74
+ else if (Array.isArray(sentences) && sentences.length > 0)
75
+ n = sentences.length;
76
+ return { n, unit: 'sentence' };
77
+ }
78
+ if (items && items.length > 0)
79
+ return { n: items.length, unit: 'question' };
80
+ return null;
81
+ }
82
+ /**
83
+ * 문장훈련 한 판의 문제 수 — `countTrainingQuestionsDetail` 의 수만. 셀 수 없으면 `null`.
84
+ *
85
+ * @public
86
+ */
87
+ export function countTrainingQuestions(typeKey, trainingData) {
88
+ return countTrainingQuestionsDetail(typeKey, trainingData)?.n ?? null;
89
+ }
@@ -50,6 +50,8 @@ export { toStorageName, toBase64UrlSafe, officialSoundPath } from './utils/encod
50
50
  export { copyText } from './utils/clipboard';
51
51
  export { formatPhone, PHONE_REGEX, isValidPhone, PERSONAL_PHONE_REGEX, isPersonalPhone, normalizeDate, dateToDb, formatTimeHM, formatCount } from './utils/format';
52
52
  export { configureTrainingCategories, getTopicTypes, getTrainingTypes } from './utils/categories';
53
+ export { countTrainingQuestions, countTrainingQuestionsDetail } from './utils/trainingQuestionCount';
54
+ export type { TrainingQuestionCount } from './utils/trainingQuestionCount';
53
55
  export type { TopicType, TopicSubType, TrainingType, TrainingCategoryConfig } from './utils/categories';
54
56
  export { formatYmd, formatRelativeTime, getTodayKst, getTodayKstDate, kstStartOfDay, parseLocalYmd, toKstYmd, toKstHm, formatDateKo, formatDateLongKo, formatDatetimeKo, formatDateLocale, formatDateLongLocale } from './utils/date';
55
57
  export type { FormatYmdOptions } from './utils/date';
@@ -40,6 +40,7 @@ export { toStorageName, toBase64UrlSafe, officialSoundPath } from './utils/encod
40
40
  export { copyText } from './utils/clipboard';
41
41
  export { formatPhone, PHONE_REGEX, isValidPhone, PERSONAL_PHONE_REGEX, isPersonalPhone, normalizeDate, dateToDb, formatTimeHM, formatCount } from './utils/format';
42
42
  export { configureTrainingCategories, getTopicTypes, getTrainingTypes } from './utils/categories';
43
+ export { countTrainingQuestions, countTrainingQuestionsDetail } from './utils/trainingQuestionCount';
43
44
  export { formatYmd, formatRelativeTime, getTodayKst, getTodayKstDate, kstStartOfDay, parseLocalYmd, toKstYmd, toKstHm, formatDateKo, formatDateLongKo, formatDatetimeKo, formatDateLocale, formatDateLongLocale } from './utils/date';
44
45
  export { getSavedTheme, applyTheme, initTheme } from './utils/theme';
45
46
  export { getSavedFontScale, applyFontScale, initFontScale } from './utils/fontScale';
@@ -46,4 +46,4 @@
46
46
  *
47
47
  * 값은 손으로 적고 `test/coreVersion.test.ts` 가 package.json 과 어긋나면 운다.
48
48
  */
49
- export declare const CORE_VERSION = "0.464.0";
49
+ export declare const CORE_VERSION = "0.466.0";
@@ -46,4 +46,4 @@
46
46
  *
47
47
  * 값은 손으로 적고 `test/coreVersion.test.ts` 가 package.json 과 어긋나면 운다.
48
48
  */
49
- export const CORE_VERSION = '0.464.0';
49
+ export const CORE_VERSION = '0.466.0';