@ihabdevteam/core 0.437.0 → 0.440.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 +58 -0
- package/README.md +3 -3
- package/dist/components.cjs.js +196 -186
- package/dist/components.esm.css +3 -3
- package/dist/hooks.cjs.js +5 -5
- package/dist/i18n.cjs.js +3 -3
- package/dist/ihabdevteam-core.cjs.js +195 -185
- package/dist/ihabdevteam-core.d.ts +317 -6
- package/dist/packages/core/src/components/Breadcrumb.css +52 -0
- package/dist/packages/core/src/components/Breadcrumb.d.ts +19 -1
- package/dist/packages/core/src/components/Breadcrumb.js +12 -4
- package/dist/packages/core/src/components/Button.css +9 -2
- package/dist/packages/core/src/components/Dropdown.css +2 -1
- package/dist/packages/core/src/components/FolderGrid.css +28 -0
- package/dist/packages/core/src/components/FolderGrid.d.ts +47 -0
- package/dist/packages/core/src/components/FolderGrid.js +76 -0
- package/dist/packages/core/src/components/FolderHead.css +8 -0
- package/dist/packages/core/src/components/FolderHead.d.ts +42 -0
- package/dist/packages/core/src/components/FolderHead.js +62 -0
- package/dist/packages/core/src/components/FolderTreeButton.css +2 -0
- package/dist/packages/core/src/components/FolderTreeButton.d.ts +34 -0
- package/dist/packages/core/src/components/FolderTreeButton.js +44 -0
- package/dist/packages/core/src/components/Popup/ConfirmPopup.d.ts +8 -2
- package/dist/packages/core/src/components/Popup/ConfirmPopup.js +3 -3
- package/dist/packages/core/src/components/Popup/Popup.css +2 -0
- package/dist/packages/core/src/components/SideNav.css +8 -0
- package/dist/packages/core/src/components/SideNav.js +4 -1
- package/dist/packages/core/src/components/Tooltip/DescriptionTooltip.css +1 -1
- package/dist/packages/core/src/components/Tooltip/FolderTreeTooltip.css +99 -0
- package/dist/packages/core/src/components/Tooltip/FolderTreeTooltip.d.ts +60 -0
- package/dist/packages/core/src/components/Tooltip/FolderTreeTooltip.js +81 -0
- package/dist/packages/core/src/components/Tooltip/TextBoxTooltip.css +1 -1
- package/dist/packages/core/src/components/Tooltip/Tooltip.css +5 -1
- package/dist/packages/core/src/components/Tooltip/Tooltip.d.ts +6 -0
- package/dist/packages/core/src/components/Tooltip/Tooltip.js +10 -4
- package/dist/packages/core/src/components/Tooltip/TrainingTooltip.css +1 -0
- package/dist/packages/core/src/components/Tooltip/WordImageTooltip.css +1 -0
- package/dist/packages/core/src/components/Training/TrainingCard.css +45 -8
- package/dist/packages/core/src/components/Training/TrainingCard.d.ts +35 -2
- package/dist/packages/core/src/components/Training/TrainingCard.js +26 -5
- package/dist/packages/core/src/components.d.ts +8 -0
- package/dist/packages/core/src/components.js +5 -0
- package/dist/packages/core/src/i18n/locales/en.json +10 -0
- package/dist/packages/core/src/i18n/locales/ko.json +9 -0
- package/dist/packages/core/src/utils/folderPath.d.ts +50 -0
- package/dist/packages/core/src/utils/folderPath.js +98 -0
- package/dist/packages/core/src/utils/lucideIconSet.js +4 -0
- package/dist/packages/core/src/utils.d.ts +1 -0
- package/dist/packages/core/src/utils.js +2 -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 +175 -165
- package/package.json +3 -3
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import Tooltip from './Tooltip';
|
|
6
|
+
import Icon from '../Icon';
|
|
7
|
+
import { canMoveFolder, isInFolder } from '../../utils/folderPath';
|
|
8
|
+
import './FolderTreeTooltip.css';
|
|
9
|
+
/** 맨 위 줄의 열쇠 — 폴더 이름에는 빗금을 못 쓰니 겹칠 일이 없다 */
|
|
10
|
+
const ROOT = '/';
|
|
11
|
+
/**
|
|
12
|
+
* **폴더 구조를 나무로 띄우는 툴팁** — `MenuTooltip` 의 짝이다. 그쪽이 '할 일의 줄' 이라면 이쪽은 **'어디에 있나' 의 나무**다
|
|
13
|
+
* (말귀 청 (435), 사장님 지시 2026-11-13 *"menu 툴팁 사용하지말고 폴더 구조를 보여줄 수 있는 ui로 구성되도록 새로운 tooltip
|
|
14
|
+
* 만들어줘"*). 뜨는 통(그림자 · 모서리 · 자리 · 바깥 누름)은 `Tooltip` 그대로이고 속만 여기서 그린다: 줄마다 폴더 아이콘 ·
|
|
15
|
+
* 이름 · 든 수 · 접는 화살표가 서고, 층은 들여쓰기와 꺾쇠(└)다. 지금 자리는 옅은 바탕 · 굵은 글자 · 열린 폴더 아이콘으로 말한다.
|
|
16
|
+
*
|
|
17
|
+
* · **맨 위(뿌리)가 첫 줄**이다 — `rootLabel`. 고르면 `null` 을 돌려준다.
|
|
18
|
+
* · 하위 폴더가 있는 줄은 오른쪽 끝의 화살표로 **접고 편다**(처음엔 다 펴져 있다). 접힘은 이 통이 떠 있는 동안만 기억한다.
|
|
19
|
+
* · 줄을 고르면 `onPick` 을 부르고 **닫는다**(`onClose`). 닫을지는 부르는 쪽이 쥔다 — 통을 띄운 단추가 제 상태를 안다.
|
|
20
|
+
* · 아래로 펼친다(`prefer="bottom"`) — 위로 뜨면 쪽 제목을 덮는다.
|
|
21
|
+
*
|
|
22
|
+
* 띄우는 단추는 따로 있다(`FolderTreeButton`).
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
export default function FolderTreeTooltip({ anchorEl, onClose, rootLabel, opened, onPick, tree, ariaLabel, onMove, itemDropProps, itemDropOver, }) {
|
|
26
|
+
const { t } = useTranslation();
|
|
27
|
+
/** 접어 둔 폴더들 — 그 아래 줄은 안 선다 */
|
|
28
|
+
const [folded, setFolded] = useState(new Set());
|
|
29
|
+
const pick = (path) => { onPick(path); onClose(); };
|
|
30
|
+
/** 지금 끌고 있는 폴더 · 그것이 떠 있는 줄(맨 위 줄은 `ROOT`) */
|
|
31
|
+
const [dragging, setDragging] = useState(null);
|
|
32
|
+
const [over, setOver] = useState(null);
|
|
33
|
+
/** 그 줄을 놓을 자리로 만드는 손 — 못 놓는 자리면 아무것도 안 얹는다(금지 커서가 선다) */
|
|
34
|
+
const dropOn = (into) => {
|
|
35
|
+
/* 폴더를 끄는 중이 아니면 **카드가 놓일 자리**다(화면이 준 손) */
|
|
36
|
+
if (dragging === null)
|
|
37
|
+
return itemDropProps?.(into) ?? {};
|
|
38
|
+
if (!onMove || !canMoveFolder(dragging, into))
|
|
39
|
+
return {};
|
|
40
|
+
const key = into ?? ROOT;
|
|
41
|
+
return {
|
|
42
|
+
onDragOver: (e) => { e.preventDefault(); e.dataTransfer.dropEffect = 'move'; if (over !== key)
|
|
43
|
+
setOver(key); },
|
|
44
|
+
onDragLeave: () => setOver(now => (now === key ? null : now)),
|
|
45
|
+
onDrop: (e) => { e.preventDefault(); const from = dragging; setDragging(null); setOver(null); onMove(from, into); },
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
/** 폴더 줄을 쥐는 손 */
|
|
49
|
+
const dragFrom = (path) => (onMove ? {
|
|
50
|
+
draggable: true,
|
|
51
|
+
onDragStart: (e) => { e.dataTransfer.effectAllowed = 'move'; e.dataTransfer.setData('text/plain', path); setDragging(path); },
|
|
52
|
+
onDragEnd: () => { setDragging(null); setOver(null); },
|
|
53
|
+
} : {});
|
|
54
|
+
const toggle = (path) => setFolded(now => {
|
|
55
|
+
const next = new Set(now);
|
|
56
|
+
if (next.has(path))
|
|
57
|
+
next.delete(path);
|
|
58
|
+
else
|
|
59
|
+
next.add(path);
|
|
60
|
+
return next;
|
|
61
|
+
});
|
|
62
|
+
/* 접힌 폴더의 **아래** 줄은 뺀다(접힌 폴더 그 줄은 남는다) */
|
|
63
|
+
const rows = tree.filter(node => ![...folded].some(f => f !== node.path && isInFolder(node.path, f)));
|
|
64
|
+
const rowClass = (extra) => ['folder-tree-tooltip__row', ...extra].filter(Boolean).join(' ');
|
|
65
|
+
return (_jsx(Tooltip, { anchorEl: anchorEl, onClose: onClose, closeOnOutsideClick: true, offset: 4, prefer: "bottom", ariaLabel: ariaLabel, children: _jsxs("div", { className: "folder-tree-tooltip", role: "tree", "aria-label": ariaLabel, children: [_jsx("div", { role: "none", ...dropOn(null), className: rowClass([
|
|
66
|
+
opened === null && 'folder-tree-tooltip__row--here',
|
|
67
|
+
(over === ROOT || (dragging === null && !!itemDropOver?.(null))) && 'folder-tree-tooltip__row--over',
|
|
68
|
+
]), children: _jsxs("button", { type: "button", className: "folder-tree-tooltip__name body-2", role: "treeitem", "aria-level": 1, "aria-current": opened === null ? 'page' : undefined, onClick: () => pick(null), children: [_jsx(Icon, { icon: "folder-open", size: 18, className: "folder-tree-tooltip__icon" }), _jsx("span", { className: "folder-tree-tooltip__label", children: rootLabel })] }) }), rows.map((node, i) => {
|
|
69
|
+
const hasChildren = tree.some(other => other.path !== node.path && isInFolder(other.path, node.path));
|
|
70
|
+
const isFolded = folded.has(node.path);
|
|
71
|
+
const here = opened === node.path;
|
|
72
|
+
return (_jsxs("div", { role: "none", ...dragFrom(node.path), ...dropOn(node.path), className: rowClass([
|
|
73
|
+
node.depth > 0 && 'folder-tree-tooltip__row--nested',
|
|
74
|
+
here && 'folder-tree-tooltip__row--here',
|
|
75
|
+
(over === node.path || (dragging === null && !!itemDropOver?.(node.path))) && 'folder-tree-tooltip__row--over',
|
|
76
|
+
dragging === node.path && 'folder-tree-tooltip__row--dragging',
|
|
77
|
+
]), style: { '--folder-depth': node.depth + 1 }, children: [_jsxs("button", { type: "button", className: "folder-tree-tooltip__name body-2", role: "treeitem", "aria-level": node.depth + 2, "aria-posinset": i + 1, "aria-current": here ? 'page' : undefined, onClick: () => pick(node.path), children: [_jsx(Icon, { icon: here ? 'folder-open' : 'folder', size: 18, className: "folder-tree-tooltip__icon" }), _jsx("span", { className: "folder-tree-tooltip__label", children: node.label }), node.count > 0 && _jsx("span", { className: "folder-tree-tooltip__count caption-1", children: node.count })] }), hasChildren && (_jsx("button", { type: "button", className: `folder-tree-tooltip__twist${isFolded ? '' : ' folder-tree-tooltip__twist--open'}`, "aria-label": isFolded
|
|
78
|
+
? t('folder.unfold', { name: node.label, defaultValue: '{{name}} 펼치기' })
|
|
79
|
+
: t('folder.fold', { name: node.label, defaultValue: '{{name}} 접기' }), "aria-expanded": !isFolded, onClick: () => toggle(node.path), children: _jsx(Icon, { icon: "chevron-right", size: 16, className: "folder-tree-tooltip__twist-mark" }) }))] }, node.path));
|
|
80
|
+
})] }) }));
|
|
81
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
padding: var(--spacing-content);
|
|
3
3
|
border-radius: var(--radius-m);
|
|
4
4
|
background: var(--color-deepWhite);
|
|
5
|
-
border: 1px solid var(--color-
|
|
5
|
+
border: 1px solid var(--color-darkWhite); /* 2026-11-12 사장님 지시 — 툴팁 외곽선은 darkWhite */
|
|
6
6
|
max-width: 520px;
|
|
7
7
|
box-sizing: border-box;
|
|
8
8
|
}
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
animation: tooltip-pop 200ms cubic-bezier(.2,.9,.2,1) both;
|
|
12
12
|
will-change: transform, opacity;
|
|
13
13
|
background-color: var(--color-white);
|
|
14
|
+
/* **늘 외곽선**(사장님 지시 2026-11-12: *"popup, tooltip dp 외곽선이 없으니까 가끔 이상하게 보일때가 있네 각각 보더 넣어주되 컬러를 --color-darkWhite로"*). 전에는 `useBorder` 일 때만 섰다 */
|
|
15
|
+
border: 1px solid var(--color-darkWhite);
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
/* useBorder=true 일 때만 외곽선 */
|
|
@@ -19,7 +21,7 @@
|
|
|
19
21
|
position: static;
|
|
20
22
|
}
|
|
21
23
|
.tooltip__content--bordered {
|
|
22
|
-
border: 1px solid var(--color-
|
|
24
|
+
border: 1px solid var(--color-darkWhite);
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
/* 배경 없는 variant 툴팁(Info/Description/Training) 공통 — 감싸는 wrapper(.tooltip__content)의
|
|
@@ -31,6 +33,8 @@
|
|
|
31
33
|
.tooltip__content.training-tooltip {
|
|
32
34
|
background: transparent;
|
|
33
35
|
box-shadow: none;
|
|
36
|
+
/* 감싸개는 안 보이는 겉이다 — 외곽선은 안쪽 상자가 쥔다(겹치면 두 줄이 된다) */
|
|
37
|
+
border: none;
|
|
34
38
|
}
|
|
35
39
|
|
|
36
40
|
/* header prop 전달 시 상단 헤더 */
|
|
@@ -8,6 +8,12 @@ export interface TooltipProps {
|
|
|
8
8
|
anchorEl?: Element | null;
|
|
9
9
|
offset?: number;
|
|
10
10
|
edgeMargin?: number;
|
|
11
|
+
/**
|
|
12
|
+
* 먼저 고를 쪽. 기본 `top` — 전처럼 위에 자리가 있으면 위로 뜬다.
|
|
13
|
+
* `bottom` 을 주면 **아래에 자리가 있을 때 아래로** 뜬다(없으면 위 · 옆으로 전과 같이 넘어간다) — 단추에서 펼쳐 내리는
|
|
14
|
+
* 메뉴(「폴더 이름 ▾」)에 쓴다(말귀 청 (432), 사장님 지시 2026-11-13 "tooltip 아래로 나오도록").
|
|
15
|
+
*/
|
|
16
|
+
prefer?: 'top' | 'bottom';
|
|
11
17
|
onClose?: () => void;
|
|
12
18
|
closeOnOutsideClick?: boolean;
|
|
13
19
|
className?: string;
|
|
@@ -10,7 +10,7 @@ import { usePrefersReducedMotion } from '../../hooks/usePrefersReducedMotion';
|
|
|
10
10
|
import { withLegacy } from '../../utils/legacyBlocks';
|
|
11
11
|
/** @public */
|
|
12
12
|
export default function Tooltip(props) {
|
|
13
|
-
const { anchorRect, anchorEl, offset = 20, edgeMargin = 20, onClose, closeOnOutsideClick = true, className = '', role = 'dialog', ariaLabel = '', children, backdrop = false, isMobilePopup = false, useBorder = true, header, focusOnOpen, } = props || {};
|
|
13
|
+
const { anchorRect, anchorEl, offset = 20, edgeMargin = 20, prefer = 'top', onClose, closeOnOutsideClick = true, className = '', role = 'dialog', ariaLabel = '', children, backdrop = false, isMobilePopup = false, useBorder = true, header, focusOnOpen, } = props || {};
|
|
14
14
|
const ref = useRef(null);
|
|
15
15
|
const [posStyle, setPosStyle] = useState({ position: 'fixed', left: 0, top: -9999 });
|
|
16
16
|
const [closing, setClosing] = useState(false);
|
|
@@ -53,12 +53,18 @@ export default function Tooltip(props) {
|
|
|
53
53
|
let left = 0;
|
|
54
54
|
let top = 0;
|
|
55
55
|
let chosen = 'top';
|
|
56
|
-
|
|
56
|
+
const fitsTop = spaceTop >= h + offset;
|
|
57
|
+
const fitsBottom = spaceBottom >= h + offset;
|
|
58
|
+
/* 먼저 고를 쪽(`prefer`)에 자리가 있으면 그쪽, 없으면 맞은쪽 — 둘 다 없을 때의 차례는 전과 같다 */
|
|
59
|
+
const vertical = prefer === 'bottom'
|
|
60
|
+
? (fitsBottom ? 'bottom' : fitsTop ? 'top' : null)
|
|
61
|
+
: (fitsTop ? 'top' : fitsBottom ? 'bottom' : null);
|
|
62
|
+
if (vertical === 'top') {
|
|
57
63
|
chosen = 'top';
|
|
58
64
|
top = rect.top - offset - h;
|
|
59
65
|
left = rect.left + rect.width / 2 - w / 2;
|
|
60
66
|
}
|
|
61
|
-
else if (
|
|
67
|
+
else if (vertical === 'bottom') {
|
|
62
68
|
chosen = 'bottom';
|
|
63
69
|
top = rect.bottom + offset;
|
|
64
70
|
left = rect.left + rect.width / 2 - w / 2;
|
|
@@ -111,7 +117,7 @@ export default function Tooltip(props) {
|
|
|
111
117
|
setPosStyle({ position: 'fixed', left: leftRounded, top: topRounded });
|
|
112
118
|
setMeasured(true);
|
|
113
119
|
}
|
|
114
|
-
}, [isMobile, isMobilePopup, anchorEl, anchorRect, offset, edgeMargin, placement]);
|
|
120
|
+
}, [isMobile, isMobilePopup, anchorEl, anchorRect, offset, edgeMargin, placement, prefer]);
|
|
115
121
|
/* 앵커가 바뀌면 담아 둔 것을 비운다 — 다음 앵커를 새로 재야 한다 */
|
|
116
122
|
useEffect(() => () => { openAnchorRectRef.current = null; }, [anchorEl, anchorRect]);
|
|
117
123
|
// anchor/모드 변경 시 위치를 재계산하는 의도된 동기화다
|
|
@@ -9,8 +9,10 @@
|
|
|
9
9
|
gap: 10px;
|
|
10
10
|
padding: 18px;
|
|
11
11
|
background: var(--color-white);
|
|
12
|
-
/*
|
|
13
|
-
|
|
12
|
+
/* **기본 테두리는 whiteLine**(사장님 지시 2026-11-12: *"기본 border 넣자. white line 으로"*). 전에는 고대비에서만
|
|
13
|
+
섰다(`--color-control-edge`, 보통 transparent — 청 412). 고대비에서는 whiteLine 토큰 자체가 짙어져(#7b8798)
|
|
14
|
+
경계가 그대로 또렷하다. */
|
|
15
|
+
border: 1px solid var(--color-whiteLine);
|
|
14
16
|
border-radius: var(--radius-card);
|
|
15
17
|
transition: border-color 0.15s, box-shadow 0.15s;
|
|
16
18
|
}
|
|
@@ -36,9 +38,11 @@
|
|
|
36
38
|
.training-card__header {
|
|
37
39
|
display: grid;
|
|
38
40
|
grid-template-columns: minmax(0, 1fr) auto;
|
|
39
|
-
|
|
41
|
+
/* 갈래 표시 · 제목 · 설명 세 줄(2026-11-12 갈래 줄이 머리 안으로 들어왔다) */
|
|
42
|
+
grid-template-rows: auto auto auto;
|
|
40
43
|
column-gap: 8px;
|
|
41
|
-
|
|
44
|
+
/* 갈래 · 제목 · 설명 사이 6(사장님 지시 2026-11-12 *"간격 조정"* — 4 로는 세 줄이 붙어 보였다) */
|
|
45
|
+
row-gap: 6px;
|
|
42
46
|
align-items: start;
|
|
43
47
|
}
|
|
44
48
|
|
|
@@ -47,11 +51,24 @@
|
|
|
47
51
|
display: contents;
|
|
48
52
|
}
|
|
49
53
|
|
|
50
|
-
.training-
|
|
54
|
+
.training-card__header > .training-card__category { grid-area: 1 / 1; min-width: 0; }
|
|
55
|
+
.training-card__title-row > :first-child { grid-area: 2 / 1; min-width: 0; }
|
|
51
56
|
|
|
52
57
|
/* 머리의 마지막 아이는 설명이다(없으면 빈 자리를 채우는 자리지기) */
|
|
53
|
-
.training-card__header > :last-child { grid-area:
|
|
58
|
+
.training-card__header > :last-child { grid-area: 3 / 1; }
|
|
54
59
|
|
|
60
|
+
/* 제목 위 갈래 표시('문장 훈련' · '단어 훈련', 사장님 지시 2026-11-12). 본색 글자로 제목과 층을 가른다.
|
|
61
|
+
한 줄 — 넘치면 말줄임. 머리 격자의 첫 줄이라 제목과 사이는 줄 간격(4)이다. */
|
|
62
|
+
.training-card__category {
|
|
63
|
+
margin: 0;
|
|
64
|
+
color: var(--color-main-ink, var(--color-main));
|
|
65
|
+
font-weight: 600;
|
|
66
|
+
white-space: nowrap;
|
|
67
|
+
overflow: hidden;
|
|
68
|
+
text-overflow: ellipsis;
|
|
69
|
+
min-height: 1lh;
|
|
70
|
+
}
|
|
71
|
+
.training-card__category--sub { color: var(--color-sub); } /* 단어 훈련(사장님 지시 2026-11-12) */
|
|
55
72
|
.training-card__title {
|
|
56
73
|
margin: 0;
|
|
57
74
|
color: var(--color-darkGray);
|
|
@@ -66,14 +83,18 @@
|
|
|
66
83
|
/* **두 줄에 걸친다.** 첫 줄만 차지하면 그 줄이 다시 단추 키(40px)로 부풀어
|
|
67
84
|
아무것도 나아지지 않는다 — 고치는 도중에 실제로 그랬다(머리가 66px 그대로).
|
|
68
85
|
두 줄에 걸치고 `align-self: start` 로 위에 붙여야 제목 줄이 제 키를 지킨다. */
|
|
69
|
-
|
|
86
|
+
/* 갈래 줄부터 설명 줄까지 — 카드 **오른쪽 위**에 붙는다(제목 줄과 따로, 사장님 지시 2026-11-12) */
|
|
87
|
+
grid-row: 1 / 4;
|
|
70
88
|
grid-column: 2;
|
|
71
89
|
align-self: start;
|
|
72
90
|
display: flex;
|
|
73
91
|
align-items: center;
|
|
74
92
|
gap: 2px;
|
|
75
93
|
flex-shrink: 0;
|
|
76
|
-
|
|
94
|
+
/* **아이콘을 카드 안쪽 여백 모서리에 맞춘다**(2026-11-12) — 40 단추 안의 20 아이콘은 사방 10 이 비어, 그대로 두면
|
|
95
|
+
아이콘이 갈래 글자보다 10 아래 · 여백보다 안쪽에 떠 보였다. 위 · 오른쪽으로 10 씩 당긴다. */
|
|
96
|
+
margin-top: -10px;
|
|
97
|
+
margin-right: -10px;
|
|
77
98
|
}
|
|
78
99
|
|
|
79
100
|
/* 게시자 이름은 **글자 높이가 곧 누름감 높이**였다 — 320px 라이브 실측 29 x 13px
|
|
@@ -139,9 +160,21 @@
|
|
|
139
160
|
flex-direction: column;
|
|
140
161
|
gap: 8px;
|
|
141
162
|
justify-content: flex-end;
|
|
163
|
+
/* **가운데가 기본**(사장님 지시 2026-11-12: *"가운데 정렬을 기본으로"*). 수 칸을 `training-card__types` 로 감싼
|
|
164
|
+
카드는 가운데, 감싸지 않고 바로 넣은 카드는 왼쪽에 서서 카드마다 달랐다. 본문 자체를 가운데로 둔다 —
|
|
165
|
+
한 줄을 다 쓰는 것(단어 배지 줄 등)은 제 폭이 차서 그대로다. */
|
|
166
|
+
align-items: center;
|
|
167
|
+
/* **본문이 없어도 수 칸(CountTile 72) 한 줄 자리를 쥔다**(사장님 지시 2026-11-12) — 카드 키가 든 것에 따라
|
|
168
|
+
달라지지 않게. 본문이 없는 카드는 빈 자리(`--empty`)가 이 키로 선다. */
|
|
169
|
+
min-height: 72px;
|
|
142
170
|
}
|
|
143
171
|
|
|
144
172
|
.training-card__empty { color: var(--color-lightGray); }
|
|
173
|
+
/* 빈 본문 · 빈 바닥 자리 — 키만 쥐고 아무것도 받지 않는다(2026-11-12) */
|
|
174
|
+
.training-card__body--empty,
|
|
175
|
+
.training-card__footer--empty { pointer-events: none; }
|
|
176
|
+
/* ⋯ 메뉴를 담는 자리 — 자리를 안 차지한다(메뉴는 몸통에 떠서 선다) */
|
|
177
|
+
.training-card__menu-host { display: contents; }
|
|
145
178
|
|
|
146
179
|
.training-card__types {
|
|
147
180
|
display: flex;
|
|
@@ -175,6 +208,10 @@
|
|
|
175
208
|
justify-content: space-between;
|
|
176
209
|
padding-top: 8px;
|
|
177
210
|
gap: var(--spacing-xs);
|
|
211
|
+
/* **바닥이 없거나 작은 것만 들어도 같은 키**(사장님 지시 2026-11-12) — 바닥에 흔히 서는 작은 배지(높이 20)만큼
|
|
212
|
+
자리를 쥔다. 날짜(11px)만 든 바닥도, 바닥이 없는 카드(`--empty`)도 이 키로 선다. */
|
|
213
|
+
min-height: 28px;
|
|
214
|
+
box-sizing: border-box;
|
|
178
215
|
}
|
|
179
216
|
|
|
180
217
|
.training-card__footer-left {
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
import './TrainingCard.css';
|
|
2
2
|
import type { ReactNode, DragEvent } from 'react';
|
|
3
|
+
import type { ButtonProps } from '../buttonTypes';
|
|
4
|
+
/**
|
|
5
|
+
* @public 카드 오른쪽 위의 할 일 하나 — `actions` 로 준다.
|
|
6
|
+
* `selected` 는 눌린 꼴(좋아요가 켜졌나)이다 — 단추 하나일 때 `aria-pressed` 로, 메뉴일 때 선택 표시로 선다.
|
|
7
|
+
*/
|
|
8
|
+
export type TrainingCardAction = {
|
|
9
|
+
icon: string;
|
|
10
|
+
label: string;
|
|
11
|
+
onClick: () => void;
|
|
12
|
+
selected?: boolean;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
/** 단추 하나일 때의 색 꼴 — 기본 `transparent-lightGray`. 좋아요가 켜졌을 때 `danger` 처럼 바꾼다(메뉴 꼴에서는 안 쓴다). */
|
|
15
|
+
variant?: ButtonProps['variant'];
|
|
16
|
+
};
|
|
3
17
|
/** @public */
|
|
4
18
|
export type TrainingCardProps = {
|
|
5
19
|
/** 카드 제목을 **머리글 몇 급**으로 그릴지(말귀가 (54) 를 재다 짚음, 2026-10-02).
|
|
@@ -10,12 +24,31 @@ export type TrainingCardProps = {
|
|
|
10
24
|
* (말귀 실측: `H1 나의 문장훈련 / H3 1123 / H3 테스트 카드`).
|
|
11
25
|
* `0` 을 주면 전과 같이 `div` 로 그린다. */
|
|
12
26
|
titleLevel?: 0 | 2 | 3 | 4 | 5 | 6;
|
|
27
|
+
/**
|
|
28
|
+
* **제목 위 갈래 표시** — `'문장 훈련'` · `'단어 훈련'` 처럼 이 카드가 어느 훈련인지(사장님 지시 2026-11-12:
|
|
29
|
+
* *"title 상단에 문장훈련, 단어훈련 표시하도록 하자"*). 작은 글자 한 줄로 제목 위에 선다.
|
|
30
|
+
* 안 줘도 그 한 줄 자리는 비워 둔다 — 갈래를 준 카드와 안 준 카드가 한 줄에 서도 키가 같다(같은 날 지시
|
|
31
|
+
* *"안에 항목 없더라도 동일한 크기가 되도록"*).
|
|
32
|
+
*/
|
|
33
|
+
category?: ReactNode;
|
|
34
|
+
/** 갈래 표시의 색 — `'main'`(기본, 문장 훈련) · `'sub'`(단어 훈련 — 사장님 지시 2026-11-12: *"단어훈련은 --color-sub 컬러로"*) */
|
|
35
|
+
categoryVariant?: 'main' | 'sub';
|
|
13
36
|
/** 제목 — 문자열이면 h4 제목으로 감싸고, 노드면 그대로 렌더(예: 인라인 이름변경 입력) */
|
|
14
37
|
title: ReactNode;
|
|
15
38
|
/** 한 줄 설명 — 문자열이면 본문 문단으로 감싸고, 노드면 그대로 렌더 */
|
|
16
39
|
description?: ReactNode;
|
|
17
|
-
/** 우측 상단 액션 영역 (좋아요/다운로드, ⋯ 메뉴 등) — 클릭이 카드로 전파되지
|
|
40
|
+
/** 우측 상단 액션 영역 (좋아요/다운로드, ⋯ 메뉴 등) — 클릭이 카드로 전파되지 않음.
|
|
41
|
+
* **할 일 단추는 `actions` 로 준다** — 여기에 단추를 여럿 얹으면 '단추는 하나' 규칙을 못 지킨다. 이 칸은 단추가 아닌 것
|
|
42
|
+
* (모서리 배지 등)이나 `actions` 로 못 그리는 것에 쓴다. `actions` 를 주면 이 칸은 안 그린다. */
|
|
18
43
|
topActions?: ReactNode;
|
|
44
|
+
/**
|
|
45
|
+
* **오른쪽 위 할 일 — 단추는 늘 하나다**(사장님 지시 2026-11-12: *"우측 상단의 버튼은 무조건 1개. 2개 이상일 경우에는
|
|
46
|
+
* ...버튼으로 표현하고 tooltip menu 로 선택하도록"*).
|
|
47
|
+
*
|
|
48
|
+
* 하나면 그 아이콘 단추(이름 = `label`, `selected` 면 눌린 꼴). 둘 이상이면 `⋯` 단추 하나가 서고 누르면 메뉴로 고른다.
|
|
49
|
+
* 비었거나 안 주면 `topActions` 를 그린다.
|
|
50
|
+
*/
|
|
51
|
+
actions?: TrainingCardAction[];
|
|
19
52
|
/**
|
|
20
53
|
* **카드가 눌릴 때 읽히는 이름**(말귀 요청 (65), 2026-10-02).
|
|
21
54
|
*
|
|
@@ -43,4 +76,4 @@ export type TrainingCardProps = {
|
|
|
43
76
|
className?: string;
|
|
44
77
|
};
|
|
45
78
|
/** @public */
|
|
46
|
-
export default function TrainingCard({ title, titleLevel, description, topActions, children, footerLeft, footerRight, ariaLabel, onClick, draggable, onDragStart, onDragEnd, className, }: TrainingCardProps): import("react").JSX.Element;
|
|
79
|
+
export default function TrainingCard({ title, titleLevel, category, categoryVariant, description, topActions, actions, children, footerLeft, footerRight, ariaLabel, onClick, draggable, onDragStart, onDragEnd, className, }: TrainingCardProps): import("react").JSX.Element;
|
|
@@ -2,10 +2,25 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { cx } from '../../utils/cx';
|
|
4
4
|
import './TrainingCard.css';
|
|
5
|
-
import { useCallback } from 'react';
|
|
5
|
+
import { useCallback, useState } from 'react';
|
|
6
|
+
import { useTranslation } from 'react-i18next';
|
|
7
|
+
import Button from '../Button';
|
|
8
|
+
import Tooltip from '../Tooltip/Tooltip';
|
|
9
|
+
import MenuTooltip from '../Tooltip/MenuTooltip';
|
|
6
10
|
/** @public */
|
|
7
|
-
export default function TrainingCard({ title, titleLevel = 3, description, topActions, children, footerLeft, footerRight, ariaLabel, onClick, draggable, onDragStart, onDragEnd, className, }) {
|
|
11
|
+
export default function TrainingCard({ title, titleLevel = 3, category, categoryVariant = 'main', description, topActions, actions, children, footerLeft, footerRight, ariaLabel, onClick, draggable, onDragStart, onDragEnd, className, }) {
|
|
8
12
|
const TitleTag = titleLevel ? `h${titleLevel}` : 'div';
|
|
13
|
+
const { t } = useTranslation();
|
|
14
|
+
const [menuRect, setMenuRect] = useState(null);
|
|
15
|
+
const closeMenu = useCallback(() => setMenuRect(null), []);
|
|
16
|
+
const openMenu = useCallback((e) => {
|
|
17
|
+
const r = e.currentTarget.getBoundingClientRect();
|
|
18
|
+
setMenuRect(prev => (prev ? null : { left: r.left, right: r.right, top: r.top, bottom: r.bottom, width: r.width, height: r.height, x: r.x, y: r.y }));
|
|
19
|
+
}, []);
|
|
20
|
+
/* **단추는 하나**(사장님 지시 2026-11-12) — 할 일이 하나면 그 단추, 둘 이상이면 ⋯ 하나에 메뉴 */
|
|
21
|
+
const actionList = (actions ?? []).filter(Boolean);
|
|
22
|
+
const actionNode = actionList.length === 1 ? (_jsx(Button, { htmlType: "button", type: "dot", size: 40, icon: actionList[0].icon, ariaLabel: actionList[0].label, showTooltipInfo: actionList[0].label, selected: actionList[0].selected, disabled: actionList[0].disabled, variant: actionList[0].variant ?? 'transparent-lightGray', useBorder: false, onClick: actionList[0].onClick })) : actionList.length > 1 ? (_jsx(Button, { htmlType: "button", type: "dot", size: 40, icon: "ellipsis", ariaLabel: t('common.more', '더보기'), showTooltipInfo: t('common.more', '더보기'), variant: "transparent-lightGray", useBorder: false, "aria-haspopup": "menu", "aria-expanded": !!menuRect, onClick: openMenu })) : null;
|
|
23
|
+
const topNode = actionNode ?? topActions;
|
|
9
24
|
const hasFooter = footerLeft != null || footerRight != null;
|
|
10
25
|
const hasBody = children != null && children !== false;
|
|
11
26
|
const handleKeyDown = useCallback((e) => {
|
|
@@ -20,11 +35,17 @@ export default function TrainingCard({ title, titleLevel = 3, description, topAc
|
|
|
20
35
|
onClick();
|
|
21
36
|
}
|
|
22
37
|
}, [onClick]);
|
|
23
|
-
return (_jsxs("div", { className: cx('training-card', onClick ? 'training-card--clickable' : '', className), onClick: onClick, onKeyDown: onClick ? handleKeyDown : undefined, role: onClick ? 'button' : undefined, "aria-label": onClick ? (ariaLabel ?? (typeof title === 'string' ? title : undefined)) : undefined, tabIndex: onClick ? 0 : undefined, draggable: draggable, onDragStart: onDragStart, onDragEnd: onDragEnd, children: [_jsxs("div", { className: "training-card__header", children: [
|
|
38
|
+
return (_jsxs("div", { className: cx('training-card', onClick ? 'training-card--clickable' : '', className), onClick: onClick, onKeyDown: onClick ? handleKeyDown : undefined, role: onClick ? 'button' : undefined, "aria-label": onClick ? (ariaLabel ?? (typeof title === 'string' ? title : undefined)) : undefined, tabIndex: onClick ? 0 : undefined, draggable: draggable, onDragStart: onDragStart, onDragEnd: onDragEnd, children: [_jsxs("div", { className: "training-card__header", children: [category != null
|
|
39
|
+
? _jsx("p", { className: cx('training-card__category', 'caption-1', categoryVariant === 'sub' && 'training-card__category--sub'), children: category })
|
|
40
|
+
: _jsx("p", { className: "training-card__category caption-1", "aria-hidden": "true", children: ' ' }), _jsxs("div", { className: "training-card__title-row", children: [typeof title === 'string'
|
|
24
41
|
? _jsx(TitleTag, { className: "training-card__title h4", children: title })
|
|
25
|
-
: title,
|
|
42
|
+
: title, topNode != null && (_jsx("div", { className: "training-card__top-actions", onClick: (e) => e.stopPropagation(), children: topNode }))] }), description != null
|
|
26
43
|
? (typeof description === 'string'
|
|
27
44
|
? _jsx("p", { className: "training-card__description body-3", children: description })
|
|
28
45
|
: description)
|
|
29
|
-
: _jsx("p", { className: "training-card__description body-3", "aria-hidden": "true", children: ' ' })] }), hasBody
|
|
46
|
+
: _jsx("p", { className: "training-card__description body-3", "aria-hidden": "true", children: ' ' })] }), hasBody
|
|
47
|
+
? _jsx("div", { className: "training-card__body", children: children })
|
|
48
|
+
: _jsx("div", { className: "training-card__body training-card__body--empty", "aria-hidden": "true" }), hasFooter ? (_jsxs("div", { className: "training-card__footer", children: [footerLeft != null && _jsx("div", { className: "training-card__footer-left", children: footerLeft }), footerRight != null && _jsx("div", { className: "training-card__meta", children: footerRight })] })) : _jsx("div", { className: "training-card__footer training-card__footer--empty", "aria-hidden": "true" }), menuRect && actionList.length > 1 && (
|
|
49
|
+
/* 메뉴의 누름은 카드로 올라가지 않는다 — 고르는 것이 카드를 여는 것이 되면 안 된다 */
|
|
50
|
+
_jsx("div", { className: "training-card__menu-host", onClick: (e) => e.stopPropagation(), children: _jsx(Tooltip, { anchorRect: menuRect, onClose: closeMenu, ariaLabel: t('tooltip.menu', '메뉴'), children: _jsx(MenuTooltip, { columns: [{ items: actionList.map(a => ({ label: a.label, icon: a.icon, selected: a.selected, disabled: a.disabled, onClick: a.onClick })) }], onClose: closeMenu, size: "small" }) }) }))] }));
|
|
30
51
|
}
|
|
@@ -103,6 +103,14 @@ export { default as FileUpload } from './components/FileUpload';
|
|
|
103
103
|
export type { FileUploadProps } from './components/FileUpload';
|
|
104
104
|
export { default as Breadcrumb } from './components/Breadcrumb';
|
|
105
105
|
export type { BreadcrumbProps, BreadcrumbItem } from './components/Breadcrumb';
|
|
106
|
+
export { default as FolderHead } from './components/FolderHead';
|
|
107
|
+
export type { FolderHeadProps } from './components/FolderHead';
|
|
108
|
+
export { default as FolderGrid } from './components/FolderGrid';
|
|
109
|
+
export type { FolderGridProps, FolderEntry } from './components/FolderGrid';
|
|
110
|
+
export { default as FolderTreeButton } from './components/FolderTreeButton';
|
|
111
|
+
export type { FolderTreeButtonProps } from './components/FolderTreeButton';
|
|
112
|
+
export { default as FolderTreeTooltip } from './components/Tooltip/FolderTreeTooltip';
|
|
113
|
+
export type { FolderTreeTooltipProps, FolderTreeNode } from './components/Tooltip/FolderTreeTooltip';
|
|
106
114
|
export { default as Rating } from './components/Rating';
|
|
107
115
|
export type { RatingProps, RatingSize } from './components/Rating';
|
|
108
116
|
export { default as ColorPicker } from './components/ColorPicker';
|
|
@@ -71,6 +71,11 @@ export { default as Tabs } from './components/Tabs';
|
|
|
71
71
|
export { default as Avatar } from './components/Avatar';
|
|
72
72
|
export { default as FileUpload } from './components/FileUpload';
|
|
73
73
|
export { default as Breadcrumb } from './components/Breadcrumb';
|
|
74
|
+
/* 폴더로 보는 화면 — 구조 단추 · 길 · 폴더 칸(말귀 청 (435), 2026-11-13). 길 셈은 `utils` 의 `folder*` 다 */
|
|
75
|
+
export { default as FolderHead } from './components/FolderHead';
|
|
76
|
+
export { default as FolderGrid } from './components/FolderGrid';
|
|
77
|
+
export { default as FolderTreeButton } from './components/FolderTreeButton';
|
|
78
|
+
export { default as FolderTreeTooltip } from './components/Tooltip/FolderTreeTooltip';
|
|
74
79
|
export { default as Rating } from './components/Rating';
|
|
75
80
|
export { default as ColorPicker } from './components/ColorPicker';
|
|
76
81
|
export { default as CountTile } from './components/CountTile';
|
|
@@ -1111,6 +1111,16 @@
|
|
|
1111
1111
|
"breadcrumb": {
|
|
1112
1112
|
"ariaLabel": "Breadcrumb"
|
|
1113
1113
|
},
|
|
1114
|
+
"folder": {
|
|
1115
|
+
"list": "Folders",
|
|
1116
|
+
"open_one": "Open folder {{name}}, {{count}} item",
|
|
1117
|
+
"open_other": "Open folder {{name}}, {{count}} items",
|
|
1118
|
+
"menu": "{{name}} folder menu",
|
|
1119
|
+
"placeMenu": "{{name}} menu",
|
|
1120
|
+
"tree": "Show folder structure",
|
|
1121
|
+
"fold": "Collapse {{name}}",
|
|
1122
|
+
"unfold": "Expand {{name}}"
|
|
1123
|
+
},
|
|
1114
1124
|
"board": {
|
|
1115
1125
|
"empty": "No items yet."
|
|
1116
1126
|
},
|
|
@@ -1094,6 +1094,15 @@
|
|
|
1094
1094
|
"breadcrumb": {
|
|
1095
1095
|
"ariaLabel": "이동 경로"
|
|
1096
1096
|
},
|
|
1097
|
+
"folder": {
|
|
1098
|
+
"list": "폴더",
|
|
1099
|
+
"open": "{{name}} 폴더 열기, {{count}}개",
|
|
1100
|
+
"menu": "{{name}} 폴더 메뉴",
|
|
1101
|
+
"placeMenu": "{{name}} 메뉴",
|
|
1102
|
+
"tree": "폴더 구조 보기",
|
|
1103
|
+
"fold": "{{name}} 접기",
|
|
1104
|
+
"unfold": "{{name}} 펼치기"
|
|
1105
|
+
},
|
|
1097
1106
|
"board": {
|
|
1098
1107
|
"empty": "등록된 항목이 없습니다."
|
|
1099
1108
|
},
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** @public 화면에 보일 이름 — 길의 마지막 마디 */
|
|
2
|
+
export declare function folderLeaf(path: string): string;
|
|
3
|
+
/** @public 한 층 위 폴더의 길 — 맨 위 폴더면 `null`(맨 위) */
|
|
4
|
+
export declare function folderParent(path: string): string | null;
|
|
5
|
+
/** @public 폴더 안에 새 폴더의 길을 짓는다 — `parent` 가 없으면 맨 위에 선다 */
|
|
6
|
+
export declare const folderJoin: (parent: string | null, name: string) => string;
|
|
7
|
+
/** @public 새 폴더 이름으로 쓸 수 있나 — 비지 않고, 길을 가르는 글자가 없어야 한다 */
|
|
8
|
+
export declare const isFolderNameOk: (name: string) => boolean;
|
|
9
|
+
/** @public `path` 가 `ancestor` 그 자체이거나 그 아래인가 */
|
|
10
|
+
export declare const isInFolder: (path: string | null | undefined, ancestor: string) => boolean;
|
|
11
|
+
/**
|
|
12
|
+
* 적힌 길들에 **중간 폴더를 채워** 돌려준다(받은 차례를 지키고, 중간 폴더는 그 하위가 처음 나온 자리 앞에 선다).
|
|
13
|
+
* 같은 길은 한 번만.
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export declare function withAncestors(paths: readonly string[]): string[];
|
|
17
|
+
/** @public `parent` 바로 아래의 폴더들(한 층만) — `parent` 가 `null` 이면 맨 위의 폴더들. 받은 차례 그대로 */
|
|
18
|
+
export declare function folderChildren(paths: readonly string[], parent: string | null): string[];
|
|
19
|
+
/** @public 맨 위에서 그 폴더까지의 길 — 층마다 `{ path, label }`(길 · 보일 이름) */
|
|
20
|
+
export declare function folderTrail(path: string): {
|
|
21
|
+
path: string;
|
|
22
|
+
label: string;
|
|
23
|
+
}[];
|
|
24
|
+
/** @public 폴더 나무를 **펼친 차례**로 — 부모 바로 뒤에 그 자식들이 선다. 층은 0 부터 */
|
|
25
|
+
export declare function folderTree(paths: readonly string[]): {
|
|
26
|
+
path: string;
|
|
27
|
+
label: string;
|
|
28
|
+
depth: number;
|
|
29
|
+
}[];
|
|
30
|
+
/**
|
|
31
|
+
* 폴더 `from` 을 `toParent` 안으로 **옮겼을 때** `path` 의 새 길(사장님 지시 2026-11-13 "드래드 해서 다른 폴더에 넣거나 뺄 수
|
|
32
|
+
* 있도록"). `path` 가 `from` 그 자체나 그 아래면 앞머리를 갈아 돌려주고, 상관없는 길이면 `undefined`.
|
|
33
|
+
* `toParent` 가 `null` 이면 맨 위로 뺀다.
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
export declare function folderMoved(path: string | null | undefined, from: string, toParent: string | null): string | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* 폴더 `from` 을 `toParent` 안으로 옮길 수 있나 — 제 자신 · 제 아래로는 못 들어가고, 이미 그 자리에 있으면 옮길 것이 없다.
|
|
39
|
+
* (같은 이름이 그 자리에 이미 있는지는 부르는 쪽이 본다 — 있는 폴더를 아는 것은 그쪽이다.)
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
42
|
+
export declare const canMoveFolder: (from: string, toParent: string | null) => boolean;
|
|
43
|
+
/**
|
|
44
|
+
* 폴더 `from` 을 `into` 안으로 옮기려 할 때의 **판정** — 세 화면(나의 단어표 · 단어훈련 · 문장훈련)이 같은 말을 따로 적고 있었다.
|
|
45
|
+
* · `noop` — 옮길 것이 없다(제 자신 · 제 아래 · 이미 그 자리)
|
|
46
|
+
* · `clash` — 그 자리에 같은 이름의 폴더가 이미 있다(알린다 — `folderTree.moveClash`)
|
|
47
|
+
* · `ok` — 옮긴다. 새 길은 `folderMoved(from, from, into)`
|
|
48
|
+
* @public
|
|
49
|
+
*/
|
|
50
|
+
export declare function folderMoveVerdict(from: string, into: string | null, existing: readonly string[]): 'ok' | 'clash' | 'noop';
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **폴더 안의 폴더 — 이름을 길로 적는다.** (말귀 청 (435), 사장님 지시 2026-11-13 "core에 포함 시켜야 할게 있다면 포함시키고")
|
|
3
|
+
*
|
|
4
|
+
* 폴더와 그 안에 든 것이 **이름 글자로 이어져 있는** 자료(외래키가 아니라, 든 것의 `group` 과 폴더의 이름이 같은 글자면 그 안)에서
|
|
5
|
+
* 폴더에 층을 준다: 「앙」 안의 「하위」 를 `앙/하위` 로 적으면 **자료 꼴을 안 바꾸고** 층이 생긴다. 든 것은 제 폴더의 온 길을
|
|
6
|
+
* 적고, 화면은 길의 마지막 마디만 보인다(`folderLeaf`). 대신 폴더 이름에 `/` 는 못 쓴다(`isFolderNameOk`).
|
|
7
|
+
*
|
|
8
|
+
* **중간 폴더는 적혀 있지 않아도 있는 것으로 친다** — `앙/하위` 만 적혀 있고 `앙` 이 없어도 「앙」 이 선다(`withAncestors`).
|
|
9
|
+
* 옛 자료나 한쪽만 지워진 자료에서 하위 폴더가 통째로 사라져 보이면 안 된다.
|
|
10
|
+
*
|
|
11
|
+
* 그리는 조각은 `FolderHead`(길 · 구조 단추 · 폴더 칸) · `FolderGrid` · `FolderTreeButton` · `FolderTreeTooltip` 이다.
|
|
12
|
+
* 말귀의 나의 단어표 · 나의 단어훈련 · 나의 문장훈련에서 먼저 섰다(2026-11-13).
|
|
13
|
+
*/
|
|
14
|
+
const FOLDER_SEP = '/';
|
|
15
|
+
/** 길을 마디로 — 빈 마디는 버린다 */
|
|
16
|
+
const folderParts = (path) => path.split(FOLDER_SEP).filter(part => part !== '');
|
|
17
|
+
/** @public 화면에 보일 이름 — 길의 마지막 마디 */
|
|
18
|
+
export function folderLeaf(path) {
|
|
19
|
+
const parts = folderParts(path);
|
|
20
|
+
/* `.at(-1)` 은 옛 폰(iOS 15.4 아래)에서 터진다 — 길이로 짚는다 */
|
|
21
|
+
return parts[parts.length - 1] ?? path;
|
|
22
|
+
}
|
|
23
|
+
/** @public 한 층 위 폴더의 길 — 맨 위 폴더면 `null`(맨 위) */
|
|
24
|
+
export function folderParent(path) {
|
|
25
|
+
const parts = folderParts(path);
|
|
26
|
+
return parts.length > 1 ? parts.slice(0, -1).join(FOLDER_SEP) : null;
|
|
27
|
+
}
|
|
28
|
+
/** @public 폴더 안에 새 폴더의 길을 짓는다 — `parent` 가 없으면 맨 위에 선다 */
|
|
29
|
+
export const folderJoin = (parent, name) => (parent ? `${parent}${FOLDER_SEP}${name.trim()}` : name.trim());
|
|
30
|
+
/** @public 새 폴더 이름으로 쓸 수 있나 — 비지 않고, 길을 가르는 글자가 없어야 한다 */
|
|
31
|
+
export const isFolderNameOk = (name) => name.trim() !== '' && !name.includes(FOLDER_SEP);
|
|
32
|
+
/** @public `path` 가 `ancestor` 그 자체이거나 그 아래인가 */
|
|
33
|
+
export const isInFolder = (path, ancestor) => !!path && (path === ancestor || path.startsWith(ancestor + FOLDER_SEP));
|
|
34
|
+
/**
|
|
35
|
+
* 적힌 길들에 **중간 폴더를 채워** 돌려준다(받은 차례를 지키고, 중간 폴더는 그 하위가 처음 나온 자리 앞에 선다).
|
|
36
|
+
* 같은 길은 한 번만.
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
export function withAncestors(paths) {
|
|
40
|
+
const seen = new Set();
|
|
41
|
+
const out = [];
|
|
42
|
+
for (const path of paths) {
|
|
43
|
+
const parts = folderParts(path);
|
|
44
|
+
for (let depth = 1; depth <= parts.length; depth += 1) {
|
|
45
|
+
const at = parts.slice(0, depth).join(FOLDER_SEP);
|
|
46
|
+
if (!seen.has(at)) {
|
|
47
|
+
seen.add(at);
|
|
48
|
+
out.push(at);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return out;
|
|
53
|
+
}
|
|
54
|
+
/** @public `parent` 바로 아래의 폴더들(한 층만) — `parent` 가 `null` 이면 맨 위의 폴더들. 받은 차례 그대로 */
|
|
55
|
+
export function folderChildren(paths, parent) {
|
|
56
|
+
return withAncestors(paths).filter(path => folderParent(path) === parent);
|
|
57
|
+
}
|
|
58
|
+
/** @public 맨 위에서 그 폴더까지의 길 — 층마다 `{ path, label }`(길 · 보일 이름) */
|
|
59
|
+
export function folderTrail(path) {
|
|
60
|
+
const parts = folderParts(path);
|
|
61
|
+
return parts.map((label, i) => ({ path: parts.slice(0, i + 1).join(FOLDER_SEP), label }));
|
|
62
|
+
}
|
|
63
|
+
/** @public 폴더 나무를 **펼친 차례**로 — 부모 바로 뒤에 그 자식들이 선다. 층은 0 부터 */
|
|
64
|
+
export function folderTree(paths) {
|
|
65
|
+
const all = withAncestors(paths);
|
|
66
|
+
const walk = (parent, depth) => all.filter(path => folderParent(path) === parent)
|
|
67
|
+
.flatMap(path => [{ path, label: folderLeaf(path), depth }, ...walk(path, depth + 1)]);
|
|
68
|
+
return walk(null, 0);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* 폴더 `from` 을 `toParent` 안으로 **옮겼을 때** `path` 의 새 길(사장님 지시 2026-11-13 "드래드 해서 다른 폴더에 넣거나 뺄 수
|
|
72
|
+
* 있도록"). `path` 가 `from` 그 자체나 그 아래면 앞머리를 갈아 돌려주고, 상관없는 길이면 `undefined`.
|
|
73
|
+
* `toParent` 가 `null` 이면 맨 위로 뺀다.
|
|
74
|
+
* @public
|
|
75
|
+
*/
|
|
76
|
+
export function folderMoved(path, from, toParent) {
|
|
77
|
+
if (!path || !isInFolder(path, from))
|
|
78
|
+
return undefined;
|
|
79
|
+
return folderJoin(toParent, folderLeaf(from)) + path.slice(from.length);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* 폴더 `from` 을 `toParent` 안으로 옮길 수 있나 — 제 자신 · 제 아래로는 못 들어가고, 이미 그 자리에 있으면 옮길 것이 없다.
|
|
83
|
+
* (같은 이름이 그 자리에 이미 있는지는 부르는 쪽이 본다 — 있는 폴더를 아는 것은 그쪽이다.)
|
|
84
|
+
* @public
|
|
85
|
+
*/
|
|
86
|
+
export const canMoveFolder = (from, toParent) => folderParent(from) !== toParent && !(toParent !== null && isInFolder(toParent, from));
|
|
87
|
+
/**
|
|
88
|
+
* 폴더 `from` 을 `into` 안으로 옮기려 할 때의 **판정** — 세 화면(나의 단어표 · 단어훈련 · 문장훈련)이 같은 말을 따로 적고 있었다.
|
|
89
|
+
* · `noop` — 옮길 것이 없다(제 자신 · 제 아래 · 이미 그 자리)
|
|
90
|
+
* · `clash` — 그 자리에 같은 이름의 폴더가 이미 있다(알린다 — `folderTree.moveClash`)
|
|
91
|
+
* · `ok` — 옮긴다. 새 길은 `folderMoved(from, from, into)`
|
|
92
|
+
* @public
|
|
93
|
+
*/
|
|
94
|
+
export function folderMoveVerdict(from, into, existing) {
|
|
95
|
+
if (!canMoveFolder(from, into))
|
|
96
|
+
return 'noop';
|
|
97
|
+
return existing.includes(folderJoin(into, folderLeaf(from))) ? 'clash' : 'ok';
|
|
98
|
+
}
|