kr-elements 0.0.1-alpha.6 → 0.0.1-alpha.8
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.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/// <reference types="combobox.js" />
|
|
1
|
+
/// <reference types="src/combobox/combobox.js" />
|
|
2
2
|
export * from './HTML.combobox.element.js';
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kr-elements",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.8",
|
|
4
4
|
"description": "Custom elements",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"prepare": "husky",
|
|
8
8
|
"clean": "rm -rf dist",
|
|
9
|
-
"build:combobox": "tsc -b configs/combobox.tsconfig.cjs.json configs/combobox.tsconfig.esm.json configs/combobox.tsconfig.types.json",
|
|
9
|
+
"build:combobox": "tsc -b configs/combobox.tsconfig.cjs.json configs/combobox.tsconfig.esm.json configs/combobox.tsconfig.types.json && cp src/combobox/combobox.d.ts dist/types/combobox/combobox.d.ts",
|
|
10
10
|
"generate": "node --import tsx ./scripts/genPackageFiles.ts",
|
|
11
11
|
"build": "npm-run-all clean build:combobox generate",
|
|
12
12
|
"check-types": "tsc --noEmit"
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@espcom/eslint-config": "latest",
|
|
22
22
|
"@types/node": "22.8.6",
|
|
23
|
+
"@types/react": "^19.2.14",
|
|
23
24
|
"c8": "10.1.2",
|
|
24
25
|
"esbuild": "0.25.5",
|
|
25
26
|
"husky": "9.1.5",
|
|
@@ -36,17 +37,17 @@
|
|
|
36
37
|
"sideEffect": false,
|
|
37
38
|
"files": [
|
|
38
39
|
"dist",
|
|
39
|
-
"combobox.d.ts"
|
|
40
|
+
"src/combobox/combobox.d.ts"
|
|
40
41
|
],
|
|
41
42
|
"exports": {
|
|
42
43
|
"./combobox": {
|
|
43
|
-
"types": "./combobox.d.ts",
|
|
44
|
+
"types": "./dist/types/combobox/combobox.d.ts",
|
|
44
45
|
"require": "./dist/cjs/combobox/index.js",
|
|
45
46
|
"import": "./dist/esm/combobox/index.js"
|
|
46
47
|
}
|
|
47
48
|
},
|
|
48
49
|
"main": "dist/cjs/combobox/index.js",
|
|
49
50
|
"module": "dist/esm/combobox/index.js",
|
|
50
|
-
"types": "combobox.d.ts",
|
|
51
|
+
"types": "dist/types/combobox/index.d.ts",
|
|
51
52
|
"combobox": "dist/cjs/combobox/index.js"
|
|
52
53
|
}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
interface HTMLComboboxTagElement extends HTMLElement {}
|
|
5
|
+
|
|
6
|
+
interface HTMLComboboxOptionElement extends HTMLOptionElement {
|
|
7
|
+
value: string
|
|
8
|
+
label: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface HTMLComboboxElement extends HTMLSelectElement {
|
|
12
|
+
/** The value of internal input
|
|
13
|
+
*
|
|
14
|
+
* Internal input is visible when either "searchable" or "filterable" attribute is presented */
|
|
15
|
+
query: string;
|
|
16
|
+
|
|
17
|
+
/** List of selected options value attribute */
|
|
18
|
+
valueAsArray: string[];
|
|
19
|
+
|
|
20
|
+
/** The placeholder of internal input
|
|
21
|
+
*
|
|
22
|
+
* Internal input is visible when either "searchable" or "filterable" attribute is presented
|
|
23
|
+
*
|
|
24
|
+
* When <combo-box> is empty, this value is also shown as <combo-box> placeholder itself
|
|
25
|
+
* */
|
|
26
|
+
placeholder: string;
|
|
27
|
+
|
|
28
|
+
/** When is true, the clear-all-button is shown in the <combo-box> itself,
|
|
29
|
+
* and the clear-button is shown for each selected tag.
|
|
30
|
+
*
|
|
31
|
+
* If multiple attribute is set to "true", this is also enabled.
|
|
32
|
+
*
|
|
33
|
+
* If multiple attribute is set to "false", i.e. the <combo-box> is used as a <select>,
|
|
34
|
+
* then setting this attribute to "true" will make the clear-button of selected tag visible
|
|
35
|
+
* */
|
|
36
|
+
clearable?: boolean;
|
|
37
|
+
|
|
38
|
+
/** When is true, the internal input is shown.
|
|
39
|
+
*
|
|
40
|
+
* When user type something, available options are not filtered by this query.
|
|
41
|
+
* You have to set an "input" listener to the <combo-box> and filter options by yourself
|
|
42
|
+
*
|
|
43
|
+
* Setting both "searchable" and "filterable" make no sense, the "searchable" will have priority
|
|
44
|
+
* */
|
|
45
|
+
searchable?: boolean;
|
|
46
|
+
|
|
47
|
+
/** When is true, the internal input is shown.
|
|
48
|
+
*
|
|
49
|
+
* When user type something, available options are filtered by this query.
|
|
50
|
+
*
|
|
51
|
+
* Setting both "filterable" and "searchable" make no sense, the "searchable" will have priority
|
|
52
|
+
* */
|
|
53
|
+
filterable?: boolean;
|
|
54
|
+
|
|
55
|
+
selectedOptions: NodeListOf<HTMLComboboxOptionElement>;
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
// For standard events - let TypeScript infer correctly
|
|
59
|
+
addEventListener<K extends keyof HTMLElementEventMap>(
|
|
60
|
+
type: K,
|
|
61
|
+
listener: (this: HTMLComboboxElement, ev: HTMLElementEventMap[K]) => any,
|
|
62
|
+
options?: boolean | AddEventListenerOptions
|
|
63
|
+
): void;
|
|
64
|
+
|
|
65
|
+
// For your custom events
|
|
66
|
+
addEventListener<K extends keyof ComboboxEventMap>(
|
|
67
|
+
type: K,
|
|
68
|
+
listener: (this: HTMLComboboxElement, ev: ComboboxEventMap[K]) => any,
|
|
69
|
+
options?: boolean | AddEventListenerOptions
|
|
70
|
+
): void;
|
|
71
|
+
|
|
72
|
+
// Fallback
|
|
73
|
+
addEventListener(
|
|
74
|
+
type: string,
|
|
75
|
+
listener: EventListenerOrEventListenerObject,
|
|
76
|
+
options?: boolean | AddEventListenerOptions
|
|
77
|
+
): void;
|
|
78
|
+
|
|
79
|
+
// Similar for removeEventListener
|
|
80
|
+
removeEventListener<K extends keyof HTMLElementEventMap>(
|
|
81
|
+
type: K,
|
|
82
|
+
listener: (this: HTMLComboboxElement, ev: HTMLElementEventMap[K]) => any,
|
|
83
|
+
options?: boolean | EventListenerOptions
|
|
84
|
+
): void;
|
|
85
|
+
|
|
86
|
+
removeEventListener<K extends keyof ComboboxEventMap>(
|
|
87
|
+
type: K,
|
|
88
|
+
listener: (this: HTMLComboboxElement, ev: ComboboxEventMap[K]) => any,
|
|
89
|
+
options?: boolean | EventListenerOptions
|
|
90
|
+
): void;
|
|
91
|
+
|
|
92
|
+
removeEventListener(
|
|
93
|
+
type: string,
|
|
94
|
+
listener: EventListenerOrEventListenerObject,
|
|
95
|
+
options?: boolean | EventListenerOptions
|
|
96
|
+
): void;
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
onchange: ((this: HTMLComboboxElement, ev: ComboboxEvent) => any) | null;
|
|
100
|
+
oninput: ((this: HTMLComboboxElement, ev: ComboboxInputEvent) => any) | null;
|
|
101
|
+
oninvalid: ((this: HTMLComboboxElement, ev: ComboboxEvent) => any) | null;
|
|
102
|
+
// onselect: ((this: HTMLComboboxElement, ev: Event) => any) | null;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
interface ComboboxEvent extends Event {
|
|
106
|
+
readonly target: HTMLComboboxElement;
|
|
107
|
+
readonly currentTarget: HTMLComboboxElement;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
interface ComboboxInputEvent extends InputEvent {
|
|
111
|
+
readonly target: HTMLComboboxElement;
|
|
112
|
+
readonly currentTarget: HTMLComboboxElement;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
interface ComboboxFocusEvent extends FocusEvent {
|
|
116
|
+
readonly target: HTMLComboboxElement;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
interface ComboboxEventMap extends HTMLElementEventMap {
|
|
120
|
+
"change": ComboboxEvent;
|
|
121
|
+
"blur": ComboboxFocusEvent;
|
|
122
|
+
"focus": ComboboxFocusEvent;
|
|
123
|
+
"focusin": ComboboxFocusEvent;
|
|
124
|
+
"focusout": ComboboxFocusEvent;
|
|
125
|
+
"input": ComboboxInputEvent;
|
|
126
|
+
"invalid": ComboboxEvent;
|
|
127
|
+
// "select": ComboboxEvent;
|
|
128
|
+
"selectionchange": ComboboxEvent;
|
|
129
|
+
"selectstart": ComboboxEvent;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Add to tag name map
|
|
133
|
+
declare global {
|
|
134
|
+
interface HTMLElementTagNameMap {
|
|
135
|
+
'combo-box': HTMLComboboxElement;
|
|
136
|
+
'box-option': HTMLComboboxOptionElement;
|
|
137
|
+
'box-tag': HTMLComboboxTagElement;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
declare namespace JSX {
|
|
142
|
+
interface IntrinsicElements {
|
|
143
|
+
'combo-box': React.DetailedHTMLProps<React.HTMLAttributes<HTMLComboboxElement>, HTMLComboboxElement> & {
|
|
144
|
+
/** The value of internal input
|
|
145
|
+
*
|
|
146
|
+
* Internal input is visible when either "searchable" or "filterable" attribute is presented */
|
|
147
|
+
value?: string;
|
|
148
|
+
|
|
149
|
+
/** The value of internal input
|
|
150
|
+
*
|
|
151
|
+
* Internal input is visible when either "searchable" or "filterable" attribute is presented */
|
|
152
|
+
query?: string;
|
|
153
|
+
|
|
154
|
+
/** When is true, the internal input is shown.
|
|
155
|
+
*
|
|
156
|
+
* When user type something, available options are filtered by this query.
|
|
157
|
+
*
|
|
158
|
+
* Setting both "filterable" and "searchable" make no sense, the "searchable" will have priority
|
|
159
|
+
* */
|
|
160
|
+
filterable?: boolean;
|
|
161
|
+
|
|
162
|
+
/** When is true, the internal input is shown.
|
|
163
|
+
*
|
|
164
|
+
* When user type something, available options are not filtered by this query.
|
|
165
|
+
* You have to set an "input" listener to the <combo-box> and filter options by yourself
|
|
166
|
+
*
|
|
167
|
+
* Setting both "searchable" and "filterable" make no sense, the "searchable" will have priority
|
|
168
|
+
* */
|
|
169
|
+
searchable?: boolean;
|
|
170
|
+
|
|
171
|
+
/** When is true, the clear-all-button is shown in the <combo-box> itself,
|
|
172
|
+
* and the clear-button is shown for each selected tag.
|
|
173
|
+
*
|
|
174
|
+
* If multiple attribute is set to "true", this is also enabled.
|
|
175
|
+
*
|
|
176
|
+
* If multiple attribute is set to "false", i.e. the <combo-box> is used as a <select>,
|
|
177
|
+
* then setting this attribute to "true" will make the clear-button of selected tag visible
|
|
178
|
+
* */
|
|
179
|
+
clearable?: boolean;
|
|
180
|
+
|
|
181
|
+
/** The placeholder of internal input
|
|
182
|
+
*
|
|
183
|
+
* Internal input is visible when either "searchable" or "filterable" attribute is presented
|
|
184
|
+
*
|
|
185
|
+
* When <combo-box> is empty, this value is also shown as <combo-box> placeholder itself
|
|
186
|
+
* */
|
|
187
|
+
placeholder?: string;
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
multiple?: boolean
|
|
191
|
+
|
|
192
|
+
// Events
|
|
193
|
+
onChange?: (event: React.SyntheticEvent<HTMLComboboxElement>) => void;
|
|
194
|
+
onInput?: (event: React.FormEvent<HTMLComboboxElement>) => void;
|
|
195
|
+
onInvalid?: (event: React.FormEvent<HTMLComboboxElement>) => void;
|
|
196
|
+
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
}
|