@iyulab/components 2.20.1 → 2.20.3

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,34 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.20.3] - 2026-10-12
4
+
5
+ ### Fixed
6
+
7
+ - `parseNumber` and `u-input type="number"` read an exponent, as a native number input does: `1e7`, `1.5e-6`,
8
+ `2E+3`, and `1,5e3` on a comma-decimal page. Typed scientific notation used to report `badInput` with an empty
9
+ value. This also fixes a round trip: `value` is written with `String(number)`, which uses exponent form for very
10
+ small and very large numbers (`0,0000001` → `"1e-7"`), and `valueAsNumber` read that back as `NaN`.
11
+ - The React wrappers type an event with a standard DOM name (`change`, `input`, `copy`) as the DOM event the
12
+ element dispatches — `Event`, `ClipboardEvent` — instead of `CustomEvent`. These events carry no `detail`; the
13
+ old type let `e.detail` pass type checking and read `undefined` at runtime. Runtime behaviour is unchanged. A
14
+ handler annotated `(e: CustomEvent)` or reading `e.detail` on these props now fails type checking: annotate it
15
+ `(e: Event)` and read the value from `e.currentTarget`. Wrappers built with `plugins/vite-plugin-react-wrapper`
16
+ get the same typing.
17
+
18
+ ## [2.20.2] - 2026-10-12
19
+
20
+ ### Fixed
21
+
22
+ - The React wrapper types name every event's `detail` type with an import. `onPageChange` on the `UPagination`
23
+ wrapper used `PageChangeDetail` without importing it: under `skipLibCheck` the handler's event was silently
24
+ `any`, otherwise the declaration failed with `TS2304`. The wrapper generator (`plugins/vite-plugin-react-wrapper`)
25
+ now imports a detail type declared in the element's own module, and one imported from another package by its
26
+ package specifier.
27
+ - The wrapper generator types an `@event`-only event from the package's event map declarations — an element-scoped
28
+ `*EventMap`, then the `HTMLElementEventMap` / `GlobalEventHandlersEventMap` augmentations — when the event's
29
+ `detail` is `CustomEvent<T>` (or an alias of it) with `T` importable. Events dispatched by a controller rather than
30
+ `this.fire<T>()` were typed as a bare `CustomEvent`. Native-named events (`change`, `input`) are unchanged.
31
+
3
32
  ## [2.20.1] - 2026-10-12
4
33
 
5
34
  ### Fixed
@@ -14,6 +14,17 @@ interface ComponentEvent {
14
14
  * 절대화해 이 어긋남을 원천 차단한다.
15
15
  */
16
16
  detailSource: string;
17
+ /**
18
+ * detail 타입을 **다른 패키지**에서 가져올 때의 지정자(예: `@iyulab/components/dist/events/RemoveEvent.js`).
19
+ * 그 경우 `detailSource` 는 비고, d.ts 는 이 지정자 그대로 import 한다 — 비워 두면 래퍼 d.ts 가
20
+ * import 없이 이름만 써서 소비자 쪽에서 풀리지 않는다(`TS2304`).
21
+ */
22
+ detailSpecifier?: string;
23
+ }
24
+ /** detail 타입을 어디서 가져오는가 — 같은 패키지 소스(절대 경로) 또는 다른 패키지(지정자). */
25
+ interface DetailOrigin {
26
+ detailSource: string;
27
+ detailSpecifier?: string;
17
28
  }
18
29
  interface PluginOptions {
19
30
  /** 컴포넌트 소스 디렉토리 경로 (기본값: 'src/components') */
@@ -72,4 +83,39 @@ export declare function findEventDeclarationViolations(content: string, classNam
72
83
  * ⑵leaf 가 같은 이벤트를 더 구체적 타입으로 발화하면 그것이 이긴다.
73
84
  */
74
85
  export declare function collectComponentEvents(filePath: string): ComponentEvent[];
86
+ type EventEntry = {
87
+ detailType: string;
88
+ } & DetailOrigin;
89
+ /** 이벤트 맵 인터페이스의 `'name': Type;` 항목들 — `map` 은 맵 이름(예: `HTMLElementEventMap`). */
90
+ export declare function readEventMapEntries(content: string): {
91
+ map: string;
92
+ name: string;
93
+ type: string;
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;";
115
+ /**
116
+ * 이벤트 타입 글자에서 detail 타입과 그 출처를 푼다 — `CustomEvent<X>` 이거나, 같은 파일의
117
+ * `type A = CustomEvent<X>` 별칭 `A`. `X` 는 그 파일이 선언했거나 import 한 이름 하나, 또는 다른 이름을
118
+ * 참조하지 않는 인라인 타입(`{ query: string }`). 못 풀면 null — 추측해서 거짓 타입을 내지 않는다.
119
+ */
120
+ export declare function detailFromEventType(type: string, file: string, content: string): EventEntry | null;
75
121
  export {};
@@ -131,12 +131,26 @@ export function findEventDeclarationViolations(content, className, tagName, even
131
131
  */
132
132
  export function collectComponentEvents(filePath) {
133
133
  const eventMap = new Map();
134
- collectInto(eventMap, filePath, new Set());
135
- return Array.from(eventMap, ([name, { detailType, detailSource }]) => ({
134
+ const chain = new Set();
135
+ collectInto(eventMap, filePath, chain);
136
+ // `@event` 만 있고 detail 타입을 모르는 이벤트는 **이벤트 맵 선언**에서 찾는다 — 요소 범위 맵
137
+ // (`UInputEventMap` 처럼 상속 체인 파일의 `*EventMap`)이 먼저, 패키지 전역 증강
138
+ // (`HTMLElementEventMap`·`GlobalEventHandlersEventMap`)이 다음. 타입은 그 선언 한 곳이 정본이다 —
139
+ // 컨트롤러가 대신 발화하는 이벤트(`this.fire` 가 없다)도 여기서 타입을 얻는다.
140
+ const srcRoot = packageSrcRoot(filePath);
141
+ for (const [name, entry] of eventMap) {
142
+ if (entry.detailType !== 'unknown')
143
+ continue;
144
+ const found = lookupEventMaps(name, [...chain], srcRoot);
145
+ if (found)
146
+ eventMap.set(name, found);
147
+ }
148
+ return Array.from(eventMap, ([name, { detailType, detailSource, detailSpecifier }]) => ({
136
149
  name,
137
150
  reactName: toCamelEvent(name),
138
151
  detailType,
139
152
  detailSource,
153
+ ...(detailSpecifier ? { detailSpecifier } : {}),
140
154
  }));
141
155
  }
142
156
  function collectInto(eventMap, filePath, visited) {
@@ -146,15 +160,7 @@ function collectInto(eventMap, filePath, visited) {
146
160
  const content = readFileSync(filePath, 'utf-8');
147
161
  // import 구문에서 식별자 → 소스 경로 매핑 수집 (detail 타입과 베이스 클래스 양쪽에 쓴다)
148
162
  // 예: import { ShowEventDetail } from '../events/ShowEvent.js';
149
- const importMap = new Map();
150
- for (const m of content.matchAll(/import\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/g)) {
151
- const importPath = m[2];
152
- for (const name of m[1].split(',')) {
153
- const typeName = name.replace(/type\s+/, '').trim();
154
- if (typeName)
155
- importMap.set(typeName, importPath);
156
- }
157
- }
163
+ const importMap = readImportMap(content);
158
164
  // 베이스 클래스를 먼저 수집한다 (제네릭 베이스 `extends UFormControlElement<T>` 포함)
159
165
  const extendsMatch = content.match(/export\s+(?:abstract\s+)?class\s+\w+(?:<[^>]*>)?\s+extends\s+(\w+)/);
160
166
  if (extendsMatch) {
@@ -170,10 +176,163 @@ function collectInto(eventMap, filePath, visited) {
170
176
  // this.fire<DetailType>('eventName') 패턴 - 제네릭 타입 추출
171
177
  for (const m of content.matchAll(/this\.fire\s*(?:<([^>]+)>)?\s*\(\s*['"]([\w-]+)['"]/g)) {
172
178
  const detailType = m[1] || 'unknown';
173
- const detailSource = resolveLocalModule(filePath, importMap.get(detailType)) || '';
174
- eventMap.set(m[2], { detailType, detailSource });
179
+ eventMap.set(m[2], { detailType, ...detailOrigin(detailType, filePath, content, importMap) });
175
180
  }
176
181
  }
182
+ /** 이 파일이 그 이름을 export 선언하는가. */
183
+ function declaresExport(content, name) {
184
+ return new RegExp(`export\\s+(?:interface|type|class|enum)\\s+${name}\\b`).test(content);
185
+ }
186
+ /**
187
+ * detail 타입 이름의 출처 — 이 파일이 import 했으면 그 import 를, 이 파일이 스스로 export 선언했으면 이 파일을.
188
+ * ⚠뒤쪽이 빠져 있었다: `UPagination` 의 `PageChangeDetail` 처럼 요소 파일이 선언한 detail 은 출처가 비어
189
+ * 래퍼 d.ts 가 import 없이 이름만 썼다(`skipLibCheck` 소비자에게는 조용한 `any`, 아니면 `TS2304`).
190
+ */
191
+ function detailOrigin(name, file, content, importMap) {
192
+ const imported = importMap.get(name);
193
+ if (imported)
194
+ return resolveDetailOrigin(file, imported);
195
+ return declaresExport(content, name) ? { detailSource: file } : { detailSource: '' };
196
+ }
197
+ function readImportMap(content) {
198
+ const importMap = new Map();
199
+ for (const m of content.matchAll(/import\s+(?:type\s+)?\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/g)) {
200
+ for (const name of m[1].split(',')) {
201
+ const typeName = name.replace(/type\s+/, '').trim();
202
+ if (typeName)
203
+ importMap.set(typeName, m[2]);
204
+ }
205
+ }
206
+ return importMap;
207
+ }
208
+ /** 상대 import 는 같은 패키지 소스(절대 경로)로, 패키지 지정자는 그대로 — 둘 다 아니면 출처 없음. */
209
+ function resolveDetailOrigin(fromFile, importPath) {
210
+ if (importPath && !importPath.startsWith('.'))
211
+ return { detailSource: '', detailSpecifier: importPath };
212
+ return { detailSource: resolveLocalModule(fromFile, importPath) || '' };
213
+ }
214
+ /** 소스 파일이 속한 패키지의 `src` 디렉터리(없으면 그 파일의 디렉터리). */
215
+ function packageSrcRoot(filePath) {
216
+ const norm = filePath.split(sep).join('/');
217
+ const i = norm.lastIndexOf('/src/');
218
+ return i >= 0 ? norm.slice(0, i + 4) : dirname(filePath);
219
+ }
220
+ /** 이벤트 맵 인터페이스의 `'name': Type;` 항목들 — `map` 은 맵 이름(예: `HTMLElementEventMap`). */
221
+ export function readEventMapEntries(content) {
222
+ const out = [];
223
+ for (const m of content.matchAll(/interface\s+(\w*EventMap)\s*\{/g)) {
224
+ // 짝 맞는 닫는 중괄호까지 — 항목 타입 안의 `{ query: string }` 를 건너뛴다.
225
+ let depth = 1;
226
+ let i = m.index + m[0].length;
227
+ const start = i;
228
+ for (; i < content.length && depth > 0; i++) {
229
+ if (content[i] === '{')
230
+ depth++;
231
+ else if (content[i] === '}')
232
+ depth--;
233
+ }
234
+ const body = content.slice(start, i - 1).replace(/\/\*[\s\S]*?\*\//g, '').replace(/\/\/.*$/gm, '');
235
+ // 항목 = 맨 바깥 깊이의 `이름: 타입;` — 인라인 객체 타입 안의 `query: string;` 을 항목으로 읽지 않는다.
236
+ let depthB = 0;
237
+ let from = 0;
238
+ for (let j = 0; j < body.length; j++) {
239
+ const c = body[j];
240
+ if (c === '{' || c === '<' || c === '(')
241
+ depthB++;
242
+ else if (c === '}' || c === '>' || c === ')')
243
+ depthB--;
244
+ else if (c === ';' && depthB === 0) {
245
+ const e = body.slice(from, j).match(/^\s*['"]?([\w-]+)['"]?\s*:\s*([\s\S]+)$/);
246
+ if (e)
247
+ out.push({ map: m[1], name: e[1], type: e[2].trim() });
248
+ from = j + 1;
249
+ }
250
+ }
251
+ }
252
+ return out;
253
+ }
254
+ const GLOBAL_EVENT_MAPS = new Set(['HTMLElementEventMap', 'GlobalEventHandlersEventMap']);
255
+ const globalMapCache = new Map();
256
+ function globalEventMapEntries(srcRoot) {
257
+ let entries = globalMapCache.get(srcRoot);
258
+ if (!entries) {
259
+ entries = [];
260
+ for (const file of globSync('**/*.ts', { cwd: srcRoot, absolute: true, ignore: ['**/*.test.ts', '**/*.d.ts'] })) {
261
+ const content = readFileSync(file, 'utf-8');
262
+ if (!content.includes('EventMap'))
263
+ continue;
264
+ for (const e of readEventMapEntries(content)) {
265
+ if (GLOBAL_EVENT_MAPS.has(e.map))
266
+ entries.push({ name: e.name, type: e.type, file });
267
+ }
268
+ }
269
+ globalMapCache.set(srcRoot, entries);
270
+ }
271
+ return entries;
272
+ }
273
+ function lookupEventMaps(name, chainFiles, srcRoot) {
274
+ // 요소 범위 맵 — 상속 체인 파일 안의 `*EventMap`. leaf 부터(가장 구체적인 선언이 이긴다).
275
+ for (const file of [...chainFiles].reverse()) {
276
+ const content = readFileSync(file, 'utf-8');
277
+ const hit = readEventMapEntries(content).find(e => e.name === name && !GLOBAL_EVENT_MAPS.has(e.map));
278
+ const resolved = hit && detailFromEventType(hit.type, file, content);
279
+ if (resolved)
280
+ return resolved;
281
+ }
282
+ for (const hit of globalEventMapEntries(srcRoot).filter(e => e.name === name)) {
283
+ const resolved = detailFromEventType(hit.type, hit.file, readFileSync(hit.file, 'utf-8'));
284
+ if (resolved)
285
+ return resolved;
286
+ }
287
+ return null;
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;';
310
+ const INLINE_PRIMITIVES = new Set(['string', 'number', 'boolean', 'null', 'undefined', 'unknown', 'true', 'false', 'readonly']);
311
+ /**
312
+ * 이벤트 타입 글자에서 detail 타입과 그 출처를 푼다 — `CustomEvent<X>` 이거나, 같은 파일의
313
+ * `type A = CustomEvent<X>` 별칭 `A`. `X` 는 그 파일이 선언했거나 import 한 이름 하나, 또는 다른 이름을
314
+ * 참조하지 않는 인라인 타입(`{ query: string }`). 못 풀면 null — 추측해서 거짓 타입을 내지 않는다.
315
+ */
316
+ export function detailFromEventType(type, file, content) {
317
+ const alias = type.match(/^(\w+)$/);
318
+ if (alias) {
319
+ const def = content.match(new RegExp(`type\\s+${alias[1]}\\s*=\\s*([^;]+);`));
320
+ return def ? detailFromEventType(def[1].trim(), file, content) : null;
321
+ }
322
+ const custom = type.match(/^CustomEvent<([\s\S]+)>$/);
323
+ if (!custom)
324
+ return null;
325
+ const detail = custom[1].trim();
326
+ if (/^\w+$/.test(detail)) {
327
+ const origin = detailOrigin(detail, file, content, readImportMap(content));
328
+ return origin.detailSource || origin.detailSpecifier ? { detailType: detail, ...origin } : null;
329
+ }
330
+ // 인라인 타입 — 속성 이름과 원시 타입만 쓸 때(다른 이름을 참조하면 import 할 길이 없다).
331
+ const keys = new Set([...detail.matchAll(/(\w+)\??\s*:/g)].map(k => k[1]));
332
+ const idents = (detail.replace(/(['"])(?:(?!\1).)*\1/g, '').match(/[A-Za-z_]\w*/g) ?? [])
333
+ .filter(id => !INLINE_PRIMITIVES.has(id) && !keys.has(id));
334
+ return idents.length === 0 ? { detailType: detail, detailSource: '' } : null;
335
+ }
177
336
  /** 같은 패키지 소스 안의 상대 import 를 절대 `.ts` 경로로 해석한다 (외부 모듈이면 null) */
178
337
  function resolveLocalModule(fromFile, importPath) {
179
338
  if (!importPath || !importPath.startsWith('.'))
@@ -252,8 +411,18 @@ export const ${className} = createComponent({
252
411
  // leaf 기준으로 잘못 풀리는 것을 막기 위함 — ComponentEvent.detailSource 주석 참조).
253
412
  const detailImportMap = new Map(); // 빌드경로 → [타입명]
254
413
  for (const e of events) {
255
- if (e.detailType === 'unknown' || !e.detailSource)
414
+ if (e.detailType === 'unknown')
256
415
  continue;
416
+ // 다른 패키지의 detail 타입은 그 지정자 그대로 — 이미 «패키지 스펙»이다.
417
+ if (e.detailSpecifier) {
418
+ const types = detailImportMap.get(e.detailSpecifier) || [];
419
+ if (!types.includes(e.detailType))
420
+ types.push(e.detailType);
421
+ detailImportMap.set(e.detailSpecifier, types);
422
+ continue;
423
+ }
424
+ if (!e.detailSource)
425
+ continue; // 인라인 타입(`{ query: string }`) — import 할 것이 없다
257
426
  const absEventSrc = e.detailSource.replace(/\\/g, '/');
258
427
  const eventSrcIndex = absEventSrc.indexOf('/src/');
259
428
  const relFromSrc = eventSrcIndex >= 0
@@ -274,10 +443,7 @@ export const ${className} = createComponent({
274
443
  dtsImports.push(`import { type ${types.join(', type ')} } from '${path}';`);
275
444
  }
276
445
  const eventTypes = events.length > 0
277
- ? events.map(e => {
278
- const type = e.detailType !== 'unknown' ? `CustomEvent<${e.detailType}>` : 'CustomEvent';
279
- return ` ${e.reactName}?: (event: ${type}) => void;`;
280
- }).join('\n') + '\n'
446
+ ? events.map(e => ` ${e.reactName}?: (event: ${eventPropType(e)}) => void;`).join('\n') + '\n'
281
447
  : '';
282
448
  // 래퍼 이벤트 prop(onChange 등)은 React.HTMLAttributes 의 동명 핸들러와 교집합되면
283
449
  // 어떤 시그니처도 대입 불가가 된다. HTMLAttributes 쪽에서 해당 키를 제거해 CustomEvent
@@ -302,7 +468,7 @@ export const ${className} = createComponent({
302
468
  // 이것을 빠뜨리면 **런타임은 되는데 타입만 거부하는** 괴리가 생긴다.
303
469
  const dts = `${dtsImports.join('\n')}
304
470
 
305
- 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>;
306
472
 
307
473
  export declare const ${className}: React.ForwardRefExoticComponent<
308
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,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { UPagination as UPaginationElement } from '@iyulab/components/dist/components/pagination/UPagination.js';
3
+ import { type PageChangeDetail } from '@iyulab/components/dist/components/pagination/UPagination.js';
3
4
 
4
5
  type UPaginationOwnProps = Omit<UPaginationElement, keyof HTMLElement>;
5
6
 
@@ -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
 
@@ -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`). */
@@ -99,13 +99,20 @@ var GROUP_MARKS = /[\s\u00A0\u202F\u2009'\u2019]/;
99
99
  * digits follow (`1,234` on an English page → 1234).
100
100
  *
101
101
  * 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`.
102
+ * one to three digits — `1,23,4` is `null`. A leading `+`, `-` or `−` sets the sign.
103
+ *
104
+ * An exponent may follow, as in a native number input: `e` or `E`, an optional sign, digits
105
+ * (`1e7`, `1.5e-6`, `2E+3`). The separator rules above apply to the part before it (`1,5e3` on a
106
+ * comma-decimal page is 1500); the exponent is never grouped. `e5`, `1e` and `1e+` are `null`.
107
+ * Reading exponents also lets every string `String(number)` writes come back (`1e-7`, `1e+21`).
108
+ * `locale` defaults to the active `Locale`.
104
109
  */
105
110
  function parseNumber(text, locale) {
106
111
  const signed = text.trim().match(/^([+\-\u2212]?)(.*)$/s);
107
112
  const negative = signed[1] === "-" || signed[1] === "−";
108
- const body = signed[2];
113
+ const scientific = signed[2].match(/^(.*?)[eE]([+-]?)(\d+)$/s);
114
+ const body = scientific ? scientific[1] : signed[2];
115
+ const exponent = scientific ? `${scientific[2]}${scientific[3]}` : "0";
109
116
  if (!body || !/^[\d.,\s\u00A0\u202F\u2009'\u2019]+$/.test(body) || !/\d/.test(body)) return null;
110
117
  if (GROUP_MARKS.test(body[0]) || GROUP_MARKS.test(body[body.length - 1])) return null;
111
118
  const dots = body.split(".").length - 1;
@@ -129,7 +136,7 @@ function parseNumber(text, locale) {
129
136
  } else if (!/^\d*$/.test(intPart)) return null;
130
137
  const digits = groups.join("");
131
138
  if (!digits && !fracPart) return null;
132
- const value = Number(`${negative ? "-" : ""}${digits || "0"}.${fracPart || "0"}`);
139
+ const value = Number(`${negative ? "-" : ""}${digits || "0"}.${fracPart || "0"}e${exponent}`);
133
140
  return Number.isFinite(value) ? value : null;
134
141
  }
135
142
  /** 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.1",
4
+ "version": "2.20.3",
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