@ihabdevteam/core 0.440.0 → 0.442.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 +19 -0
- package/dist/components.cjs.js +178 -178
- package/dist/components.esm.css +1 -1
- package/dist/hooks.cjs.js +5 -5
- package/dist/i18n.cjs.js +1 -1
- package/dist/ihabdevteam-core.cjs.js +187 -187
- package/dist/ihabdevteam-core.d.ts +203 -2
- package/dist/packages/core/src/components/CardSection.css +26 -0
- package/dist/packages/core/src/components/CardSection.d.ts +32 -0
- package/dist/packages/core/src/components/CardSection.js +23 -0
- package/dist/packages/core/src/components/FolderGrid.js +9 -17
- package/dist/packages/core/src/components/FolderSearchSections.d.ts +25 -0
- package/dist/packages/core/src/components/FolderSearchSections.js +18 -0
- package/dist/packages/core/src/components/Popup/ListPopup.js +3 -1
- package/dist/packages/core/src/components/Popup/useDiscardGuard.d.ts +26 -0
- package/dist/packages/core/src/components/Popup/useDiscardGuard.js +28 -0
- package/dist/packages/core/src/components.d.ts +6 -2
- package/dist/packages/core/src/components.js +4 -1
- package/dist/packages/core/src/hooks/useCardDragToGroup.d.ts +33 -0
- package/dist/packages/core/src/hooks/useCardDragToGroup.js +52 -0
- package/dist/packages/core/src/hooks/useFolderBrowse.d.ts +30 -0
- package/dist/packages/core/src/hooks/useFolderBrowse.js +38 -0
- package/dist/packages/core/src/hooks/usePageSizeOptions.d.ts +19 -0
- package/dist/packages/core/src/hooks/usePageSizeOptions.js +25 -0
- package/dist/packages/core/src/hooks.d.ts +3 -0
- package/dist/packages/core/src/hooks.js +4 -0
- package/dist/packages/core/src/utils/folderMenu.d.ts +27 -0
- package/dist/packages/core/src/utils/folderMenu.js +19 -0
- package/dist/packages/core/src/utils.d.ts +2 -0
- package/dist/packages/core/src/utils.js +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 +164 -164
- package/package.json +1 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useCallback, useState } from 'react';
|
|
3
|
+
const defaultGetId = (p) => String(p);
|
|
4
|
+
/** @public */
|
|
5
|
+
export function useCardDragToGroup(onDrop, getId = defaultGetId) {
|
|
6
|
+
const [dragging, setDragging] = useState(null);
|
|
7
|
+
const [dragOverKey, setDragOverKey] = useState(null);
|
|
8
|
+
const cardProps = useCallback((payload) => ({
|
|
9
|
+
draggable: true,
|
|
10
|
+
onDragStart: (e) => {
|
|
11
|
+
setDragging(payload);
|
|
12
|
+
e.dataTransfer.effectAllowed = 'move';
|
|
13
|
+
e.dataTransfer.setData('text/plain', getId(payload));
|
|
14
|
+
},
|
|
15
|
+
onDragEnd: () => { setDragging(null); setDragOverKey(null); },
|
|
16
|
+
}), [getId]);
|
|
17
|
+
const groupProps = useCallback((groupKey, accept) => {
|
|
18
|
+
/* 지금 끄는 짐을 이 자리가 받나(`accept` 를 안 주면 다 받는다) */
|
|
19
|
+
const active = dragging != null && (!accept || accept(dragging));
|
|
20
|
+
return {
|
|
21
|
+
onDragOver: (e) => {
|
|
22
|
+
if (!active)
|
|
23
|
+
return;
|
|
24
|
+
e.preventDefault();
|
|
25
|
+
e.dataTransfer.dropEffect = 'move';
|
|
26
|
+
setDragOverKey(groupKey);
|
|
27
|
+
},
|
|
28
|
+
onDragEnter: () => { if (active)
|
|
29
|
+
setDragOverKey(groupKey); },
|
|
30
|
+
onDragLeave: (e) => {
|
|
31
|
+
if (active && !e.currentTarget.contains(e.relatedTarget))
|
|
32
|
+
setDragOverKey(now => (now === groupKey ? null : now));
|
|
33
|
+
},
|
|
34
|
+
onDrop: (e) => {
|
|
35
|
+
if (!active || dragging == null)
|
|
36
|
+
return;
|
|
37
|
+
e.preventDefault();
|
|
38
|
+
const payload = dragging;
|
|
39
|
+
setDragOverKey(null);
|
|
40
|
+
setDragging(null);
|
|
41
|
+
onDrop(payload, groupKey);
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}, [dragging, onDrop]);
|
|
45
|
+
return {
|
|
46
|
+
dragging,
|
|
47
|
+
draggingId: dragging == null ? null : getId(dragging),
|
|
48
|
+
dragOverKey,
|
|
49
|
+
cardProps,
|
|
50
|
+
groupProps,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **폴더로 보는 화면의 자리** — 지금 어느 폴더 안에 있나, 찾는 중인가, 새 폴더는 어디에 서나(말귀 청 (437) ㉮ — 말귀 앱에서 옮겨 왔다).
|
|
3
|
+
*
|
|
4
|
+
* 말귀의 나의 단어표 · 나의 단어훈련 · 나의 문장훈련이 이 규칙을 한 벌씩 들고 있다가 앱에서 한 벌로 모았고, 코어 `FolderHead` 식구로 옮겼다.
|
|
5
|
+
* 화면마다 같아야 하는 규칙이다:
|
|
6
|
+
*
|
|
7
|
+
* · **목록에 없는 폴더는 안 연 것으로 친다** — 들어가 있던 폴더를 지웠거나 보기(갈래)를 바꿔 그 폴더가 없으면 맨 위로 돌아온다.
|
|
8
|
+
* · **찾는 중에는 폴더를 가리지 않는다** — 그때 새 폴더는 맨 위에 선다(길이 안 보이는데 안 보이는 폴더 안에 만들면 안 된다).
|
|
9
|
+
* · 폴더를 열면 **첫 쪽으로** 돌아간다(`onOpen`) — 3쪽을 보다가 폴더에 들어가면 그 폴더의 3쪽(대개 빈 화면)이 선다.
|
|
10
|
+
* · 들어가 있던 폴더가 옮겨지거나 이름이 바뀌면 **그 새 길로 따라간다** — 안 따라가면 맨 위로 튕긴다.
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export declare function useFolderBrowse({ paths, search, onOpen }: {
|
|
14
|
+
/** 있는 폴더 전부의 길(중간 폴더까지 채운 것 — `withAncestors`) */
|
|
15
|
+
paths: readonly string[];
|
|
16
|
+
/** 찾는 말 — 비어 있지 않으면 찾는 중이다 */
|
|
17
|
+
search: string;
|
|
18
|
+
/** 폴더를 열거나 맨 위로 갈 때 함께 할 일 — 쪽을 첫 쪽으로 돌린다 */
|
|
19
|
+
onOpen?: () => void;
|
|
20
|
+
}): {
|
|
21
|
+
opened: string | null;
|
|
22
|
+
searching: boolean;
|
|
23
|
+
open: (path: string | null) => void;
|
|
24
|
+
reset: () => void;
|
|
25
|
+
followMove: (from: string, into: string | null) => void;
|
|
26
|
+
followRename: (from: string, to: string) => void;
|
|
27
|
+
newFolderParent: string | null;
|
|
28
|
+
/** 새 폴더가 설 자리에 이미 있는 이름들 — 같은 이름을 또 못 짓게 견준다 */
|
|
29
|
+
siblingNames: string[];
|
|
30
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useCallback, useState } from 'react';
|
|
3
|
+
import { folderChildren, folderLeaf, folderMoved } from '../utils/folderPath';
|
|
4
|
+
/**
|
|
5
|
+
* **폴더로 보는 화면의 자리** — 지금 어느 폴더 안에 있나, 찾는 중인가, 새 폴더는 어디에 서나(말귀 청 (437) ㉮ — 말귀 앱에서 옮겨 왔다).
|
|
6
|
+
*
|
|
7
|
+
* 말귀의 나의 단어표 · 나의 단어훈련 · 나의 문장훈련이 이 규칙을 한 벌씩 들고 있다가 앱에서 한 벌로 모았고, 코어 `FolderHead` 식구로 옮겼다.
|
|
8
|
+
* 화면마다 같아야 하는 규칙이다:
|
|
9
|
+
*
|
|
10
|
+
* · **목록에 없는 폴더는 안 연 것으로 친다** — 들어가 있던 폴더를 지웠거나 보기(갈래)를 바꿔 그 폴더가 없으면 맨 위로 돌아온다.
|
|
11
|
+
* · **찾는 중에는 폴더를 가리지 않는다** — 그때 새 폴더는 맨 위에 선다(길이 안 보이는데 안 보이는 폴더 안에 만들면 안 된다).
|
|
12
|
+
* · 폴더를 열면 **첫 쪽으로** 돌아간다(`onOpen`) — 3쪽을 보다가 폴더에 들어가면 그 폴더의 3쪽(대개 빈 화면)이 선다.
|
|
13
|
+
* · 들어가 있던 폴더가 옮겨지거나 이름이 바뀌면 **그 새 길로 따라간다** — 안 따라가면 맨 위로 튕긴다.
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export function useFolderBrowse({ paths, search, onOpen }) {
|
|
17
|
+
const [pick, setPick] = useState(null);
|
|
18
|
+
const opened = pick && paths.includes(pick) ? pick : null;
|
|
19
|
+
const searching = search.trim() !== '';
|
|
20
|
+
const open = useCallback((path) => { setPick(path); onOpen?.(); }, [onOpen]);
|
|
21
|
+
/** 폴더 `from` 이 `into` 안으로 옮겨졌다 — 그 안에 들어가 있었으면 새 길로 따라간다 */
|
|
22
|
+
const followMove = useCallback((from, into) => {
|
|
23
|
+
setPick(now => folderMoved(now, from, into) ?? now);
|
|
24
|
+
}, []);
|
|
25
|
+
/** 폴더 `from` 의 길이 `to` 로 바뀌었다(이름 바꾸기) — 그 안에 들어가 있었으면 새 길로 따라간다 */
|
|
26
|
+
const followRename = useCallback((from, to) => {
|
|
27
|
+
setPick(now => (now === from ? to : now?.startsWith(`${from}/`) ? to + now.slice(from.length) : now));
|
|
28
|
+
}, []);
|
|
29
|
+
/** 맨 위로 — 보기(갈래)를 바꿀 때 */
|
|
30
|
+
const reset = useCallback(() => setPick(null), []);
|
|
31
|
+
/** 새 폴더가 설 자리 — 찾는 중에는 맨 위 */
|
|
32
|
+
const newFolderParent = searching ? null : opened;
|
|
33
|
+
return {
|
|
34
|
+
opened, searching, open, reset, followMove, followRename, newFolderParent,
|
|
35
|
+
/** 새 폴더가 설 자리에 이미 있는 이름들 — 같은 이름을 또 못 짓게 견준다 */
|
|
36
|
+
siblingNames: folderChildren(paths, newFolderParent).map(folderLeaf),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** @public 목록 쪽당 개수의 기본값 — 말귀 회원앱 목록들이 쓰던 넷 */
|
|
2
|
+
export declare const DEFAULT_PAGE_SIZES: readonly [10, 25, 50, 100];
|
|
3
|
+
/**
|
|
4
|
+
* **"N개씩 보기" 보기 목록** — `Toolbar` 의 `pageSize.options` · `Dropdown` 에 그대로 넘긴다(말귀 청 (437) ㉳ⓐ, 2026-11-13).
|
|
5
|
+
*
|
|
6
|
+
* 코어가 `ListPopup` 안에서 `common.pageSizeLabel` 로 이 목록을 짓고도 내주지 않아, 말귀 앱 · 어드민이 사전 열쇠 세 벌과
|
|
7
|
+
* 박은 한국어로 같은 것을 다시 지었다. 문구는 사전(`common.pageSizeLabel` — `{{n}}개씩 보기` · `Show {{n}}`) 한 벌이고,
|
|
8
|
+
* 값(몇 개씩)은 화면마다 다르니 받는다. 값은 문자열로 돌려준다(드롭다운 값이 문자열이다).
|
|
9
|
+
*
|
|
10
|
+
* ```tsx
|
|
11
|
+
* const options = usePageSizeOptions() // 10 · 25 · 50 · 100
|
|
12
|
+
* const cards = usePageSizeOptions([12, 24, 48]) // 화면마다 다른 값
|
|
13
|
+
* ```
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export declare function usePageSizeOptions(counts?: readonly number[]): {
|
|
17
|
+
value: string;
|
|
18
|
+
label: string;
|
|
19
|
+
}[];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
/** @public 목록 쪽당 개수의 기본값 — 말귀 회원앱 목록들이 쓰던 넷 */
|
|
5
|
+
export const DEFAULT_PAGE_SIZES = [10, 25, 50, 100];
|
|
6
|
+
/**
|
|
7
|
+
* **"N개씩 보기" 보기 목록** — `Toolbar` 의 `pageSize.options` · `Dropdown` 에 그대로 넘긴다(말귀 청 (437) ㉳ⓐ, 2026-11-13).
|
|
8
|
+
*
|
|
9
|
+
* 코어가 `ListPopup` 안에서 `common.pageSizeLabel` 로 이 목록을 짓고도 내주지 않아, 말귀 앱 · 어드민이 사전 열쇠 세 벌과
|
|
10
|
+
* 박은 한국어로 같은 것을 다시 지었다. 문구는 사전(`common.pageSizeLabel` — `{{n}}개씩 보기` · `Show {{n}}`) 한 벌이고,
|
|
11
|
+
* 값(몇 개씩)은 화면마다 다르니 받는다. 값은 문자열로 돌려준다(드롭다운 값이 문자열이다).
|
|
12
|
+
*
|
|
13
|
+
* ```tsx
|
|
14
|
+
* const options = usePageSizeOptions() // 10 · 25 · 50 · 100
|
|
15
|
+
* const cards = usePageSizeOptions([12, 24, 48]) // 화면마다 다른 값
|
|
16
|
+
* ```
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export function usePageSizeOptions(counts = DEFAULT_PAGE_SIZES) {
|
|
20
|
+
const { t } = useTranslation();
|
|
21
|
+
const key = counts.join(',');
|
|
22
|
+
return useMemo(() => counts.map(n => ({ value: String(n), label: t('common.pageSizeLabel', { n, defaultValue: '{{n}}개씩 보기' }) })),
|
|
23
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- 값 목록은 내용(key)으로 견준다 — 부르는 쪽이 매 그림 새 배열을 넘겨도 다시 안 짓는다
|
|
24
|
+
[key, t]);
|
|
25
|
+
}
|
|
@@ -33,3 +33,6 @@ export type { UseAnchoredMenuOptions, UseAnchoredMenuResult } from './hooks/useA
|
|
|
33
33
|
export { useSoundCompassExam } from './hooks/useSoundCompassExam';
|
|
34
34
|
export type { SoundCompassMode, SoundCompassPhase, SoundCompassExam, UseSoundCompassExamOptions } from './hooks/useSoundCompassExam';
|
|
35
35
|
export { useInlineSvg } from './hooks/useInlineSvg';
|
|
36
|
+
export * from './hooks/useFolderBrowse';
|
|
37
|
+
export * from './hooks/useCardDragToGroup';
|
|
38
|
+
export * from './hooks/usePageSizeOptions';
|
|
@@ -37,3 +37,7 @@ export { useAnchoredMenu } from './hooks/useAnchoredMenu';
|
|
|
37
37
|
export { useSoundCompassExam } from './hooks/useSoundCompassExam';
|
|
38
38
|
/* SVG 글자를 얻는다 — 속에 넣어 칠하려는 쪽이 쓴다(`BrandLogo` 의 `textColor`). */
|
|
39
39
|
export { useInlineSvg } from './hooks/useInlineSvg';
|
|
40
|
+
/* 폴더 화면(말귀 청 (437) ㉮, 2026-11-13) — 지금 연 폴더 · 카드를 끌어 폴더에 놓기 */
|
|
41
|
+
export * from './hooks/useFolderBrowse';
|
|
42
|
+
export * from './hooks/useCardDragToGroup';
|
|
43
|
+
export * from './hooks/usePageSizeOptions'; // "N개씩 보기" 목록(말귀 청 (437) ㉳ⓐ)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **폴더 메뉴의 줄** — 길의 「이름 ▾」 와 폴더 칸의 ⋯ 가 여는 메뉴(말귀 청 (437) ㉮ — 말귀 앱에서 옮겨 왔다, 2026-11-13).
|
|
3
|
+
*
|
|
4
|
+
* 화면마다 차례와 아이콘이 갈리면 안 되는 자리다: **더하기 → 폴더 추가 → (이름 바꾸기) → 폴더 삭제**. 구분선은 없고, 줄을 고르면 닫힌다.
|
|
5
|
+
* 이름표는 부르는 쪽이 준다(무엇을 '더하는지' 는 화면마다 다르다 — 단어표 · 훈련 …).
|
|
6
|
+
* · 맨 위의 메뉴는 `rename` · `remove` 를 안 준다(지울 폴더가 없다).
|
|
7
|
+
* · 이름 바꾸기는 그 일이 있는 화면만 준다.
|
|
8
|
+
* 돌려준 줄은 `FolderHead` 의 `folderMenu` · `rootMenu`, `FolderGrid` 의 `menuItems` 에 그대로 넘긴다.
|
|
9
|
+
*/
|
|
10
|
+
/** @public 메뉴 한 줄 — 이름표와 할 일 */
|
|
11
|
+
export interface FolderMenuLine {
|
|
12
|
+
label: string;
|
|
13
|
+
onClick: () => void;
|
|
14
|
+
}
|
|
15
|
+
/** @public 폴더 메뉴의 줄을 정해진 차례 · 아이콘으로 짓는다 */
|
|
16
|
+
export declare function folderMenuItems(lines: {
|
|
17
|
+
/** 이 자리에 하나 더 만든다(무엇을 만드는지는 화면 몫) */
|
|
18
|
+
add: FolderMenuLine;
|
|
19
|
+
addFolder: FolderMenuLine;
|
|
20
|
+
rename?: FolderMenuLine;
|
|
21
|
+
remove?: FolderMenuLine;
|
|
22
|
+
}): {
|
|
23
|
+
label: string;
|
|
24
|
+
icon: string;
|
|
25
|
+
onClick: () => void;
|
|
26
|
+
closeOnSelect: true;
|
|
27
|
+
}[];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **폴더 메뉴의 줄** — 길의 「이름 ▾」 와 폴더 칸의 ⋯ 가 여는 메뉴(말귀 청 (437) ㉮ — 말귀 앱에서 옮겨 왔다, 2026-11-13).
|
|
3
|
+
*
|
|
4
|
+
* 화면마다 차례와 아이콘이 갈리면 안 되는 자리다: **더하기 → 폴더 추가 → (이름 바꾸기) → 폴더 삭제**. 구분선은 없고, 줄을 고르면 닫힌다.
|
|
5
|
+
* 이름표는 부르는 쪽이 준다(무엇을 '더하는지' 는 화면마다 다르다 — 단어표 · 훈련 …).
|
|
6
|
+
* · 맨 위의 메뉴는 `rename` · `remove` 를 안 준다(지울 폴더가 없다).
|
|
7
|
+
* · 이름 바꾸기는 그 일이 있는 화면만 준다.
|
|
8
|
+
* 돌려준 줄은 `FolderHead` 의 `folderMenu` · `rootMenu`, `FolderGrid` 의 `menuItems` 에 그대로 넘긴다.
|
|
9
|
+
*/
|
|
10
|
+
/** @public 폴더 메뉴의 줄을 정해진 차례 · 아이콘으로 짓는다 */
|
|
11
|
+
export function folderMenuItems(lines) {
|
|
12
|
+
const row = (line, icon) => ({ ...line, icon, closeOnSelect: true });
|
|
13
|
+
return [
|
|
14
|
+
row(lines.add, 'plus'),
|
|
15
|
+
row(lines.addFolder, 'folder-plus'),
|
|
16
|
+
...(lines.rename ? [row(lines.rename, 'edit-2')] : []),
|
|
17
|
+
...(lines.remove ? [row(lines.remove, 'trash-2')] : []),
|
|
18
|
+
];
|
|
19
|
+
}
|
|
@@ -25,6 +25,8 @@ export { reorderArray, shuffle, sample } from './utils/array';
|
|
|
25
25
|
export { getErrorMessage, toUserErrorMessage, isNetworkErrorMessage, NETWORK_ERROR_MESSAGE } from './utils/errorMessage';
|
|
26
26
|
export { sortToValue, parseSortValue } from './utils/sortValue';
|
|
27
27
|
export { folderLeaf, folderParent, folderJoin, isFolderNameOk, isInFolder, withAncestors, folderChildren, folderTrail, folderTree, folderMoved, canMoveFolder, folderMoveVerdict, } from './utils/folderPath';
|
|
28
|
+
export { folderMenuItems } from './utils/folderMenu';
|
|
29
|
+
export type { FolderMenuLine } from './utils/folderMenu';
|
|
28
30
|
export { escapeCsvField, downloadCsvText } from './utils/csv';
|
|
29
31
|
export { setWordPool, getWordPool } from './utils/wordPool';
|
|
30
32
|
export type { WordPool, WordPoolEntry } from './utils/wordPool';
|
|
@@ -24,6 +24,7 @@ export { getErrorMessage, toUserErrorMessage, isNetworkErrorMessage, NETWORK_ERR
|
|
|
24
24
|
export { sortToValue, parseSortValue } from './utils/sortValue';
|
|
25
25
|
/* 폴더 안의 폴더 — 이름을 길로 적는 셈(말귀 청 (435), 2026-11-13). 그리는 조각은 `FolderHead` 식구다 */
|
|
26
26
|
export { folderLeaf, folderParent, folderJoin, isFolderNameOk, isInFolder, withAncestors, folderChildren, folderTrail, folderTree, folderMoved, canMoveFolder, folderMoveVerdict, } from './utils/folderPath';
|
|
27
|
+
export { folderMenuItems } from './utils/folderMenu'; // 폴더 메뉴의 줄(말귀 청 (437) ㉮)
|
|
27
28
|
export { escapeCsvField, downloadCsvText } from './utils/csv';
|
|
28
29
|
export { setWordPool, getWordPool } from './utils/wordPool';
|
|
29
30
|
export { setTrainingTimeLogger, logTrainingTime, setCrosswordLogger, logCrossword, setTrainingCompletionLogger, logTrainingCompletion } from './utils/trainingLogger';
|