@ihabdevteam/core 0.375.0 → 0.376.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 +75 -0
- package/dist/components.cjs.js +173 -173
- package/dist/components.esm.css +1 -1
- package/dist/hooks.cjs.js +3 -3
- package/dist/i18n.cjs.js +3 -3
- package/dist/ihabdevteam-core.cjs.js +179 -179
- package/dist/ihabdevteam-core.d.ts +44 -3
- package/dist/packages/core/src/components/Button.css +8 -0
- package/dist/packages/core/src/components/Button.js +18 -5
- package/dist/packages/core/src/components/Training/TrainingWordCard.js +14 -2
- package/dist/packages/core/src/components/Word/WordTableBlock.d.ts +1 -1
- package/dist/packages/core/src/components/Word/WordTableBlock.js +38 -16
- package/dist/packages/core/src/components/Word/wordTableBlockTypes.d.ts +15 -0
- package/dist/packages/core/src/components/WordTable.d.ts +10 -1
- package/dist/packages/core/src/components/WordTable.js +29 -6
- package/dist/packages/core/src/components/buttonTypes.d.ts +17 -0
- 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/version.d.ts +1 -1
- package/dist/packages/core/src/version.js +1 -1
- package/dist/utils.cjs.js +3 -3
- package/package.json +2 -1
|
@@ -986,6 +986,23 @@ export declare interface ButtonProps {
|
|
|
986
986
|
/** 이 단추가 여닫는 영역의 id — `aria-controls` 로 단다(`ariaExpanded` 와 함께 쓴다) */
|
|
987
987
|
ariaControls?: string;
|
|
988
988
|
disabled?: boolean;
|
|
989
|
+
/**
|
|
990
|
+
* **기다리는 중** — 아이콘 자리에 도는 표시(`Loader variant="spinner"`)가 서고 다시 눌리지 않는다.
|
|
991
|
+
*
|
|
992
|
+
* 소리 단추가 쥐는 때는 **셋**인데 꼴은 둘뿐이었다 — `재생`/`멈춤` 만 있고 *받아 오는 중*
|
|
993
|
+
* 이 없었다(말귀 청 (330), 2026-10-28). 음원이 없는 낱말은 누른 뒤 합성을 기다리는데
|
|
994
|
+
* (실측 처음 3,567ms · 캐시가 있을 때 772ms), 그동안 단추가 곧바로 '멈춤' 이 되어
|
|
995
|
+
* **눌렀는데 멈춰 있는** 꼴로 보였다.
|
|
996
|
+
*
|
|
997
|
+
* **보이는 꼴만 바꾼다 — 손은 그대로 받는다.** 막으려면 `disabled` 를 함께 준다.
|
|
998
|
+
*
|
|
999
|
+
* 막는 것까지 여기 묶지 않은 까닭은, 기다리는 단추를 누르는 뜻이 자리마다 갈려서다.
|
|
1000
|
+
* 저장 단추는 **아무 일도 안 나야** 하고(두 번 누르면 두 번 저장된다), 소리 단추는
|
|
1001
|
+
* **기다림을 접어야** 한다(옆 칸을 누르거나 마음이 바뀐다). 하나의 참/거짓으로 둘을 다
|
|
1002
|
+
* 말할 수 없다 — 그래서 *보이는 꼴*만 맡고, 막는 일은 이미 그 일을 하는 `disabled` 에
|
|
1003
|
+
* 둔다. 빠져나갈 구멍을 하나 더 뚫는 것보다 **뜻이 하나씩인 쪽**이 낫다.
|
|
1004
|
+
*/
|
|
1005
|
+
loading?: boolean;
|
|
989
1006
|
/** label을 숨기려면 false로 설정 */
|
|
990
1007
|
useLabel?: boolean;
|
|
991
1008
|
useBorder?: boolean;
|
|
@@ -1770,7 +1787,7 @@ export declare function copyText(text: string): Promise<boolean>;
|
|
|
1770
1787
|
*
|
|
1771
1788
|
* 값은 손으로 적고 `test/coreVersion.test.ts` 가 package.json 과 어긋나면 운다.
|
|
1772
1789
|
*/
|
|
1773
|
-
export declare const CORE_VERSION = "0.
|
|
1790
|
+
export declare const CORE_VERSION = "0.376.0";
|
|
1774
1791
|
|
|
1775
1792
|
/** @public */
|
|
1776
1793
|
declare const coreDefault: Record<string, unknown>;
|
|
@@ -11493,9 +11510,9 @@ export declare interface WordSearchResultWord {
|
|
|
11493
11510
|
* 표시(items)·편집(editCells) 두 모드를 지원한다.
|
|
11494
11511
|
* @public
|
|
11495
11512
|
*/
|
|
11496
|
-
export declare function WordTable({ title, titleIcon, disc, className, orientation, contentTypes, baseItem, baseContentTypes, cutLine, showOutline, showDivLine, items, editCells, count, activeCell, onActivateCell, onRemoveCell, onRemoveItem, onReorder, renderCellAction, showFillerAdd, contentRef, buttonSize, brand, code, pageNumber, pageNumberPosition, fitHeight, scoring, marks, onMarkClick, scoreIndexOffset, }: WordTableProps): JSX.Element;
|
|
11513
|
+
export declare function WordTable({ title, titleIcon, disc, className, orientation, contentTypes, baseItem, baseContentTypes, cutLine, showOutline, showDivLine, items, editCells, count, activeCell, onActivateCell, onRemoveCell, onRemoveItem, onReorder, renderCellAction, showFillerAdd, addableCount, contentRef, buttonSize, brand, code, pageNumber, pageNumberPosition, fitHeight, scoring, marks, onMarkClick, scoreIndexOffset, }: WordTableProps): JSX.Element;
|
|
11497
11514
|
|
|
11498
|
-
export declare function WordTableBlock({ title, titleIcon, disc, filterTitle, filterCollapsible, filterDefaultCollapsed, filterCollapsed, onFilterCollapsedChange, filterHeaderSummary, brand, code, baseItem, baseContentTypes, items, onSaveComplete, onLoad, onRemoveItem, onReset, resetLabel, saveButtonLabel, secondarySaveButtonLabel, onReorder, showCellCount, onAddItem, className, renderSavePopup, renderWordSearch, hideControls, saveOnly, tableName, nameValue, onNameChange, descriptionValue, onDescriptionChange, namePlaceholder, descriptionPlaceholder, existingNames, editingName, onCancel, initialItemsPerPage, renderCellAction, actionsLeftExtra }: WordTableBlockProps): JSX.Element;
|
|
11515
|
+
export declare function WordTableBlock({ title, titleIcon, disc, filterTitle, filterCollapsible, filterDefaultCollapsed, filterCollapsed, onFilterCollapsedChange, filterHeaderSummary, brand, code, baseItem, baseContentTypes, cellCapacity, items, onSaveComplete, onLoad, onRemoveItem, onReset, resetLabel, saveButtonLabel, secondarySaveButtonLabel, onReorder, showCellCount, onAddItem, className, renderSavePopup, renderWordSearch, hideControls, saveOnly, tableName, nameValue, onNameChange, descriptionValue, onDescriptionChange, namePlaceholder, descriptionPlaceholder, existingNames, editingName, onCancel, initialItemsPerPage, renderCellAction, actionsLeftExtra }: WordTableBlockProps): JSX.Element;
|
|
11499
11516
|
|
|
11500
11517
|
/** @public */
|
|
11501
11518
|
export declare interface WordTableBlockProps {
|
|
@@ -11558,6 +11575,21 @@ export declare interface WordTableBlockProps {
|
|
|
11558
11575
|
baseItem?: WordTableProps['baseItem'];
|
|
11559
11576
|
/** 머리 칸에만 걸리는 보임 — 안 주면 표 설정 판에서 고른 `contentTypes` 를 따른다. */
|
|
11560
11577
|
baseContentTypes?: WordTableProps['baseContentTypes'];
|
|
11578
|
+
/**
|
|
11579
|
+
* **이 표가 채울 수 있는 칸 수** — 항목 수보다 크면 그만큼 빈 칸이 생기고,
|
|
11580
|
+
* `onAddItem` 이 있으면 그 칸 가운데에 '추가하기' 가 선다.
|
|
11581
|
+
*
|
|
11582
|
+
* 활용표처럼 **칸 수를 사람이 아니라 낱말이 정하는 표**를 위해 둔다(말귀 청 (327),
|
|
11583
|
+
* 2026-10-28). 전에는 빈 칸을 내는 길이 `showCellCount` 뿐이었는데 그것은 값이 비쌌다 —
|
|
11584
|
+
* '칸 수' 고르개를 세우고 **쪽 나눔을 통째로 껐다.** 이것은 둘 다 안 한다.
|
|
11585
|
+
*
|
|
11586
|
+
* 쪽이 나뉘면 빈 칸은 **뒤쪽 쪽에** 선다. 쪽 수는 `올림(cellCapacity / 페이지당 개수)` 이라,
|
|
11587
|
+
* 항목이 모자라도 채울 자리가 남아 있으면 그만큼 쪽이 더 선다.
|
|
11588
|
+
*
|
|
11589
|
+
* 항목 수보다 작으면 무시한다 — 담긴 것을 가릴 수는 없다. `showCellCount` 와 함께 주면
|
|
11590
|
+
* 그쪽이 이긴다(사람이 고른 것이 마지막 말이다).
|
|
11591
|
+
*/
|
|
11592
|
+
cellCapacity?: number;
|
|
11561
11593
|
disc?: ReactNode;
|
|
11562
11594
|
/** 현재 표의 저장된 이름(불러온 표 등). 있으면 인쇄/PDF 저장 시 파일명으로 사용, 없으면 "오늘 날짜 + 단어표/대립쌍표" */
|
|
11563
11595
|
tableName?: string;
|
|
@@ -11894,6 +11926,15 @@ export declare interface WordTableProps {
|
|
|
11894
11926
|
onReorder?: (fromIndex: number, toIndex: number) => void;
|
|
11895
11927
|
/** 표시 모드에서 `count` 안의 빈칸(항목 수 뒤 ~ count)에 '추가' 버튼 노출. count 가 항목 수와 같으면 그런 칸이 없다. `onActivateCell` 필요. */
|
|
11896
11928
|
showFillerAdd?: boolean;
|
|
11929
|
+
/**
|
|
11930
|
+
* '추가하기' 가 설 수 있는 칸 수 — 안 주면 `count` 를 따른다.
|
|
11931
|
+
*
|
|
11932
|
+
* 쪽이 나뉜 표의 **마지막 쪽**을 위해 둔다(말귀 청 (327), 2026-10-28). 쪽마다 칸 크기가
|
|
11933
|
+
* 같아야 해서 `count` 는 모든 쪽이 '페이지당 개수' 로 같은데, 채울 자리는 마지막 쪽에서
|
|
11934
|
+
* 모자랄 수 있다(자리 12 · 쪽당 8 → 둘째 쪽은 네 자리뿐). `count` 로 세면 **없는 자리에도
|
|
11935
|
+
* 단추가 선다.**
|
|
11936
|
+
*/
|
|
11937
|
+
addableCount?: number;
|
|
11897
11938
|
/**
|
|
11898
11939
|
* **칸 오른쪽 위에 부르는 쪽이 얹는 것** — 칸 번호와 그 칸의 항목을 준다. 안 주면 아무것도 안 얹는다.
|
|
11899
11940
|
*
|
|
@@ -41,6 +41,14 @@
|
|
|
41
41
|
.button__icon--medium { width: 24px; height: 24px; }
|
|
42
42
|
.button__icon--large { width: 36px; height: 36px; }
|
|
43
43
|
|
|
44
|
+
/* 기다리는 꼴(`loading`) — 아이콘과 **같은 상자**에 도는 표시를 세운다(청 (330), 2026-10-28).
|
|
45
|
+
상자 크기는 위 `button__icon--*` 가 그대로 정하고, 여기서는 안의 것을 가운데로만 몬다. */
|
|
46
|
+
.button__spinner {
|
|
47
|
+
display: inline-flex;
|
|
48
|
+
align-items: center;
|
|
49
|
+
justify-content: center;
|
|
50
|
+
}
|
|
51
|
+
|
|
44
52
|
/* group for center-aligned icon+label so they stay together */
|
|
45
53
|
.button__center-group {
|
|
46
54
|
display: inline-flex;
|
|
@@ -5,13 +5,14 @@ import { devWarnOnce, isDev } from '../utils/devWarn';
|
|
|
5
5
|
import { forwardRef, useCallback, useEffect, useId, useRef, useState } from 'react';
|
|
6
6
|
import './Button.css';
|
|
7
7
|
import Icon from './Icon';
|
|
8
|
+
import Loader from './Loader';
|
|
8
9
|
import InfoTooltip from "./Tooltip/InfoTooltip";
|
|
9
10
|
import DescriptionTooltip from "./Tooltip/DescriptionTooltip";
|
|
10
11
|
import { isTouchPointer, recentlyTouched, useTouchToggle } from '../hooks/touchToggle';
|
|
11
12
|
/* **ref 는 forwardRef 로 받는다** — React 19 는 ref 를 props 로 넘기지만 peer 는 16.8~ 라, React 18(kscan) 에서는 함수 컴포넌트에 준
|
|
12
13
|
ref 가 버려진다. 게다가 전에는 안쪽 ref(`btnRef`)가 props 에서 온 ref 를 덮어써 19 에서도 부르는 쪽 ref 가 비었다. 두 ref 를 잇는다. */
|
|
13
14
|
function ButtonInner(props, forwardedRef) {
|
|
14
|
-
const { size = 48, type: explicitType, htmlType, href, target, rel, icon, rightIcon, label: labelProp, count, subLabel, children, ariaLabel, variant = 'default', align = 'center', nowrap = false, selected, toggleable = false, ariaExpanded, ariaControls, disabled = false, useLabel = true, useBorder = true, useBG = true, useDisabledCovered = false, useDisabledInvisible = false, useDisabledFilled = false, width, minWidth, onClick, onDisabledClick, showTooltipInfo = false, tooltipInfoText = null, tooltipDescription = null, tooltipOnly = false, iconSize = 'medium', iconColor, shape = 'rounded', color, className, ...rest } = props;
|
|
15
|
+
const { size = 48, type: explicitType, htmlType, href, target, rel, icon, rightIcon, label: labelProp, count, subLabel, children, ariaLabel, variant = 'default', align = 'center', nowrap = false, selected, toggleable = false, ariaExpanded, ariaControls, disabled = false, loading = false, useLabel = true, useBorder = true, useBG = true, useDisabledCovered = false, useDisabledInvisible = false, useDisabledFilled = false, width, minWidth, onClick, onDisabledClick, showTooltipInfo = false, tooltipInfoText = null, tooltipDescription = null, tooltipOnly = false, iconSize = 'medium', iconColor, shape = 'rounded', color, className, ...rest } = props;
|
|
15
16
|
const sizeKey = typeof size === 'string' && isNaN(Number(size))
|
|
16
17
|
? size.toLowerCase()
|
|
17
18
|
: String(Number(size) || 48);
|
|
@@ -233,6 +234,9 @@ function ButtonInner(props, forwardedRef) {
|
|
|
233
234
|
});
|
|
234
235
|
restProps['aria-disabled'] = 'true';
|
|
235
236
|
}
|
|
237
|
+
/* 낭독기에 *기다리는 중* 을 알린다 — 도는 표시는 `aria-hidden` 이라 이 말이 유일하다 */
|
|
238
|
+
if (loading)
|
|
239
|
+
restProps['aria-busy'] = 'true';
|
|
236
240
|
// 툴팁 텍스트: showTooltipInfo(string) → tooltipInfoText → ariaLabel → label 순 우선
|
|
237
241
|
const tooltipText = (typeof showTooltipInfo === 'string' ? showTooltipInfo : null)
|
|
238
242
|
?? (typeof tooltipInfoText === 'string' ? tooltipInfoText : null)
|
|
@@ -252,15 +256,24 @@ function ButtonInner(props, forwardedRef) {
|
|
|
252
256
|
: showTooltipInfo && tooltipText && tooltipText !== ariaLabelString ? tooltipText : '';
|
|
253
257
|
const consumerDescribedBy = typeof rest['aria-describedby'] === 'string' ? rest['aria-describedby'] : undefined;
|
|
254
258
|
const ariaDescribedBy = [consumerDescribedBy, describeText ? describeId : null].filter(Boolean).join(' ') || undefined;
|
|
259
|
+
/* **기다리는 꼴**(`loading`) — 아이콘 자리를 그대로 쓴다(청 (330)).
|
|
260
|
+
`button__icon` 을 함께 달아 아이콘과 **같은 상자**에 서게 한다 — 따로 재면 단추 크기마다
|
|
261
|
+
어긋난다. `Loader` 가 `role="status"` 와 숨은 글자를 들고 오므로 **통째로 가린다** —
|
|
262
|
+
단추 쪽의 `aria-busy` 가 그 말을 이미 하고 있어, 안 가리면 두 번 읽힌다. */
|
|
263
|
+
const renderSpinner = () => (_jsx("span", { className: `${iconClassName} button__spinner`, "aria-hidden": "true", children: _jsx(Loader, { variant: "spinner", size: "100%" }) }));
|
|
255
264
|
const renderIcon = (iconVal, label) => (_jsx(Icon, { icon: iconVal, label: label ?? ariaLabelString, className: iconClassName, imgClassName: "button__icon-img", maskClassName: "button__icon-mask", svgClassName: "button__icon-svg" }));
|
|
265
|
+
/* 기다리는 꼴은 **왼쪽(주된) 아이콘 자리 하나**만 바꾼다. `renderIcon` 안에서 바꾸면
|
|
266
|
+
오른쪽 아이콘까지 돌아 **한 단추에 도는 표시가 둘**이 된다. 아이콘이 없는 단추에는
|
|
267
|
+
글자 앞에 세운다 — 그 자리도 기다리고 있기는 마찬가지다. */
|
|
268
|
+
const renderMainIcon = (label) => (loading ? renderSpinner() : renderIcon(icon, label));
|
|
256
269
|
const renderContent = () => {
|
|
257
270
|
if (type === 'dot') {
|
|
258
|
-
return (_jsxs(_Fragment, { children: [
|
|
271
|
+
return (_jsxs(_Fragment, { children: [renderMainIcon(), hasLabel && _jsx("span", { className: `button__label ${labelTypoClass}`, children: renderLabelContent() })] }));
|
|
259
272
|
}
|
|
260
|
-
if (align === 'center' && icon) {
|
|
261
|
-
return (_jsxs(_Fragment, { children: [_jsxs("span", { className: "button__center-group", children: [_jsx("span", { className: "button__left", children:
|
|
273
|
+
if (align === 'center' && (icon || loading)) {
|
|
274
|
+
return (_jsxs(_Fragment, { children: [_jsxs("span", { className: "button__center-group", children: [_jsx("span", { className: "button__left", children: renderMainIcon() }), hasLabel && _jsx("span", { className: `button__label ${labelTypoClass}`, children: renderLabelContent() })] }), hasRight && _jsx("span", { className: "button__right", children: renderIcon(rightIcon) })] }));
|
|
262
275
|
}
|
|
263
|
-
return (_jsxs(_Fragment, { children: [icon && _jsx("span", { className: "button__left", children:
|
|
276
|
+
return (_jsxs(_Fragment, { children: [(icon || loading) && _jsx("span", { className: "button__left", children: renderMainIcon(ariaLabel ?? label) }), hasLabel && _jsx("span", { className: `button__label ${labelTypoClass}`, children: renderLabelContent() }), hasRight && _jsx("span", { className: "button__right", children: renderIcon(rightIcon) })] }));
|
|
264
277
|
};
|
|
265
278
|
/* href 가 있고 비활성이 아니면 링크로 렌더한다. */
|
|
266
279
|
const isLink = !!href && !disabledProp;
|
|
@@ -43,6 +43,9 @@ const TrainingWordCard = forwardRef(function TrainingWordCard({ item, disabled =
|
|
|
43
43
|
const audioRef = useRef(null);
|
|
44
44
|
const isMobile = useMediaQuery('(max-width: 767px)');
|
|
45
45
|
const [playing, setPlaying] = useState(false);
|
|
46
|
+
/* **받아 오는 중** — 합성 폴백을 기다리는 동안이다(말귀 청 (330), 2026-10-28).
|
|
47
|
+
전에는 이 동안 단추가 그냥 '재생' 이라, 누른 사람이 제 손이 닿았는지를 알 수 없었다. */
|
|
48
|
+
const [waiting, setWaiting] = useState(false);
|
|
46
49
|
/* 준비한 URL 은 **어느 낱말의 것인지와 함께** 둔다. 카드는 번호 key 로 재사용되는데(TrainingStepCard),
|
|
47
50
|
전에는 낱말이 바뀌어도 URL 을 비우지 않아 새 낱말의 리졸버가 기다리는 동안·실패했을 때 누르면
|
|
48
51
|
**이전 낱말 소리**가 났다 — 변별 훈련에서 틀린 자극이다. 지금 낱말의 것이 아니면 없는 것으로 본다. */
|
|
@@ -197,11 +200,17 @@ const TrainingWordCard = forwardRef(function TrainingWordCard({ item, disabled =
|
|
|
197
200
|
const fallbackResolver = getTTSFallbackUrlResolver();
|
|
198
201
|
if (fallbackResolver && label) {
|
|
199
202
|
try {
|
|
203
|
+
/* 합성은 그 자리에서 만든다 — 실측 처음 3.5초. 그동안 단추가 도는 표시를 든다
|
|
204
|
+
(청 (330)). 끄는 자리가 **소리가 나기 시작할 때**인 것이 중요하다 — 아래
|
|
205
|
+
`finally` 는 `playUrl` 이 **끝날 때** 도는 자리라, 거기서만 끄면 듣는 내내 돈다. */
|
|
206
|
+
setWaiting(true);
|
|
200
207
|
const url = await Promise.resolve(fallbackResolver(label));
|
|
201
208
|
/* 기다리는 사이 떠났거나 **소리 자리를 남에게 넘겼으면**(다른 카드를 눌렀거나 같은 카드를 다시 눌렀으면) 끝낸다 —
|
|
202
|
-
늦게 온 합성 주소로 틀어 두 소리가 겹쳤고, 같은 카드를 두 번 누르면 두 번 울려 onPlayDone 도 두 번 나갔다.
|
|
209
|
+
늦게 온 합성 주소로 틀어 두 소리가 겹쳤고, 같은 카드를 두 번 누르면 두 번 울려 onPlayDone 도 두 번 나갔다.
|
|
210
|
+
이때 도는 표시를 끄지 않는 것도 같은 까닭이다 — **다음 누름이 그것을 쥐고 있다.** */
|
|
203
211
|
if (!mountedRef.current || heldSoundRef.current !== stop)
|
|
204
212
|
return;
|
|
213
|
+
setWaiting(false);
|
|
205
214
|
if (url) {
|
|
206
215
|
setPlaying(true);
|
|
207
216
|
if (await playUrl(url))
|
|
@@ -215,6 +224,9 @@ const TrainingWordCard = forwardRef(function TrainingWordCard({ item, disabled =
|
|
|
215
224
|
await playSpeechSynthesis();
|
|
216
225
|
}
|
|
217
226
|
finally {
|
|
227
|
+
/* 남이 가져갔으면 그 사람의 기다림이다 — 내가 끄면 그쪽 도는 표시가 사라진다 */
|
|
228
|
+
if (heldSoundRef.current === stop)
|
|
229
|
+
setWaiting(false);
|
|
218
230
|
release(); // 다음 사람이 이미 가져갔으면 아무 일도 안 한다
|
|
219
231
|
if (heldSoundRef.current === stop)
|
|
220
232
|
heldSoundRef.current = null;
|
|
@@ -261,6 +273,6 @@ const TrainingWordCard = forwardRef(function TrainingWordCard({ item, disabled =
|
|
|
261
273
|
onSelect?.();
|
|
262
274
|
}
|
|
263
275
|
}
|
|
264
|
-
: undefined, children: _jsxs("div", { className: "training-word-card__flipper", style: { transitionDelay: showBack ? '0ms' : `${flipDelay}ms` }, children: [_jsxs("div", { className: "training-word-card__front", children: [selected && (_jsx("div", { className: "training-word-card__selected-badge", onClick: handleStopProp, children: _jsx(Badge, { type: "dot", size: 40, position: "inline", animate: true, icon: orderRank != null ? undefined : 'check', number: orderRank ?? undefined, "aria-label": orderRank != null ? t('training.nthSelected', { n: orderRank }) : t('training.selected', '선택됨') }) })), _jsx("div", { className: "training-word-card__image-wrap", children: textCard ? (_jsx("div", { className: "training-word-card__text-face", children: front.label })) : hasImage ? (_jsxs(_Fragment, { children: [imgLoading && _jsx("div", { className: "training-word-card__spinner" }), _jsx("img", { ref: imgRef, className: "training-word-card__image", src: imageUrl, alt: front.label || t('common.image', '이미지'), style: { opacity: imgLoading ? 0 : 1 }, onLoad: handleImgLoad, onError: handleImgError })] })) : (_jsx("div", { className: "training-word-card__placeholder" })) }), !hideLabel && (_jsxs("div", { className: "training-word-card__body", children: [!textCard && _jsx("div", { className: "training-word-card__word", children: front.label }), front.subLabel && (_jsxs("div", { className: "training-word-card__pronunciation", children: ["[", front.subLabel, "]"] })), front.colloquialLabel && (_jsxs("div", { className: "training-word-card__colloquial caption-1", children: ["[", front.colloquialLabel, "]"] }))] })), !hideAudio && (_jsx("div", { className: "training-word-card__bottom", onClick: selectable ? handleStopProp : undefined, children: _jsx(Button, { htmlType: "button", size: isMobile ? 40 : 48, type: isMobile ? 'dot' : 'bar', icon: playing ? 'pause' : 'play', label: isMobile ? undefined : t('training.playSound', '소리 듣기'), selected: playing, onClick: handlePlay, disabled: disabled, ariaLabel: t('training.playSound', '소리 듣기') }) }))] }), _jsx("div", { className: "training-word-card__back", "aria-hidden": "true", children: _jsx("span", { className: "training-word-card__disabled-symbol", style: { ['--disabled-symbol-src']: `url("${symbolSrc}")` } }) })] }) }));
|
|
276
|
+
: undefined, children: _jsxs("div", { className: "training-word-card__flipper", style: { transitionDelay: showBack ? '0ms' : `${flipDelay}ms` }, children: [_jsxs("div", { className: "training-word-card__front", children: [selected && (_jsx("div", { className: "training-word-card__selected-badge", onClick: handleStopProp, children: _jsx(Badge, { type: "dot", size: 40, position: "inline", animate: true, icon: orderRank != null ? undefined : 'check', number: orderRank ?? undefined, "aria-label": orderRank != null ? t('training.nthSelected', { n: orderRank }) : t('training.selected', '선택됨') }) })), _jsx("div", { className: "training-word-card__image-wrap", children: textCard ? (_jsx("div", { className: "training-word-card__text-face", children: front.label })) : hasImage ? (_jsxs(_Fragment, { children: [imgLoading && _jsx("div", { className: "training-word-card__spinner" }), _jsx("img", { ref: imgRef, className: "training-word-card__image", src: imageUrl, alt: front.label || t('common.image', '이미지'), style: { opacity: imgLoading ? 0 : 1 }, onLoad: handleImgLoad, onError: handleImgError })] })) : (_jsx("div", { className: "training-word-card__placeholder" })) }), !hideLabel && (_jsxs("div", { className: "training-word-card__body", children: [!textCard && _jsx("div", { className: "training-word-card__word", children: front.label }), front.subLabel && (_jsxs("div", { className: "training-word-card__pronunciation", children: ["[", front.subLabel, "]"] })), front.colloquialLabel && (_jsxs("div", { className: "training-word-card__colloquial caption-1", children: ["[", front.colloquialLabel, "]"] }))] })), !hideAudio && (_jsx("div", { className: "training-word-card__bottom", onClick: selectable ? handleStopProp : undefined, children: _jsx(Button, { htmlType: "button", size: isMobile ? 40 : 48, type: isMobile ? 'dot' : 'bar', icon: playing ? 'pause' : 'play', label: isMobile ? undefined : t('training.playSound', '소리 듣기'), selected: playing, loading: waiting, onClick: handlePlay, disabled: disabled, ariaLabel: t('training.playSound', '소리 듣기') }) }))] }), _jsx("div", { className: "training-word-card__back", "aria-hidden": "true", children: _jsx("span", { className: "training-word-card__disabled-symbol", style: { ['--disabled-symbol-src']: `url("${symbolSrc}")` } }) })] }) }));
|
|
265
277
|
});
|
|
266
278
|
export default TrainingWordCard;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import './WordTableBlock.css';
|
|
2
2
|
import type { WordTableBlockProps } from './wordTableBlockTypes';
|
|
3
3
|
export type { WordEntry, WordTableBlockProps } from './wordTableBlockTypes';
|
|
4
|
-
export default function WordTableBlock({ title, titleIcon, disc, filterTitle, filterCollapsible, filterDefaultCollapsed, filterCollapsed, onFilterCollapsedChange, filterHeaderSummary, brand, code, baseItem, baseContentTypes, items, onSaveComplete, onLoad, onRemoveItem, onReset, resetLabel, saveButtonLabel, secondarySaveButtonLabel, onReorder, showCellCount, onAddItem, className, renderSavePopup, renderWordSearch, hideControls, saveOnly, tableName, nameValue, onNameChange, descriptionValue, onDescriptionChange, namePlaceholder, descriptionPlaceholder, existingNames, editingName, onCancel, initialItemsPerPage, renderCellAction, actionsLeftExtra }: WordTableBlockProps): import("react").JSX.Element;
|
|
4
|
+
export default function WordTableBlock({ title, titleIcon, disc, filterTitle, filterCollapsible, filterDefaultCollapsed, filterCollapsed, onFilterCollapsedChange, filterHeaderSummary, brand, code, baseItem, baseContentTypes, cellCapacity, items, onSaveComplete, onLoad, onRemoveItem, onReset, resetLabel, saveButtonLabel, secondarySaveButtonLabel, onReorder, showCellCount, onAddItem, className, renderSavePopup, renderWordSearch, hideControls, saveOnly, tableName, nameValue, onNameChange, descriptionValue, onDescriptionChange, namePlaceholder, descriptionPlaceholder, existingNames, editingName, onCancel, initialItemsPerPage, renderCellAction, actionsLeftExtra }: WordTableBlockProps): import("react").JSX.Element;
|
|
@@ -10,7 +10,6 @@ import TextField from '../TextField';
|
|
|
10
10
|
import Panel, { PanelRow } from '../Panel';
|
|
11
11
|
import Popup from '../Popup/Popup';
|
|
12
12
|
import WordTable, { WORD_TABLE_PAPER } from '../WordTable';
|
|
13
|
-
import { chunkItems } from '../wordTableLayout';
|
|
14
13
|
import TableFilterPanel from './TableFilterPanel';
|
|
15
14
|
import { buildItemsPerPageSection, buildPageNumberSection, parsePageNumberPosition, itemsPerPageFromChoice } from './wordTableSettings';
|
|
16
15
|
import Toast from '../Toast';
|
|
@@ -45,7 +44,7 @@ function withUniqueIds(list) {
|
|
|
45
44
|
return id === it.id ? it : { ...it, id };
|
|
46
45
|
});
|
|
47
46
|
}
|
|
48
|
-
export default function WordTableBlock({ title, titleIcon, disc, filterTitle, filterCollapsible, filterDefaultCollapsed, filterCollapsed, onFilterCollapsedChange, filterHeaderSummary, brand, code, baseItem, baseContentTypes, items, onSaveComplete, onLoad, onRemoveItem, onReset, resetLabel, saveButtonLabel, secondarySaveButtonLabel, onReorder, showCellCount, onAddItem, className, renderSavePopup, renderWordSearch, hideControls, saveOnly, tableName, nameValue, onNameChange, descriptionValue, onDescriptionChange, namePlaceholder, descriptionPlaceholder, existingNames, editingName, onCancel, initialItemsPerPage, renderCellAction, actionsLeftExtra }) {
|
|
47
|
+
export default function WordTableBlock({ title, titleIcon, disc, filterTitle, filterCollapsible, filterDefaultCollapsed, filterCollapsed, onFilterCollapsedChange, filterHeaderSummary, brand, code, baseItem, baseContentTypes, cellCapacity, items, onSaveComplete, onLoad, onRemoveItem, onReset, resetLabel, saveButtonLabel, secondarySaveButtonLabel, onReorder, showCellCount, onAddItem, className, renderSavePopup, renderWordSearch, hideControls, saveOnly, tableName, nameValue, onNameChange, descriptionValue, onDescriptionChange, namePlaceholder, descriptionPlaceholder, existingNames, editingName, onCancel, initialItemsPerPage, renderCellAction, actionsLeftExtra }) {
|
|
49
48
|
const { t } = useTranslation();
|
|
50
49
|
const resolvedResetLabel = resetLabel ?? t('wordPrint.clearAllSelection', '모두 선택 해제');
|
|
51
50
|
const isEditable = items === undefined;
|
|
@@ -107,8 +106,8 @@ export default function WordTableBlock({ title, titleIcon, disc, filterTitle, fi
|
|
|
107
106
|
const handleCloseWordSearch = useCallback(() => setActiveCell(null), [setActiveCell]);
|
|
108
107
|
/* onAddItem 의 "추가하기" 는 빈 칸에 선다 — 표시 모드에서 빈 칸은 showCellCount 로 칸 수를 늘릴 때만 생긴다.
|
|
109
108
|
둘을 함께 주지 않으면 아무것도 안 떠서 조용히 헛돈다. */
|
|
110
|
-
if (onAddItem && !isEditable && !showCellCount) {
|
|
111
|
-
devWarnOnce('word-table-block-add-without-cell-count', '[WordTableBlock] 표시 모드에서 onAddItem 은 showCellCount 와 함께 줘야 "추가하기" 칸이 생긴다.');
|
|
109
|
+
if (onAddItem && !isEditable && !showCellCount && !cellCapacity) {
|
|
110
|
+
devWarnOnce('word-table-block-add-without-cell-count', '[WordTableBlock] 표시 모드에서 onAddItem 은 cellCapacity 나 showCellCount 와 함께 줘야 "추가하기" 칸이 생긴다.');
|
|
112
111
|
}
|
|
113
112
|
/* 머리 칸은 표시 모드에서만 선다 — 편집 격자에 주면 아무 데서도 안 터지고 **그냥 안 보인다** */
|
|
114
113
|
if (baseItem && isEditable) {
|
|
@@ -119,20 +118,31 @@ export default function WordTableBlock({ title, titleIcon, disc, filterTitle, fi
|
|
|
119
118
|
담았다 3개로 줄여도 8칸이 남았다. 처음 값은 처음 항목 수 — 고르기 전에 하나를 빼도 표가 한 칸 줄어 흔들리지 않게. */
|
|
120
119
|
const [chosenCellCount, setChosenCellCount] = useState(() => Math.max(items?.length ?? 1, 1));
|
|
121
120
|
// 레이아웃 칸 수
|
|
121
|
+
/* **채울 수 있는 칸 수** — 항목보다 많으면 그 차이가 빈 칸이 된다(`cellCapacity`, 청 (327)).
|
|
122
|
+
담긴 것을 가릴 수는 없으니 항목 수가 바닥이다. */
|
|
123
|
+
const capacity = Math.max(cellCapacity ?? 0, items?.length ?? 0, 1);
|
|
122
124
|
const count = isEditable
|
|
123
125
|
? cellCount
|
|
124
126
|
: showCellCount
|
|
125
127
|
? Math.max(chosenCellCount, items?.length ?? 1, 1)
|
|
126
|
-
:
|
|
128
|
+
: capacity;
|
|
127
129
|
const { width, height } = WORD_TABLE_PAPER[orientation];
|
|
128
130
|
// 페이지 분할 — 편집/칸수조절(showCellCount) 모드에서는 적용하지 않고, 완성된 표시 모드에서만 적용
|
|
129
131
|
const pagesEnabled = !isEditable && !showCellCount;
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
132
|
+
/* '페이지당 개수' 첫 옵션은 늘 **자리 수**(= 한 쪽에 전부), 나머지는 그보다 작은 표준 분할값.
|
|
133
|
+
기본/저장된 설정(8)이 자리 수보다 크면 전체로 조인다 — 다섯 자리뿐이면 "5개(전부)" 가 기본.
|
|
134
|
+
|
|
135
|
+
**항목 수가 아니라 자리 수로 조인다**(청 (327)). 항목이 하나뿐인 열두 칸짜리 표를
|
|
136
|
+
항목 수로 조이면 한 쪽에 한 칸씩 **열두 쪽**이 된다. `cellCapacity` 를 안 주면
|
|
137
|
+
자리 수 = 항목 수라 지금까지와 같다. */
|
|
138
|
+
const effectiveItemsPerPage = Math.min(itemsPerPageSetting, Math.max(capacity, 1));
|
|
134
139
|
const itemsPerPage = pagesEnabled ? effectiveItemsPerPage : count;
|
|
135
|
-
|
|
140
|
+
/* 쪽은 **항목이 아니라 자리**로 센다 — 빈 칸만 남은 쪽도 서야 '추가하기' 가 닿는다.
|
|
141
|
+
항목이 모자란 쪽은 빈 배열을 받는다. */
|
|
142
|
+
const pageCount = pagesEnabled ? Math.max(1, Math.ceil(capacity / Math.max(1, itemsPerPage))) : 0;
|
|
143
|
+
const pages = pagesEnabled
|
|
144
|
+
? Array.from({ length: pageCount }, (_, i) => (items ?? []).slice(i * itemsPerPage, (i + 1) * itemsPerPage))
|
|
145
|
+
: null;
|
|
136
146
|
const isPaginated = !!pages && pages.length > 1;
|
|
137
147
|
const hasPairs = isEditable
|
|
138
148
|
? visibleCells.some(c => c !== null && c.length > 1)
|
|
@@ -179,13 +189,18 @@ export default function WordTableBlock({ title, titleIcon, disc, filterTitle, fi
|
|
|
179
189
|
/* 물어볼 낱말이 있는지는 **렌더 중에 안다** — 굳이 상태로 들고 있을 것이 아니다.
|
|
180
190
|
이걸 상태로 두면 "없음"으로 되돌리는 일을 효과가 해야 하고, 그러면 낡은 값으로
|
|
181
191
|
한 번 그린 뒤에 고쳐진다. */
|
|
192
|
+
/* **머리 칸도 센다**(말귀 청 (329), 2026-10-28 — 사장님 *"이거 왜 비활성화 되어 있어?
|
|
193
|
+
왼쪽 칸에 이미지 있는데?"*). 활용표는 그림이 머리 칸에만 있다 — 나머지 절반은 사전에
|
|
194
|
+
없는 활용형이라 그림이 없다. `items` 만 세면 전부 헛쳐서 **왼쪽 절반에 그림이 떡하니
|
|
195
|
+
떠 있는데 '이미지' 칩만 회색**이 된다. `baseItem` 은 `items` 와 같은 꼴이라 그대로 잇는다. */
|
|
182
196
|
const imagePairs = useMemo(() => {
|
|
183
197
|
if (!getImageResolver())
|
|
184
198
|
return [];
|
|
199
|
+
const pairsOf = (list) => list.flatMap(item => (item.words ?? []).map(w => [w.label, w.homonum]));
|
|
185
200
|
return isEditable
|
|
186
201
|
? cells.slice(0, cellCount).flatMap(c => (c ?? []).map(e => [e.word, e.homonum]))
|
|
187
|
-
: (
|
|
188
|
-
}, [isEditable, cells, cellCount, items]);
|
|
202
|
+
: pairsOf([...(baseItem ? [baseItem] : []), ...(items ?? [])]);
|
|
203
|
+
}, [isEditable, cells, cellCount, items, baseItem]);
|
|
189
204
|
/* 실제로 파일이 있는지는 물어봐야 안다(HEAD 요청 + 캐시). 그 답만 상태로 든다.
|
|
190
205
|
`imagePairs` 가 비면 물어볼 것도 없으므로 아래 유도에서 곧바로 false 가 된다. */
|
|
191
206
|
const [imageFound, setImageFound] = useState(false);
|
|
@@ -205,11 +220,11 @@ export default function WordTableBlock({ title, titleIcon, disc, filterTitle, fi
|
|
|
205
220
|
const middleSections = useMemo(() => [
|
|
206
221
|
...((isEditable || showCellCount) ? [{ label: t('wordTable.filter.columns', '칸 수'), items: CELL_COUNTS.map(n => ({ value: `${n}칸`, displayLabel: t('wordTable.filter.column', { count: n }) })), display: 'segmented' }] : []),
|
|
207
222
|
// 내용이 있는(1개 이상) 표면 '페이지당 대립쌍/단어 수'를 항상 노출한다(표시 모드 한정).
|
|
208
|
-
...(pagesEnabled && (items?.length ?? 0) > 0 ? [buildItemsPerPageSection(t, { hasPairs, itemCount })] : []),
|
|
223
|
+
...(pagesEnabled && (items?.length ?? 0) > 0 ? [buildItemsPerPageSection(t, { hasPairs, itemCount: capacity })] : []),
|
|
209
224
|
/* 이 블록은 종이 띠를 안 받는다 — 쪽 번호가 설 데가 여기뿐이라 자리 고르개를 그대로 둔다
|
|
210
225
|
(띠를 쓰는 `WordTable` 쪽만 이 절을 걷는다). */
|
|
211
226
|
...(isPaginated ? [buildPageNumberSection(t)] : []),
|
|
212
|
-
], [t, isEditable, showCellCount, pagesEnabled, items?.length, hasPairs,
|
|
227
|
+
], [t, isEditable, showCellCount, pagesEnabled, items?.length, hasPairs, capacity, isPaginated]);
|
|
213
228
|
const middleSelected = {
|
|
214
229
|
...((isEditable || showCellCount) ? { [t('wordTable.filter.columns', '칸 수')]: `${count}칸` } : {}),
|
|
215
230
|
...(pagesEnabled && (items?.length ?? 0) > 0 ? { [t(hasPairs ? 'wordTable.filter.itemsPerPagePair' : 'wordTable.filter.itemsPerPageWord')]: `${effectiveItemsPerPage}개` } : {}),
|
|
@@ -225,7 +240,7 @@ export default function WordTableBlock({ title, titleIcon, disc, filterTitle, fi
|
|
|
225
240
|
setChosenCellCount(parseInt(value));
|
|
226
241
|
}
|
|
227
242
|
else if (sectionLabel === t(hasPairs ? 'wordTable.filter.itemsPerPagePair' : 'wordTable.filter.itemsPerPageWord')) {
|
|
228
|
-
setItemsPerPageSetting(itemsPerPageFromChoice(parseInt(value),
|
|
243
|
+
setItemsPerPageSetting(itemsPerPageFromChoice(parseInt(value), capacity));
|
|
229
244
|
}
|
|
230
245
|
else if (sectionLabel === t('wordTable.filter.pageNumber', '페이지 번호')) {
|
|
231
246
|
setPageNumberPosition(parsePageNumberPosition(value));
|
|
@@ -339,7 +354,14 @@ export default function WordTableBlock({ title, titleIcon, disc, filterTitle, fi
|
|
|
339
354
|
onReorder: onReorder && ((from, to) => onReorder(from + i * itemsPerPage, to + i * itemsPerPage)),
|
|
340
355
|
/* 안쪽 표는 제 쪽 안의 번호를 준다 — 부르는 쪽에는 **표 전체 기준**으로 넘긴다
|
|
341
356
|
(위 `onReorder` 와 같은 셈이다. 쪽이 몇으로 나뉘었는지는 부르는 쪽 일이 아니다). */
|
|
342
|
-
renderCellAction: renderCellAction && ((n, item) => renderCellAction(n + i * itemsPerPage, item)),
|
|
357
|
+
renderCellAction: renderCellAction && ((n, item) => renderCellAction(n + i * itemsPerPage, item)),
|
|
358
|
+
/* **빈 칸과 '추가하기' 는 쪽이 나뉘어도 선다**(청 (327)) — 전에는 한 장짜리 가지에만
|
|
359
|
+
실려 있어 쪽이 둘이 되는 순간 단추가 조용히 사라졌다. 칸 번호는 위 둘과 같은 셈으로
|
|
360
|
+
**표 전체 기준**으로 올린다. */
|
|
361
|
+
showFillerAdd: !!onAddItem, onActivateCell: onAddItem ? (n => setActiveCell(n + i * itemsPerPage)) : undefined,
|
|
362
|
+
/* 칸 크기가 쪽마다 같아야 해서 `count` 는 모든 쪽이 '페이지당 개수' 다 —
|
|
363
|
+
채울 자리는 마지막 쪽에서 모자랄 수 있으니 그것만 따로 센다. */
|
|
364
|
+
addableCount: Math.max(0, Math.min(itemsPerPage, capacity - i * itemsPerPage)), brand: band, code: code, contentRef: el => { pageRefs.current[i] = el; }, pageNumber: { current: i + 1, total: pages.length }, pageNumberPosition: pageNumberPosition }, i))) })) : (_jsx(WordTable, { orientation: orientation, contentTypes: contentTypes, cutLine: cutLine, showOutline: showOutline, showDivLine: showDivLine, count: count, items: isEditable ? undefined : (items ?? []), baseItem: isEditable ? undefined : baseItem, baseContentTypes: baseContentTypes, editCells: isEditable ? visibleCells : undefined, activeCell: activeCell, onActivateCell: (isEditable || onAddItem) ? setActiveCell : undefined, onRemoveCell: isEditable ? handleRemove : undefined, onRemoveItem: !isEditable ? onRemoveItem : undefined, onReorder: !isEditable ? onReorder : undefined,
|
|
343
365
|
/* 편집 모드에는 얹을 항목이 없다 — 칸을 손으로 채우는 꼴이다 */
|
|
344
366
|
renderCellAction: !isEditable ? renderCellAction : undefined, brand: band, code: code, showFillerAdd: !!onAddItem, contentRef: contentRef })), !hideControls && !saveOnly && actionsLeftExtra != null && (_jsx("div", { className: "word-table-block__table-actions", children: actionsLeftExtra })), inlineNameFields && !hideControls && (_jsxs(Panel, { size: "medium", labelWidth: 64, useBorder: false, useRowBorder: false, className: "word-table-block__meta", children: [_jsx(PanelRow, { variant: "custom", label: t('wordTable.save.nameLabel', '이름'), required: true, align: "vertical", useFullWidth: true, children: _jsx(TextField, { required: true, value: nameValue ?? '', onChange: onNameChange, placeholder: namePlaceholder ? namePlaceholder + t('wordTable.save.autoFillHint', ' (Tab 또는 space 입력시 자동 입력)') : t('wordTable.save.placeholder', '이 단어표에 대한 제목을 입력하세요.'),
|
|
345
367
|
/* PanelRow의 라벨은 시각적으로만 붙어 있고 입력과 연결돼 있지 않아, 낭독기에는
|
|
@@ -76,6 +76,21 @@ export interface WordTableBlockProps {
|
|
|
76
76
|
baseItem?: WordTableProps['baseItem'];
|
|
77
77
|
/** 머리 칸에만 걸리는 보임 — 안 주면 표 설정 판에서 고른 `contentTypes` 를 따른다. */
|
|
78
78
|
baseContentTypes?: WordTableProps['baseContentTypes'];
|
|
79
|
+
/**
|
|
80
|
+
* **이 표가 채울 수 있는 칸 수** — 항목 수보다 크면 그만큼 빈 칸이 생기고,
|
|
81
|
+
* `onAddItem` 이 있으면 그 칸 가운데에 '추가하기' 가 선다.
|
|
82
|
+
*
|
|
83
|
+
* 활용표처럼 **칸 수를 사람이 아니라 낱말이 정하는 표**를 위해 둔다(말귀 청 (327),
|
|
84
|
+
* 2026-10-28). 전에는 빈 칸을 내는 길이 `showCellCount` 뿐이었는데 그것은 값이 비쌌다 —
|
|
85
|
+
* '칸 수' 고르개를 세우고 **쪽 나눔을 통째로 껐다.** 이것은 둘 다 안 한다.
|
|
86
|
+
*
|
|
87
|
+
* 쪽이 나뉘면 빈 칸은 **뒤쪽 쪽에** 선다. 쪽 수는 `올림(cellCapacity / 페이지당 개수)` 이라,
|
|
88
|
+
* 항목이 모자라도 채울 자리가 남아 있으면 그만큼 쪽이 더 선다.
|
|
89
|
+
*
|
|
90
|
+
* 항목 수보다 작으면 무시한다 — 담긴 것을 가릴 수는 없다. `showCellCount` 와 함께 주면
|
|
91
|
+
* 그쪽이 이긴다(사람이 고른 것이 마지막 말이다).
|
|
92
|
+
*/
|
|
93
|
+
cellCapacity?: number;
|
|
79
94
|
disc?: ReactNode;
|
|
80
95
|
/** 현재 표의 저장된 이름(불러온 표 등). 있으면 인쇄/PDF 저장 시 파일명으로 사용, 없으면 "오늘 날짜 + 단어표/대립쌍표" */
|
|
81
96
|
tableName?: string;
|
|
@@ -52,6 +52,15 @@ export interface WordTableProps {
|
|
|
52
52
|
onReorder?: (fromIndex: number, toIndex: number) => void;
|
|
53
53
|
/** 표시 모드에서 `count` 안의 빈칸(항목 수 뒤 ~ count)에 '추가' 버튼 노출. count 가 항목 수와 같으면 그런 칸이 없다. `onActivateCell` 필요. */
|
|
54
54
|
showFillerAdd?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* '추가하기' 가 설 수 있는 칸 수 — 안 주면 `count` 를 따른다.
|
|
57
|
+
*
|
|
58
|
+
* 쪽이 나뉜 표의 **마지막 쪽**을 위해 둔다(말귀 청 (327), 2026-10-28). 쪽마다 칸 크기가
|
|
59
|
+
* 같아야 해서 `count` 는 모든 쪽이 '페이지당 개수' 로 같은데, 채울 자리는 마지막 쪽에서
|
|
60
|
+
* 모자랄 수 있다(자리 12 · 쪽당 8 → 둘째 쪽은 네 자리뿐). `count` 로 세면 **없는 자리에도
|
|
61
|
+
* 단추가 선다.**
|
|
62
|
+
*/
|
|
63
|
+
addableCount?: number;
|
|
55
64
|
/**
|
|
56
65
|
* **칸 오른쪽 위에 부르는 쪽이 얹는 것** — 칸 번호와 그 칸의 항목을 준다. 안 주면 아무것도 안 얹는다.
|
|
57
66
|
*
|
|
@@ -202,4 +211,4 @@ export interface WordTableProps {
|
|
|
202
211
|
* 표시(items)·편집(editCells) 두 모드를 지원한다.
|
|
203
212
|
* @public
|
|
204
213
|
*/
|
|
205
|
-
export default function WordTable({ title, titleIcon, disc, className, orientation, contentTypes, baseItem, baseContentTypes, cutLine, showOutline, showDivLine, items, editCells, count, activeCell, onActivateCell, onRemoveCell, onRemoveItem, onReorder, renderCellAction, showFillerAdd, contentRef, buttonSize, brand, code, pageNumber, pageNumberPosition, fitHeight, scoring, marks, onMarkClick, scoreIndexOffset, }: WordTableProps): import("react").JSX.Element;
|
|
214
|
+
export default function WordTable({ title, titleIcon, disc, className, orientation, contentTypes, baseItem, baseContentTypes, cutLine, showOutline, showDivLine, items, editCells, count, activeCell, onActivateCell, onRemoveCell, onRemoveItem, onReorder, renderCellAction, showFillerAdd, addableCount, contentRef, buttonSize, brand, code, pageNumber, pageNumberPosition, fitHeight, scoring, marks, onMarkClick, scoreIndexOffset, }: WordTableProps): import("react").JSX.Element;
|
|
@@ -54,6 +54,10 @@ function WordCell({ label, subLabel, colloquialLabel, captionLabel, homonum, sho
|
|
|
54
54
|
const audioRef = useRef(null);
|
|
55
55
|
const [scale, setScale] = useState(1);
|
|
56
56
|
const [playing, setPlaying] = useState(false);
|
|
57
|
+
/* **받아 오는 중** — `playing` 과 따로 둔다(말귀 청 (330), 2026-10-28). 전에는 합성을
|
|
58
|
+
기다리는 동안에도 `playing` 만 세워, 단추가 곧바로 '멈춤' 이 되는데 소리는 한참 뒤에
|
|
59
|
+
났다. 사람 눈에는 *눌렀는데 멈춰 있는* 꼴이다(실측 처음 3,567ms · 캐시 772ms). */
|
|
60
|
+
const [waiting, setWaiting] = useState(false);
|
|
57
61
|
/* 받은 주소에 **어느 낱말의 것인지** 를 함께 둔다 — 주소만 들고 있으면 같은 칸의 낱말이 바뀐 뒤 새 주소를 받는 동안(또는
|
|
58
62
|
못 받으면) 누를 때 앞 낱말 소리가 났다(틀린 자극). 지금 낱말의 것일 때만 쓴다. */
|
|
59
63
|
const [fetchedAudio, setFetchedAudio] = useState({ for: '', url: '' });
|
|
@@ -87,6 +91,18 @@ function WordCell({ label, subLabel, colloquialLabel, captionLabel, homonum, sho
|
|
|
87
91
|
}, [wordInfo, t]);
|
|
88
92
|
const audioKey = pron || label;
|
|
89
93
|
const audioUrl = fetchedAudio.for === audioKey ? fetchedAudio.url : '';
|
|
94
|
+
/* **칸은 낱말마다 한 번만 묻는다.** 받은 답이 뒤에 나아져도 다시 묻지 않는다.
|
|
95
|
+
말귀가 (326) 뒤에 그 자리를 밟았다(2026-10-28): 그쪽 음원 색인은 *낱말 소리를 처음
|
|
96
|
+
찾는 순간* 뒤에서 받는데, 활용표에서는 그 '처음' 이 **표를 그리는 그 순간**이라 칸이
|
|
97
|
+
색인보다 앞에 섰다. 색인 앞에서는 주소가 '없다' 가 아니라 '모른다' 라 규약으로 지은
|
|
98
|
+
주소가 나가고, 그것이 400 이었다 — **빈 글자가 아니므로 아래 폴백도 안 돈다.**
|
|
99
|
+
훈련 카드는 틀어 보고 실패하면 폴백으로 가니 넘어가는데, 표의 칸은 그 주소를 한 번
|
|
100
|
+
받아 그대로 눌러앉았다(열두 칸 모두 400).
|
|
101
|
+
말귀는 쪽이 열릴 때 색인을 미리 받는 것으로 막았다. 코어에는 *"답이 나아졌다"* 를
|
|
102
|
+
들을 길이 없으니(`clearAudioExistsCache` 는 '음성 있음' 거르개의 것이지 이 자리의
|
|
103
|
+
것이 아니다) 여기서 고칠 수 있는 것이 아니다 — **밟을 수 있는 자리라는 것만 적어
|
|
104
|
+
둔다.** 리졸버가 때에 따라 다른 답을 주는 곳이면, 표를 그리기 전에 그 때를 지나 둬야
|
|
105
|
+
한다. */
|
|
90
106
|
useEffect(() => {
|
|
91
107
|
const resolver = getTTSUrlResolver();
|
|
92
108
|
const ttsText = pron || label;
|
|
@@ -128,7 +144,9 @@ function WordCell({ label, subLabel, colloquialLabel, captionLabel, homonum, sho
|
|
|
128
144
|
playReqRef.current.cancelled = true; }, []);
|
|
129
145
|
const handlePlay = useCallback((e) => {
|
|
130
146
|
e.stopPropagation();
|
|
131
|
-
|
|
147
|
+
/* **기다리는 중에 누르면 기다림이 접힌다**(청 (330)) — `playing` 만 보면 그때 손이
|
|
148
|
+
`stop` 에 안 닿아 **합성이 한 번 더 나간다.** 둘 다 본다. */
|
|
149
|
+
if (playing || waiting) {
|
|
132
150
|
stopRef.current?.();
|
|
133
151
|
return;
|
|
134
152
|
}
|
|
@@ -145,12 +163,13 @@ function WordCell({ label, subLabel, colloquialLabel, captionLabel, homonum, sho
|
|
|
145
163
|
const stop = () => {
|
|
146
164
|
req.cancelled = true;
|
|
147
165
|
req.stop?.();
|
|
166
|
+
setWaiting(false);
|
|
148
167
|
setPlaying(false);
|
|
149
168
|
releaseRef.current?.();
|
|
150
169
|
};
|
|
151
170
|
stopRef.current = stop;
|
|
152
171
|
releaseRef.current = claimSound(stop);
|
|
153
|
-
|
|
172
|
+
setWaiting(true);
|
|
154
173
|
void Promise.resolve()
|
|
155
174
|
.then(() => fallback(ttsText))
|
|
156
175
|
.then(url => {
|
|
@@ -166,6 +185,10 @@ function WordCell({ label, subLabel, colloquialLabel, captionLabel, homonum, sho
|
|
|
166
185
|
const sound = playOneShot(url, () => { setPlaying(false); releaseRef.current?.(); });
|
|
167
186
|
audioRef.current = sound.el;
|
|
168
187
|
req.stop = sound.stop;
|
|
188
|
+
/* 소리가 생긴 **그때** 기다림이 끝난다 — 둘을 한 번에 바꾸면 도는 표시가 한 틱
|
|
189
|
+
더 남거나 '멈춤' 이 한 틱 먼저 선다. */
|
|
190
|
+
setWaiting(false);
|
|
191
|
+
setPlaying(true);
|
|
169
192
|
})
|
|
170
193
|
.catch(() => { stop(); });
|
|
171
194
|
return;
|
|
@@ -183,7 +206,7 @@ function WordCell({ label, subLabel, colloquialLabel, captionLabel, homonum, sho
|
|
|
183
206
|
stopRef.current = sound.stop;
|
|
184
207
|
/* 자물쇠를 잡으면 앞서 울리던 것(다른 칸·훈련 카드 등)이 멈추고, 남이 잡으면 stop 이 불려 내가 멈춘다 */
|
|
185
208
|
releaseRef.current = claimSound(sound.stop);
|
|
186
|
-
}, [playing, audioUrl, pron, label]);
|
|
209
|
+
}, [playing, waiting, audioUrl, pron, label]);
|
|
187
210
|
const hasImage = showImage && !!imageUrl && !imgFailed;
|
|
188
211
|
const refW = hasImage && showWord ? REF_W_BOTH : hasImage ? REF_W_IMAGE_ONLY : REF_W_TEXT_ONLY;
|
|
189
212
|
const refH = hasImage && showWord ? REF_H_BOTH : hasImage ? REF_H_IMAGE_ONLY : REF_H_TEXT_ONLY;
|
|
@@ -228,7 +251,7 @@ function WordCell({ label, subLabel, colloquialLabel, captionLabel, homonum, sho
|
|
|
228
251
|
* 안 곱하면 또 조용히 헛돈다.
|
|
229
252
|
*/
|
|
230
253
|
const tapTooSmall = buttonSize * outerScale < MIN_TAP_PX;
|
|
231
|
-
return (_jsxs("div", { ref: outerRef, className: cx('word-table-cell', tapTooSmall && 'word-table-cell--tap-too-small', hasImage ? 'word-table-cell--with-image' : ''), "data-ref-w": refW, "data-ref-h": refH, children: [_jsxs("div", { className: "word-table-cell__inner", style: { transform: `scale(${scale})` }, children: [hasImage && (_jsxs("div", { className: "word-table-cell__image-wrap", children: [imgLoading && _jsx("div", { className: "word-table-cell__spinner" }), _jsx("img", { ref: imgRef, className: "word-table-cell__image", src: imageUrl, alt: label, draggable: false, style: { opacity: imgLoading ? 0 : 1 }, onLoad: handleImgLoad, onError: handleImgError })] })),
|
|
254
|
+
return (_jsxs("div", { ref: outerRef, className: cx('word-table-cell', tapTooSmall && 'word-table-cell--tap-too-small', hasImage ? 'word-table-cell--with-image' : ''), "data-ref-w": refW, "data-ref-h": refH, children: [_jsxs("div", { className: "word-table-cell__inner", style: { transform: `scale(${scale})` }, children: [hasImage && (_jsxs("div", { className: "word-table-cell__image-wrap", children: [imgLoading && _jsx("div", { className: "word-table-cell__spinner" }), _jsx("img", { ref: imgRef, className: "word-table-cell__image", src: imageUrl, alt: label, draggable: false, style: { opacity: imgLoading ? 0 : 1 }, onLoad: handleImgLoad, onError: handleImgError })] })), captionLabel && _jsx("span", { className: "word-table-cell__caption h5", children: captionLabel }), showWord && _jsx("span", { className: "word-table-cell__word h0", children: label }), showPronunciation && pron && _jsxs("span", { className: "word-table-cell__sub h3", children: ["[", pron, "]"] }), showColloquial && colloquialLabel && _jsxs("span", { className: "word-table-cell__colloquial h5", children: ["[", colloquialLabel, "]"] })] }), _jsxs("div", { className: "word-table-cell__play-button", "data-audio-src": audioUrl, children: [_jsx("span", { "data-play-state": "play", style: { display: playing ? 'none' : undefined }, children: _jsx(Button, { htmlType: "button", size: buttonSize, type: "dot", icon: "play", variant: "transparent-lightGray", useBorder: false, loading: waiting, showTooltipInfo: waiting ? t('common.loading', '불러오는 중') : t('common.play', '재생'), ariaLabel: label ? t('common.playFor', { name: label, defaultValue: `${label} 재생` }) : t('common.play', '재생'), onClick: handlePlay }) }), _jsx("span", { "data-play-state": "pause", style: { display: playing ? undefined : 'none' }, children: _jsx(Button, { htmlType: "button", size: buttonSize, type: "dot", icon: "pause", useBorder: false, selected: true, showTooltipInfo: t('common.pause', '멈춤'), ariaLabel: label ? t('common.pauseFor', { name: label, defaultValue: `${label} 멈춤` }) : t('common.pause', '멈춤'), onClick: handlePlay }) })] }), wordInfo && (_jsxs("div", { ref: infoRef, className: "word-table-cell__info-button", onPointerEnter: (e) => { if (!isTouchPointer(e))
|
|
232
255
|
handleInfoEnter(); }, onPointerLeave: (e) => { if (!isTouchPointer(e))
|
|
233
256
|
handleInfoLeave(); },
|
|
234
257
|
// 이 div 자체는 포커스 대상이 아니지만 안의 Button이 포커스를 받으면
|
|
@@ -246,7 +269,7 @@ function WordCell({ label, subLabel, colloquialLabel, captionLabel, homonum, sho
|
|
|
246
269
|
* 표시(items)·편집(editCells) 두 모드를 지원한다.
|
|
247
270
|
* @public
|
|
248
271
|
*/
|
|
249
|
-
export default function WordTable({ title, titleIcon, disc, className, orientation = 'landscape', contentTypes = ['image', 'word', 'standardPron'], baseItem, baseContentTypes, cutLine = 'show', showOutline = true, showDivLine = true, items, editCells, count, activeCell = null, onActivateCell, onRemoveCell, onRemoveItem, onReorder, renderCellAction, showFillerAdd = false, contentRef, buttonSize = 40, brand, code, pageNumber, pageNumberPosition = 'right', fitHeight = false, scoring = false, marks, onMarkClick, scoreIndexOffset = 0, }) {
|
|
272
|
+
export default function WordTable({ title, titleIcon, disc, className, orientation = 'landscape', contentTypes = ['image', 'word', 'standardPron'], baseItem, baseContentTypes, cutLine = 'show', showOutline = true, showDivLine = true, items, editCells, count, activeCell = null, onActivateCell, onRemoveCell, onRemoveItem, onReorder, renderCellAction, showFillerAdd = false, addableCount, contentRef, buttonSize = 40, brand, code, pageNumber, pageNumberPosition = 'right', fitHeight = false, scoring = false, marks, onMarkClick, scoreIndexOffset = 0, }) {
|
|
250
273
|
const clickMark = useCallback((cellIndex, clicked) => {
|
|
251
274
|
onMarkClick?.(scoreIndexOffset + cellIndex, clicked);
|
|
252
275
|
}, [onMarkClick, scoreIndexOffset]);
|
|
@@ -563,7 +586,7 @@ export default function WordTable({ title, titleIcon, disc, className, orientati
|
|
|
563
586
|
}) }) })), (renderCellAction || onRemoveItem) && (
|
|
564
587
|
/* 오른쪽 위 한 줄 — 부르는 쪽이 얹은 것과 빼기가 나란히 선다(지우는 것이 끝) */
|
|
565
588
|
_jsxs("div", { className: "word-table-block__card-actions", children: [renderCellAction?.(index, item), onRemoveItem && (_jsx("div", { className: "word-table-block__card-close", children: _jsx(Button, { htmlType: "button", size: buttonSize, type: "dot", icon: "x", variant: "transparent-lightGray", useBorder: false, showTooltipInfo: (item.words ?? []).length > 1 ? t('wordPrint.removePair', '대립쌍 빼기') : t('wordPrint.removeWord', '단어 빼기'), ariaLabel: (item.words ?? []).length > 1 ? t('wordPrint.removePair', '대립쌍 빼기') : t('wordPrint.removeWord', '단어 빼기'), onClick: () => onRemoveItem(item.id) }) }))] }))] }, index))), Array.from({ length: Math.max(0, itemCols * itemRows - (items?.length ?? 0)) }).map((_, i) => {
|
|
566
|
-
const isWithinCount = (items?.length ?? 0) + i < cellCount;
|
|
589
|
+
const isWithinCount = (items?.length ?? 0) + i < (addableCount ?? cellCount);
|
|
567
590
|
return (_jsx("div", { className: "word-table-block__card word-table-block__card--filler", children: showFillerAdd && onActivateCell && isWithinCount && (_jsx("div", { style: counterScale, children: _jsx(Button, { htmlType: "button", size: buttonSize, type: "bar", icon: "plus", label: t('wordTable.addWord', '추가하기'), onClick: () => onActivateCell((items?.length ?? 0) + i) }) })) }, `filler-${i}`));
|
|
568
591
|
})] })), showTopBand && (_jsx(_Fragment, { children: _jsxs("div", { className: "word-table__band word-table__band--top", children: [_jsx("img", { className: "word-table__brand-logo", src: brand?.topLogo?.src ?? speechearLogo, alt: brand?.topLogo?.alt ?? '말귀' }), (() => {
|
|
569
592
|
/* 표 제목 · 기관 이름 · 표 번호 — 있는 것끼리만 가운뎃점으로 잇는다
|
|
@@ -90,6 +90,23 @@ export interface ButtonProps {
|
|
|
90
90
|
/** 이 단추가 여닫는 영역의 id — `aria-controls` 로 단다(`ariaExpanded` 와 함께 쓴다) */
|
|
91
91
|
ariaControls?: string;
|
|
92
92
|
disabled?: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* **기다리는 중** — 아이콘 자리에 도는 표시(`Loader variant="spinner"`)가 서고 다시 눌리지 않는다.
|
|
95
|
+
*
|
|
96
|
+
* 소리 단추가 쥐는 때는 **셋**인데 꼴은 둘뿐이었다 — `재생`/`멈춤` 만 있고 *받아 오는 중*
|
|
97
|
+
* 이 없었다(말귀 청 (330), 2026-10-28). 음원이 없는 낱말은 누른 뒤 합성을 기다리는데
|
|
98
|
+
* (실측 처음 3,567ms · 캐시가 있을 때 772ms), 그동안 단추가 곧바로 '멈춤' 이 되어
|
|
99
|
+
* **눌렀는데 멈춰 있는** 꼴로 보였다.
|
|
100
|
+
*
|
|
101
|
+
* **보이는 꼴만 바꾼다 — 손은 그대로 받는다.** 막으려면 `disabled` 를 함께 준다.
|
|
102
|
+
*
|
|
103
|
+
* 막는 것까지 여기 묶지 않은 까닭은, 기다리는 단추를 누르는 뜻이 자리마다 갈려서다.
|
|
104
|
+
* 저장 단추는 **아무 일도 안 나야** 하고(두 번 누르면 두 번 저장된다), 소리 단추는
|
|
105
|
+
* **기다림을 접어야** 한다(옆 칸을 누르거나 마음이 바뀐다). 하나의 참/거짓으로 둘을 다
|
|
106
|
+
* 말할 수 없다 — 그래서 *보이는 꼴*만 맡고, 막는 일은 이미 그 일을 하는 `disabled` 에
|
|
107
|
+
* 둔다. 빠져나갈 구멍을 하나 더 뚫는 것보다 **뜻이 하나씩인 쪽**이 낫다.
|
|
108
|
+
*/
|
|
109
|
+
loading?: boolean;
|
|
93
110
|
/** label을 숨기려면 false로 설정 */
|
|
94
111
|
useLabel?: boolean;
|
|
95
112
|
useBorder?: boolean;
|