kr-elements 0.0.1-alpha.3 → 0.0.1-alpha.5

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