kr-elements 0.0.1-alpha.2 → 0.0.1-alpha.21

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.
Files changed (49) hide show
  1. package/dist/cjs/combobox/Boolean.attribute.value.normalizer.js +2 -2
  2. package/dist/cjs/combobox/Combobox.markup.js +22 -5
  3. package/dist/cjs/combobox/HTML.combobox.element.js +35 -23
  4. package/dist/cjs/combobox/HTML.combobox.option.element.js +42 -37
  5. package/dist/cjs/index.js +3 -1
  6. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -0
  7. package/dist/esm/combobox/Boolean.attribute.value.normalizer.js +1 -0
  8. package/dist/esm/combobox/Combobox.markup.js +22 -5
  9. package/dist/esm/combobox/HTML.combobox.element.js +21 -11
  10. package/dist/esm/combobox/HTML.combobox.option.element.js +34 -31
  11. package/dist/esm/index.js +3 -1
  12. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -0
  13. package/dist/types/combobox/Boolean.attribute.value.normalizer.d.ts +2 -0
  14. package/dist/types/combobox/Boolean.attribute.value.normalizer.d.ts.map +1 -0
  15. package/dist/types/combobox/Combobox.markup.d.ts +2 -0
  16. package/dist/types/combobox/Combobox.markup.d.ts.map +1 -0
  17. package/dist/types/combobox/HTML.combobox.element.d.ts +1 -0
  18. package/dist/types/combobox/HTML.combobox.element.d.ts.map +1 -0
  19. package/dist/types/combobox/HTML.combobox.option.element.d.ts +1 -0
  20. package/dist/types/combobox/HTML.combobox.option.element.d.ts.map +1 -0
  21. package/dist/types/combobox/HTML.combobox.tag.element.d.ts +1 -0
  22. package/dist/types/combobox/HTML.combobox.tag.element.d.ts.map +1 -0
  23. package/dist/types/combobox/index.d.ts +1 -0
  24. package/dist/types/combobox/index.d.ts.map +1 -0
  25. package/dist/types/index.d.ts +174 -1
  26. package/dist/types/index.d.ts.map +1 -1
  27. package/dist/types/tsconfig.types.tsbuildinfo +1 -0
  28. package/dist/types/types.d.ts +198 -0
  29. package/package.json +13 -14
  30. package/dist/cjs/Boolean.attribute.value.normalizer.js +0 -11
  31. package/dist/cjs/Combobox.markup.js +0 -315
  32. package/dist/cjs/HTML.combobox.element.js +0 -317
  33. package/dist/cjs/HTML.combobox.option.element.js +0 -95
  34. package/dist/cjs/HTML.combobox.tag.element.js +0 -22
  35. package/dist/esm/Boolean.attribute.value.normalizer.js +0 -7
  36. package/dist/esm/Combobox.markup.js +0 -311
  37. package/dist/esm/HTML.combobox.element.js +0 -313
  38. package/dist/esm/HTML.combobox.option.element.js +0 -91
  39. package/dist/esm/HTML.combobox.tag.element.js +0 -18
  40. package/dist/types/Boolean.attribute.value.normalizer.d.ts +0 -2
  41. package/dist/types/Boolean.attribute.value.normalizer.d.ts.map +0 -1
  42. package/dist/types/Combobox.markup.d.ts +0 -26
  43. package/dist/types/Combobox.markup.d.ts.map +0 -1
  44. package/dist/types/HTML.combobox.element.d.ts +0 -50
  45. package/dist/types/HTML.combobox.element.d.ts.map +0 -1
  46. package/dist/types/HTML.combobox.option.element.d.ts +0 -15
  47. package/dist/types/HTML.combobox.option.element.d.ts.map +0 -1
  48. package/dist/types/HTML.combobox.tag.element.d.ts +0 -4
  49. package/dist/types/HTML.combobox.tag.element.d.ts.map +0 -1
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toBoolean = void 0;
3
+ exports.toBoolean = toBoolean;
4
+ /** Transform invalid (nullish or stringed) values to correct boolean value */
4
5
  function toBoolean(value) {
5
6
  if (value == null || value === 'false' || value === false)
6
7
  value = false;
@@ -8,4 +9,3 @@ function toBoolean(value) {
8
9
  value = true;
9
10
  return Boolean(value);
10
11
  }
11
- exports.toBoolean = toBoolean;
@@ -11,6 +11,7 @@ class ComboboxMarkup {
11
11
  dropdown = null;
12
12
  placeholder = null;
13
13
  searchInput = null;
14
+ connected = false;
14
15
  constructor(shadowRoot, internals) {
15
16
  this.#shadowRoot = shadowRoot;
16
17
  this.#internals = internals;
@@ -21,24 +22,32 @@ class ComboboxMarkup {
21
22
  document.addEventListener('scroll', this.onPageScroll);
22
23
  }
23
24
  connect() {
25
+ const placeholder = this.#shadowRoot.host.getAttribute('placeholder') || '';
24
26
  this.tagsContainer = this.#shadowRoot.querySelector('#tags');
25
27
  this.optionsContainer = this.#shadowRoot.querySelector('[part="options"]');
26
28
  this.clearAllButton = this.#shadowRoot.querySelector('[part="clear-all-button"]');
27
29
  this.dropdown = this.#shadowRoot.querySelector('#dropdown');
28
30
  this.placeholder = this.#shadowRoot.querySelector('#placeholder');
31
+ this.placeholder.innerText = placeholder;
29
32
  this.searchInput = this.#shadowRoot.querySelector('[part="search-input"]');
33
+ this.searchInput.value = this.#shadowRoot.host.getAttribute('query');
34
+ this.searchInput.placeholder = placeholder;
35
+ this.connected = true;
30
36
  }
31
37
  sort(query) {
32
38
  const regex = new RegExp(query, 'i');
33
39
  this.optionsContainer.querySelectorAll('box-option')
34
40
  .forEach(option => {
35
41
  if (query === '') {
42
+ // option.style.order = "unset";
36
43
  option.style.display = "initial";
37
44
  }
38
45
  else if (!regex.test(option.label)) {
46
+ // option.style.order = "-1";
39
47
  option.style.display = "none";
40
48
  }
41
49
  else {
50
+ // option.style.order = "unset";
42
51
  option.style.order = "initial";
43
52
  }
44
53
  });
@@ -49,6 +58,7 @@ class ComboboxMarkup {
49
58
  this.#shadowRoot.host.removeEventListener('click', this.showDropdown);
50
59
  document.removeEventListener('click', this.hideDropdown);
51
60
  document.removeEventListener('scroll', this.onPageScroll);
61
+ this.connected = false;
52
62
  }
53
63
  onPageScroll = () => {
54
64
  if (this.dropdown.matches(':popover-open')) {
@@ -78,6 +88,7 @@ class ComboboxMarkup {
78
88
  try {
79
89
  this.setDropdownPosition(this.#shadowRoot.host.getBoundingClientRect());
80
90
  this.dropdown.style.display = 'flex';
91
+ // @ts-ignore
81
92
  this.dropdown.showPopover();
82
93
  this.#internals.ariaExpanded = "true";
83
94
  }
@@ -89,6 +100,7 @@ class ComboboxMarkup {
89
100
  if (event.composedPath().includes(this.#shadowRoot.host))
90
101
  return;
91
102
  try {
103
+ // @ts-ignore
92
104
  this.dropdown.hidePopover();
93
105
  this.dropdown.style.display = 'none';
94
106
  this.#internals.ariaExpanded = "false";
@@ -158,20 +170,23 @@ class ComboboxMarkup {
158
170
  overflow-y: scroll;
159
171
  flex-direction: column;
160
172
  border-radius: inherit;
173
+ border-color: ButtonFace;
174
+ border-width: inherit;
161
175
  }
162
176
 
163
177
  [part="options"] {
164
178
  display: flex;
165
179
  flex-direction: column;
180
+ justify-content: start;
166
181
  gap: 2px;
167
182
  padding-block: .5rem;
168
183
  border-radius: inherit;
169
184
  }
170
185
 
171
186
  [part="options"] box-option {
187
+ display: flex;
172
188
  border-radius: inherit;
173
189
  content-visibility: auto;
174
- border: 1px solid cornflowerblue;
175
190
  }
176
191
 
177
192
  [part="options"] box-option[selected] {
@@ -195,6 +210,7 @@ class ComboboxMarkup {
195
210
  }
196
211
 
197
212
  #placeholder {
213
+ text-align: left;
198
214
  overflow: hidden;
199
215
  }
200
216
 
@@ -215,7 +231,7 @@ class ComboboxMarkup {
215
231
  border-radius: inherit;
216
232
  }
217
233
 
218
- [part="tag"] {
234
+ [part="box-tag"] {
219
235
  width: 100%;
220
236
  justify-self: start;
221
237
  font-size: inherit;
@@ -229,7 +245,7 @@ class ComboboxMarkup {
229
245
  gap: 5px;
230
246
  }
231
247
 
232
- :host([multiple]) [part="tag"] {
248
+ :host([multiple]) [part="box-tag"] {
233
249
  background-color: Highlight;
234
250
  width: fit-content;
235
251
  max-width: 100%;
@@ -291,13 +307,14 @@ class ComboboxMarkup {
291
307
  }
292
308
 
293
309
  :host:has(#tags:empty) [part="clear-all-button"] {
294
- /*display: none;*/
310
+ pointer-events: none;
311
+ color: darkgrey;
295
312
  }
296
313
 
297
314
  </style>
298
315
 
299
316
  <div id="tags"></div>
300
- <div id="placeholder" ></div>
317
+ <div id="placeholder">&nbsp;</div>
301
318
  <button part="clear-all-button">✕</button>
302
319
  <div id="dropdown" popover="manual">
303
320
  <input name="search-input" part="search-input" />
@@ -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,15 @@ 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
  }
29
+ // Lifecycle callbacks
28
30
  connectedCallback() {
29
31
  this.#markup.connect();
30
32
  this.#initialAttributesSynchronization();
31
33
  this.#onOptionsChanges([{ addedNodes: Array.from(this.children) }]);
32
- this.#observer.observe(this, HTMLComboboxElement.observerOptions);
34
+ this.#observer.observe(this, _a.observerOptions);
33
35
  this.#markup.clearAllButton.addEventListener('click', this.#onClickClearAllButton);
34
36
  this.#markup.searchInput.addEventListener('input', this.#onInput);
35
37
  }
@@ -47,6 +49,8 @@ class HTMLComboboxElement extends HTMLElement {
47
49
  formDisabledCallback(isDisabled) {
48
50
  this.disabled = isDisabled;
49
51
  }
52
+ // Instance properties
53
+ // readonly
50
54
  get valueAsArray() {
51
55
  return Array.from(this.#values);
52
56
  }
@@ -59,6 +63,7 @@ class HTMLComboboxElement extends HTMLElement {
59
63
  get willValidate() {
60
64
  return this.internals.willValidate;
61
65
  }
66
+ // configurable
62
67
  get value() {
63
68
  return this.valueAsArray.join(',');
64
69
  }
@@ -96,77 +101,82 @@ class HTMLComboboxElement extends HTMLElement {
96
101
  });
97
102
  }
98
103
  get query() {
99
- return this.#markup.searchInput.value;
104
+ return this.getAttribute('query');
100
105
  }
101
106
  set query(value) {
102
107
  if (value === this.query)
103
108
  return;
104
- this.#markup.searchInput.value = value;
105
109
  super.setAttribute('query', value);
110
+ if (this.#markup.connected) {
111
+ this.#markup.searchInput.value = value;
112
+ }
106
113
  }
107
114
  get clearable() {
108
115
  return this.hasAttribute('clearable');
109
116
  }
110
117
  set clearable(value) {
111
- super.toggleAttribute('clearable', value);
118
+ super.toggleAttribute('clearable', (0, Boolean_attribute_value_normalizer_js_1.toBoolean)(value));
112
119
  }
113
120
  get multiple() {
114
121
  return this.hasAttribute('multiple');
115
122
  }
116
123
  set multiple(value) {
117
- super.toggleAttribute('multiple', value);
124
+ super.toggleAttribute('multiple', (0, Boolean_attribute_value_normalizer_js_1.toBoolean)(value));
118
125
  }
119
126
  get filterable() {
120
127
  return this.hasAttribute('filterable');
121
128
  }
122
129
  set filterable(value) {
123
- super.toggleAttribute('filterable', value);
130
+ super.toggleAttribute('filterable', (0, Boolean_attribute_value_normalizer_js_1.toBoolean)(value));
124
131
  }
125
132
  get searchable() {
126
133
  return this.hasAttribute('searchable');
127
134
  }
128
135
  set searchable(value) {
129
- super.toggleAttribute('searchable', value);
136
+ super.toggleAttribute('searchable', (0, Boolean_attribute_value_normalizer_js_1.toBoolean)(value));
130
137
  }
131
138
  get disabled() {
132
139
  return this.hasAttribute('disabled');
133
140
  }
134
141
  set disabled(value) {
135
142
  this.internals.ariaDisabled = String(value);
136
- super.toggleAttribute('disabled', value);
143
+ super.toggleAttribute('disabled', (0, Boolean_attribute_value_normalizer_js_1.toBoolean)(value));
137
144
  }
138
145
  get required() {
139
146
  return this.hasAttribute('required');
140
147
  }
141
148
  set required(value) {
142
149
  this.internals.ariaRequired = String(value);
143
- super.toggleAttribute('required', value);
150
+ super.toggleAttribute('required', (0, Boolean_attribute_value_normalizer_js_1.toBoolean)(value));
144
151
  }
145
152
  get placeholder() {
146
- return this.#markup.searchInput.placeholder;
153
+ return this.getAttribute('placeholder');
147
154
  }
148
155
  set placeholder(value) {
149
- this.#markup.placeholder.innerText = value;
150
- this.#markup.searchInput.placeholder = value;
151
156
  super.setAttribute('placeholder', value);
157
+ if (this.#markup.connected) {
158
+ this.#markup.placeholder.innerText = value;
159
+ this.#markup.searchInput.placeholder = value;
160
+ }
152
161
  }
162
+ // Instance methods
153
163
  setAttribute(name, value) {
154
- if (HTMLComboboxElement.booleanAttributes.has(name)) {
164
+ if (_a.booleanAttributes.has(name)) {
155
165
  Reflect.set(this, name, (0, Boolean_attribute_value_normalizer_js_1.toBoolean)(value));
156
166
  return;
157
167
  }
158
- if (HTMLComboboxElement.stringAttributes.has(name)) {
168
+ if (_a.stringAttributes.has(name)) {
159
169
  Reflect.set(this, name, value);
160
170
  return;
161
171
  }
162
172
  super.setAttribute(name, value);
163
173
  }
164
174
  removeAttribute(name) {
165
- if (HTMLComboboxElement.booleanAttributes.has(name)) {
175
+ if (_a.booleanAttributes.has(name)) {
166
176
  Reflect.set(this, name, false);
167
177
  return;
168
178
  }
169
- if (HTMLComboboxElement.stringAttributes.has(name)) {
179
+ if (_a.stringAttributes.has(name)) {
170
180
  return;
171
181
  }
172
182
  super.removeAttribute(name);
@@ -185,6 +195,7 @@ class HTMLComboboxElement extends HTMLElement {
185
195
  this.internals.setValidity({ customError: true }, message);
186
196
  }
187
197
  }
198
+ // Internal
188
199
  #onInput = (event) => {
189
200
  if (this.filterable) {
190
201
  if (event.target && event.target instanceof HTMLInputElement) {
@@ -272,11 +283,11 @@ class HTMLComboboxElement extends HTMLElement {
272
283
  }
273
284
  }
274
285
  #initialAttributesSynchronization() {
275
- for (const key of HTMLComboboxElement.booleanAttributes) {
286
+ for (const key of _a.booleanAttributes) {
276
287
  const value = (0, Boolean_attribute_value_normalizer_js_1.toBoolean)(this.getAttribute(key));
277
288
  Reflect.set(this, key, value);
278
289
  }
279
- for (const key of HTMLComboboxElement.stringAttributes) {
290
+ for (const key of _a.stringAttributes) {
280
291
  if (this.hasAttribute(key)) {
281
292
  Reflect.set(this, key, this.getAttribute(key));
282
293
  }
@@ -286,17 +297,17 @@ class HTMLComboboxElement extends HTMLElement {
286
297
  }
287
298
  static loadCssFromDocumentStyleSheets() {
288
299
  if (document.readyState === 'complete') {
289
- HTMLComboboxElement.#loadDocumentStyleSheets();
300
+ _a.#loadDocumentStyleSheets();
290
301
  }
291
302
  if (document.readyState === 'loading') {
292
- document.addEventListener('DOMContentLoaded', HTMLComboboxElement.#loadDocumentStyleSheets);
303
+ document.addEventListener('DOMContentLoaded', _a.#loadDocumentStyleSheets);
293
304
  }
294
305
  if (document.readyState === 'interactive') {
295
- queueMicrotask(HTMLComboboxElement.#loadDocumentStyleSheets);
306
+ queueMicrotask(_a.#loadDocumentStyleSheets);
296
307
  }
297
308
  }
298
309
  static #loadDocumentStyleSheets() {
299
- const [innerSheet] = HTMLComboboxElement.styleSheet;
310
+ const [innerSheet] = _a.styleSheet;
300
311
  for (const outerSheet of document.styleSheets) {
301
312
  for (const rule of outerSheet.cssRules) {
302
313
  innerSheet.insertRule(rule.cssText, innerSheet.cssRules.length);
@@ -305,6 +316,7 @@ class HTMLComboboxElement extends HTMLElement {
305
316
  }
306
317
  }
307
318
  exports.HTMLComboboxElement = HTMLComboboxElement;
319
+ _a = HTMLComboboxElement;
308
320
  document.addEventListener('keypress', (event) => {
309
321
  if (document.activeElement instanceof HTMLComboboxElement) {
310
322
  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");
@@ -10,23 +11,48 @@ class HTMLComboboxOptionElement extends HTMLElement {
10
11
  super.setAttribute('part', 'box-option');
11
12
  super.setAttribute('tabindex', "0");
12
13
  super.setAttribute('role', "option");
13
- if (this.children.length === 0) {
14
- this.textContent = this.label;
14
+ const value = this.value;
15
+ const label = this.label;
16
+ const hasNoMarkup = this.children.length === 0;
17
+ const text = this.textContent.trim();
18
+ const hasText = text.length > 0;
19
+ if (!value && !label) {
20
+ console.log('!value && !label');
21
+ if (hasNoMarkup && hasText) {
22
+ this.value = text;
23
+ this.label = text;
24
+ }
25
+ else {
26
+ throw new Error('box-option must have value and label attributes');
27
+ }
28
+ return;
29
+ }
30
+ if (value && !label) {
31
+ if (hasNoMarkup && hasText) {
32
+ this.label = text;
33
+ }
34
+ else {
35
+ this.label = value;
36
+ }
37
+ }
38
+ if (!value && label) {
39
+ this.value = label;
40
+ }
41
+ if (hasNoMarkup && !hasText) {
42
+ this.textContent = label || value;
15
43
  }
16
44
  }
17
45
  get value() {
18
46
  return this.getAttribute('value');
19
47
  }
20
48
  set value(value) {
21
- value = this.#getOrExtractValue(value, 'value');
22
- super.setAttribute('value', value);
49
+ super.setAttribute('value', String(value));
23
50
  }
24
51
  get label() {
25
- return this.getAttribute('value');
52
+ return this.getAttribute('label');
26
53
  }
27
54
  set label(value) {
28
- value = this.#getOrExtractValue(value, 'label');
29
- super.setAttribute('label', value);
55
+ super.setAttribute('label', String(value));
30
56
  }
31
57
  get selected() {
32
58
  return this.hasAttribute('selected');
@@ -35,61 +61,40 @@ class HTMLComboboxOptionElement extends HTMLElement {
35
61
  super.toggleAttribute('selected', (0, Boolean_attribute_value_normalizer_js_1.toBoolean)(value));
36
62
  }
37
63
  #initialAttributesSynchronization() {
38
- for (const key of HTMLComboboxOptionElement.booleanAttributes) {
64
+ for (const key of _a.booleanAttributes) {
39
65
  const value = (0, Boolean_attribute_value_normalizer_js_1.toBoolean)(this.getAttribute(key));
40
66
  Reflect.set(this, key, value);
41
67
  }
42
- for (const key of HTMLComboboxOptionElement.stringAttributes) {
43
- Reflect.set(this, key, this.getAttribute(key));
44
- }
45
- }
46
- get #optionHasOnlyTextNode() {
47
- return this.children.length === 0 && this.textContent.length > 0;
48
- }
49
- #getOrExtractValue(value, name) {
50
- if (typeof value === 'string')
51
- return value;
52
- if (value == null) {
53
- const opposite = name === 'label' ? 'value' : 'label';
54
- const oppositeValue = this.getAttribute(opposite);
55
- if (oppositeValue) {
56
- value = oppositeValue;
57
- }
58
- else {
59
- if (this.#optionHasOnlyTextNode) {
60
- value = this.textContent;
61
- }
62
- else {
63
- throw new TypeError('No value, or label or textContent found');
64
- }
68
+ for (const key of _a.stringAttributes) {
69
+ if (this.hasAttribute(key)) {
70
+ Reflect.set(this, key, this.getAttribute(key));
65
71
  }
66
- return value;
67
72
  }
68
- throw new TypeError('Invalid value');
69
73
  }
70
74
  setAttribute(name, value) {
71
- if (HTMLComboboxOptionElement.booleanAttributes.has(name)) {
75
+ if (_a.booleanAttributes.has(name)) {
72
76
  Reflect.set(this, name, (0, Boolean_attribute_value_normalizer_js_1.toBoolean)(value));
73
77
  return;
74
78
  }
75
- if (HTMLComboboxOptionElement.stringAttributes.has(name)) {
79
+ if (_a.stringAttributes.has(name)) {
76
80
  Reflect.set(this, name, value);
77
81
  return;
78
82
  }
79
83
  super.setAttribute(name, value);
80
84
  }
81
85
  removeAttribute(name) {
82
- if (HTMLComboboxOptionElement.stringAttributes.has(name)) {
86
+ if (_a.stringAttributes.has(name)) {
83
87
  Reflect.set(this, name, false);
84
88
  return;
85
89
  }
86
- if (HTMLComboboxOptionElement.stringAttributes.has(name)) {
90
+ if (_a.stringAttributes.has(name)) {
87
91
  return;
88
92
  }
89
93
  super.removeAttribute(name);
90
94
  }
91
95
  }
92
96
  exports.HTMLComboboxOptionElement = HTMLComboboxOptionElement;
97
+ _a = HTMLComboboxOptionElement;
93
98
  if (!window.customElements.get('box-option')) {
94
99
  window.customElements.define('box-option', HTMLComboboxOptionElement);
95
100
  }
package/dist/cjs/index.js CHANGED
@@ -1,4 +1,6 @@
1
1
  "use strict";
2
+ /// <reference types="solid-js" />
3
+ /// <reference types="preact" />
2
4
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
5
  if (k2 === undefined) k2 = k;
4
6
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -14,4 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
16
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
17
  };
16
18
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./HTML.combobox.element.js"), exports);
19
+ __exportStar(require("./combobox/index.js"), exports);
@@ -0,0 +1 @@
1
+ {"root":["../../src/index.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,3 +1,4 @@
1
+ /** Transform invalid (nullish or stringed) values to correct boolean value */
1
2
  export function toBoolean(value) {
2
3
  if (value == null || value === 'false' || value === false)
3
4
  value = false;
@@ -8,6 +8,7 @@ export class ComboboxMarkup {
8
8
  dropdown = null;
9
9
  placeholder = null;
10
10
  searchInput = null;
11
+ connected = false;
11
12
  constructor(shadowRoot, internals) {
12
13
  this.#shadowRoot = shadowRoot;
13
14
  this.#internals = internals;
@@ -18,24 +19,32 @@ export class ComboboxMarkup {
18
19
  document.addEventListener('scroll', this.onPageScroll);
19
20
  }
20
21
  connect() {
22
+ const placeholder = this.#shadowRoot.host.getAttribute('placeholder') || '';
21
23
  this.tagsContainer = this.#shadowRoot.querySelector('#tags');
22
24
  this.optionsContainer = this.#shadowRoot.querySelector('[part="options"]');
23
25
  this.clearAllButton = this.#shadowRoot.querySelector('[part="clear-all-button"]');
24
26
  this.dropdown = this.#shadowRoot.querySelector('#dropdown');
25
27
  this.placeholder = this.#shadowRoot.querySelector('#placeholder');
28
+ this.placeholder.innerText = placeholder;
26
29
  this.searchInput = this.#shadowRoot.querySelector('[part="search-input"]');
30
+ this.searchInput.value = this.#shadowRoot.host.getAttribute('query');
31
+ this.searchInput.placeholder = placeholder;
32
+ this.connected = true;
27
33
  }
28
34
  sort(query) {
29
35
  const regex = new RegExp(query, 'i');
30
36
  this.optionsContainer.querySelectorAll('box-option')
31
37
  .forEach(option => {
32
38
  if (query === '') {
39
+ // option.style.order = "unset";
33
40
  option.style.display = "initial";
34
41
  }
35
42
  else if (!regex.test(option.label)) {
43
+ // option.style.order = "-1";
36
44
  option.style.display = "none";
37
45
  }
38
46
  else {
47
+ // option.style.order = "unset";
39
48
  option.style.order = "initial";
40
49
  }
41
50
  });
@@ -46,6 +55,7 @@ export class ComboboxMarkup {
46
55
  this.#shadowRoot.host.removeEventListener('click', this.showDropdown);
47
56
  document.removeEventListener('click', this.hideDropdown);
48
57
  document.removeEventListener('scroll', this.onPageScroll);
58
+ this.connected = false;
49
59
  }
50
60
  onPageScroll = () => {
51
61
  if (this.dropdown.matches(':popover-open')) {
@@ -75,6 +85,7 @@ export class ComboboxMarkup {
75
85
  try {
76
86
  this.setDropdownPosition(this.#shadowRoot.host.getBoundingClientRect());
77
87
  this.dropdown.style.display = 'flex';
88
+ // @ts-ignore
78
89
  this.dropdown.showPopover();
79
90
  this.#internals.ariaExpanded = "true";
80
91
  }
@@ -86,6 +97,7 @@ export class ComboboxMarkup {
86
97
  if (event.composedPath().includes(this.#shadowRoot.host))
87
98
  return;
88
99
  try {
100
+ // @ts-ignore
89
101
  this.dropdown.hidePopover();
90
102
  this.dropdown.style.display = 'none';
91
103
  this.#internals.ariaExpanded = "false";
@@ -155,20 +167,23 @@ export class ComboboxMarkup {
155
167
  overflow-y: scroll;
156
168
  flex-direction: column;
157
169
  border-radius: inherit;
170
+ border-color: ButtonFace;
171
+ border-width: inherit;
158
172
  }
159
173
 
160
174
  [part="options"] {
161
175
  display: flex;
162
176
  flex-direction: column;
177
+ justify-content: start;
163
178
  gap: 2px;
164
179
  padding-block: .5rem;
165
180
  border-radius: inherit;
166
181
  }
167
182
 
168
183
  [part="options"] box-option {
184
+ display: flex;
169
185
  border-radius: inherit;
170
186
  content-visibility: auto;
171
- border: 1px solid cornflowerblue;
172
187
  }
173
188
 
174
189
  [part="options"] box-option[selected] {
@@ -192,6 +207,7 @@ export class ComboboxMarkup {
192
207
  }
193
208
 
194
209
  #placeholder {
210
+ text-align: left;
195
211
  overflow: hidden;
196
212
  }
197
213
 
@@ -212,7 +228,7 @@ export class ComboboxMarkup {
212
228
  border-radius: inherit;
213
229
  }
214
230
 
215
- [part="tag"] {
231
+ [part="box-tag"] {
216
232
  width: 100%;
217
233
  justify-self: start;
218
234
  font-size: inherit;
@@ -226,7 +242,7 @@ export class ComboboxMarkup {
226
242
  gap: 5px;
227
243
  }
228
244
 
229
- :host([multiple]) [part="tag"] {
245
+ :host([multiple]) [part="box-tag"] {
230
246
  background-color: Highlight;
231
247
  width: fit-content;
232
248
  max-width: 100%;
@@ -288,13 +304,14 @@ export class ComboboxMarkup {
288
304
  }
289
305
 
290
306
  :host:has(#tags:empty) [part="clear-all-button"] {
291
- /*display: none;*/
307
+ pointer-events: none;
308
+ color: darkgrey;
292
309
  }
293
310
 
294
311
  </style>
295
312
 
296
313
  <div id="tags"></div>
297
- <div id="placeholder" ></div>
314
+ <div id="placeholder">&nbsp;</div>
298
315
  <button part="clear-all-button">✕</button>
299
316
  <div id="dropdown" popover="manual">
300
317
  <input name="search-input" part="search-input" />