html-combobox-element 0.0.6 → 0.0.7
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/README.md +26 -25
- package/dist/cjs/index.d.ts +66 -22
- package/dist/cjs/index.js +11 -0
- package/dist/esm/index.js +10 -0
- package/dist/types/index.d.ts +66 -22
- package/package.json +33 -2
package/README.md
CHANGED
|
@@ -145,37 +145,38 @@ Playwright names a custom element from `<label for>` only for native controls,
|
|
|
145
145
|
so query `getByRole('combobox', { name })` with `aria-label` or `aria-labelledby` on the `<combo-box>`, or without a name.
|
|
146
146
|
|
|
147
147
|
## TypeScript and JSX
|
|
148
|
-
|
|
149
|
-
|
|
148
|
+
`import 'html-combobox-element'` also brings the typings: `document.createElement('combo-box')`, `querySelector`, `addEventListener` with the combobox's own events (`change`, `input`, `close`, `search`, `reset`, with a typed `event.target`) and `instanceof HTMLComboboxElement` all use the same `HTMLComboboxElement` type.
|
|
149
|
+
|
|
150
|
+
### React
|
|
151
|
+
Nothing to add: `<combo-box>`, `<box-option>` and `<box-tag>` are typed with React's own types (`ref`, `style`, every DOM handler, `aria-*`...), for `jsx: "react-jsx"`, `"react-jsxdev"` and classic `"react"`.
|
|
152
|
+
|
|
153
|
+
React wraps events in its own SyntheticEvents, so handlers are typed accordingly:
|
|
154
|
+
- `onChange`, `onInput`, `onFocus`, `onClick`, ... receive a SyntheticEvent: `event.target` is the `<combo-box>` (`event.target.value`, `event.target.query`), `event.nativeEvent` is the DOM event.
|
|
155
|
+
- Events React doesn't know are attached by React 19 as native listeners under the exact, case-sensitive name: use `onclose` and `onsearch` (lowercase). `onClose`/`onSearch` never fire, and are type errors.
|
|
156
|
+
|
|
157
|
+
```tsx
|
|
158
|
+
<combo-box
|
|
159
|
+
name="fruit"
|
|
160
|
+
multiple
|
|
161
|
+
onChange={(event) => setFruits(event.target.valueAsArray)}
|
|
162
|
+
onclose={(event) => event.target.changed && save()}
|
|
163
|
+
>
|
|
164
|
+
<box-option value="apple">Apple</box-option>
|
|
165
|
+
</combo-box>
|
|
166
|
+
```
|
|
150
167
|
|
|
151
|
-
|
|
168
|
+
With `@types/react` 18 the framework-agnostic typings are used, as in previous versions.
|
|
152
169
|
|
|
153
|
-
|
|
154
|
-
<summary><strong>React</strong> (<code>jsx: "react-jsx"</code>)</summary>
|
|
170
|
+
If you copied the React `combo-box.d.ts` snippet from the README of a previous version, delete it: it still compiles, but it keeps the old typings.
|
|
155
171
|
|
|
172
|
+
### Monorepos
|
|
173
|
+
The typings are part of a TypeScript program only if the program includes this package. A workspace package that renders `<combo-box>` but leaves the import to the app shell type-checks inside the app, but not on its own (its CI, editor, project references). Add a type-only import there - it's removed from the JS output, nothing is registered twice:
|
|
156
174
|
```ts
|
|
157
|
-
|
|
158
|
-
declare module 'react/jsx-runtime' {
|
|
159
|
-
namespace JSX {
|
|
160
|
-
interface IntrinsicElements {
|
|
161
|
-
'combo-box': ComboboxElementAttributes;
|
|
162
|
-
'box-option': ComboboxOptionElementAttributes;
|
|
163
|
-
'box-tag': ComboboxTagElementAttributes;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
declare module 'react/jsx-dev-runtime' {
|
|
168
|
-
namespace JSX {
|
|
169
|
-
interface IntrinsicElements {
|
|
170
|
-
'combo-box': ComboboxElementAttributes;
|
|
171
|
-
'box-option': ComboboxOptionElementAttributes;
|
|
172
|
-
'box-tag': ComboboxTagElementAttributes;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
175
|
+
import type {} from 'html-combobox-element';
|
|
176
176
|
```
|
|
177
177
|
|
|
178
|
-
|
|
178
|
+
### Other frameworks
|
|
179
|
+
JSX/template type-checking for these needs one small file in your project, with the snippet for your framework:
|
|
179
180
|
|
|
180
181
|
<details>
|
|
181
182
|
<summary><strong>Preact</strong> (<code>jsx: "react-jsx"</code>, <code>jsxImportSource: "preact"</code>)</summary>
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,13 +1,31 @@
|
|
|
1
|
+
import { HTMLComboboxElement as ComboboxElementClass } from './combobox/HTML.combobox.element.js';
|
|
2
|
+
import type { HTMLComboboxOptionsCollection } from './combobox/HTML.combobox.options.collection.js';
|
|
1
3
|
export * from './combobox/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* The `<combo-box>` constructor, typed the way lib.dom types built-in elements
|
|
6
|
+
* (`interface HTMLSelectElement` + `declare var HTMLSelectElement: { prototype; new() }`):
|
|
7
|
+
* the same `HTMLComboboxElement` type is what `document.createElement('combo-box')`,
|
|
8
|
+
* `querySelector('combo-box')`, `event.target`, refs and `instanceof HTMLComboboxElement` give.
|
|
9
|
+
*
|
|
10
|
+
* Runtime-wise this is the very same class object that `export *` exported before.
|
|
11
|
+
*/
|
|
12
|
+
export declare const HTMLComboboxElement: Omit<typeof ComboboxElementClass, 'prototype'> & {
|
|
13
|
+
prototype: HTMLComboboxElement;
|
|
14
|
+
new (): HTMLComboboxElement;
|
|
15
|
+
};
|
|
2
16
|
interface HTMLComboboxTagElement extends HTMLElement {
|
|
3
17
|
}
|
|
4
18
|
interface HTMLComboboxOptionElement extends HTMLOptionElement {
|
|
5
19
|
value: string;
|
|
6
20
|
label: string;
|
|
7
21
|
}
|
|
8
|
-
interface HTMLComboboxElement extends HTMLSelectElement {
|
|
22
|
+
export interface HTMLComboboxElement extends HTMLSelectElement {
|
|
9
23
|
/** List of selected options value attribute */
|
|
10
24
|
valueAsArray: string[];
|
|
25
|
+
/** Whether the value differs from when the picker opened (read it in a `close` listener). */
|
|
26
|
+
readonly changed: boolean;
|
|
27
|
+
/** A live `HTMLOptionsCollection`-compatible collection (not `instanceof HTMLOptionsCollection`). */
|
|
28
|
+
readonly options: HTMLOptionsCollection & HTMLComboboxOptionsCollection;
|
|
11
29
|
multiple: boolean;
|
|
12
30
|
/** The value of internal input
|
|
13
31
|
*
|
|
@@ -45,11 +63,11 @@ interface HTMLComboboxElement extends HTMLSelectElement {
|
|
|
45
63
|
* */
|
|
46
64
|
filterable: boolean;
|
|
47
65
|
selectedOptions: HTMLCollectionOf<HTMLComboboxOptionElement>;
|
|
48
|
-
addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLComboboxElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
49
66
|
addEventListener<K extends keyof ComboboxEventMap>(type: K, listener: (this: HTMLComboboxElement, ev: ComboboxEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
67
|
+
addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLComboboxElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
50
68
|
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
51
|
-
removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLComboboxElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
|
|
52
69
|
removeEventListener<K extends keyof ComboboxEventMap>(type: K, listener: (this: HTMLComboboxElement, ev: ComboboxEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
|
|
70
|
+
removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLComboboxElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
|
|
53
71
|
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
54
72
|
}
|
|
55
73
|
interface ComboboxEventMap extends HTMLElementEventMap {
|
|
@@ -62,6 +80,12 @@ interface ComboboxEventMap extends HTMLElementEventMap {
|
|
|
62
80
|
"invalid": ComboboxEvent;
|
|
63
81
|
"selectionchange": ComboboxEvent;
|
|
64
82
|
"selectstart": ComboboxEvent;
|
|
83
|
+
/** The picker closed (read `event.target.changed`) */
|
|
84
|
+
"close": ComboboxEvent;
|
|
85
|
+
/** Enter was pressed in the search field */
|
|
86
|
+
"search": ComboboxEvent;
|
|
87
|
+
/** The owner form was reset */
|
|
88
|
+
"reset": ComboboxEvent;
|
|
65
89
|
}
|
|
66
90
|
/** Own attributes/properties of `<combo-box>`, shared by every JSX integration below. */
|
|
67
91
|
export interface ComboboxJsxAttributes {
|
|
@@ -109,6 +133,10 @@ export interface ComboboxJsxAttributes {
|
|
|
109
133
|
/** A Boolean attribute indicating that at least one option must be selected. */
|
|
110
134
|
required?: boolean;
|
|
111
135
|
disabled?: boolean;
|
|
136
|
+
/** The name the value is submitted under (`<combo-box>` is form-associated). */
|
|
137
|
+
name?: string;
|
|
138
|
+
/** The id of the `<form>` this combobox belongs to, when it isn't inside it. */
|
|
139
|
+
form?: string;
|
|
112
140
|
}
|
|
113
141
|
export interface ComboboxOptionJsxAttributes {
|
|
114
142
|
value: string;
|
|
@@ -173,29 +201,45 @@ declare global {
|
|
|
173
201
|
}
|
|
174
202
|
}
|
|
175
203
|
declare module 'react' {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
204
|
+
/** A React event whose `target` is the element (events from the shadow DOM are retargeted to it). */
|
|
205
|
+
type ComboboxSyntheticEvent<T, E extends globalThis.Event = globalThis.Event> = import('react').SyntheticEvent<T, E> & {
|
|
206
|
+
target: EventTarget & T;
|
|
207
|
+
};
|
|
208
|
+
type ComboboxBaseHTMLAttributes<T> = import('react').HTMLAttributes<T>;
|
|
209
|
+
type ComboboxBaseHostAttributes<T> = Omit<import('react').HTMLAttributes<T>, 'onInput'>;
|
|
210
|
+
interface ComboboxHTMLAttributes<T> extends ComboboxBaseHostAttributes<T>, ComboboxJsxAttributes {
|
|
211
|
+
class?: string | undefined;
|
|
212
|
+
/** The user changed the selection (`event.target.value` is the new value). */
|
|
213
|
+
onChange?: import('react').EventHandler<ComboboxSyntheticEvent<T>> | undefined;
|
|
214
|
+
/** The user typed in the search field (`event.target.query`); `nativeEvent` is its InputEvent. */
|
|
215
|
+
onInput?: import('react').EventHandler<ComboboxSyntheticEvent<T, globalThis.InputEvent>> | undefined;
|
|
216
|
+
onInvalid?: import('react').EventHandler<ComboboxSyntheticEvent<T>> | undefined;
|
|
217
|
+
/** Native listener: the picker closed (`event.target.changed`). Lowercase - `onClose` never fires. */
|
|
218
|
+
onclose?: ((event: ComboboxEvent) => void) | undefined;
|
|
219
|
+
/** Native listener: Enter in the search field. Lowercase - `onSearch` never fires. */
|
|
220
|
+
onsearch?: ((event: ComboboxEvent) => void) | undefined;
|
|
182
221
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
namespace JSX {
|
|
186
|
-
interface IntrinsicElements {
|
|
187
|
-
'combo-box': ComboboxElementAttributes;
|
|
188
|
-
'box-option': ComboboxOptionElementAttributes;
|
|
189
|
-
'box-tag': ComboboxTagElementAttributes;
|
|
190
|
-
}
|
|
222
|
+
interface ComboboxOptionHTMLAttributes<T> extends ComboboxBaseHTMLAttributes<T>, ComboboxOptionJsxAttributes {
|
|
223
|
+
class?: string | undefined;
|
|
191
224
|
}
|
|
192
|
-
|
|
193
|
-
|
|
225
|
+
interface ComboboxTagHTMLAttributes<T> extends ComboboxBaseHTMLAttributes<T> {
|
|
226
|
+
class?: string | undefined;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* @types/react 18 builds React.JSX.IntrinsicElements on top of the global JSX namespace, so
|
|
230
|
+
* its entries must stay assignable to the framework-agnostic global ones (catch-all `on*`,
|
|
231
|
+
* native event types): with React 18 types the global entries are kept as they are.
|
|
232
|
+
* @types/react 19 has no global JSX namespace: React.JSX gets React-typed props.
|
|
233
|
+
* (React 18 types declare the HTML elements in the global namespace, React 19 types don't.)
|
|
234
|
+
*/
|
|
235
|
+
type ComboboxIntrinsicElement<Global, Typed> = globalThis.JSX.IntrinsicElements extends {
|
|
236
|
+
div: unknown;
|
|
237
|
+
} ? Global : Typed;
|
|
194
238
|
namespace JSX {
|
|
195
239
|
interface IntrinsicElements {
|
|
196
|
-
'combo-box': ComboboxElementAttributes
|
|
197
|
-
'box-option': ComboboxOptionElementAttributes
|
|
198
|
-
'box-tag': ComboboxTagElementAttributes
|
|
240
|
+
'combo-box': ComboboxIntrinsicElement<ComboboxElementAttributes, import('react').ClassAttributes<HTMLComboboxElement> & ComboboxHTMLAttributes<HTMLComboboxElement>>;
|
|
241
|
+
'box-option': ComboboxIntrinsicElement<ComboboxOptionElementAttributes, import('react').ClassAttributes<HTMLComboboxOptionElement> & ComboboxOptionHTMLAttributes<HTMLComboboxOptionElement>>;
|
|
242
|
+
'box-tag': ComboboxIntrinsicElement<ComboboxTagElementAttributes, import('react').ClassAttributes<HTMLComboboxTagElement> & ComboboxTagHTMLAttributes<HTMLComboboxTagElement>>;
|
|
199
243
|
}
|
|
200
244
|
}
|
|
201
245
|
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -14,4 +14,15 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.HTMLComboboxElement = void 0;
|
|
18
|
+
const HTML_combobox_element_js_1 = require("./combobox/HTML.combobox.element.js");
|
|
17
19
|
__exportStar(require("./combobox/index.js"), exports);
|
|
20
|
+
/**
|
|
21
|
+
* The `<combo-box>` constructor, typed the way lib.dom types built-in elements
|
|
22
|
+
* (`interface HTMLSelectElement` + `declare var HTMLSelectElement: { prototype; new() }`):
|
|
23
|
+
* the same `HTMLComboboxElement` type is what `document.createElement('combo-box')`,
|
|
24
|
+
* `querySelector('combo-box')`, `event.target`, refs and `instanceof HTMLComboboxElement` give.
|
|
25
|
+
*
|
|
26
|
+
* Runtime-wise this is the very same class object that `export *` exported before.
|
|
27
|
+
*/
|
|
28
|
+
exports.HTMLComboboxElement = HTML_combobox_element_js_1.HTMLComboboxElement;
|
package/dist/esm/index.js
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
|
+
import { HTMLComboboxElement as ComboboxElementClass } from './combobox/HTML.combobox.element.js';
|
|
1
2
|
export * from './combobox/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* The `<combo-box>` constructor, typed the way lib.dom types built-in elements
|
|
5
|
+
* (`interface HTMLSelectElement` + `declare var HTMLSelectElement: { prototype; new() }`):
|
|
6
|
+
* the same `HTMLComboboxElement` type is what `document.createElement('combo-box')`,
|
|
7
|
+
* `querySelector('combo-box')`, `event.target`, refs and `instanceof HTMLComboboxElement` give.
|
|
8
|
+
*
|
|
9
|
+
* Runtime-wise this is the very same class object that `export *` exported before.
|
|
10
|
+
*/
|
|
11
|
+
export const HTMLComboboxElement = ComboboxElementClass;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,13 +1,31 @@
|
|
|
1
|
+
import { HTMLComboboxElement as ComboboxElementClass } from './combobox/HTML.combobox.element.js';
|
|
2
|
+
import type { HTMLComboboxOptionsCollection } from './combobox/HTML.combobox.options.collection.js';
|
|
1
3
|
export * from './combobox/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* The `<combo-box>` constructor, typed the way lib.dom types built-in elements
|
|
6
|
+
* (`interface HTMLSelectElement` + `declare var HTMLSelectElement: { prototype; new() }`):
|
|
7
|
+
* the same `HTMLComboboxElement` type is what `document.createElement('combo-box')`,
|
|
8
|
+
* `querySelector('combo-box')`, `event.target`, refs and `instanceof HTMLComboboxElement` give.
|
|
9
|
+
*
|
|
10
|
+
* Runtime-wise this is the very same class object that `export *` exported before.
|
|
11
|
+
*/
|
|
12
|
+
export declare const HTMLComboboxElement: Omit<typeof ComboboxElementClass, 'prototype'> & {
|
|
13
|
+
prototype: HTMLComboboxElement;
|
|
14
|
+
new (): HTMLComboboxElement;
|
|
15
|
+
};
|
|
2
16
|
interface HTMLComboboxTagElement extends HTMLElement {
|
|
3
17
|
}
|
|
4
18
|
interface HTMLComboboxOptionElement extends HTMLOptionElement {
|
|
5
19
|
value: string;
|
|
6
20
|
label: string;
|
|
7
21
|
}
|
|
8
|
-
interface HTMLComboboxElement extends HTMLSelectElement {
|
|
22
|
+
export interface HTMLComboboxElement extends HTMLSelectElement {
|
|
9
23
|
/** List of selected options value attribute */
|
|
10
24
|
valueAsArray: string[];
|
|
25
|
+
/** Whether the value differs from when the picker opened (read it in a `close` listener). */
|
|
26
|
+
readonly changed: boolean;
|
|
27
|
+
/** A live `HTMLOptionsCollection`-compatible collection (not `instanceof HTMLOptionsCollection`). */
|
|
28
|
+
readonly options: HTMLOptionsCollection & HTMLComboboxOptionsCollection;
|
|
11
29
|
multiple: boolean;
|
|
12
30
|
/** The value of internal input
|
|
13
31
|
*
|
|
@@ -45,11 +63,11 @@ interface HTMLComboboxElement extends HTMLSelectElement {
|
|
|
45
63
|
* */
|
|
46
64
|
filterable: boolean;
|
|
47
65
|
selectedOptions: HTMLCollectionOf<HTMLComboboxOptionElement>;
|
|
48
|
-
addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLComboboxElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
49
66
|
addEventListener<K extends keyof ComboboxEventMap>(type: K, listener: (this: HTMLComboboxElement, ev: ComboboxEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
67
|
+
addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLComboboxElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
50
68
|
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
51
|
-
removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLComboboxElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
|
|
52
69
|
removeEventListener<K extends keyof ComboboxEventMap>(type: K, listener: (this: HTMLComboboxElement, ev: ComboboxEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
|
|
70
|
+
removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLComboboxElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
|
|
53
71
|
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
54
72
|
}
|
|
55
73
|
interface ComboboxEventMap extends HTMLElementEventMap {
|
|
@@ -62,6 +80,12 @@ interface ComboboxEventMap extends HTMLElementEventMap {
|
|
|
62
80
|
"invalid": ComboboxEvent;
|
|
63
81
|
"selectionchange": ComboboxEvent;
|
|
64
82
|
"selectstart": ComboboxEvent;
|
|
83
|
+
/** The picker closed (read `event.target.changed`) */
|
|
84
|
+
"close": ComboboxEvent;
|
|
85
|
+
/** Enter was pressed in the search field */
|
|
86
|
+
"search": ComboboxEvent;
|
|
87
|
+
/** The owner form was reset */
|
|
88
|
+
"reset": ComboboxEvent;
|
|
65
89
|
}
|
|
66
90
|
/** Own attributes/properties of `<combo-box>`, shared by every JSX integration below. */
|
|
67
91
|
export interface ComboboxJsxAttributes {
|
|
@@ -109,6 +133,10 @@ export interface ComboboxJsxAttributes {
|
|
|
109
133
|
/** A Boolean attribute indicating that at least one option must be selected. */
|
|
110
134
|
required?: boolean;
|
|
111
135
|
disabled?: boolean;
|
|
136
|
+
/** The name the value is submitted under (`<combo-box>` is form-associated). */
|
|
137
|
+
name?: string;
|
|
138
|
+
/** The id of the `<form>` this combobox belongs to, when it isn't inside it. */
|
|
139
|
+
form?: string;
|
|
112
140
|
}
|
|
113
141
|
export interface ComboboxOptionJsxAttributes {
|
|
114
142
|
value: string;
|
|
@@ -173,29 +201,45 @@ declare global {
|
|
|
173
201
|
}
|
|
174
202
|
}
|
|
175
203
|
declare module 'react' {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
204
|
+
/** A React event whose `target` is the element (events from the shadow DOM are retargeted to it). */
|
|
205
|
+
type ComboboxSyntheticEvent<T, E extends globalThis.Event = globalThis.Event> = import('react').SyntheticEvent<T, E> & {
|
|
206
|
+
target: EventTarget & T;
|
|
207
|
+
};
|
|
208
|
+
type ComboboxBaseHTMLAttributes<T> = import('react').HTMLAttributes<T>;
|
|
209
|
+
type ComboboxBaseHostAttributes<T> = Omit<import('react').HTMLAttributes<T>, 'onInput'>;
|
|
210
|
+
interface ComboboxHTMLAttributes<T> extends ComboboxBaseHostAttributes<T>, ComboboxJsxAttributes {
|
|
211
|
+
class?: string | undefined;
|
|
212
|
+
/** The user changed the selection (`event.target.value` is the new value). */
|
|
213
|
+
onChange?: import('react').EventHandler<ComboboxSyntheticEvent<T>> | undefined;
|
|
214
|
+
/** The user typed in the search field (`event.target.query`); `nativeEvent` is its InputEvent. */
|
|
215
|
+
onInput?: import('react').EventHandler<ComboboxSyntheticEvent<T, globalThis.InputEvent>> | undefined;
|
|
216
|
+
onInvalid?: import('react').EventHandler<ComboboxSyntheticEvent<T>> | undefined;
|
|
217
|
+
/** Native listener: the picker closed (`event.target.changed`). Lowercase - `onClose` never fires. */
|
|
218
|
+
onclose?: ((event: ComboboxEvent) => void) | undefined;
|
|
219
|
+
/** Native listener: Enter in the search field. Lowercase - `onSearch` never fires. */
|
|
220
|
+
onsearch?: ((event: ComboboxEvent) => void) | undefined;
|
|
182
221
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
namespace JSX {
|
|
186
|
-
interface IntrinsicElements {
|
|
187
|
-
'combo-box': ComboboxElementAttributes;
|
|
188
|
-
'box-option': ComboboxOptionElementAttributes;
|
|
189
|
-
'box-tag': ComboboxTagElementAttributes;
|
|
190
|
-
}
|
|
222
|
+
interface ComboboxOptionHTMLAttributes<T> extends ComboboxBaseHTMLAttributes<T>, ComboboxOptionJsxAttributes {
|
|
223
|
+
class?: string | undefined;
|
|
191
224
|
}
|
|
192
|
-
|
|
193
|
-
|
|
225
|
+
interface ComboboxTagHTMLAttributes<T> extends ComboboxBaseHTMLAttributes<T> {
|
|
226
|
+
class?: string | undefined;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* @types/react 18 builds React.JSX.IntrinsicElements on top of the global JSX namespace, so
|
|
230
|
+
* its entries must stay assignable to the framework-agnostic global ones (catch-all `on*`,
|
|
231
|
+
* native event types): with React 18 types the global entries are kept as they are.
|
|
232
|
+
* @types/react 19 has no global JSX namespace: React.JSX gets React-typed props.
|
|
233
|
+
* (React 18 types declare the HTML elements in the global namespace, React 19 types don't.)
|
|
234
|
+
*/
|
|
235
|
+
type ComboboxIntrinsicElement<Global, Typed> = globalThis.JSX.IntrinsicElements extends {
|
|
236
|
+
div: unknown;
|
|
237
|
+
} ? Global : Typed;
|
|
194
238
|
namespace JSX {
|
|
195
239
|
interface IntrinsicElements {
|
|
196
|
-
'combo-box': ComboboxElementAttributes
|
|
197
|
-
'box-option': ComboboxOptionElementAttributes
|
|
198
|
-
'box-tag': ComboboxTagElementAttributes
|
|
240
|
+
'combo-box': ComboboxIntrinsicElement<ComboboxElementAttributes, import('react').ClassAttributes<HTMLComboboxElement> & ComboboxHTMLAttributes<HTMLComboboxElement>>;
|
|
241
|
+
'box-option': ComboboxIntrinsicElement<ComboboxOptionElementAttributes, import('react').ClassAttributes<HTMLComboboxOptionElement> & ComboboxOptionHTMLAttributes<HTMLComboboxOptionElement>>;
|
|
242
|
+
'box-tag': ComboboxIntrinsicElement<ComboboxTagElementAttributes, import('react').ClassAttributes<HTMLComboboxTagElement> & ComboboxTagHTMLAttributes<HTMLComboboxTagElement>>;
|
|
199
243
|
}
|
|
200
244
|
}
|
|
201
245
|
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "html-combobox-element",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "The combo-box web-component & customizable select polyfill",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/nihil-pro/html-combobox-element.git"
|
|
9
|
+
},
|
|
6
10
|
"scripts": {
|
|
7
11
|
"prepare": "husky",
|
|
8
12
|
"clean": "rm -rf dist",
|
|
@@ -11,7 +15,8 @@
|
|
|
11
15
|
"postbuild": "node scripts/fix-dual-package.mjs",
|
|
12
16
|
"check-types": "tsc --noEmit",
|
|
13
17
|
"test": "playwright test",
|
|
14
|
-
"test:ui": "playwright test --ui"
|
|
18
|
+
"test:ui": "playwright test --ui",
|
|
19
|
+
"test:types": "playwright test -c playwright.types.config.ts"
|
|
15
20
|
},
|
|
16
21
|
"keywords": [
|
|
17
22
|
"combo-box",
|
|
@@ -26,6 +31,7 @@
|
|
|
26
31
|
"@playwright/test": "^1.65.0",
|
|
27
32
|
"@types/node": "22.8.6",
|
|
28
33
|
"@types/react": "^19.2.14",
|
|
34
|
+
"@types/react-dom": "^19.2.3",
|
|
29
35
|
"c8": "10.1.2",
|
|
30
36
|
"esbuild": "0.25.5",
|
|
31
37
|
"husky": "9.1.5",
|
|
@@ -33,12 +39,37 @@
|
|
|
33
39
|
"npm-run-all": "^4.1.5",
|
|
34
40
|
"preact": "^10.28.4",
|
|
35
41
|
"react": "^19.2.4",
|
|
42
|
+
"react-dom": "^19.2.4",
|
|
36
43
|
"solid-js": "^1.9.11",
|
|
37
44
|
"tsx": "^4.19.2",
|
|
38
45
|
"typescript": "5.9.3",
|
|
39
46
|
"vue": "^3.5.28",
|
|
40
47
|
"xml-splitter": "1.2.1"
|
|
41
48
|
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"@types/react": "*",
|
|
51
|
+
"react": "*",
|
|
52
|
+
"preact": "*",
|
|
53
|
+
"solid-js": "*",
|
|
54
|
+
"vue": "*"
|
|
55
|
+
},
|
|
56
|
+
"peerDependenciesMeta": {
|
|
57
|
+
"@types/react": {
|
|
58
|
+
"optional": true
|
|
59
|
+
},
|
|
60
|
+
"react": {
|
|
61
|
+
"optional": true
|
|
62
|
+
},
|
|
63
|
+
"preact": {
|
|
64
|
+
"optional": true
|
|
65
|
+
},
|
|
66
|
+
"solid-js": {
|
|
67
|
+
"optional": true
|
|
68
|
+
},
|
|
69
|
+
"vue": {
|
|
70
|
+
"optional": true
|
|
71
|
+
}
|
|
72
|
+
},
|
|
42
73
|
"sideEffect": false,
|
|
43
74
|
"files": [
|
|
44
75
|
"dist",
|