@iyulab/components 2.20.2 → 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 +15 -0
- package/dist/plugins/vite-plugin-react-wrapper.d.ts +20 -0
- package/dist/plugins/vite-plugin-react-wrapper.js +23 -5
- package/dist/react/UCheckbox.d.ts +2 -1
- package/dist/react/UCopyButton.d.ts +2 -1
- package/dist/react/UDatePicker.d.ts +2 -1
- package/dist/react/UDateRangePicker.d.ts +2 -1
- package/dist/react/UFileInput.d.ts +2 -1
- package/dist/react/UForm.d.ts +2 -1
- package/dist/react/UInput.d.ts +3 -2
- package/dist/react/UMenu.d.ts +2 -1
- package/dist/react/URadio.d.ts +2 -1
- package/dist/react/URating.d.ts +2 -1
- package/dist/react/USelect.d.ts +2 -1
- package/dist/react/USlider.d.ts +2 -1
- package/dist/react/USwitch.d.ts +2 -1
- package/dist/react/UTabPanel.d.ts +2 -1
- package/dist/react/UTextarea.d.ts +3 -2
- package/dist/react/UTree.d.ts +2 -1
- package/dist/utilities/format.d.ts +7 -2
- package/dist/utilities/format.js +11 -4
- package/package.json +2 -2
- package/skills/iyulab-components/references/components/input.md +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
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
|
+
|
|
3
18
|
## [2.20.2] - 2026-10-12
|
|
4
19
|
|
|
5
20
|
### Fixed
|
|
@@ -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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
12
|
+
onChange?: (event: EventOf<'change'>) => void;
|
|
12
13
|
}
|
|
13
14
|
>;
|
|
14
15
|
|
package/dist/react/UForm.d.ts
CHANGED
|
@@ -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:
|
|
12
|
+
onChange?: (event: EventOf<'change'>) => void;
|
|
12
13
|
}
|
|
13
14
|
>;
|
|
14
15
|
|
package/dist/react/UInput.d.ts
CHANGED
|
@@ -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:
|
|
12
|
-
onChange?: (event:
|
|
12
|
+
onInput?: (event: EventOf<'input'>) => void;
|
|
13
|
+
onChange?: (event: EventOf<'change'>) => void;
|
|
13
14
|
onSearch?: (event: CustomEvent<{ query: string }>) => void;
|
|
14
15
|
}
|
|
15
16
|
>;
|
package/dist/react/UMenu.d.ts
CHANGED
|
@@ -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:
|
|
12
|
+
onChange?: (event: EventOf<'change'>) => void;
|
|
12
13
|
}
|
|
13
14
|
>;
|
|
14
15
|
|
package/dist/react/URadio.d.ts
CHANGED
|
@@ -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:
|
|
12
|
+
onChange?: (event: EventOf<'change'>) => void;
|
|
12
13
|
}
|
|
13
14
|
>;
|
|
14
15
|
|
package/dist/react/URating.d.ts
CHANGED
|
@@ -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:
|
|
12
|
+
onChange?: (event: EventOf<'change'>) => void;
|
|
12
13
|
}
|
|
13
14
|
>;
|
|
14
15
|
|
package/dist/react/USelect.d.ts
CHANGED
|
@@ -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:
|
|
12
|
+
onChange?: (event: EventOf<'change'>) => void;
|
|
12
13
|
onSearch?: (event: CustomEvent<{ query: string }>) => void;
|
|
13
14
|
}
|
|
14
15
|
>;
|
package/dist/react/USlider.d.ts
CHANGED
|
@@ -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:
|
|
12
|
+
onChange?: (event: EventOf<'change'>) => void;
|
|
12
13
|
}
|
|
13
14
|
>;
|
|
14
15
|
|
package/dist/react/USwitch.d.ts
CHANGED
|
@@ -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:
|
|
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:
|
|
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:
|
|
12
|
-
onChange?: (event:
|
|
12
|
+
onInput?: (event: EventOf<'input'>) => void;
|
|
13
|
+
onChange?: (event: EventOf<'change'>) => void;
|
|
13
14
|
}
|
|
14
15
|
>;
|
|
15
16
|
|
package/dist/react/UTree.d.ts
CHANGED
|
@@ -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:
|
|
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.
|
|
55
|
-
*
|
|
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`). */
|
package/dist/utilities/format.js
CHANGED
|
@@ -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.
|
|
103
|
-
*
|
|
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
|
|
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.
|
|
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": "^
|
|
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`).
|
|
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
|