html-combobox-element 0.0.1 → 0.0.2-beta.10
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 +1 -0
- package/combobox-skill/SKILL.md +43 -0
- package/combobox-skill/custom-box-tag.md +17 -0
- package/combobox-skill/customization.md +23 -0
- package/combobox-skill/legacy-react-restrictions.md +14 -0
- package/combobox-skill/share-styles.md +17 -0
- package/dist/cjs/combobox/Combobox.markup.js +231 -123
- package/dist/cjs/combobox/HTML.combobox.element.js +189 -112
- package/dist/cjs/combobox/HTML.combobox.option.element.js +86 -5
- package/dist/cjs/combobox/HTML.combobox.tag.element.js +27 -7
- package/dist/cjs/index.js +0 -62
- package/dist/esm/combobox/Combobox.markup.js +231 -123
- package/dist/esm/combobox/HTML.combobox.element.js +189 -112
- package/dist/esm/combobox/HTML.combobox.option.element.js +86 -5
- package/dist/esm/combobox/HTML.combobox.tag.element.js +27 -7
- package/dist/esm/index.js +0 -62
- package/dist/types/combobox/Combobox.markup.d.ts +14 -8
- package/dist/types/combobox/Combobox.markup.d.ts.map +1 -1
- package/dist/types/combobox/HTML.combobox.element.d.ts +4 -3
- package/dist/types/combobox/HTML.combobox.element.d.ts.map +1 -1
- package/dist/types/combobox/HTML.combobox.option.element.d.ts +11 -0
- package/dist/types/combobox/HTML.combobox.option.element.d.ts.map +1 -1
- package/dist/types/combobox/HTML.combobox.tag.element.d.ts +9 -1
- package/dist/types/combobox/HTML.combobox.tag.element.d.ts.map +1 -1
- package/package.json +3 -2
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# html-combobox-element
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: HTMLComboboxElement
|
|
3
|
+
description: This element provides both "dropdown" or "combobox" functionality wia HTMLSelectElement compatible API, and it may be fully customized.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## References
|
|
7
|
+
- Consider that <combo-box> is the same as <select> (HTMLSelectElement), but uses <box-option> instead of <option>.
|
|
8
|
+
- Consider that <box-option> is the same as <option> (HTMLOptionElement), just fully customizable.
|
|
9
|
+
- Note that browsers interpret <combo-box> as a REAL form element.
|
|
10
|
+
- Additions that extends the <combo-box> "dropdown" functionality with "combobox" functionality are:
|
|
11
|
+
- attributes:
|
|
12
|
+
- filterable: If present, the search input in picker is shown, and during typing, <box-option>'s which textContent didn't match the input value are hidden.
|
|
13
|
+
- searchable: If present, the search input in picker is shown, to implement custom logic filtering, like server search, fuzzy matching, etc.
|
|
14
|
+
- clearable: If present, shows a remove button on each selected tag. If multiple is present, an additional clear-all button is shown.
|
|
15
|
+
- query: Controls the picker's search input value.
|
|
16
|
+
- events:
|
|
17
|
+
- input: Fires when user typing something in the picker search input.
|
|
18
|
+
- close: Fires when the picker closes.
|
|
19
|
+
- search: Fires when user presses Enter when the picker's search input is in focus.
|
|
20
|
+
- properties:
|
|
21
|
+
- changed: Readonly, boolean. Indicates whether the value has been changed after the picker has been opened.
|
|
22
|
+
- valueAsArray: Readonly, Array<string>. An array of value attributes from all selected <box-option> elements.
|
|
23
|
+
- Typescript:
|
|
24
|
+
- The HTMLComboboxElement, ComboboxEvent and ComboboxInputEvent interfaces are globally available and don't require import.
|
|
25
|
+
- The <combo-box>, <box-option> and <box-tag> are declared globally as valid JSX tags including props.
|
|
26
|
+
- Only if React < 19 is used, read the ./legacy-react-restrictions.md
|
|
27
|
+
- Only if you need fully custom <box-tag>, read the ./custom-box-tag.md
|
|
28
|
+
- Only if you need to customize the <combo-box>, read the ./customization.md
|
|
29
|
+
- Only if you need to share the project styles to the <combo-box>, read the ./share-styles.md.
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
## Constraints
|
|
33
|
+
- Changing the <combo-box> source code is strictly prohibited!
|
|
34
|
+
|
|
35
|
+
## Requirements
|
|
36
|
+
- Direct descendants of <combo-box> may be ONLY:
|
|
37
|
+
- <box-tag>: optional, max 1, must be first if present.
|
|
38
|
+
- <box-option>: zero or more, any position.
|
|
39
|
+
- <optgroup>: zero or more, any position with only <box-option> as direct descendants.
|
|
40
|
+
|
|
41
|
+
## Usage success criteria
|
|
42
|
+
- The constraints listed above are not violated.
|
|
43
|
+
- The requirements listed above are met.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: customization
|
|
3
|
+
description: Use this when you need fully custom tags for <combo-box> element.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## References
|
|
7
|
+
- Note that <box-tag> is a container with named slots.
|
|
8
|
+
- Note that <box-option> provides content for <box-tag> slots.
|
|
9
|
+
|
|
10
|
+
## Requirements
|
|
11
|
+
- The <box-tag> must contain a direct descendant with attribute `part="clear-tag"`.
|
|
12
|
+
- The <box-tag> slots must also define their part attribute for customization.
|
|
13
|
+
- The <box-tag> must be used only if a fully custom tag is needed.
|
|
14
|
+
- The <box-option> must still use part attribute for customization.
|
|
15
|
+
|
|
16
|
+
## Constraints
|
|
17
|
+
- Multiple <box-tag> descendants are prohibited.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: customization
|
|
3
|
+
description: Use this when you need to write CSS to customize the <combo-box> element.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## References
|
|
7
|
+
- The <combo-box> is a web-component with shadow root.
|
|
8
|
+
- The <combo-box> exposed parts are:
|
|
9
|
+
- internal: The container that arrange shadow root descendants.
|
|
10
|
+
- placeholder: Tag: <div>. Shown when there are no selected tags.
|
|
11
|
+
- tags: Tag: <div>. Selected tag's container.
|
|
12
|
+
- clear-all: Tag: <button>.
|
|
13
|
+
- dropdown: Tag: <div>. The <combo-box> picker implemented with Popover API.
|
|
14
|
+
- search-input: Tag: <input>. The picker's search input.
|
|
15
|
+
- options: Tag: <div>. A scrollable container for <box-option>'s.
|
|
16
|
+
- tag: Represent <box-tag>.
|
|
17
|
+
- tag-label: Tag: <span>. Alias to <box-tag> > tag-label. Displays the selected <box-option> label value.
|
|
18
|
+
- clear-tag: Tag: <div> with tabindex="0". Alias to <box-tag> > clear-tag.
|
|
19
|
+
- option: Represent <box-option>.
|
|
20
|
+
- option selected: Represent selected <box-option>.
|
|
21
|
+
|
|
22
|
+
## Constraints
|
|
23
|
+
- Interfere the <combo-box> styles without an explicit request from the user is strictly prohibited.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: legacy-react-restrictions
|
|
3
|
+
description: Use this when you need to use the <combo-box> in a legacy (i.e. less that 19v) React environment.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## References
|
|
7
|
+
- Note React <19 web-components events listeners limitations.
|
|
8
|
+
- Note that there are no special requirements for working with attributes.
|
|
9
|
+
|
|
10
|
+
## Requirements
|
|
11
|
+
- The legacy React event listener attachment must be used.
|
|
12
|
+
|
|
13
|
+
## Constraints
|
|
14
|
+
- Creating a wrapper around <combo-box> without an explicit request from the user is strictly prohibited.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: share-styles
|
|
3
|
+
description: Use this, when you need to share document/page styles to the <combo-box> shadow root.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## References
|
|
7
|
+
- The <combo-box> uses a constructed style sheet and shares it across all instances.
|
|
8
|
+
- Style sharing is achieved using one or both of two HTMLComboboxElement static methods:
|
|
9
|
+
- loadCssFromUrls(urls: string[]): adds urls as CSS @import directives to the constructed StyleSheet.
|
|
10
|
+
- loadCssFromDocumentStyleSheets(): the method internally WAITS until document fully load, and ONLY then inserts all document.styleSheets CSS rules into constructed StyleSheet.
|
|
11
|
+
|
|
12
|
+
## Requirements
|
|
13
|
+
- Styles must be shared once in the App root.
|
|
14
|
+
- The CSSStyleSheet.insertRule() parsing limitations must be taken into account.
|
|
15
|
+
|
|
16
|
+
## Constraints
|
|
17
|
+
- Sharing styles without an explicit request from the user is strictly prohibited.
|