@edu-tosel/design 1.0.275 → 1.0.277

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.
@@ -1 +1 @@
1
- export default function formatDateToString(date: Date): string;
1
+ export default function formatDateToString(date: Date, formatType?: "dash" | "dot" | "koreanYYMM"): string;
@@ -1,6 +1,13 @@
1
- export default function formatDateToString(date) {
2
- const year = date.getFullYear();
3
- const month = (date.getMonth() + 1).toString().padStart(2, "0"); // 월은 0부터 시작하므로 +1
4
- const day = date.getDate().toString().padStart(2, "0"); // 날짜를 두 자리로 맞춤
5
- return `${year}-${month}-${day}`;
1
+ export default function formatDateToString(date, formatType) {
2
+ const fullYear = date.getFullYear();
3
+ const shortYear = fullYear % 100; // 자리 연도
4
+ const month = (date.getMonth() + 1).toString().padStart(2, "0");
5
+ const day = date.getDate().toString().padStart(2, "0");
6
+ if (formatType === "dot") {
7
+ return `${shortYear}.${month}.${day}`; // YY.MM.DD 형식
8
+ }
9
+ if (formatType === "koreanYYMM") {
10
+ return `${shortYear}년 ${month}월`; // YY년 MM월 형식
11
+ }
12
+ return `${fullYear}-${month}-${day}`; // 기본: YYYY-MM-DD
6
13
  }
@@ -207,32 +207,40 @@ function createSearch({ record, } = {}) {
207
207
  const lowerQuery = query.toLowerCase();
208
208
  const isHangulQuery = isHangul(query);
209
209
  const queryChoseong = isHangulQuery ? getChoseong(query) : "";
210
- // **정확한 일치 (Exact Match)**
211
- const entireMatch = entries
212
- .filter(([_, value]) => {
213
- const normalizedValue = value.toLowerCase();
214
- return (normalizedValue === lowerQuery ||
215
- new RegExp(`\\b${lowerQuery}`).test(normalizedValue));
216
- })
217
- .map(([key, value]) => [
218
- key,
219
- record[key]?.[0] ?? value, // 첫 번째 키워드가 없을 경우 value를 기본값으로 사용
220
- value,
221
- ]);
222
- // **초성 매칭 (Choseong Match)**
223
- const choseongMatch = isHangulQuery
224
- ? choseongEntries
225
- .map((value, index) => ({ index, value }))
226
- .filter(({ value: [_, value] }) => value.includes(queryChoseong))
227
- .map(({ index }) => {
228
- const key = entries[index][0];
229
- return [
230
- key,
231
- record[key]?.[0] ?? entries[index][1], // 첫 번째 키워드가 없을 경우 대체
232
- entries[index][1],
233
- ];
210
+ const isChoseong = getConstantVowel(lowerQuery[0] ?? "");
211
+ // console.log(`${lowerQuery[0]}: ${isChoseong}`);
212
+ let entireMatch = [];
213
+ if (!isChoseong) {
214
+ // **정확한 일치 (Exact Match)**
215
+ entireMatch = entries
216
+ .filter(([_, value]) => {
217
+ const normalizedValue = value.toLowerCase();
218
+ return (normalizedValue === lowerQuery || value.includes(lowerQuery) ||
219
+ new RegExp(`\\b${lowerQuery}`).test(normalizedValue));
234
220
  })
235
- : [];
221
+ .map(([key, value]) => [
222
+ key,
223
+ record[key]?.[0] ?? value, // 첫 번째 키워드가 없을 경우 value를 기본값으로 사용
224
+ value,
225
+ ]);
226
+ }
227
+ let choseongMatch = [];
228
+ if (isChoseong) {
229
+ // **초성 매칭 (Choseong Match)**
230
+ choseongMatch = isHangulQuery
231
+ ? choseongEntries
232
+ .map((value, index) => ({ index, value }))
233
+ .filter(({ value: [_, value] }) => value.includes(queryChoseong))
234
+ .map(({ index }) => {
235
+ const key = entries[index][0];
236
+ return [
237
+ key,
238
+ record[key]?.[0] ?? entries[index][1], // 첫 번째 키워드가 없을 경우 대체
239
+ entries[index][1],
240
+ ];
241
+ })
242
+ : [];
243
+ }
236
244
  // **중복 제거 (EntireMatch에 포함된 키 제거)**
237
245
  const entireMatchKeys = new Set(entireMatch.map(([key]) => key));
238
246
  const filteredChoseongMatch = choseongMatch.filter(([key]) => !entireMatchKeys.has(key));
@@ -253,5 +261,14 @@ function createSearch({ record, } = {}) {
253
261
  };
254
262
  return { search };
255
263
  }
264
+ const getConstantVowel = (kor) => {
265
+ const ga = 44032;
266
+ let uni = kor.charCodeAt(0);
267
+ uni = uni - ga;
268
+ let fn = Math.floor(uni / 588);
269
+ // let sn = Math.floor((uni - (fn * 588)) / 28);
270
+ // let tn = uni % 28;
271
+ return fn < 0;
272
+ };
256
273
  const { search } = createSearch();
257
274
  export default search;
package/version.txt CHANGED
@@ -1 +1 @@
1
- 1.0.275
1
+ 1.0.277