@kalyx/core 0.2.0 → 0.3.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/dist/index.d.cts CHANGED
@@ -1,21 +1,21 @@
1
1
  /**
2
- * @kalyx/core 타입 정의
2
+ * @kalyx/core type definitions.
3
3
  *
4
- * 모든 날짜 값은 ISO 8601 UTC string으로 표현한다.
5
- * native Date 객체는 사용하지 않는다.
4
+ * All date values are represented as ISO 8601 UTC strings.
5
+ * Native Date objects are not used.
6
6
  */
7
- /** ISO 8601 UTC 날짜 문자열. 예: "2026-01-15T00:00:00.000Z" */
7
+ /** ISO 8601 UTC date string. e.g. "2026-01-15T00:00:00.000Z" */
8
8
  type ISODateString = string;
9
9
  /**
10
- * 날짜 비활성화 규칙. 여러 규칙을 배열로 조합할 있다.
10
+ * Date-disable rules. Multiple rules can be combined in an array.
11
11
  *
12
12
  * @example
13
13
  * ```ts
14
14
  * const rules: DisabledRule[] = [
15
- * { before: '2026-01-01T00:00:00.000Z' }, // 1월 1일 이전 비활성화
16
- * { after: '2026-12-31T00:00:00.000Z' }, // 12월 31일 이후 비활성화
17
- * { date: '2026-06-15T00:00:00.000Z' }, // 특정 날짜 비활성화
18
- * { dayOfWeek: [0, 6] }, // 주말 비활성화
15
+ * { before: '2026-01-01T00:00:00.000Z' }, // disable before Jan 1
16
+ * { after: '2026-12-31T00:00:00.000Z' }, // disable after Dec 31
17
+ * { date: '2026-06-15T00:00:00.000Z' }, // disable a specific date
18
+ * { dayOfWeek: [0, 6] }, // disable weekends
19
19
  * ];
20
20
  * ```
21
21
  */
@@ -28,46 +28,46 @@ type DisabledRule = {
28
28
  } | {
29
29
  dayOfWeek: number[];
30
30
  };
31
- /** 날짜 범위 (RangePicker) */
31
+ /** Date range (RangePicker) */
32
32
  interface DateRange {
33
33
  start: ISODateString | null;
34
34
  end: ISODateString | null;
35
35
  }
36
- /** 캘린더 그리드의 하루를 표현하는 타입 */
36
+ /** Represents a single day in the calendar grid */
37
37
  interface CalendarDay {
38
38
  /** ISO 8601 UTC string */
39
39
  isoString: ISODateString;
40
- /** 날짜 숫자 (1-31) */
40
+ /** Day of month (1-31) */
41
41
  dayNumber: number;
42
- /** 현재 표시 중인 달에 속하는지 */
42
+ /** Whether this day belongs to the currently displayed month */
43
43
  isCurrentMonth: boolean;
44
- /** 오늘인지 */
44
+ /** Whether this day is today */
45
45
  isToday: boolean;
46
- /** 선택된 날짜인지 (단일 선택) */
46
+ /** Whether this day is the selected date (single selection) */
47
47
  isSelected: boolean;
48
- /** 비활성화 상태인지 */
48
+ /** Whether this day is disabled */
49
49
  isDisabled: boolean;
50
- /** 포커스된 날짜인지 */
50
+ /** Whether this day is focused */
51
51
  isFocused: boolean;
52
- /** 범위의 시작일인지 */
52
+ /** Whether this day is the start of a range */
53
53
  isRangeStart: boolean;
54
- /** 범위의 종료일인지 */
54
+ /** Whether this day is the end of a range */
55
55
  isRangeEnd: boolean;
56
- /** 범위 내부 (시작과 종료 사이)인지 */
56
+ /** Whether this day is inside a range (between start and end) */
57
57
  isInRange: boolean;
58
58
  }
59
- /** 캘린더 그리드: 주(week) 배열 일(day) 배열 */
59
+ /** Calendar grid: array of weeks, each week is an array of days */
60
60
  type CalendarWeek = CalendarDay[];
61
61
  type CalendarGrid = CalendarWeek[];
62
62
  /**
63
- * 날짜 라이브러리 어댑터 인터페이스.
64
- * 모든 날짜 연산을 추상화하여 다른 라이브러리(Temporal API) 교체 가능.
65
- * 기본 구현체: {@link DateFnsAdapter}
63
+ * Date library adapter interface.
64
+ * Abstracts all date operations so the underlying library (e.g. Temporal API) can be swapped.
65
+ * Default implementation: {@link DateFnsAdapter}
66
66
  */
67
67
  interface DateAdapter {
68
- /** 어떤 형식이든 → ISO 8601 UTC string */
68
+ /** Any format → ISO 8601 UTC string */
69
69
  parse(value: string, format?: string): string;
70
- /** ISO string → 화면 표시용 string */
70
+ /** ISO string → display string */
71
71
  format(iso: string, formatStr: string, timezone?: string): string;
72
72
  addDays(iso: string, n: number): string;
73
73
  addMonths(iso: string, n: number): string;
@@ -89,24 +89,24 @@ interface DateAdapter {
89
89
  getDate(iso: string): number;
90
90
  getDay(iso: string): number;
91
91
  }
92
- /** 시작 요일 */
92
+ /** First day of the week */
93
93
  type WeekStartsOn = 0 | 1;
94
- /** 캘린더 그리드 생성 옵션 */
94
+ /** Options for generating a calendar grid */
95
95
  interface CalendarOptions {
96
96
  weekStartsOn?: WeekStartsOn;
97
97
  today?: ISODateString;
98
98
  selected?: ISODateString | null;
99
99
  focusedDate?: ISODateString;
100
100
  disabled?: DisabledRule[];
101
- /** 선택된 범위 (RangePicker) */
101
+ /** Selected range (RangePicker) */
102
102
  range?: DateRange | null;
103
- /** 호버 중인 날짜 (RangePicker 미리보기용) */
103
+ /** Currently hovered date (for RangePicker preview) */
104
104
  rangeHover?: ISODateString | null;
105
105
  }
106
106
 
107
107
  /**
108
- * date-fns 기반 DateAdapter 구현체.
109
- * 모든 연산은 UTC 기준으로 동작하여 timezone 간섭을 방지한다.
108
+ * DateAdapter implementation backed by date-fns.
109
+ * All operations run in UTC to avoid timezone interference.
110
110
  *
111
111
  * @example
112
112
  * ```ts
@@ -120,13 +120,13 @@ interface CalendarOptions {
120
120
  declare const DateFnsAdapter: DateAdapter;
121
121
 
122
122
  /**
123
- * 특정 월의 캘린더 그리드를 생성한다.
124
- * 주(week) 단위로 구분된 2차원 배열(`CalendarGrid`) 반환한다.
123
+ * Builds the calendar grid for the given month.
124
+ * Returns a 2D array (`CalendarGrid`) organized by week.
125
125
  *
126
- * @param monthISO - 표시할 월을 포함하는 ISO datetime
127
- * @param adapter - 날짜 연산 어댑터 ({@link DateFnsAdapter})
128
- * @param options - 시작 요일, 선택된 날짜, 비활성화 규칙, 범위
129
- * @returns 4~6주의 캘린더 그리드. 주는 7개의 {@link CalendarDay} 배열.
126
+ * @param monthISO - ISO datetime containing the month to display
127
+ * @param adapter - Date operation adapter ({@link DateFnsAdapter})
128
+ * @param options - Week start day, selected date, disabled rules, range, etc.
129
+ * @returns A calendar grid of 4-6 weeks. Each week is an array of 7 {@link CalendarDay}.
130
130
  *
131
131
  * @example
132
132
  * ```ts
@@ -135,122 +135,214 @@ declare const DateFnsAdapter: DateAdapter;
135
135
  * selected: '2026-01-15T00:00:00.000Z',
136
136
  * disabled: [{ dayOfWeek: [0, 6] }],
137
137
  * });
138
- * // grid[0] = 첫째 (CalendarDay[7])
139
- * // grid[0][0].dayNumber = 28 (이전 )
138
+ * // grid[0] = first week (CalendarDay[7])
139
+ * // grid[0][0].dayNumber = 28 (previous month)
140
140
  * ```
141
141
  */
142
142
  declare function getCalendarDays(monthISO: string, adapter: DateAdapter, options?: CalendarOptions): CalendarGrid;
143
143
  /**
144
- * 주어진 날짜가 비활성화 규칙에 해당하는지 검사한다.
144
+ * Checks whether the given date matches any disable rule.
145
145
  */
146
146
  declare function isDateDisabled(iso: string, rules: DisabledRule[], adapter: DateAdapter): boolean;
147
147
  /**
148
- * 날짜 이른 것을 반환한다.
148
+ * Returns the earlier of two dates.
149
149
  */
150
150
  declare function minDate(a: ISODateString, b: ISODateString, adapter: DateAdapter): ISODateString;
151
151
  /**
152
- * 날짜 늦은 것을 반환한다.
152
+ * Returns the later of two dates.
153
153
  */
154
154
  declare function maxDate(a: ISODateString, b: ISODateString, adapter: DateAdapter): ISODateString;
155
155
 
156
156
  /**
157
- * 날짜 문자열을 ISO 8601 UTC 형식으로 정규화한다.
157
+ * Normalizes a date string to ISO 8601 UTC form.
158
158
  * "2026-01-15" → "2026-01-15T00:00:00.000Z"
159
+ *
160
+ * Full datetime strings must include a timezone suffix (Z or ±HH:MM).
161
+ * Strings without a timezone suffix are treated as-is (not matched as datetime).
159
162
  */
160
163
  declare function normalizeISO(value: string): string;
161
164
  /**
162
- * 사용자 입력 텍스트를 ISO string으로 파싱한다.
163
- * 실패 null 반환한다.
165
+ * Parses user input text into an ISO string.
166
+ * Returns null on failure.
164
167
  */
165
- declare function parseInputValue(input: string, format: string, adapter: DateAdapter): string | null;
168
+ declare function parseInputValue(input: string, adapter: DateAdapter): string | null;
166
169
 
167
- /** 시간 표현 (24시간제 기준) */
170
+ /** Time-of-day value (24-hour clock) */
168
171
  interface TimeValue {
169
172
  hours: number;
170
173
  minutes: number;
171
174
  seconds: number;
172
175
  }
173
176
  /**
174
- * ISO datetime의 시간 부분을 변경한다.
175
- * UTC 기준으로 동작한다.
177
+ * Replaces the time portion of an ISO datetime.
178
+ * Operates in UTC.
176
179
  */
177
180
  declare function setTime(iso: ISODateString, time: Partial<TimeValue>): ISODateString;
178
181
  /**
179
- * ISO datetime에서 시간 부분만 추출한다.
182
+ * Extracts the time portion of an ISO datetime.
180
183
  */
181
184
  declare function getTime(iso: ISODateString): TimeValue;
182
185
  /**
183
- * "HH:MM" 또는 "HH:MM:SS" 문자열을 TimeValue로 파싱한다.
184
- * 잘못된 형식이면 null 반환.
186
+ * Parses an "HH:MM" or "HH:MM:SS" string into a TimeValue.
187
+ * Returns null on invalid input.
185
188
  */
186
189
  declare function parseTimeString(input: string): TimeValue | null;
187
190
  /**
188
- * TimeValue "HH:MM" 또는 "HH:MM:SS" 문자열로 포맷팅한다.
191
+ * Formats a TimeValue as "HH:MM" or "HH:MM:SS".
189
192
  */
190
193
  declare function formatTimeString(time: TimeValue, withSeconds?: boolean): string;
191
194
  /**
192
- * 24시간제 12시간제 변환.
193
- * 0 → 12 AM, 12 → 12 PM
195
+ * Converts a 24-hour value to 12-hour form.
196
+ * 0 → 12 AM, 12 → 12 PM
194
197
  */
195
198
  declare function to12Hour(hours24: number): {
196
199
  hours12: number;
197
200
  period: 'AM' | 'PM';
198
201
  };
199
202
  /**
200
- * 12시간제 24시간제 변환.
203
+ * Converts a 12-hour value to 24-hour form.
201
204
  */
202
205
  declare function to24Hour(hours12: number, period: 'AM' | 'PM'): number;
203
206
  /**
204
- * 리스트 생성 (0-23 또는 1-12)
207
+ * Builds an hours list (0-23 or 1-12).
205
208
  */
206
209
  declare function generateHours(format?: '12h' | '24h'): number[];
207
210
  /**
208
- * 리스트 생성 (step 단위)
211
+ * Builds a minutes list at the given step.
209
212
  * step=1 → [0, 1, 2, ..., 59]
210
213
  * step=15 → [0, 15, 30, 45]
211
214
  * step=5 → [0, 5, 10, ..., 55]
212
215
  */
213
216
  declare function generateMinutes(step?: number): number[];
214
217
  /**
215
- * TimeValue가 동일한지 비교 (시·분·초 모두).
218
+ * Checks whether two TimeValues are identical (hours, minutes, and seconds).
216
219
  */
217
220
  declare function isSameTime(a: TimeValue, b: TimeValue): boolean;
218
221
  /**
219
- * ISO datetime 시간 문자열로 포맷팅 (UTC 기준).
220
- * 어댑터를 받아서 일관성 유지.
222
+ * Formats an ISO datetime as a time string (UTC based).
223
+ * Accepts an adapter for API consistency.
221
224
  */
222
- declare function formatTimeFromISO(iso: ISODateString, format: 'HH:mm' | 'HH:mm:ss' | 'h:mm a' | 'h:mm:ss a', _adapter?: DateAdapter): string;
225
+ declare function formatTimeFromISO(iso: ISODateString, format: 'HH:mm' | 'HH:mm:ss' | 'h:mm a' | 'h:mm:ss a'): string;
223
226
 
224
227
  interface WeekdayInfo {
225
- /** 짧은 이름 (예: "Su", "일") */
228
+ /** Short name (e.g. "Su", "일") */
226
229
  short: string;
227
- /** 전체 이름 (예: "Sunday", "일요일") */
230
+ /** Full name (e.g. "Sunday", "일요일") */
228
231
  full: string;
229
232
  }
230
233
  /**
231
- * Intl.DateTimeFormat으로 월 이름을 반환한다.
234
+ * Returns a localized month name via Intl.DateTimeFormat.
232
235
  * @param month 0-indexed (0 = January)
233
- * @param year 표시에만 사용 (일부 locale은 포함)
234
- * @param locale BCP 47 locale string (예: "en-US", "ko-KR", "ja-JP")
236
+ * @param locale BCP 47 locale string (e.g. "en-US", "ko-KR", "ja-JP")
235
237
  */
236
238
  declare function getMonthName(month: number, locale?: string): string;
237
239
  /**
238
- * "2026년 1월" 또는 "January 2026" 같은 월+년 문자열을 반환한다.
240
+ * Returns a month+year string like "January 2026" or "2026년 1월".
239
241
  */
240
242
  declare function formatMonthYear(year: number, month: number, locale?: string): string;
241
243
  /**
242
- * Intl.DateTimeFormat으로 주의 요일 이름 배열을 반환한다.
243
- * weekStartsOn에 맞춰 정렬.
244
+ * Returns localized weekday names via Intl.DateTimeFormat.
245
+ * Ordered according to weekStartsOn.
244
246
  *
245
247
  * @param locale BCP 47 locale string
246
248
  * @param weekStartsOn 0 = Sunday, 1 = Monday
247
- * @returns 7개의 WeekdayInfo 배열
249
+ * @returns Array of 7 WeekdayInfo entries
248
250
  */
249
251
  declare function getWeekdayNames(locale?: string, weekStartsOn?: WeekStartsOn): WeekdayInfo[];
250
252
  /**
251
- * Intl.DateTimeFormat으로 날짜의 전체 텍스트를 반환한다 (스크린리더용).
252
- * 예: "2026년 1월 15 목요일"
253
+ * Returns a fully formatted date string via Intl.DateTimeFormat (for screen readers).
254
+ * e.g. "Thursday, January 15, 2026"
253
255
  */
254
256
  declare function formatFullDate(iso: string, locale?: string): string;
255
257
 
256
- export { type CalendarDay, type CalendarGrid, type CalendarOptions, type CalendarWeek, type DateAdapter, DateFnsAdapter, type DateRange, type DisabledRule, type ISODateString, type TimeValue, type WeekStartsOn, type WeekdayInfo, formatFullDate, formatMonthYear, formatTimeFromISO, formatTimeString, generateHours, generateMinutes, getCalendarDays, getMonthName, getTime, getWeekdayNames, isDateDisabled, isSameTime, maxDate, minDate, normalizeISO, parseInputValue, parseTimeString, setTime, to12Hour, to24Hour };
258
+ /**
259
+ * Format a UTC ISO string for display in a specific IANA timezone.
260
+ * Handles DST transitions correctly. Supports a small set of tokens: `yyyy MM dd HH mm ss`.
261
+ *
262
+ * @param iso - UTC ISO 8601 string
263
+ * @param formatStr - token string (e.g. `"yyyy-MM-dd HH:mm"`)
264
+ * @param timeZone - IANA zone (e.g. `"America/New_York"`)
265
+ *
266
+ * @example
267
+ * formatInTimezone('2026-03-08T07:30:00.000Z', 'yyyy-MM-dd HH:mm', 'America/New_York');
268
+ * // → '2026-03-08 03:30' (post spring-forward EDT)
269
+ */
270
+ declare function formatInTimezone(iso: ISODateString, formatStr: string, timeZone: string): string;
271
+ /**
272
+ * UTC offset (minutes east of UTC) at a given UTC instant, as applied by the given timezone.
273
+ * The offset may differ on either side of a DST transition.
274
+ *
275
+ * @example
276
+ * getTimezoneOffsetMinutes('2026-03-08T06:00:00.000Z', 'America/New_York'); // -300 (EST, UTC-5)
277
+ * getTimezoneOffsetMinutes('2026-03-08T07:00:00.000Z', 'America/New_York'); // -240 (EDT, UTC-4)
278
+ * getTimezoneOffsetMinutes('2026-01-15T12:00:00.000Z', 'Asia/Seoul'); // 540 (UTC+9)
279
+ */
280
+ declare function getTimezoneOffsetMinutes(iso: ISODateString, timeZone: string): number;
281
+ /**
282
+ * Midnight of the civil date (as observed in `timeZone`) returned as a UTC ISO string.
283
+ *
284
+ * Across DST transitions this is the correct way to compute "start of day" — the offset
285
+ * changes, so the UTC instant of midnight differs before and after the transition.
286
+ *
287
+ * @example
288
+ * startOfDayInTimezone('2026-03-08T12:00:00.000Z', 'America/New_York'); // '2026-03-08T05:00:00.000Z' (EST)
289
+ * startOfDayInTimezone('2026-03-09T12:00:00.000Z', 'America/New_York'); // '2026-03-09T04:00:00.000Z' (EDT)
290
+ */
291
+ declare function startOfDayInTimezone(iso: ISODateString, timeZone: string): ISODateString;
292
+ /**
293
+ * Whether two UTC instants fall on the same civil day in the given timezone.
294
+ * Timezone-safe alternative to comparing `iso.slice(0, 10)`.
295
+ *
296
+ * @example
297
+ * // Seoul is UTC+9, so 03:00 UTC and 14:00 UTC are both on 2026-01-15 KST
298
+ * isSameDayInTimezone('2026-01-15T03:00:00.000Z', '2026-01-15T14:00:00.000Z', 'Asia/Seoul'); // true
299
+ * // But 17:00 UTC is 02:00 KST on 2026-01-16
300
+ * isSameDayInTimezone('2026-01-15T03:00:00.000Z', '2026-01-15T17:00:00.000Z', 'Asia/Seoul'); // false
301
+ */
302
+ declare function isSameDayInTimezone(a: ISODateString, b: ISODateString, timeZone: string): boolean;
303
+ /**
304
+ * "Today" in the given timezone, returned as the UTC ISO string representing that day's midnight.
305
+ * Prefer this over `new Date()` when the notion of "today" should follow the user's displayed
306
+ * timezone rather than the server's local clock.
307
+ */
308
+ declare function todayInTimezone(timeZone: string): ISODateString;
309
+
310
+ /**
311
+ * Default English labels for ARIA attributes and accessible text.
312
+ * Override via the `labels` prop on Root components.
313
+ */
314
+ interface DatePickerLabels {
315
+ triggerOpen: string;
316
+ triggerClose: string;
317
+ popoverLabel: string;
318
+ prevMonth: string;
319
+ nextMonth: string;
320
+ prevYear: string;
321
+ nextYear: string;
322
+ prevDecade: string;
323
+ nextDecade: string;
324
+ /** Used by DateTimePicker.Input (present only when DatePickerContext is provided by DateTimePickerRoot) */
325
+ dateTimeInput?: string;
326
+ }
327
+ interface RangePickerLabels extends DatePickerLabels {
328
+ startInput: string;
329
+ endInput: string;
330
+ presetsGroup: string;
331
+ }
332
+ interface TimePickerLabels {
333
+ timeInput: string;
334
+ hourList: string;
335
+ minuteList: string;
336
+ amPmToggle: string;
337
+ hourOption: (hour: number) => string;
338
+ minuteOption: (minute: number) => string;
339
+ }
340
+ interface DateTimePickerLabels extends DatePickerLabels, TimePickerLabels {
341
+ dateTimeInput: string;
342
+ }
343
+ declare const DEFAULT_DATEPICKER_LABELS: DatePickerLabels;
344
+ declare const DEFAULT_RANGEPICKER_LABELS: RangePickerLabels;
345
+ declare const DEFAULT_TIMEPICKER_LABELS: TimePickerLabels;
346
+ declare const DEFAULT_DATETIMEPICKER_LABELS: DateTimePickerLabels;
347
+
348
+ export { type CalendarDay, type CalendarGrid, type CalendarOptions, type CalendarWeek, DEFAULT_DATEPICKER_LABELS, DEFAULT_DATETIMEPICKER_LABELS, DEFAULT_RANGEPICKER_LABELS, DEFAULT_TIMEPICKER_LABELS, type DateAdapter, DateFnsAdapter, type DatePickerLabels, type DateRange, type DateTimePickerLabels, type DisabledRule, type ISODateString, type RangePickerLabels, type TimePickerLabels, type TimeValue, type WeekStartsOn, type WeekdayInfo, formatFullDate, formatInTimezone, formatMonthYear, formatTimeFromISO, formatTimeString, generateHours, generateMinutes, getCalendarDays, getMonthName, getTime, getTimezoneOffsetMinutes, getWeekdayNames, isDateDisabled, isSameDayInTimezone, isSameTime, maxDate, minDate, normalizeISO, parseInputValue, parseTimeString, setTime, startOfDayInTimezone, to12Hour, to24Hour, todayInTimezone };