kr-elements 0.0.1-alpha.11 → 0.0.1-alpha.12

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,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toBoolean = void 0;
3
+ exports.toBoolean = toBoolean;
4
4
  function toBoolean(value) {
5
5
  if (value == null || value === 'false' || value === false)
6
6
  value = false;
@@ -8,4 +8,3 @@ function toBoolean(value) {
8
8
  value = true;
9
9
  return Boolean(value);
10
10
  }
11
- exports.toBoolean = toBoolean;
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ var _a;
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.HTMLComboboxElement = void 0;
4
5
  const Combobox_markup_js_1 = require("./Combobox.markup.js");
@@ -22,14 +23,14 @@ class HTMLComboboxElement extends HTMLElement {
22
23
  this.shadowRoot = this.attachShadow({ mode: 'closed', delegatesFocus: true });
23
24
  this.#markup = new Combobox_markup_js_1.ComboboxMarkup(this.shadowRoot, this.internals);
24
25
  this.shadowRoot.innerHTML = Combobox_markup_js_1.ComboboxMarkup.template;
25
- this.shadowRoot.adoptedStyleSheets = HTMLComboboxElement.styleSheet;
26
+ this.shadowRoot.adoptedStyleSheets = _a.styleSheet;
26
27
  this.#observer = new MutationObserver(this.#onOptionsChanges);
27
28
  }
28
29
  connectedCallback() {
29
30
  this.#markup.connect();
30
31
  this.#initialAttributesSynchronization();
31
32
  this.#onOptionsChanges([{ addedNodes: Array.from(this.children) }]);
32
- this.#observer.observe(this, HTMLComboboxElement.observerOptions);
33
+ this.#observer.observe(this, _a.observerOptions);
33
34
  this.#markup.clearAllButton.addEventListener('click', this.#onClickClearAllButton);
34
35
  this.#markup.searchInput.addEventListener('input', this.#onInput);
35
36
  }
@@ -155,22 +156,22 @@ class HTMLComboboxElement extends HTMLElement {
155
156
  }
156
157
  }
157
158
  setAttribute(name, value) {
158
- if (HTMLComboboxElement.booleanAttributes.has(name)) {
159
+ if (_a.booleanAttributes.has(name)) {
159
160
  Reflect.set(this, name, (0, Boolean_attribute_value_normalizer_js_1.toBoolean)(value));
160
161
  return;
161
162
  }
162
- if (HTMLComboboxElement.stringAttributes.has(name)) {
163
+ if (_a.stringAttributes.has(name)) {
163
164
  Reflect.set(this, name, value);
164
165
  return;
165
166
  }
166
167
  super.setAttribute(name, value);
167
168
  }
168
169
  removeAttribute(name) {
169
- if (HTMLComboboxElement.booleanAttributes.has(name)) {
170
+ if (_a.booleanAttributes.has(name)) {
170
171
  Reflect.set(this, name, false);
171
172
  return;
172
173
  }
173
- if (HTMLComboboxElement.stringAttributes.has(name)) {
174
+ if (_a.stringAttributes.has(name)) {
174
175
  return;
175
176
  }
176
177
  super.removeAttribute(name);
@@ -276,11 +277,11 @@ class HTMLComboboxElement extends HTMLElement {
276
277
  }
277
278
  }
278
279
  #initialAttributesSynchronization() {
279
- for (const key of HTMLComboboxElement.booleanAttributes) {
280
+ for (const key of _a.booleanAttributes) {
280
281
  const value = (0, Boolean_attribute_value_normalizer_js_1.toBoolean)(this.getAttribute(key));
281
282
  Reflect.set(this, key, value);
282
283
  }
283
- for (const key of HTMLComboboxElement.stringAttributes) {
284
+ for (const key of _a.stringAttributes) {
284
285
  if (this.hasAttribute(key)) {
285
286
  Reflect.set(this, key, this.getAttribute(key));
286
287
  }
@@ -290,17 +291,17 @@ class HTMLComboboxElement extends HTMLElement {
290
291
  }
291
292
  static loadCssFromDocumentStyleSheets() {
292
293
  if (document.readyState === 'complete') {
293
- HTMLComboboxElement.#loadDocumentStyleSheets();
294
+ _a.#loadDocumentStyleSheets();
294
295
  }
295
296
  if (document.readyState === 'loading') {
296
- document.addEventListener('DOMContentLoaded', HTMLComboboxElement.#loadDocumentStyleSheets);
297
+ document.addEventListener('DOMContentLoaded', _a.#loadDocumentStyleSheets);
297
298
  }
298
299
  if (document.readyState === 'interactive') {
299
- queueMicrotask(HTMLComboboxElement.#loadDocumentStyleSheets);
300
+ queueMicrotask(_a.#loadDocumentStyleSheets);
300
301
  }
301
302
  }
302
303
  static #loadDocumentStyleSheets() {
303
- const [innerSheet] = HTMLComboboxElement.styleSheet;
304
+ const [innerSheet] = _a.styleSheet;
304
305
  for (const outerSheet of document.styleSheets) {
305
306
  for (const rule of outerSheet.cssRules) {
306
307
  innerSheet.insertRule(rule.cssText, innerSheet.cssRules.length);
@@ -309,6 +310,7 @@ class HTMLComboboxElement extends HTMLElement {
309
310
  }
310
311
  }
311
312
  exports.HTMLComboboxElement = HTMLComboboxElement;
313
+ _a = HTMLComboboxElement;
312
314
  document.addEventListener('keypress', (event) => {
313
315
  if (document.activeElement instanceof HTMLComboboxElement) {
314
316
  if (document.activeElement.shadowRoot.activeElement instanceof HTML_combobox_option_element_js_1.HTMLComboboxOptionElement) {
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ var _a;
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.HTMLComboboxOptionElement = void 0;
4
5
  const Boolean_attribute_value_normalizer_js_1 = require("./Boolean.attribute.value.normalizer.js");
@@ -35,11 +36,11 @@ class HTMLComboboxOptionElement extends HTMLElement {
35
36
  super.toggleAttribute('selected', (0, Boolean_attribute_value_normalizer_js_1.toBoolean)(value));
36
37
  }
37
38
  #initialAttributesSynchronization() {
38
- for (const key of HTMLComboboxOptionElement.booleanAttributes) {
39
+ for (const key of _a.booleanAttributes) {
39
40
  const value = (0, Boolean_attribute_value_normalizer_js_1.toBoolean)(this.getAttribute(key));
40
41
  Reflect.set(this, key, value);
41
42
  }
42
- for (const key of HTMLComboboxOptionElement.stringAttributes) {
43
+ for (const key of _a.stringAttributes) {
43
44
  Reflect.set(this, key, this.getAttribute(key));
44
45
  }
45
46
  }
@@ -68,28 +69,29 @@ class HTMLComboboxOptionElement extends HTMLElement {
68
69
  throw new TypeError('Invalid value');
69
70
  }
70
71
  setAttribute(name, value) {
71
- if (HTMLComboboxOptionElement.booleanAttributes.has(name)) {
72
+ if (_a.booleanAttributes.has(name)) {
72
73
  Reflect.set(this, name, (0, Boolean_attribute_value_normalizer_js_1.toBoolean)(value));
73
74
  return;
74
75
  }
75
- if (HTMLComboboxOptionElement.stringAttributes.has(name)) {
76
+ if (_a.stringAttributes.has(name)) {
76
77
  Reflect.set(this, name, value);
77
78
  return;
78
79
  }
79
80
  super.setAttribute(name, value);
80
81
  }
81
82
  removeAttribute(name) {
82
- if (HTMLComboboxOptionElement.stringAttributes.has(name)) {
83
+ if (_a.stringAttributes.has(name)) {
83
84
  Reflect.set(this, name, false);
84
85
  return;
85
86
  }
86
- if (HTMLComboboxOptionElement.stringAttributes.has(name)) {
87
+ if (_a.stringAttributes.has(name)) {
87
88
  return;
88
89
  }
89
90
  super.removeAttribute(name);
90
91
  }
91
92
  }
92
93
  exports.HTMLComboboxOptionElement = HTMLComboboxOptionElement;
94
+ _a = HTMLComboboxOptionElement;
93
95
  if (!window.customElements.get('box-option')) {
94
96
  window.customElements.define('box-option', HTMLComboboxOptionElement);
95
97
  }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./combobox/index.js"), exports);
@@ -0,0 +1 @@
1
+ {"root":["../../src/index.ts","../../src/types.d.ts","../../src/combobox/boolean.attribute.value.normalizer.ts","../../src/combobox/combobox.markup.ts","../../src/combobox/html.combobox.element.ts","../../src/combobox/html.combobox.option.element.ts","../../src/combobox/html.combobox.tag.element.ts","../../src/combobox/index.ts"],"version":"5.9.3"}
@@ -0,0 +1 @@
1
+ export * from './combobox/index.js';
@@ -0,0 +1 @@
1
+ {"root":["../../src/index.ts","../../src/types.d.ts","../../src/combobox/boolean.attribute.value.normalizer.ts","../../src/combobox/combobox.markup.ts","../../src/combobox/html.combobox.element.ts","../../src/combobox/html.combobox.option.element.ts","../../src/combobox/html.combobox.tag.element.ts","../../src/combobox/index.ts"],"version":"5.9.3"}
@@ -1 +1,2 @@
1
1
  export declare function toBoolean(value: any): boolean;
2
+ //# sourceMappingURL=Boolean.attribute.value.normalizer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Boolean.attribute.value.normalizer.d.ts","sourceRoot":"","sources":["../../../src/combobox/Boolean.attribute.value.normalizer.ts"],"names":[],"mappings":"AACA,wBAAgB,SAAS,CAAC,KAAK,EAAE,GAAG,WAInC"}
@@ -24,3 +24,4 @@ export declare class ComboboxMarkup {
24
24
  get selectedOptions(): NodeListOf<HTMLComboboxOptionElement>;
25
25
  static get template(): string;
26
26
  }
27
+ //# sourceMappingURL=Combobox.markup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Combobox.markup.d.ts","sourceRoot":"","sources":["../../../src/combobox/Combobox.markup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAE9E,qBAAa,cAAc;;IAGzB,aAAa,EAAE,cAAc,GAAG,IAAI,CAAQ;IAC5C,gBAAgB,EAAE,cAAc,GAAG,IAAI,CAAQ;IAC/C,cAAc,EAAE,iBAAiB,GAAG,IAAI,CAAQ;IAChD,QAAQ,EAAE,cAAc,GAAG,IAAI,CAAQ;IACvC,WAAW,EAAE,cAAc,GAAG,IAAI,CAAQ;IAC1C,WAAW,EAAE,gBAAgB,GAAG,IAAI,CAAQ;IAE5C,SAAS,UAAS;gBAEN,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,gBAAgB;IAU/D,OAAO;IAcP,IAAI,CAAC,KAAK,EAAE,MAAM;IAiBlB,UAAU;IASV,YAAY,aAIX;IAED,mBAAmB,CAAC,IAAI,EAAE,OAAO;IAmBjC,YAAY,aAUX;IAED,YAAY,GAAI,OAAO,KAAK,UAU3B;IAED,kBAAkB,CAAC,MAAM,EAAE,yBAAyB;IAqBpD,aAAa,CAAC,KAAK,EAAE,MAAM;IAI3B,gBAAgB,CAAC,KAAK,EAAE,MAAM;IAI9B,IAAI,WAAW,2BAQd;IAGD,IAAI,eAAe,0CAGlB;IAED,MAAM,KAAK,QAAQ,WAmLlB;CACF"}
@@ -47,3 +47,4 @@ export declare class HTMLComboboxElement extends HTMLElement {
47
47
  static staticLoadCssByUrls(urls: string[]): void;
48
48
  static loadCssFromDocumentStyleSheets(): void;
49
49
  }
50
+ //# sourceMappingURL=HTML.combobox.element.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HTML.combobox.element.d.ts","sourceRoot":"","sources":["../../../src/combobox/HTML.combobox.element.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAG9E,qBAAa,mBAAoB,SAAQ,WAAW;;IAClD,MAAM,CAAC,gBAAgB,cAAgD;IACvE,MAAM,CAAC,iBAAiB,cAA4F;IACpH,MAAM,CAAC,eAAe;;;;MAA0D;IAChF,MAAM,CAAC,UAAU,kBAAuB;IACxC,MAAM,CAAC,cAAc,UAAQ;IAE7B,SAAS,EAAE,gBAAgB,CAAC;IAC5B,UAAU,EAAE,UAAU,CAAC;;IAkBvB,iBAAiB;IASjB,oBAAoB;IAKpB,iBAAiB;IAQjB,oBAAoB,CAAC,UAAU,EAAE,OAAO;IAMxC,IAAI,YAAY,aAEf;IACD,IAAI,eAAe,0CAElB;IACD,IAAI,QAAQ,kBAEX;IACD,IAAI,YAAY,YAEf;IAGD,IAAI,KAAK,IAGQ,MAAM,CADtB;IACD,IAAI,KAAK,CAAC,KAAK,EAAE,MAAM,EAgCtB;IAED,IAAI,KAAK,IAGQ,MAAM,CADtB;IACD,IAAI,KAAK,CAAC,KAAK,EAAE,MAAM,EAMtB;IAED,IAAI,SAAS,YAEZ;IACD,IAAI,SAAS,CAAC,KAAK,SAAA,EAElB;IAED,IAAI,QAAQ,YAEX;IACD,IAAI,QAAQ,CAAC,KAAK,SAAA,EAEjB;IAED,IAAI,UAAU,YAEb;IACD,IAAI,UAAU,CAAC,KAAK,SAAA,EAEnB;IAED,IAAI,UAAU,YAEb;IACD,IAAI,UAAU,CAAC,KAAK,SAAA,EAEnB;IAED,IAAI,QAAQ,YAEX;IACD,IAAI,QAAQ,CAAC,KAAK,SAAA,EAGjB;IAED,IAAI,QAAQ,YAEX;IACD,IAAI,QAAQ,CAAC,KAAK,SAAA,EAGjB;IAED,IAAI,WAAW,WAEd;IACD,IAAI,WAAW,CAAC,KAAK,QAAA,EAMpB;IAID,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG;IAYrC,eAAe,CAAC,IAAI,EAAE,MAAM;IAW5B,cAAc;IAId,aAAa;IAIb,iBAAiB,CAAC,OAAO,EAAE,MAAM;IAgHjC,MAAM,CAAC,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE;IAIzC,MAAM,CAAC,8BAA8B;CAoBtC"}
@@ -12,3 +12,4 @@ export declare class HTMLComboboxOptionElement extends HTMLElement {
12
12
  setAttribute(name: string, value: string): void;
13
13
  removeAttribute(name: string): void;
14
14
  }
15
+ //# sourceMappingURL=HTML.combobox.option.element.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HTML.combobox.option.element.d.ts","sourceRoot":"","sources":["../../../src/combobox/HTML.combobox.option.element.ts"],"names":[],"mappings":"AAEA,qBAAa,yBAA0B,SAAQ,WAAW;;IACxD,MAAM,CAAC,iBAAiB,cAAyB;IACjD,MAAM,CAAC,gBAAgB,cAA+B;IAEtD,iBAAiB;IAUjB,IAAI,KAAK,WAER;IACD,IAAI,KAAK,CAAC,KAAK,QAAA,EAGd;IAED,IAAI,KAAK,WAER;IACD,IAAI,KAAK,CAAC,KAAK,QAAA,EAGd;IAED,IAAI,QAAQ,YAEX;IACD,IAAI,QAAQ,CAAC,KAAK,SAAA,EAEjB;IAoCD,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAYxC,eAAe,CAAC,IAAI,EAAE,MAAM;CAU7B"}
@@ -1,3 +1,4 @@
1
1
  export declare class HTMLComboboxTagElement extends HTMLElement {
2
2
  connectedCallback(): void;
3
3
  }
4
+ //# sourceMappingURL=HTML.combobox.tag.element.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HTML.combobox.tag.element.d.ts","sourceRoot":"","sources":["../../../src/combobox/HTML.combobox.tag.element.ts"],"names":[],"mappings":"AAAA,qBAAa,sBAAuB,SAAQ,WAAW;IACrD,iBAAiB;CAalB"}
@@ -1,61 +1,2 @@
1
- interface HTMLComboboxTagElement extends HTMLElement {
2
- }
3
- interface HTMLComboboxOptionElement extends HTMLOptionElement {
4
- value: string;
5
- label: string;
6
- }
7
- interface HTMLComboboxElement extends HTMLSelectElement {
8
- query: string;
9
- valueAsArray: string[];
10
- placeholder: string;
11
- clearable?: boolean;
12
- searchable?: boolean;
13
- filterable?: boolean;
14
- selectedOptions: HTMLCollectionOf<HTMLComboboxOptionElement>;
15
- addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLComboboxElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
16
- addEventListener<K extends keyof ComboboxEventMap>(type: K, listener: (this: HTMLComboboxElement, ev: ComboboxEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
17
- addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
18
- removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLComboboxElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
19
- removeEventListener<K extends keyof ComboboxEventMap>(type: K, listener: (this: HTMLComboboxElement, ev: ComboboxEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
20
- removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
21
- onchange: ((this: HTMLComboboxElement, ev: ComboboxEvent) => any) | null;
22
- oninput: ((this: HTMLComboboxElement, ev: ComboboxInputEvent) => any) | null;
23
- oninvalid: ((this: HTMLComboboxElement, ev: ComboboxEvent) => any) | null;
24
- }
25
- interface ComboboxEvent extends Event {
26
- readonly target: HTMLComboboxElement;
27
- readonly currentTarget: HTMLComboboxElement;
28
- }
29
- interface ComboboxInputEvent extends InputEvent {
30
- readonly target: HTMLComboboxElement;
31
- readonly currentTarget: HTMLComboboxElement;
32
- }
33
- interface ComboboxFocusEvent extends FocusEvent {
34
- readonly target: HTMLComboboxElement;
35
- }
36
- interface ComboboxEventMap extends HTMLElementEventMap {
37
- "change": ComboboxEvent;
38
- "blur": ComboboxFocusEvent;
39
- "focus": ComboboxFocusEvent;
40
- "focusin": ComboboxFocusEvent;
41
- "focusout": ComboboxFocusEvent;
42
- "input": ComboboxInputEvent;
43
- "invalid": ComboboxEvent;
44
- "selectionchange": ComboboxEvent;
45
- "selectstart": ComboboxEvent;
46
- }
47
- declare global {
48
- interface HTMLElementTagNameMap {
49
- 'combo-box': HTMLComboboxElement;
50
- 'box-option': HTMLComboboxOptionElement;
51
- 'box-tag': HTMLComboboxTagElement;
52
- }
53
- namespace JSX {
54
- interface IntrinsicElements {
55
- 'combo-box': HTMLComboboxElement;
56
- 'box-option': HTMLComboboxOptionElement;
57
- 'box-tag': HTMLComboboxTagElement;
58
- }
59
- }
60
- }
61
1
  export * from './HTML.combobox.element.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/combobox/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './combobox/index.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1 @@
1
+ {"root":["../../src/index.ts","../../src/types.d.ts","../../src/combobox/boolean.attribute.value.normalizer.ts","../../src/combobox/combobox.markup.ts","../../src/combobox/html.combobox.element.ts","../../src/combobox/html.combobox.option.element.ts","../../src/combobox/html.combobox.tag.element.ts","../../src/combobox/index.ts"],"version":"5.9.3"}
@@ -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
+ /** List of selected options value attribute */
10
+ valueAsArray: string[];
11
+
12
+ multiple: boolean;
13
+
14
+ /** The value of internal input
15
+ *
16
+ * Internal input is visible when either "searchable" or "filterable" attribute is presented */
17
+ query: string;
18
+
19
+ /** The placeholder of internal input
20
+ *
21
+ * Internal input is visible when either "searchable" or "filterable" attribute is presented
22
+ *
23
+ * When <combo-box> is empty, this value is also shown as <combo-box> placeholder itself
24
+ * */
25
+ placeholder: string;
26
+
27
+ /** When is true, the clear-all-button is shown in the <combo-box> itself,
28
+ * and the clear-button is shown for each selected tag.
29
+ *
30
+ * If multiple attribute is set to "true", this is also enabled.
31
+ *
32
+ * If multiple attribute is set to "false", i.e. the <combo-box> is used as a <select>,
33
+ * then setting this attribute to "true" will make the clear-button of selected tag visible
34
+ * */
35
+ clearable: boolean;
36
+
37
+ /** When is true, the internal input is shown.
38
+ *
39
+ * When user type something, available options are not filtered by this query.
40
+ * You have to set an "input" listener to the <combo-box> and filter options by yourself
41
+ *
42
+ * Setting both "searchable" and "filterable" make no sense, the "searchable" will have priority
43
+ * */
44
+ searchable: boolean;
45
+
46
+ /** When is true, the internal input is shown.
47
+ *
48
+ * When user type something, available options are filtered by this query.
49
+ *
50
+ * Setting both "filterable" and "searchable" make no sense, the "searchable" will have priority
51
+ * */
52
+ filterable: boolean;
53
+
54
+ selectedOptions: HTMLCollectionOf<HTMLComboboxOptionElement>;
55
+
56
+
57
+ // For standard events - let TypeScript infer correctly
58
+ addEventListener<K extends keyof HTMLElementEventMap>(
59
+ type: K,
60
+ listener: (this: HTMLComboboxElement, ev: HTMLElementEventMap[K]) => any,
61
+ options?: boolean | AddEventListenerOptions
62
+ ): void;
63
+
64
+ // For your custom events
65
+ addEventListener<K extends keyof ComboboxEventMap>(
66
+ type: K,
67
+ listener: (this: HTMLComboboxElement, ev: ComboboxEventMap[K]) => any,
68
+ options?: boolean | AddEventListenerOptions
69
+ ): void;
70
+
71
+ // Fallback
72
+ addEventListener(
73
+ type: string,
74
+ listener: EventListenerOrEventListenerObject,
75
+ options?: boolean | AddEventListenerOptions
76
+ ): void;
77
+
78
+ // Similar for removeEventListener
79
+ removeEventListener<K extends keyof HTMLElementEventMap>(
80
+ type: K,
81
+ listener: (this: HTMLComboboxElement, ev: HTMLElementEventMap[K]) => any,
82
+ options?: boolean | EventListenerOptions
83
+ ): void;
84
+
85
+ removeEventListener<K extends keyof ComboboxEventMap>(
86
+ type: K,
87
+ listener: (this: HTMLComboboxElement, ev: ComboboxEventMap[K]) => any,
88
+ options?: boolean | EventListenerOptions
89
+ ): void;
90
+
91
+ removeEventListener(
92
+ type: string,
93
+ listener: EventListenerOrEventListenerObject,
94
+ options?: boolean | EventListenerOptions
95
+ ): void;
96
+ }
97
+
98
+ interface ComboboxEvent extends Event {
99
+ readonly target: HTMLComboboxElement;
100
+ readonly currentTarget: HTMLComboboxElement;
101
+ }
102
+
103
+ interface ComboboxInputEvent extends InputEvent {
104
+ readonly target: HTMLComboboxElement;
105
+ readonly currentTarget: HTMLComboboxElement;
106
+ }
107
+
108
+ interface ComboboxFocusEvent extends FocusEvent {
109
+ readonly target: HTMLComboboxElement;
110
+ }
111
+
112
+ interface ComboboxEventMap extends HTMLElementEventMap {
113
+ "change": ComboboxEvent;
114
+ "blur": ComboboxFocusEvent;
115
+ "focus": ComboboxFocusEvent;
116
+ "focusin": ComboboxFocusEvent;
117
+ "focusout": ComboboxFocusEvent;
118
+ "input": ComboboxInputEvent;
119
+ "invalid": ComboboxEvent;
120
+ // "select": ComboboxEvent;
121
+ "selectionchange": ComboboxEvent;
122
+ "selectstart": ComboboxEvent;
123
+ }
124
+
125
+ interface HTMLElementTagNameMap {
126
+ 'combo-box': HTMLComboboxElement;
127
+ 'box-option': HTMLComboboxOptionElement;
128
+ 'box-tag': HTMLComboboxTagElement;
129
+ }
130
+
131
+ interface ComboboxJsxAttributes {
132
+ /** The value of the internal input.
133
+ *
134
+ * The internal input is visible when either the `searchable` or `filterable` attribute is present.
135
+ *
136
+ * Setting ""
137
+ * */
138
+ query?: string;
139
+
140
+ /** A comma-separated list of descendant `<box-option>` value attributes to be selected by default.
141
+ *
142
+ * When the `multiple` attribute is present, only the first option will be selected.
143
+ *
144
+ * Alternatively, you can set default selections by adding the `selected` attribute directly to individual `<box-option>` elements. */
145
+ value?: string;
146
+
147
+ /** This Boolean attribute indicates that multiple options can be selected.
148
+ *
149
+ * When present, users can select multiple options. When absent, only one option can be selected at a time (the `<combo-box>` behaves like a `<select>`). */
150
+ multiple?: boolean;
151
+
152
+ /** The placeholder for the internal input.
153
+ *
154
+ * The internal input is visible when either the `searchable` or `filterable` attribute is present.
155
+ *
156
+ * When the `<combo-box>` is empty, this value is also shown as the `<combo-box>` placeholder itself. */
157
+ placeholder?: string;
158
+
159
+ /** When present, the clear-all button is shown in the `<combo-box>` itself, and the clear button is shown for each selected tag.
160
+ *
161
+ * This attribute is automatically enabled when the `multiple` attribute is present.
162
+ *
163
+ * When the `multiple` attribute is absent (single-select mode), setting `clearable` makes the clear button visible on the selected tag. */
164
+ clearable?: boolean;
165
+
166
+ /** When present, the internal input is shown.
167
+ *
168
+ * As the user types, available options are **not** filtered by the query. You must attach an `input` listener to the `<combo-box>` and filter options manually.
169
+ *
170
+ * Setting both `searchable` and `filterable` is not recommended—`searchable` takes precedence. */
171
+ searchable?: boolean;
172
+
173
+ /** When present, the internal input is shown.
174
+ *
175
+ * As the user types, available options are filtered by the query automatically.
176
+ *
177
+ * Setting both `filterable` and `searchable` is not recommended—`searchable` takes precedence. */
178
+ filterable?: boolean;
179
+
180
+ /** A Boolean attribute indicating that at least one option must be selected. */
181
+ required?: boolean;
182
+ }
183
+
184
+ declare namespace React {
185
+ namespace JSX {
186
+ interface IntrinsicElements {
187
+ 'combo-box': React.DetailedHTMLProps<
188
+ Omit<React.HTMLAttributes<HTMLComboboxElement>, 'defaultValue'>,
189
+ HTMLComboboxElement
190
+ > & ComboboxJsxAttributes;
191
+
192
+ 'box-option': HTMLComboboxOptionElement;
193
+ 'box-tag': HTMLComboboxTagElement;
194
+ }
195
+ }
196
+ }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "kr-elements",
3
- "version": "0.0.1-alpha.11",
3
+ "version": "0.0.1-alpha.12",
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/tsconfig.cjs.json configs/tsconfig.esm.json configs/tsconfig.types.json && cp src/types.d.ts dist/types/types.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"
@@ -30,22 +30,14 @@
30
30
  "react": "^19.2.4",
31
31
  "solid": "^0.2.1",
32
32
  "tsx": "^4.19.2",
33
- "typescript": "latest",
33
+ "typescript": "5.9.3",
34
34
  "xml-splitter": "1.2.1"
35
35
  },
36
36
  "sideEffect": false,
37
37
  "files": [
38
38
  "dist"
39
39
  ],
40
- "exports": {
41
- "./combobox": {
42
- "types": "./dist/types/combobox/index.d.ts",
43
- "require": "./dist/cjs/combobox/index.js",
44
- "import": "./dist/esm/combobox/index.js"
45
- }
46
- },
47
- "main": "dist/cjs/combobox/index.js",
48
- "module": "dist/esm/combobox/index.js",
49
- "types": "dist/types/combobox/index.d.ts",
50
- "combobox": "dist/cjs/combobox/index.js"
40
+ "main": "dist/cjs/index.js",
41
+ "module": "dist/esm/index.js",
42
+ "types": "dist/types.d.ts"
51
43
  }