@iyulab/components 2.20.2 → 2.21.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 CHANGED
@@ -1,5 +1,37 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.21.0] - 2026-10-12
4
+
5
+ ### Added
6
+
7
+ - **Date values** — `readDateValue(value)` reads the three kinds of date text an app receives and says which
8
+ one it is: `instant` (a date-time with `Z` or an offset — that moment), `plainDateTime` (no offset — local wall
9
+ clock) and `plainDate` (`YYYY-MM-DD` — local midnight, not UTC midnight). It returns `null` for a day or time that
10
+ does not exist (`2026-02-30`) instead of a rolled-over date. `writeInstant`, `writePlainDateTime`,
11
+ `writePlainDate` and `localOffset` write a date back in the kind it was read. The date pickers and `formatDate`
12
+ read through it.
13
+
14
+ ### Changed
15
+
16
+ - `formatDate` shows ISO-shaped text that names no real day (`2026-02-30`) as the text itself, as it does for
17
+ other invalid input — it used to format the rolled-over date (March 2). Text that is not ISO-shaped still goes
18
+ to the platform parser.
19
+
20
+ ## [2.20.3] - 2026-10-12
21
+
22
+ ### Fixed
23
+
24
+ - `parseNumber` and `u-input type="number"` read an exponent, as a native number input does: `1e7`, `1.5e-6`,
25
+ `2E+3`, and `1,5e3` on a comma-decimal page. Typed scientific notation used to report `badInput` with an empty
26
+ value. This also fixes a round trip: `value` is written with `String(number)`, which uses exponent form for very
27
+ small and very large numbers (`0,0000001` → `"1e-7"`), and `valueAsNumber` read that back as `NaN`.
28
+ - The React wrappers type an event with a standard DOM name (`change`, `input`, `copy`) as the DOM event the
29
+ element dispatches — `Event`, `ClipboardEvent` — instead of `CustomEvent`. These events carry no `detail`; the
30
+ old type let `e.detail` pass type checking and read `undefined` at runtime. Runtime behaviour is unchanged. A
31
+ handler annotated `(e: CustomEvent)` or reading `e.detail` on these props now fails type checking: annotate it
32
+ `(e: Event)` and read the value from `e.currentTarget`. Wrappers built with `plugins/vite-plugin-react-wrapper`
33
+ get the same typing.
34
+
3
35
  ## [2.20.2] - 2026-10-12
4
36
 
5
37
  ### Fixed
@@ -1,6 +1,5 @@
1
- /** `±HH:mm` for the browser's local timezone at `date` (DST-aware — recomputed per date,
2
- * not cached — `getTimezoneOffset()`'s sign is the inverse of the ISO-8601 offset sign). */
3
- export declare function localOffset(date: Date): string;
1
+ import { localOffset } from '../../utilities/dateValue.js';
2
+ export { localOffset };
4
3
  /** ISO day + `HH:mm` or `HH:mm:ss` → `YYYY-MM-DDTHH:mm:ss±HH:mm` (the offset of that local day and time). */
5
4
  export declare function toDateTimeOffset(day: string, time: string): string;
6
5
  /** A date-time value as this browser's wall clock — `YYYY-MM-DDTHH:mm:ss±HH:mm` in the local offset.
@@ -1,13 +1,6 @@
1
+ import { localOffset, readDateValue, writeInstant } from "../../utilities/dateValue.js";
1
2
  import { parseISODate } from "./dates.js";
2
3
  //#region src/components/calendar/datetime.ts
3
- /** `±HH:mm` for the browser's local timezone at `date` (DST-aware — recomputed per date,
4
- * not cached — `getTimezoneOffset()`'s sign is the inverse of the ISO-8601 offset sign). */
5
- function localOffset(date) {
6
- const minutes = -date.getTimezoneOffset();
7
- const sign = minutes >= 0 ? "+" : "-";
8
- const abs = Math.abs(minutes);
9
- return `${sign}${String(Math.floor(abs / 60)).padStart(2, "0")}:${String(abs % 60).padStart(2, "0")}`;
10
- }
11
4
  /** ISO day + `HH:mm` or `HH:mm:ss` → `YYYY-MM-DDTHH:mm:ss±HH:mm` (the offset of that local day and time). */
12
5
  function toDateTimeOffset(day, time) {
13
6
  const [h, m, s = 0] = time.split(":").map(Number);
@@ -15,19 +8,14 @@ function toDateTimeOffset(day, time) {
15
8
  local.setHours(h, m, s);
16
9
  return `${day}T${normalizeTime(time, true)}${localOffset(local)}`;
17
10
  }
18
- /** A date-time with a UTC designator or offset after its time (`…Z`, `…+09:00`, `…-0530`). */
19
- var WITH_OFFSET = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})$/i;
20
11
  /** A date-time value as this browser's wall clock — `YYYY-MM-DDTHH:mm:ss±HH:mm` in the local offset.
21
12
  * A value with an offset is an instant: `2026-09-06T22:22:34Z` reads `2026-09-07T07:22:34+09:00` in
22
13
  * Seoul, the same moment. A value without one is already wall clock and comes back as it is, and so
23
14
  * does anything that is not a date-time. Every read of a picker value goes through here, so what
24
15
  * the picker shows and what it writes back describe the same instant. */
25
16
  function toLocalDateTime(value) {
26
- if (!WITH_OFFSET.test(value)) return value;
27
- const instant = new Date(value);
28
- if (Number.isNaN(instant.getTime())) return value;
29
- const pad = (n) => String(n).padStart(2, "0");
30
- return toDateTimeOffset(`${instant.getFullYear()}-${pad(instant.getMonth() + 1)}-${pad(instant.getDate())}`, `${pad(instant.getHours())}:${pad(instant.getMinutes())}:${pad(instant.getSeconds())}`);
17
+ const read = readDateValue(value);
18
+ return read?.kind === "instant" ? writeInstant(read.date) : value;
31
19
  }
32
20
  /** Whether two picker values are the same — a day, a date-time, or a `start/end` interval of either,
33
21
  * compared half by half as instants when they carry offsets. A value written back in the local
package/dist/index.d.ts CHANGED
@@ -63,6 +63,7 @@ export * from './events/ShowEvent';
63
63
  export * from './utilities/BrowserStorage.js';
64
64
  export * from './utilities/clipboard.js';
65
65
  export * from './utilities/converters.js';
66
+ export * from './utilities/dateValue.js';
66
67
  export * from './utilities/devWarning.js';
67
68
  export * from './utilities/Dialog.js';
68
69
  export * from './utilities/elements.js';
package/dist/index.js CHANGED
@@ -26,6 +26,7 @@ import { UCheckbox } from "./components/checkbox/UCheckbox.js";
26
26
  import { UTag } from "./components/tag/UTag.js";
27
27
  import { UChip } from "./components/chip/UChip.js";
28
28
  import { UCopyButton } from "./components/copy-button/UCopyButton.js";
29
+ import { localOffset, readDateValue, writeInstant, writePlainDate, writePlainDateTime } from "./utilities/dateValue.js";
29
30
  import { dateTextPattern, formatCurrency, formatDate, formatDateRange, formatDateRangeText, formatDateText, formatDateTimeRangeText, formatDateTimeText, formatNumber, parseDate, parseDateRange, parseDateTime, parseDateTimeRange, parseNumber } from "./utilities/format.js";
30
31
  import { UField } from "./components/field/UField.js";
31
32
  import { UPopover } from "./components/popover/UPopover.js";
@@ -65,4 +66,4 @@ import { Dialog } from "./utilities/Dialog.js";
65
66
  import { Theme } from "./utilities/Theme.js";
66
67
  import { Toast } from "./utilities/Toast.js";
67
68
  import { decodeDelimited, decodeTsv, encodeTsv } from "./utilities/tsv.js";
68
- export { ALERT_STATUSES, BrowserStorage, Dialog, IconCache, IconRegistry, Locale, OverlayManager, Theme, Toast, UAlert, UAvatar, UBadge, UBreadcrumb, UBreadcrumbItem, UButton, UButtonGroup, UCard, UCarousel, UCheckbox, UChip, UCopyButton, UDatePicker, UDateRangePicker, UDialog, UDivider, UDrawer, UElement, UExpander, UField, UFileInput, UFloatingElement, UForm, UFormControlElement, UIcon, UIconButton, UInput, UMenu, UMenuItem, UOption, UOverlayElement, UPagination, UPanel, UPopover, UProgressBar, UProgressRing, URadio, URating, USelect, USkeleton, USlider, USpinner, USplitPanel, USteps, USwitch, UTab, UTabPanel, UTag, UText, UTextarea, UTooltip, UTree, UTreeItem, arrayAttrConverter, booleanAttrConverter, copyFromKey, createDevWarner, dateAttrConverter, dateTextPattern, decodeDelimited, decodeTsv, devWarnOnce, encodeTsv, formatCurrency, formatDate, formatDateRange, formatDateRangeText, formatDateText, formatDateTimeRangeText, formatDateTimeText, formatNumber, getDefaultBaseUrl, getParentElement, isCoarsePointer, isFocusCandidate, isFromControl, isImeComposing, isTextEntry, jsonAttrConverter, parseDate, parseDateRange, parseDateTime, parseDateTimeRange, parseNumber, pasteFromKey, querySelectorAllWithin, querySelectorDeep, querySelectorWithin, resetDevWarnings, setDefaultBaseUrl, urlAttrConverter };
69
+ export { ALERT_STATUSES, BrowserStorage, Dialog, IconCache, IconRegistry, Locale, OverlayManager, Theme, Toast, UAlert, UAvatar, UBadge, UBreadcrumb, UBreadcrumbItem, UButton, UButtonGroup, UCard, UCarousel, UCheckbox, UChip, UCopyButton, UDatePicker, UDateRangePicker, UDialog, UDivider, UDrawer, UElement, UExpander, UField, UFileInput, UFloatingElement, UForm, UFormControlElement, UIcon, UIconButton, UInput, UMenu, UMenuItem, UOption, UOverlayElement, UPagination, UPanel, UPopover, UProgressBar, UProgressRing, URadio, URating, USelect, USkeleton, USlider, USpinner, USplitPanel, USteps, USwitch, UTab, UTabPanel, UTag, UText, UTextarea, UTooltip, UTree, UTreeItem, arrayAttrConverter, booleanAttrConverter, copyFromKey, createDevWarner, dateAttrConverter, dateTextPattern, decodeDelimited, decodeTsv, devWarnOnce, encodeTsv, formatCurrency, formatDate, formatDateRange, formatDateRangeText, formatDateText, formatDateTimeRangeText, formatDateTimeText, formatNumber, getDefaultBaseUrl, getParentElement, isCoarsePointer, isFocusCandidate, isFromControl, isImeComposing, isTextEntry, jsonAttrConverter, localOffset, parseDate, parseDateRange, parseDateTime, parseDateTimeRange, parseNumber, pasteFromKey, querySelectorAllWithin, querySelectorDeep, querySelectorWithin, readDateValue, resetDevWarnings, setDefaultBaseUrl, urlAttrConverter, writeInstant, writePlainDate, writePlainDateTime };
@@ -92,6 +92,26 @@ export declare function readEventMapEntries(content: string): {
92
92
  name: string;
93
93
  type: string;
94
94
  }[];
95
+ /**
96
+ * 래퍼 이벤트 prop 이 핸들러에 넘기는 이벤트의 타입 글자.
97
+ *
98
+ * - detail 타입을 풀었으면 `CustomEvent<T>`.
99
+ * - 못 풀었으면(`unknown`) 이름이 결정한다: 표준 DOM 이벤트 이름(`change`·`input`·`copy` …)은 컴포넌트가
100
+ * 네이티브 생성자로 다시 내는 이벤트라(`new Event('change')` · `relay` · `ClipboardEvent`) **그 DOM 타입**
101
+ * (`HTMLElementEventMap['change']` = `Event`), 그 밖에는 `CustomEvent`.
102
+ * 종전에는 전부 `CustomEvent` 였다 — 소비자가 `e.detail` 을 타입 검사 통과한 채 읽고 런타임에 `undefined` 를 얻었다.
103
+ * - 표준 이름 판정을 손으로 쓴 목록에 두지 않고 타입 시스템에 맡긴다 — d.ts 의 제네릭 별칭
104
+ * ({@link EVENT_OF_ALIAS})이 소비자 쪽에서 푼다(`EventOf<'change'>` → `Event`). `fire('change')` 로
105
+ * `CustomEvent` 를 내는 요소도 `Event` 로 보이는데, detail 이 없으므로 잃는 것이 없다(상위 타입).
106
+ * ⚠별칭이 **제네릭**이어야 한다 — 리터럴을 직접 쓴 조건부(`'change' extends keyof M ? M['change'] : …`)는 참 갈래에서
107
+ * 좁혀지지 않아 `TS2538` 이고, 소비자의 `skipLibCheck` 아래 그 오류는 조용한 `any` 가 된다(타입 스모크가 잡았다).
108
+ */
109
+ export declare function eventPropType(e: {
110
+ name: string;
111
+ detailType: string;
112
+ }): string;
113
+ /** {@link eventPropType} 이 쓰는 별칭 — 그것을 쓰는 래퍼 d.ts 에만 싣는다. */
114
+ export declare const EVENT_OF_ALIAS = "type EventOf<K extends string> = K extends keyof HTMLElementEventMap ? HTMLElementEventMap[K] : CustomEvent;";
95
115
  /**
96
116
  * 이벤트 타입 글자에서 detail 타입과 그 출처를 푼다 — `CustomEvent<X>` 이거나, 같은 파일의
97
117
  * `type A = CustomEvent<X>` 별칭 `A`. `X` 는 그 파일이 선언했거나 import 한 이름 하나, 또는 다른 이름을
@@ -286,6 +286,27 @@ function lookupEventMaps(name, chainFiles, srcRoot) {
286
286
  }
287
287
  return null;
288
288
  }
289
+ /**
290
+ * 래퍼 이벤트 prop 이 핸들러에 넘기는 이벤트의 타입 글자.
291
+ *
292
+ * - detail 타입을 풀었으면 `CustomEvent<T>`.
293
+ * - 못 풀었으면(`unknown`) 이름이 결정한다: 표준 DOM 이벤트 이름(`change`·`input`·`copy` …)은 컴포넌트가
294
+ * 네이티브 생성자로 다시 내는 이벤트라(`new Event('change')` · `relay` · `ClipboardEvent`) **그 DOM 타입**
295
+ * (`HTMLElementEventMap['change']` = `Event`), 그 밖에는 `CustomEvent`.
296
+ * 종전에는 전부 `CustomEvent` 였다 — 소비자가 `e.detail` 을 타입 검사 통과한 채 읽고 런타임에 `undefined` 를 얻었다.
297
+ * - 표준 이름 판정을 손으로 쓴 목록에 두지 않고 타입 시스템에 맡긴다 — d.ts 의 제네릭 별칭
298
+ * ({@link EVENT_OF_ALIAS})이 소비자 쪽에서 푼다(`EventOf<'change'>` → `Event`). `fire('change')` 로
299
+ * `CustomEvent` 를 내는 요소도 `Event` 로 보이는데, detail 이 없으므로 잃는 것이 없다(상위 타입).
300
+ * ⚠별칭이 **제네릭**이어야 한다 — 리터럴을 직접 쓴 조건부(`'change' extends keyof M ? M['change'] : …`)는 참 갈래에서
301
+ * 좁혀지지 않아 `TS2538` 이고, 소비자의 `skipLibCheck` 아래 그 오류는 조용한 `any` 가 된다(타입 스모크가 잡았다).
302
+ */
303
+ export function eventPropType(e) {
304
+ if (e.detailType !== 'unknown')
305
+ return `CustomEvent<${e.detailType}>`;
306
+ return `EventOf<'${e.name}'>`;
307
+ }
308
+ /** {@link eventPropType} 이 쓰는 별칭 — 그것을 쓰는 래퍼 d.ts 에만 싣는다. */
309
+ export const EVENT_OF_ALIAS = 'type EventOf<K extends string> = K extends keyof HTMLElementEventMap ? HTMLElementEventMap[K] : CustomEvent;';
289
310
  const INLINE_PRIMITIVES = new Set(['string', 'number', 'boolean', 'null', 'undefined', 'unknown', 'true', 'false', 'readonly']);
290
311
  /**
291
312
  * 이벤트 타입 글자에서 detail 타입과 그 출처를 푼다 — `CustomEvent<X>` 이거나, 같은 파일의
@@ -422,10 +443,7 @@ export const ${className} = createComponent({
422
443
  dtsImports.push(`import { type ${types.join(', type ')} } from '${path}';`);
423
444
  }
424
445
  const eventTypes = events.length > 0
425
- ? events.map(e => {
426
- const type = e.detailType !== 'unknown' ? `CustomEvent<${e.detailType}>` : 'CustomEvent';
427
- return ` ${e.reactName}?: (event: ${type}) => void;`;
428
- }).join('\n') + '\n'
446
+ ? events.map(e => ` ${e.reactName}?: (event: ${eventPropType(e)}) => void;`).join('\n') + '\n'
429
447
  : '';
430
448
  // 래퍼 이벤트 prop(onChange 등)은 React.HTMLAttributes 의 동명 핸들러와 교집합되면
431
449
  // 어떤 시그니처도 대입 불가가 된다. HTMLAttributes 쪽에서 해당 키를 제거해 CustomEvent
@@ -450,7 +468,7 @@ export const ${className} = createComponent({
450
468
  // 이것을 빠뜨리면 **런타임은 되는데 타입만 거부하는** 괴리가 생긴다.
451
469
  const dts = `${dtsImports.join('\n')}
452
470
 
453
- type ${className}OwnProps = Omit<${className}Element, keyof HTMLElement>;
471
+ ${events.some(e => e.detailType === 'unknown') ? `${EVENT_OF_ALIAS}\n` : ''}type ${className}OwnProps = Omit<${className}Element, keyof HTMLElement>;
454
472
 
455
473
  export declare const ${className}: React.ForwardRefExoticComponent<
456
474
  Partial<Omit<${className}Element, Exclude<keyof React.HTMLAttributes<${className}Element>, keyof ${className}OwnProps>>>
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { UCheckbox as UCheckboxElement } from '@iyulab/components/dist/components/checkbox/UCheckbox.js';
3
3
 
4
+ type EventOf<K extends string> = K extends keyof HTMLElementEventMap ? HTMLElementEventMap[K] : CustomEvent;
4
5
  type UCheckboxOwnProps = Omit<UCheckboxElement, keyof HTMLElement>;
5
6
 
6
7
  export declare const UCheckbox: React.ForwardRefExoticComponent<
@@ -8,7 +9,7 @@ export declare const UCheckbox: React.ForwardRefExoticComponent<
8
9
  & Omit<React.HTMLAttributes<UCheckboxElement>, keyof UCheckboxOwnProps | 'onChange'>
9
10
  & React.RefAttributes<UCheckboxElement>
10
11
  & {
11
- onChange?: (event: CustomEvent) => void;
12
+ onChange?: (event: EventOf<'change'>) => void;
12
13
  }
13
14
  >;
14
15
 
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { UCopyButton as UCopyButtonElement } from '@iyulab/components/dist/components/copy-button/UCopyButton.js';
3
3
 
4
+ type EventOf<K extends string> = K extends keyof HTMLElementEventMap ? HTMLElementEventMap[K] : CustomEvent;
4
5
  type UCopyButtonOwnProps = Omit<UCopyButtonElement, keyof HTMLElement>;
5
6
 
6
7
  export declare const UCopyButton: React.ForwardRefExoticComponent<
@@ -8,7 +9,7 @@ export declare const UCopyButton: React.ForwardRefExoticComponent<
8
9
  & Omit<React.HTMLAttributes<UCopyButtonElement>, keyof UCopyButtonOwnProps | 'onCopy'>
9
10
  & React.RefAttributes<UCopyButtonElement>
10
11
  & {
11
- onCopy?: (event: CustomEvent) => void;
12
+ onCopy?: (event: EventOf<'copy'>) => void;
12
13
  }
13
14
  >;
14
15
 
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { UDatePicker as UDatePickerElement } from '@iyulab/components/dist/components/date-picker/UDatePicker.js';
3
3
 
4
+ type EventOf<K extends string> = K extends keyof HTMLElementEventMap ? HTMLElementEventMap[K] : CustomEvent;
4
5
  type UDatePickerOwnProps = Omit<UDatePickerElement, keyof HTMLElement>;
5
6
 
6
7
  export declare const UDatePicker: React.ForwardRefExoticComponent<
@@ -8,7 +9,7 @@ export declare const UDatePicker: React.ForwardRefExoticComponent<
8
9
  & Omit<React.HTMLAttributes<UDatePickerElement>, keyof UDatePickerOwnProps | 'onChange'>
9
10
  & React.RefAttributes<UDatePickerElement>
10
11
  & {
11
- onChange?: (event: CustomEvent) => void;
12
+ onChange?: (event: EventOf<'change'>) => void;
12
13
  }
13
14
  >;
14
15
 
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { UDateRangePicker as UDateRangePickerElement } from '@iyulab/components/dist/components/date-range-picker/UDateRangePicker.js';
3
3
 
4
+ type EventOf<K extends string> = K extends keyof HTMLElementEventMap ? HTMLElementEventMap[K] : CustomEvent;
4
5
  type UDateRangePickerOwnProps = Omit<UDateRangePickerElement, keyof HTMLElement>;
5
6
 
6
7
  export declare const UDateRangePicker: React.ForwardRefExoticComponent<
@@ -8,7 +9,7 @@ export declare const UDateRangePicker: React.ForwardRefExoticComponent<
8
9
  & Omit<React.HTMLAttributes<UDateRangePickerElement>, keyof UDateRangePickerOwnProps | 'onChange'>
9
10
  & React.RefAttributes<UDateRangePickerElement>
10
11
  & {
11
- onChange?: (event: CustomEvent) => void;
12
+ onChange?: (event: EventOf<'change'>) => void;
12
13
  }
13
14
  >;
14
15
 
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { UFileInput as UFileInputElement } from '@iyulab/components/dist/components/file-input/UFileInput.js';
3
3
 
4
+ type EventOf<K extends string> = K extends keyof HTMLElementEventMap ? HTMLElementEventMap[K] : CustomEvent;
4
5
  type UFileInputOwnProps = Omit<UFileInputElement, keyof HTMLElement>;
5
6
 
6
7
  export declare const UFileInput: React.ForwardRefExoticComponent<
@@ -8,7 +9,7 @@ export declare const UFileInput: React.ForwardRefExoticComponent<
8
9
  & Omit<React.HTMLAttributes<UFileInputElement>, keyof UFileInputOwnProps | 'onChange'>
9
10
  & React.RefAttributes<UFileInputElement>
10
11
  & {
11
- onChange?: (event: CustomEvent) => void;
12
+ onChange?: (event: EventOf<'change'>) => void;
12
13
  }
13
14
  >;
14
15
 
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { UForm as UFormElement } from '@iyulab/components/dist/components/form/UForm.js';
3
3
 
4
+ type EventOf<K extends string> = K extends keyof HTMLElementEventMap ? HTMLElementEventMap[K] : CustomEvent;
4
5
  type UFormOwnProps = Omit<UFormElement, keyof HTMLElement>;
5
6
 
6
7
  export declare const UForm: React.ForwardRefExoticComponent<
@@ -8,7 +9,7 @@ export declare const UForm: React.ForwardRefExoticComponent<
8
9
  & Omit<React.HTMLAttributes<UFormElement>, keyof UFormOwnProps | 'onChange'>
9
10
  & React.RefAttributes<UFormElement>
10
11
  & {
11
- onChange?: (event: CustomEvent) => void;
12
+ onChange?: (event: EventOf<'change'>) => void;
12
13
  }
13
14
  >;
14
15
 
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { UInput as UInputElement } from '@iyulab/components/dist/components/input/UInput.js';
3
3
 
4
+ type EventOf<K extends string> = K extends keyof HTMLElementEventMap ? HTMLElementEventMap[K] : CustomEvent;
4
5
  type UInputOwnProps = Omit<UInputElement, keyof HTMLElement>;
5
6
 
6
7
  export declare const UInput: React.ForwardRefExoticComponent<
@@ -8,8 +9,8 @@ export declare const UInput: React.ForwardRefExoticComponent<
8
9
  & Omit<React.HTMLAttributes<UInputElement>, keyof UInputOwnProps | 'onInput' | 'onChange' | 'onSearch'>
9
10
  & React.RefAttributes<UInputElement>
10
11
  & {
11
- onInput?: (event: CustomEvent) => void;
12
- onChange?: (event: CustomEvent) => void;
12
+ onInput?: (event: EventOf<'input'>) => void;
13
+ onChange?: (event: EventOf<'change'>) => void;
13
14
  onSearch?: (event: CustomEvent<{ query: string }>) => void;
14
15
  }
15
16
  >;
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { UMenu as UMenuElement } from '@iyulab/components/dist/components/menu/UMenu.js';
3
3
 
4
+ type EventOf<K extends string> = K extends keyof HTMLElementEventMap ? HTMLElementEventMap[K] : CustomEvent;
4
5
  type UMenuOwnProps = Omit<UMenuElement, keyof HTMLElement>;
5
6
 
6
7
  export declare const UMenu: React.ForwardRefExoticComponent<
@@ -8,7 +9,7 @@ export declare const UMenu: React.ForwardRefExoticComponent<
8
9
  & Omit<React.HTMLAttributes<UMenuElement>, keyof UMenuOwnProps | 'onChange'>
9
10
  & React.RefAttributes<UMenuElement>
10
11
  & {
11
- onChange?: (event: CustomEvent) => void;
12
+ onChange?: (event: EventOf<'change'>) => void;
12
13
  }
13
14
  >;
14
15
 
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { URadio as URadioElement } from '@iyulab/components/dist/components/radio/URadio.js';
3
3
 
4
+ type EventOf<K extends string> = K extends keyof HTMLElementEventMap ? HTMLElementEventMap[K] : CustomEvent;
4
5
  type URadioOwnProps = Omit<URadioElement, keyof HTMLElement>;
5
6
 
6
7
  export declare const URadio: React.ForwardRefExoticComponent<
@@ -8,7 +9,7 @@ export declare const URadio: React.ForwardRefExoticComponent<
8
9
  & Omit<React.HTMLAttributes<URadioElement>, keyof URadioOwnProps | 'onChange'>
9
10
  & React.RefAttributes<URadioElement>
10
11
  & {
11
- onChange?: (event: CustomEvent) => void;
12
+ onChange?: (event: EventOf<'change'>) => void;
12
13
  }
13
14
  >;
14
15
 
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { URating as URatingElement } from '@iyulab/components/dist/components/rating/URating.js';
3
3
 
4
+ type EventOf<K extends string> = K extends keyof HTMLElementEventMap ? HTMLElementEventMap[K] : CustomEvent;
4
5
  type URatingOwnProps = Omit<URatingElement, keyof HTMLElement>;
5
6
 
6
7
  export declare const URating: React.ForwardRefExoticComponent<
@@ -8,7 +9,7 @@ export declare const URating: React.ForwardRefExoticComponent<
8
9
  & Omit<React.HTMLAttributes<URatingElement>, keyof URatingOwnProps | 'onChange'>
9
10
  & React.RefAttributes<URatingElement>
10
11
  & {
11
- onChange?: (event: CustomEvent) => void;
12
+ onChange?: (event: EventOf<'change'>) => void;
12
13
  }
13
14
  >;
14
15
 
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { USelect as USelectElement } from '@iyulab/components/dist/components/select/USelect.js';
3
3
 
4
+ type EventOf<K extends string> = K extends keyof HTMLElementEventMap ? HTMLElementEventMap[K] : CustomEvent;
4
5
  type USelectOwnProps = Omit<USelectElement, keyof HTMLElement>;
5
6
 
6
7
  export declare const USelect: React.ForwardRefExoticComponent<
@@ -8,7 +9,7 @@ export declare const USelect: React.ForwardRefExoticComponent<
8
9
  & Omit<React.HTMLAttributes<USelectElement>, keyof USelectOwnProps | 'onChange' | 'onSearch'>
9
10
  & React.RefAttributes<USelectElement>
10
11
  & {
11
- onChange?: (event: CustomEvent) => void;
12
+ onChange?: (event: EventOf<'change'>) => void;
12
13
  onSearch?: (event: CustomEvent<{ query: string }>) => void;
13
14
  }
14
15
  >;
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { USlider as USliderElement } from '@iyulab/components/dist/components/slider/USlider.js';
3
3
 
4
+ type EventOf<K extends string> = K extends keyof HTMLElementEventMap ? HTMLElementEventMap[K] : CustomEvent;
4
5
  type USliderOwnProps = Omit<USliderElement, keyof HTMLElement>;
5
6
 
6
7
  export declare const USlider: React.ForwardRefExoticComponent<
@@ -8,7 +9,7 @@ export declare const USlider: React.ForwardRefExoticComponent<
8
9
  & Omit<React.HTMLAttributes<USliderElement>, keyof USliderOwnProps | 'onChange'>
9
10
  & React.RefAttributes<USliderElement>
10
11
  & {
11
- onChange?: (event: CustomEvent) => void;
12
+ onChange?: (event: EventOf<'change'>) => void;
12
13
  }
13
14
  >;
14
15
 
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { USwitch as USwitchElement } from '@iyulab/components/dist/components/switch/USwitch.js';
3
3
 
4
+ type EventOf<K extends string> = K extends keyof HTMLElementEventMap ? HTMLElementEventMap[K] : CustomEvent;
4
5
  type USwitchOwnProps = Omit<USwitchElement, keyof HTMLElement>;
5
6
 
6
7
  export declare const USwitch: React.ForwardRefExoticComponent<
@@ -8,7 +9,7 @@ export declare const USwitch: React.ForwardRefExoticComponent<
8
9
  & Omit<React.HTMLAttributes<USwitchElement>, keyof USwitchOwnProps | 'onChange'>
9
10
  & React.RefAttributes<USwitchElement>
10
11
  & {
11
- onChange?: (event: CustomEvent) => void;
12
+ onChange?: (event: EventOf<'change'>) => void;
12
13
  }
13
14
  >;
14
15
 
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { UTabPanel as UTabPanelElement } from '@iyulab/components/dist/components/tab-panel/UTabPanel.js';
3
3
 
4
+ type EventOf<K extends string> = K extends keyof HTMLElementEventMap ? HTMLElementEventMap[K] : CustomEvent;
4
5
  type UTabPanelOwnProps = Omit<UTabPanelElement, keyof HTMLElement>;
5
6
 
6
7
  export declare const UTabPanel: React.ForwardRefExoticComponent<
@@ -8,7 +9,7 @@ export declare const UTabPanel: React.ForwardRefExoticComponent<
8
9
  & Omit<React.HTMLAttributes<UTabPanelElement>, keyof UTabPanelOwnProps | 'onChange'>
9
10
  & React.RefAttributes<UTabPanelElement>
10
11
  & {
11
- onChange?: (event: CustomEvent) => void;
12
+ onChange?: (event: EventOf<'change'>) => void;
12
13
  }
13
14
  >;
14
15
 
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { UTextarea as UTextareaElement } from '@iyulab/components/dist/components/textarea/UTextarea.js';
3
3
 
4
+ type EventOf<K extends string> = K extends keyof HTMLElementEventMap ? HTMLElementEventMap[K] : CustomEvent;
4
5
  type UTextareaOwnProps = Omit<UTextareaElement, keyof HTMLElement>;
5
6
 
6
7
  export declare const UTextarea: React.ForwardRefExoticComponent<
@@ -8,8 +9,8 @@ export declare const UTextarea: React.ForwardRefExoticComponent<
8
9
  & Omit<React.HTMLAttributes<UTextareaElement>, keyof UTextareaOwnProps | 'onInput' | 'onChange'>
9
10
  & React.RefAttributes<UTextareaElement>
10
11
  & {
11
- onInput?: (event: CustomEvent) => void;
12
- onChange?: (event: CustomEvent) => void;
12
+ onInput?: (event: EventOf<'input'>) => void;
13
+ onChange?: (event: EventOf<'change'>) => void;
13
14
  }
14
15
  >;
15
16
 
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { UTree as UTreeElement } from '@iyulab/components/dist/components/tree/UTree.js';
3
3
 
4
+ type EventOf<K extends string> = K extends keyof HTMLElementEventMap ? HTMLElementEventMap[K] : CustomEvent;
4
5
  type UTreeOwnProps = Omit<UTreeElement, keyof HTMLElement>;
5
6
 
6
7
  export declare const UTree: React.ForwardRefExoticComponent<
@@ -8,7 +9,7 @@ export declare const UTree: React.ForwardRefExoticComponent<
8
9
  & Omit<React.HTMLAttributes<UTreeElement>, keyof UTreeOwnProps | 'onChange'>
9
10
  & React.RefAttributes<UTreeElement>
10
11
  & {
11
- onChange?: (event: CustomEvent) => void;
12
+ onChange?: (event: EventOf<'change'>) => void;
12
13
  }
13
14
  >;
14
15
 
@@ -0,0 +1,36 @@
1
+ /**
2
+ * The three kinds of date value an app receives as text, read and written in one place.
3
+ * The names come from Temporal:
4
+ *
5
+ * - **`instant`** — a date-time with an offset or `Z` (`2026-09-06T22:22:34Z`, `…+09:00`). It names one
6
+ * moment everywhere; shown here, it is this browser's wall clock at that moment.
7
+ * - **`plainDateTime`** — a date-time without an offset (`2026-09-06T22:22`, `2026-09-06 22:22:34`). It is a
8
+ * wall clock already and is read as local time, never shifted.
9
+ * - **`plainDate`** — a calendar day (`2026-09-06`). It is local midnight of that day. `new Date('2026-09-06')`
10
+ * is UTC midnight instead, which is the previous day west of Greenwich.
11
+ *
12
+ * A `Date` is an instant. Text that is none of the three, or names a day that does not exist
13
+ * (`2026-02-30`), reads as `null` — never a rolled-over or guessed date.
14
+ */
15
+ export type DateValueKind = 'instant' | 'plainDateTime' | 'plainDate';
16
+ /** A date value with the kind its text named. `date` is the moment it means here. */
17
+ export interface DateValue {
18
+ kind: DateValueKind;
19
+ date: Date;
20
+ }
21
+ /**
22
+ * Reads a date value and tells which kind it is. `null` for text that is not one of the three
23
+ * kinds, for a day or time that does not exist, and for an invalid `Date`.
24
+ */
25
+ export declare function readDateValue(value: Date | string): DateValue | null;
26
+ /** `±HH:mm` for this browser's time zone at `date` — recomputed per date, so a DST change is honoured
27
+ * (`getTimezoneOffset()`'s sign is the inverse of the ISO-8601 sign). */
28
+ export declare function localOffset(date: Date): string;
29
+ /** The local calendar day of `date` — `YYYY-MM-DD`. */
30
+ export declare function writePlainDate(date: Date): string;
31
+ /** The local wall clock of `date` without an offset — `YYYY-MM-DDTHH:mm:ss`, or `YYYY-MM-DDTHH:mm`
32
+ * when `seconds` is `false`. */
33
+ export declare function writePlainDateTime(date: Date, seconds?: boolean): string;
34
+ /** The moment `date` names, written as this browser's wall clock with its offset —
35
+ * `YYYY-MM-DDTHH:mm:ss±HH:mm`. `2026-09-06T22:22:34Z` read in Seoul writes `2026-09-07T07:22:34+09:00`. */
36
+ export declare function writeInstant(date: Date): string;
@@ -0,0 +1,79 @@
1
+ //#region src/utilities/dateValue.ts
2
+ var PLAIN_DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
3
+ var DATE_TIME = /^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,9}))?)?(Z|[+-]\d{2}:?\d{2})?$/i;
4
+ /** Whether the fields name a real calendar day and clock time — `Date` rolls `2026-02-30` into March and
5
+ * `24:00` into the next day; the check runs in UTC so no time zone moves a field. */
6
+ function realFields(y, m, d, h = 0, min = 0, s = 0) {
7
+ const u = new Date(Date.UTC(y, m - 1, d, h, min, s));
8
+ return u.getUTCFullYear() === y && u.getUTCMonth() === m - 1 && u.getUTCDate() === d && u.getUTCHours() === h && u.getUTCMinutes() === min && u.getUTCSeconds() === s;
9
+ }
10
+ /**
11
+ * Reads a date value and tells which kind it is. `null` for text that is not one of the three
12
+ * kinds, for a day or time that does not exist, and for an invalid `Date`.
13
+ */
14
+ function readDateValue(value) {
15
+ if (value instanceof Date) return Number.isNaN(value.getTime()) ? null : {
16
+ kind: "instant",
17
+ date: value
18
+ };
19
+ const text = value.trim();
20
+ const day = PLAIN_DATE.exec(text);
21
+ if (day) {
22
+ const [y, m, d] = [
23
+ Number(day[1]),
24
+ Number(day[2]),
25
+ Number(day[3])
26
+ ];
27
+ return realFields(y, m, d) ? {
28
+ kind: "plainDate",
29
+ date: new Date(y, m - 1, d)
30
+ } : null;
31
+ }
32
+ const dt = DATE_TIME.exec(text);
33
+ if (!dt) return null;
34
+ const [y, m, d, h, min, s] = [
35
+ 1,
36
+ 2,
37
+ 3,
38
+ 4,
39
+ 5,
40
+ 6
41
+ ].map((i) => Number(dt[i] ?? 0));
42
+ const ms = dt[7] ? Number(dt[7].slice(0, 3).padEnd(3, "0")) : 0;
43
+ if (!realFields(y, m, d, h, min, s)) return null;
44
+ const zone = dt[8];
45
+ if (!zone) return {
46
+ kind: "plainDateTime",
47
+ date: new Date(y, m - 1, d, h, min, s, ms)
48
+ };
49
+ const offset = zone.toUpperCase() === "Z" ? 0 : (zone[0] === "-" ? -1 : 1) * (Number(zone.slice(1, 3)) * 60 + Number(zone.slice(-2)));
50
+ return {
51
+ kind: "instant",
52
+ date: /* @__PURE__ */ new Date(Date.UTC(y, m - 1, d, h, min, s, ms) - offset * 6e4)
53
+ };
54
+ }
55
+ var pad = (n, width = 2) => String(n).padStart(width, "0");
56
+ /** `±HH:mm` for this browser's time zone at `date` — recomputed per date, so a DST change is honoured
57
+ * (`getTimezoneOffset()`'s sign is the inverse of the ISO-8601 sign). */
58
+ function localOffset(date) {
59
+ const minutes = -date.getTimezoneOffset();
60
+ const abs = Math.abs(minutes);
61
+ return `${minutes >= 0 ? "+" : "-"}${pad(Math.floor(abs / 60))}:${pad(abs % 60)}`;
62
+ }
63
+ /** The local calendar day of `date` — `YYYY-MM-DD`. */
64
+ function writePlainDate(date) {
65
+ return `${pad(date.getFullYear(), 4)}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
66
+ }
67
+ /** The local wall clock of `date` without an offset — `YYYY-MM-DDTHH:mm:ss`, or `YYYY-MM-DDTHH:mm`
68
+ * when `seconds` is `false`. */
69
+ function writePlainDateTime(date, seconds = true) {
70
+ const time = `${pad(date.getHours())}:${pad(date.getMinutes())}${seconds ? `:${pad(date.getSeconds())}` : ""}`;
71
+ return `${writePlainDate(date)}T${time}`;
72
+ }
73
+ /** The moment `date` names, written as this browser's wall clock with its offset —
74
+ * `YYYY-MM-DDTHH:mm:ss±HH:mm`. `2026-09-06T22:22:34Z` read in Seoul writes `2026-09-07T07:22:34+09:00`. */
75
+ function writeInstant(date) {
76
+ return `${writePlainDateTime(date)}${localOffset(date)}`;
77
+ }
78
+ //#endregion
79
+ export { localOffset, readDateValue, writeInstant, writePlainDate, writePlainDateTime };
@@ -51,8 +51,13 @@ export declare function formatDateRange(start: Date | string, end: Date | string
51
51
  * digits follow (`1,234` on an English page → 1234).
52
52
  *
53
53
  * Grouping (by either separator, spaces or apostrophes) must come in threes after a first group of
54
- * one to three digits — `1,23,4` is `null`. A leading `+`, `-` or `−` sets the sign. Exponents are
55
- * not read. `locale` defaults to the active `Locale`.
54
+ * one to three digits — `1,23,4` is `null`. A leading `+`, `-` or `−` sets the sign.
55
+ *
56
+ * An exponent may follow, as in a native number input: `e` or `E`, an optional sign, digits
57
+ * (`1e7`, `1.5e-6`, `2E+3`). The separator rules above apply to the part before it (`1,5e3` on a
58
+ * comma-decimal page is 1500); the exponent is never grouped. `e5`, `1e` and `1e+` are `null`.
59
+ * Reading exponents also lets every string `String(number)` writes come back (`1e-7`, `1e+21`).
60
+ * `locale` defaults to the active `Locale`.
56
61
  */
57
62
  export declare function parseNumber(text: string, locale?: LocaleTag): number | null;
58
63
  /** How a date is written in a text field: ISO `YYYY-MM-DD`, or the locale's numeric order (`10/02/2026`, `02.10.2026`). */
@@ -1,25 +1,16 @@
1
1
  import { Locale } from "./Locale.js";
2
+ import { readDateValue } from "./dateValue.js";
2
3
  //#region src/utilities/format.ts
3
4
  /**
4
- * Parses "YYYY-MM-DD" as midnight in the **local** timezone.
5
- * Using `Date.parse("YYYY-MM-DD")` (UTC interpretation) shifts the date
6
- * back a day in negative-UTC-offset regions — split y/m/d and construct
7
- * `new Date(y, m-1, d)` directly instead.
8
- *
9
- * A full ISO datetime (e.g. `2026-02-24T09:00:00Z`) is unambiguous — it carries
10
- * its own timezone — so the local-time-safe split isn't needed there; when the
11
- * split doesn't yield three numbers, fall back to native parsing instead of
12
- * producing an Invalid Date.
13
- */
14
- function parseISODate(iso) {
15
- const [y, m, d] = iso.split("-").map(Number);
16
- return Number.isNaN(y) || Number.isNaN(m) || Number.isNaN(d) ? new Date(iso) : new Date(y, m - 1, d);
17
- }
18
- /**
19
- * Resolves a Date or ISO date string to a Date object.
5
+ * Resolves a Date or date string to a Date — through {@link readDateValue}, so a `YYYY-MM-DD` day is local
6
+ * midnight (not UTC midnight, which is the previous day west of Greenwich), a date-time without an offset is
7
+ * local wall clock, and one with an offset is that instant. ISO-shaped text that names no real day
8
+ * (`2026-02-30`) is an invalid `Date` — not March 2. Other text goes to the platform parser, as it always did.
20
9
  */
21
10
  function resolve(value) {
22
- return typeof value === "string" ? parseISODate(value) : value;
11
+ const read = readDateValue(value);
12
+ if (read) return read.date;
13
+ return typeof value === "string" && !/^\d{4}-\d{2}-\d{2}/.test(value.trim()) ? new Date(value) : /* @__PURE__ */ new Date(NaN);
23
14
  }
24
15
  /**
25
16
  * Wraps `Intl.NumberFormat` with the active locale (`Locale.get()` if omitted).
@@ -99,13 +90,20 @@ var GROUP_MARKS = /[\s\u00A0\u202F\u2009'\u2019]/;
99
90
  * digits follow (`1,234` on an English page → 1234).
100
91
  *
101
92
  * Grouping (by either separator, spaces or apostrophes) must come in threes after a first group of
102
- * one to three digits — `1,23,4` is `null`. A leading `+`, `-` or `−` sets the sign. Exponents are
103
- * not read. `locale` defaults to the active `Locale`.
93
+ * one to three digits — `1,23,4` is `null`. A leading `+`, `-` or `−` sets the sign.
94
+ *
95
+ * An exponent may follow, as in a native number input: `e` or `E`, an optional sign, digits
96
+ * (`1e7`, `1.5e-6`, `2E+3`). The separator rules above apply to the part before it (`1,5e3` on a
97
+ * comma-decimal page is 1500); the exponent is never grouped. `e5`, `1e` and `1e+` are `null`.
98
+ * Reading exponents also lets every string `String(number)` writes come back (`1e-7`, `1e+21`).
99
+ * `locale` defaults to the active `Locale`.
104
100
  */
105
101
  function parseNumber(text, locale) {
106
102
  const signed = text.trim().match(/^([+\-\u2212]?)(.*)$/s);
107
103
  const negative = signed[1] === "-" || signed[1] === "−";
108
- const body = signed[2];
104
+ const scientific = signed[2].match(/^(.*?)[eE]([+-]?)(\d+)$/s);
105
+ const body = scientific ? scientific[1] : signed[2];
106
+ const exponent = scientific ? `${scientific[2]}${scientific[3]}` : "0";
109
107
  if (!body || !/^[\d.,\s\u00A0\u202F\u2009'\u2019]+$/.test(body) || !/\d/.test(body)) return null;
110
108
  if (GROUP_MARKS.test(body[0]) || GROUP_MARKS.test(body[body.length - 1])) return null;
111
109
  const dots = body.split(".").length - 1;
@@ -129,7 +127,7 @@ function parseNumber(text, locale) {
129
127
  } else if (!/^\d*$/.test(intPart)) return null;
130
128
  const digits = groups.join("");
131
129
  if (!digits && !fracPart) return null;
132
- const value = Number(`${negative ? "-" : ""}${digits || "0"}.${fracPart || "0"}`);
130
+ const value = Number(`${negative ? "-" : ""}${digits || "0"}.${fracPart || "0"}e${exponent}`);
133
131
  return Number.isFinite(value) ? value : null;
134
132
  }
135
133
  /** The year/month/day order and separator the locale's numeric date uses (`en-US` → month/day/year · `/`). */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@iyulab/components",
3
3
  "description": "web-components library based on lit-element made by iyulab",
4
- "version": "2.20.2",
4
+ "version": "2.21.0",
5
5
  "keywords": [
6
6
  "iyulab",
7
7
  "components",
@@ -94,7 +94,7 @@
94
94
  "eslint-plugin-lit": "^2.3.1",
95
95
  "glob": "^13.0.6",
96
96
  "globals": "^17.7.0",
97
- "happy-dom": "^20.10.6",
97
+ "happy-dom": "^21.0.1",
98
98
  "react": "^19.2.7",
99
99
  "typescript": "^6.0.2",
100
100
  "typescript-eslint": "^8.64.0",
@@ -27,7 +27,8 @@ Text input field with prefix/suffix slots and label. Add `u-option` children for
27
27
  ```
28
28
 
29
29
  `type="number"` reads what the user types **in the page's locale**: `1,5` on a German page and
30
- `1.5` anywhere are both 1.5; `1.234,5` and `1,234.5` are both 1234.5 (rules: `parseNumber`). The
30
+ `1.5` anywhere are both 1.5; `1.234,5` and `1,234.5` are both 1234.5 (rules: `parseNumber`).
31
+ Exponents read as in a native number input (`1e7`, `1,5e-6` on a German page). The
31
32
  inner input is `type="text" inputmode="decimal"` — a native number input drops or rejects a
32
33
  decimal comma depending on the browser (`1,5` became `15`, a valid number ten times too large).
33
34
  `value` is always the canonical dot-decimal string — `""` when the text is not a number, which
@@ -52,9 +52,11 @@ formatDate('2026-03-14', { dateStyle: 'long' });
52
52
  formatDate(order.createdAt, { dateStyle: 'short', timeStyle: 'short' });
53
53
  ```
54
54
 
55
- Accepts a `Date` or an ISO `YYYY-MM-DD` string. **The string form is parsed as local time,
56
- not UTC** — `'2026-03-14'` is midnight where the user is, so a date never shifts a day
57
- across time zones the way `new Date('2026-03-14')` does.
55
+ Accepts a `Date` or a date string, read by [`readDateValue`](#date-values--readdatevalue-and-writers): a
56
+ `YYYY-MM-DD` day is **local midnight, not UTC** — `'2026-03-14'` is midnight where the user is, so a date
57
+ never shifts a day across time zones the way `new Date('2026-03-14')` does; a date-time without an offset is
58
+ local wall clock; one with an offset (`…Z`, `…+09:00`) is that instant. ISO-shaped text that names no real
59
+ day (`2026-02-30`) is treated as invalid rather than rolled into March; other text goes to the platform parser.
58
60
 
59
61
  A value that cannot be resolved to a real date — a malformed string, or an already-invalid
60
62
  `Date` — returns `String(value)` instead of throwing. `Intl.DateTimeFormat.format()` throws
@@ -65,6 +67,30 @@ That degrade is **deliberately not symmetric** with `formatCurrency`: a date arr
65
67
  data (an API, a user, a stale cache), so a bad one is an expected runtime state; a currency
66
68
  code is written at the call site, so a bad one is a bug worth surfacing.
67
69
 
70
+ ## Date values — `readDateValue` and writers
71
+
72
+ ```ts
73
+ import { readDateValue, writeInstant, writePlainDate, writePlainDateTime } from '@iyulab/components';
74
+
75
+ const read = readDateValue('2026-09-06T22:22:34Z');
76
+ // { kind: 'instant', date } — in Seoul, writeInstant(read.date) is '2026-09-07T07:22:34+09:00'
77
+ if (read?.kind === 'plainDate') console.log(writePlainDate(read.date));
78
+ ```
79
+
80
+ An app receives dates as text of three kinds, named after Temporal:
81
+
82
+ | kind | text | means here |
83
+ |---|---|---|
84
+ | `instant` | a date-time with `Z` or an offset (`…+09:00`, `…-0500`) | that moment; shown as this browser's wall clock |
85
+ | `plainDateTime` | a date-time without an offset (`2026-09-06T22:22`, `2026-09-06 22:22:34`) | that wall clock, local |
86
+ | `plainDate` | a day (`2026-09-06`) | local midnight of that day |
87
+
88
+ `readDateValue(value)` returns `{ kind, date }`, or `null` for text that is none of the three or names a day or
89
+ time that does not exist. A `Date` reads as an `instant`. Write back in the kind you read so the value keeps its
90
+ meaning: `writeInstant(date)` (local offset, same moment), `writePlainDateTime(date, seconds?)`,
91
+ `writePlainDate(date)`. `localOffset(date)` gives the `±HH:mm` of that date (daylight saving is per date).
92
+ `formatDate` and the date pickers read through the same function.
93
+
68
94
  ## Locale
69
95
 
70
96
  All three read `Locale.get()` when `locale` is omitted, so they follow whatever