@ihabdevteam/core 0.414.0 → 0.416.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.
Files changed (33) hide show
  1. package/CHANGELOG.md +360 -0
  2. package/dist/components.cjs.js +40 -40
  3. package/dist/components.esm.css +2 -2
  4. package/dist/hooks.cjs.js +3 -3
  5. package/dist/i18n.cjs.js +3 -3
  6. package/dist/ihabdevteam-core.cjs.js +181 -181
  7. package/dist/ihabdevteam-core.d.ts +33 -3
  8. package/dist/packages/core/src/components/BarChart.css +41 -13
  9. package/dist/packages/core/src/components/BarChart.d.ts +1 -1
  10. package/dist/packages/core/src/components/BarChart.js +52 -15
  11. package/dist/packages/core/src/components/ChartSection.css +149 -37
  12. package/dist/packages/core/src/components/ChartSection.d.ts +23 -1
  13. package/dist/packages/core/src/components/ChartSection.js +48 -7
  14. package/dist/packages/core/src/components/Header.css +3 -1
  15. package/dist/packages/core/src/components/RingChart.js +2 -2
  16. package/dist/packages/core/src/components/SideNav.css +44 -15
  17. package/dist/packages/core/src/components/SideNav.js +1 -1
  18. package/dist/packages/core/src/components/Word/WordSearchResultBlock.css +9 -0
  19. package/dist/packages/core/src/components/Word/WordSearchResultBlock.js +6 -1
  20. package/dist/packages/core/src/components/barChartData.d.ts +23 -0
  21. package/dist/packages/core/src/components/barChartData.js +30 -0
  22. package/dist/packages/core/src/components/barChartTypes.d.ts +8 -0
  23. package/dist/packages/core/src/components/useBarChartControl.js +17 -13
  24. package/dist/packages/core/src/hooks/useWideCardSpans.d.ts +28 -0
  25. package/dist/packages/core/src/hooks/useWideCardSpans.js +85 -0
  26. package/dist/packages/core/src/i18n/locales/en.json +2 -1
  27. package/dist/packages/core/src/i18n/locales/ko.json +1 -0
  28. package/dist/packages/core/src/utils/date.d.ts +12 -0
  29. package/dist/packages/core/src/utils/date.js +18 -0
  30. package/dist/packages/core/src/version.d.ts +1 -1
  31. package/dist/packages/core/src/version.js +1 -1
  32. package/dist/utils.cjs.js +3 -3
  33. package/package.json +1 -1
@@ -0,0 +1,85 @@
1
+ 'use client';
2
+ import { useCallback, useLayoutEffect, useRef } from 'react';
3
+ /**
4
+ * **칸보다 넓은 카드는 다음 칸까지 쓴다**(사장님 지시 2026-11-02 — *"가로가 길면 다음 칸
5
+ * 까지 사용하도록 해야지?"*).
6
+ *
7
+ * 낱말 묶음 격자는 **200px 고정 열**인데(`repeat(auto-fill, 200px)`), 그 안의 단추는
8
+ * 글 길이만큼 넓어진다(`min-width: 200px` 이고 넘침을 안 감춘다). 그래서 긴 묶음이 들면
9
+ * **단추가 제 칸을 넘어 옆 칸 위로 삐져나가고, 옆 카드가 그 위에 그려져 잘린 것처럼 보인다.**
10
+ *
11
+ * **아무 자도 그걸 못 잡는다** — `scrollWidth` 는 격자가 아니라 제 상자를 재니 멀쩡하고
12
+ * (실측 2026-11-02: 단추 `scrollWidth` 260 = `clientWidth` 260, 넘침 0으로 읽힌다),
13
+ * `overflow` 는 `visible` 이라 구르지도 잘리지도 않는다. 눈으로만 잡히던 자리다.
14
+ *
15
+ * 실측(2026-11-02 · 폭 1420 · 50묶음) — 열 200 × 6 · 틈 8. `가운뎃손가락 다리미질하다
16
+ * 콘트라베이스` 한 묶음이 **단추 262px** 라 62px 이 옆 칸을 덮었다. 두 칸이면 408px 이라 든다.
17
+ *
18
+ * ## 왜 CSS 로 못 하나
19
+ *
20
+ * 격자는 **칸 수를 글 길이로 못 정한다.** `max-content` 로 열을 잡으면 **가장 긴 묶음의 폭이
21
+ * 모든 열에 퍼져** 짧은 묶음 사이가 휑해지고(이 파일 CSS 머리말에 그 자취가 있다),
22
+ * `1fr` 로 늘리면 단추가 열을 못 채워 같은 일이 난다. 그래서 **재서 칸 수를 적는다.**
23
+ *
24
+ * 그리기 **직후에** 잰다(`useLayoutEffect`) — 효과가 늦으면 한 틱 동안 덮인 채 보인다.
25
+ * 폭이 바뀌면 열 수가 달라지므로 `ResizeObserver` 로 다시 잰다.
26
+ *
27
+ * @param deps 다시 재야 하는 때(묶음 목록·쪽·정렬이 바뀔 때).
28
+ * @returns 격자들을 **감싸는** 자리에 다는 자리표(격자 자체가 아니다 — 여럿일 수 있다).
29
+ */
30
+ export function useWideCardSpans(deps = []) {
31
+ const ref = useRef(null);
32
+ /* **격자가 여럿일 수 있다** — 묶어서 보여 줄 때는 묶음마다 제 격자를 세운다. 그래서
33
+ 자리표는 **격자가 아니라 그 바깥**에 달고, 안의 격자를 다 찾아 하나씩 잰다(격자에 달면
34
+ 마지막 하나만 잡힌다). */
35
+ const measureGrid = useCallback((grid) => {
36
+ const style = getComputedStyle(grid);
37
+ /* 열 하나의 폭과 틈을 **격자에게 묻는다** — 200·8 을 여기 또 적으면 CSS 를 고칠 때
38
+ 이 자리만 옛 수로 남는다. */
39
+ const columns = style.gridTemplateColumns.split(' ').filter(Boolean);
40
+ const column = parseFloat(columns[0] ?? '0');
41
+ const gap = parseFloat(style.columnGap || '0') || 0;
42
+ if (!column || columns.length < 2) { // 열이 하나뿐인 좁은 판은 넓힐 데가 없다
43
+ for (const cell of grid.children)
44
+ cell.style.gridColumn = '';
45
+ return;
46
+ }
47
+ for (const node of grid.children) {
48
+ const cell = node;
49
+ /* **단추의 제 폭**을 재려면 먼저 자리표를 걷는다 — 지난번에 넓혀 둔 칸이 그대로면
50
+ 단추가 그 폭에 맞춰져 "이제 안 넘친다" 로 읽힌다(고친 뒤 다시 좁아지지 않는다). */
51
+ cell.style.gridColumn = '';
52
+ cell.removeAttribute('data-wide');
53
+ const button = cell.querySelector('button');
54
+ const need = button ? button.getBoundingClientRect().width : 0;
55
+ if (need <= column + 0.5)
56
+ continue;
57
+ const span = Math.min(columns.length, Math.ceil((need + gap) / (column + gap)));
58
+ if (span <= 1)
59
+ continue;
60
+ cell.style.gridColumn = `span ${span}`;
61
+ /* **넓힌 칸은 카드가 채운다** — 칸만 넓히면 단추는 제 글 폭(262)에 머물러 오른쪽에
62
+ 146px 이 빈다(실측 2026-11-02). 격자에 구멍이 난 것처럼 보인다. 채우는 일은 CSS 가
63
+ 하고(`[data-wide]`), 여기서는 **어느 칸이 넓은지만** 표시한다. */
64
+ cell.setAttribute('data-wide', '');
65
+ }
66
+ }, []);
67
+ const measure = useCallback(() => {
68
+ const root = ref.current;
69
+ if (!root)
70
+ return;
71
+ for (const grid of root.querySelectorAll('.word-search-result-block__items'))
72
+ measureGrid(grid);
73
+ }, [measureGrid]);
74
+ useLayoutEffect(() => {
75
+ measure();
76
+ const root = ref.current;
77
+ if (!root || typeof ResizeObserver === 'undefined')
78
+ return;
79
+ const watch = new ResizeObserver(() => measure());
80
+ watch.observe(root);
81
+ return () => watch.disconnect();
82
+ // eslint-disable-next-line react-hooks/exhaustive-deps
83
+ }, [measure, ...deps]);
84
+ return ref;
85
+ }
@@ -115,8 +115,9 @@
115
115
  "Fri",
116
116
  "Sat"
117
117
  ],
118
- "yearMonthCompact": "{{full}}",
118
+ "yearMonthCompact": "{{short}}",
119
119
  "weekLabel": "Week {{ord}}",
120
+ "weekLabelCompact": "W{{ord}}",
120
121
  "prevMonth": "Previous month",
121
122
  "addOnDate": "Add a visit on {{date}}",
122
123
  "nextMonth": "Next month",
@@ -122,6 +122,7 @@
122
122
  ],
123
123
  "yearMonthCompact": "{{year}}.{{month}}",
124
124
  "weekLabel": "{{ord}}주",
125
+ "weekLabelCompact": "{{ord}}주",
125
126
  "prevMonth": "이전 달",
126
127
  "addOnDate": "{{date}}에 방문 등록",
127
128
  "nextMonth": "다음 달",
@@ -41,6 +41,18 @@ export declare function formatDateLocale(iso: string, lang: string): string;
41
41
  */
42
42
  export declare function intlLocale(lang: string): string;
43
43
  export declare function formatYearMonth(year: number, month: number, lang: string): string;
44
+ /**
45
+ * **달 이름을 줄인 연월** — `September 2026` 대신 `Sep 2026`.
46
+ *
47
+ * 긴 꼴은 차트 카드 머리의 기간 고르개에 **안 들어간다.** 실측(2026-11-03, 카드 540 ·
48
+ * 글자 16px): `September 2026 Week 4` 는 이름표 칸 100 에 **179** 가 필요해 `September …`
49
+ * 로 잘렸고, 상자를 글에 맞춰 늘리면 229 가 되어 **머리가 두 줄로 접혔다**(32 → 63).
50
+ * 달 이름을 줄이면 `May 2026 Week 4` 가 가장 길어 **130** — 상자 180 으로 한 줄에 선다.
51
+ *
52
+ * **`formatYearMonth`(긴 꼴)은 그대로 둔다** — 달력 머리줄(`Calendar`)이 쓰는 자리라
53
+ * 거기서는 달 이름이 온전히 보여야 한다. 줄인 꼴이 필요한 자리만 이것을 부른다.
54
+ */
55
+ export declare function formatYearMonthShort(year: number, month: number, lang: string): string;
44
56
  /**
45
57
  * **연·월 이름표 — 사전이 있으면 사전, 없으면 브라우저.** @public
46
58
  *
@@ -122,6 +122,24 @@ export function formatYearMonth(year, month, lang) {
122
122
  return `${year}-${month}`;
123
123
  return new Intl.DateTimeFormat(intlLocale(lang), { year: 'numeric', month: 'long' }).format(new Date(year, month - 1, 1));
124
124
  }
125
+ /**
126
+ * **달 이름을 줄인 연월** — `September 2026` 대신 `Sep 2026`.
127
+ *
128
+ * 긴 꼴은 차트 카드 머리의 기간 고르개에 **안 들어간다.** 실측(2026-11-03, 카드 540 ·
129
+ * 글자 16px): `September 2026 Week 4` 는 이름표 칸 100 에 **179** 가 필요해 `September …`
130
+ * 로 잘렸고, 상자를 글에 맞춰 늘리면 229 가 되어 **머리가 두 줄로 접혔다**(32 → 63).
131
+ * 달 이름을 줄이면 `May 2026 Week 4` 가 가장 길어 **130** — 상자 180 으로 한 줄에 선다.
132
+ *
133
+ * **`formatYearMonth`(긴 꼴)은 그대로 둔다** — 달력 머리줄(`Calendar`)이 쓰는 자리라
134
+ * 거기서는 달 이름이 온전히 보여야 한다. 줄인 꼴이 필요한 자리만 이것을 부른다.
135
+ */
136
+ export function formatYearMonthShort(year, month, lang) {
137
+ /* 범위 밖을 받으면 긴 꼴과 **같은 꼴로** 돌려준다 — 두 함수가 같은 입력에 다른 말을
138
+ 하면 어느 쪽이 맞는지 부르는 쪽이 못 가린다. */
139
+ if (!Number.isFinite(year) || !Number.isFinite(month) || month < 1 || month > 12)
140
+ return `${year}-${month}`;
141
+ return new Intl.DateTimeFormat(intlLocale(lang), { year: 'numeric', month: 'short' }).format(new Date(year, month - 1, 1));
142
+ }
125
143
  /**
126
144
  * **연·월 이름표 — 사전이 있으면 사전, 없으면 브라우저.** @public
127
145
  *
@@ -46,4 +46,4 @@
46
46
  *
47
47
  * 값은 손으로 적고 `test/coreVersion.test.ts` 가 package.json 과 어긋나면 운다.
48
48
  */
49
- export declare const CORE_VERSION = "0.414.0";
49
+ export declare const CORE_VERSION = "0.416.0";
@@ -46,4 +46,4 @@
46
46
  *
47
47
  * 값은 손으로 적고 `test/coreVersion.test.ts` 가 package.json 과 어긋나면 운다.
48
48
  */
49
- export const CORE_VERSION = '0.414.0';
49
+ export const CORE_VERSION = '0.416.0';